@commet/node 5.5.0 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -779,7 +779,7 @@ var CommetValidationError = class extends CommetError {
|
|
|
779
779
|
|
|
780
780
|
// src/version.ts
|
|
781
781
|
var API_VERSION = "2026-05-25";
|
|
782
|
-
var SDK_VERSION = "5.5.
|
|
782
|
+
var SDK_VERSION = "5.5.1";
|
|
783
783
|
|
|
784
784
|
// src/utils/telemetry.ts
|
|
785
785
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|
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/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/transactions.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":["export { Commet, createCommet } from \"./client\";\nexport type {\n ActiveAddon,\n Addon,\n AddonConsumptionModel,\n BalanceAddon,\n BooleanAddon,\n CreateAddonParams,\n CreateBalanceAddonParams,\n CreateBooleanAddonParams,\n CreateCreditsAddonParams,\n CreateMeteredAddonParams,\n CreditsAddon,\n DeleteAddonParams,\n GetAddonParams,\n ListActiveAddonsParams,\n ListAddonsParams,\n MeteredAddon,\n UpdateAddonParams,\n} from \"./resources/addons\";\nexport type {\n ApiKey,\n ApiKeyCreated,\n CreateApiKeyParams,\n DeleteApiKeyParams,\n ListApiKeysParams,\n} from \"./resources/api-keys\";\nexport type {\n CreateCreditPackParams,\n CreditPack,\n CreditPackDetail,\n DeleteCreditPackParams,\n UpdateCreditPackParams,\n} from \"./resources/credit-packs\";\nexport type {\n BatchResult as CustomersBatchResult,\n CreateParams as CreateCustomerParams,\n Customer,\n CustomerAddress,\n GetCustomerParams,\n ListCustomersParams,\n UpdateParams as UpdateCustomerParams,\n} from \"./resources/customers\";\nexport type {\n CanUseFeatureParams,\n CanUseResult,\n CreateFeatureParams,\n DeleteFeatureParams,\n Feature,\n FeatureAccess,\n GetFeatureParams,\n ListFeaturesParams,\n UpdateFeatureParams,\n} from \"./resources/features\";\nexport type {\n ChargeType,\n CreateAdjustmentParams,\n CreateAdjustmentResult,\n GetDownloadUrlParams,\n GetInvoiceParams,\n InvoiceDetail,\n InvoiceDownloadResult,\n InvoiceLineItem,\n InvoiceLineType,\n InvoiceListItem,\n InvoiceSendResult,\n InvoiceStatus,\n InvoiceStatusResult,\n InvoiceType,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n AddPlanToGroupParams,\n CreatePlanGroupParams,\n DeletePlanGroupParams,\n GetPlanGroupParams,\n ListPlanGroupsParams,\n PlanGroup,\n PlanGroupDetail,\n RemovePlanFromGroupParams,\n ReorderPlansParams,\n UpdatePlanGroupParams,\n} from \"./resources/plan-groups\";\nexport type {\n AddAiModelPricingFeatureParams,\n AddFixedPricingFeatureParams,\n AddPlanFeatureParams,\n AddPlanPriceParams,\n AiModelPricingFeatureManage,\n BillingInterval,\n ConsumptionModel,\n CreatePlanParams,\n DeletePlanParams,\n DeletePlanPriceParams,\n DeleteRegionalPricesParams,\n DeleteResult,\n DiscountType,\n FeatureType,\n FixedPricingFeatureManage,\n ListPlansParams,\n Plan,\n PlanDetail,\n PlanFeature,\n PlanFeatureManage,\n PlanID,\n PlanManage,\n PlanPrice,\n PlanPriceManage,\n RegionalPriceResult,\n RemovePlanFeatureParams,\n RemoveResult,\n SetDefaultPriceParams,\n SetRegionalPricesParams,\n SetVisibilityParams,\n UpdatePlanFeatureParams,\n UpdatePlanParams,\n UpdatePlanPriceParams,\n} from \"./resources/plans\";\nexport type { GetUrlParams, PortalAccess } from \"./resources/portal\";\nexport type {\n CreatePromoCodeParams,\n GetPromoCodeParams,\n ListPromoCodesParams,\n PromoCode,\n PromoCodeDetail,\n UpdatePromoCodeParams,\n} from \"./resources/promo-codes\";\nexport type {\n AddQuotaParams,\n GetAllQuotaParams,\n GetQuotaParams,\n QuotaAllowance,\n QuotaEvent,\n RemoveQuotaParams,\n SetQuotaParams,\n} from \"./resources/quota\";\nexport type {\n AddSeatsParams,\n GetAllBalancesParams,\n GetBalanceParams,\n RemoveSeatsParams,\n SeatBalance,\n SeatEvent,\n SetAllSeatsParams,\n SetSeatsParams,\n} from \"./resources/seats\";\nexport type {\n ActivateAddonParams,\n ActivateAddonResult,\n ActiveSubscription,\n AdjustBalanceParams,\n AdjustBalanceResult,\n CancellationSummary,\n CancelParams,\n ChangePlanParams,\n ChangePlanResult,\n CreatedSubscription,\n CreateSubscriptionParams,\n CustomIntroOffer,\n DeactivateAddonParams,\n DeactivateAddonResult,\n DiscountSummary,\n FeatureSummary,\n GetActiveParams,\n ListSubscriptionsParams,\n PreviewChangeParams,\n PreviewChangeResult,\n PurchaseCreditsParams,\n PurchaseCreditsResult,\n Subscription,\n SubscriptionListItem,\n SubscriptionStatus,\n TopupBalanceParams,\n TopupBalanceResult,\n UncancelParams,\n} from \"./resources/subscriptions\";\nexport type {\n GetTransactionParams,\n ListTransactionsParams,\n RefundTransactionParams,\n RetryTransactionParams,\n TransactionDetail,\n TransactionListItem,\n TransactionRefundResult,\n TransactionRetryResult,\n TransactionStatus,\n} from \"./resources/transactions\";\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 { registerIntegration } from \"./utils/telemetry\";\nexport { API_VERSION, SDK_VERSION } from \"./version\";\n\nimport { Commet } from \"./client\";\nexport default Commet;\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport type AddonConsumptionModel =\n | \"boolean\"\n | \"metered\"\n | \"credits\"\n | \"balance\";\n\nexport interface ActiveAddon {\n object: \"addon\";\n livemode: boolean;\n slug: string;\n name: string;\n basePrice: number;\n featureCode: string;\n featureName: string;\n featureType: FeatureType;\n consumptionModel: AddonConsumptionModel | null;\n activatedAt: string;\n}\n\nexport interface ListActiveAddonsParams {\n customerId: CustomerID;\n}\n\ninterface AddonBase {\n id: string;\n object: \"addon\";\n livemode: boolean;\n name: string;\n slug: string;\n description: string | null;\n basePrice: number;\n featureCode: string;\n featureName: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface BooleanAddon extends AddonBase {\n consumptionModel: \"boolean\";\n includedUnits: null;\n overageRate: null;\n creditCost: null;\n}\n\nexport interface MeteredAddon extends AddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n creditCost: null;\n}\n\nexport interface CreditsAddon extends AddonBase {\n consumptionModel: \"credits\";\n includedUnits: null;\n overageRate: null;\n creditCost: number;\n}\n\nexport interface BalanceAddon extends AddonBase {\n consumptionModel: \"balance\";\n includedUnits: null;\n overageRate: number;\n creditCost: null;\n}\n\nexport type Addon = BooleanAddon | MeteredAddon | CreditsAddon | BalanceAddon;\n\nexport interface ListAddonsParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\ninterface CreateAddonBase {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n}\n\nexport interface CreateBooleanAddonParams extends CreateAddonBase {\n consumptionModel: \"boolean\";\n}\n\nexport interface CreateMeteredAddonParams extends CreateAddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n}\n\nexport interface CreateCreditsAddonParams extends CreateAddonBase {\n consumptionModel: \"credits\";\n creditCost: number;\n}\n\nexport interface CreateBalanceAddonParams extends CreateAddonBase {\n consumptionModel: \"balance\";\n overageRate: number;\n}\n\nexport type CreateAddonParams =\n | CreateBooleanAddonParams\n | CreateMeteredAddonParams\n | CreateCreditsAddonParams\n | CreateBalanceAddonParams;\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 async listActive(\n params: ListActiveAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActiveAddon[]>> {\n return this.httpClient.get(\n \"/addons/active\",\n { customerId: params.customerId },\n options,\n );\n }\n\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon[]>> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\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 async create(\n params: CreateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/addons/${id}`, body, options);\n }\n\n /** Fails if addon has active subscriptions. */\n async delete(\n params: DeleteAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ApiKey {\n id: string;\n object: \"api_key\";\n livemode: boolean;\n name: string;\n prefix: string;\n expiresAt: string | null;\n lastUsedAt: string | null;\n createdAt: string;\n}\n\nexport interface ApiKeyCreated extends ApiKey {\n apiKey: string;\n}\n\nexport interface ListApiKeysParams {\n limit?: number;\n cursor?: string;\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 async list(params?: ListApiKeysParams): Promise<ApiResponse<ApiKey[]>> {\n return this.httpClient.get(\"/api-keys\", params);\n }\n\n /** Response includes full `apiKey` which is only returned once. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ApiKeyCreated>> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(`/api-keys/${params.id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CreditPack {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n currency: string;\n}\n\nexport interface CreditPackDetail {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n isActive: boolean;\n createdAt: string;\n updatedAt: string;\n}\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 async list(): Promise<ApiResponse<CreditPack[]>> {\n return this.httpClient.get(\"/credit-packs\");\n }\n\n async create(\n params: CreateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n return this.httpClient.post(\"/credit-packs/manage\", params, options);\n }\n\n async update(\n params: UpdateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/credit-packs/${id}`, body, options);\n }\n\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n}\n","import type {\n ApiResponse,\n ListParams as BaseListParams,\n CustomerID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Customer {\n id: CustomerID;\n object: \"customer\";\n livemode: boolean;\n organizationId: string;\n fullName?: string;\n domain?: string;\n website?: string;\n billingEmail: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n}\n\nexport interface CreateParams {\n email: string; // billingEmail - the only required field\n id?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface GetCustomerParams {\n id: CustomerID;\n}\n\nexport interface UpdateParams {\n id: CustomerID;\n email?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface ListCustomersParams extends BaseListParams {\n search?: string;\n}\n\nexport interface BatchResult {\n successful: Customer[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateParams;\n }>;\n}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Idempotent when `id` is provided — returns existing customer instead of duplicating. */\n async create(\n params: CreateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\n \"/customers\",\n {\n billingEmail: params.email,\n id: params.id,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async createBatch(\n params: { customers: CreateParams[] },\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult>> {\n const customers = params.customers.map((c) => ({\n billingEmail: c.email,\n id: c.id,\n fullName: c.fullName,\n domain: c.domain,\n website: c.website,\n timezone: c.timezone,\n language: c.language,\n industry: c.industry,\n metadata: c.metadata,\n address: c.address,\n }));\n return this.httpClient.post(\"/customers/batch\", { customers }, options);\n }\n\n async get(params: GetCustomerParams): Promise<ApiResponse<Customer>> {\n return this.httpClient.get(`/customers/${params.id}`);\n }\n\n async update(\n params: UpdateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${params.id}`,\n {\n billingEmail: params.email,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params as Record<string, unknown>);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport interface GetFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface CanUseFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface ListFeaturesParams {\n customerId: CustomerID;\n}\n\nexport interface FeatureAccess {\n object: \"feature\";\n livemode: boolean;\n code: string;\n name: string;\n type: FeatureType;\n allowed: boolean;\n enabled?: boolean;\n current?: number;\n included?: number;\n remaining?: number;\n overage?: number;\n overageUnitPrice?: number;\n billedQuantity?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n}\n\nexport interface CanUseResult {\n allowed: boolean;\n willBeCharged: boolean;\n reason?: string;\n}\n\nexport interface Feature {\n id: string;\n object: \"feature\";\n livemode: boolean;\n name: string;\n code: string;\n type: FeatureType;\n description: string | null;\n unitName: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreateFeatureParams {\n code: string;\n name: string;\n type: FeatureType;\n description?: string;\n unitName?: string;\n}\n\nexport interface UpdateFeatureParams {\n code: string;\n name?: string;\n description?: string;\n unitName?: string;\n}\n\nexport interface DeleteFeatureParams {\n code: string;\n}\n\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async get(\n params: GetFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId },\n options,\n );\n }\n\n /** Checks if the customer can consume one more unit — returns billing impact and reason if blocked. */\n async canUse(\n params: CanUseFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanUseResult>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId, action: \"canUse\" },\n options,\n );\n }\n\n async list(\n params: ListFeaturesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess[]>> {\n return this.httpClient.get(\n \"/features\",\n { customerId: params.customerId },\n options,\n );\n }\n\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 async update(\n params: UpdateFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Feature>> {\n const { code, ...body } = params;\n return this.httpClient.put(`/features/${code}/manage`, body, options);\n }\n\n /** Fails if feature is attached to active plans or has an active addon. */\n async delete(\n params: DeleteFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { DiscountType } from \"./plans\";\n\nexport type InvoiceStatus =\n | \"draft\"\n | \"upcoming\"\n | \"outstanding\"\n | \"paid\"\n | \"void\"\n | \"uncollectible\";\nexport type InvoiceType =\n | \"recurring\"\n | \"overage\"\n | \"plan_change\"\n | \"adjustment\"\n | \"credit_purchase\"\n | \"balance_topup\"\n | \"addon_activation\";\nexport type InvoiceLineType =\n | \"plan_base\"\n | \"feature_overage\"\n | \"feature_seats\"\n | \"feature_quota\"\n | \"discount\"\n | \"credit\"\n | \"addon_base\";\nexport type ChargeType = \"standard\" | \"advance\" | \"true_up\";\n\nexport interface InvoiceLineItem {\n lineType: InvoiceLineType;\n featureName: string | null;\n description: string | null;\n quantity: number;\n unitAmount: number;\n amount: number;\n includedAmount: number | null;\n usedAmount: number | null;\n overageAmount: number | null;\n discountType: DiscountType | null;\n discountValue: number | null;\n discountName: string | null;\n chargeType: ChargeType | null;\n}\n\nexport interface InvoiceListItem {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n subscriptionId: string | null;\n invoiceNumber: string;\n status: InvoiceStatus;\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n discountAmount: number;\n taxAmount: number;\n total: number;\n periodStart: string | null;\n periodEnd: string | null;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface InvoiceDetail extends InvoiceListItem {\n creditApplied: number;\n planName: string | null;\n poNumber: string | null;\n reference: string | null;\n lineItems: InvoiceLineItem[];\n}\n\nexport interface InvoiceDownloadResult {\n url: string;\n expiresAt: string;\n}\n\nexport interface InvoiceSendResult {\n sent: boolean;\n sentAt: string;\n}\n\nexport interface InvoiceStatusResult {\n id: string;\n status: \"paid\" | \"void\";\n updatedAt: string;\n}\n\nexport interface CreateAdjustmentResult {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n invoiceNumber: string;\n status: \"outstanding\" | \"paid\";\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n taxAmount: number;\n total: number;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListInvoicesParams {\n customerId?: string;\n status?: InvoiceStatus;\n subscriptionId?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface CreateAdjustmentParams {\n customerId: string;\n amount: number;\n description?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface GetDownloadUrlParams {\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 async list(\n params?: ListInvoicesParams,\n ): Promise<ApiResponse<InvoiceListItem[]>> {\n return this.httpClient.get(\"/invoices\", params);\n }\n\n async get(params: GetInvoiceParams): Promise<ApiResponse<InvoiceDetail>> {\n return this.httpClient.get(`/invoices/${params.id}`);\n }\n\n /** Negative amount creates a credit. */\n async createAdjustment(\n params: CreateAdjustmentParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreateAdjustmentResult>> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\n\n /** Signed URL, expires after 7 days. */\n async getDownloadUrl(\n params: GetDownloadUrlParams,\n ): Promise<ApiResponse<InvoiceDownloadResult>> {\n return this.httpClient.get(`/invoices/${params.id}/download`);\n }\n\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceSendResult>> {\n return this.httpClient.post(`/invoices/${params.id}/send`, {}, options);\n }\n\n /** Only outstanding invoices can be changed to paid or void. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceStatusResult>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/invoices/${id}/status`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PlanGroup {\n id: string;\n object: \"plan_group\";\n livemode: boolean;\n name: string;\n description: string | null;\n isPublic: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PlanGroupDetail extends PlanGroup {\n plans: Array<{ id: string; code: string; name: string; sortOrder: number }>;\n}\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;\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 ReorderPlansParams {\n id: string;\n planIds: string[];\n}\n\nexport class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlanGroupsParams): Promise<ApiResponse<PlanGroup[]>> {\n return this.httpClient.get(\"/plan-groups\", params);\n }\n\n async get(params: GetPlanGroupParams): Promise<ApiResponse<PlanGroupDetail>> {\n return this.httpClient.get(`/plan-groups/${params.id}`);\n }\n\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 async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroup>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plan-groups/${id}`, body, options);\n }\n\n /** Plans in the group are unlinked, not deleted. */\n async delete(\n params: DeletePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(\n `/plan-groups/${params.id}`,\n undefined,\n options,\n );\n }\n\n async addPlan(\n params: AddPlanToGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, body, options);\n }\n\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n const { id, planId } = params;\n return this.httpClient.delete(\n `/plan-groups/${id}/plans/${planId}`,\n undefined,\n options,\n );\n }\n\n async reorderPlans(\n params: ReorderPlansParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(\n `/plan-groups/${id}/plans/reorder`,\n body,\n options,\n );\n }\n}\n","import type { ApiResponse, ListParams, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PlanID = `plan_${string}`;\nexport type BillingInterval =\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"yearly\"\n | \"one_time\";\nexport type FeatureType = \"boolean\" | \"usage\" | \"seats\" | \"quota\";\nexport type ConsumptionModel = \"metered\" | \"credits\" | \"balance\";\nexport type DiscountType = \"percentage\" | \"amount\";\n\nexport interface PlanPrice {\n billingInterval: BillingInterval;\n price: number; // in cents\n isDefault: boolean;\n trialDays: number;\n}\n\nexport interface PlanFeature {\n code: string;\n name: string;\n type: FeatureType;\n unitName: string | null;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n overageUnitPrice?: number;\n}\n\nexport interface Plan {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isFree: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanPrice[];\n features: PlanFeature[];\n createdAt: string;\n}\n\nexport interface PlanDetailPrice {\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n introOffer: {\n enabled: boolean;\n discountType: DiscountType | null;\n discountValue: number | null;\n durationCycles: number | null;\n } | null;\n}\n\nexport interface PlanDetailFeature extends PlanFeature {\n overage: {\n enabled: boolean;\n model: \"per_unit\" | null;\n unitPrice: number | null;\n } | null;\n}\n\nexport interface PlanDetail {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanDetailPrice[];\n features: PlanDetailFeature[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListPlansParams extends ListParams {\n includePrivate?: boolean;\n}\n\nexport interface PlanManage {\n id: string;\n object: \"plan\";\n livemode: boolean;\n name: string;\n code: string;\n description: string | null;\n consumptionModel: ConsumptionModel | null;\n isPublic: boolean;\n isDefault: boolean;\n isFree: boolean;\n blockOnExhaustion: boolean;\n sortOrder: number;\n planGroupId: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface PlanFeatureManageBase {\n planId: string;\n featureId: string;\n enabled: boolean;\n includedAmount: number | null;\n unlimited: boolean;\n overageEnabled: boolean;\n creditsPerUnit: number | null;\n}\n\nexport interface FixedPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"fixed\";\n overageUnitPrice: number | null;\n margin: null;\n}\n\nexport interface AiModelPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"ai_model\";\n margin: number;\n overageUnitPrice: null;\n}\n\nexport type PlanFeatureManage =\n | FixedPricingFeatureManage\n | AiModelPricingFeatureManage;\n\nexport interface PlanPriceManage {\n id: string;\n object: \"plan_price\";\n livemode: boolean;\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n includedBalance: number | null;\n includedCredits: number | null;\n introOfferEnabled: boolean;\n introOfferDiscountType: DiscountType | null;\n introOfferDiscountValue: number | null;\n introOfferDurationCycles: number | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RegionalPriceResult {\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteResult {\n id: string;\n deleted: true;\n}\n\nexport interface RemoveResult {\n id: string;\n removed: true;\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;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface SetVisibilityParams {\n id: string;\n isPublic: boolean;\n}\n\ninterface AddPlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface AddFixedPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface AddAiModelPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode: \"ai_model\";\n margin: number;\n}\n\nexport type AddPlanFeatureParams =\n | AddFixedPricingFeatureParams\n | AddAiModelPricingFeatureParams;\n\ninterface UpdatePlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface UpdateFixedPricingFeatureParams extends UpdatePlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface UpdateAiModelPricingFeatureParams\n extends UpdatePlanFeatureBase {\n pricingMode: \"ai_model\";\n margin?: number;\n}\n\nexport type UpdatePlanFeatureParams =\n | UpdateFixedPricingFeatureParams\n | UpdateAiModelPricingFeatureParams;\n\nexport interface RemovePlanFeatureParams {\n planId: string;\n featureId: string;\n}\n\nexport interface AddPlanPriceParams {\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n trialDays?: number;\n isDefault?: boolean;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\";\n introOfferDiscountValue?: number;\n introOfferDurationCycles?: number;\n}\n\nexport interface UpdatePlanPriceParams {\n planId: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue?: number | null;\n introOfferDurationCycles?: number | null;\n}\n\nexport interface DeletePlanPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetDefaultPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetRegionalPricesParams {\n planId: string;\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n planId: string;\n priceId: string;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>> {\n return this.httpClient.get(\"/plans\", params);\n }\n\n async get(params: { id: string }): Promise<ApiResponse<PlanDetail>> {\n return this.httpClient.get(`/plans/${params.id}`);\n }\n\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n return this.httpClient.post(\"/plans/manage\", params, options);\n }\n\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/manage`, body, options);\n }\n\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n return this.httpClient.delete(\n `/plans/${params.id}/manage`,\n undefined,\n options,\n );\n }\n\n async setVisibility(\n params: SetVisibilityParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, body, options);\n }\n\n async addFeature(\n params: AddPlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/features`, body, options);\n }\n\n async updateFeature(\n params: UpdatePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, featureId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/features/${featureId}`,\n body,\n options,\n );\n }\n\n async removeFeature(\n params: RemovePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RemoveResult>> {\n const { planId, featureId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/prices`, body, options);\n }\n\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}`,\n body,\n options,\n );\n }\n\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n async setDefaultPrice(\n params: SetDefaultPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/default`,\n {},\n options,\n );\n }\n\n async setRegionalPrices(\n params: SetRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RegionalPriceResult>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/regional`,\n body,\n options,\n );\n }\n\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}/regional`,\n undefined,\n options,\n );\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PortalAccess {\n success: boolean;\n message: string;\n portalUrl: string;\n}\n\ninterface GetUrlByCustomerId {\n customerId: CustomerID;\n email?: never;\n}\n\ninterface GetUrlByEmail {\n email: string;\n customerId?: never;\n}\n\nexport type GetUrlParams = GetUrlByCustomerId | GetUrlByEmail;\n\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async getUrl(\n params: GetUrlParams,\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PromoCode {\n id: string;\n object: \"promo_code\";\n livemode: boolean;\n code: string;\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number | null;\n maxRedemptions: number | null;\n expiresAt: string | null;\n active: boolean;\n redemptionCount: number;\n createdAt: string;\n}\n\nexport interface PromoCodeDetail extends PromoCode {\n updatedAt: string;\n}\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: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles?: number;\n maxRedemptions?: number;\n expiresAt?: string;\n planIds?: string[];\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n maxRedemptions?: number;\n expiresAt?: string;\n active?: boolean;\n planIds?: string[];\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPromoCodesParams): Promise<ApiResponse<PromoCode[]>> {\n return this.httpClient.get(\"/promo-codes\", params);\n }\n\n async get(params: GetPromoCodeParams): Promise<ApiResponse<PromoCodeDetail>> {\n return this.httpClient.get(`/promo-codes/${params.id}`);\n }\n\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCode>> {\n return this.httpClient.post(\"/promo-codes\", params, options);\n }\n\n async update(\n params: UpdatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCodeDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/promo-codes/${id}`, body, options);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface QuotaEvent {\n id: string;\n customerId: CustomerID;\n featureCode: string;\n previousBalance: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface QuotaAllowance {\n featureCode: string;\n current: number;\n included: number;\n remaining: number | null;\n billedQuantity?: number;\n unlimited: boolean;\n overageEnabled: boolean;\n asOf: string | null;\n}\n\nexport interface AddQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface RemoveQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface GetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllQuotaParams {\n customerId: CustomerID;\n}\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.post(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.put(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.delete(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async get(params: GetQuotaParams): Promise<ApiResponse<QuotaAllowance>> {\n return this.httpClient.get(\"/usage/quota\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAll(\n params: GetAllQuotaParams,\n ): Promise<ApiResponse<QuotaAllowance[]>> {\n return this.httpClient.get(\"/usage/quota/all\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatEvent {\n id: string;\n object: \"seat\";\n livemode: boolean;\n organizationId: string;\n customerId: CustomerID;\n featureCode: string;\n eventType: \"add\" | \"remove\" | \"set\";\n quantity: number;\n previousBalance?: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface SeatBalance {\n current: number;\n asOf: string;\n}\n\nexport interface AddSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface SetAllSeatsParams {\n customerId: CustomerID;\n seats: Record<string, number>;\n}\n\nexport interface GetBalanceParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllBalancesParams {\n customerId: CustomerID;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n /** Removal 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async setAll(\n params: SetAllSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalance>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalance>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { BillingInterval, ConsumptionModel, FeatureType } from \"./plans\";\n\nexport type SubscriptionStatus =\n | \"draft\"\n | \"pending_payment\"\n | \"trialing\"\n | \"active\"\n | \"paused\"\n | \"past_due\"\n | \"canceled\"\n | \"expired\";\n\nexport interface FeatureSummary {\n code: string;\n name: string;\n type: FeatureType;\n enabled?: boolean;\n usage?: {\n current: number;\n included: number;\n overage: number;\n overageUnitPrice?: number;\n };\n}\n\nexport interface CreditsSummary {\n remaining: number;\n included: number;\n purchased: number;\n}\n\nexport interface BalanceSummary {\n remaining: number;\n included: number;\n currency: string;\n}\n\nexport interface CancellationSummary {\n scheduledAt: string;\n reason: string | null;\n effectiveAt: string;\n}\n\nexport interface DiscountSummary {\n type: \"percentage\" | \"amount\";\n value: number;\n name: string | null;\n endsAt: string | null;\n}\n\nexport interface ActiveSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n plan: {\n id: string;\n name: string;\n basePrice: number;\n billingInterval: BillingInterval | null;\n };\n name: string;\n description: string | null;\n status: SubscriptionStatus;\n consumptionModel: ConsumptionModel | null;\n trialEndsAt: string | null;\n currentPeriod: {\n start: string;\n end: string;\n daysRemaining: number;\n };\n features: FeatureSummary[];\n credits: CreditsSummary | null;\n balance: BalanceSummary | null;\n cancellation: CancellationSummary | null;\n discount: DiscountSummary | null;\n startDate: string;\n endDate: string | null;\n billingDayOfMonth: number;\n nextBillingDate: string;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreatedSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval | null;\n trialEndsAt: string | null;\n startDate: string;\n endDate: string | null;\n currentPeriodStart: string | null;\n currentPeriodEnd: string | null;\n billingDayOfMonth: number;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n introOfferEndsAt: string | null;\n introOfferDiscountType: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue: number | null;\n}\n\nexport interface Subscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n description?: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval;\n trialEndsAt?: string;\n startDate: string;\n endDate?: string;\n currentPeriodStart?: string;\n currentPeriodEnd?: string;\n billingDayOfMonth: number;\n checkoutUrl?: string;\n createdAt: string;\n updatedAt: string;\n}\n\ntype PlanIdentifier =\n | { planCode: string; planId?: never }\n | { planCode?: never; planId: string };\n\nexport interface CustomIntroOffer {\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number;\n}\n\nexport type CreateSubscriptionParams = PlanIdentifier & {\n customerId: string;\n} & {\n billingInterval?: BillingInterval;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n name?: string;\n startDate?: string;\n successUrl?: string;\n customIntroOffer?: CustomIntroOffer;\n};\n\nexport interface GetActiveParams {\n customerId: string;\n}\n\nexport interface CancelParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport interface UncancelParams {\n id: string;\n}\n\nexport interface ChangePlanParams {\n id: string;\n newPlanId?: string;\n newBillingInterval?: BillingInterval;\n /** Where to redirect after checkout when a free→paid change requires payment. */\n successUrl?: string;\n}\n\nexport interface ChangePlanResult {\n id: string;\n scheduled: boolean;\n customerId?: string;\n previousPlan?: { id: string; name: string };\n currentPlan?: { id: string; name: string; price: number };\n billingInterval?: string;\n billing?: {\n credit: number;\n creditsApplied: number;\n charge: number;\n taxAmount: number;\n netAmount: number;\n totalCharged: number;\n remainingCreditBalance: number;\n };\n invoiceId?: string;\n scheduledFor?: string;\n changeType?: string;\n requiresCheckout?: boolean;\n checkoutUrl?: string;\n}\n\nexport interface ListSubscriptionsParams extends Record<string, unknown> {\n customerId?: string;\n status?: SubscriptionStatus;\n limit?: number;\n cursor?: string;\n}\n\nexport interface SubscriptionListItem {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n startDate: string;\n endDate: string;\n billingDayOfMonth: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PreviewChangeParams {\n id: string;\n planId?: string;\n billingInterval?: BillingInterval;\n}\n\nexport interface PreviewChangeResult {\n currentPlanCredit: number;\n newPlanCharge: number;\n estimatedTotal: number;\n effectiveDate: string;\n daysRemaining: number;\n totalDays: number;\n isUpgrade: boolean;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface ActivateAddonResult {\n addonId: string;\n status: string;\n proratedCharge: number;\n}\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface DeactivateAddonResult {\n id: string;\n status: string;\n deactivatedAt: string;\n}\n\nexport interface AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"balance\" | \"credits\";\n}\n\nexport interface AdjustBalanceResult {\n amount: number;\n newBalance: number;\n reason: string | null;\n}\n\nexport interface TopupBalanceParams {\n id: string;\n amount: number;\n}\n\nexport interface TopupBalanceResult {\n amount: number;\n}\n\nexport interface PurchaseCreditsParams {\n id: string;\n creditPackId: string;\n}\n\nexport interface PurchaseCreditsResult {\n credits: number;\n}\n\n/** Each customer can only have one active subscription at a time. */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Returns a `checkoutUrl` when payment is required before activation. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreatedSubscription>> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n\n async getActive(\n params: GetActiveParams,\n ): Promise<ApiResponse<ActiveSubscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", {\n customerId: params.customerId,\n });\n }\n\n /** Schedules cancellation at period end by default. Set `immediate: true` to cancel now. */\n async cancel(\n params: CancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, body, options);\n }\n\n /** Only works on subscriptions with a pending cancellation — cannot revert already-canceled. */\n async uncancel(\n params: UncancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${params.id}/uncancel`,\n {},\n options,\n );\n }\n\n /** Upgrades execute immediately with proration. Downgrades are scheduled for end of period. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ChangePlanResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n body,\n options,\n );\n }\n\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<SubscriptionListItem[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /** Dry-run: returns proration details without applying the change. */\n async previewChange(\n params: PreviewChangeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PreviewChangeResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n body,\n options,\n );\n }\n\n /** Prorated charge for the current billing period. */\n async activateAddon(\n params: ActivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActivateAddonResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, body, options);\n }\n\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeactivateAddonResult>> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\n options,\n );\n }\n\n /** Positive amount adds, negative subtracts. */\n async adjustBalance(\n params: AdjustBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<AdjustBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/adjust`,\n body,\n options,\n );\n }\n\n /** Charges the customer's payment method. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TopupBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n body,\n options,\n );\n }\n\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PurchaseCreditsResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type TransactionStatus =\n | \"pending\"\n | \"succeeded\"\n | \"failed\"\n | \"refunded\"\n | \"disputed\";\n\nexport interface TransactionListItem {\n id: string;\n object: \"transaction\";\n livemode: boolean;\n invoiceId: string;\n grossAmount: number;\n subtotal: number;\n taxAmount: number;\n currency: string;\n status: TransactionStatus;\n customerEmail: string;\n customerName: string | null;\n paidAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface TransactionDetail extends TransactionListItem {\n availableAt: string | null;\n}\n\nexport interface TransactionRefundResult {\n id: string;\n status: \"refunded\";\n}\n\nexport interface TransactionRetryResult {\n id: string;\n status: \"processing\";\n retryInvoiceNumber: string;\n}\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 async list(\n params?: ListTransactionsParams,\n ): Promise<ApiResponse<TransactionListItem[]>> {\n return this.httpClient.get(\"/transactions\", params);\n }\n\n async get(\n params: GetTransactionParams,\n ): Promise<ApiResponse<TransactionDetail>> {\n return this.httpClient.get(`/transactions/${params.id}`);\n }\n\n /** Full refund only. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRefundResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/refund`,\n {},\n options,\n );\n }\n\n /** Creates a new invoice and initiates a new payment attempt. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRetryResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/retry`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { ConsumptionModel } from \"./plans\";\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { SubscriptionStatus } from \"./subscriptions\";\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-05-25\";\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 { 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 { 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 { TransactionsResource } from \"./resources/transactions\";\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> {\n private httpClient: CommetHTTPClient;\n\n public readonly addons: AddonsResource;\n public readonly apiKeys: ApiKeysResource;\n public readonly creditPacks: CreditPacksResource;\n public readonly customers: CustomersResource;\n public readonly features: FeaturesResource;\n public readonly invoices: InvoicesResource;\n public readonly planGroups: PlanGroupsResource;\n public readonly plans: PlansResource;\n public readonly portal: PortalResource;\n public readonly promoCodes: PromoCodesResource;\n public readonly quota: QuotaResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\n public readonly transactions: TransactionsResource;\n public readonly usage: UsageResource;\n public readonly webhooks: Webhooks;\n\n constructor(config: CommetClientOptions) {\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.addons = new AddonsResource(this.httpClient);\n this.apiKeys = new ApiKeysResource(this.httpClient);\n this.creditPacks = new CreditPacksResource(this.httpClient);\n this.customers = new CustomersResource(this.httpClient);\n this.features = new FeaturesResource(this.httpClient);\n this.invoices = new InvoicesResource(this.httpClient);\n this.planGroups = new PlanGroupsResource(this.httpClient);\n this.plans = new PlansResource(this.httpClient);\n this.portal = new PortalResource(this.httpClient);\n this.promoCodes = new PromoCodesResource(this.httpClient);\n this.quota = new QuotaResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(this.httpClient);\n this.transactions = new TransactionsResource(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;;;AC8HO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA,EAEnD,MAAM,WACJ,QACA,SACqC;AACrC,WAAO,KAAK,WAAW;AAAA,MACrB;AAAA,MACA,EAAE,YAAY,OAAO,WAAW;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,KACJ,QACA,SAC+B;AAC/B,WAAO,KAAK,WAAW,IAAI,WAAW,QAAQ,OAAO;AAAA,EACvD;AAAA,EAEA,MAAM,IACJ,QACA,SAC6B;AAC7B,UAAM,EAAE,GAAG,IAAI;AACf,WAAO,KAAK,WAAW,IAAI,WAAW,EAAE,IAAI,QAAW,OAAO;AAAA,EAChE;AAAA,EAEA,MAAM,OACJ,QACA,SAC6B;AAC7B,WAAO,KAAK,WAAW,KAAK,WAAW,QAAQ,OAAO;AAAA,EACxD;AAAA,EAEA,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,OACJ,QACA,SACqD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qBAAqB,KAAK,UAAU;AAC5D,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;;;AC7BO,SAAS,aAA4C,QAAc;AACxE,SAAO;AACT;;;AtByMA,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/features.ts","../src/resources/invoices.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/transactions.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":["export { Commet, createCommet } from \"./client\";\nexport type {\n ActiveAddon,\n Addon,\n AddonConsumptionModel,\n BalanceAddon,\n BooleanAddon,\n CreateAddonParams,\n CreateBalanceAddonParams,\n CreateBooleanAddonParams,\n CreateCreditsAddonParams,\n CreateMeteredAddonParams,\n CreditsAddon,\n DeleteAddonParams,\n GetAddonParams,\n ListActiveAddonsParams,\n ListAddonsParams,\n MeteredAddon,\n UpdateAddonParams,\n} from \"./resources/addons\";\nexport type {\n ApiKey,\n ApiKeyCreated,\n CreateApiKeyParams,\n DeleteApiKeyParams,\n ListApiKeysParams,\n} from \"./resources/api-keys\";\nexport type {\n CreateCreditPackParams,\n CreditPack,\n CreditPackDetail,\n DeleteCreditPackParams,\n UpdateCreditPackParams,\n} from \"./resources/credit-packs\";\nexport type {\n BatchResult as CustomersBatchResult,\n CreateParams as CreateCustomerParams,\n Customer,\n CustomerAddress,\n GetCustomerParams,\n ListCustomersParams,\n UpdateParams as UpdateCustomerParams,\n} from \"./resources/customers\";\nexport type {\n CanUseFeatureParams,\n CanUseResult,\n CreateFeatureParams,\n DeleteFeatureParams,\n Feature,\n FeatureAccess,\n GetFeatureParams,\n ListFeaturesParams,\n UpdateFeatureParams,\n} from \"./resources/features\";\nexport type {\n ChargeType,\n CreateAdjustmentParams,\n CreateAdjustmentResult,\n GetDownloadUrlParams,\n GetInvoiceParams,\n InvoiceDetail,\n InvoiceDownloadResult,\n InvoiceLineItem,\n InvoiceLineType,\n InvoiceListItem,\n InvoiceSendResult,\n InvoiceStatus,\n InvoiceStatusResult,\n InvoiceType,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n AddPlanToGroupParams,\n CreatePlanGroupParams,\n DeletePlanGroupParams,\n GetPlanGroupParams,\n ListPlanGroupsParams,\n PlanGroup,\n PlanGroupDetail,\n RemovePlanFromGroupParams,\n ReorderPlansParams,\n UpdatePlanGroupParams,\n} from \"./resources/plan-groups\";\nexport type {\n AddAiModelPricingFeatureParams,\n AddFixedPricingFeatureParams,\n AddPlanFeatureParams,\n AddPlanPriceParams,\n AiModelPricingFeatureManage,\n BillingInterval,\n ConsumptionModel,\n CreatePlanParams,\n DeletePlanParams,\n DeletePlanPriceParams,\n DeleteRegionalPricesParams,\n DeleteResult,\n DiscountType,\n FeatureType,\n FixedPricingFeatureManage,\n ListPlansParams,\n Plan,\n PlanDetail,\n PlanFeature,\n PlanFeatureManage,\n PlanID,\n PlanManage,\n PlanPrice,\n PlanPriceManage,\n RegionalPriceResult,\n RemovePlanFeatureParams,\n RemoveResult,\n SetDefaultPriceParams,\n SetRegionalPricesParams,\n SetVisibilityParams,\n UpdatePlanFeatureParams,\n UpdatePlanParams,\n UpdatePlanPriceParams,\n} from \"./resources/plans\";\nexport type { GetUrlParams, PortalAccess } from \"./resources/portal\";\nexport type {\n CreatePromoCodeParams,\n GetPromoCodeParams,\n ListPromoCodesParams,\n PromoCode,\n PromoCodeDetail,\n UpdatePromoCodeParams,\n} from \"./resources/promo-codes\";\nexport type {\n AddQuotaParams,\n GetAllQuotaParams,\n GetQuotaParams,\n QuotaAllowance,\n QuotaEvent,\n RemoveQuotaParams,\n SetQuotaParams,\n} from \"./resources/quota\";\nexport type {\n AddSeatsParams,\n GetAllBalancesParams,\n GetBalanceParams,\n RemoveSeatsParams,\n SeatBalance,\n SeatEvent,\n SetAllSeatsParams,\n SetSeatsParams,\n} from \"./resources/seats\";\nexport type {\n ActivateAddonParams,\n ActivateAddonResult,\n ActiveSubscription,\n AdjustBalanceParams,\n AdjustBalanceResult,\n CancellationSummary,\n CancelParams,\n ChangePlanParams,\n ChangePlanResult,\n CreatedSubscription,\n CreateSubscriptionParams,\n CustomIntroOffer,\n DeactivateAddonParams,\n DeactivateAddonResult,\n DiscountSummary,\n FeatureSummary,\n GetActiveParams,\n ListSubscriptionsParams,\n PreviewChangeParams,\n PreviewChangeResult,\n PurchaseCreditsParams,\n PurchaseCreditsResult,\n Subscription,\n SubscriptionListItem,\n SubscriptionStatus,\n TopupBalanceParams,\n TopupBalanceResult,\n UncancelParams,\n} from \"./resources/subscriptions\";\nexport type {\n GetTransactionParams,\n ListTransactionsParams,\n RefundTransactionParams,\n RetryTransactionParams,\n TransactionDetail,\n TransactionListItem,\n TransactionRefundResult,\n TransactionRetryResult,\n TransactionStatus,\n} from \"./resources/transactions\";\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 { registerIntegration } from \"./utils/telemetry\";\nexport { API_VERSION, SDK_VERSION } from \"./version\";\n\nimport { Commet } from \"./client\";\nexport default Commet;\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport type AddonConsumptionModel =\n | \"boolean\"\n | \"metered\"\n | \"credits\"\n | \"balance\";\n\nexport interface ActiveAddon {\n object: \"addon\";\n livemode: boolean;\n slug: string;\n name: string;\n basePrice: number;\n featureCode: string;\n featureName: string;\n featureType: FeatureType;\n consumptionModel: AddonConsumptionModel | null;\n activatedAt: string;\n}\n\nexport interface ListActiveAddonsParams {\n customerId: CustomerID;\n}\n\ninterface AddonBase {\n id: string;\n object: \"addon\";\n livemode: boolean;\n name: string;\n slug: string;\n description: string | null;\n basePrice: number;\n featureCode: string;\n featureName: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface BooleanAddon extends AddonBase {\n consumptionModel: \"boolean\";\n includedUnits: null;\n overageRate: null;\n creditCost: null;\n}\n\nexport interface MeteredAddon extends AddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n creditCost: null;\n}\n\nexport interface CreditsAddon extends AddonBase {\n consumptionModel: \"credits\";\n includedUnits: null;\n overageRate: null;\n creditCost: number;\n}\n\nexport interface BalanceAddon extends AddonBase {\n consumptionModel: \"balance\";\n includedUnits: null;\n overageRate: number;\n creditCost: null;\n}\n\nexport type Addon = BooleanAddon | MeteredAddon | CreditsAddon | BalanceAddon;\n\nexport interface ListAddonsParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\ninterface CreateAddonBase {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n}\n\nexport interface CreateBooleanAddonParams extends CreateAddonBase {\n consumptionModel: \"boolean\";\n}\n\nexport interface CreateMeteredAddonParams extends CreateAddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n}\n\nexport interface CreateCreditsAddonParams extends CreateAddonBase {\n consumptionModel: \"credits\";\n creditCost: number;\n}\n\nexport interface CreateBalanceAddonParams extends CreateAddonBase {\n consumptionModel: \"balance\";\n overageRate: number;\n}\n\nexport type CreateAddonParams =\n | CreateBooleanAddonParams\n | CreateMeteredAddonParams\n | CreateCreditsAddonParams\n | CreateBalanceAddonParams;\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 async listActive(\n params: ListActiveAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActiveAddon[]>> {\n return this.httpClient.get(\n \"/addons/active\",\n { customerId: params.customerId },\n options,\n );\n }\n\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon[]>> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\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 async create(\n params: CreateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/addons/${id}`, body, options);\n }\n\n /** Fails if addon has active subscriptions. */\n async delete(\n params: DeleteAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ApiKey {\n id: string;\n object: \"api_key\";\n livemode: boolean;\n name: string;\n prefix: string;\n expiresAt: string | null;\n lastUsedAt: string | null;\n createdAt: string;\n}\n\nexport interface ApiKeyCreated extends ApiKey {\n apiKey: string;\n}\n\nexport interface ListApiKeysParams {\n limit?: number;\n cursor?: string;\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 async list(params?: ListApiKeysParams): Promise<ApiResponse<ApiKey[]>> {\n return this.httpClient.get(\"/api-keys\", params);\n }\n\n /** Response includes full `apiKey` which is only returned once. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ApiKeyCreated>> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(`/api-keys/${params.id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CreditPack {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n currency: string;\n}\n\nexport interface CreditPackDetail {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n isActive: boolean;\n createdAt: string;\n updatedAt: string;\n}\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 async list(): Promise<ApiResponse<CreditPack[]>> {\n return this.httpClient.get(\"/credit-packs\");\n }\n\n async create(\n params: CreateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n return this.httpClient.post(\"/credit-packs/manage\", params, options);\n }\n\n async update(\n params: UpdateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/credit-packs/${id}`, body, options);\n }\n\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n}\n","import type {\n ApiResponse,\n ListParams as BaseListParams,\n CustomerID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Customer {\n id: CustomerID;\n object: \"customer\";\n livemode: boolean;\n organizationId: string;\n fullName?: string;\n domain?: string;\n website?: string;\n billingEmail: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n}\n\nexport interface CreateParams {\n email: string; // billingEmail - the only required field\n id?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface GetCustomerParams {\n id: CustomerID;\n}\n\nexport interface UpdateParams {\n id: CustomerID;\n email?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface ListCustomersParams extends BaseListParams {\n search?: string;\n}\n\nexport interface BatchResult {\n successful: Customer[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateParams;\n }>;\n}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Idempotent when `id` is provided — returns existing customer instead of duplicating. */\n async create(\n params: CreateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\n \"/customers\",\n {\n billingEmail: params.email,\n id: params.id,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async createBatch(\n params: { customers: CreateParams[] },\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult>> {\n const customers = params.customers.map((c) => ({\n billingEmail: c.email,\n id: c.id,\n fullName: c.fullName,\n domain: c.domain,\n website: c.website,\n timezone: c.timezone,\n language: c.language,\n industry: c.industry,\n metadata: c.metadata,\n address: c.address,\n }));\n return this.httpClient.post(\"/customers/batch\", { customers }, options);\n }\n\n async get(params: GetCustomerParams): Promise<ApiResponse<Customer>> {\n return this.httpClient.get(`/customers/${params.id}`);\n }\n\n async update(\n params: UpdateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${params.id}`,\n {\n billingEmail: params.email,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params as Record<string, unknown>);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport interface GetFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface CanUseFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface ListFeaturesParams {\n customerId: CustomerID;\n}\n\nexport interface FeatureAccess {\n object: \"feature\";\n livemode: boolean;\n code: string;\n name: string;\n type: FeatureType;\n allowed: boolean;\n enabled?: boolean;\n current?: number;\n included?: number;\n remaining?: number;\n overage?: number;\n overageUnitPrice?: number;\n billedQuantity?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n}\n\nexport interface CanUseResult {\n allowed: boolean;\n willBeCharged: boolean;\n reason?: string;\n}\n\nexport interface Feature {\n id: string;\n object: \"feature\";\n livemode: boolean;\n name: string;\n code: string;\n type: FeatureType;\n description: string | null;\n unitName: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreateFeatureParams {\n code: string;\n name: string;\n type: FeatureType;\n description?: string;\n unitName?: string;\n}\n\nexport interface UpdateFeatureParams {\n code: string;\n name?: string;\n description?: string;\n unitName?: string;\n}\n\nexport interface DeleteFeatureParams {\n code: string;\n}\n\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async get(\n params: GetFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId },\n options,\n );\n }\n\n /** Checks if the customer can consume one more unit — returns billing impact and reason if blocked. */\n async canUse(\n params: CanUseFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanUseResult>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId, action: \"canUse\" },\n options,\n );\n }\n\n async list(\n params: ListFeaturesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess[]>> {\n return this.httpClient.get(\n \"/features\",\n { customerId: params.customerId },\n options,\n );\n }\n\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 async update(\n params: UpdateFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Feature>> {\n const { code, ...body } = params;\n return this.httpClient.put(`/features/${code}/manage`, body, options);\n }\n\n /** Fails if feature is attached to active plans or has an active addon. */\n async delete(\n params: DeleteFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { DiscountType } from \"./plans\";\n\nexport type InvoiceStatus =\n | \"draft\"\n | \"upcoming\"\n | \"outstanding\"\n | \"paid\"\n | \"void\"\n | \"uncollectible\";\nexport type InvoiceType =\n | \"recurring\"\n | \"overage\"\n | \"plan_change\"\n | \"adjustment\"\n | \"credit_purchase\"\n | \"balance_topup\"\n | \"addon_activation\";\nexport type InvoiceLineType =\n | \"plan_base\"\n | \"feature_overage\"\n | \"feature_seats\"\n | \"feature_quota\"\n | \"discount\"\n | \"credit\"\n | \"addon_base\";\nexport type ChargeType = \"standard\" | \"advance\" | \"true_up\";\n\nexport interface InvoiceLineItem {\n lineType: InvoiceLineType;\n featureName: string | null;\n description: string | null;\n quantity: number;\n unitAmount: number;\n amount: number;\n includedAmount: number | null;\n usedAmount: number | null;\n overageAmount: number | null;\n discountType: DiscountType | null;\n discountValue: number | null;\n discountName: string | null;\n chargeType: ChargeType | null;\n}\n\nexport interface InvoiceListItem {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n subscriptionId: string | null;\n invoiceNumber: string;\n status: InvoiceStatus;\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n discountAmount: number;\n taxAmount: number;\n total: number;\n periodStart: string | null;\n periodEnd: string | null;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface InvoiceDetail extends InvoiceListItem {\n creditApplied: number;\n planName: string | null;\n poNumber: string | null;\n reference: string | null;\n lineItems: InvoiceLineItem[];\n}\n\nexport interface InvoiceDownloadResult {\n url: string;\n expiresAt: string;\n}\n\nexport interface InvoiceSendResult {\n sent: boolean;\n sentAt: string;\n}\n\nexport interface InvoiceStatusResult {\n id: string;\n status: \"paid\" | \"void\";\n updatedAt: string;\n}\n\nexport interface CreateAdjustmentResult {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n invoiceNumber: string;\n status: \"outstanding\" | \"paid\";\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n taxAmount: number;\n total: number;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListInvoicesParams {\n customerId?: string;\n status?: InvoiceStatus;\n subscriptionId?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface CreateAdjustmentParams {\n customerId: string;\n amount: number;\n description?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface GetDownloadUrlParams {\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 async list(\n params?: ListInvoicesParams,\n ): Promise<ApiResponse<InvoiceListItem[]>> {\n return this.httpClient.get(\"/invoices\", params);\n }\n\n async get(params: GetInvoiceParams): Promise<ApiResponse<InvoiceDetail>> {\n return this.httpClient.get(`/invoices/${params.id}`);\n }\n\n /** Negative amount creates a credit. */\n async createAdjustment(\n params: CreateAdjustmentParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreateAdjustmentResult>> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\n\n /** Signed URL, expires after 7 days. */\n async getDownloadUrl(\n params: GetDownloadUrlParams,\n ): Promise<ApiResponse<InvoiceDownloadResult>> {\n return this.httpClient.get(`/invoices/${params.id}/download`);\n }\n\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceSendResult>> {\n return this.httpClient.post(`/invoices/${params.id}/send`, {}, options);\n }\n\n /** Only outstanding invoices can be changed to paid or void. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceStatusResult>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/invoices/${id}/status`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PlanGroup {\n id: string;\n object: \"plan_group\";\n livemode: boolean;\n name: string;\n description: string | null;\n isPublic: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PlanGroupDetail extends PlanGroup {\n plans: Array<{ id: string; code: string; name: string; sortOrder: number }>;\n}\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;\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 ReorderPlansParams {\n id: string;\n planIds: string[];\n}\n\nexport class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlanGroupsParams): Promise<ApiResponse<PlanGroup[]>> {\n return this.httpClient.get(\"/plan-groups\", params);\n }\n\n async get(params: GetPlanGroupParams): Promise<ApiResponse<PlanGroupDetail>> {\n return this.httpClient.get(`/plan-groups/${params.id}`);\n }\n\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 async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroup>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plan-groups/${id}`, body, options);\n }\n\n /** Plans in the group are unlinked, not deleted. */\n async delete(\n params: DeletePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(\n `/plan-groups/${params.id}`,\n undefined,\n options,\n );\n }\n\n async addPlan(\n params: AddPlanToGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, body, options);\n }\n\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n const { id, planId } = params;\n return this.httpClient.delete(\n `/plan-groups/${id}/plans/${planId}`,\n undefined,\n options,\n );\n }\n\n async reorderPlans(\n params: ReorderPlansParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(\n `/plan-groups/${id}/plans/reorder`,\n body,\n options,\n );\n }\n}\n","import type { ApiResponse, ListParams, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PlanID = `plan_${string}`;\nexport type BillingInterval =\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"yearly\"\n | \"one_time\";\nexport type FeatureType = \"boolean\" | \"usage\" | \"seats\" | \"quota\";\nexport type ConsumptionModel = \"metered\" | \"credits\" | \"balance\";\nexport type DiscountType = \"percentage\" | \"amount\";\n\nexport interface PlanPrice {\n billingInterval: BillingInterval;\n price: number; // in cents\n isDefault: boolean;\n trialDays: number;\n}\n\nexport interface PlanFeature {\n code: string;\n name: string;\n type: FeatureType;\n unitName: string | null;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n overageUnitPrice?: number;\n}\n\nexport interface Plan {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isFree: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanPrice[];\n features: PlanFeature[];\n createdAt: string;\n}\n\nexport interface PlanDetailPrice {\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n introOffer: {\n enabled: boolean;\n discountType: DiscountType | null;\n discountValue: number | null;\n durationCycles: number | null;\n } | null;\n}\n\nexport interface PlanDetailFeature extends PlanFeature {\n overage: {\n enabled: boolean;\n model: \"per_unit\" | null;\n unitPrice: number | null;\n } | null;\n}\n\nexport interface PlanDetail {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanDetailPrice[];\n features: PlanDetailFeature[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListPlansParams extends ListParams {\n includePrivate?: boolean;\n}\n\nexport interface PlanManage {\n id: string;\n object: \"plan\";\n livemode: boolean;\n name: string;\n code: string;\n description: string | null;\n consumptionModel: ConsumptionModel | null;\n isPublic: boolean;\n isDefault: boolean;\n isFree: boolean;\n blockOnExhaustion: boolean;\n sortOrder: number;\n planGroupId: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface PlanFeatureManageBase {\n planId: string;\n featureId: string;\n enabled: boolean;\n includedAmount: number | null;\n unlimited: boolean;\n overageEnabled: boolean;\n creditsPerUnit: number | null;\n}\n\nexport interface FixedPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"fixed\";\n overageUnitPrice: number | null;\n margin: null;\n}\n\nexport interface AiModelPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"ai_model\";\n margin: number;\n overageUnitPrice: null;\n}\n\nexport type PlanFeatureManage =\n | FixedPricingFeatureManage\n | AiModelPricingFeatureManage;\n\nexport interface PlanPriceManage {\n id: string;\n object: \"plan_price\";\n livemode: boolean;\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n includedBalance: number | null;\n includedCredits: number | null;\n introOfferEnabled: boolean;\n introOfferDiscountType: DiscountType | null;\n introOfferDiscountValue: number | null;\n introOfferDurationCycles: number | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RegionalPriceResult {\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteResult {\n id: string;\n deleted: true;\n}\n\nexport interface RemoveResult {\n id: string;\n removed: true;\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;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface SetVisibilityParams {\n id: string;\n isPublic: boolean;\n}\n\ninterface AddPlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface AddFixedPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface AddAiModelPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode: \"ai_model\";\n margin: number;\n}\n\nexport type AddPlanFeatureParams =\n | AddFixedPricingFeatureParams\n | AddAiModelPricingFeatureParams;\n\ninterface UpdatePlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface UpdateFixedPricingFeatureParams extends UpdatePlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface UpdateAiModelPricingFeatureParams\n extends UpdatePlanFeatureBase {\n pricingMode: \"ai_model\";\n margin?: number;\n}\n\nexport type UpdatePlanFeatureParams =\n | UpdateFixedPricingFeatureParams\n | UpdateAiModelPricingFeatureParams;\n\nexport interface RemovePlanFeatureParams {\n planId: string;\n featureId: string;\n}\n\nexport interface AddPlanPriceParams {\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n trialDays?: number;\n isDefault?: boolean;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\";\n introOfferDiscountValue?: number;\n introOfferDurationCycles?: number;\n}\n\nexport interface UpdatePlanPriceParams {\n planId: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue?: number | null;\n introOfferDurationCycles?: number | null;\n}\n\nexport interface DeletePlanPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetDefaultPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetRegionalPricesParams {\n planId: string;\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n planId: string;\n priceId: string;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>> {\n return this.httpClient.get(\"/plans\", params);\n }\n\n async get(params: { id: string }): Promise<ApiResponse<PlanDetail>> {\n return this.httpClient.get(`/plans/${params.id}`);\n }\n\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n return this.httpClient.post(\"/plans/manage\", params, options);\n }\n\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/manage`, body, options);\n }\n\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n return this.httpClient.delete(\n `/plans/${params.id}/manage`,\n undefined,\n options,\n );\n }\n\n async setVisibility(\n params: SetVisibilityParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, body, options);\n }\n\n async addFeature(\n params: AddPlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/features`, body, options);\n }\n\n async updateFeature(\n params: UpdatePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, featureId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/features/${featureId}`,\n body,\n options,\n );\n }\n\n async removeFeature(\n params: RemovePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RemoveResult>> {\n const { planId, featureId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/prices`, body, options);\n }\n\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}`,\n body,\n options,\n );\n }\n\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n async setDefaultPrice(\n params: SetDefaultPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/default`,\n {},\n options,\n );\n }\n\n async setRegionalPrices(\n params: SetRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RegionalPriceResult>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/regional`,\n body,\n options,\n );\n }\n\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}/regional`,\n undefined,\n options,\n );\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PortalAccess {\n success: boolean;\n message: string;\n portalUrl: string;\n}\n\ninterface GetUrlByCustomerId {\n customerId: CustomerID;\n email?: never;\n}\n\ninterface GetUrlByEmail {\n email: string;\n customerId?: never;\n}\n\nexport type GetUrlParams = GetUrlByCustomerId | GetUrlByEmail;\n\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async getUrl(\n params: GetUrlParams,\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PromoCode {\n id: string;\n object: \"promo_code\";\n livemode: boolean;\n code: string;\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number | null;\n maxRedemptions: number | null;\n expiresAt: string | null;\n active: boolean;\n redemptionCount: number;\n createdAt: string;\n}\n\nexport interface PromoCodeDetail extends PromoCode {\n updatedAt: string;\n}\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: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles?: number;\n maxRedemptions?: number;\n expiresAt?: string;\n planIds?: string[];\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n maxRedemptions?: number;\n expiresAt?: string;\n active?: boolean;\n planIds?: string[];\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPromoCodesParams): Promise<ApiResponse<PromoCode[]>> {\n return this.httpClient.get(\"/promo-codes\", params);\n }\n\n async get(params: GetPromoCodeParams): Promise<ApiResponse<PromoCodeDetail>> {\n return this.httpClient.get(`/promo-codes/${params.id}`);\n }\n\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCode>> {\n return this.httpClient.post(\"/promo-codes\", params, options);\n }\n\n async update(\n params: UpdatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCodeDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/promo-codes/${id}`, body, options);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface QuotaEvent {\n id: string;\n customerId: CustomerID;\n featureCode: string;\n previousBalance: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface QuotaAllowance {\n featureCode: string;\n current: number;\n included: number;\n remaining: number | null;\n billedQuantity?: number;\n unlimited: boolean;\n overageEnabled: boolean;\n asOf: string | null;\n}\n\nexport interface AddQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface RemoveQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface GetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllQuotaParams {\n customerId: CustomerID;\n}\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.post(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.put(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.delete(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async get(params: GetQuotaParams): Promise<ApiResponse<QuotaAllowance>> {\n return this.httpClient.get(\"/usage/quota\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAll(\n params: GetAllQuotaParams,\n ): Promise<ApiResponse<QuotaAllowance[]>> {\n return this.httpClient.get(\"/usage/quota/all\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatEvent {\n id: string;\n object: \"seat\";\n livemode: boolean;\n organizationId: string;\n customerId: CustomerID;\n featureCode: string;\n eventType: \"add\" | \"remove\" | \"set\";\n quantity: number;\n previousBalance?: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface SeatBalance {\n current: number;\n asOf: string;\n}\n\nexport interface AddSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface SetAllSeatsParams {\n customerId: CustomerID;\n seats: Record<string, number>;\n}\n\nexport interface GetBalanceParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllBalancesParams {\n customerId: CustomerID;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n /** Removal 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async setAll(\n params: SetAllSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalance>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalance>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { BillingInterval, ConsumptionModel, FeatureType } from \"./plans\";\n\nexport type SubscriptionStatus =\n | \"draft\"\n | \"pending_payment\"\n | \"trialing\"\n | \"active\"\n | \"paused\"\n | \"past_due\"\n | \"canceled\"\n | \"expired\";\n\nexport interface FeatureSummary {\n code: string;\n name: string;\n type: FeatureType;\n enabled?: boolean;\n usage?: {\n current: number;\n included: number;\n overage: number;\n overageUnitPrice?: number;\n };\n}\n\nexport interface CreditsSummary {\n remaining: number;\n included: number;\n purchased: number;\n}\n\nexport interface BalanceSummary {\n remaining: number;\n included: number;\n currency: string;\n}\n\nexport interface CancellationSummary {\n scheduledAt: string;\n reason: string | null;\n effectiveAt: string;\n}\n\nexport interface DiscountSummary {\n type: \"percentage\" | \"amount\";\n value: number;\n name: string | null;\n endsAt: string | null;\n}\n\nexport interface ActiveSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n plan: {\n id: string;\n name: string;\n basePrice: number;\n billingInterval: BillingInterval | null;\n };\n name: string;\n description: string | null;\n status: SubscriptionStatus;\n consumptionModel: ConsumptionModel | null;\n trialEndsAt: string | null;\n currentPeriod: {\n start: string;\n end: string;\n daysRemaining: number;\n };\n features: FeatureSummary[];\n credits: CreditsSummary | null;\n balance: BalanceSummary | null;\n cancellation: CancellationSummary | null;\n discount: DiscountSummary | null;\n startDate: string;\n endDate: string | null;\n billingDayOfMonth: number;\n nextBillingDate: string;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreatedSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval | null;\n trialEndsAt: string | null;\n startDate: string;\n endDate: string | null;\n currentPeriodStart: string | null;\n currentPeriodEnd: string | null;\n billingDayOfMonth: number;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n introOfferEndsAt: string | null;\n introOfferDiscountType: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue: number | null;\n}\n\nexport interface Subscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n description?: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval;\n trialEndsAt?: string;\n startDate: string;\n endDate?: string;\n currentPeriodStart?: string;\n currentPeriodEnd?: string;\n billingDayOfMonth: number;\n checkoutUrl?: string;\n createdAt: string;\n updatedAt: string;\n}\n\ntype PlanIdentifier =\n | { planCode: string; planId?: never }\n | { planCode?: never; planId: string };\n\nexport interface CustomIntroOffer {\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number;\n}\n\nexport type CreateSubscriptionParams = PlanIdentifier & {\n customerId: string;\n} & {\n billingInterval?: BillingInterval;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n name?: string;\n startDate?: string;\n successUrl?: string;\n customIntroOffer?: CustomIntroOffer;\n};\n\nexport interface GetActiveParams {\n customerId: string;\n}\n\nexport interface CancelParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport interface UncancelParams {\n id: string;\n}\n\nexport interface ChangePlanParams {\n id: string;\n newPlanId?: string;\n newBillingInterval?: BillingInterval;\n /** Where to redirect after checkout when a free→paid change requires payment. */\n successUrl?: string;\n}\n\nexport interface ChangePlanResult {\n id: string;\n scheduled: boolean;\n customerId?: string;\n previousPlan?: { id: string; name: string };\n currentPlan?: { id: string; name: string; price: number };\n billingInterval?: string;\n billing?: {\n credit: number;\n creditsApplied: number;\n charge: number;\n taxAmount: number;\n netAmount: number;\n totalCharged: number;\n remainingCreditBalance: number;\n };\n invoiceId?: string;\n scheduledFor?: string;\n changeType?: string;\n requiresCheckout?: boolean;\n checkoutUrl?: string;\n}\n\nexport interface ListSubscriptionsParams extends Record<string, unknown> {\n customerId?: string;\n status?: SubscriptionStatus;\n limit?: number;\n cursor?: string;\n}\n\nexport interface SubscriptionListItem {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n startDate: string;\n endDate: string;\n billingDayOfMonth: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PreviewChangeParams {\n id: string;\n planId?: string;\n billingInterval?: BillingInterval;\n}\n\nexport interface PreviewChangeResult {\n currency: string;\n currentPlanCredit: number;\n newPlanCharge: number;\n estimatedTotal: number;\n effectiveDate: string;\n daysRemaining: number;\n totalDays: number;\n isUpgrade: boolean;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface ActivateAddonResult {\n addonId: string;\n status: string;\n proratedCharge: number;\n}\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface DeactivateAddonResult {\n id: string;\n status: string;\n deactivatedAt: string;\n}\n\nexport interface AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"balance\" | \"credits\";\n}\n\nexport interface AdjustBalanceResult {\n amount: number;\n newBalance: number;\n reason: string | null;\n}\n\nexport interface TopupBalanceParams {\n id: string;\n amount: number;\n}\n\nexport interface TopupBalanceResult {\n amount: number;\n}\n\nexport interface PurchaseCreditsParams {\n id: string;\n creditPackId: string;\n}\n\nexport interface PurchaseCreditsResult {\n credits: number;\n}\n\n/** Each customer can only have one active subscription at a time. */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Returns a `checkoutUrl` when payment is required before activation. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreatedSubscription>> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n\n async getActive(\n params: GetActiveParams,\n ): Promise<ApiResponse<ActiveSubscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", {\n customerId: params.customerId,\n });\n }\n\n /** Schedules cancellation at period end by default. Set `immediate: true` to cancel now. */\n async cancel(\n params: CancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, body, options);\n }\n\n /** Only works on subscriptions with a pending cancellation — cannot revert already-canceled. */\n async uncancel(\n params: UncancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${params.id}/uncancel`,\n {},\n options,\n );\n }\n\n /** Upgrades execute immediately with proration. Downgrades are scheduled for end of period. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ChangePlanResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n body,\n options,\n );\n }\n\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<SubscriptionListItem[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /** Dry-run: returns proration details without applying the change. */\n async previewChange(\n params: PreviewChangeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PreviewChangeResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n body,\n options,\n );\n }\n\n /** Prorated charge for the current billing period. */\n async activateAddon(\n params: ActivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActivateAddonResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, body, options);\n }\n\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeactivateAddonResult>> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\n options,\n );\n }\n\n /** Positive amount adds, negative subtracts. */\n async adjustBalance(\n params: AdjustBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<AdjustBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/adjust`,\n body,\n options,\n );\n }\n\n /** Charges the customer's payment method. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TopupBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n body,\n options,\n );\n }\n\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PurchaseCreditsResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type TransactionStatus =\n | \"pending\"\n | \"succeeded\"\n | \"failed\"\n | \"refunded\"\n | \"disputed\";\n\nexport interface TransactionListItem {\n id: string;\n object: \"transaction\";\n livemode: boolean;\n invoiceId: string;\n grossAmount: number;\n subtotal: number;\n taxAmount: number;\n currency: string;\n status: TransactionStatus;\n customerEmail: string;\n customerName: string | null;\n paidAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface TransactionDetail extends TransactionListItem {\n availableAt: string | null;\n}\n\nexport interface TransactionRefundResult {\n id: string;\n status: \"refunded\";\n}\n\nexport interface TransactionRetryResult {\n id: string;\n status: \"processing\";\n retryInvoiceNumber: string;\n}\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 async list(\n params?: ListTransactionsParams,\n ): Promise<ApiResponse<TransactionListItem[]>> {\n return this.httpClient.get(\"/transactions\", params);\n }\n\n async get(\n params: GetTransactionParams,\n ): Promise<ApiResponse<TransactionDetail>> {\n return this.httpClient.get(`/transactions/${params.id}`);\n }\n\n /** Full refund only. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRefundResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/refund`,\n {},\n options,\n );\n }\n\n /** Creates a new invoice and initiates a new payment attempt. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRetryResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/retry`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { ConsumptionModel } from \"./plans\";\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { SubscriptionStatus } from \"./subscriptions\";\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-05-25\";\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 { 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 { 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 { TransactionsResource } from \"./resources/transactions\";\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> {\n private httpClient: CommetHTTPClient;\n\n public readonly addons: AddonsResource;\n public readonly apiKeys: ApiKeysResource;\n public readonly creditPacks: CreditPacksResource;\n public readonly customers: CustomersResource;\n public readonly features: FeaturesResource;\n public readonly invoices: InvoicesResource;\n public readonly planGroups: PlanGroupsResource;\n public readonly plans: PlansResource;\n public readonly portal: PortalResource;\n public readonly promoCodes: PromoCodesResource;\n public readonly quota: QuotaResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\n public readonly transactions: TransactionsResource;\n public readonly usage: UsageResource;\n public readonly webhooks: Webhooks;\n\n constructor(config: CommetClientOptions) {\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.addons = new AddonsResource(this.httpClient);\n this.apiKeys = new ApiKeysResource(this.httpClient);\n this.creditPacks = new CreditPacksResource(this.httpClient);\n this.customers = new CustomersResource(this.httpClient);\n this.features = new FeaturesResource(this.httpClient);\n this.invoices = new InvoicesResource(this.httpClient);\n this.planGroups = new PlanGroupsResource(this.httpClient);\n this.plans = new PlansResource(this.httpClient);\n this.portal = new PortalResource(this.httpClient);\n this.promoCodes = new PromoCodesResource(this.httpClient);\n this.quota = new QuotaResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(this.httpClient);\n this.transactions = new TransactionsResource(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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ationError = class extends CommetError {
|
|
|
733
733
|
|
|
734
734
|
// src/version.ts
|
|
735
735
|
var API_VERSION = "2026-05-25";
|
|
736
|
-
var SDK_VERSION = "5.5.
|
|
736
|
+
var SDK_VERSION = "5.5.1";
|
|
737
737
|
|
|
738
738
|
// src/utils/telemetry.ts
|
|
739
739
|
var registeredIntegrations = /* @__PURE__ */ new Set();
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../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/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/transactions.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","../src/index.ts"],"sourcesContent":["import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport type AddonConsumptionModel =\n | \"boolean\"\n | \"metered\"\n | \"credits\"\n | \"balance\";\n\nexport interface ActiveAddon {\n object: \"addon\";\n livemode: boolean;\n slug: string;\n name: string;\n basePrice: number;\n featureCode: string;\n featureName: string;\n featureType: FeatureType;\n consumptionModel: AddonConsumptionModel | null;\n activatedAt: string;\n}\n\nexport interface ListActiveAddonsParams {\n customerId: CustomerID;\n}\n\ninterface AddonBase {\n id: string;\n object: \"addon\";\n livemode: boolean;\n name: string;\n slug: string;\n description: string | null;\n basePrice: number;\n featureCode: string;\n featureName: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface BooleanAddon extends AddonBase {\n consumptionModel: \"boolean\";\n includedUnits: null;\n overageRate: null;\n creditCost: null;\n}\n\nexport interface MeteredAddon extends AddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n creditCost: null;\n}\n\nexport interface CreditsAddon extends AddonBase {\n consumptionModel: \"credits\";\n includedUnits: null;\n overageRate: null;\n creditCost: number;\n}\n\nexport interface BalanceAddon extends AddonBase {\n consumptionModel: \"balance\";\n includedUnits: null;\n overageRate: number;\n creditCost: null;\n}\n\nexport type Addon = BooleanAddon | MeteredAddon | CreditsAddon | BalanceAddon;\n\nexport interface ListAddonsParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\ninterface CreateAddonBase {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n}\n\nexport interface CreateBooleanAddonParams extends CreateAddonBase {\n consumptionModel: \"boolean\";\n}\n\nexport interface CreateMeteredAddonParams extends CreateAddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n}\n\nexport interface CreateCreditsAddonParams extends CreateAddonBase {\n consumptionModel: \"credits\";\n creditCost: number;\n}\n\nexport interface CreateBalanceAddonParams extends CreateAddonBase {\n consumptionModel: \"balance\";\n overageRate: number;\n}\n\nexport type CreateAddonParams =\n | CreateBooleanAddonParams\n | CreateMeteredAddonParams\n | CreateCreditsAddonParams\n | CreateBalanceAddonParams;\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 async listActive(\n params: ListActiveAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActiveAddon[]>> {\n return this.httpClient.get(\n \"/addons/active\",\n { customerId: params.customerId },\n options,\n );\n }\n\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon[]>> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\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 async create(\n params: CreateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/addons/${id}`, body, options);\n }\n\n /** Fails if addon has active subscriptions. */\n async delete(\n params: DeleteAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ApiKey {\n id: string;\n object: \"api_key\";\n livemode: boolean;\n name: string;\n prefix: string;\n expiresAt: string | null;\n lastUsedAt: string | null;\n createdAt: string;\n}\n\nexport interface ApiKeyCreated extends ApiKey {\n apiKey: string;\n}\n\nexport interface ListApiKeysParams {\n limit?: number;\n cursor?: string;\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 async list(params?: ListApiKeysParams): Promise<ApiResponse<ApiKey[]>> {\n return this.httpClient.get(\"/api-keys\", params);\n }\n\n /** Response includes full `apiKey` which is only returned once. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ApiKeyCreated>> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(`/api-keys/${params.id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CreditPack {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n currency: string;\n}\n\nexport interface CreditPackDetail {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n isActive: boolean;\n createdAt: string;\n updatedAt: string;\n}\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 async list(): Promise<ApiResponse<CreditPack[]>> {\n return this.httpClient.get(\"/credit-packs\");\n }\n\n async create(\n params: CreateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n return this.httpClient.post(\"/credit-packs/manage\", params, options);\n }\n\n async update(\n params: UpdateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/credit-packs/${id}`, body, options);\n }\n\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n}\n","import type {\n ApiResponse,\n ListParams as BaseListParams,\n CustomerID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Customer {\n id: CustomerID;\n object: \"customer\";\n livemode: boolean;\n organizationId: string;\n fullName?: string;\n domain?: string;\n website?: string;\n billingEmail: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n}\n\nexport interface CreateParams {\n email: string; // billingEmail - the only required field\n id?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface GetCustomerParams {\n id: CustomerID;\n}\n\nexport interface UpdateParams {\n id: CustomerID;\n email?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface ListCustomersParams extends BaseListParams {\n search?: string;\n}\n\nexport interface BatchResult {\n successful: Customer[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateParams;\n }>;\n}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Idempotent when `id` is provided — returns existing customer instead of duplicating. */\n async create(\n params: CreateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\n \"/customers\",\n {\n billingEmail: params.email,\n id: params.id,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async createBatch(\n params: { customers: CreateParams[] },\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult>> {\n const customers = params.customers.map((c) => ({\n billingEmail: c.email,\n id: c.id,\n fullName: c.fullName,\n domain: c.domain,\n website: c.website,\n timezone: c.timezone,\n language: c.language,\n industry: c.industry,\n metadata: c.metadata,\n address: c.address,\n }));\n return this.httpClient.post(\"/customers/batch\", { customers }, options);\n }\n\n async get(params: GetCustomerParams): Promise<ApiResponse<Customer>> {\n return this.httpClient.get(`/customers/${params.id}`);\n }\n\n async update(\n params: UpdateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${params.id}`,\n {\n billingEmail: params.email,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params as Record<string, unknown>);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport interface GetFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface CanUseFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface ListFeaturesParams {\n customerId: CustomerID;\n}\n\nexport interface FeatureAccess {\n object: \"feature\";\n livemode: boolean;\n code: string;\n name: string;\n type: FeatureType;\n allowed: boolean;\n enabled?: boolean;\n current?: number;\n included?: number;\n remaining?: number;\n overage?: number;\n overageUnitPrice?: number;\n billedQuantity?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n}\n\nexport interface CanUseResult {\n allowed: boolean;\n willBeCharged: boolean;\n reason?: string;\n}\n\nexport interface Feature {\n id: string;\n object: \"feature\";\n livemode: boolean;\n name: string;\n code: string;\n type: FeatureType;\n description: string | null;\n unitName: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreateFeatureParams {\n code: string;\n name: string;\n type: FeatureType;\n description?: string;\n unitName?: string;\n}\n\nexport interface UpdateFeatureParams {\n code: string;\n name?: string;\n description?: string;\n unitName?: string;\n}\n\nexport interface DeleteFeatureParams {\n code: string;\n}\n\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async get(\n params: GetFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId },\n options,\n );\n }\n\n /** Checks if the customer can consume one more unit — returns billing impact and reason if blocked. */\n async canUse(\n params: CanUseFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanUseResult>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId, action: \"canUse\" },\n options,\n );\n }\n\n async list(\n params: ListFeaturesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess[]>> {\n return this.httpClient.get(\n \"/features\",\n { customerId: params.customerId },\n options,\n );\n }\n\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 async update(\n params: UpdateFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Feature>> {\n const { code, ...body } = params;\n return this.httpClient.put(`/features/${code}/manage`, body, options);\n }\n\n /** Fails if feature is attached to active plans or has an active addon. */\n async delete(\n params: DeleteFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { DiscountType } from \"./plans\";\n\nexport type InvoiceStatus =\n | \"draft\"\n | \"upcoming\"\n | \"outstanding\"\n | \"paid\"\n | \"void\"\n | \"uncollectible\";\nexport type InvoiceType =\n | \"recurring\"\n | \"overage\"\n | \"plan_change\"\n | \"adjustment\"\n | \"credit_purchase\"\n | \"balance_topup\"\n | \"addon_activation\";\nexport type InvoiceLineType =\n | \"plan_base\"\n | \"feature_overage\"\n | \"feature_seats\"\n | \"feature_quota\"\n | \"discount\"\n | \"credit\"\n | \"addon_base\";\nexport type ChargeType = \"standard\" | \"advance\" | \"true_up\";\n\nexport interface InvoiceLineItem {\n lineType: InvoiceLineType;\n featureName: string | null;\n description: string | null;\n quantity: number;\n unitAmount: number;\n amount: number;\n includedAmount: number | null;\n usedAmount: number | null;\n overageAmount: number | null;\n discountType: DiscountType | null;\n discountValue: number | null;\n discountName: string | null;\n chargeType: ChargeType | null;\n}\n\nexport interface InvoiceListItem {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n subscriptionId: string | null;\n invoiceNumber: string;\n status: InvoiceStatus;\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n discountAmount: number;\n taxAmount: number;\n total: number;\n periodStart: string | null;\n periodEnd: string | null;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface InvoiceDetail extends InvoiceListItem {\n creditApplied: number;\n planName: string | null;\n poNumber: string | null;\n reference: string | null;\n lineItems: InvoiceLineItem[];\n}\n\nexport interface InvoiceDownloadResult {\n url: string;\n expiresAt: string;\n}\n\nexport interface InvoiceSendResult {\n sent: boolean;\n sentAt: string;\n}\n\nexport interface InvoiceStatusResult {\n id: string;\n status: \"paid\" | \"void\";\n updatedAt: string;\n}\n\nexport interface CreateAdjustmentResult {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n invoiceNumber: string;\n status: \"outstanding\" | \"paid\";\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n taxAmount: number;\n total: number;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListInvoicesParams {\n customerId?: string;\n status?: InvoiceStatus;\n subscriptionId?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface CreateAdjustmentParams {\n customerId: string;\n amount: number;\n description?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface GetDownloadUrlParams {\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 async list(\n params?: ListInvoicesParams,\n ): Promise<ApiResponse<InvoiceListItem[]>> {\n return this.httpClient.get(\"/invoices\", params);\n }\n\n async get(params: GetInvoiceParams): Promise<ApiResponse<InvoiceDetail>> {\n return this.httpClient.get(`/invoices/${params.id}`);\n }\n\n /** Negative amount creates a credit. */\n async createAdjustment(\n params: CreateAdjustmentParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreateAdjustmentResult>> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\n\n /** Signed URL, expires after 7 days. */\n async getDownloadUrl(\n params: GetDownloadUrlParams,\n ): Promise<ApiResponse<InvoiceDownloadResult>> {\n return this.httpClient.get(`/invoices/${params.id}/download`);\n }\n\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceSendResult>> {\n return this.httpClient.post(`/invoices/${params.id}/send`, {}, options);\n }\n\n /** Only outstanding invoices can be changed to paid or void. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceStatusResult>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/invoices/${id}/status`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PlanGroup {\n id: string;\n object: \"plan_group\";\n livemode: boolean;\n name: string;\n description: string | null;\n isPublic: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PlanGroupDetail extends PlanGroup {\n plans: Array<{ id: string; code: string; name: string; sortOrder: number }>;\n}\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;\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 ReorderPlansParams {\n id: string;\n planIds: string[];\n}\n\nexport class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlanGroupsParams): Promise<ApiResponse<PlanGroup[]>> {\n return this.httpClient.get(\"/plan-groups\", params);\n }\n\n async get(params: GetPlanGroupParams): Promise<ApiResponse<PlanGroupDetail>> {\n return this.httpClient.get(`/plan-groups/${params.id}`);\n }\n\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 async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroup>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plan-groups/${id}`, body, options);\n }\n\n /** Plans in the group are unlinked, not deleted. */\n async delete(\n params: DeletePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(\n `/plan-groups/${params.id}`,\n undefined,\n options,\n );\n }\n\n async addPlan(\n params: AddPlanToGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, body, options);\n }\n\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n const { id, planId } = params;\n return this.httpClient.delete(\n `/plan-groups/${id}/plans/${planId}`,\n undefined,\n options,\n );\n }\n\n async reorderPlans(\n params: ReorderPlansParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(\n `/plan-groups/${id}/plans/reorder`,\n body,\n options,\n );\n }\n}\n","import type { ApiResponse, ListParams, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PlanID = `plan_${string}`;\nexport type BillingInterval =\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"yearly\"\n | \"one_time\";\nexport type FeatureType = \"boolean\" | \"usage\" | \"seats\" | \"quota\";\nexport type ConsumptionModel = \"metered\" | \"credits\" | \"balance\";\nexport type DiscountType = \"percentage\" | \"amount\";\n\nexport interface PlanPrice {\n billingInterval: BillingInterval;\n price: number; // in cents\n isDefault: boolean;\n trialDays: number;\n}\n\nexport interface PlanFeature {\n code: string;\n name: string;\n type: FeatureType;\n unitName: string | null;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n overageUnitPrice?: number;\n}\n\nexport interface Plan {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isFree: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanPrice[];\n features: PlanFeature[];\n createdAt: string;\n}\n\nexport interface PlanDetailPrice {\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n introOffer: {\n enabled: boolean;\n discountType: DiscountType | null;\n discountValue: number | null;\n durationCycles: number | null;\n } | null;\n}\n\nexport interface PlanDetailFeature extends PlanFeature {\n overage: {\n enabled: boolean;\n model: \"per_unit\" | null;\n unitPrice: number | null;\n } | null;\n}\n\nexport interface PlanDetail {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanDetailPrice[];\n features: PlanDetailFeature[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListPlansParams extends ListParams {\n includePrivate?: boolean;\n}\n\nexport interface PlanManage {\n id: string;\n object: \"plan\";\n livemode: boolean;\n name: string;\n code: string;\n description: string | null;\n consumptionModel: ConsumptionModel | null;\n isPublic: boolean;\n isDefault: boolean;\n isFree: boolean;\n blockOnExhaustion: boolean;\n sortOrder: number;\n planGroupId: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface PlanFeatureManageBase {\n planId: string;\n featureId: string;\n enabled: boolean;\n includedAmount: number | null;\n unlimited: boolean;\n overageEnabled: boolean;\n creditsPerUnit: number | null;\n}\n\nexport interface FixedPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"fixed\";\n overageUnitPrice: number | null;\n margin: null;\n}\n\nexport interface AiModelPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"ai_model\";\n margin: number;\n overageUnitPrice: null;\n}\n\nexport type PlanFeatureManage =\n | FixedPricingFeatureManage\n | AiModelPricingFeatureManage;\n\nexport interface PlanPriceManage {\n id: string;\n object: \"plan_price\";\n livemode: boolean;\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n includedBalance: number | null;\n includedCredits: number | null;\n introOfferEnabled: boolean;\n introOfferDiscountType: DiscountType | null;\n introOfferDiscountValue: number | null;\n introOfferDurationCycles: number | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RegionalPriceResult {\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteResult {\n id: string;\n deleted: true;\n}\n\nexport interface RemoveResult {\n id: string;\n removed: true;\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;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface SetVisibilityParams {\n id: string;\n isPublic: boolean;\n}\n\ninterface AddPlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface AddFixedPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface AddAiModelPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode: \"ai_model\";\n margin: number;\n}\n\nexport type AddPlanFeatureParams =\n | AddFixedPricingFeatureParams\n | AddAiModelPricingFeatureParams;\n\ninterface UpdatePlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface UpdateFixedPricingFeatureParams extends UpdatePlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface UpdateAiModelPricingFeatureParams\n extends UpdatePlanFeatureBase {\n pricingMode: \"ai_model\";\n margin?: number;\n}\n\nexport type UpdatePlanFeatureParams =\n | UpdateFixedPricingFeatureParams\n | UpdateAiModelPricingFeatureParams;\n\nexport interface RemovePlanFeatureParams {\n planId: string;\n featureId: string;\n}\n\nexport interface AddPlanPriceParams {\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n trialDays?: number;\n isDefault?: boolean;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\";\n introOfferDiscountValue?: number;\n introOfferDurationCycles?: number;\n}\n\nexport interface UpdatePlanPriceParams {\n planId: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue?: number | null;\n introOfferDurationCycles?: number | null;\n}\n\nexport interface DeletePlanPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetDefaultPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetRegionalPricesParams {\n planId: string;\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n planId: string;\n priceId: string;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>> {\n return this.httpClient.get(\"/plans\", params);\n }\n\n async get(params: { id: string }): Promise<ApiResponse<PlanDetail>> {\n return this.httpClient.get(`/plans/${params.id}`);\n }\n\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n return this.httpClient.post(\"/plans/manage\", params, options);\n }\n\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/manage`, body, options);\n }\n\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n return this.httpClient.delete(\n `/plans/${params.id}/manage`,\n undefined,\n options,\n );\n }\n\n async setVisibility(\n params: SetVisibilityParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, body, options);\n }\n\n async addFeature(\n params: AddPlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/features`, body, options);\n }\n\n async updateFeature(\n params: UpdatePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, featureId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/features/${featureId}`,\n body,\n options,\n );\n }\n\n async removeFeature(\n params: RemovePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RemoveResult>> {\n const { planId, featureId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/prices`, body, options);\n }\n\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}`,\n body,\n options,\n );\n }\n\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n async setDefaultPrice(\n params: SetDefaultPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/default`,\n {},\n options,\n );\n }\n\n async setRegionalPrices(\n params: SetRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RegionalPriceResult>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/regional`,\n body,\n options,\n );\n }\n\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}/regional`,\n undefined,\n options,\n );\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PortalAccess {\n success: boolean;\n message: string;\n portalUrl: string;\n}\n\ninterface GetUrlByCustomerId {\n customerId: CustomerID;\n email?: never;\n}\n\ninterface GetUrlByEmail {\n email: string;\n customerId?: never;\n}\n\nexport type GetUrlParams = GetUrlByCustomerId | GetUrlByEmail;\n\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async getUrl(\n params: GetUrlParams,\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PromoCode {\n id: string;\n object: \"promo_code\";\n livemode: boolean;\n code: string;\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number | null;\n maxRedemptions: number | null;\n expiresAt: string | null;\n active: boolean;\n redemptionCount: number;\n createdAt: string;\n}\n\nexport interface PromoCodeDetail extends PromoCode {\n updatedAt: string;\n}\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: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles?: number;\n maxRedemptions?: number;\n expiresAt?: string;\n planIds?: string[];\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n maxRedemptions?: number;\n expiresAt?: string;\n active?: boolean;\n planIds?: string[];\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPromoCodesParams): Promise<ApiResponse<PromoCode[]>> {\n return this.httpClient.get(\"/promo-codes\", params);\n }\n\n async get(params: GetPromoCodeParams): Promise<ApiResponse<PromoCodeDetail>> {\n return this.httpClient.get(`/promo-codes/${params.id}`);\n }\n\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCode>> {\n return this.httpClient.post(\"/promo-codes\", params, options);\n }\n\n async update(\n params: UpdatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCodeDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/promo-codes/${id}`, body, options);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface QuotaEvent {\n id: string;\n customerId: CustomerID;\n featureCode: string;\n previousBalance: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface QuotaAllowance {\n featureCode: string;\n current: number;\n included: number;\n remaining: number | null;\n billedQuantity?: number;\n unlimited: boolean;\n overageEnabled: boolean;\n asOf: string | null;\n}\n\nexport interface AddQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface RemoveQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface GetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllQuotaParams {\n customerId: CustomerID;\n}\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.post(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.put(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.delete(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async get(params: GetQuotaParams): Promise<ApiResponse<QuotaAllowance>> {\n return this.httpClient.get(\"/usage/quota\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAll(\n params: GetAllQuotaParams,\n ): Promise<ApiResponse<QuotaAllowance[]>> {\n return this.httpClient.get(\"/usage/quota/all\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatEvent {\n id: string;\n object: \"seat\";\n livemode: boolean;\n organizationId: string;\n customerId: CustomerID;\n featureCode: string;\n eventType: \"add\" | \"remove\" | \"set\";\n quantity: number;\n previousBalance?: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface SeatBalance {\n current: number;\n asOf: string;\n}\n\nexport interface AddSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface SetAllSeatsParams {\n customerId: CustomerID;\n seats: Record<string, number>;\n}\n\nexport interface GetBalanceParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllBalancesParams {\n customerId: CustomerID;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n /** Removal 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async setAll(\n params: SetAllSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalance>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalance>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { BillingInterval, ConsumptionModel, FeatureType } from \"./plans\";\n\nexport type SubscriptionStatus =\n | \"draft\"\n | \"pending_payment\"\n | \"trialing\"\n | \"active\"\n | \"paused\"\n | \"past_due\"\n | \"canceled\"\n | \"expired\";\n\nexport interface FeatureSummary {\n code: string;\n name: string;\n type: FeatureType;\n enabled?: boolean;\n usage?: {\n current: number;\n included: number;\n overage: number;\n overageUnitPrice?: number;\n };\n}\n\nexport interface CreditsSummary {\n remaining: number;\n included: number;\n purchased: number;\n}\n\nexport interface BalanceSummary {\n remaining: number;\n included: number;\n currency: string;\n}\n\nexport interface CancellationSummary {\n scheduledAt: string;\n reason: string | null;\n effectiveAt: string;\n}\n\nexport interface DiscountSummary {\n type: \"percentage\" | \"amount\";\n value: number;\n name: string | null;\n endsAt: string | null;\n}\n\nexport interface ActiveSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n plan: {\n id: string;\n name: string;\n basePrice: number;\n billingInterval: BillingInterval | null;\n };\n name: string;\n description: string | null;\n status: SubscriptionStatus;\n consumptionModel: ConsumptionModel | null;\n trialEndsAt: string | null;\n currentPeriod: {\n start: string;\n end: string;\n daysRemaining: number;\n };\n features: FeatureSummary[];\n credits: CreditsSummary | null;\n balance: BalanceSummary | null;\n cancellation: CancellationSummary | null;\n discount: DiscountSummary | null;\n startDate: string;\n endDate: string | null;\n billingDayOfMonth: number;\n nextBillingDate: string;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreatedSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval | null;\n trialEndsAt: string | null;\n startDate: string;\n endDate: string | null;\n currentPeriodStart: string | null;\n currentPeriodEnd: string | null;\n billingDayOfMonth: number;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n introOfferEndsAt: string | null;\n introOfferDiscountType: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue: number | null;\n}\n\nexport interface Subscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n description?: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval;\n trialEndsAt?: string;\n startDate: string;\n endDate?: string;\n currentPeriodStart?: string;\n currentPeriodEnd?: string;\n billingDayOfMonth: number;\n checkoutUrl?: string;\n createdAt: string;\n updatedAt: string;\n}\n\ntype PlanIdentifier =\n | { planCode: string; planId?: never }\n | { planCode?: never; planId: string };\n\nexport interface CustomIntroOffer {\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number;\n}\n\nexport type CreateSubscriptionParams = PlanIdentifier & {\n customerId: string;\n} & {\n billingInterval?: BillingInterval;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n name?: string;\n startDate?: string;\n successUrl?: string;\n customIntroOffer?: CustomIntroOffer;\n};\n\nexport interface GetActiveParams {\n customerId: string;\n}\n\nexport interface CancelParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport interface UncancelParams {\n id: string;\n}\n\nexport interface ChangePlanParams {\n id: string;\n newPlanId?: string;\n newBillingInterval?: BillingInterval;\n /** Where to redirect after checkout when a free→paid change requires payment. */\n successUrl?: string;\n}\n\nexport interface ChangePlanResult {\n id: string;\n scheduled: boolean;\n customerId?: string;\n previousPlan?: { id: string; name: string };\n currentPlan?: { id: string; name: string; price: number };\n billingInterval?: string;\n billing?: {\n credit: number;\n creditsApplied: number;\n charge: number;\n taxAmount: number;\n netAmount: number;\n totalCharged: number;\n remainingCreditBalance: number;\n };\n invoiceId?: string;\n scheduledFor?: string;\n changeType?: string;\n requiresCheckout?: boolean;\n checkoutUrl?: string;\n}\n\nexport interface ListSubscriptionsParams extends Record<string, unknown> {\n customerId?: string;\n status?: SubscriptionStatus;\n limit?: number;\n cursor?: string;\n}\n\nexport interface SubscriptionListItem {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n startDate: string;\n endDate: string;\n billingDayOfMonth: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PreviewChangeParams {\n id: string;\n planId?: string;\n billingInterval?: BillingInterval;\n}\n\nexport interface PreviewChangeResult {\n currentPlanCredit: number;\n newPlanCharge: number;\n estimatedTotal: number;\n effectiveDate: string;\n daysRemaining: number;\n totalDays: number;\n isUpgrade: boolean;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface ActivateAddonResult {\n addonId: string;\n status: string;\n proratedCharge: number;\n}\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface DeactivateAddonResult {\n id: string;\n status: string;\n deactivatedAt: string;\n}\n\nexport interface AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"balance\" | \"credits\";\n}\n\nexport interface AdjustBalanceResult {\n amount: number;\n newBalance: number;\n reason: string | null;\n}\n\nexport interface TopupBalanceParams {\n id: string;\n amount: number;\n}\n\nexport interface TopupBalanceResult {\n amount: number;\n}\n\nexport interface PurchaseCreditsParams {\n id: string;\n creditPackId: string;\n}\n\nexport interface PurchaseCreditsResult {\n credits: number;\n}\n\n/** Each customer can only have one active subscription at a time. */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Returns a `checkoutUrl` when payment is required before activation. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreatedSubscription>> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n\n async getActive(\n params: GetActiveParams,\n ): Promise<ApiResponse<ActiveSubscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", {\n customerId: params.customerId,\n });\n }\n\n /** Schedules cancellation at period end by default. Set `immediate: true` to cancel now. */\n async cancel(\n params: CancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, body, options);\n }\n\n /** Only works on subscriptions with a pending cancellation — cannot revert already-canceled. */\n async uncancel(\n params: UncancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${params.id}/uncancel`,\n {},\n options,\n );\n }\n\n /** Upgrades execute immediately with proration. Downgrades are scheduled for end of period. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ChangePlanResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n body,\n options,\n );\n }\n\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<SubscriptionListItem[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /** Dry-run: returns proration details without applying the change. */\n async previewChange(\n params: PreviewChangeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PreviewChangeResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n body,\n options,\n );\n }\n\n /** Prorated charge for the current billing period. */\n async activateAddon(\n params: ActivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActivateAddonResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, body, options);\n }\n\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeactivateAddonResult>> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\n options,\n );\n }\n\n /** Positive amount adds, negative subtracts. */\n async adjustBalance(\n params: AdjustBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<AdjustBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/adjust`,\n body,\n options,\n );\n }\n\n /** Charges the customer's payment method. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TopupBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n body,\n options,\n );\n }\n\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PurchaseCreditsResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type TransactionStatus =\n | \"pending\"\n | \"succeeded\"\n | \"failed\"\n | \"refunded\"\n | \"disputed\";\n\nexport interface TransactionListItem {\n id: string;\n object: \"transaction\";\n livemode: boolean;\n invoiceId: string;\n grossAmount: number;\n subtotal: number;\n taxAmount: number;\n currency: string;\n status: TransactionStatus;\n customerEmail: string;\n customerName: string | null;\n paidAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface TransactionDetail extends TransactionListItem {\n availableAt: string | null;\n}\n\nexport interface TransactionRefundResult {\n id: string;\n status: \"refunded\";\n}\n\nexport interface TransactionRetryResult {\n id: string;\n status: \"processing\";\n retryInvoiceNumber: string;\n}\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 async list(\n params?: ListTransactionsParams,\n ): Promise<ApiResponse<TransactionListItem[]>> {\n return this.httpClient.get(\"/transactions\", params);\n }\n\n async get(\n params: GetTransactionParams,\n ): Promise<ApiResponse<TransactionDetail>> {\n return this.httpClient.get(`/transactions/${params.id}`);\n }\n\n /** Full refund only. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRefundResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/refund`,\n {},\n options,\n );\n }\n\n /** Creates a new invoice and initiates a new payment attempt. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRetryResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/retry`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { ConsumptionModel } from \"./plans\";\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { SubscriptionStatus } from \"./subscriptions\";\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-05-25\";\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 { 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 { 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 { TransactionsResource } from \"./resources/transactions\";\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> {\n private httpClient: CommetHTTPClient;\n\n public readonly addons: AddonsResource;\n public readonly apiKeys: ApiKeysResource;\n public readonly creditPacks: CreditPacksResource;\n public readonly customers: CustomersResource;\n public readonly features: FeaturesResource;\n public readonly invoices: InvoicesResource;\n public readonly planGroups: PlanGroupsResource;\n public readonly plans: PlansResource;\n public readonly portal: PortalResource;\n public readonly promoCodes: PromoCodesResource;\n public readonly quota: QuotaResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\n public readonly transactions: TransactionsResource;\n public readonly usage: UsageResource;\n public readonly webhooks: Webhooks;\n\n constructor(config: CommetClientOptions) {\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.addons = new AddonsResource(this.httpClient);\n this.apiKeys = new ApiKeysResource(this.httpClient);\n this.creditPacks = new CreditPacksResource(this.httpClient);\n this.customers = new CustomersResource(this.httpClient);\n this.features = new FeaturesResource(this.httpClient);\n this.invoices = new InvoicesResource(this.httpClient);\n this.planGroups = new PlanGroupsResource(this.httpClient);\n this.plans = new PlansResource(this.httpClient);\n this.portal = new PortalResource(this.httpClient);\n this.promoCodes = new PromoCodesResource(this.httpClient);\n this.quota = new QuotaResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(this.httpClient);\n this.transactions = new TransactionsResource(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","export { Commet, createCommet } from \"./client\";\nexport type {\n ActiveAddon,\n Addon,\n AddonConsumptionModel,\n BalanceAddon,\n BooleanAddon,\n CreateAddonParams,\n CreateBalanceAddonParams,\n CreateBooleanAddonParams,\n CreateCreditsAddonParams,\n CreateMeteredAddonParams,\n CreditsAddon,\n DeleteAddonParams,\n GetAddonParams,\n ListActiveAddonsParams,\n ListAddonsParams,\n MeteredAddon,\n UpdateAddonParams,\n} from \"./resources/addons\";\nexport type {\n ApiKey,\n ApiKeyCreated,\n CreateApiKeyParams,\n DeleteApiKeyParams,\n ListApiKeysParams,\n} from \"./resources/api-keys\";\nexport type {\n CreateCreditPackParams,\n CreditPack,\n CreditPackDetail,\n DeleteCreditPackParams,\n UpdateCreditPackParams,\n} from \"./resources/credit-packs\";\nexport type {\n BatchResult as CustomersBatchResult,\n CreateParams as CreateCustomerParams,\n Customer,\n CustomerAddress,\n GetCustomerParams,\n ListCustomersParams,\n UpdateParams as UpdateCustomerParams,\n} from \"./resources/customers\";\nexport type {\n CanUseFeatureParams,\n CanUseResult,\n CreateFeatureParams,\n DeleteFeatureParams,\n Feature,\n FeatureAccess,\n GetFeatureParams,\n ListFeaturesParams,\n UpdateFeatureParams,\n} from \"./resources/features\";\nexport type {\n ChargeType,\n CreateAdjustmentParams,\n CreateAdjustmentResult,\n GetDownloadUrlParams,\n GetInvoiceParams,\n InvoiceDetail,\n InvoiceDownloadResult,\n InvoiceLineItem,\n InvoiceLineType,\n InvoiceListItem,\n InvoiceSendResult,\n InvoiceStatus,\n InvoiceStatusResult,\n InvoiceType,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n AddPlanToGroupParams,\n CreatePlanGroupParams,\n DeletePlanGroupParams,\n GetPlanGroupParams,\n ListPlanGroupsParams,\n PlanGroup,\n PlanGroupDetail,\n RemovePlanFromGroupParams,\n ReorderPlansParams,\n UpdatePlanGroupParams,\n} from \"./resources/plan-groups\";\nexport type {\n AddAiModelPricingFeatureParams,\n AddFixedPricingFeatureParams,\n AddPlanFeatureParams,\n AddPlanPriceParams,\n AiModelPricingFeatureManage,\n BillingInterval,\n ConsumptionModel,\n CreatePlanParams,\n DeletePlanParams,\n DeletePlanPriceParams,\n DeleteRegionalPricesParams,\n DeleteResult,\n DiscountType,\n FeatureType,\n FixedPricingFeatureManage,\n ListPlansParams,\n Plan,\n PlanDetail,\n PlanFeature,\n PlanFeatureManage,\n PlanID,\n PlanManage,\n PlanPrice,\n PlanPriceManage,\n RegionalPriceResult,\n RemovePlanFeatureParams,\n RemoveResult,\n SetDefaultPriceParams,\n SetRegionalPricesParams,\n SetVisibilityParams,\n UpdatePlanFeatureParams,\n UpdatePlanParams,\n UpdatePlanPriceParams,\n} from \"./resources/plans\";\nexport type { GetUrlParams, PortalAccess } from \"./resources/portal\";\nexport type {\n CreatePromoCodeParams,\n GetPromoCodeParams,\n ListPromoCodesParams,\n PromoCode,\n PromoCodeDetail,\n UpdatePromoCodeParams,\n} from \"./resources/promo-codes\";\nexport type {\n AddQuotaParams,\n GetAllQuotaParams,\n GetQuotaParams,\n QuotaAllowance,\n QuotaEvent,\n RemoveQuotaParams,\n SetQuotaParams,\n} from \"./resources/quota\";\nexport type {\n AddSeatsParams,\n GetAllBalancesParams,\n GetBalanceParams,\n RemoveSeatsParams,\n SeatBalance,\n SeatEvent,\n SetAllSeatsParams,\n SetSeatsParams,\n} from \"./resources/seats\";\nexport type {\n ActivateAddonParams,\n ActivateAddonResult,\n ActiveSubscription,\n AdjustBalanceParams,\n AdjustBalanceResult,\n CancellationSummary,\n CancelParams,\n ChangePlanParams,\n ChangePlanResult,\n CreatedSubscription,\n CreateSubscriptionParams,\n CustomIntroOffer,\n DeactivateAddonParams,\n DeactivateAddonResult,\n DiscountSummary,\n FeatureSummary,\n GetActiveParams,\n ListSubscriptionsParams,\n PreviewChangeParams,\n PreviewChangeResult,\n PurchaseCreditsParams,\n PurchaseCreditsResult,\n Subscription,\n SubscriptionListItem,\n SubscriptionStatus,\n TopupBalanceParams,\n TopupBalanceResult,\n UncancelParams,\n} from \"./resources/subscriptions\";\nexport type {\n GetTransactionParams,\n ListTransactionsParams,\n RefundTransactionParams,\n RetryTransactionParams,\n TransactionDetail,\n TransactionListItem,\n TransactionRefundResult,\n TransactionRetryResult,\n TransactionStatus,\n} from \"./resources/transactions\";\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 { registerIntegration } from \"./utils/telemetry\";\nexport { API_VERSION, SDK_VERSION } from \"./version\";\n\nimport { Commet } from \"./client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CAAiC;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,SAAS,IAAI,eAAe,KAAK,UAAU;AAChD,SAAK,UAAU,IAAI,gBAAgB,KAAK,UAAU;AAClD,SAAK,cAAc,IAAI,oBAAoB,KAAK,UAAU;AAC1D,SAAK,YAAY,IAAI,kBAAkB,KAAK,UAAU;AACtD,SAAK,WAAW,IAAI,iBAAiB,KAAK,UAAU;AACpD,SAAK,WAAW,IAAI,iBAAiB,KAAK,UAAU;AACpD,SAAK,aAAa,IAAI,mBAAmB,KAAK,UAAU;AACxD,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,SAAS,IAAI,eAAe,KAAK,UAAU;AAChD,SAAK,aAAa,IAAI,mBAAmB,KAAK,UAAU;AACxD,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,gBAAgB,IAAI,sBAAsB,KAAK,UAAU;AAC9D,SAAK,eAAe,IAAI,qBAAqB,KAAK,UAAU;AAC5D,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;;;AC7BO,SAAS,aAA4C,QAAc;AACxE,SAAO;AACT;;;ACyMA,IAAO,gBAAQ;","names":["crypto"]}
|
|
1
|
+
{"version":3,"sources":["../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/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/transactions.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","../src/index.ts"],"sourcesContent":["import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport type AddonConsumptionModel =\n | \"boolean\"\n | \"metered\"\n | \"credits\"\n | \"balance\";\n\nexport interface ActiveAddon {\n object: \"addon\";\n livemode: boolean;\n slug: string;\n name: string;\n basePrice: number;\n featureCode: string;\n featureName: string;\n featureType: FeatureType;\n consumptionModel: AddonConsumptionModel | null;\n activatedAt: string;\n}\n\nexport interface ListActiveAddonsParams {\n customerId: CustomerID;\n}\n\ninterface AddonBase {\n id: string;\n object: \"addon\";\n livemode: boolean;\n name: string;\n slug: string;\n description: string | null;\n basePrice: number;\n featureCode: string;\n featureName: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface BooleanAddon extends AddonBase {\n consumptionModel: \"boolean\";\n includedUnits: null;\n overageRate: null;\n creditCost: null;\n}\n\nexport interface MeteredAddon extends AddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n creditCost: null;\n}\n\nexport interface CreditsAddon extends AddonBase {\n consumptionModel: \"credits\";\n includedUnits: null;\n overageRate: null;\n creditCost: number;\n}\n\nexport interface BalanceAddon extends AddonBase {\n consumptionModel: \"balance\";\n includedUnits: null;\n overageRate: number;\n creditCost: null;\n}\n\nexport type Addon = BooleanAddon | MeteredAddon | CreditsAddon | BalanceAddon;\n\nexport interface ListAddonsParams {\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetAddonParams {\n id: string;\n}\n\ninterface CreateAddonBase {\n name: string;\n description?: string;\n basePrice: number;\n featureId: string;\n}\n\nexport interface CreateBooleanAddonParams extends CreateAddonBase {\n consumptionModel: \"boolean\";\n}\n\nexport interface CreateMeteredAddonParams extends CreateAddonBase {\n consumptionModel: \"metered\";\n includedUnits: number;\n overageRate: number;\n}\n\nexport interface CreateCreditsAddonParams extends CreateAddonBase {\n consumptionModel: \"credits\";\n creditCost: number;\n}\n\nexport interface CreateBalanceAddonParams extends CreateAddonBase {\n consumptionModel: \"balance\";\n overageRate: number;\n}\n\nexport type CreateAddonParams =\n | CreateBooleanAddonParams\n | CreateMeteredAddonParams\n | CreateCreditsAddonParams\n | CreateBalanceAddonParams;\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 async listActive(\n params: ListActiveAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActiveAddon[]>> {\n return this.httpClient.get(\n \"/addons/active\",\n { customerId: params.customerId },\n options,\n );\n }\n\n async list(\n params?: ListAddonsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon[]>> {\n return this.httpClient.get(\"/addons\", params, options);\n }\n\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 async create(\n params: CreateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n return this.httpClient.post(\"/addons\", params, options);\n }\n\n async update(\n params: UpdateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Addon>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/addons/${id}`, body, options);\n }\n\n /** Fails if addon has active subscriptions. */\n async delete(\n params: DeleteAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface ApiKey {\n id: string;\n object: \"api_key\";\n livemode: boolean;\n name: string;\n prefix: string;\n expiresAt: string | null;\n lastUsedAt: string | null;\n createdAt: string;\n}\n\nexport interface ApiKeyCreated extends ApiKey {\n apiKey: string;\n}\n\nexport interface ListApiKeysParams {\n limit?: number;\n cursor?: string;\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 async list(params?: ListApiKeysParams): Promise<ApiResponse<ApiKey[]>> {\n return this.httpClient.get(\"/api-keys\", params);\n }\n\n /** Response includes full `apiKey` which is only returned once. */\n async create(\n params: CreateApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ApiKeyCreated>> {\n return this.httpClient.post(\"/api-keys\", params, options);\n }\n\n async delete(\n params: DeleteApiKeyParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(`/api-keys/${params.id}`, undefined, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface CreditPack {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n currency: string;\n}\n\nexport interface CreditPackDetail {\n id: string;\n object: \"credit_pack\";\n livemode: boolean;\n name: string;\n description: string | null;\n credits: number;\n price: number;\n isActive: boolean;\n createdAt: string;\n updatedAt: string;\n}\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 async list(): Promise<ApiResponse<CreditPack[]>> {\n return this.httpClient.get(\"/credit-packs\");\n }\n\n async create(\n params: CreateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n return this.httpClient.post(\"/credit-packs/manage\", params, options);\n }\n\n async update(\n params: UpdateCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreditPackDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/credit-packs/${id}`, body, options);\n }\n\n async delete(\n params: DeleteCreditPackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\n const { id } = params;\n return this.httpClient.delete(`/credit-packs/${id}`, undefined, options);\n }\n}\n","import type {\n ApiResponse,\n ListParams as BaseListParams,\n CustomerID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Customer {\n id: CustomerID;\n object: \"customer\";\n livemode: boolean;\n organizationId: string;\n fullName?: string;\n domain?: string;\n website?: string;\n billingEmail: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n}\n\nexport interface CreateParams {\n email: string; // billingEmail - the only required field\n id?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface GetCustomerParams {\n id: CustomerID;\n}\n\nexport interface UpdateParams {\n id: CustomerID;\n email?: string;\n fullName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n address?: CustomerAddress;\n}\n\nexport interface ListCustomersParams extends BaseListParams {\n search?: string;\n}\n\nexport interface BatchResult {\n successful: Customer[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateParams;\n }>;\n}\n\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Idempotent when `id` is provided — returns existing customer instead of duplicating. */\n async create(\n params: CreateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\n \"/customers\",\n {\n billingEmail: params.email,\n id: params.id,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async createBatch(\n params: { customers: CreateParams[] },\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult>> {\n const customers = params.customers.map((c) => ({\n billingEmail: c.email,\n id: c.id,\n fullName: c.fullName,\n domain: c.domain,\n website: c.website,\n timezone: c.timezone,\n language: c.language,\n industry: c.industry,\n metadata: c.metadata,\n address: c.address,\n }));\n return this.httpClient.post(\"/customers/batch\", { customers }, options);\n }\n\n async get(params: GetCustomerParams): Promise<ApiResponse<Customer>> {\n return this.httpClient.get(`/customers/${params.id}`);\n }\n\n async update(\n params: UpdateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${params.id}`,\n {\n billingEmail: params.email,\n fullName: params.fullName,\n domain: params.domain,\n website: params.website,\n timezone: params.timezone,\n language: params.language,\n industry: params.industry,\n metadata: params.metadata,\n address: params.address,\n },\n options,\n );\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params as Record<string, unknown>);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { FeatureType } from \"./plans\";\n\nexport interface GetFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface CanUseFeatureParams {\n customerId: CustomerID;\n code: string;\n}\n\nexport interface ListFeaturesParams {\n customerId: CustomerID;\n}\n\nexport interface FeatureAccess {\n object: \"feature\";\n livemode: boolean;\n code: string;\n name: string;\n type: FeatureType;\n allowed: boolean;\n enabled?: boolean;\n current?: number;\n included?: number;\n remaining?: number;\n overage?: number;\n overageUnitPrice?: number;\n billedQuantity?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n}\n\nexport interface CanUseResult {\n allowed: boolean;\n willBeCharged: boolean;\n reason?: string;\n}\n\nexport interface Feature {\n id: string;\n object: \"feature\";\n livemode: boolean;\n name: string;\n code: string;\n type: FeatureType;\n description: string | null;\n unitName: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreateFeatureParams {\n code: string;\n name: string;\n type: FeatureType;\n description?: string;\n unitName?: string;\n}\n\nexport interface UpdateFeatureParams {\n code: string;\n name?: string;\n description?: string;\n unitName?: string;\n}\n\nexport interface DeleteFeatureParams {\n code: string;\n}\n\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async get(\n params: GetFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId },\n options,\n );\n }\n\n /** Checks if the customer can consume one more unit — returns billing impact and reason if blocked. */\n async canUse(\n params: CanUseFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanUseResult>> {\n return this.httpClient.get(\n `/features/${params.code}`,\n { customerId: params.customerId, action: \"canUse\" },\n options,\n );\n }\n\n async list(\n params: ListFeaturesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess[]>> {\n return this.httpClient.get(\n \"/features\",\n { customerId: params.customerId },\n options,\n );\n }\n\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 async update(\n params: UpdateFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Feature>> {\n const { code, ...body } = params;\n return this.httpClient.put(`/features/${code}/manage`, body, options);\n }\n\n /** Fails if feature is attached to active plans or has an active addon. */\n async delete(\n params: DeleteFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ id: string; deleted: true }>> {\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { DiscountType } from \"./plans\";\n\nexport type InvoiceStatus =\n | \"draft\"\n | \"upcoming\"\n | \"outstanding\"\n | \"paid\"\n | \"void\"\n | \"uncollectible\";\nexport type InvoiceType =\n | \"recurring\"\n | \"overage\"\n | \"plan_change\"\n | \"adjustment\"\n | \"credit_purchase\"\n | \"balance_topup\"\n | \"addon_activation\";\nexport type InvoiceLineType =\n | \"plan_base\"\n | \"feature_overage\"\n | \"feature_seats\"\n | \"feature_quota\"\n | \"discount\"\n | \"credit\"\n | \"addon_base\";\nexport type ChargeType = \"standard\" | \"advance\" | \"true_up\";\n\nexport interface InvoiceLineItem {\n lineType: InvoiceLineType;\n featureName: string | null;\n description: string | null;\n quantity: number;\n unitAmount: number;\n amount: number;\n includedAmount: number | null;\n usedAmount: number | null;\n overageAmount: number | null;\n discountType: DiscountType | null;\n discountValue: number | null;\n discountName: string | null;\n chargeType: ChargeType | null;\n}\n\nexport interface InvoiceListItem {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n subscriptionId: string | null;\n invoiceNumber: string;\n status: InvoiceStatus;\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n discountAmount: number;\n taxAmount: number;\n total: number;\n periodStart: string | null;\n periodEnd: string | null;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface InvoiceDetail extends InvoiceListItem {\n creditApplied: number;\n planName: string | null;\n poNumber: string | null;\n reference: string | null;\n lineItems: InvoiceLineItem[];\n}\n\nexport interface InvoiceDownloadResult {\n url: string;\n expiresAt: string;\n}\n\nexport interface InvoiceSendResult {\n sent: boolean;\n sentAt: string;\n}\n\nexport interface InvoiceStatusResult {\n id: string;\n status: \"paid\" | \"void\";\n updatedAt: string;\n}\n\nexport interface CreateAdjustmentResult {\n id: string;\n object: \"invoice\";\n livemode: boolean;\n customerId: string;\n invoiceNumber: string;\n status: \"outstanding\" | \"paid\";\n invoiceType: InvoiceType;\n currency: string;\n subtotal: number;\n taxAmount: number;\n total: number;\n issueDate: string;\n dueDate: string | null;\n memo: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListInvoicesParams {\n customerId?: string;\n status?: InvoiceStatus;\n subscriptionId?: string;\n limit?: number;\n cursor?: string;\n}\n\nexport interface GetInvoiceParams {\n id: string;\n}\n\nexport interface CreateAdjustmentParams {\n customerId: string;\n amount: number;\n description?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface GetDownloadUrlParams {\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 async list(\n params?: ListInvoicesParams,\n ): Promise<ApiResponse<InvoiceListItem[]>> {\n return this.httpClient.get(\"/invoices\", params);\n }\n\n async get(params: GetInvoiceParams): Promise<ApiResponse<InvoiceDetail>> {\n return this.httpClient.get(`/invoices/${params.id}`);\n }\n\n /** Negative amount creates a credit. */\n async createAdjustment(\n params: CreateAdjustmentParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreateAdjustmentResult>> {\n return this.httpClient.post(\"/invoices\", params, options);\n }\n\n /** Signed URL, expires after 7 days. */\n async getDownloadUrl(\n params: GetDownloadUrlParams,\n ): Promise<ApiResponse<InvoiceDownloadResult>> {\n return this.httpClient.get(`/invoices/${params.id}/download`);\n }\n\n async send(\n params: SendInvoiceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceSendResult>> {\n return this.httpClient.post(`/invoices/${params.id}/send`, {}, options);\n }\n\n /** Only outstanding invoices can be changed to paid or void. */\n async updateStatus(\n params: UpdateInvoiceStatusParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<InvoiceStatusResult>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/invoices/${id}/status`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PlanGroup {\n id: string;\n object: \"plan_group\";\n livemode: boolean;\n name: string;\n description: string | null;\n isPublic: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PlanGroupDetail extends PlanGroup {\n plans: Array<{ id: string; code: string; name: string; sortOrder: number }>;\n}\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;\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 ReorderPlansParams {\n id: string;\n planIds: string[];\n}\n\nexport class PlanGroupsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlanGroupsParams): Promise<ApiResponse<PlanGroup[]>> {\n return this.httpClient.get(\"/plan-groups\", params);\n }\n\n async get(params: GetPlanGroupParams): Promise<ApiResponse<PlanGroupDetail>> {\n return this.httpClient.get(`/plan-groups/${params.id}`);\n }\n\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 async update(\n params: UpdatePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroup>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plan-groups/${id}`, body, options);\n }\n\n /** Plans in the group are unlinked, not deleted. */\n async delete(\n params: DeletePlanGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n return this.httpClient.delete(\n `/plan-groups/${params.id}`,\n undefined,\n options,\n );\n }\n\n async addPlan(\n params: AddPlanToGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/plan-groups/${id}/plans`, body, options);\n }\n\n async removePlan(\n params: RemovePlanFromGroupParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<void>> {\n const { id, planId } = params;\n return this.httpClient.delete(\n `/plan-groups/${id}/plans/${planId}`,\n undefined,\n options,\n );\n }\n\n async reorderPlans(\n params: ReorderPlansParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanGroupDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(\n `/plan-groups/${id}/plans/reorder`,\n body,\n options,\n );\n }\n}\n","import type { ApiResponse, ListParams, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PlanID = `plan_${string}`;\nexport type BillingInterval =\n | \"weekly\"\n | \"monthly\"\n | \"quarterly\"\n | \"yearly\"\n | \"one_time\";\nexport type FeatureType = \"boolean\" | \"usage\" | \"seats\" | \"quota\";\nexport type ConsumptionModel = \"metered\" | \"credits\" | \"balance\";\nexport type DiscountType = \"percentage\" | \"amount\";\n\nexport interface PlanPrice {\n billingInterval: BillingInterval;\n price: number; // in cents\n isDefault: boolean;\n trialDays: number;\n}\n\nexport interface PlanFeature {\n code: string;\n name: string;\n type: FeatureType;\n unitName: string | null;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n overageUnitPrice?: number;\n}\n\nexport interface Plan {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isFree: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanPrice[];\n features: PlanFeature[];\n createdAt: string;\n}\n\nexport interface PlanDetailPrice {\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n introOffer: {\n enabled: boolean;\n discountType: DiscountType | null;\n discountValue: number | null;\n durationCycles: number | null;\n } | null;\n}\n\nexport interface PlanDetailFeature extends PlanFeature {\n overage: {\n enabled: boolean;\n model: \"per_unit\" | null;\n unitPrice: number | null;\n } | null;\n}\n\nexport interface PlanDetail {\n id: PlanID;\n object: \"plan\";\n livemode: boolean;\n code: string;\n name: string;\n description: string | null;\n isPublic: boolean;\n isDefault: boolean;\n sortOrder: number;\n prices: PlanDetailPrice[];\n features: PlanDetailFeature[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface ListPlansParams extends ListParams {\n includePrivate?: boolean;\n}\n\nexport interface PlanManage {\n id: string;\n object: \"plan\";\n livemode: boolean;\n name: string;\n code: string;\n description: string | null;\n consumptionModel: ConsumptionModel | null;\n isPublic: boolean;\n isDefault: boolean;\n isFree: boolean;\n blockOnExhaustion: boolean;\n sortOrder: number;\n planGroupId: string | null;\n metadata: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface PlanFeatureManageBase {\n planId: string;\n featureId: string;\n enabled: boolean;\n includedAmount: number | null;\n unlimited: boolean;\n overageEnabled: boolean;\n creditsPerUnit: number | null;\n}\n\nexport interface FixedPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"fixed\";\n overageUnitPrice: number | null;\n margin: null;\n}\n\nexport interface AiModelPricingFeatureManage extends PlanFeatureManageBase {\n pricingMode: \"ai_model\";\n margin: number;\n overageUnitPrice: null;\n}\n\nexport type PlanFeatureManage =\n | FixedPricingFeatureManage\n | AiModelPricingFeatureManage;\n\nexport interface PlanPriceManage {\n id: string;\n object: \"plan_price\";\n livemode: boolean;\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n isDefault: boolean;\n trialDays: number;\n includedBalance: number | null;\n includedCredits: number | null;\n introOfferEnabled: boolean;\n introOfferDiscountType: DiscountType | null;\n introOfferDiscountValue: number | null;\n introOfferDurationCycles: number | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface RegionalPriceResult {\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteResult {\n id: string;\n deleted: true;\n}\n\nexport interface RemoveResult {\n id: string;\n removed: true;\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;\n metadata?: Record<string, unknown>;\n isPublic?: boolean;\n}\n\nexport interface DeletePlanParams {\n id: string;\n}\n\nexport interface SetVisibilityParams {\n id: string;\n isPublic: boolean;\n}\n\ninterface AddPlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface AddFixedPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface AddAiModelPricingFeatureParams extends AddPlanFeatureBase {\n pricingMode: \"ai_model\";\n margin: number;\n}\n\nexport type AddPlanFeatureParams =\n | AddFixedPricingFeatureParams\n | AddAiModelPricingFeatureParams;\n\ninterface UpdatePlanFeatureBase {\n planId: string;\n featureId: string;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n creditsPerUnit?: number | null;\n}\n\nexport interface UpdateFixedPricingFeatureParams extends UpdatePlanFeatureBase {\n pricingMode?: \"fixed\";\n overageUnitPrice?: number;\n}\n\nexport interface UpdateAiModelPricingFeatureParams\n extends UpdatePlanFeatureBase {\n pricingMode: \"ai_model\";\n margin?: number;\n}\n\nexport type UpdatePlanFeatureParams =\n | UpdateFixedPricingFeatureParams\n | UpdateAiModelPricingFeatureParams;\n\nexport interface RemovePlanFeatureParams {\n planId: string;\n featureId: string;\n}\n\nexport interface AddPlanPriceParams {\n planId: string;\n billingInterval: BillingInterval;\n price: number;\n trialDays?: number;\n isDefault?: boolean;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\";\n introOfferDiscountValue?: number;\n introOfferDurationCycles?: number;\n}\n\nexport interface UpdatePlanPriceParams {\n planId: string;\n priceId: string;\n price?: number;\n isDefault?: boolean;\n trialDays?: number;\n includedBalance?: number;\n includedCredits?: number;\n introOfferEnabled?: boolean;\n introOfferDiscountType?: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue?: number | null;\n introOfferDurationCycles?: number | null;\n}\n\nexport interface DeletePlanPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetDefaultPriceParams {\n planId: string;\n priceId: string;\n}\n\nexport interface SetRegionalPricesParams {\n planId: string;\n priceId: string;\n overrides: Array<{ currency: string; price: number }>;\n}\n\nexport interface DeleteRegionalPricesParams {\n planId: string;\n priceId: string;\n}\n\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>> {\n return this.httpClient.get(\"/plans\", params);\n }\n\n async get(params: { id: string }): Promise<ApiResponse<PlanDetail>> {\n return this.httpClient.get(`/plans/${params.id}`);\n }\n\n async create(\n params: CreatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n return this.httpClient.post(\"/plans/manage\", params, options);\n }\n\n async update(\n params: UpdatePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/manage`, body, options);\n }\n\n async delete(\n params: DeletePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n return this.httpClient.delete(\n `/plans/${params.id}/manage`,\n undefined,\n options,\n );\n }\n\n async setVisibility(\n params: SetVisibilityParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanManage>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/plans/${id}/visibility`, body, options);\n }\n\n async addFeature(\n params: AddPlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/features`, body, options);\n }\n\n async updateFeature(\n params: UpdatePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanFeatureManage>> {\n const { planId, featureId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/features/${featureId}`,\n body,\n options,\n );\n }\n\n async removeFeature(\n params: RemovePlanFeatureParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RemoveResult>> {\n const { planId, featureId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/features/${featureId}`,\n undefined,\n options,\n );\n }\n\n async addPrice(\n params: AddPlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, ...body } = params;\n return this.httpClient.post(`/plans/${planId}/prices`, body, options);\n }\n\n async updatePrice(\n params: UpdatePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}`,\n body,\n options,\n );\n }\n\n async deletePrice(\n params: DeletePlanPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}`,\n undefined,\n options,\n );\n }\n\n async setDefaultPrice(\n params: SetDefaultPriceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PlanPriceManage>> {\n const { planId, priceId } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/default`,\n {},\n options,\n );\n }\n\n async setRegionalPrices(\n params: SetRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<RegionalPriceResult>> {\n const { planId, priceId, ...body } = params;\n return this.httpClient.put(\n `/plans/${planId}/prices/${priceId}/regional`,\n body,\n options,\n );\n }\n\n async deleteRegionalPrices(\n params: DeleteRegionalPricesParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeleteResult>> {\n const { planId, priceId } = params;\n return this.httpClient.delete(\n `/plans/${planId}/prices/${priceId}/regional`,\n undefined,\n options,\n );\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PortalAccess {\n success: boolean;\n message: string;\n portalUrl: string;\n}\n\ninterface GetUrlByCustomerId {\n customerId: CustomerID;\n email?: never;\n}\n\ninterface GetUrlByEmail {\n email: string;\n customerId?: never;\n}\n\nexport type GetUrlParams = GetUrlByCustomerId | GetUrlByEmail;\n\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async getUrl(\n params: GetUrlParams,\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 { CommetHTTPClient } from \"../utils/http\";\n\nexport interface PromoCode {\n id: string;\n object: \"promo_code\";\n livemode: boolean;\n code: string;\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number | null;\n maxRedemptions: number | null;\n expiresAt: string | null;\n active: boolean;\n redemptionCount: number;\n createdAt: string;\n}\n\nexport interface PromoCodeDetail extends PromoCode {\n updatedAt: string;\n}\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: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles?: number;\n maxRedemptions?: number;\n expiresAt?: string;\n planIds?: string[];\n}\n\nexport interface UpdatePromoCodeParams {\n id: string;\n maxRedemptions?: number;\n expiresAt?: string;\n active?: boolean;\n planIds?: string[];\n}\n\nexport class PromoCodesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(params?: ListPromoCodesParams): Promise<ApiResponse<PromoCode[]>> {\n return this.httpClient.get(\"/promo-codes\", params);\n }\n\n async get(params: GetPromoCodeParams): Promise<ApiResponse<PromoCodeDetail>> {\n return this.httpClient.get(`/promo-codes/${params.id}`);\n }\n\n async create(\n params: CreatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCode>> {\n return this.httpClient.post(\"/promo-codes\", params, options);\n }\n\n async update(\n params: UpdatePromoCodeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PromoCodeDetail>> {\n const { id, ...body } = params;\n return this.httpClient.put(`/promo-codes/${id}`, body, options);\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface QuotaEvent {\n id: string;\n customerId: CustomerID;\n featureCode: string;\n previousBalance: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface QuotaAllowance {\n featureCode: string;\n current: number;\n included: number;\n remaining: number | null;\n billedQuantity?: number;\n unlimited: boolean;\n overageEnabled: boolean;\n asOf: string | null;\n}\n\nexport interface AddQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface RemoveQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface GetQuotaParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllQuotaParams {\n customerId: CustomerID;\n}\n\nexport class QuotaResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.post(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.put(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveQuotaParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<QuotaEvent>> {\n return this.httpClient.delete(\n \"/usage/quota\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async get(params: GetQuotaParams): Promise<ApiResponse<QuotaAllowance>> {\n return this.httpClient.get(\"/usage/quota\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAll(\n params: GetAllQuotaParams,\n ): Promise<ApiResponse<QuotaAllowance[]>> {\n return this.httpClient.get(\"/usage/quota/all\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatEvent {\n id: string;\n object: \"seat\";\n livemode: boolean;\n organizationId: string;\n customerId: CustomerID;\n featureCode: string;\n eventType: \"add\" | \"remove\" | \"set\";\n quantity: number;\n previousBalance?: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface SeatBalance {\n current: number;\n asOf: string;\n}\n\nexport interface AddSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count?: number;\n}\n\nexport interface SetSeatsParams {\n customerId: CustomerID;\n featureCode: string;\n count: number;\n}\n\nexport interface SetAllSeatsParams {\n customerId: CustomerID;\n seats: Record<string, number>;\n}\n\nexport interface GetBalanceParams {\n customerId: CustomerID;\n featureCode: string;\n}\n\nexport interface GetAllBalancesParams {\n customerId: CustomerID;\n}\n\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n /** Removal 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(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count ?? 1,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n featureCode: params.featureCode,\n count: params.count,\n },\n options,\n );\n }\n\n async setAll(\n params: SetAllSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalance>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n featureCode: params.featureCode,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalance>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n });\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { BillingInterval, ConsumptionModel, FeatureType } from \"./plans\";\n\nexport type SubscriptionStatus =\n | \"draft\"\n | \"pending_payment\"\n | \"trialing\"\n | \"active\"\n | \"paused\"\n | \"past_due\"\n | \"canceled\"\n | \"expired\";\n\nexport interface FeatureSummary {\n code: string;\n name: string;\n type: FeatureType;\n enabled?: boolean;\n usage?: {\n current: number;\n included: number;\n overage: number;\n overageUnitPrice?: number;\n };\n}\n\nexport interface CreditsSummary {\n remaining: number;\n included: number;\n purchased: number;\n}\n\nexport interface BalanceSummary {\n remaining: number;\n included: number;\n currency: string;\n}\n\nexport interface CancellationSummary {\n scheduledAt: string;\n reason: string | null;\n effectiveAt: string;\n}\n\nexport interface DiscountSummary {\n type: \"percentage\" | \"amount\";\n value: number;\n name: string | null;\n endsAt: string | null;\n}\n\nexport interface ActiveSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n plan: {\n id: string;\n name: string;\n basePrice: number;\n billingInterval: BillingInterval | null;\n };\n name: string;\n description: string | null;\n status: SubscriptionStatus;\n consumptionModel: ConsumptionModel | null;\n trialEndsAt: string | null;\n currentPeriod: {\n start: string;\n end: string;\n daysRemaining: number;\n };\n features: FeatureSummary[];\n credits: CreditsSummary | null;\n balance: BalanceSummary | null;\n cancellation: CancellationSummary | null;\n discount: DiscountSummary | null;\n startDate: string;\n endDate: string | null;\n billingDayOfMonth: number;\n nextBillingDate: string;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface CreatedSubscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval | null;\n trialEndsAt: string | null;\n startDate: string;\n endDate: string | null;\n currentPeriodStart: string | null;\n currentPeriodEnd: string | null;\n billingDayOfMonth: number;\n checkoutUrl: string | null;\n createdAt: string;\n updatedAt: string;\n introOfferEndsAt: string | null;\n introOfferDiscountType: \"percentage\" | \"amount\" | null;\n introOfferDiscountValue: number | null;\n}\n\nexport interface Subscription {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n description?: string;\n status: SubscriptionStatus;\n billingInterval: BillingInterval;\n trialEndsAt?: string;\n startDate: string;\n endDate?: string;\n currentPeriodStart?: string;\n currentPeriodEnd?: string;\n billingDayOfMonth: number;\n checkoutUrl?: string;\n createdAt: string;\n updatedAt: string;\n}\n\ntype PlanIdentifier =\n | { planCode: string; planId?: never }\n | { planCode?: never; planId: string };\n\nexport interface CustomIntroOffer {\n discountType: \"percentage\" | \"amount\";\n discountValue: number;\n durationCycles: number;\n}\n\nexport type CreateSubscriptionParams = PlanIdentifier & {\n customerId: string;\n} & {\n billingInterval?: BillingInterval;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n name?: string;\n startDate?: string;\n successUrl?: string;\n customIntroOffer?: CustomIntroOffer;\n};\n\nexport interface GetActiveParams {\n customerId: string;\n}\n\nexport interface CancelParams {\n id: string;\n reason?: string;\n immediate?: boolean;\n}\n\nexport interface UncancelParams {\n id: string;\n}\n\nexport interface ChangePlanParams {\n id: string;\n newPlanId?: string;\n newBillingInterval?: BillingInterval;\n /** Where to redirect after checkout when a free→paid change requires payment. */\n successUrl?: string;\n}\n\nexport interface ChangePlanResult {\n id: string;\n scheduled: boolean;\n customerId?: string;\n previousPlan?: { id: string; name: string };\n currentPlan?: { id: string; name: string; price: number };\n billingInterval?: string;\n billing?: {\n credit: number;\n creditsApplied: number;\n charge: number;\n taxAmount: number;\n netAmount: number;\n totalCharged: number;\n remainingCreditBalance: number;\n };\n invoiceId?: string;\n scheduledFor?: string;\n changeType?: string;\n requiresCheckout?: boolean;\n checkoutUrl?: string;\n}\n\nexport interface ListSubscriptionsParams extends Record<string, unknown> {\n customerId?: string;\n status?: SubscriptionStatus;\n limit?: number;\n cursor?: string;\n}\n\nexport interface SubscriptionListItem {\n id: string;\n object: \"subscription\";\n livemode: boolean;\n customerId: string;\n planId: string;\n planName: string;\n name: string;\n status: SubscriptionStatus;\n startDate: string;\n endDate: string;\n billingDayOfMonth: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PreviewChangeParams {\n id: string;\n planId?: string;\n billingInterval?: BillingInterval;\n}\n\nexport interface PreviewChangeResult {\n currency: string;\n currentPlanCredit: number;\n newPlanCharge: number;\n estimatedTotal: number;\n effectiveDate: string;\n daysRemaining: number;\n totalDays: number;\n isUpgrade: boolean;\n}\n\nexport interface ActivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface ActivateAddonResult {\n addonId: string;\n status: string;\n proratedCharge: number;\n}\n\nexport interface DeactivateAddonParams {\n id: string;\n addonId: string;\n}\n\nexport interface DeactivateAddonResult {\n id: string;\n status: string;\n deactivatedAt: string;\n}\n\nexport interface AdjustBalanceParams {\n id: string;\n amount: number;\n reason?: string;\n type?: \"balance\" | \"credits\";\n}\n\nexport interface AdjustBalanceResult {\n amount: number;\n newBalance: number;\n reason: string | null;\n}\n\nexport interface TopupBalanceParams {\n id: string;\n amount: number;\n}\n\nexport interface TopupBalanceResult {\n amount: number;\n}\n\nexport interface PurchaseCreditsParams {\n id: string;\n creditPackId: string;\n}\n\nexport interface PurchaseCreditsResult {\n credits: number;\n}\n\n/** Each customer can only have one active subscription at a time. */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /** Returns a `checkoutUrl` when payment is required before activation. */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<CreatedSubscription>> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n\n async getActive(\n params: GetActiveParams,\n ): Promise<ApiResponse<ActiveSubscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", {\n customerId: params.customerId,\n });\n }\n\n /** Schedules cancellation at period end by default. Set `immediate: true` to cancel now. */\n async cancel(\n params: CancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/cancel`, body, options);\n }\n\n /** Only works on subscriptions with a pending cancellation — cannot revert already-canceled. */\n async uncancel(\n params: UncancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${params.id}/uncancel`,\n {},\n options,\n );\n }\n\n /** Upgrades execute immediately with proration. Downgrades are scheduled for end of period. */\n async changePlan(\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ChangePlanResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/change-plan`,\n body,\n options,\n );\n }\n\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<SubscriptionListItem[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /** Dry-run: returns proration details without applying the change. */\n async previewChange(\n params: PreviewChangeParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PreviewChangeResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/preview-change`,\n body,\n options,\n );\n }\n\n /** Prorated charge for the current billing period. */\n async activateAddon(\n params: ActivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<ActivateAddonResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/addons`, body, options);\n }\n\n async deactivateAddon(\n params: DeactivateAddonParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<DeactivateAddonResult>> {\n const { id, addonId } = params;\n return this.httpClient.delete(\n `/subscriptions/${id}/addons/${addonId}`,\n undefined,\n options,\n );\n }\n\n /** Positive amount adds, negative subtracts. */\n async adjustBalance(\n params: AdjustBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<AdjustBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/adjust`,\n body,\n options,\n );\n }\n\n /** Charges the customer's payment method. */\n async topupBalance(\n params: TopupBalanceParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TopupBalanceResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(\n `/subscriptions/${id}/balance/topup`,\n body,\n options,\n );\n }\n\n async purchaseCredits(\n params: PurchaseCreditsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<PurchaseCreditsResult>> {\n const { id, ...body } = params;\n return this.httpClient.post(`/subscriptions/${id}/credits`, body, options);\n }\n}\n","import type { ApiResponse, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type TransactionStatus =\n | \"pending\"\n | \"succeeded\"\n | \"failed\"\n | \"refunded\"\n | \"disputed\";\n\nexport interface TransactionListItem {\n id: string;\n object: \"transaction\";\n livemode: boolean;\n invoiceId: string;\n grossAmount: number;\n subtotal: number;\n taxAmount: number;\n currency: string;\n status: TransactionStatus;\n customerEmail: string;\n customerName: string | null;\n paidAt: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface TransactionDetail extends TransactionListItem {\n availableAt: string | null;\n}\n\nexport interface TransactionRefundResult {\n id: string;\n status: \"refunded\";\n}\n\nexport interface TransactionRetryResult {\n id: string;\n status: \"processing\";\n retryInvoiceNumber: string;\n}\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 async list(\n params?: ListTransactionsParams,\n ): Promise<ApiResponse<TransactionListItem[]>> {\n return this.httpClient.get(\"/transactions\", params);\n }\n\n async get(\n params: GetTransactionParams,\n ): Promise<ApiResponse<TransactionDetail>> {\n return this.httpClient.get(`/transactions/${params.id}`);\n }\n\n /** Full refund only. */\n async refund(\n params: RefundTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRefundResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/refund`,\n {},\n options,\n );\n }\n\n /** Creates a new invoice and initiates a new payment attempt. */\n async retry(\n params: RetryTransactionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<TransactionRetryResult>> {\n return this.httpClient.post(\n `/transactions/${params.id}/retry`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { ConsumptionModel } from \"./plans\";\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 { CommetHTTPClient } from \"../utils/http\";\nimport type { SubscriptionStatus } from \"./subscriptions\";\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-05-25\";\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 { 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 { 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 { TransactionsResource } from \"./resources/transactions\";\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> {\n private httpClient: CommetHTTPClient;\n\n public readonly addons: AddonsResource;\n public readonly apiKeys: ApiKeysResource;\n public readonly creditPacks: CreditPacksResource;\n public readonly customers: CustomersResource;\n public readonly features: FeaturesResource;\n public readonly invoices: InvoicesResource;\n public readonly planGroups: PlanGroupsResource;\n public readonly plans: PlansResource;\n public readonly portal: PortalResource;\n public readonly promoCodes: PromoCodesResource;\n public readonly quota: QuotaResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\n public readonly transactions: TransactionsResource;\n public readonly usage: UsageResource;\n public readonly webhooks: Webhooks;\n\n constructor(config: CommetClientOptions) {\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.addons = new AddonsResource(this.httpClient);\n this.apiKeys = new ApiKeysResource(this.httpClient);\n this.creditPacks = new CreditPacksResource(this.httpClient);\n this.customers = new CustomersResource(this.httpClient);\n this.features = new FeaturesResource(this.httpClient);\n this.invoices = new InvoicesResource(this.httpClient);\n this.planGroups = new PlanGroupsResource(this.httpClient);\n this.plans = new PlansResource(this.httpClient);\n this.portal = new PortalResource(this.httpClient);\n this.promoCodes = new PromoCodesResource(this.httpClient);\n this.quota = new QuotaResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(this.httpClient);\n this.transactions = new TransactionsResource(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","export { Commet, createCommet } from \"./client\";\nexport type {\n ActiveAddon,\n Addon,\n AddonConsumptionModel,\n BalanceAddon,\n BooleanAddon,\n CreateAddonParams,\n CreateBalanceAddonParams,\n CreateBooleanAddonParams,\n CreateCreditsAddonParams,\n CreateMeteredAddonParams,\n CreditsAddon,\n DeleteAddonParams,\n GetAddonParams,\n ListActiveAddonsParams,\n ListAddonsParams,\n MeteredAddon,\n UpdateAddonParams,\n} from \"./resources/addons\";\nexport type {\n ApiKey,\n ApiKeyCreated,\n CreateApiKeyParams,\n DeleteApiKeyParams,\n ListApiKeysParams,\n} from \"./resources/api-keys\";\nexport type {\n CreateCreditPackParams,\n CreditPack,\n CreditPackDetail,\n DeleteCreditPackParams,\n UpdateCreditPackParams,\n} from \"./resources/credit-packs\";\nexport type {\n BatchResult as CustomersBatchResult,\n CreateParams as CreateCustomerParams,\n Customer,\n CustomerAddress,\n GetCustomerParams,\n ListCustomersParams,\n UpdateParams as UpdateCustomerParams,\n} from \"./resources/customers\";\nexport type {\n CanUseFeatureParams,\n CanUseResult,\n CreateFeatureParams,\n DeleteFeatureParams,\n Feature,\n FeatureAccess,\n GetFeatureParams,\n ListFeaturesParams,\n UpdateFeatureParams,\n} from \"./resources/features\";\nexport type {\n ChargeType,\n CreateAdjustmentParams,\n CreateAdjustmentResult,\n GetDownloadUrlParams,\n GetInvoiceParams,\n InvoiceDetail,\n InvoiceDownloadResult,\n InvoiceLineItem,\n InvoiceLineType,\n InvoiceListItem,\n InvoiceSendResult,\n InvoiceStatus,\n InvoiceStatusResult,\n InvoiceType,\n ListInvoicesParams,\n SendInvoiceParams,\n UpdateInvoiceStatusParams,\n} from \"./resources/invoices\";\nexport type {\n AddPlanToGroupParams,\n CreatePlanGroupParams,\n DeletePlanGroupParams,\n GetPlanGroupParams,\n ListPlanGroupsParams,\n PlanGroup,\n PlanGroupDetail,\n RemovePlanFromGroupParams,\n ReorderPlansParams,\n UpdatePlanGroupParams,\n} from \"./resources/plan-groups\";\nexport type {\n AddAiModelPricingFeatureParams,\n AddFixedPricingFeatureParams,\n AddPlanFeatureParams,\n AddPlanPriceParams,\n AiModelPricingFeatureManage,\n BillingInterval,\n ConsumptionModel,\n CreatePlanParams,\n DeletePlanParams,\n DeletePlanPriceParams,\n DeleteRegionalPricesParams,\n DeleteResult,\n DiscountType,\n FeatureType,\n FixedPricingFeatureManage,\n ListPlansParams,\n Plan,\n PlanDetail,\n PlanFeature,\n PlanFeatureManage,\n PlanID,\n PlanManage,\n PlanPrice,\n PlanPriceManage,\n RegionalPriceResult,\n RemovePlanFeatureParams,\n RemoveResult,\n SetDefaultPriceParams,\n SetRegionalPricesParams,\n SetVisibilityParams,\n UpdatePlanFeatureParams,\n UpdatePlanParams,\n UpdatePlanPriceParams,\n} from \"./resources/plans\";\nexport type { GetUrlParams, PortalAccess } from \"./resources/portal\";\nexport type {\n CreatePromoCodeParams,\n GetPromoCodeParams,\n ListPromoCodesParams,\n PromoCode,\n PromoCodeDetail,\n UpdatePromoCodeParams,\n} from \"./resources/promo-codes\";\nexport type {\n AddQuotaParams,\n GetAllQuotaParams,\n GetQuotaParams,\n QuotaAllowance,\n QuotaEvent,\n RemoveQuotaParams,\n SetQuotaParams,\n} from \"./resources/quota\";\nexport type {\n AddSeatsParams,\n GetAllBalancesParams,\n GetBalanceParams,\n RemoveSeatsParams,\n SeatBalance,\n SeatEvent,\n SetAllSeatsParams,\n SetSeatsParams,\n} from \"./resources/seats\";\nexport type {\n ActivateAddonParams,\n ActivateAddonResult,\n ActiveSubscription,\n AdjustBalanceParams,\n AdjustBalanceResult,\n CancellationSummary,\n CancelParams,\n ChangePlanParams,\n ChangePlanResult,\n CreatedSubscription,\n CreateSubscriptionParams,\n CustomIntroOffer,\n DeactivateAddonParams,\n DeactivateAddonResult,\n DiscountSummary,\n FeatureSummary,\n GetActiveParams,\n ListSubscriptionsParams,\n PreviewChangeParams,\n PreviewChangeResult,\n PurchaseCreditsParams,\n PurchaseCreditsResult,\n Subscription,\n SubscriptionListItem,\n SubscriptionStatus,\n TopupBalanceParams,\n TopupBalanceResult,\n UncancelParams,\n} from \"./resources/subscriptions\";\nexport type {\n GetTransactionParams,\n ListTransactionsParams,\n RefundTransactionParams,\n RetryTransactionParams,\n TransactionDetail,\n TransactionListItem,\n TransactionRefundResult,\n TransactionRetryResult,\n TransactionStatus,\n} from \"./resources/transactions\";\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 { registerIntegration } from \"./utils/telemetry\";\nexport { API_VERSION, SDK_VERSION } from \"./version\";\n\nimport { Commet } from \"./client\";\nexport default Commet;\n"],"mappings":";AA8HO,IAAM,iBAAN,MAAqB;AAAA,EAC1B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA,EAEnD,MAAM,WACJ,QACA,SACqC;AACrC,WAAO,KAAK,WAAW;AAAA,MACrB;AAAA,MACA,EAAE,YAAY,OAAO,WAAW;AAAA,MAChC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,KACJ,QACA,SAC+B;AAC/B,WAAO,KAAK,WAAW,IAAI,WAAW,QAAQ,OAAO;AAAA,EACvD;AAAA,EAEA,MAAM,IACJ,QACA,SAC6B;AAC7B,UAAM,EAAE,GAAG,IAAI;AACf,WAAO,KAAK,WAAW,IAAI,WAAW,EAAE,IAAI,QAAW,OAA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