@commet/node 0.10.0 → 0.11.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/README.md CHANGED
@@ -58,6 +58,11 @@ await commet.customers.create({
58
58
  legalName: 'Acme Corp',
59
59
  billingEmail: 'billing@acme.com'
60
60
  });
61
+
62
+ // Generate customer portal access
63
+ await commet.portal.requestAccess({
64
+ externalId: 'my-customer-123'
65
+ });
61
66
  ```
62
67
 
63
68
  ## Type Safety
package/dist/index.d.mts CHANGED
@@ -227,6 +227,79 @@ declare class CustomersResource {
227
227
  deactivate(customerId: CustomerID, options?: RequestOptions): Promise<ApiResponse<Customer>>;
228
228
  }
229
229
 
230
+ /**
231
+ * Portal access response
232
+ */
233
+ interface PortalAccess {
234
+ success: boolean;
235
+ message: string;
236
+ portalUrl: string;
237
+ }
238
+ /**
239
+ * Request portal access by customer ID
240
+ */
241
+ interface RequestAccessByCustomerId {
242
+ customerId: CustomerID;
243
+ email?: never;
244
+ externalId?: never;
245
+ }
246
+ /**
247
+ * Request portal access by external ID
248
+ */
249
+ interface RequestAccessByExternalId {
250
+ externalId: string;
251
+ email?: never;
252
+ customerId?: never;
253
+ }
254
+ /**
255
+ * Request portal access by email
256
+ */
257
+ interface RequestAccessByEmail {
258
+ email: string;
259
+ customerId?: never;
260
+ externalId?: never;
261
+ }
262
+ /**
263
+ * Portal access parameters
264
+ */
265
+ type RequestAccessParams = RequestAccessByCustomerId | RequestAccessByExternalId | RequestAccessByEmail;
266
+ /**
267
+ * Customer Portal resource for generating customer portal access
268
+ */
269
+ declare class PortalResource {
270
+ private httpClient;
271
+ constructor(httpClient: CommetHTTPClient);
272
+ /**
273
+ * Request portal access for a customer
274
+ *
275
+ * Generates a secure portal URL that can be sent to the customer via email or used directly.
276
+ * The URL contains a time-limited token for secure access to the customer portal.
277
+ *
278
+ * @param params - customerId, externalId, or email
279
+ * @param options - Request options (idempotency, timeout)
280
+ * @returns Portal access response with URL
281
+ *
282
+ * @example
283
+ * // External ID (recommended)
284
+ * const portal = await commet.portal.requestAccess({
285
+ * externalId: 'my-customer-123'
286
+ * });
287
+ *
288
+ * @example
289
+ * // Customer ID
290
+ * const portal = await commet.portal.requestAccess({
291
+ * customerId: 'cus_123'
292
+ * });
293
+ *
294
+ * @example
295
+ * // Email
296
+ * const portal = await commet.portal.requestAccess({
297
+ * email: 'customer@example.com'
298
+ * });
299
+ */
300
+ requestAccess(params: RequestAccessParams, options?: RequestOptions): Promise<ApiResponse<PortalAccess>>;
301
+ }
302
+
230
303
  interface SeatBalance {
231
304
  id: string;
232
305
  organizationId: string;
@@ -318,9 +391,6 @@ interface Subscription {
318
391
  startDate: string;
319
392
  endDate?: string;
320
393
  billingDayOfMonth: number;
321
- totalContractValue?: number;
322
- poNumber?: string;
323
- reference?: string;
324
394
  isTemplate?: boolean;
325
395
  checkoutUrl?: string;
326
396
  createdAt: string;
@@ -585,6 +655,7 @@ declare class Commet {
585
655
  readonly usage: UsageResource;
586
656
  readonly seats: SeatsResource;
587
657
  readonly subscriptions: SubscriptionsResource;
658
+ readonly portal: PortalResource;
588
659
  readonly webhooks: Webhooks;
589
660
  constructor(config: CommetConfig);
590
661
  getEnvironment(): Environment;
@@ -605,4 +676,4 @@ declare function isProduction(environment: Environment): boolean;
605
676
  * Commet SDK - Billing and usage tracking SDK
606
677
  */
607
678
 
608
- export { type AddSeatsParams, type AgreementID, type ApiResponse, type BatchResult, type BulkSeatUpdate, type BulkUpdateSeatsParams, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateBatchUsageEventsParams, type CreateCustomerParams, type CreateSubscriptionParams, type CreateUsageEventParams, type Currency, type Customer, type CustomerID, type Environment, type EventID, type GeneratedEventType, type GeneratedProductId, type GeneratedSeatType, type GetAllBalancesParams, type GetBalanceParams, type InvoiceID, type ItemID, type ListCustomersParams, type ListParams, type ListSeatEventsParams, type ListSubscriptionsParams, type ListUsageEventsParams, type PaginatedList, type PaginatedResponse, type PhaseID, type ProductID, type RemoveSeatsParams, type RequestOptions, type RetrieveOptions, type SeatBalance, type SeatBalanceResponse, type SeatEvent, type SetSeatsParams, type Subscription, type SubscriptionItem, type UpdateCustomerParams, type UsageEvent, type UsageEventProperty, type WebhookData, type WebhookEvent, type WebhookID, type WebhookPayload, Commet as default, isProduction, isSandbox };
679
+ export { type AddSeatsParams, type AgreementID, type ApiResponse, type BatchResult, type BulkSeatUpdate, type BulkUpdateSeatsParams, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateBatchUsageEventsParams, type CreateCustomerParams, type CreateSubscriptionParams, type CreateUsageEventParams, type Currency, type Customer, type CustomerID, type Environment, type EventID, type GeneratedEventType, type GeneratedProductId, type GeneratedSeatType, type GetAllBalancesParams, type GetBalanceParams, type InvoiceID, type ItemID, type ListCustomersParams, type ListParams, type ListSeatEventsParams, type ListSubscriptionsParams, type ListUsageEventsParams, type PaginatedList, type PaginatedResponse, type PhaseID, type PortalAccess, type ProductID, type RemoveSeatsParams, type RequestAccessParams, type RequestOptions, type RetrieveOptions, type SeatBalance, type SeatBalanceResponse, type SeatEvent, type SetSeatsParams, type Subscription, type SubscriptionItem, type UpdateCustomerParams, type UsageEvent, type UsageEventProperty, type WebhookData, type WebhookEvent, type WebhookID, type WebhookPayload, Webhooks, Commet as default, isProduction, isSandbox };
package/dist/index.d.ts CHANGED
@@ -227,6 +227,79 @@ declare class CustomersResource {
227
227
  deactivate(customerId: CustomerID, options?: RequestOptions): Promise<ApiResponse<Customer>>;
228
228
  }
229
229
 
230
+ /**
231
+ * Portal access response
232
+ */
233
+ interface PortalAccess {
234
+ success: boolean;
235
+ message: string;
236
+ portalUrl: string;
237
+ }
238
+ /**
239
+ * Request portal access by customer ID
240
+ */
241
+ interface RequestAccessByCustomerId {
242
+ customerId: CustomerID;
243
+ email?: never;
244
+ externalId?: never;
245
+ }
246
+ /**
247
+ * Request portal access by external ID
248
+ */
249
+ interface RequestAccessByExternalId {
250
+ externalId: string;
251
+ email?: never;
252
+ customerId?: never;
253
+ }
254
+ /**
255
+ * Request portal access by email
256
+ */
257
+ interface RequestAccessByEmail {
258
+ email: string;
259
+ customerId?: never;
260
+ externalId?: never;
261
+ }
262
+ /**
263
+ * Portal access parameters
264
+ */
265
+ type RequestAccessParams = RequestAccessByCustomerId | RequestAccessByExternalId | RequestAccessByEmail;
266
+ /**
267
+ * Customer Portal resource for generating customer portal access
268
+ */
269
+ declare class PortalResource {
270
+ private httpClient;
271
+ constructor(httpClient: CommetHTTPClient);
272
+ /**
273
+ * Request portal access for a customer
274
+ *
275
+ * Generates a secure portal URL that can be sent to the customer via email or used directly.
276
+ * The URL contains a time-limited token for secure access to the customer portal.
277
+ *
278
+ * @param params - customerId, externalId, or email
279
+ * @param options - Request options (idempotency, timeout)
280
+ * @returns Portal access response with URL
281
+ *
282
+ * @example
283
+ * // External ID (recommended)
284
+ * const portal = await commet.portal.requestAccess({
285
+ * externalId: 'my-customer-123'
286
+ * });
287
+ *
288
+ * @example
289
+ * // Customer ID
290
+ * const portal = await commet.portal.requestAccess({
291
+ * customerId: 'cus_123'
292
+ * });
293
+ *
294
+ * @example
295
+ * // Email
296
+ * const portal = await commet.portal.requestAccess({
297
+ * email: 'customer@example.com'
298
+ * });
299
+ */
300
+ requestAccess(params: RequestAccessParams, options?: RequestOptions): Promise<ApiResponse<PortalAccess>>;
301
+ }
302
+
230
303
  interface SeatBalance {
231
304
  id: string;
232
305
  organizationId: string;
@@ -318,9 +391,6 @@ interface Subscription {
318
391
  startDate: string;
319
392
  endDate?: string;
320
393
  billingDayOfMonth: number;
321
- totalContractValue?: number;
322
- poNumber?: string;
323
- reference?: string;
324
394
  isTemplate?: boolean;
325
395
  checkoutUrl?: string;
326
396
  createdAt: string;
@@ -585,6 +655,7 @@ declare class Commet {
585
655
  readonly usage: UsageResource;
586
656
  readonly seats: SeatsResource;
587
657
  readonly subscriptions: SubscriptionsResource;
658
+ readonly portal: PortalResource;
588
659
  readonly webhooks: Webhooks;
589
660
  constructor(config: CommetConfig);
590
661
  getEnvironment(): Environment;
@@ -605,4 +676,4 @@ declare function isProduction(environment: Environment): boolean;
605
676
  * Commet SDK - Billing and usage tracking SDK
606
677
  */
607
678
 
608
- export { type AddSeatsParams, type AgreementID, type ApiResponse, type BatchResult, type BulkSeatUpdate, type BulkUpdateSeatsParams, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateBatchUsageEventsParams, type CreateCustomerParams, type CreateSubscriptionParams, type CreateUsageEventParams, type Currency, type Customer, type CustomerID, type Environment, type EventID, type GeneratedEventType, type GeneratedProductId, type GeneratedSeatType, type GetAllBalancesParams, type GetBalanceParams, type InvoiceID, type ItemID, type ListCustomersParams, type ListParams, type ListSeatEventsParams, type ListSubscriptionsParams, type ListUsageEventsParams, type PaginatedList, type PaginatedResponse, type PhaseID, type ProductID, type RemoveSeatsParams, type RequestOptions, type RetrieveOptions, type SeatBalance, type SeatBalanceResponse, type SeatEvent, type SetSeatsParams, type Subscription, type SubscriptionItem, type UpdateCustomerParams, type UsageEvent, type UsageEventProperty, type WebhookData, type WebhookEvent, type WebhookID, type WebhookPayload, Commet as default, isProduction, isSandbox };
679
+ export { type AddSeatsParams, type AgreementID, type ApiResponse, type BatchResult, type BulkSeatUpdate, type BulkUpdateSeatsParams, Commet, CommetAPIError, type CommetConfig, CommetError, type CommetGeneratedTypes, CommetValidationError, type CreateBatchUsageEventsParams, type CreateCustomerParams, type CreateSubscriptionParams, type CreateUsageEventParams, type Currency, type Customer, type CustomerID, type Environment, type EventID, type GeneratedEventType, type GeneratedProductId, type GeneratedSeatType, type GetAllBalancesParams, type GetBalanceParams, type InvoiceID, type ItemID, type ListCustomersParams, type ListParams, type ListSeatEventsParams, type ListSubscriptionsParams, type ListUsageEventsParams, type PaginatedList, type PaginatedResponse, type PhaseID, type PortalAccess, type ProductID, type RemoveSeatsParams, type RequestAccessParams, type RequestOptions, type RetrieveOptions, type SeatBalance, type SeatBalanceResponse, type SeatEvent, type SetSeatsParams, type Subscription, type SubscriptionItem, type UpdateCustomerParams, type UsageEvent, type UsageEventProperty, type WebhookData, type WebhookEvent, type WebhookID, type WebhookPayload, Webhooks, Commet as default, isProduction, isSandbox };
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ __export(index_exports, {
34
34
  CommetAPIError: () => CommetAPIError,
35
35
  CommetError: () => CommetError,
36
36
  CommetValidationError: () => CommetValidationError,
37
+ Webhooks: () => Webhooks,
37
38
  default: () => index_default,
38
39
  isProduction: () => isProduction,
39
40
  isSandbox: () => isSandbox
@@ -70,6 +71,44 @@ var CustomersResource = class {
70
71
  }
71
72
  };
72
73
 
74
+ // src/resources/portal.ts
75
+ var PortalResource = class {
76
+ constructor(httpClient) {
77
+ this.httpClient = httpClient;
78
+ }
79
+ /**
80
+ * Request portal access for a customer
81
+ *
82
+ * Generates a secure portal URL that can be sent to the customer via email or used directly.
83
+ * The URL contains a time-limited token for secure access to the customer portal.
84
+ *
85
+ * @param params - customerId, externalId, or email
86
+ * @param options - Request options (idempotency, timeout)
87
+ * @returns Portal access response with URL
88
+ *
89
+ * @example
90
+ * // External ID (recommended)
91
+ * const portal = await commet.portal.requestAccess({
92
+ * externalId: 'my-customer-123'
93
+ * });
94
+ *
95
+ * @example
96
+ * // Customer ID
97
+ * const portal = await commet.portal.requestAccess({
98
+ * customerId: 'cus_123'
99
+ * });
100
+ *
101
+ * @example
102
+ * // Email
103
+ * const portal = await commet.portal.requestAccess({
104
+ * email: 'customer@example.com'
105
+ * });
106
+ */
107
+ async requestAccess(params, options) {
108
+ return this.httpClient.post("/portal/request-access", params, options);
109
+ }
110
+ };
111
+
73
112
  // src/resources/seats.ts
74
113
  var SeatsResource = class {
75
114
  constructor(httpClient) {
@@ -591,6 +630,7 @@ var Commet = class {
591
630
  this.usage = new UsageResource(this.httpClient);
592
631
  this.seats = new SeatsResource(this.httpClient);
593
632
  this.subscriptions = new SubscriptionsResource(this.httpClient);
633
+ this.portal = new PortalResource(this.httpClient);
594
634
  this.webhooks = new Webhooks();
595
635
  if (config.debug) {
596
636
  console.log(`[Commet SDK] Initialized in ${this.environment} mode`);
@@ -626,6 +666,7 @@ var index_default = Commet;
626
666
  CommetAPIError,
627
667
  CommetError,
628
668
  CommetValidationError,
669
+ Webhooks,
629
670
  isProduction,
630
671
  isSandbox
631
672
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/resources/customers.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"],"sourcesContent":["/**\n * Commet SDK - Billing and usage tracking SDK\n */\nexport { Commet } from \"./client\";\n\n// Type exports\nexport type {\n CommetConfig,\n CommetGeneratedTypes,\n GeneratedEventType,\n GeneratedSeatType,\n GeneratedProductId,\n Environment,\n ApiResponse,\n PaginatedResponse,\n PaginatedList,\n Currency,\n CustomerID,\n AgreementID,\n InvoiceID,\n PhaseID,\n ItemID,\n ProductID,\n EventID,\n WebhookID,\n ListParams,\n RetrieveOptions,\n RequestOptions,\n} from \"./types/common\";\n\n// Error exports\nexport {\n CommetError,\n CommetAPIError,\n CommetValidationError,\n} from \"./types/common\";\n\n// Resource type exports\nexport type {\n Customer,\n CreateCustomerParams,\n UpdateCustomerParams,\n ListCustomersParams,\n} from \"./resources/customers\";\n\nexport type {\n UsageEvent,\n UsageEventProperty,\n CreateUsageEventParams,\n CreateBatchUsageEventsParams,\n BatchResult,\n ListUsageEventsParams,\n} from \"./resources/usage\";\n\nexport type {\n SeatBalance,\n SeatEvent,\n SeatBalanceResponse,\n BulkSeatUpdate,\n AddSeatsParams,\n RemoveSeatsParams,\n SetSeatsParams,\n BulkUpdateSeatsParams,\n GetBalanceParams,\n GetAllBalancesParams,\n ListSeatEventsParams,\n} from \"./resources/seats\";\n\nexport type {\n Subscription,\n SubscriptionItem,\n CreateSubscriptionParams,\n ListSubscriptionsParams,\n} from \"./resources/subscriptions\";\n\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","import type {\n ApiResponse,\n Currency,\n CustomerID,\n ListParams,\n RequestOptions,\n RetrieveOptions,\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 taxStatus: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency: Currency;\n addressId: string;\n billingEmail?: string;\n paymentTerms?: 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\n// Base fields shared by all customer creation scenarios\ninterface CreateCustomerBaseParams {\n externalId?: string;\n legalName: string;\n displayName?: string;\n domain?: string;\n website?: string;\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n}\n\n// Address structure\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n region?: string;\n}\n\n// When taxStatus is TAXED, address is required\ninterface CreateCustomerTaxed extends CreateCustomerBaseParams {\n taxStatus: \"TAXED\";\n address: CustomerAddress;\n}\n\n// For other tax statuses, address is optional\ninterface CreateCustomerOtherTaxStatus extends CreateCustomerBaseParams {\n taxStatus?: \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n address?: CustomerAddress;\n}\n\n// Union type that enforces the constraint\nexport type CreateCustomerParams =\n | CreateCustomerTaxed\n | CreateCustomerOtherTaxStatus;\n\nexport interface UpdateCustomerParams {\n externalId?: string;\n legalName?: string;\n displayName?: string;\n domain?: string;\n website?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n isActive?: boolean;\n}\n\nexport interface ListCustomersParams extends ListParams {\n externalId?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n isActive?: boolean;\n search?: string;\n}\n\n/**\n * Customer resource for managing customer data\n */\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\"/customers\", params, options);\n }\n\n async retrieve(\n customerId: CustomerID,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Customer>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/customers/${customerId}`, params);\n }\n\n async update(\n customerId: CustomerID,\n params: UpdateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(`/customers/${customerId}`, params, options);\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params);\n }\n\n /**\n * Deactivate a customer (soft delete)\n */\n async deactivate(\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 CustomerID,\n GeneratedSeatType,\n ListParams,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatBalance {\n id: string;\n organizationId: string;\n customerId: CustomerID;\n seatType: GeneratedSeatType;\n balance: number;\n asOf: string;\n createdAt: string;\n updatedAt: string;\n}\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 SeatBalanceResponse {\n current: number;\n asOf: string;\n}\n\nexport interface BulkSeatUpdate {\n [seatType: string]: number;\n}\n\nexport interface AddSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface BulkUpdateSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seats: BulkSeatUpdate;\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\nexport interface ListSeatEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType?: GeneratedSeatType;\n eventType?: \"add\" | \"remove\" | \"set\";\n}\n\n/**\n * Seats resource for seat-based billing management\n */\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async bulkUpdate(\n params: BulkUpdateSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\n \"/seats/bulk\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seats: params.seats,\n },\n options,\n );\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalanceResponse>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalanceResponse>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n externalId: params.externalId,\n });\n }\n\n async listEvents(\n params?: ListSeatEventsParams,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.get(\"/seats/events\", params);\n }\n}\n","import type {\n ApiResponse,\n GeneratedProductId,\n ListParams,\n RequestOptions,\n RetrieveOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Subscription {\n id: string; // publicId (e.g., \"sub_xxx\")\n customerId: string;\n name: string;\n description?: string;\n status: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n startDate: string; // ISO datetime\n endDate?: string; // ISO datetime (puede ser null)\n billingDayOfMonth: number; // 1-31\n totalContractValue?: number;\n poNumber?: string;\n reference?: string;\n isTemplate?: boolean;\n checkoutUrl?: string; // Secure checkout URL for pending payment subscriptions\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface SubscriptionItem {\n priceId: string; // List price ID\n quantity?: number; // For fixed pricing\n initialSeats?: number; // For seat-based pricing\n}\n\n// Customer identifier: mutually exclusive customerId or externalId\ntype CustomerIdentifier =\n | { customerId: string; externalId?: never }\n | { customerId?: never; externalId: string };\n\nexport type CreateSubscriptionParams = CustomerIdentifier & {\n items: SubscriptionItem[];\n name?: string;\n startDate?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\";\n};\n\nexport interface ListSubscriptionsParams extends ListParams {\n customerId?: string;\n externalId?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n}\n\n/**\n * Subscription resource for managing subscriptions\n */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a subscription with multiple items (products)\n *\n * @example\n * ```typescript\n * // Free plan - Multiple products\n * await commet.subscriptions.create({\n * externalId: \"org_123\",\n * items: [\n * { priceId: \"price_tasks_free\", quantity: 1 },\n * { priceId: \"price_usage_free\" },\n * { priceId: \"price_seats_free\", initialSeats: 1 }\n * ]\n * });\n *\n * // Pro plan upgrade\n * await commet.subscriptions.create({\n * customerId: \"cus_xxx\",\n * items: [\n * { priceId: \"price_tasks_pro\" },\n * { priceId: \"price_usage_pro\" },\n * { priceId: \"price_seats_pro\", initialSeats: 5 }\n * ],\n * status: \"active\"\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 * Retrieve a subscription by ID\n */\n async retrieve(\n subscriptionId: string,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Subscription>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/subscriptions/${subscriptionId}`, params);\n }\n\n /**\n * List subscriptions with optional filters\n *\n * @example\n * ```typescript\n * // List all active subscriptions for a customer\n * await commet.subscriptions.list({\n * customerId: \"cus_xxx\",\n * status: \"active\"\n * });\n *\n * // Using externalId\n * await commet.subscriptions.list({\n * externalId: \"my-customer-123\"\n * });\n * ```\n */\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<Subscription[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /**\n * Cancel a subscription\n *\n * @example\n * ```typescript\n * await commet.subscriptions.cancel(\"sub_xxx\");\n * ```\n */\n async cancel(\n subscriptionId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/cancel`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n GeneratedEventType,\n ListParams,\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 CreateUsageEventParams {\n eventType: GeneratedEventType;\n customerId?: CustomerID;\n externalId?: string;\n idempotencyKey?: string; // For idempotency\n timestamp?: string; // ISO string, defaults to now\n properties?: Array<{\n property: string;\n value: string;\n }>;\n}\n\nexport interface CreateBatchUsageEventsParams {\n events: CreateUsageEventParams[];\n}\n\nexport interface BatchResult<T> {\n successful: T[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateUsageEventParams;\n }>;\n}\n\nexport interface ListUsageEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n eventType?: GeneratedEventType;\n idempotencyKey?: string;\n}\n\n/**\n * Usage Events resource - Track business events for usage-based billing\n */\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateUsageEventParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData = {\n ...params,\n ts: params.timestamp || new Date().toISOString(),\n };\n\n return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n async createBatch(\n params: CreateBatchUsageEventsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult<UsageEvent>>> {\n return this.httpClient.post(\"/usage/events/batch\", params, options);\n }\n\n async retrieve(eventId: EventID): Promise<ApiResponse<UsageEvent>> {\n return this.httpClient.get(`/usage/events/${eventId}`);\n }\n\n async list(\n params?: ListUsageEventsParams,\n ): Promise<ApiResponse<UsageEvent[]>> {\n return this.httpClient.get(\"/usage/events\", params);\n }\n\n async delete(\n eventId: EventID,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ deleted: boolean }>> {\n return this.httpClient.delete(\n `/usage/events/${eventId}`,\n undefined,\n options,\n );\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 */\nexport type GeneratedProductId = CommetGeneratedTypes extends {\n productId: 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 const responseClone = response.clone();\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 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 { 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 usage: UsageResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\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.usage = new UsageResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2GO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA,EAEnD,MAAM,OACJ,QACA,SACgC;AAChC,WAAO,KAAK,WAAW,KAAK,cAAc,QAAQ,OAAO;AAAA,EAC3D;AAAA,EAEA,MAAM,SACJ,YACA,SACgC;AAChC,UAAM,SAAS,SAAS,SACpB,EAAE,QAAQ,QAAQ,OAAO,KAAK,GAAG,EAAE,IACnC;AACJ,WAAO,KAAK,WAAW,IAAI,cAAc,UAAU,IAAI,MAAM;AAAA,EAC/D;AAAA,EAEA,MAAM,OACJ,YACA,QACA,SACgC;AAChC,WAAO,KAAK,WAAW,IAAI,cAAc,UAAU,IAAI,QAAQ,OAAO;AAAA,EACxE;AAAA,EA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I,iBAAiB,QAAQ,KAAK,WAAW;AAC/D,SAAK,YAAY,IAAI,kBAAkB,KAAK,UAAU;AACtD,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,gBAAgB,IAAI,sBAAsB,KAAK,UAAU;AAC9D,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;;;AC3DO,SAAS,UAAU,aAAmC;AAC3D,SAAO,gBAAgB;AACzB;AAKO,SAAS,aAAa,aAAmC;AAC9D,SAAO,gBAAgB;AACzB;;;ATwEA,IAAO,gBAAQ;","names":["crypto","data"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/resources/customers.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"],"sourcesContent":["/**\n * Commet SDK - Billing and usage tracking SDK\n */\nexport { Commet } from \"./client\";\n\n// Type exports\nexport type {\n CommetConfig,\n CommetGeneratedTypes,\n GeneratedEventType,\n GeneratedSeatType,\n GeneratedProductId,\n Environment,\n ApiResponse,\n PaginatedResponse,\n PaginatedList,\n Currency,\n CustomerID,\n AgreementID,\n InvoiceID,\n PhaseID,\n ItemID,\n ProductID,\n EventID,\n WebhookID,\n ListParams,\n RetrieveOptions,\n RequestOptions,\n} from \"./types/common\";\n\n// Error exports\nexport {\n CommetError,\n CommetAPIError,\n CommetValidationError,\n} from \"./types/common\";\n\n// Resource type exports\nexport type {\n Customer,\n CreateCustomerParams,\n UpdateCustomerParams,\n ListCustomersParams,\n} from \"./resources/customers\";\n\nexport type {\n UsageEvent,\n UsageEventProperty,\n CreateUsageEventParams,\n CreateBatchUsageEventsParams,\n BatchResult,\n ListUsageEventsParams,\n} from \"./resources/usage\";\n\nexport type {\n SeatBalance,\n SeatEvent,\n SeatBalanceResponse,\n BulkSeatUpdate,\n AddSeatsParams,\n RemoveSeatsParams,\n SetSeatsParams,\n BulkUpdateSeatsParams,\n GetBalanceParams,\n GetAllBalancesParams,\n ListSeatEventsParams,\n} from \"./resources/seats\";\n\nexport type {\n Subscription,\n SubscriptionItem,\n CreateSubscriptionParams,\n ListSubscriptionsParams,\n} from \"./resources/subscriptions\";\n\nexport type {\n PortalAccess,\n RequestAccessParams,\n} from \"./resources/portal\";\n\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","import type {\n ApiResponse,\n Currency,\n CustomerID,\n ListParams,\n RequestOptions,\n RetrieveOptions,\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 taxStatus: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency: Currency;\n addressId: string;\n billingEmail?: string;\n paymentTerms?: 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\n// Base fields shared by all customer creation scenarios\ninterface CreateCustomerBaseParams {\n externalId?: string;\n legalName: string;\n displayName?: string;\n domain?: string;\n website?: string;\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n}\n\n// Address structure\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n region?: string;\n}\n\n// When taxStatus is TAXED, address is required\ninterface CreateCustomerTaxed extends CreateCustomerBaseParams {\n taxStatus: \"TAXED\";\n address: CustomerAddress;\n}\n\n// For other tax statuses, address is optional\ninterface CreateCustomerOtherTaxStatus extends CreateCustomerBaseParams {\n taxStatus?: \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n address?: CustomerAddress;\n}\n\n// Union type that enforces the constraint\nexport type CreateCustomerParams =\n | CreateCustomerTaxed\n | CreateCustomerOtherTaxStatus;\n\nexport interface UpdateCustomerParams {\n externalId?: string;\n legalName?: string;\n displayName?: string;\n domain?: string;\n website?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n isActive?: boolean;\n}\n\nexport interface ListCustomersParams extends ListParams {\n externalId?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n isActive?: boolean;\n search?: string;\n}\n\n/**\n * Customer resource for managing customer data\n */\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\"/customers\", params, options);\n }\n\n async retrieve(\n customerId: CustomerID,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Customer>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/customers/${customerId}`, params);\n }\n\n async update(\n customerId: CustomerID,\n params: UpdateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(`/customers/${customerId}`, params, options);\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params);\n }\n\n /**\n * Deactivate a customer (soft delete)\n */\n async deactivate(\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, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\n/**\n * Portal access response\n */\nexport interface PortalAccess {\n success: boolean;\n message: string;\n portalUrl: string;\n}\n\n/**\n * Request portal access by customer ID\n */\ninterface RequestAccessByCustomerId {\n customerId: CustomerID;\n email?: never;\n externalId?: never;\n}\n\n/**\n * Request portal access by external ID\n */\ninterface RequestAccessByExternalId {\n externalId: string;\n email?: never;\n customerId?: never;\n}\n\n/**\n * Request portal access by email\n */\ninterface RequestAccessByEmail {\n email: string;\n customerId?: never;\n externalId?: never;\n}\n\n/**\n * Portal access parameters\n */\nexport type RequestAccessParams =\n | RequestAccessByCustomerId\n | RequestAccessByExternalId\n | RequestAccessByEmail;\n\n/**\n * Customer Portal resource for generating customer portal access\n */\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Request portal access for a customer\n *\n * Generates a secure portal URL that can be sent to the customer via email or used directly.\n * The URL contains a time-limited token for secure access to the customer portal.\n *\n * @param params - customerId, externalId, or email\n * @param options - Request options (idempotency, timeout)\n * @returns Portal access response with URL\n *\n * @example\n * // External ID (recommended)\n * const portal = await commet.portal.requestAccess({\n * externalId: 'my-customer-123'\n * });\n *\n * @example\n * // Customer ID\n * const portal = await commet.portal.requestAccess({\n * customerId: 'cus_123'\n * });\n *\n * @example\n * // Email\n * const portal = await commet.portal.requestAccess({\n * email: 'customer@example.com'\n * });\n */\n async requestAccess(\n params: RequestAccessParams,\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 ListParams,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatBalance {\n id: string;\n organizationId: string;\n customerId: CustomerID;\n seatType: GeneratedSeatType;\n balance: number;\n asOf: string;\n createdAt: string;\n updatedAt: string;\n}\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 SeatBalanceResponse {\n current: number;\n asOf: string;\n}\n\nexport interface BulkSeatUpdate {\n [seatType: string]: number;\n}\n\nexport interface AddSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface BulkUpdateSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seats: BulkSeatUpdate;\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\nexport interface ListSeatEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType?: GeneratedSeatType;\n eventType?: \"add\" | \"remove\" | \"set\";\n}\n\n/**\n * Seats resource for seat-based billing management\n */\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async bulkUpdate(\n params: BulkUpdateSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\n \"/seats/bulk\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seats: params.seats,\n },\n options,\n );\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalanceResponse>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalanceResponse>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n externalId: params.externalId,\n });\n }\n\n async listEvents(\n params?: ListSeatEventsParams,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.get(\"/seats/events\", params);\n }\n}\n","import type {\n ApiResponse,\n GeneratedProductId,\n ListParams,\n RequestOptions,\n RetrieveOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Subscription {\n id: string; // publicId (e.g., \"sub_xxx\")\n customerId: string;\n name: string;\n description?: string;\n status: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n startDate: string; // ISO datetime\n endDate?: string; // ISO datetime (puede ser null)\n billingDayOfMonth: number; // 1-31\n isTemplate?: boolean;\n checkoutUrl?: string; // Secure checkout URL for pending payment subscriptions\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface SubscriptionItem {\n priceId: string; // List price ID\n quantity?: number; // For fixed pricing\n initialSeats?: number; // For seat-based pricing\n}\n\n// Customer identifier: mutually exclusive customerId or externalId\ntype CustomerIdentifier =\n | { customerId: string; externalId?: never }\n | { customerId?: never; externalId: string };\n\nexport type CreateSubscriptionParams = CustomerIdentifier & {\n items: SubscriptionItem[];\n name?: string;\n startDate?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\";\n};\n\nexport interface ListSubscriptionsParams extends ListParams {\n customerId?: string;\n externalId?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n}\n\n/**\n * Subscription resource for managing subscriptions\n */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a subscription with multiple items (products)\n *\n * @example\n * ```typescript\n * // Free plan - Multiple products\n * await commet.subscriptions.create({\n * externalId: \"org_123\",\n * items: [\n * { priceId: \"price_tasks_free\", quantity: 1 },\n * { priceId: \"price_usage_free\" },\n * { priceId: \"price_seats_free\", initialSeats: 1 }\n * ]\n * });\n *\n * // Pro plan upgrade\n * await commet.subscriptions.create({\n * customerId: \"cus_xxx\",\n * items: [\n * { priceId: \"price_tasks_pro\" },\n * { priceId: \"price_usage_pro\" },\n * { priceId: \"price_seats_pro\", initialSeats: 5 }\n * ],\n * status: \"active\"\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 * Retrieve a subscription by ID\n */\n async retrieve(\n subscriptionId: string,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Subscription>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/subscriptions/${subscriptionId}`, params);\n }\n\n /**\n * List subscriptions with optional filters\n *\n * @example\n * ```typescript\n * // List all active subscriptions for a customer\n * await commet.subscriptions.list({\n * customerId: \"cus_xxx\",\n * status: \"active\"\n * });\n *\n * // Using externalId\n * await commet.subscriptions.list({\n * externalId: \"my-customer-123\"\n * });\n * ```\n */\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<Subscription[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /**\n * Cancel a subscription\n *\n * @example\n * ```typescript\n * await commet.subscriptions.cancel(\"sub_xxx\");\n * ```\n */\n async cancel(\n subscriptionId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/cancel`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n GeneratedEventType,\n ListParams,\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 CreateUsageEventParams {\n eventType: GeneratedEventType;\n customerId?: CustomerID;\n externalId?: string;\n idempotencyKey?: string; // For idempotency\n timestamp?: string; // ISO string, defaults to now\n properties?: Array<{\n property: string;\n value: string;\n }>;\n}\n\nexport interface CreateBatchUsageEventsParams {\n events: CreateUsageEventParams[];\n}\n\nexport interface BatchResult<T> {\n successful: T[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateUsageEventParams;\n }>;\n}\n\nexport interface ListUsageEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n eventType?: GeneratedEventType;\n idempotencyKey?: string;\n}\n\n/**\n * Usage Events resource - Track business events for usage-based billing\n */\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateUsageEventParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData = {\n ...params,\n ts: params.timestamp || new Date().toISOString(),\n };\n\n return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n async createBatch(\n params: CreateBatchUsageEventsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult<UsageEvent>>> {\n return this.httpClient.post(\"/usage/events/batch\", params, options);\n }\n\n async retrieve(eventId: EventID): Promise<ApiResponse<UsageEvent>> {\n return this.httpClient.get(`/usage/events/${eventId}`);\n }\n\n async list(\n params?: ListUsageEventsParams,\n ): Promise<ApiResponse<UsageEvent[]>> {\n return this.httpClient.get(\"/usage/events\", params);\n }\n\n async delete(\n eventId: EventID,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ deleted: boolean }>> {\n return this.httpClient.delete(\n `/usage/events/${eventId}`,\n undefined,\n options,\n );\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 */\nexport type GeneratedProductId = CommetGeneratedTypes extends {\n productId: 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 const responseClone = response.clone();\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 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 { 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 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.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;AC2GO,IAAM,oBAAN,MAAwB;AAAA,EA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AAM,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;;;AC9DO,SAAS,UAAU,aAAmC;AAC3D,SAAO,gBAAgB;AACzB;AAKO,SAAS,aAAa,aAAmC;AAC9D,SAAO,gBAAgB;AACzB;;;AV8EA,IAAO,gBAAQ;","names":["crypto","data"]}
package/dist/index.mjs CHANGED
@@ -28,6 +28,44 @@ var CustomersResource = class {
28
28
  }
29
29
  };
30
30
 
31
+ // src/resources/portal.ts
32
+ var PortalResource = class {
33
+ constructor(httpClient) {
34
+ this.httpClient = httpClient;
35
+ }
36
+ /**
37
+ * Request portal access for a customer
38
+ *
39
+ * Generates a secure portal URL that can be sent to the customer via email or used directly.
40
+ * The URL contains a time-limited token for secure access to the customer portal.
41
+ *
42
+ * @param params - customerId, externalId, or email
43
+ * @param options - Request options (idempotency, timeout)
44
+ * @returns Portal access response with URL
45
+ *
46
+ * @example
47
+ * // External ID (recommended)
48
+ * const portal = await commet.portal.requestAccess({
49
+ * externalId: 'my-customer-123'
50
+ * });
51
+ *
52
+ * @example
53
+ * // Customer ID
54
+ * const portal = await commet.portal.requestAccess({
55
+ * customerId: 'cus_123'
56
+ * });
57
+ *
58
+ * @example
59
+ * // Email
60
+ * const portal = await commet.portal.requestAccess({
61
+ * email: 'customer@example.com'
62
+ * });
63
+ */
64
+ async requestAccess(params, options) {
65
+ return this.httpClient.post("/portal/request-access", params, options);
66
+ }
67
+ };
68
+
31
69
  // src/resources/seats.ts
32
70
  var SeatsResource = class {
33
71
  constructor(httpClient) {
@@ -549,6 +587,7 @@ var Commet = class {
549
587
  this.usage = new UsageResource(this.httpClient);
550
588
  this.seats = new SeatsResource(this.httpClient);
551
589
  this.subscriptions = new SubscriptionsResource(this.httpClient);
590
+ this.portal = new PortalResource(this.httpClient);
552
591
  this.webhooks = new Webhooks();
553
592
  if (config.debug) {
554
593
  console.log(`[Commet SDK] Initialized in ${this.environment} mode`);
@@ -583,6 +622,7 @@ export {
583
622
  CommetAPIError,
584
623
  CommetError,
585
624
  CommetValidationError,
625
+ Webhooks,
586
626
  index_default as default,
587
627
  isProduction,
588
628
  isSandbox
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/resources/customers.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 Currency,\n CustomerID,\n ListParams,\n RequestOptions,\n RetrieveOptions,\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 taxStatus: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency: Currency;\n addressId: string;\n billingEmail?: string;\n paymentTerms?: 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\n// Base fields shared by all customer creation scenarios\ninterface CreateCustomerBaseParams {\n externalId?: string;\n legalName: string;\n displayName?: string;\n domain?: string;\n website?: string;\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n}\n\n// Address structure\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n region?: string;\n}\n\n// When taxStatus is TAXED, address is required\ninterface CreateCustomerTaxed extends CreateCustomerBaseParams {\n taxStatus: \"TAXED\";\n address: CustomerAddress;\n}\n\n// For other tax statuses, address is optional\ninterface CreateCustomerOtherTaxStatus extends CreateCustomerBaseParams {\n taxStatus?: \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n address?: CustomerAddress;\n}\n\n// Union type that enforces the constraint\nexport type CreateCustomerParams =\n | CreateCustomerTaxed\n | CreateCustomerOtherTaxStatus;\n\nexport interface UpdateCustomerParams {\n externalId?: string;\n legalName?: string;\n displayName?: string;\n domain?: string;\n website?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n isActive?: boolean;\n}\n\nexport interface ListCustomersParams extends ListParams {\n externalId?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n isActive?: boolean;\n search?: string;\n}\n\n/**\n * Customer resource for managing customer data\n */\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\"/customers\", params, options);\n }\n\n async retrieve(\n customerId: CustomerID,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Customer>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/customers/${customerId}`, params);\n }\n\n async update(\n customerId: CustomerID,\n params: UpdateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(`/customers/${customerId}`, params, options);\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params);\n }\n\n /**\n * Deactivate a customer (soft delete)\n */\n async deactivate(\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 CustomerID,\n GeneratedSeatType,\n ListParams,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatBalance {\n id: string;\n organizationId: string;\n customerId: CustomerID;\n seatType: GeneratedSeatType;\n balance: number;\n asOf: string;\n createdAt: string;\n updatedAt: string;\n}\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 SeatBalanceResponse {\n current: number;\n asOf: string;\n}\n\nexport interface BulkSeatUpdate {\n [seatType: string]: number;\n}\n\nexport interface AddSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface BulkUpdateSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seats: BulkSeatUpdate;\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\nexport interface ListSeatEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType?: GeneratedSeatType;\n eventType?: \"add\" | \"remove\" | \"set\";\n}\n\n/**\n * Seats resource for seat-based billing management\n */\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async bulkUpdate(\n params: BulkUpdateSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\n \"/seats/bulk\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seats: params.seats,\n },\n options,\n );\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalanceResponse>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalanceResponse>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n externalId: params.externalId,\n });\n }\n\n async listEvents(\n params?: ListSeatEventsParams,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.get(\"/seats/events\", params);\n }\n}\n","import type {\n ApiResponse,\n GeneratedProductId,\n ListParams,\n RequestOptions,\n RetrieveOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Subscription {\n id: string; // publicId (e.g., \"sub_xxx\")\n customerId: string;\n name: string;\n description?: string;\n status: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n startDate: string; // ISO datetime\n endDate?: string; // ISO datetime (puede ser null)\n billingDayOfMonth: number; // 1-31\n totalContractValue?: number;\n poNumber?: string;\n reference?: string;\n isTemplate?: boolean;\n checkoutUrl?: string; // Secure checkout URL for pending payment subscriptions\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface SubscriptionItem {\n priceId: string; // List price ID\n quantity?: number; // For fixed pricing\n initialSeats?: number; // For seat-based pricing\n}\n\n// Customer identifier: mutually exclusive customerId or externalId\ntype CustomerIdentifier =\n | { customerId: string; externalId?: never }\n | { customerId?: never; externalId: string };\n\nexport type CreateSubscriptionParams = CustomerIdentifier & {\n items: SubscriptionItem[];\n name?: string;\n startDate?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\";\n};\n\nexport interface ListSubscriptionsParams extends ListParams {\n customerId?: string;\n externalId?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n}\n\n/**\n * Subscription resource for managing subscriptions\n */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a subscription with multiple items (products)\n *\n * @example\n * ```typescript\n * // Free plan - Multiple products\n * await commet.subscriptions.create({\n * externalId: \"org_123\",\n * items: [\n * { priceId: \"price_tasks_free\", quantity: 1 },\n * { priceId: \"price_usage_free\" },\n * { priceId: \"price_seats_free\", initialSeats: 1 }\n * ]\n * });\n *\n * // Pro plan upgrade\n * await commet.subscriptions.create({\n * customerId: \"cus_xxx\",\n * items: [\n * { priceId: \"price_tasks_pro\" },\n * { priceId: \"price_usage_pro\" },\n * { priceId: \"price_seats_pro\", initialSeats: 5 }\n * ],\n * status: \"active\"\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 * Retrieve a subscription by ID\n */\n async retrieve(\n subscriptionId: string,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Subscription>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/subscriptions/${subscriptionId}`, params);\n }\n\n /**\n * List subscriptions with optional filters\n *\n * @example\n * ```typescript\n * // List all active subscriptions for a customer\n * await commet.subscriptions.list({\n * customerId: \"cus_xxx\",\n * status: \"active\"\n * });\n *\n * // Using externalId\n * await commet.subscriptions.list({\n * externalId: \"my-customer-123\"\n * });\n * ```\n */\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<Subscription[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /**\n * Cancel a subscription\n *\n * @example\n * ```typescript\n * await commet.subscriptions.cancel(\"sub_xxx\");\n * ```\n */\n async cancel(\n subscriptionId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/cancel`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n GeneratedEventType,\n ListParams,\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 CreateUsageEventParams {\n eventType: GeneratedEventType;\n customerId?: CustomerID;\n externalId?: string;\n idempotencyKey?: string; // For idempotency\n timestamp?: string; // ISO string, defaults to now\n properties?: Array<{\n property: string;\n value: string;\n }>;\n}\n\nexport interface CreateBatchUsageEventsParams {\n events: CreateUsageEventParams[];\n}\n\nexport interface BatchResult<T> {\n successful: T[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateUsageEventParams;\n }>;\n}\n\nexport interface ListUsageEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n eventType?: GeneratedEventType;\n idempotencyKey?: string;\n}\n\n/**\n * Usage Events resource - Track business events for usage-based billing\n */\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateUsageEventParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData = {\n ...params,\n ts: params.timestamp || new Date().toISOString(),\n };\n\n return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n async createBatch(\n params: CreateBatchUsageEventsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult<UsageEvent>>> {\n return this.httpClient.post(\"/usage/events/batch\", params, options);\n }\n\n async retrieve(eventId: EventID): Promise<ApiResponse<UsageEvent>> {\n return this.httpClient.get(`/usage/events/${eventId}`);\n }\n\n async list(\n params?: ListUsageEventsParams,\n ): Promise<ApiResponse<UsageEvent[]>> {\n return this.httpClient.get(\"/usage/events\", params);\n }\n\n async delete(\n eventId: EventID,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ deleted: boolean }>> {\n return this.httpClient.delete(\n `/usage/events/${eventId}`,\n undefined,\n options,\n );\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 */\nexport type GeneratedProductId = CommetGeneratedTypes extends {\n productId: 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 const responseClone = response.clone();\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 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 { 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 usage: UsageResource;\n public readonly seats: SeatsResource;\n public readonly subscriptions: SubscriptionsResource;\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.usage = new UsageResource(this.httpClient);\n this.seats = new SeatsResource(this.httpClient);\n this.subscriptions = new SubscriptionsResource(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 SDK\n */\nexport { Commet } from \"./client\";\n\n// Type exports\nexport type {\n CommetConfig,\n CommetGeneratedTypes,\n GeneratedEventType,\n GeneratedSeatType,\n GeneratedProductId,\n Environment,\n ApiResponse,\n PaginatedResponse,\n PaginatedList,\n Currency,\n CustomerID,\n AgreementID,\n InvoiceID,\n PhaseID,\n ItemID,\n ProductID,\n EventID,\n WebhookID,\n ListParams,\n RetrieveOptions,\n RequestOptions,\n} from \"./types/common\";\n\n// Error exports\nexport {\n CommetError,\n CommetAPIError,\n CommetValidationError,\n} from \"./types/common\";\n\n// Resource type exports\nexport type {\n Customer,\n CreateCustomerParams,\n UpdateCustomerParams,\n ListCustomersParams,\n} from \"./resources/customers\";\n\nexport type {\n UsageEvent,\n UsageEventProperty,\n CreateUsageEventParams,\n CreateBatchUsageEventsParams,\n BatchResult,\n ListUsageEventsParams,\n} from \"./resources/usage\";\n\nexport type {\n SeatBalance,\n SeatEvent,\n SeatBalanceResponse,\n BulkSeatUpdate,\n AddSeatsParams,\n RemoveSeatsParams,\n SetSeatsParams,\n BulkUpdateSeatsParams,\n GetBalanceParams,\n GetAllBalancesParams,\n ListSeatEventsParams,\n} from \"./resources/seats\";\n\nexport type {\n Subscription,\n SubscriptionItem,\n CreateSubscriptionParams,\n ListSubscriptionsParams,\n} from \"./resources/subscriptions\";\n\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":";AA2GO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA,EAEnD,MAAM,OACJ,QACA,SACgC;AAChC,WAAO,KAAK,WAAW,KAAK,cAAc,QAAQ,OAAO;AAAA,EAC3D;AAAA,EAEA,MAAM,SACJ,YACA,SACgC;AAChC,UAAM,SAAS,SAAS,SACpB,EAAE,QAAQ,QAAQ,OAAO,KAAK,GAAG,EAAE,IACnC;AACJ,WAAO,KAAK,WAAW,IAAI,cAAc,UAAU,IAAI,MAAM;AAAA,EAC/D;AAAA,EAEA,MAAM,OACJ,YACA,QACA,SACgC;AAChC,WAAO,KAAK,WAAW,IAAI,cAAc,UAAU,IAAI,QAAQ,OAAO;AAAA,EACxE;AAAA,EAEA,MAAM,KAAK,QAAgE;AACzE,WAAO,KAAK,WAAW,IAAI,cAAc,MAAM;AAAA,EACjD;AAAA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IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,QAAQ,IAAI,cAAc,KAAK,UAAU;AAC9C,SAAK,gBAAgB,IAAI,sBAAsB,KAAK,UAAU;AAC9D,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;;;AC3DO,SAAS,UAAU,aAAmC;AAC3D,SAAO,gBAAgB;AACzB;AAKO,SAAS,aAAa,aAAmC;AAC9D,SAAO,gBAAgB;AACzB;;;ACwEA,IAAO,gBAAQ;","names":["data"]}
1
+ {"version":3,"sources":["../src/resources/customers.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 Currency,\n CustomerID,\n ListParams,\n RequestOptions,\n RetrieveOptions,\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 taxStatus: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency: Currency;\n addressId: string;\n billingEmail?: string;\n paymentTerms?: 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\n// Base fields shared by all customer creation scenarios\ninterface CreateCustomerBaseParams {\n externalId?: string;\n legalName: string;\n displayName?: string;\n domain?: string;\n website?: string;\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n}\n\n// Address structure\nexport interface CustomerAddress {\n line1: string;\n line2?: string;\n city: string;\n state?: string;\n postalCode: string;\n country: string; // ISO-2\n region?: string;\n}\n\n// When taxStatus is TAXED, address is required\ninterface CreateCustomerTaxed extends CreateCustomerBaseParams {\n taxStatus: \"TAXED\";\n address: CustomerAddress;\n}\n\n// For other tax statuses, address is optional\ninterface CreateCustomerOtherTaxStatus extends CreateCustomerBaseParams {\n taxStatus?: \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n address?: CustomerAddress;\n}\n\n// Union type that enforces the constraint\nexport type CreateCustomerParams =\n | CreateCustomerTaxed\n | CreateCustomerOtherTaxStatus;\n\nexport interface UpdateCustomerParams {\n externalId?: string;\n legalName?: string;\n displayName?: string;\n domain?: string;\n website?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n billingEmail?: string;\n paymentTerms?: string;\n timezone?: string;\n language?: string;\n industry?: string;\n employeeCount?: string;\n metadata?: Record<string, unknown>;\n isActive?: boolean;\n}\n\nexport interface ListCustomersParams extends ListParams {\n externalId?: string;\n taxStatus?: \"TAXED\" | \"TAX_EXEMPT\" | \"REVERSE_CHARGE\" | \"NOT_APPLICABLE\";\n currency?: Currency;\n isActive?: boolean;\n search?: string;\n}\n\n/**\n * Customer resource for managing customer data\n */\nexport class CustomersResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.post(\"/customers\", params, options);\n }\n\n async retrieve(\n customerId: CustomerID,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Customer>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/customers/${customerId}`, params);\n }\n\n async update(\n customerId: CustomerID,\n params: UpdateCustomerParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<Customer>> {\n return this.httpClient.put(`/customers/${customerId}`, params, options);\n }\n\n async list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>> {\n return this.httpClient.get(\"/customers\", params);\n }\n\n /**\n * Deactivate a customer (soft delete)\n */\n async deactivate(\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, CustomerID, RequestOptions } from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\n/**\n * Portal access response\n */\nexport interface PortalAccess {\n success: boolean;\n message: string;\n portalUrl: string;\n}\n\n/**\n * Request portal access by customer ID\n */\ninterface RequestAccessByCustomerId {\n customerId: CustomerID;\n email?: never;\n externalId?: never;\n}\n\n/**\n * Request portal access by external ID\n */\ninterface RequestAccessByExternalId {\n externalId: string;\n email?: never;\n customerId?: never;\n}\n\n/**\n * Request portal access by email\n */\ninterface RequestAccessByEmail {\n email: string;\n customerId?: never;\n externalId?: never;\n}\n\n/**\n * Portal access parameters\n */\nexport type RequestAccessParams =\n | RequestAccessByCustomerId\n | RequestAccessByExternalId\n | RequestAccessByEmail;\n\n/**\n * Customer Portal resource for generating customer portal access\n */\nexport class PortalResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Request portal access for a customer\n *\n * Generates a secure portal URL that can be sent to the customer via email or used directly.\n * The URL contains a time-limited token for secure access to the customer portal.\n *\n * @param params - customerId, externalId, or email\n * @param options - Request options (idempotency, timeout)\n * @returns Portal access response with URL\n *\n * @example\n * // External ID (recommended)\n * const portal = await commet.portal.requestAccess({\n * externalId: 'my-customer-123'\n * });\n *\n * @example\n * // Customer ID\n * const portal = await commet.portal.requestAccess({\n * customerId: 'cus_123'\n * });\n *\n * @example\n * // Email\n * const portal = await commet.portal.requestAccess({\n * email: 'customer@example.com'\n * });\n */\n async requestAccess(\n params: RequestAccessParams,\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 ListParams,\n RequestOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface SeatBalance {\n id: string;\n organizationId: string;\n customerId: CustomerID;\n seatType: GeneratedSeatType;\n balance: number;\n asOf: string;\n createdAt: string;\n updatedAt: string;\n}\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 SeatBalanceResponse {\n current: number;\n asOf: string;\n}\n\nexport interface BulkSeatUpdate {\n [seatType: string]: number;\n}\n\nexport interface AddSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface RemoveSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface SetSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType: GeneratedSeatType;\n count: number;\n}\n\nexport interface BulkUpdateSeatsParams {\n customerId?: CustomerID;\n externalId?: string;\n seats: BulkSeatUpdate;\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\nexport interface ListSeatEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n seatType?: GeneratedSeatType;\n eventType?: \"add\" | \"remove\" | \"set\";\n}\n\n/**\n * Seats resource for seat-based billing management\n */\nexport class SeatsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async add(\n params: AddSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async remove(\n params: RemoveSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.delete(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async set(\n params: SetSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.put(\n \"/seats\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n count: params.count,\n },\n options,\n );\n }\n\n async bulkUpdate(\n params: BulkUpdateSeatsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.put(\n \"/seats/bulk\",\n {\n customerId: params.customerId,\n externalId: params.externalId,\n seats: params.seats,\n },\n options,\n );\n }\n\n async getBalance(\n params: GetBalanceParams,\n ): Promise<ApiResponse<SeatBalanceResponse>> {\n return this.httpClient.get(\"/seats/balance\", {\n customerId: params.customerId,\n externalId: params.externalId,\n seatType: params.seatType,\n });\n }\n\n async getAllBalances(\n params: GetAllBalancesParams,\n ): Promise<ApiResponse<Record<string, SeatBalanceResponse>>> {\n return this.httpClient.get(\"/seats/balances\", {\n customerId: params.customerId,\n externalId: params.externalId,\n });\n }\n\n async listEvents(\n params?: ListSeatEventsParams,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.get(\"/seats/events\", params);\n }\n}\n","import type {\n ApiResponse,\n GeneratedProductId,\n ListParams,\n RequestOptions,\n RetrieveOptions,\n} from \"../types/common\";\nimport type { CommetHTTPClient } from \"../utils/http\";\n\nexport interface Subscription {\n id: string; // publicId (e.g., \"sub_xxx\")\n customerId: string;\n name: string;\n description?: string;\n status: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n startDate: string; // ISO datetime\n endDate?: string; // ISO datetime (puede ser null)\n billingDayOfMonth: number; // 1-31\n isTemplate?: boolean;\n checkoutUrl?: string; // Secure checkout URL for pending payment subscriptions\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface SubscriptionItem {\n priceId: string; // List price ID\n quantity?: number; // For fixed pricing\n initialSeats?: number; // For seat-based pricing\n}\n\n// Customer identifier: mutually exclusive customerId or externalId\ntype CustomerIdentifier =\n | { customerId: string; externalId?: never }\n | { customerId?: never; externalId: string };\n\nexport type CreateSubscriptionParams = CustomerIdentifier & {\n items: SubscriptionItem[];\n name?: string;\n startDate?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\";\n};\n\nexport interface ListSubscriptionsParams extends ListParams {\n customerId?: string;\n externalId?: string;\n status?: \"draft\" | \"pending_payment\" | \"active\" | \"completed\" | \"canceled\";\n}\n\n/**\n * Subscription resource for managing subscriptions\n */\nexport class SubscriptionsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n /**\n * Create a subscription with multiple items (products)\n *\n * @example\n * ```typescript\n * // Free plan - Multiple products\n * await commet.subscriptions.create({\n * externalId: \"org_123\",\n * items: [\n * { priceId: \"price_tasks_free\", quantity: 1 },\n * { priceId: \"price_usage_free\" },\n * { priceId: \"price_seats_free\", initialSeats: 1 }\n * ]\n * });\n *\n * // Pro plan upgrade\n * await commet.subscriptions.create({\n * customerId: \"cus_xxx\",\n * items: [\n * { priceId: \"price_tasks_pro\" },\n * { priceId: \"price_usage_pro\" },\n * { priceId: \"price_seats_pro\", initialSeats: 5 }\n * ],\n * status: \"active\"\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 * Retrieve a subscription by ID\n */\n async retrieve(\n subscriptionId: string,\n options?: RetrieveOptions,\n ): Promise<ApiResponse<Subscription>> {\n const params = options?.expand\n ? { expand: options.expand.join(\",\") }\n : undefined;\n return this.httpClient.get(`/subscriptions/${subscriptionId}`, params);\n }\n\n /**\n * List subscriptions with optional filters\n *\n * @example\n * ```typescript\n * // List all active subscriptions for a customer\n * await commet.subscriptions.list({\n * customerId: \"cus_xxx\",\n * status: \"active\"\n * });\n *\n * // Using externalId\n * await commet.subscriptions.list({\n * externalId: \"my-customer-123\"\n * });\n * ```\n */\n async list(\n params?: ListSubscriptionsParams,\n ): Promise<ApiResponse<Subscription[]>> {\n return this.httpClient.get(\"/subscriptions\", params);\n }\n\n /**\n * Cancel a subscription\n *\n * @example\n * ```typescript\n * await commet.subscriptions.cancel(\"sub_xxx\");\n * ```\n */\n async cancel(\n subscriptionId: string,\n options?: RequestOptions,\n ): Promise<ApiResponse<Subscription>> {\n return this.httpClient.post(\n `/subscriptions/${subscriptionId}/cancel`,\n {},\n options,\n );\n }\n}\n","import type {\n ApiResponse,\n CustomerID,\n EventID,\n GeneratedEventType,\n ListParams,\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 CreateUsageEventParams {\n eventType: GeneratedEventType;\n customerId?: CustomerID;\n externalId?: string;\n idempotencyKey?: string; // For idempotency\n timestamp?: string; // ISO string, defaults to now\n properties?: Array<{\n property: string;\n value: string;\n }>;\n}\n\nexport interface CreateBatchUsageEventsParams {\n events: CreateUsageEventParams[];\n}\n\nexport interface BatchResult<T> {\n successful: T[];\n failed: Array<{\n index: number;\n error: string;\n data: CreateUsageEventParams;\n }>;\n}\n\nexport interface ListUsageEventsParams extends ListParams {\n customerId?: CustomerID;\n externalId?: string;\n eventType?: GeneratedEventType;\n idempotencyKey?: string;\n}\n\n/**\n * Usage Events resource - Track business events for usage-based billing\n */\nexport class UsageResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async create(\n params: CreateUsageEventParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<UsageEvent>> {\n const eventData = {\n ...params,\n ts: params.timestamp || new Date().toISOString(),\n };\n\n return this.httpClient.post(\"/usage/events\", eventData, options);\n }\n\n async createBatch(\n params: CreateBatchUsageEventsParams,\n options?: RequestOptions,\n ): Promise<ApiResponse<BatchResult<UsageEvent>>> {\n return this.httpClient.post(\"/usage/events/batch\", params, options);\n }\n\n async retrieve(eventId: EventID): Promise<ApiResponse<UsageEvent>> {\n return this.httpClient.get(`/usage/events/${eventId}`);\n }\n\n async list(\n params?: ListUsageEventsParams,\n ): Promise<ApiResponse<UsageEvent[]>> {\n return this.httpClient.get(\"/usage/events\", params);\n }\n\n async delete(\n eventId: EventID,\n options?: RequestOptions,\n ): Promise<ApiResponse<{ deleted: boolean }>> {\n return this.httpClient.delete(\n `/usage/events/${eventId}`,\n undefined,\n options,\n );\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 */\nexport type GeneratedProductId = CommetGeneratedTypes extends {\n productId: 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 const responseClone = response.clone();\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 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 { 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 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.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 SDK\n */\nexport { Commet } from \"./client\";\n\n// Type exports\nexport type {\n CommetConfig,\n CommetGeneratedTypes,\n GeneratedEventType,\n GeneratedSeatType,\n GeneratedProductId,\n Environment,\n ApiResponse,\n PaginatedResponse,\n PaginatedList,\n Currency,\n CustomerID,\n AgreementID,\n InvoiceID,\n PhaseID,\n ItemID,\n ProductID,\n EventID,\n WebhookID,\n ListParams,\n RetrieveOptions,\n RequestOptions,\n} from \"./types/common\";\n\n// Error exports\nexport {\n CommetError,\n CommetAPIError,\n CommetValidationError,\n} from \"./types/common\";\n\n// Resource type exports\nexport type {\n Customer,\n CreateCustomerParams,\n UpdateCustomerParams,\n ListCustomersParams,\n} from \"./resources/customers\";\n\nexport type {\n UsageEvent,\n UsageEventProperty,\n CreateUsageEventParams,\n CreateBatchUsageEventsParams,\n BatchResult,\n ListUsageEventsParams,\n} from \"./resources/usage\";\n\nexport type {\n SeatBalance,\n SeatEvent,\n SeatBalanceResponse,\n BulkSeatUpdate,\n AddSeatsParams,\n RemoveSeatsParams,\n SetSeatsParams,\n BulkUpdateSeatsParams,\n GetBalanceParams,\n GetAllBalancesParams,\n ListSeatEventsParams,\n} from \"./resources/seats\";\n\nexport type {\n Subscription,\n SubscriptionItem,\n CreateSubscriptionParams,\n ListSubscriptionsParams,\n} from \"./resources/subscriptions\";\n\nexport type {\n PortalAccess,\n RequestAccessParams,\n} from \"./resources/portal\";\n\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":";AA2GO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAAoB,YAA8B;AAA9B;AAAA,EAA+B;AAAA,EAEnD,MAAM,OACJ,QACA,SACgC;AAChC,WAAO,KAAK,WAAW,KAAK,cAAc,QAAQ,OAAO;AAAA,EAC3D;AAAA,EAEA,MAAM,SACJ,YACA,SACgC;AAChC,UAAM,SAAS,SAAS,SACpB,EAAE,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B,WAAO,KAAK,gBAAgB;AAAA,EAC9B;AACF;;;AC9DO,SAAS,UAAU,aAAmC;AAC3D,SAAO,gBAAgB;AACzB;AAKO,SAAS,aAAa,aAAmC;AAC9D,SAAO,gBAAgB;AACzB;;;AC8EA,IAAO,gBAAQ;","names":["data"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commet/node",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",
@@ -28,12 +28,12 @@
28
28
  "author": "Commet Team",
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "zod": "^3.22.4"
31
+ "zod": "4.1.12"
32
32
  },
33
33
  "devDependencies": {
34
- "@types/node": "^20.10.0",
35
- "tsup": "^8.0.1",
36
- "typescript": "^5.3.3"
34
+ "@types/node": "24.10.1",
35
+ "tsup": "8.5.0",
36
+ "typescript": "5.9.3"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "typescript": ">=5.0.0"