@commet/node 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,3 +1,184 @@
1
+ // src/customer.ts
2
+ var CustomerContext = class {
3
+ constructor(httpClient, externalId) {
4
+ /**
5
+ * Feature access methods - check what the customer can use
6
+ */
7
+ this.features = {
8
+ /**
9
+ * Get detailed feature access/usage
10
+ */
11
+ get: (code, options) => {
12
+ return this.httpClient.get(
13
+ `/features/${code}`,
14
+ { externalId: this.externalId },
15
+ options
16
+ );
17
+ },
18
+ /**
19
+ * Check if a boolean feature is enabled
20
+ */
21
+ check: async (code, options) => {
22
+ const result = await this.httpClient.get(
23
+ `/features/${code}`,
24
+ { externalId: this.externalId },
25
+ options
26
+ );
27
+ if (!result.success || !result.data) {
28
+ return {
29
+ success: false,
30
+ data: { allowed: false },
31
+ message: result.message
32
+ };
33
+ }
34
+ return {
35
+ success: true,
36
+ data: { allowed: result.data.allowed },
37
+ message: result.message
38
+ };
39
+ },
40
+ /**
41
+ * Check if customer can use one more unit
42
+ */
43
+ canUse: (code, options) => {
44
+ return this.httpClient.get(
45
+ `/features/${code}`,
46
+ { externalId: this.externalId, action: "canUse" },
47
+ options
48
+ );
49
+ },
50
+ /**
51
+ * List all features
52
+ */
53
+ list: (options) => {
54
+ return this.httpClient.get(
55
+ "/features",
56
+ { externalId: this.externalId },
57
+ options
58
+ );
59
+ }
60
+ };
61
+ /**
62
+ * Seat management methods
63
+ */
64
+ this.seats = {
65
+ /**
66
+ * Add seats
67
+ */
68
+ add: (seatType, count = 1, options) => {
69
+ return this.httpClient.post(
70
+ "/seats/add",
71
+ { externalId: this.externalId, seatType, count },
72
+ options
73
+ );
74
+ },
75
+ /**
76
+ * Remove seats
77
+ */
78
+ remove: (seatType, count = 1, options) => {
79
+ return this.httpClient.post(
80
+ "/seats/remove",
81
+ { externalId: this.externalId, seatType, count },
82
+ options
83
+ );
84
+ },
85
+ /**
86
+ * Set total seat count
87
+ */
88
+ set: (seatType, count, options) => {
89
+ return this.httpClient.post(
90
+ "/seats/set",
91
+ { externalId: this.externalId, seatType, count },
92
+ options
93
+ );
94
+ },
95
+ /**
96
+ * Get current seat balance
97
+ */
98
+ getBalance: (seatType, options) => {
99
+ return this.httpClient.get(
100
+ "/seats/balance",
101
+ { externalId: this.externalId, seatType },
102
+ options
103
+ );
104
+ }
105
+ };
106
+ /**
107
+ * Usage tracking methods
108
+ */
109
+ this.usage = {
110
+ /**
111
+ * Track a usage event
112
+ */
113
+ track: (eventType, properties, options) => {
114
+ return this.httpClient.post(
115
+ "/usage",
116
+ {
117
+ externalId: this.externalId,
118
+ eventType,
119
+ properties
120
+ },
121
+ options
122
+ );
123
+ }
124
+ };
125
+ /**
126
+ * Subscription methods
127
+ */
128
+ this.subscription = {
129
+ /**
130
+ * Get active subscription
131
+ */
132
+ get: (options) => {
133
+ return this.httpClient.get(
134
+ "/subscriptions/active",
135
+ { externalId: this.externalId },
136
+ options
137
+ );
138
+ },
139
+ /**
140
+ * Cancel subscription
141
+ */
142
+ cancel: (params, options) => {
143
+ return this.httpClient.get(
144
+ "/subscriptions/active",
145
+ { externalId: this.externalId }
146
+ ).then((result) => {
147
+ if (!result.success || !result.data) {
148
+ return {
149
+ success: false,
150
+ data: null,
151
+ message: "No active subscription found"
152
+ };
153
+ }
154
+ return this.httpClient.post(
155
+ `/subscriptions/${result.data.id}/cancel`,
156
+ params || {},
157
+ options
158
+ );
159
+ });
160
+ }
161
+ };
162
+ /**
163
+ * Portal methods
164
+ */
165
+ this.portal = {
166
+ /**
167
+ * Get customer portal URL
168
+ */
169
+ getUrl: (options) => {
170
+ return this.httpClient.get(
171
+ "/portal/url",
172
+ { externalId: this.externalId },
173
+ options
174
+ );
175
+ }
176
+ };
177
+ this.httpClient = httpClient;
178
+ this.externalId = externalId;
179
+ }
180
+ };
181
+
1
182
  // src/resources/customers.ts
2
183
  var CustomersResource = class {
3
184
  constructor(httpClient) {
@@ -89,6 +270,97 @@ var CustomersResource = class {
89
270
  }
90
271
  };
91
272
 
273
+ // src/resources/features.ts
274
+ var FeaturesResource = class {
275
+ constructor(httpClient) {
276
+ this.httpClient = httpClient;
277
+ }
278
+ /**
279
+ * Get detailed feature access/usage for a customer
280
+ *
281
+ * @example
282
+ * ```typescript
283
+ * const seats = await commet.features.get("team_members", "user_123");
284
+ * console.log(seats.current, seats.included, seats.remaining);
285
+ * ```
286
+ */
287
+ async get(code, externalId, options) {
288
+ return this.httpClient.get(
289
+ `/features/${code}`,
290
+ { externalId },
291
+ options
292
+ );
293
+ }
294
+ /**
295
+ * Check if a boolean feature is enabled for a customer
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const { allowed } = await commet.features.check("custom_branding", "user_123");
300
+ * if (!allowed) redirect("/upgrade");
301
+ * ```
302
+ */
303
+ async check(code, externalId, options) {
304
+ const result = await this.httpClient.get(
305
+ `/features/${code}`,
306
+ { externalId },
307
+ options
308
+ );
309
+ if (!result.success || !result.data) {
310
+ return {
311
+ success: false,
312
+ data: { allowed: false },
313
+ message: result.message
314
+ };
315
+ }
316
+ return {
317
+ success: true,
318
+ data: { allowed: result.data.allowed },
319
+ message: result.message
320
+ };
321
+ }
322
+ /**
323
+ * Check if customer can use one more unit of a feature
324
+ *
325
+ * Returns whether the customer can add one more (allowed)
326
+ * and whether they'll be charged extra (willBeCharged).
327
+ *
328
+ * @example
329
+ * ```typescript
330
+ * const { allowed, willBeCharged } = await commet.features.canUse("team_members", "user_123");
331
+ *
332
+ * if (!allowed) {
333
+ * return { error: "Upgrade to add more members" };
334
+ * }
335
+ *
336
+ * if (willBeCharged) {
337
+ * // Show confirmation: "This will cost $10/month extra"
338
+ * }
339
+ * ```
340
+ */
341
+ async canUse(code, externalId, options) {
342
+ return this.httpClient.get(
343
+ `/features/${code}`,
344
+ { externalId, action: "canUse" },
345
+ options
346
+ );
347
+ }
348
+ /**
349
+ * List all features for a customer's active subscription
350
+ *
351
+ * @example
352
+ * ```typescript
353
+ * const features = await commet.features.list("user_123");
354
+ * for (const feature of features) {
355
+ * console.log(feature.code, feature.allowed);
356
+ * }
357
+ * ```
358
+ */
359
+ async list(externalId, options) {
360
+ return this.httpClient.get("/features", { externalId }, options);
361
+ }
362
+ };
363
+
92
364
  // src/resources/plans.ts
93
365
  var PlansResource = class {
94
366
  constructor(httpClient) {
@@ -110,17 +382,17 @@ var PlansResource = class {
110
382
  return this.httpClient.get("/plans", params);
111
383
  }
112
384
  /**
113
- * Get a specific plan by ID
385
+ * Get a specific plan by code
114
386
  *
115
387
  * @example
116
388
  * ```typescript
117
- * const plan = await commet.plans.get('plan_xxx');
389
+ * const plan = await commet.plans.get('pro');
118
390
  * console.log(plan.data.name); // "Pro"
119
391
  * console.log(plan.data.prices); // [{ billingInterval: 'monthly', price: 9900 }]
120
392
  * ```
121
393
  */
122
- async get(planId) {
123
- return this.httpClient.get(`/plans/${planId}`);
394
+ async get(planCode) {
395
+ return this.httpClient.get(`/plans/${planCode}`);
124
396
  }
125
397
  };
126
398
 
@@ -720,6 +992,7 @@ var Commet = class {
720
992
  this.seats = new SeatsResource(this.httpClient);
721
993
  this.subscriptions = new SubscriptionsResource(this.httpClient);
722
994
  this.portal = new PortalResource(this.httpClient);
995
+ this.features = new FeaturesResource(this.httpClient);
723
996
  this.webhooks = new Webhooks();
724
997
  if (config.debug) {
725
998
  console.log(`[Commet SDK] Initialized in ${this.environment} mode`);
@@ -728,6 +1001,22 @@ var Commet = class {
728
1001
  console.log("Base URL:", baseURL);
729
1002
  }
730
1003
  }
1004
+ /**
1005
+ * Create a customer-scoped context for cleaner API usage
1006
+ *
1007
+ * @example
1008
+ * ```typescript
1009
+ * const customer = commet.customer("user_123");
1010
+ *
1011
+ * // All operations are now scoped to this customer
1012
+ * const seats = await customer.features.get("team_members");
1013
+ * await customer.seats.add("member");
1014
+ * await customer.usage.track("api_call");
1015
+ * ```
1016
+ */
1017
+ customer(externalId) {
1018
+ return new CustomerContext(this.httpClient, externalId);
1019
+ }
731
1020
  getEnvironment() {
732
1021
  return this.environment;
733
1022
  }
@@ -754,6 +1043,7 @@ export {
754
1043
  CommetAPIError,
755
1044
  CommetError,
756
1045
  CommetValidationError,
1046
+ CustomerContext,
757
1047
  Webhooks,
758
1048
  index_default as default,
759
1049
  isProduction,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resources/customers.ts","../src/resources/plans.ts","../src/resources/portal.ts","../src/resources/seats.ts","../src/resources/subscriptions.ts","../src/resources/usage.ts","../src/resources/webhooks.ts","../src/types/common.ts","../src/utils/http.ts","../src/client.ts","../src/utils/environment.ts","../src/index.ts"],"sourcesContent":["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 organizationId: string;\n externalId?: string;\n legalName?: string;\n displayName?: 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 isActive: boolean;\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 externalId?: string;\n legalName?: string;\n displayName?: 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 UpdateParams {\n externalId?: string;\n email?: string;\n legalName?: string;\n displayName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface ListCustomersParams extends BaseListParams {\n externalId?: string;\n isActive?: boolean;\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\n/**\n * Customers resource - Manage your customers\n */\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a customer (idempotent with externalId)\n */\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 externalId: params.externalId,\n legalName: params.legalName,\n displayName: params.displayName,\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 /**\n * Create multiple customers in batch\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 externalId: c.externalId,\n legalName: c.legalName,\n displayName: c.displayName,\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 /**\n * Get a customer by ID\n */\n async get(customerId: CustomerID): Promise<ApiResponse<Customer>> {\n return this.httpClient.get(`/customers/${customerId}`);\n }\n\n /**\n * Update a customer\n */\n async update(\n customerId: CustomerID,\n params: UpdateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${customerId}`,\n {\n billingEmail: params.email,\n externalId: params.externalId,\n legalName: params.legalName,\n displayName: params.displayName,\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 },\n options,\n );\n }\n\n /**\n * List customers with optional filters\n */\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params as Record<string, unknown>);\n }\n\n /**\n * Archive a customer\n */\n async archive(\n customerId: CustomerID,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${customerId}`,\n { isActive: false },\n options,\n );\n }\n}\n","import type { ApiResponse, ListParams } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PlanID = `plan_${string}`;\nexport type BillingInterval = \"monthly\" | \"quarterly\" | \"yearly\";\nexport type FeatureType = \"boolean\" | \"metered\" | \"seats\";\n\nexport interface PlanPrice {\n billingInterval: BillingInterval;\n price: number; // in cents\n isDefault: boolean;\n}\n\nexport interface PlanFeature {\n code: string;\n name: string;\n type: FeatureType;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n overageUnitPrice?: number;\n}\n\nexport interface Plan {\n id: PlanID;\n name: string;\n description?: string;\n isPublic: boolean;\n isDefault: boolean;\n trialDays: number;\n sortOrder: number;\n prices: PlanPrice[];\n features: PlanFeature[];\n createdAt: string;\n}\n\nexport interface PlanDetail extends Plan {\n features: Array<\n PlanFeature & {\n unitName?: string;\n overage?: {\n enabled: boolean;\n model: \"per_unit\" | \"tiered\";\n unitPrice: number;\n tiers?: Array<{\n order: number;\n upTo: number | null;\n unitAmount: number;\n flatFee: number;\n }>;\n } | null;\n }\n >;\n updatedAt: string;\n}\n\nexport interface ListPlansParams extends ListParams {\n includePrivate?: boolean;\n}\n\n/**\n * Plans resource for listing available plans\n */\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * List all available plans\n *\n * @example\n * ```typescript\n * // List public plans\n * const plans = await commet.plans.list();\n *\n * // Include private plans\n * const allPlans = await commet.plans.list({ includePrivate: true });\n * ```\n */\n async list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>> {\n return this.httpClient.get(\"/plans\", params);\n }\n\n /**\n * Get a specific plan by ID\n *\n * @example\n * ```typescript\n * const plan = await commet.plans.get('plan_xxx');\n * console.log(plan.data.name); // \"Pro\"\n * console.log(plan.data.prices); // [{ billingInterval: 'monthly', price: 9900 }]\n * ```\n */\n async get(planId: string): Promise<ApiResponse<PlanDetail>> {\n return this.httpClient.get(`/plans/${planId}`);\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 externalId?: never;\n}\n\ninterface GetUrlByExternalId {\n externalId: string;\n email?: never;\n customerId?: never;\n}\n\ninterface GetUrlByEmail {\n email: string;\n customerId?: never;\n externalId?: never;\n}\n\nexport type GetUrlParams =\n | GetUrlByCustomerId\n | GetUrlByExternalId\n | GetUrlByEmail;\n\n/**\n * Portal resource - Generate customer portal access\n */\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Get a portal URL\n *\n * @example\n * ```typescript\n * const portal = await commet.portal.getUrl({ externalId: 'user_123' });\n * ```\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 {\n ApiResponse,\n CustomerID,\n GeneratedSeatType,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatEvent {\n id: string;\n organizationId: string;\n customerId: CustomerID;\n seatType: GeneratedSeatType;\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 AddParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface RemoveParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetAllParams {\n customerId?: CustomerID;\n externalId?: string;\n seats: Record<string, number>;\n}\n\nexport interface GetBalanceParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n}\n\nexport interface GetAllBalancesParams {\n customerId?: CustomerID;\n externalId?: string;\n}\n\n/**\n * Seats resource - Manage seat-based licenses\n */\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Add seats\n *\n * @example\n * ```typescript\n * await commet.seats.add({\n * externalId: 'user_123',\n * seatType: 'editor',\n * count: 5\n * });\n * ```\n */\n async add(\n params: AddParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\"/seats\", params, options);\n }\n\n /**\n * Remove seats\n *\n * @example\n * ```typescript\n * await commet.seats.remove({\n * externalId: 'user_123',\n * seatType: 'editor',\n * count: 2\n * });\n * ```\n */\n async remove(\n params: RemoveParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\"/seats\", params, options);\n }\n\n /**\n * Set seats to a specific count\n *\n * @example\n * ```typescript\n * await commet.seats.set({\n * externalId: 'user_123',\n * seatType: 'editor',\n * count: 10\n * });\n * ```\n */\n async set(\n params: SetParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\"/seats\", params, options);\n }\n\n /**\n * Set all seat types\n *\n * @example\n * ```typescript\n * await commet.seats.setAll({\n * externalId: 'user_123',\n * seats: { editor: 10, viewer: 50 }\n * });\n * ```\n */\n async setAll(\n params: SetAllParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n /**\n * Get balance for a seat type\n *\n * @example\n * ```typescript\n * const balance = await commet.seats.getBalance({\n * externalId: 'user_123',\n * seatType: 'editor'\n * });\n * ```\n */\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalance>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n });\n }\n\n /**\n * Get all seat balances\n *\n * @example\n * ```typescript\n * const balances = await commet.seats.getAllBalances({\n * externalId: 'user_123'\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 externalId: params.externalId,\n });\n }\n}\n","import type {\n ApiResponse,\n GeneratedPlanCode,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { BillingInterval } 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: \"boolean\" | \"metered\" | \"seats\";\n enabled?: boolean;\n usage?: {\n current: number;\n included: number;\n overage: number;\n };\n}\n\nexport interface ActiveSubscription {\n id: string;\n customerId: string;\n plan: {\n id: string;\n name: string;\n basePrice: number;\n billingInterval: BillingInterval;\n };\n name: string;\n description?: string;\n status: SubscriptionStatus;\n trialEndsAt?: string;\n currentPeriod: {\n start: string;\n end: string;\n daysRemaining: number;\n };\n features: FeatureSummary[];\n startDate: string;\n endDate?: string;\n billingDayOfMonth: number;\n nextBillingDate: string;\n checkoutUrl?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface Subscription {\n id: string;\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\n// Customer identifier: mutually exclusive customerId or externalId\ntype CustomerIdentifier =\n | { customerId: string; externalId?: never }\n | { customerId?: never; externalId: string };\n\n// Plan identifier: use planCode (with autocomplete) or planId (legacy)\ntype PlanIdentifier =\n | { planCode: GeneratedPlanCode; planId?: never }\n | { planCode?: never; planId: string };\n\nexport type CreateSubscriptionParams = CustomerIdentifier &\n PlanIdentifier & {\n billingInterval?: BillingInterval;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n name?: string;\n startDate?: string;\n };\n\nexport type ChangePlanParams = PlanIdentifier & {\n billingInterval?: BillingInterval;\n};\n\nexport interface CancelParams {\n reason?: string;\n immediate?: boolean;\n}\n\nexport type GetSubscriptionParams = CustomerIdentifier;\n\n/**\n * Subscription resource for managing subscriptions (plan-first model)\n *\n * Each customer can only have ONE active subscription at a time.\n */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a subscription with a plan\n *\n * @example\n * ```typescript\n * await commet.subscriptions.create({\n * externalId: 'user_123',\n * planCode: 'pro', // autocomplete works after `commet pull`\n * billingInterval: 'yearly',\n * initialSeats: { editor: 5 }\n * });\n * ```\n */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n\n /**\n * Get the active subscription for a customer\n *\n * @example\n * ```typescript\n * const sub = await commet.subscriptions.get({ externalId: 'user_123' });\n * ```\n */\n async get(\n params: GetSubscriptionParams,\n ): Promise<ApiResponse<ActiveSubscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", params);\n }\n\n /**\n * Change the plan of a subscription (upgrade/downgrade)\n *\n * @example\n * ```typescript\n * await commet.subscriptions.changePlan('sub_xxx', {\n * planCode: 'enterprise' // autocomplete works after `commet pull`\n * });\n * ```\n */\n async changePlan(\n subscriptionId: string,\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/change-plan`,\n params,\n options,\n );\n }\n\n /**\n * Cancel a subscription\n *\n * @example\n * ```typescript\n * await commet.subscriptions.cancel('sub_xxx', {\n * reason: 'switched_to_competitor'\n * });\n * ```\n */\n async cancel(\n subscriptionId: string,\n params?: CancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/cancel`,\n params || {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n GeneratedEventType,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface UsageEvent {\n id: EventID;\n organizationId: string;\n customerId: CustomerID;\n eventType: GeneratedEventType;\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\nexport interface BatchResult<T> {\n successful: T[];\n failed: Array<{\n index: number;\n error: string;\n data: TrackParams;\n }>;\n}\n\nexport interface TrackParams {\n eventType: GeneratedEventType;\n customerId?: CustomerID;\n externalId?: string;\n idempotencyKey?: string;\n value?: number;\n timestamp?: string;\n properties?: Record<string, string>;\n}\n\n/**\n * Usage resource - Track consumption events for usage-based billing\n */\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Track a usage event\n *\n * @example\n * ```typescript\n * await commet.usage.track({\n * externalId: 'user_123',\n * eventType: 'api_call',\n * idempotencyKey: `evt_${requestId}`,\n * properties: { endpoint: '/users', method: 'GET' }\n * });\n * ```\n */\n async track(\n params: TrackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData = {\n eventType: params.eventType,\n customerId: params.customerId,\n externalId: params.externalId,\n idempotencyKey: params.idempotencyKey,\n ts: 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 return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n /**\n * Track multiple usage events in a batch\n *\n * @example\n * ```typescript\n * await commet.usage.trackBatch({\n * events: [\n * { externalId: 'user_123', eventType: 'api_call', idempotencyKey: 'evt_1' },\n * { externalId: 'user_456', eventType: 'api_call', idempotencyKey: 'evt_2' }\n * ]\n * });\n * ```\n */\n async trackBatch(\n params: { events: TrackParams[] },\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult<UsageEvent>>> {\n const events = params.events.map((event) => ({\n eventType: event.eventType,\n customerId: event.customerId,\n externalId: event.externalId,\n idempotencyKey: event.idempotencyKey,\n ts: event.timestamp || new Date().toISOString(),\n properties: event.properties\n ? Object.entries(event.properties).map(([property, value]) => ({\n property,\n value,\n }))\n : undefined,\n }));\n\n return this.httpClient.post(\"/usage/events/batch\", { events }, options);\n }\n}\n","import crypto from \"node:crypto\";\n\n/**\n * Webhook payload structure from Commet\n */\nexport interface WebhookPayload {\n event: WebhookEvent;\n timestamp: string;\n organizationId: string;\n data: WebhookData;\n}\n\n/**\n * Webhook data structure (subscription-related fields)\n */\nexport interface WebhookData {\n id?: string;\n publicId?: string;\n subscriptionId?: string;\n customerId?: string;\n externalId?: string;\n status?: string;\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\n/**\n * Webhooks resource for signature verification\n */\nexport class Webhooks {\n /**\n * Verify HMAC-SHA256 webhook signature\n *\n * Use this method to verify that webhooks are authentically from Commet.\n * The signature is included in the `X-Commet-Signature` header.\n *\n * @param payload - Raw request body as string (IMPORTANT: Do not parse JSON first)\n * @param signature - Value from X-Commet-Signature header\n * @param secret - Your webhook secret from Commet dashboard\n * @returns true if signature is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Next.js API route example\n * export async function POST(request: Request) {\n * const rawBody = await request.text();\n * const signature = request.headers.get('x-commet-signature');\n *\n * const isValid = commet.webhooks.verify(\n * rawBody,\n * signature,\n * process.env.COMMET_WEBHOOK_SECRET\n * );\n *\n * if (!isValid) {\n * return new Response('Invalid signature', { status: 401 });\n * }\n *\n * const payload = JSON.parse(rawBody);\n * // Handle webhook event...\n * }\n * ```\n */\n verify(payload: string, signature: string | null, secret: string): boolean {\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 /**\n * Generate HMAC-SHA256 signature (internal use)\n * @internal\n */\n private generateSignature(payload: string, secret: string): string {\n return crypto.createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n }\n\n /**\n * Parse and verify webhook payload in one step\n *\n * @param rawBody - Raw request body as string\n * @param signature - Value from X-Commet-Signature header\n * @param secret - Your webhook secret from Commet dashboard\n * @returns Parsed payload if valid, null if invalid\n *\n * @example\n * ```typescript\n * const payload = commet.webhooks.verifyAndParse(\n * rawBody,\n * signature,\n * process.env.COMMET_WEBHOOK_SECRET\n * );\n *\n * if (!payload) {\n * return new Response('Invalid signature', { status: 401 });\n * }\n *\n * // payload is typed and validated\n * if (payload.event === 'subscription.activated') {\n * // Handle activation...\n * }\n * ```\n */\n verifyAndParse(\n rawBody: string,\n signature: string | null,\n secret: string,\n ): WebhookPayload | null {\n if (!this.verify(rawBody, signature, secret)) {\n return null;\n }\n\n try {\n return JSON.parse(rawBody) as WebhookPayload;\n } catch {\n return null;\n }\n }\n}\n","export type Environment = \"sandbox\" | \"production\";\n\nexport type CommetConfig = {\n apiKey: string;\n environment?: Environment;\n debug?: boolean;\n timeout?: number;\n retries?: number;\n};\n\n// API Response types\nexport interface ApiResponse<T = unknown> {\n success: boolean;\n data?: T;\n error?: string;\n message?: string;\n // Pagination fields (optional, included for list endpoints)\n hasMore?: boolean;\n nextCursor?: 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 constructor(\n message: string,\n public statusCode: number,\n public code?: string,\n public details?: unknown,\n ) {\n super(message, code, statusCode, details);\n this.name = \"CommetAPIError\";\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 = `cus_${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 idempotencyKey?: string;\n timeout?: number;\n}\n\n/**\n * Generated types interface - augmented by CLI after 'commet pull'\n *\n * This interface gets filled by module augmentation when you run `commet pull`.\n * The CLI generates a .commet.d.ts file that augments this interface with your\n * organization's specific event and seat types.\n *\n * @example\n * // After running `commet pull`, TypeScript will automatically know your types:\n * await commet.usage.events.create({\n * eventType: 'api_call', // Autocomplete works!\n * customerId: 'cus_123'\n * });\n */\n\n// biome-ignore lint/suspicious/noEmptyInterface: <explanation>\nexport interface CommetGeneratedTypes {}\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedEventType = CommetGeneratedTypes extends {\n eventType: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedSeatType = CommetGeneratedTypes extends {\n seatType: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n * @deprecated Use GeneratedPlanCode instead\n */\nexport type GeneratedProductId = CommetGeneratedTypes extends {\n productId: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedPlanCode = CommetGeneratedTypes extends {\n planCode: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedFeatureCode = CommetGeneratedTypes extends {\n featureCode: infer T;\n}\n ? T\n : string;\n","import type {\n ApiResponse,\n CommetConfig,\n Environment,\n RequestOptions,\n} from \"../types/common\";\nimport { CommetAPIError, CommetValidationError } from \"../types/common\";\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: CommetConfig;\n private environment: Environment;\n private retryConfig: RetryConfig;\n\n constructor(config: CommetConfig, environment: Environment) {\n this.config = config;\n this.environment = environment;\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>,\n options?: RequestOptions,\n ): Promise<ApiResponse<T>> {\n return this.request(\"GET\", endpoint, undefined, options, params);\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 /**\n * Core request method with retry logic\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 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 headers: Record<string, string> = {\n \"x-api-key\": this.config.apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": \"commet/0.1.0\",\n };\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n } else if (method === \"POST\" && data) {\n headers[\"Idempotency-Key\"] = this.generateIdempotencyKey();\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 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 // For 404 errors with invalid JSON, return a graceful response\n // This handles cases like HTML error pages or empty responses\n if (response.status === 404) {\n return {\n success: false,\n error: \"Resource not found\",\n } as ApiResponse<T>;\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 // Type guard for error response\n const isErrorResponse = (\n data: unknown,\n ): data is {\n message?: string;\n errors?: Record<string, string[]>;\n code?: string;\n details?: unknown;\n } => {\n return typeof data === \"object\" && data !== null;\n };\n\n const errorData = isErrorResponse(responseData) ? responseData : {};\n\n // Handle different error types\n if (response.status === 400 && errorData.errors) {\n throw new CommetValidationError(\n errorData.message || \"Validation failed\",\n errorData.errors,\n );\n }\n\n throw new CommetAPIError(\n errorData.message || `Request failed with status ${response.status}`,\n response.status,\n errorData.code,\n errorData.details,\n );\n }\n\n if (this.config.debug) {\n console.log(\"[Commet SDK] Response:\", responseData);\n }\n\n return responseData as ApiResponse<T>;\n } catch (error) {\n // Handle network errors and timeouts\n if (error instanceof TypeError && error.message.includes(\"fetch\")) {\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 * Get base URL based on environment\n */\n private getBaseURL(): string {\n return this.environment === \"production\"\n ? \"https://commet.co\"\n : \"https://sandbox.commet.co\";\n }\n\n /**\n * Build full URL from endpoint and params\n */\n private buildURL(endpoint: string, params?: Record<string, unknown>): string {\n const baseURL = this.getBaseURL();\n\n // Construct full path with /api prefix\n const normalizedEndpoint = endpoint.startsWith(\"/\")\n ? endpoint\n : `/${endpoint}`;\n const fullPath = `/api${normalizedEndpoint}`;\n\n // Debug logging\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Building URL - baseURL: ${baseURL}, endpoint: ${endpoint}, fullPath: ${fullPath}`,\n );\n }\n\n const url = new URL(fullPath, baseURL);\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 /**\n * Generate idempotency key\n */\n private generateIdempotencyKey(): string {\n // Generate UUID-like key for idempotency\n return `sdk_${Date.now()}_${Math.random().toString(36).substring(2)}`;\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 { CustomersResource } from \"./resources/customers\";\nimport { PlansResource } from \"./resources/plans\";\nimport { PortalResource } from \"./resources/portal\";\nimport { SeatsResource } from \"./resources/seats\";\nimport { SubscriptionsResource } from \"./resources/subscriptions\";\nimport { UsageResource } from \"./resources/usage\";\nimport { Webhooks } from \"./resources/webhooks\";\nimport type { CommetConfig, Environment } from \"./types/common\";\nimport { CommetHTTPClient } from \"./utils/http\";\n\n/**\n * Main Commet SDK client\n */\nexport class Commet {\n private httpClient: CommetHTTPClient;\n private environment: Environment;\n\n public readonly customers: CustomersResource;\n public readonly plans: PlansResource;\n public readonly usage: UsageResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\n public readonly portal: PortalResource;\n public readonly webhooks: Webhooks;\n\n constructor(config: CommetConfig) {\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 // Default to sandbox for safety\n this.environment = config.environment || \"sandbox\";\n\n this.httpClient = new CommetHTTPClient(config, this.environment);\n this.customers = new CustomersResource(this.httpClient);\n this.plans = new PlansResource(this.httpClient);\n this.usage = new UsageResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(this.httpClient);\n this.portal = new PortalResource(this.httpClient);\n this.webhooks = new Webhooks();\n\n if (config.debug) {\n console.log(`[Commet SDK] Initialized in ${this.environment} mode`);\n console.log(\"API Key:\", `${config.apiKey.substring(0, 12)}...`);\n const baseURL =\n this.environment === \"production\"\n ? \"https://commet.co\"\n : \"https://sandbox.commet.co\";\n console.log(\"Base URL:\", baseURL);\n }\n }\n\n getEnvironment(): Environment {\n return this.environment;\n }\n\n isSandbox(): boolean {\n return this.environment === \"sandbox\";\n }\n\n isProduction(): boolean {\n return this.environment === \"production\";\n }\n}\n","import type { Environment } from \"../types/common\";\n\n/**\n * Check if environment is sandbox\n */\nexport function isSandbox(environment: Environment): boolean {\n return environment === \"sandbox\";\n}\n\n/**\n * Check if environment is production\n */\nexport function isProduction(environment: Environment): boolean {\n return environment === \"production\";\n}\n","/**\n * Commet SDK - Billing and usage tracking for SaaS\n */\nexport { Commet } from \"./client\";\n\n// Type exports\nexport type {\n CommetConfig,\n CommetGeneratedTypes,\n GeneratedEventType,\n GeneratedSeatType,\n GeneratedPlanCode,\n GeneratedFeatureCode,\n Environment,\n ApiResponse,\n PaginatedResponse,\n PaginatedList,\n Currency,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"./types/common\";\n\n// Error exports\nexport {\n CommetError,\n CommetAPIError,\n CommetValidationError,\n} from \"./types/common\";\n\n// Customers\nexport type {\n Customer,\n CustomerAddress,\n CreateParams as CreateCustomerParams,\n UpdateParams as UpdateCustomerParams,\n ListCustomersParams,\n BatchResult as CustomersBatchResult,\n} from \"./resources/customers\";\n\n// Usage\nexport type {\n UsageEvent,\n UsageEventProperty,\n TrackParams,\n BatchResult as UsageBatchResult,\n} from \"./resources/usage\";\n\n// Seats\nexport type {\n SeatEvent,\n SeatBalance,\n AddParams as AddSeatsParams,\n RemoveParams as RemoveSeatsParams,\n SetParams as SetSeatsParams,\n SetAllParams as SetAllSeatsParams,\n GetBalanceParams,\n GetAllBalancesParams,\n} from \"./resources/seats\";\n\n// Plans\nexport type {\n Plan,\n PlanDetail,\n PlanPrice,\n PlanFeature,\n PlanID,\n BillingInterval,\n FeatureType,\n ListPlansParams,\n} from \"./resources/plans\";\n\n// Subscriptions\nexport type {\n Subscription,\n ActiveSubscription,\n SubscriptionStatus,\n FeatureSummary,\n CreateSubscriptionParams,\n ChangePlanParams,\n CancelParams,\n GetSubscriptionParams,\n} from \"./resources/subscriptions\";\n\n// Portal\nexport type { PortalAccess, GetUrlParams } from \"./resources/portal\";\n\n// Webhooks\nexport { Webhooks } from \"./resources/webhooks\";\nexport type {\n WebhookPayload,\n WebhookData,\n WebhookEvent,\n} from \"./resources/webhooks\";\n\n// Utility exports\nexport { isSandbox, isProduction } from \"./utils/environment\";\n\n// Default export\nimport { Commet } from \"./client\";\nexport default Commet;\n"],"mappings":";AAiFO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA;AAAA;AAAA;AAAA,EAKnD,MAAM,OACJ,QACA,SACgC;AAChC,WAAO,KAAK,WAAW;AAA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SAAK,WAAW,IAAI,SAAS;AAE7B,QAAI,OAAO,OAAO;AAChB,cAAQ,IAAI,+BAA+B,KAAK,WAAW,OAAO;AAClE,cAAQ,IAAI,YAAY,GAAG,OAAO,OAAO,UAAU,GAAG,EAAE,CAAC,KAAK;AAC9D,YAAM,UACJ,KAAK,gBAAgB,eACjB,sBACA;AACN,cAAQ,IAAI,aAAa,OAAO;AAAA,IAClC;AAAA,EACF;AAAA,EAEA,iBAA8B;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAqB;AACnB,WAAO,KAAK,gBAAgB;AAAA,EAC9B;AAAA,EAEA,eAAwB;AACtB,WAAO,KAAK,gBAAgB;AAAA,EAC9B;AACF;;;ACjEO,SAAS,UAAU,aAAmC;AAC3D,SAAO,gBAAgB;AACzB;AAKO,SAAS,aAAa,aAAmC;AAC9D,SAAO,gBAAgB;AACzB;;;ACsFA,IAAO,gBAAQ;","names":["data"]}
1
+ {"version":3,"sources":["../src/customer.ts","../src/resources/customers.ts","../src/resources/features.ts","../src/resources/plans.ts","../src/resources/portal.ts","../src/resources/seats.ts","../src/resources/subscriptions.ts","../src/resources/usage.ts","../src/resources/webhooks.ts","../src/types/common.ts","../src/utils/http.ts","../src/client.ts","../src/utils/environment.ts","../src/index.ts"],"sourcesContent":["import type {\n ApiResponse,\n GeneratedEventType,\n GeneratedFeatureCode,\n GeneratedSeatType,\n RequestOptions,\n} from \"./types/common\";\nimport type { CommetHTTPClient } from \"./utils/http\";\nimport type { FeatureAccess, CanUseResult, CheckResult } from \"./resources/features\";\nimport type { SeatBalance, SeatEvent } from \"./resources/seats\";\nimport type { UsageEvent } from \"./resources/usage\";\nimport type { ActiveSubscription, Subscription } from \"./resources/subscriptions\";\nimport type { PortalAccess } from \"./resources/portal\";\n\n/**\n * Customer-scoped API context\n *\n * Provides a cleaner API where you don't have to pass externalId\n * on every call. All operations are scoped to a specific customer.\n *\n * @example\n * ```typescript\n * const customer = commet.customer(\"user_123\");\n *\n * // All operations are now scoped to this customer\n * const seats = await customer.features.get(\"team_members\");\n * await customer.seats.add(\"member\");\n * await customer.usage.track(\"api_call\");\n * ```\n */\nexport class CustomerContext {\n private readonly externalId: string;\n private readonly httpClient: CommetHTTPClient;\n\n constructor(httpClient: CommetHTTPClient, externalId: string) {\n this.httpClient = httpClient;\n this.externalId = externalId;\n }\n\n /**\n * Feature access methods - check what the customer can use\n */\n features = {\n /**\n * Get detailed feature access/usage\n */\n get: (\n code: GeneratedFeatureCode,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess>> => {\n return this.httpClient.get(\n `/features/${code}`,\n { externalId: this.externalId },\n options,\n );\n },\n\n /**\n * Check if a boolean feature is enabled\n */\n check: async (\n code: GeneratedFeatureCode,\n options?: RequestOptions,\n ): Promise<ApiResponse<CheckResult>> => {\n const result = await this.httpClient.get<FeatureAccess>(\n `/features/${code}`,\n { externalId: this.externalId },\n options,\n );\n\n if (!result.success || !result.data) {\n return {\n success: false,\n data: { allowed: false },\n message: result.message,\n };\n }\n\n return {\n success: true,\n data: { allowed: result.data.allowed },\n message: result.message,\n };\n },\n\n /**\n * Check if customer can use one more unit\n */\n canUse: (\n code: GeneratedFeatureCode,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanUseResult>> => {\n return this.httpClient.get(\n `/features/${code}`,\n { externalId: this.externalId, action: \"canUse\" },\n options,\n );\n },\n\n /**\n * List all features\n */\n list: (options?: RequestOptions): Promise<ApiResponse<FeatureAccess[]>> => {\n return this.httpClient.get(\n \"/features\",\n { externalId: this.externalId },\n options,\n );\n },\n };\n\n /**\n * Seat management methods\n */\n seats = {\n /**\n * Add seats\n */\n add: (\n seatType: GeneratedSeatType,\n count = 1,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> => {\n return this.httpClient.post(\n \"/seats/add\",\n { externalId: this.externalId, seatType, count },\n options,\n );\n },\n\n /**\n * Remove seats\n */\n remove: (\n seatType: GeneratedSeatType,\n count = 1,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> => {\n return this.httpClient.post(\n \"/seats/remove\",\n { externalId: this.externalId, seatType, count },\n options,\n );\n },\n\n /**\n * Set total seat count\n */\n set: (\n seatType: GeneratedSeatType,\n count: number,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> => {\n return this.httpClient.post(\n \"/seats/set\",\n { externalId: this.externalId, seatType, count },\n options,\n );\n },\n\n /**\n * Get current seat balance\n */\n getBalance: (\n seatType: GeneratedSeatType,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatBalance>> => {\n return this.httpClient.get(\n \"/seats/balance\",\n { externalId: this.externalId, seatType },\n options,\n );\n },\n };\n\n /**\n * Usage tracking methods\n */\n usage = {\n /**\n * Track a usage event\n */\n track: (\n eventType: GeneratedEventType,\n properties?: Record<string, string>,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> => {\n return this.httpClient.post(\n \"/usage\",\n {\n externalId: this.externalId,\n eventType,\n properties,\n },\n options,\n );\n },\n };\n\n /**\n * Subscription methods\n */\n subscription = {\n /**\n * Get active subscription\n */\n get: (options?: RequestOptions): Promise<ApiResponse<ActiveSubscription | null>> => {\n return this.httpClient.get(\n \"/subscriptions/active\",\n { externalId: this.externalId },\n options,\n );\n },\n\n /**\n * Cancel subscription\n */\n cancel: (\n params?: { reason?: string; immediate?: boolean },\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> => {\n // First get the subscription to get its ID\n return this.httpClient.get<ActiveSubscription | null>(\n \"/subscriptions/active\",\n { externalId: this.externalId },\n ).then((result) => {\n if (!result.success || !result.data) {\n return {\n success: false,\n data: null as unknown as Subscription,\n message: \"No active subscription found\",\n };\n }\n return this.httpClient.post(\n `/subscriptions/${result.data.id}/cancel`,\n params || {},\n options,\n );\n });\n },\n };\n\n /**\n * Portal methods\n */\n portal = {\n /**\n * Get customer portal URL\n */\n getUrl: (options?: RequestOptions): Promise<ApiResponse<PortalAccess>> => {\n return this.httpClient.get(\n \"/portal/url\",\n { externalId: this.externalId },\n options,\n );\n },\n };\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 organizationId: string;\n externalId?: string;\n legalName?: string;\n displayName?: 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 isActive: boolean;\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 externalId?: string;\n legalName?: string;\n displayName?: 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 UpdateParams {\n externalId?: string;\n email?: string;\n legalName?: string;\n displayName?: string;\n domain?: string;\n website?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n metadata?: Record<string, unknown>;\n}\n\nexport interface ListCustomersParams extends BaseListParams {\n externalId?: string;\n isActive?: boolean;\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\n/**\n * Customers resource - Manage your customers\n */\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a customer (idempotent with externalId)\n */\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 externalId: params.externalId,\n legalName: params.legalName,\n displayName: params.displayName,\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 /**\n * Create multiple customers in batch\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 externalId: c.externalId,\n legalName: c.legalName,\n displayName: c.displayName,\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 /**\n * Get a customer by ID\n */\n async get(customerId: CustomerID): Promise<ApiResponse<Customer>> {\n return this.httpClient.get(`/customers/${customerId}`);\n }\n\n /**\n * Update a customer\n */\n async update(\n customerId: CustomerID,\n params: UpdateParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${customerId}`,\n {\n billingEmail: params.email,\n externalId: params.externalId,\n legalName: params.legalName,\n displayName: params.displayName,\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 },\n options,\n );\n }\n\n /**\n * List customers with optional filters\n */\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params as Record<string, unknown>);\n }\n\n /**\n * Archive a customer\n */\n async archive(\n customerId: CustomerID,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(\n `/customers/${customerId}`,\n { isActive: false },\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n GeneratedFeatureCode,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface FeatureAccess {\n code: string;\n name: string;\n type: \"boolean\" | \"metered\" | \"seats\";\n allowed: boolean;\n // For boolean features\n enabled?: boolean;\n // For metered/seats features\n current?: number;\n included?: number;\n remaining?: number;\n overage?: number;\n overageUnitPrice?: 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 CheckResult {\n allowed: boolean;\n}\n\n/**\n * Features resource for checking feature access and usage\n *\n * Provides a clean API to check if a customer can use a feature\n * without having to manually parse subscription data.\n */\nexport class FeaturesResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Get detailed feature access/usage for a customer\n *\n * @example\n * ```typescript\n * const seats = await commet.features.get(\"team_members\", \"user_123\");\n * console.log(seats.current, seats.included, seats.remaining);\n * ```\n */\n async get(\n code: GeneratedFeatureCode,\n externalId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess>> {\n return this.httpClient.get(\n `/features/${code}`,\n { externalId },\n options,\n );\n }\n\n /**\n * Check if a boolean feature is enabled for a customer\n *\n * @example\n * ```typescript\n * const { allowed } = await commet.features.check(\"custom_branding\", \"user_123\");\n * if (!allowed) redirect(\"/upgrade\");\n * ```\n */\n async check(\n code: GeneratedFeatureCode,\n externalId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<CheckResult>> {\n const result = await this.httpClient.get<FeatureAccess>(\n `/features/${code}`,\n { externalId },\n options,\n );\n\n if (!result.success || !result.data) {\n return {\n success: false,\n data: { allowed: false },\n message: result.message,\n };\n }\n\n return {\n success: true,\n data: { allowed: result.data.allowed },\n message: result.message,\n };\n }\n\n /**\n * Check if customer can use one more unit of a feature\n *\n * Returns whether the customer can add one more (allowed)\n * and whether they'll be charged extra (willBeCharged).\n *\n * @example\n * ```typescript\n * const { allowed, willBeCharged } = await commet.features.canUse(\"team_members\", \"user_123\");\n *\n * if (!allowed) {\n * return { error: \"Upgrade to add more members\" };\n * }\n *\n * if (willBeCharged) {\n * // Show confirmation: \"This will cost $10/month extra\"\n * }\n * ```\n */\n async canUse(\n code: GeneratedFeatureCode,\n externalId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<CanUseResult>> {\n return this.httpClient.get(\n `/features/${code}`,\n { externalId, action: \"canUse\" },\n options,\n );\n }\n\n /**\n * List all features for a customer's active subscription\n *\n * @example\n * ```typescript\n * const features = await commet.features.list(\"user_123\");\n * for (const feature of features) {\n * console.log(feature.code, feature.allowed);\n * }\n * ```\n */\n async list(\n externalId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<FeatureAccess[]>> {\n return this.httpClient.get(\"/features\", { externalId }, options);\n }\n}\n\n","import type {\n ApiResponse,\n GeneratedPlanCode,\n ListParams,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport type PlanID = `plan_${string}`;\nexport type BillingInterval = \"monthly\" | \"quarterly\" | \"yearly\";\nexport type FeatureType = \"boolean\" | \"metered\" | \"seats\";\n\nexport interface PlanPrice {\n billingInterval: BillingInterval;\n price: number; // in cents\n isDefault: boolean;\n}\n\nexport interface PlanFeature {\n code: string;\n name: string;\n type: FeatureType;\n enabled?: boolean;\n includedAmount?: number;\n unlimited?: boolean;\n overageEnabled?: boolean;\n overageUnitPrice?: number;\n}\n\nexport interface Plan {\n id: PlanID;\n name: string;\n description?: string;\n isPublic: boolean;\n isDefault: boolean;\n trialDays: number;\n sortOrder: number;\n prices: PlanPrice[];\n features: PlanFeature[];\n createdAt: string;\n}\n\nexport interface PlanDetail extends Plan {\n features: Array<\n PlanFeature & {\n unitName?: string;\n overage?: {\n enabled: boolean;\n model: \"per_unit\" | \"tiered\";\n unitPrice: number;\n tiers?: Array<{\n order: number;\n upTo: number | null;\n unitAmount: number;\n flatFee: number;\n }>;\n } | null;\n }\n >;\n updatedAt: string;\n}\n\nexport interface ListPlansParams extends ListParams {\n includePrivate?: boolean;\n}\n\n/**\n * Plans resource for listing available plans\n */\nexport class PlansResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * List all available plans\n *\n * @example\n * ```typescript\n * // List public plans\n * const plans = await commet.plans.list();\n *\n * // Include private plans\n * const allPlans = await commet.plans.list({ includePrivate: true });\n * ```\n */\n async list(params?: ListPlansParams): Promise<ApiResponse<Plan[]>> {\n return this.httpClient.get(\"/plans\", params);\n }\n\n /**\n * Get a specific plan by code\n *\n * @example\n * ```typescript\n * const plan = await commet.plans.get('pro');\n * console.log(plan.data.name); // \"Pro\"\n * console.log(plan.data.prices); // [{ billingInterval: 'monthly', price: 9900 }]\n * ```\n */\n async get(planCode: GeneratedPlanCode): Promise<ApiResponse<PlanDetail>> {\n return this.httpClient.get(`/plans/${planCode}`);\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 externalId?: never;\n}\n\ninterface GetUrlByExternalId {\n externalId: string;\n email?: never;\n customerId?: never;\n}\n\ninterface GetUrlByEmail {\n email: string;\n customerId?: never;\n externalId?: never;\n}\n\nexport type GetUrlParams =\n | GetUrlByCustomerId\n | GetUrlByExternalId\n | GetUrlByEmail;\n\n/**\n * Portal resource - Generate customer portal access\n */\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Get a portal URL\n *\n * @example\n * ```typescript\n * const portal = await commet.portal.getUrl({ externalId: 'user_123' });\n * ```\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 {\n ApiResponse,\n CustomerID,\n GeneratedSeatType,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatEvent {\n id: string;\n organizationId: string;\n customerId: CustomerID;\n seatType: GeneratedSeatType;\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 AddParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface RemoveParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetAllParams {\n customerId?: CustomerID;\n externalId?: string;\n seats: Record<string, number>;\n}\n\nexport interface GetBalanceParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n}\n\nexport interface GetAllBalancesParams {\n customerId?: CustomerID;\n externalId?: string;\n}\n\n/**\n * Seats resource - Manage seat-based licenses\n */\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Add seats\n *\n * @example\n * ```typescript\n * await commet.seats.add({\n * externalId: 'user_123',\n * seatType: 'editor',\n * count: 5\n * });\n * ```\n */\n async add(\n params: AddParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\"/seats\", params, options);\n }\n\n /**\n * Remove seats\n *\n * @example\n * ```typescript\n * await commet.seats.remove({\n * externalId: 'user_123',\n * seatType: 'editor',\n * count: 2\n * });\n * ```\n */\n async remove(\n params: RemoveParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\"/seats\", params, options);\n }\n\n /**\n * Set seats to a specific count\n *\n * @example\n * ```typescript\n * await commet.seats.set({\n * externalId: 'user_123',\n * seatType: 'editor',\n * count: 10\n * });\n * ```\n */\n async set(\n params: SetParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\"/seats\", params, options);\n }\n\n /**\n * Set all seat types\n *\n * @example\n * ```typescript\n * await commet.seats.setAll({\n * externalId: 'user_123',\n * seats: { editor: 10, viewer: 50 }\n * });\n * ```\n */\n async setAll(\n params: SetAllParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\"/seats/bulk\", params, options);\n }\n\n /**\n * Get balance for a seat type\n *\n * @example\n * ```typescript\n * const balance = await commet.seats.getBalance({\n * externalId: 'user_123',\n * seatType: 'editor'\n * });\n * ```\n */\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalance>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n });\n }\n\n /**\n * Get all seat balances\n *\n * @example\n * ```typescript\n * const balances = await commet.seats.getAllBalances({\n * externalId: 'user_123'\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 externalId: params.externalId,\n });\n }\n}\n","import type {\n ApiResponse,\n GeneratedPlanCode,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\nimport type { BillingInterval } 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: \"boolean\" | \"metered\" | \"seats\";\n enabled?: boolean;\n usage?: {\n current: number;\n included: number;\n overage: number;\n overageUnitPrice?: number;\n };\n}\n\nexport interface ActiveSubscription {\n id: string;\n customerId: string;\n plan: {\n id: string;\n name: string;\n basePrice: number;\n billingInterval: BillingInterval;\n };\n name: string;\n description?: string;\n status: SubscriptionStatus;\n trialEndsAt?: string;\n currentPeriod: {\n start: string;\n end: string;\n daysRemaining: number;\n };\n features: FeatureSummary[];\n startDate: string;\n endDate?: string;\n billingDayOfMonth: number;\n nextBillingDate: string;\n checkoutUrl?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface Subscription {\n id: string;\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\n// Customer identifier: mutually exclusive customerId or externalId\ntype CustomerIdentifier =\n | { customerId: string; externalId?: never }\n | { customerId?: never; externalId: string };\n\n// Plan identifier: use planCode (with autocomplete) or planId (legacy)\ntype PlanIdentifier =\n | { planCode: GeneratedPlanCode; planId?: never }\n | { planCode?: never; planId: string };\n\nexport type CreateSubscriptionParams = CustomerIdentifier &\n PlanIdentifier & {\n billingInterval?: BillingInterval;\n initialSeats?: Record<string, number>;\n skipTrial?: boolean;\n name?: string;\n startDate?: string;\n };\n\nexport type ChangePlanParams = PlanIdentifier & {\n billingInterval?: BillingInterval;\n};\n\nexport interface CancelParams {\n reason?: string;\n immediate?: boolean;\n}\n\nexport type GetSubscriptionParams = CustomerIdentifier;\n\n/**\n * Subscription resource for managing subscriptions (plan-first model)\n *\n * Each customer can only have ONE active subscription at a time.\n */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a subscription with a plan\n *\n * @example\n * ```typescript\n * await commet.subscriptions.create({\n * externalId: 'user_123',\n * planCode: 'pro', // autocomplete works after `commet pull`\n * billingInterval: 'yearly',\n * initialSeats: { editor: 5 }\n * });\n * ```\n */\n async create(\n params: CreateSubscriptionParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\"/subscriptions\", params, options);\n }\n\n /**\n * Get the active subscription for a customer\n *\n * @example\n * ```typescript\n * const sub = await commet.subscriptions.get({ externalId: 'user_123' });\n * ```\n */\n async get(\n params: GetSubscriptionParams,\n ): Promise<ApiResponse<ActiveSubscription | null>> {\n return this.httpClient.get(\"/subscriptions/active\", params);\n }\n\n /**\n * Change the plan of a subscription (upgrade/downgrade)\n *\n * @example\n * ```typescript\n * await commet.subscriptions.changePlan('sub_xxx', {\n * planCode: 'enterprise' // autocomplete works after `commet pull`\n * });\n * ```\n */\n async changePlan(\n subscriptionId: string,\n params: ChangePlanParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/change-plan`,\n params,\n options,\n );\n }\n\n /**\n * Cancel a subscription\n *\n * @example\n * ```typescript\n * await commet.subscriptions.cancel('sub_xxx', {\n * reason: 'switched_to_competitor'\n * });\n * ```\n */\n async cancel(\n subscriptionId: string,\n params?: CancelParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/cancel`,\n params || {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n GeneratedEventType,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface UsageEvent {\n id: EventID;\n organizationId: string;\n customerId: CustomerID;\n eventType: GeneratedEventType;\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\nexport interface BatchResult<T> {\n successful: T[];\n failed: Array<{\n index: number;\n error: string;\n data: TrackParams;\n }>;\n}\n\nexport interface TrackParams {\n eventType: GeneratedEventType;\n customerId?: CustomerID;\n externalId?: string;\n idempotencyKey?: string;\n value?: number;\n timestamp?: string;\n properties?: Record<string, string>;\n}\n\n/**\n * Usage resource - Track consumption events for usage-based billing\n */\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Track a usage event\n *\n * @example\n * ```typescript\n * await commet.usage.track({\n * externalId: 'user_123',\n * eventType: 'api_call',\n * idempotencyKey: `evt_${requestId}`,\n * properties: { endpoint: '/users', method: 'GET' }\n * });\n * ```\n */\n async track(\n params: TrackParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData = {\n eventType: params.eventType,\n customerId: params.customerId,\n externalId: params.externalId,\n idempotencyKey: params.idempotencyKey,\n ts: 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 return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n /**\n * Track multiple usage events in a batch\n *\n * @example\n * ```typescript\n * await commet.usage.trackBatch({\n * events: [\n * { externalId: 'user_123', eventType: 'api_call', idempotencyKey: 'evt_1' },\n * { externalId: 'user_456', eventType: 'api_call', idempotencyKey: 'evt_2' }\n * ]\n * });\n * ```\n */\n async trackBatch(\n params: { events: TrackParams[] },\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult<UsageEvent>>> {\n const events = params.events.map((event) => ({\n eventType: event.eventType,\n customerId: event.customerId,\n externalId: event.externalId,\n idempotencyKey: event.idempotencyKey,\n ts: event.timestamp || new Date().toISOString(),\n properties: event.properties\n ? Object.entries(event.properties).map(([property, value]) => ({\n property,\n value,\n }))\n : undefined,\n }));\n\n return this.httpClient.post(\"/usage/events/batch\", { events }, options);\n }\n}\n","import crypto from \"node:crypto\";\n\n/**\n * Webhook payload structure from Commet\n */\nexport interface WebhookPayload {\n event: WebhookEvent;\n timestamp: string;\n organizationId: string;\n data: WebhookData;\n}\n\n/**\n * Webhook data structure (subscription-related fields)\n */\nexport interface WebhookData {\n id?: string;\n publicId?: string;\n subscriptionId?: string;\n customerId?: string;\n externalId?: string;\n status?: string;\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\n/**\n * Webhooks resource for signature verification\n */\nexport class Webhooks {\n /**\n * Verify HMAC-SHA256 webhook signature\n *\n * Use this method to verify that webhooks are authentically from Commet.\n * The signature is included in the `X-Commet-Signature` header.\n *\n * @param payload - Raw request body as string (IMPORTANT: Do not parse JSON first)\n * @param signature - Value from X-Commet-Signature header\n * @param secret - Your webhook secret from Commet dashboard\n * @returns true if signature is valid, false otherwise\n *\n * @example\n * ```typescript\n * // Next.js API route example\n * export async function POST(request: Request) {\n * const rawBody = await request.text();\n * const signature = request.headers.get('x-commet-signature');\n *\n * const isValid = commet.webhooks.verify(\n * rawBody,\n * signature,\n * process.env.COMMET_WEBHOOK_SECRET\n * );\n *\n * if (!isValid) {\n * return new Response('Invalid signature', { status: 401 });\n * }\n *\n * const payload = JSON.parse(rawBody);\n * // Handle webhook event...\n * }\n * ```\n */\n verify(payload: string, signature: string | null, secret: string): boolean {\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 /**\n * Generate HMAC-SHA256 signature (internal use)\n * @internal\n */\n private generateSignature(payload: string, secret: string): string {\n return crypto.createHmac(\"sha256\", secret).update(payload).digest(\"hex\");\n }\n\n /**\n * Parse and verify webhook payload in one step\n *\n * @param rawBody - Raw request body as string\n * @param signature - Value from X-Commet-Signature header\n * @param secret - Your webhook secret from Commet dashboard\n * @returns Parsed payload if valid, null if invalid\n *\n * @example\n * ```typescript\n * const payload = commet.webhooks.verifyAndParse(\n * rawBody,\n * signature,\n * process.env.COMMET_WEBHOOK_SECRET\n * );\n *\n * if (!payload) {\n * return new Response('Invalid signature', { status: 401 });\n * }\n *\n * // payload is typed and validated\n * if (payload.event === 'subscription.activated') {\n * // Handle activation...\n * }\n * ```\n */\n verifyAndParse(\n rawBody: string,\n signature: string | null,\n secret: string,\n ): WebhookPayload | null {\n if (!this.verify(rawBody, signature, secret)) {\n return null;\n }\n\n try {\n return JSON.parse(rawBody) as WebhookPayload;\n } catch {\n return null;\n }\n }\n}\n","export type Environment = \"sandbox\" | \"production\";\n\nexport type CommetConfig = {\n apiKey: string;\n environment?: Environment;\n debug?: boolean;\n timeout?: number;\n retries?: number;\n};\n\n// API Response types\nexport interface ApiResponse<T = unknown> {\n success: boolean;\n data?: T;\n error?: string;\n message?: string;\n // Pagination fields (optional, included for list endpoints)\n hasMore?: boolean;\n nextCursor?: 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 constructor(\n message: string,\n public statusCode: number,\n public code?: string,\n public details?: unknown,\n ) {\n super(message, code, statusCode, details);\n this.name = \"CommetAPIError\";\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 = `cus_${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 idempotencyKey?: string;\n timeout?: number;\n}\n\n/**\n * Generated types interface - augmented by CLI after 'commet pull'\n *\n * This interface gets filled by module augmentation when you run `commet pull`.\n * The CLI generates a .commet.d.ts file that augments this interface with your\n * organization's specific event and seat types.\n *\n * @example\n * // After running `commet pull`, TypeScript will automatically know your types:\n * await commet.usage.events.create({\n * eventType: 'api_call', // Autocomplete works!\n * customerId: 'cus_123'\n * });\n */\n\n// biome-ignore lint/suspicious/noEmptyInterface: <explanation>\nexport interface CommetGeneratedTypes {}\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedEventType = CommetGeneratedTypes extends {\n eventType: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedSeatType = CommetGeneratedTypes extends {\n seatType: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n * @deprecated Use GeneratedPlanCode instead\n */\nexport type GeneratedProductId = CommetGeneratedTypes extends {\n productId: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedPlanCode = CommetGeneratedTypes extends {\n planCode: infer T;\n}\n ? T\n : string;\n\n/**\n * Helper type that provides fallback to string if types are not generated\n */\nexport type GeneratedFeatureCode = CommetGeneratedTypes extends {\n featureCode: infer T;\n}\n ? T\n : string;\n","import type {\n ApiResponse,\n CommetConfig,\n Environment,\n RequestOptions,\n} from \"../types/common\";\nimport { CommetAPIError, CommetValidationError } from \"../types/common\";\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: CommetConfig;\n private environment: Environment;\n private retryConfig: RetryConfig;\n\n constructor(config: CommetConfig, environment: Environment) {\n this.config = config;\n this.environment = environment;\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>,\n options?: RequestOptions,\n ): Promise<ApiResponse<T>> {\n return this.request(\"GET\", endpoint, undefined, options, params);\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 /**\n * Core request method with retry logic\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 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 headers: Record<string, string> = {\n \"x-api-key\": this.config.apiKey,\n \"Content-Type\": \"application/json\",\n \"User-Agent\": \"commet/0.1.0\",\n };\n\n if (options?.idempotencyKey) {\n headers[\"Idempotency-Key\"] = options.idempotencyKey;\n } else if (method === \"POST\" && data) {\n headers[\"Idempotency-Key\"] = this.generateIdempotencyKey();\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 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 // For 404 errors with invalid JSON, return a graceful response\n // This handles cases like HTML error pages or empty responses\n if (response.status === 404) {\n return {\n success: false,\n error: \"Resource not found\",\n } as ApiResponse<T>;\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 // Type guard for error response\n const isErrorResponse = (\n data: unknown,\n ): data is {\n message?: string;\n errors?: Record<string, string[]>;\n code?: string;\n details?: unknown;\n } => {\n return typeof data === \"object\" && data !== null;\n };\n\n const errorData = isErrorResponse(responseData) ? responseData : {};\n\n // Handle different error types\n if (response.status === 400 && errorData.errors) {\n throw new CommetValidationError(\n errorData.message || \"Validation failed\",\n errorData.errors,\n );\n }\n\n throw new CommetAPIError(\n errorData.message || `Request failed with status ${response.status}`,\n response.status,\n errorData.code,\n errorData.details,\n );\n }\n\n if (this.config.debug) {\n console.log(\"[Commet SDK] Response:\", responseData);\n }\n\n return responseData as ApiResponse<T>;\n } catch (error) {\n // Handle network errors and timeouts\n if (error instanceof TypeError && error.message.includes(\"fetch\")) {\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 * Get base URL based on environment\n */\n private getBaseURL(): string {\n return this.environment === \"production\"\n ? \"https://commet.co\"\n : \"https://sandbox.commet.co\";\n }\n\n /**\n * Build full URL from endpoint and params\n */\n private buildURL(endpoint: string, params?: Record<string, unknown>): string {\n const baseURL = this.getBaseURL();\n\n // Construct full path with /api prefix\n const normalizedEndpoint = endpoint.startsWith(\"/\")\n ? endpoint\n : `/${endpoint}`;\n const fullPath = `/api${normalizedEndpoint}`;\n\n // Debug logging\n if (this.config.debug) {\n console.log(\n `[Commet SDK] Building URL - baseURL: ${baseURL}, endpoint: ${endpoint}, fullPath: ${fullPath}`,\n );\n }\n\n const url = new URL(fullPath, baseURL);\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 /**\n * Generate idempotency key\n */\n private generateIdempotencyKey(): string {\n // Generate UUID-like key for idempotency\n return `sdk_${Date.now()}_${Math.random().toString(36).substring(2)}`;\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 { CustomerContext } from \"./customer\";\nimport { CustomersResource } from \"./resources/customers\";\nimport { FeaturesResource } from \"./resources/features\";\nimport { PlansResource } from \"./resources/plans\";\nimport { PortalResource } from \"./resources/portal\";\nimport { SeatsResource } from \"./resources/seats\";\nimport { SubscriptionsResource } from \"./resources/subscriptions\";\nimport { UsageResource } from \"./resources/usage\";\nimport { Webhooks } from \"./resources/webhooks\";\nimport type { CommetConfig, Environment } from \"./types/common\";\nimport { CommetHTTPClient } from \"./utils/http\";\n\n/**\n * Main Commet SDK client\n */\nexport class Commet {\n private httpClient: CommetHTTPClient;\n private environment: Environment;\n\n public readonly customers: CustomersResource;\n public readonly plans: PlansResource;\n public readonly usage: UsageResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\n public readonly portal: PortalResource;\n public readonly features: FeaturesResource;\n public readonly webhooks: Webhooks;\n\n constructor(config: CommetConfig) {\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 // Default to sandbox for safety\n this.environment = config.environment || \"sandbox\";\n\n this.httpClient = new CommetHTTPClient(config, this.environment);\n this.customers = new CustomersResource(this.httpClient);\n this.plans = new PlansResource(this.httpClient);\n this.usage = new UsageResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(this.httpClient);\n this.portal = new PortalResource(this.httpClient);\n this.features = new FeaturesResource(this.httpClient);\n this.webhooks = new Webhooks();\n\n if (config.debug) {\n console.log(`[Commet SDK] Initialized in ${this.environment} mode`);\n console.log(\"API Key:\", `${config.apiKey.substring(0, 12)}...`);\n const baseURL =\n this.environment === \"production\"\n ? \"https://commet.co\"\n : \"https://sandbox.commet.co\";\n console.log(\"Base URL:\", baseURL);\n }\n }\n\n /**\n * Create a customer-scoped context for cleaner API usage\n *\n * @example\n * ```typescript\n * const customer = commet.customer(\"user_123\");\n *\n * // All operations are now scoped to this customer\n * const seats = await customer.features.get(\"team_members\");\n * await customer.seats.add(\"member\");\n * await customer.usage.track(\"api_call\");\n * ```\n */\n customer(externalId: string): CustomerContext {\n return new CustomerContext(this.httpClient, externalId);\n }\n\n getEnvironment(): Environment {\n return this.environment;\n }\n\n isSandbox(): boolean {\n return this.environment === \"sandbox\";\n }\n\n isProduction(): boolean {\n return this.environment === \"production\";\n }\n}\n","import type { Environment } from \"../types/common\";\n\n/**\n * Check if environment is sandbox\n */\nexport function isSandbox(environment: Environment): boolean {\n return environment === \"sandbox\";\n}\n\n/**\n * Check if environment is production\n */\nexport function isProduction(environment: Environment): boolean {\n return environment === \"production\";\n}\n","/**\n * Commet SDK - Billing and usage tracking for SaaS\n */\nexport { Commet } from \"./client\";\nexport { CustomerContext } from \"./customer\";\n\n// Type exports\nexport type {\n CommetConfig,\n CommetGeneratedTypes,\n GeneratedEventType,\n GeneratedSeatType,\n GeneratedPlanCode,\n GeneratedFeatureCode,\n Environment,\n ApiResponse,\n PaginatedResponse,\n PaginatedList,\n Currency,\n CustomerID,\n EventID,\n RequestOptions,\n} from \"./types/common\";\n\n// Error exports\nexport {\n CommetError,\n CommetAPIError,\n CommetValidationError,\n} from \"./types/common\";\n\n// Customers\nexport type {\n Customer,\n CustomerAddress,\n CreateParams as CreateCustomerParams,\n UpdateParams as UpdateCustomerParams,\n ListCustomersParams,\n BatchResult as CustomersBatchResult,\n} from \"./resources/customers\";\n\n// Usage\nexport type {\n UsageEvent,\n UsageEventProperty,\n TrackParams,\n BatchResult as UsageBatchResult,\n} from \"./resources/usage\";\n\n// Seats\nexport type {\n SeatEvent,\n SeatBalance,\n AddParams as AddSeatsParams,\n RemoveParams as RemoveSeatsParams,\n SetParams as SetSeatsParams,\n SetAllParams as SetAllSeatsParams,\n GetBalanceParams,\n GetAllBalancesParams,\n} from \"./resources/seats\";\n\n// Plans\nexport type {\n Plan,\n PlanDetail,\n PlanPrice,\n PlanFeature,\n PlanID,\n BillingInterval,\n FeatureType,\n ListPlansParams,\n} from \"./resources/plans\";\n\n// Subscriptions\nexport type {\n Subscription,\n ActiveSubscription,\n SubscriptionStatus,\n FeatureSummary,\n CreateSubscriptionParams,\n ChangePlanParams,\n CancelParams,\n GetSubscriptionParams,\n} from \"./resources/subscriptions\";\n\n// Portal\nexport type { PortalAccess, GetUrlParams } from \"./resources/portal\";\n\n// Features\nexport type {\n FeatureAccess,\n CanUseResult,\n CheckResult,\n} from \"./resources/features\";\n\n// Webhooks\nexport { Webhooks } from \"./resources/webhooks\";\nexport type {\n WebhookPayload,\n WebhookData,\n WebhookEvent,\n} from \"./resources/webhooks\";\n\n// Utility exports\nexport { isSandbox, isProduction } from \"./utils/environment\";\n\n// Default export\nimport { Commet } from \"./client\";\nexport default Commet;\n"],"mappings":";AA8BO,IAAM,kBAAN,MAAsB;AAAA,EAI3B,YAAY,YAA8B,YAAoB;AAQ9D;AAAA;AAAA;AAAA,oBAAW;AAAA;AAAA;AAAA;AAAA,MAIT,KAAK,CACH,MACA,YACwC;AACxC,eAAO,KAAK,WAAW;AAAA,UACrB,aAAa,IAAI;AAAA,UACjB,EAAE,YAAY,KAAK,WAAW;AAAA,UAC9B;AAAA,QACF;AAAA,MACF;AAAA;AAAA;AAAA;AAAA,MAKA,OAAO,OACL,MACA,YACsC;AACtC,cAAM,SAAS,MAAM,KAAK,WAAW;AAAA,UACnC,aAAa,IAAI;AAAA,UACjB,EAAE,YAAY,KAAK,WAAW;AAAA,UAC9B;AAAA,QACF;AAEA,YAAI,CAAC,OAAO,WAAW,CAAC,OAAO,MAAM;AACnC,iBAAO;AAAA,YACL,SAAS;AAAA,YACT,MAAM,EAAE,SAAS,MAAM;AAAA,YACvB,SAAS,OAAO;AAAA,UAClB;AAAA,QACF;AAEA,eAAO;AAAA,UACL,SAAS;AAAA,UACT,MAAM,EAAE,SAAS,OAAO,KAAK,QAAQ;AAAA,UACrC,SAAS,OAAO;AAAA,QAClB;AAAA,MACF;AAAA;AAAA;AAAA;AAAA,MAKA,QAAQ,CACN,MACA,Y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Y,GAAG,OAAO,OAAO,UAAU,GAAG,EAAE,CAAC,KAAK;AAC9D,YAAM,UACJ,KAAK,gBAAgB,eACjB,sBACA;AACN,cAAQ,IAAI,aAAa,OAAO;AAAA,IAClC;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,SAAS,YAAqC;AAC5C,WAAO,IAAI,gBAAgB,KAAK,YAAY,UAAU;AAAA,EACxD;AAAA,EAEA,iBAA8B;AAC5B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAqB;AACnB,WAAO,KAAK,gBAAgB;AAAA,EAC9B;AAAA,EAEA,eAAwB;AACtB,WAAO,KAAK,gBAAgB;AAAA,EAC9B;AACF;;;ACtFO,SAAS,UAAU,aAAmC;AAC3D,SAAO,gBAAgB;AACzB;AAKO,SAAS,aAAa,aAAmC;AAC9D,SAAO,gBAAgB;AACzB;;;AC8FA,IAAO,gBAAQ;","names":["data"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commet/node",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Commet SDK for Node.js - Billing and usage tracking",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",