commet 0.3.0 → 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 +658 -395
- package/package.json +23 -30
- package/dist/index.d.mts +0 -366
- package/dist/index.d.ts +0 -366
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -413
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
DELETED
|
@@ -1,413 +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/types/common.ts
|
|
132
|
-
var CommetError = class extends Error {
|
|
133
|
-
constructor(message, code, statusCode, details) {
|
|
134
|
-
super(message);
|
|
135
|
-
this.code = code;
|
|
136
|
-
this.statusCode = statusCode;
|
|
137
|
-
this.details = details;
|
|
138
|
-
this.name = "CommetError";
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var CommetAPIError = class extends CommetError {
|
|
142
|
-
constructor(message, statusCode, code, details) {
|
|
143
|
-
super(message, code, statusCode, details);
|
|
144
|
-
this.statusCode = statusCode;
|
|
145
|
-
this.code = code;
|
|
146
|
-
this.details = details;
|
|
147
|
-
this.name = "CommetAPIError";
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
var CommetValidationError = class extends CommetError {
|
|
151
|
-
constructor(message, validationErrors) {
|
|
152
|
-
super(message);
|
|
153
|
-
this.validationErrors = validationErrors;
|
|
154
|
-
this.name = "CommetValidationError";
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
// src/utils/http.ts
|
|
159
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
160
|
-
maxRetries: 3,
|
|
161
|
-
baseDelay: 1e3,
|
|
162
|
-
// 1s
|
|
163
|
-
maxDelay: 8e3,
|
|
164
|
-
// 8s
|
|
165
|
-
retryableStatusCodes: [408, 429, 500, 502, 503, 504]
|
|
166
|
-
};
|
|
167
|
-
var CommetHTTPClient = class {
|
|
168
|
-
constructor(config, environment) {
|
|
169
|
-
this.config = config;
|
|
170
|
-
this.environment = environment;
|
|
171
|
-
this.retryConfig = {
|
|
172
|
-
...DEFAULT_RETRY_CONFIG,
|
|
173
|
-
maxRetries: config.retries ?? DEFAULT_RETRY_CONFIG.maxRetries
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
async get(endpoint, params, options) {
|
|
177
|
-
return this.request("GET", endpoint, void 0, options, params);
|
|
178
|
-
}
|
|
179
|
-
async post(endpoint, data, options) {
|
|
180
|
-
return this.request("POST", endpoint, data, options);
|
|
181
|
-
}
|
|
182
|
-
async put(endpoint, data, options) {
|
|
183
|
-
return this.request("PUT", endpoint, data, options);
|
|
184
|
-
}
|
|
185
|
-
async delete(endpoint, options) {
|
|
186
|
-
return this.request("DELETE", endpoint, void 0, options);
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Core request method with retry logic
|
|
190
|
-
*/
|
|
191
|
-
async request(method, endpoint, data, options, params) {
|
|
192
|
-
const url = this.buildURL(endpoint, params);
|
|
193
|
-
return this.executeRequest(method, url, data, options);
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Execute real API request with retry logic
|
|
197
|
-
*/
|
|
198
|
-
async executeRequest(method, url, data, options, attempt = 1) {
|
|
199
|
-
try {
|
|
200
|
-
const headers = {
|
|
201
|
-
"x-api-key": this.config.apiKey,
|
|
202
|
-
"Content-Type": "application/json",
|
|
203
|
-
"User-Agent": "commet/0.1.0"
|
|
204
|
-
};
|
|
205
|
-
if (options?.idempotencyKey) {
|
|
206
|
-
headers["Idempotency-Key"] = options.idempotencyKey;
|
|
207
|
-
} else if (method === "POST" && data) {
|
|
208
|
-
headers["Idempotency-Key"] = this.generateIdempotencyKey();
|
|
209
|
-
}
|
|
210
|
-
const requestConfig = {
|
|
211
|
-
method,
|
|
212
|
-
headers,
|
|
213
|
-
signal: AbortSignal.timeout(
|
|
214
|
-
options?.timeout ?? this.config.timeout ?? 3e4
|
|
215
|
-
)
|
|
216
|
-
};
|
|
217
|
-
if (data) {
|
|
218
|
-
requestConfig.body = JSON.stringify(data);
|
|
219
|
-
}
|
|
220
|
-
if (this.config.debug) {
|
|
221
|
-
console.log(`[Commet SDK] ${method} ${url}`);
|
|
222
|
-
if (data) {
|
|
223
|
-
console.log("Request data:", JSON.stringify(data, null, 2));
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
const response = await fetch(url, requestConfig);
|
|
227
|
-
if (this.config.debug) {
|
|
228
|
-
console.log(
|
|
229
|
-
`[Commet SDK] Response status: ${response.status} ${response.statusText}`
|
|
230
|
-
);
|
|
231
|
-
}
|
|
232
|
-
let responseData;
|
|
233
|
-
let responseText;
|
|
234
|
-
try {
|
|
235
|
-
const responseClone = response.clone();
|
|
236
|
-
responseData = await response.json();
|
|
237
|
-
responseText = "";
|
|
238
|
-
} catch (jsonError) {
|
|
239
|
-
try {
|
|
240
|
-
responseText = await response.text();
|
|
241
|
-
} catch (textError) {
|
|
242
|
-
responseText = "Failed to read response body";
|
|
243
|
-
}
|
|
244
|
-
if (this.config.debug) {
|
|
245
|
-
console.log(
|
|
246
|
-
"[Commet SDK] Failed to parse JSON response:",
|
|
247
|
-
responseText
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
throw new CommetAPIError(
|
|
251
|
-
`Invalid JSON response: ${response.status} ${response.statusText}`,
|
|
252
|
-
response.status,
|
|
253
|
-
"INVALID_JSON",
|
|
254
|
-
{ responseText }
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
if (!response.ok) {
|
|
258
|
-
if (attempt <= this.retryConfig.maxRetries && this.retryConfig.retryableStatusCodes.includes(response.status)) {
|
|
259
|
-
const delay = Math.min(
|
|
260
|
-
this.retryConfig.baseDelay * 2 ** (attempt - 1),
|
|
261
|
-
this.retryConfig.maxDelay
|
|
262
|
-
);
|
|
263
|
-
if (this.config.debug) {
|
|
264
|
-
console.log(
|
|
265
|
-
`[Commet SDK] Retrying in ${delay}ms (attempt ${attempt}/${this.retryConfig.maxRetries})`
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
await this.sleep(delay);
|
|
269
|
-
return this.executeRequest(method, url, data, options, attempt + 1);
|
|
270
|
-
}
|
|
271
|
-
if (this.config.debug) {
|
|
272
|
-
console.log(
|
|
273
|
-
"[Commet SDK] Error response:",
|
|
274
|
-
JSON.stringify(responseData, null, 2)
|
|
275
|
-
);
|
|
276
|
-
}
|
|
277
|
-
const isErrorResponse = (data2) => {
|
|
278
|
-
return typeof data2 === "object" && data2 !== null;
|
|
279
|
-
};
|
|
280
|
-
const errorData = isErrorResponse(responseData) ? responseData : {};
|
|
281
|
-
if (response.status === 400 && errorData.errors) {
|
|
282
|
-
throw new CommetValidationError(
|
|
283
|
-
errorData.message || "Validation failed",
|
|
284
|
-
errorData.errors
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
throw new CommetAPIError(
|
|
288
|
-
errorData.message || `Request failed with status ${response.status}`,
|
|
289
|
-
response.status,
|
|
290
|
-
errorData.code,
|
|
291
|
-
errorData.details
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
if (this.config.debug) {
|
|
295
|
-
console.log("[Commet SDK] Response:", responseData);
|
|
296
|
-
}
|
|
297
|
-
return responseData;
|
|
298
|
-
} catch (error) {
|
|
299
|
-
if (error instanceof TypeError && error.message.includes("fetch")) {
|
|
300
|
-
if (attempt <= this.retryConfig.maxRetries) {
|
|
301
|
-
const delay = Math.min(
|
|
302
|
-
this.retryConfig.baseDelay * 2 ** (attempt - 1),
|
|
303
|
-
this.retryConfig.maxDelay
|
|
304
|
-
);
|
|
305
|
-
if (this.config.debug) {
|
|
306
|
-
console.log(`[Commet SDK] Network error, retrying in ${delay}ms`);
|
|
307
|
-
}
|
|
308
|
-
await this.sleep(delay);
|
|
309
|
-
return this.executeRequest(method, url, data, options, attempt + 1);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
throw error;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Get base URL based on environment
|
|
317
|
-
*/
|
|
318
|
-
getBaseURL() {
|
|
319
|
-
return this.environment === "production" ? "https://billing.commet.co" : "https://sandbox.commet.co";
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* Build full URL from endpoint and params
|
|
323
|
-
*/
|
|
324
|
-
buildURL(endpoint, params) {
|
|
325
|
-
const baseURL = this.getBaseURL();
|
|
326
|
-
const fullPath = `/api${endpoint.startsWith("/") ? endpoint : `/${endpoint}`}`;
|
|
327
|
-
if (this.config.debug) {
|
|
328
|
-
console.log(
|
|
329
|
-
`[Commet SDK] Building URL - baseURL: ${baseURL}, endpoint: ${endpoint}, fullPath: ${fullPath}`
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
const url = new URL(fullPath, baseURL);
|
|
333
|
-
if (params) {
|
|
334
|
-
for (const [key, value] of Object.entries(params)) {
|
|
335
|
-
if (value !== void 0 && value !== null) {
|
|
336
|
-
url.searchParams.append(key, String(value));
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
const finalUrl = url.toString();
|
|
341
|
-
if (this.config.debug) {
|
|
342
|
-
console.log(`[Commet SDK] Final URL: ${finalUrl}`);
|
|
343
|
-
}
|
|
344
|
-
return finalUrl;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Generate idempotency key
|
|
348
|
-
*/
|
|
349
|
-
generateIdempotencyKey() {
|
|
350
|
-
return `sdk_${Date.now()}_${Math.random().toString(36).substring(2)}`;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Sleep for specified milliseconds
|
|
354
|
-
*/
|
|
355
|
-
sleep(ms) {
|
|
356
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
// src/client.ts
|
|
361
|
-
var Commet = class {
|
|
362
|
-
constructor(config) {
|
|
363
|
-
if (!config.apiKey) {
|
|
364
|
-
throw new Error("Commet SDK: API key is required");
|
|
365
|
-
}
|
|
366
|
-
if (!config.apiKey.startsWith("ck_")) {
|
|
367
|
-
throw new Error(
|
|
368
|
-
"Commet SDK: Invalid API key format. Expected format: ck_xxx..."
|
|
369
|
-
);
|
|
370
|
-
}
|
|
371
|
-
this.environment = config.environment || "sandbox";
|
|
372
|
-
this.httpClient = new CommetHTTPClient(config, this.environment);
|
|
373
|
-
this.customers = new CustomersResource(this.httpClient);
|
|
374
|
-
this.usage = new UsageResource(this.httpClient);
|
|
375
|
-
this.seats = new SeatsResource(this.httpClient);
|
|
376
|
-
if (config.debug) {
|
|
377
|
-
console.log(`[Commet SDK] Initialized in ${this.environment} mode`);
|
|
378
|
-
console.log("API Key:", `${config.apiKey.substring(0, 12)}...`);
|
|
379
|
-
const baseURL = this.environment === "production" ? "https://billing.commet.co" : "https://sandbox.commet.co";
|
|
380
|
-
console.log("Base URL:", baseURL);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
getEnvironment() {
|
|
384
|
-
return this.environment;
|
|
385
|
-
}
|
|
386
|
-
isSandbox() {
|
|
387
|
-
return this.environment === "sandbox";
|
|
388
|
-
}
|
|
389
|
-
isProduction() {
|
|
390
|
-
return this.environment === "production";
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
// src/utils/environment.ts
|
|
395
|
-
function isSandbox(environment) {
|
|
396
|
-
return environment === "sandbox";
|
|
397
|
-
}
|
|
398
|
-
function isProduction(environment) {
|
|
399
|
-
return environment === "production";
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// src/index.ts
|
|
403
|
-
var index_default = Commet;
|
|
404
|
-
export {
|
|
405
|
-
Commet,
|
|
406
|
-
CommetAPIError,
|
|
407
|
-
CommetError,
|
|
408
|
-
CommetValidationError,
|
|
409
|
-
index_default as default,
|
|
410
|
-
isProduction,
|
|
411
|
-
isSandbox
|
|
412
|
-
};
|
|
413
|
-
//# 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/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 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","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}\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\";\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\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://billing.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 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 { 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 // 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\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://billing.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 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 { isSandbox, isProduction } from \"./utils/environment\";\n\n// Default export\nimport { Commet } from \"./client\";\nexport default Commet;\n"],"mappings":";AA2GO,IA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