commet 0.2.1 → 0.4.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 +216 -20
- package/bin/commet +2 -0
- package/dist/index.js +650 -430
- package/package.json +23 -30
- package/dist/index.d.mts +0 -365
- package/dist/index.d.ts +0 -365
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -455
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
DELETED
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
// src/resources/customers.ts
|
|
2
|
-
var CustomersResource = class {
|
|
3
|
-
constructor(httpClient) {
|
|
4
|
-
this.httpClient = httpClient;
|
|
5
|
-
}
|
|
6
|
-
async create(params, options) {
|
|
7
|
-
return this.httpClient.post("/customers", params, options);
|
|
8
|
-
}
|
|
9
|
-
async retrieve(customerId, options) {
|
|
10
|
-
const params = options?.expand ? { expand: options.expand.join(",") } : void 0;
|
|
11
|
-
return this.httpClient.get(`/customers/${customerId}`, params);
|
|
12
|
-
}
|
|
13
|
-
async update(customerId, params, options) {
|
|
14
|
-
return this.httpClient.put(`/customers/${customerId}`, params, options);
|
|
15
|
-
}
|
|
16
|
-
async list(params) {
|
|
17
|
-
return this.httpClient.get("/customers", params);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Deactivate a customer (soft delete)
|
|
21
|
-
*/
|
|
22
|
-
async deactivate(customerId, options) {
|
|
23
|
-
return this.httpClient.put(
|
|
24
|
-
`/customers/${customerId}`,
|
|
25
|
-
{ isActive: false },
|
|
26
|
-
options
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// src/resources/seats.ts
|
|
32
|
-
var SeatsResource = class {
|
|
33
|
-
constructor(httpClient) {
|
|
34
|
-
this.httpClient = httpClient;
|
|
35
|
-
}
|
|
36
|
-
async add(customerId, seatType, count, options) {
|
|
37
|
-
return this.httpClient.post(
|
|
38
|
-
`/customers/${customerId}/seats/${seatType}/add`,
|
|
39
|
-
{ count },
|
|
40
|
-
options
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
async remove(customerId, seatType, count, options) {
|
|
44
|
-
return this.httpClient.post(
|
|
45
|
-
`/customers/${customerId}/seats/${seatType}/remove`,
|
|
46
|
-
{ count },
|
|
47
|
-
options
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
async set(customerId, seatType, count, options) {
|
|
51
|
-
return this.httpClient.post(
|
|
52
|
-
`/customers/${customerId}/seats/${seatType}/set`,
|
|
53
|
-
{ count },
|
|
54
|
-
options
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
async bulkUpdate(customerId, seats, options) {
|
|
58
|
-
return this.httpClient.post(
|
|
59
|
-
`/customers/${customerId}/seats/bulk-update`,
|
|
60
|
-
{ seats },
|
|
61
|
-
options
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
async getBalance(customerId, seatType) {
|
|
65
|
-
return this.httpClient.get(
|
|
66
|
-
`/customers/${customerId}/seats/${seatType}/balance`
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
async getAllBalances(customerId) {
|
|
70
|
-
return this.httpClient.get(`/customers/${customerId}/seats/balances`);
|
|
71
|
-
}
|
|
72
|
-
async getHistory(customerId, seatType, params) {
|
|
73
|
-
const queryParams = {
|
|
74
|
-
...params,
|
|
75
|
-
customerId,
|
|
76
|
-
seatType
|
|
77
|
-
};
|
|
78
|
-
return this.httpClient.get(
|
|
79
|
-
`/customers/${customerId}/seats/history`,
|
|
80
|
-
queryParams
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
async listEvents(params) {
|
|
84
|
-
return this.httpClient.get("/seats/events", params);
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// src/resources/usage.ts
|
|
89
|
-
var UsageEventsResource = class {
|
|
90
|
-
constructor(httpClient) {
|
|
91
|
-
this.httpClient = httpClient;
|
|
92
|
-
}
|
|
93
|
-
async create(params, options) {
|
|
94
|
-
const eventData = {
|
|
95
|
-
...params,
|
|
96
|
-
ts: params.timestamp || (/* @__PURE__ */ new Date()).toISOString()
|
|
97
|
-
};
|
|
98
|
-
return this.httpClient.post("/usage/events", eventData, options);
|
|
99
|
-
}
|
|
100
|
-
async createBatch(params, options) {
|
|
101
|
-
return this.httpClient.post("/usage/events/batch", params, options);
|
|
102
|
-
}
|
|
103
|
-
async retrieve(eventId) {
|
|
104
|
-
return this.httpClient.get(`/usage/events/${eventId}`);
|
|
105
|
-
}
|
|
106
|
-
async list(params) {
|
|
107
|
-
return this.httpClient.get("/usage/events", params);
|
|
108
|
-
}
|
|
109
|
-
async delete(eventId, options) {
|
|
110
|
-
return this.httpClient.delete(`/usage/events/${eventId}`, options);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var UsageMetricsResource = class {
|
|
114
|
-
constructor(httpClient) {
|
|
115
|
-
this.httpClient = httpClient;
|
|
116
|
-
}
|
|
117
|
-
async list() {
|
|
118
|
-
return this.httpClient.get("/usage/metrics");
|
|
119
|
-
}
|
|
120
|
-
async retrieve(metricId) {
|
|
121
|
-
return this.httpClient.get(`/usage/metrics/${metricId}`);
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
var UsageResource = class {
|
|
125
|
-
constructor(httpClient) {
|
|
126
|
-
this.events = new UsageEventsResource(httpClient);
|
|
127
|
-
this.metrics = new UsageMetricsResource(httpClient);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// src/utils/environment.ts
|
|
132
|
-
function detectEnvironment() {
|
|
133
|
-
try {
|
|
134
|
-
if (typeof process !== "undefined" && process.env?.NODE_ENV) {
|
|
135
|
-
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
|
|
136
|
-
return "development";
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (typeof window !== "undefined" && window.location) {
|
|
140
|
-
const hostname = window.location.hostname;
|
|
141
|
-
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname.startsWith("192.168.") || hostname.startsWith("10.") || hostname.endsWith(".local")) {
|
|
142
|
-
return "development";
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (error) {
|
|
146
|
-
}
|
|
147
|
-
return "production";
|
|
148
|
-
}
|
|
149
|
-
function isDevelopment(environment) {
|
|
150
|
-
return environment === "development";
|
|
151
|
-
}
|
|
152
|
-
function isProduction(environment) {
|
|
153
|
-
return environment === "production";
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// src/types/common.ts
|
|
157
|
-
var CommetError = class extends Error {
|
|
158
|
-
constructor(message, code, statusCode, details) {
|
|
159
|
-
super(message);
|
|
160
|
-
this.code = code;
|
|
161
|
-
this.statusCode = statusCode;
|
|
162
|
-
this.details = details;
|
|
163
|
-
this.name = "CommetError";
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
var CommetAPIError = class extends CommetError {
|
|
167
|
-
constructor(message, statusCode, code, details) {
|
|
168
|
-
super(message, code, statusCode, details);
|
|
169
|
-
this.statusCode = statusCode;
|
|
170
|
-
this.code = code;
|
|
171
|
-
this.details = details;
|
|
172
|
-
this.name = "CommetAPIError";
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
var CommetValidationError = class extends CommetError {
|
|
176
|
-
constructor(message, validationErrors) {
|
|
177
|
-
super(message);
|
|
178
|
-
this.validationErrors = validationErrors;
|
|
179
|
-
this.name = "CommetValidationError";
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
// src/utils/http.ts
|
|
184
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
185
|
-
maxRetries: 3,
|
|
186
|
-
baseDelay: 1e3,
|
|
187
|
-
// 1s
|
|
188
|
-
maxDelay: 8e3,
|
|
189
|
-
// 8s
|
|
190
|
-
retryableStatusCodes: [408, 429, 500, 502, 503, 504]
|
|
191
|
-
};
|
|
192
|
-
var CommetHTTPClient = class {
|
|
193
|
-
constructor(config, environment) {
|
|
194
|
-
this.config = config;
|
|
195
|
-
this.environment = environment;
|
|
196
|
-
this.retryConfig = {
|
|
197
|
-
...DEFAULT_RETRY_CONFIG,
|
|
198
|
-
maxRetries: config.retries ?? DEFAULT_RETRY_CONFIG.maxRetries
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
async get(endpoint, params, options) {
|
|
202
|
-
return this.request("GET", endpoint, void 0, options, params);
|
|
203
|
-
}
|
|
204
|
-
async post(endpoint, data, options) {
|
|
205
|
-
return this.request("POST", endpoint, data, options);
|
|
206
|
-
}
|
|
207
|
-
async put(endpoint, data, options) {
|
|
208
|
-
return this.request("PUT", endpoint, data, options);
|
|
209
|
-
}
|
|
210
|
-
async delete(endpoint, options) {
|
|
211
|
-
return this.request("DELETE", endpoint, void 0, options);
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Core request method with retry logic and dev mode support
|
|
215
|
-
*/
|
|
216
|
-
async request(method, endpoint, data, options, params) {
|
|
217
|
-
const url = this.buildURL(endpoint, params);
|
|
218
|
-
if (isDevelopment(this.environment)) {
|
|
219
|
-
return this.logDevRequest(method, url, data);
|
|
220
|
-
}
|
|
221
|
-
return this.executeRequest(method, url, data, options);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Log request in development mode instead of sending to API
|
|
225
|
-
*/
|
|
226
|
-
logDevRequest(method, url, data) {
|
|
227
|
-
console.log("[Commet SDK] Dev mode");
|
|
228
|
-
console.log(`Method: ${method}`);
|
|
229
|
-
console.log(`Endpoint: ${url}`);
|
|
230
|
-
if (data) {
|
|
231
|
-
console.log("Data:", JSON.stringify(data, null, 2));
|
|
232
|
-
}
|
|
233
|
-
console.log("Request logged, not sent to server");
|
|
234
|
-
if (this.config.debug) {
|
|
235
|
-
console.log("Base URL:", "https://api.commet.co/api");
|
|
236
|
-
console.log("Debug mode enabled");
|
|
237
|
-
}
|
|
238
|
-
return Promise.resolve({
|
|
239
|
-
success: true,
|
|
240
|
-
devMode: true,
|
|
241
|
-
data: { id: `dev_${Date.now()}` }
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* Execute real API request with retry logic
|
|
246
|
-
*/
|
|
247
|
-
async executeRequest(method, url, data, options, attempt = 1) {
|
|
248
|
-
try {
|
|
249
|
-
const headers = {
|
|
250
|
-
"x-api-key": this.config.apiKey,
|
|
251
|
-
"Content-Type": "application/json",
|
|
252
|
-
"User-Agent": "commet/0.1.0"
|
|
253
|
-
};
|
|
254
|
-
if (options?.idempotencyKey) {
|
|
255
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
256
|
-
} else if (method === "POST" && data) {
|
|
257
|
-
headers["Idempotency-Key"] = this.generateIdempotencyKey();
|
|
258
|
-
}
|
|
259
|
-
const requestConfig = {
|
|
260
|
-
method,
|
|
261
|
-
headers,
|
|
262
|
-
signal: AbortSignal.timeout(
|
|
263
|
-
options?.timeout ?? this.config.timeout ?? 3e4
|
|
264
|
-
)
|
|
265
|
-
};
|
|
266
|
-
if (data) {
|
|
267
|
-
requestConfig.body = JSON.stringify(data);
|
|
268
|
-
}
|
|
269
|
-
if (this.config.debug) {
|
|
270
|
-
console.log(`[Commet SDK] ${method} ${url}`);
|
|
271
|
-
if (data) {
|
|
272
|
-
console.log("Request data:", JSON.stringify(data, null, 2));
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
const response = await fetch(url, requestConfig);
|
|
276
|
-
if (this.config.debug) {
|
|
277
|
-
console.log(
|
|
278
|
-
`[Commet SDK] Response status: ${response.status} ${response.statusText}`
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
let responseData;
|
|
282
|
-
let responseText;
|
|
283
|
-
try {
|
|
284
|
-
const responseClone = response.clone();
|
|
285
|
-
responseData = await response.json();
|
|
286
|
-
responseText = "";
|
|
287
|
-
} catch (jsonError) {
|
|
288
|
-
try {
|
|
289
|
-
responseText = await response.text();
|
|
290
|
-
} catch (textError) {
|
|
291
|
-
responseText = "Failed to read response body";
|
|
292
|
-
}
|
|
293
|
-
if (this.config.debug) {
|
|
294
|
-
console.log(
|
|
295
|
-
"[Commet SDK] Failed to parse JSON response:",
|
|
296
|
-
responseText
|
|
297
|
-
);
|
|
298
|
-
}
|
|
299
|
-
throw new CommetAPIError(
|
|
300
|
-
`Invalid JSON response: ${response.status} ${response.statusText}`,
|
|
301
|
-
response.status,
|
|
302
|
-
"INVALID_JSON",
|
|
303
|
-
{ responseText }
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
if (!response.ok) {
|
|
307
|
-
if (attempt <= this.retryConfig.maxRetries && this.retryConfig.retryableStatusCodes.includes(response.status)) {
|
|
308
|
-
const delay = Math.min(
|
|
309
|
-
this.retryConfig.baseDelay * 2 ** (attempt - 1),
|
|
310
|
-
this.retryConfig.maxDelay
|
|
311
|
-
);
|
|
312
|
-
if (this.config.debug) {
|
|
313
|
-
console.log(
|
|
314
|
-
`[Commet SDK] Retrying in ${delay}ms (attempt ${attempt}/${this.retryConfig.maxRetries})`
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
await this.sleep(delay);
|
|
318
|
-
return this.executeRequest(method, url, data, options, attempt + 1);
|
|
319
|
-
}
|
|
320
|
-
if (this.config.debug) {
|
|
321
|
-
console.log(
|
|
322
|
-
"[Commet SDK] Error response:",
|
|
323
|
-
JSON.stringify(responseData, null, 2)
|
|
324
|
-
);
|
|
325
|
-
}
|
|
326
|
-
const isErrorResponse = (data2) => {
|
|
327
|
-
return typeof data2 === "object" && data2 !== null;
|
|
328
|
-
};
|
|
329
|
-
const errorData = isErrorResponse(responseData) ? responseData : {};
|
|
330
|
-
if (response.status === 400 && errorData.errors) {
|
|
331
|
-
throw new CommetValidationError(
|
|
332
|
-
errorData.message || "Validation failed",
|
|
333
|
-
errorData.errors
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
throw new CommetAPIError(
|
|
337
|
-
errorData.message || `Request failed with status ${response.status}`,
|
|
338
|
-
response.status,
|
|
339
|
-
errorData.code,
|
|
340
|
-
errorData.details
|
|
341
|
-
);
|
|
342
|
-
}
|
|
343
|
-
if (this.config.debug) {
|
|
344
|
-
console.log("[Commet SDK] Response:", responseData);
|
|
345
|
-
}
|
|
346
|
-
return responseData;
|
|
347
|
-
} catch (error) {
|
|
348
|
-
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
349
|
-
if (attempt <= this.retryConfig.maxRetries) {
|
|
350
|
-
const delay = Math.min(
|
|
351
|
-
this.retryConfig.baseDelay * 2 ** (attempt - 1),
|
|
352
|
-
this.retryConfig.maxDelay
|
|
353
|
-
);
|
|
354
|
-
if (this.config.debug) {
|
|
355
|
-
console.log(`[Commet SDK] Network error, retrying in ${delay}ms`);
|
|
356
|
-
}
|
|
357
|
-
await this.sleep(delay);
|
|
358
|
-
return this.executeRequest(method, url, data, options, attempt + 1);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
throw error;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
/**
|
|
365
|
-
* Build full URL from endpoint and params
|
|
366
|
-
*/
|
|
367
|
-
buildURL(endpoint, params) {
|
|
368
|
-
const baseURL = "https://api.commet.co";
|
|
369
|
-
const fullPath = `/api${endpoint.startsWith("/") ? endpoint : `/${endpoint}`}`;
|
|
370
|
-
if (this.config.debug) {
|
|
371
|
-
console.log(
|
|
372
|
-
`[Commet SDK] Building URL - baseURL: ${baseURL}, endpoint: ${endpoint}, fullPath: ${fullPath}`
|
|
373
|
-
);
|
|
374
|
-
}
|
|
375
|
-
const url = new URL(fullPath, baseURL);
|
|
376
|
-
if (params) {
|
|
377
|
-
for (const [key, value] of Object.entries(params)) {
|
|
378
|
-
if (value !== void 0 && value !== null) {
|
|
379
|
-
url.searchParams.append(key, String(value));
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
const finalUrl = url.toString();
|
|
384
|
-
if (this.config.debug) {
|
|
385
|
-
console.log(`[Commet SDK] Final URL: ${finalUrl}`);
|
|
386
|
-
}
|
|
387
|
-
return finalUrl;
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Generate idempotency key
|
|
391
|
-
*/
|
|
392
|
-
generateIdempotencyKey() {
|
|
393
|
-
return `sdk_${Date.now()}_${Math.random().toString(36).substring(2)}`;
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Sleep for specified milliseconds
|
|
397
|
-
*/
|
|
398
|
-
sleep(ms) {
|
|
399
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
|
|
403
|
-
// src/client.ts
|
|
404
|
-
var Commet = class {
|
|
405
|
-
constructor(config) {
|
|
406
|
-
if (!config.apiKey) {
|
|
407
|
-
throw new Error("Commet SDK: API key is required");
|
|
408
|
-
}
|
|
409
|
-
if (!config.apiKey.startsWith("ck_")) {
|
|
410
|
-
throw new Error(
|
|
411
|
-
"Commet SDK: Invalid API key format. Expected format: ck_xxx..."
|
|
412
|
-
);
|
|
413
|
-
}
|
|
414
|
-
this.environment = config.environment === "auto" ? detectEnvironment() : config.environment || detectEnvironment();
|
|
415
|
-
this.httpClient = new CommetHTTPClient(config, this.environment);
|
|
416
|
-
this.customers = new CustomersResource(this.httpClient);
|
|
417
|
-
this.usage = new UsageResource(this.httpClient);
|
|
418
|
-
this.seats = new SeatsResource(this.httpClient);
|
|
419
|
-
if (this.environment === "development" || config.debug) {
|
|
420
|
-
console.log(`[Commet SDK] Initialized in ${this.environment} mode`);
|
|
421
|
-
if (config.debug) {
|
|
422
|
-
console.log("API Key:", `${config.apiKey.substring(0, 12)}...`);
|
|
423
|
-
console.log("Base URL:", "https://api.commet.co");
|
|
424
|
-
if (this.environment === "development") {
|
|
425
|
-
console.log(
|
|
426
|
-
"Dev mode: Events will be logged to console, not sent to server"
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
getEnvironment() {
|
|
433
|
-
return this.environment;
|
|
434
|
-
}
|
|
435
|
-
isDevelopment() {
|
|
436
|
-
return this.environment === "development";
|
|
437
|
-
}
|
|
438
|
-
isProduction() {
|
|
439
|
-
return this.environment === "production";
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
|
-
|
|
443
|
-
// src/index.ts
|
|
444
|
-
var index_default = Commet;
|
|
445
|
-
export {
|
|
446
|
-
Commet,
|
|
447
|
-
CommetAPIError,
|
|
448
|
-
CommetError,
|
|
449
|
-
CommetValidationError,
|
|
450
|
-
index_default as default,
|
|
451
|
-
detectEnvironment,
|
|
452
|
-
isDevelopment,
|
|
453
|
-
isProduction
|
|
454
|
-
};
|
|
455
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/resources/customers.ts","../src/resources/seats.ts","../src/resources/usage.ts","../src/utils/environment.ts","../src/types/common.ts","../src/utils/http.ts","../src/client.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 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: string;\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: string;\n eventType: \"add\" | \"remove\" | \"set\";\n quantity: number;\n previousBalance?: number;\n newBalance: number;\n ts: string;\n createdAt: string;\n}\n\nexport interface SeatBalanceResponse {\n current: number;\n asOf: string;\n}\n\nexport interface BulkSeatUpdate {\n [seatType: string]: number;\n}\n\nexport interface ListSeatEventsParams extends ListParams {\n customerId?: CustomerID;\n seatType?: string;\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 customerId: CustomerID,\n seatType: string,\n count: number,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n `/customers/${customerId}/seats/${seatType}/add`,\n { count },\n options,\n );\n }\n\n async remove(\n customerId: CustomerID,\n seatType: string,\n count: number,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n `/customers/${customerId}/seats/${seatType}/remove`,\n { count },\n options,\n );\n }\n\n async set(\n customerId: CustomerID,\n seatType: string,\n count: number,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent>> {\n return this.httpClient.post(\n `/customers/${customerId}/seats/${seatType}/set`,\n { count },\n options,\n );\n }\n\n async bulkUpdate(\n customerId: CustomerID,\n seats: BulkSeatUpdate,\n options?: RequestOptions,\n ): Promise<ApiResponse<SeatEvent[]>> {\n return this.httpClient.post(\n `/customers/${customerId}/seats/bulk-update`,\n { seats },\n options,\n );\n }\n\n async getBalance(\n customerId: CustomerID,\n seatType: string,\n ): Promise<ApiResponse<SeatBalanceResponse>> {\n return this.httpClient.get(\n `/customers/${customerId}/seats/${seatType}/balance`,\n );\n }\n\n async getAllBalances(\n customerId: CustomerID,\n ): Promise<ApiResponse<Record<string, SeatBalanceResponse>>> {\n return this.httpClient.get(`/customers/${customerId}/seats/balances`);\n }\n\n async getHistory(\n customerId: CustomerID,\n seatType: string,\n params?: ListSeatEventsParams,\n ): Promise<ApiResponse<SeatEvent[]>> {\n const queryParams = {\n ...params,\n customerId,\n seatType,\n };\n return this.httpClient.get(\n `/customers/${customerId}/seats/history`,\n queryParams,\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 CustomerID,\n EventID,\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: string;\n idempotencyKey?: string;\n ts: string;\n properties?: UsageEventProperty[];\n createdAt: string;\n}\n\nexport interface UsageEventProperty {\n id: string;\n usageEventId: EventID;\n property: string;\n value: string;\n createdAt: string;\n}\n\nexport interface CreateUsageEventParams {\n eventType: string;\n customerId: CustomerID;\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 eventType?: string;\n idempotencyKey?: string;\n}\n\n/**\n * Usage Events resource - Track business events for usage-based billing\n */\nexport class UsageEventsResource {\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(`/usage/events/${eventId}`, options);\n }\n}\n\nexport interface UsageMetric {\n id: string;\n organizationId: string;\n name: string;\n eventType: string;\n aggregation: \"count\" | \"unique\" | \"sum\";\n property?: string;\n filters?: UsageMetricFilter[];\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface UsageMetricFilter {\n id: string;\n usageMetricId: string;\n property: string;\n operator: \"equals\" | \"not_equals\" | \"greater_than\" | \"less_than\" | \"contains\";\n value: string;\n createdAt: string;\n}\n\n/**\n * Usage Metrics resource - Read-only access to metrics\n */\nexport class UsageMetricsResource {\n constructor(private httpClient: CommetHTTPClient) {}\n\n async list(): Promise<ApiResponse<UsageMetric[]>> {\n return this.httpClient.get(\"/usage/metrics\");\n }\n\n async retrieve(metricId: string): Promise<ApiResponse<UsageMetric>> {\n return this.httpClient.get(`/usage/metrics/${metricId}`);\n }\n}\n\n/**\n * Usage resource combining events and metrics\n */\nexport class UsageResource {\n public readonly events: UsageEventsResource;\n public readonly metrics: UsageMetricsResource;\n\n constructor(httpClient: CommetHTTPClient) {\n this.events = new UsageEventsResource(httpClient);\n this.metrics = new UsageMetricsResource(httpClient);\n }\n}\n","import type { Environment } from \"../types/common\";\n\n/**\n * Detect the current environment based on NODE_ENV and hostname\n */\nexport function detectEnvironment(): Environment {\n try {\n if (typeof process !== \"undefined\" && process.env?.NODE_ENV) {\n if (\n process.env.NODE_ENV === \"development\" ||\n process.env.NODE_ENV === \"test\"\n ) {\n return \"development\";\n }\n }\n\n if (typeof window !== \"undefined\" && window.location) {\n const hostname = window.location.hostname;\n if (\n hostname === \"localhost\" ||\n hostname === \"127.0.0.1\" ||\n hostname.startsWith(\"192.168.\") ||\n hostname.startsWith(\"10.\") ||\n hostname.endsWith(\".local\")\n ) {\n return \"development\";\n }\n }\n } catch (error) {\n // Ignore errors in environment detection\n }\n\n return \"production\";\n}\n\nexport function isDevelopment(environment: Environment): boolean {\n return environment === \"development\";\n}\n\nexport function isProduction(environment: Environment): boolean {\n return environment === \"production\";\n}\n","export type Environment = \"development\" | \"production\";\n\nexport type CommetConfig = {\n apiKey: string;\n environment?: \"auto\" | 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 devMode?: boolean;\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","import type {\n ApiResponse,\n CommetConfig,\n Environment,\n RequestOptions,\n} from \"../types/common\";\nimport { CommetAPIError, CommetValidationError } from \"../types/common\";\nimport { isDevelopment } from \"./environment\";\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 options?: RequestOptions,\n ): Promise<ApiResponse<T>> {\n return this.request(\"DELETE\", endpoint, undefined, options);\n }\n\n /**\n * Core request method with retry logic and dev mode support\n */\n private async request<T = unknown>(\n method: string,\n endpoint: string,\n data?: unknown,\n options?: RequestOptions,\n params?: Record<string, unknown>,\n ): Promise<ApiResponse<T>> {\n const url = this.buildURL(endpoint, params);\n\n if (isDevelopment(this.environment)) {\n return this.logDevRequest(method, url, data);\n }\n\n return this.executeRequest(method, url, data, options);\n }\n\n /**\n * Log request in development mode instead of sending to API\n */\n private logDevRequest<T = unknown>(\n method: string,\n url: string,\n data?: unknown,\n ): Promise<ApiResponse<T>> {\n console.log(\"[Commet SDK] Dev mode\");\n console.log(`Method: ${method}`);\n console.log(`Endpoint: ${url}`);\n\n if (data) {\n console.log(\"Data:\", JSON.stringify(data, null, 2));\n }\n\n console.log(\"Request logged, not sent to server\");\n\n if (this.config.debug) {\n console.log(\"Base URL:\", \"https://api.commet.co/api\");\n console.log(\"Debug mode enabled\");\n }\n return Promise.resolve({\n success: true,\n devMode: true,\n data: { id: `dev_${Date.now()}` } as T,\n });\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 * Build full URL from endpoint and params\n */\n private buildURL(endpoint: string, params?: Record<string, unknown>): string {\n const baseURL = \"https://api.commet.co\";\n\n // Construct full path with /api prefix\n const fullPath = `/api${endpoint.startsWith(\"/\") ? endpoint : `/${endpoint}`}`;\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 { UsageResource } from \"./resources/usage\";\nimport type { CommetConfig, Environment } from \"./types/common\";\nimport { detectEnvironment } from \"./utils/environment\";\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\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 this.environment =\n config.environment === \"auto\"\n ? detectEnvironment()\n : config.environment || detectEnvironment();\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\n if (this.environment === \"development\" || config.debug) {\n console.log(`[Commet SDK] Initialized in ${this.environment} mode`);\n\n if (config.debug) {\n console.log(\"API Key:\", `${config.apiKey.substring(0, 12)}...`);\n console.log(\"Base URL:\", \"https://api.commet.co\");\n\n if (this.environment === \"development\") {\n console.log(\n \"Dev mode: Events will be logged to console, not sent to server\",\n );\n }\n }\n }\n }\n\n getEnvironment(): Environment {\n return this.environment;\n }\n\n isDevelopment(): boolean {\n return this.environment === \"development\";\n }\n\n isProduction(): boolean {\n return this.environment === \"production\";\n }\n}\n","/**\n * Commet SDK - Billing and usage tracking SDK\n */\nexport { Commet } from \"./client\";\n\n// Type exports\nexport type {\n CommetConfig,\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 UsageMetric,\n UsageMetricFilter,\n} from \"./resources/usage\";\n\nexport type {\n SeatBalance,\n SeatEvent,\n SeatBalanceResponse,\n BulkSeatUpdate,\n ListSeatEventsParams,\n} from \"./resources/seats\";\n\n// Utility exports\nexport {\n detectEnvironment,\n isDevelopment,\n isProduction,\n} 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,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