commet 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,62 +1,55 @@
1
1
  {
2
2
  "name": "commet",
3
- "version": "0.3.0",
4
- "description": "Commet SDK for Node.js",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
3
+ "version": "0.4.1",
4
+ "description": "Commet CLI - Manage your billing platform from the command line",
5
+ "bin": {
6
+ "commet": "./bin/commet"
14
7
  },
15
8
  "files": [
16
9
  "dist",
10
+ "bin",
17
11
  "README.md"
18
12
  ],
19
13
  "keywords": [
20
14
  "billing",
21
- "sdk",
15
+ "cli",
22
16
  "typescript",
23
- "payments",
24
- "invoicing",
25
- "usage-based-billing",
26
- "seat-licensing"
17
+ "commet"
27
18
  ],
28
19
  "author": "Commet Team",
29
20
  "license": "MIT",
21
+ "dependencies": {
22
+ "chalk": "^5.3.0",
23
+ "commander": "^12.0.0",
24
+ "inquirer": "^9.2.0",
25
+ "open": "^10.0.0",
26
+ "ora": "^7.0.1",
27
+ "@commet/node": "0.4.0"
28
+ },
30
29
  "devDependencies": {
30
+ "@biomejs/biome": "^1.9.4",
31
+ "@types/inquirer": "^9.0.9",
31
32
  "@types/node": "^20.10.0",
32
33
  "tsup": "^8.0.1",
33
- "typescript": "^5.3.3",
34
- "vitest": "^1.0.4",
35
- "@vitest/coverage-v8": "^1.0.4"
36
- },
37
- "dependencies": {
38
- "zod": "^3.22.4"
39
- },
40
- "peerDependencies": {
41
- "typescript": ">=5.0.0"
34
+ "typescript": "^5.3.3"
42
35
  },
43
36
  "engines": {
44
37
  "node": ">=18.0.0"
45
38
  },
46
39
  "repository": {
47
40
  "type": "git",
48
- "url": "https://github.com/commet-labs/commet-node.git"
41
+ "url": "https://github.com/commet-labs/commet.git",
42
+ "directory": "packages/cli"
49
43
  },
50
- "bugs": {
51
- "url": "https://github.com/commet-labs/commet-node/issues"
44
+ "publishConfig": {
45
+ "access": "public",
46
+ "provenance": true
52
47
  },
53
- "homepage": "https://docs.commet.co/docs/sdk",
54
48
  "scripts": {
55
49
  "build": "tsup",
56
50
  "dev": "tsup --watch",
57
51
  "lint": "biome lint src/",
58
52
  "lint:fix": "biome lint --apply src/",
59
- "clean": "rm -rf .turbo node_modules .next",
60
53
  "typecheck": "tsc --noEmit"
61
54
  }
62
55
  }
package/dist/index.d.mts DELETED
@@ -1,366 +0,0 @@
1
- type Environment = "sandbox" | "production";
2
- type CommetConfig = {
3
- apiKey: string;
4
- environment?: Environment;
5
- debug?: boolean;
6
- timeout?: number;
7
- retries?: number;
8
- };
9
- interface ApiResponse<T = unknown> {
10
- success: boolean;
11
- data?: T;
12
- error?: string;
13
- message?: string;
14
- }
15
- interface PaginatedResponse<T> {
16
- data: T[];
17
- hasMore: boolean;
18
- nextCursor?: string;
19
- totalCount?: number;
20
- }
21
- interface PaginatedList<T> extends PaginatedResponse<T> {
22
- next(): Promise<PaginatedList<T>>;
23
- all(): Promise<T[]>;
24
- }
25
- declare class CommetError extends Error {
26
- code?: string | undefined;
27
- statusCode?: number | undefined;
28
- details?: unknown | undefined;
29
- constructor(message: string, code?: string | undefined, statusCode?: number | undefined, details?: unknown | undefined);
30
- }
31
- declare class CommetAPIError extends CommetError {
32
- statusCode: number;
33
- code?: string | undefined;
34
- details?: unknown | undefined;
35
- constructor(message: string, statusCode: number, code?: string | undefined, details?: unknown | undefined);
36
- }
37
- declare class CommetValidationError extends CommetError {
38
- validationErrors: Record<string, string[]>;
39
- constructor(message: string, validationErrors: Record<string, string[]>);
40
- }
41
- type CustomerID = `cus_${string}`;
42
- type AgreementID = `agr_${string}`;
43
- type InvoiceID = `inv_${string}`;
44
- type PhaseID = `phs_${string}`;
45
- type ItemID = `itm_${string}`;
46
- type ProductID = `prd_${string}`;
47
- type EventID = `evt_${string}`;
48
- type WebhookID = `wh_${string}`;
49
- type Currency = "USD" | "EUR" | "GBP" | "CAD" | "AUD" | "JPY" | "ARS" | "BRL" | "MXN" | "CLP";
50
- interface ListParams extends Record<string, unknown> {
51
- limit?: number;
52
- cursor?: string;
53
- startDate?: string;
54
- endDate?: string;
55
- }
56
- interface RetrieveOptions {
57
- expand?: string[];
58
- }
59
- interface RequestOptions {
60
- idempotencyKey?: string;
61
- timeout?: number;
62
- }
63
-
64
- declare class CommetHTTPClient {
65
- private config;
66
- private environment;
67
- private retryConfig;
68
- constructor(config: CommetConfig, environment: Environment);
69
- get<T = unknown>(endpoint: string, params?: Record<string, unknown>, options?: RequestOptions): Promise<ApiResponse<T>>;
70
- post<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
71
- put<T = unknown>(endpoint: string, data?: unknown, options?: RequestOptions): Promise<ApiResponse<T>>;
72
- delete<T = unknown>(endpoint: string, options?: RequestOptions): Promise<ApiResponse<T>>;
73
- /**
74
- * Core request method with retry logic
75
- */
76
- private request;
77
- /**
78
- * Execute real API request with retry logic
79
- */
80
- private executeRequest;
81
- /**
82
- * Get base URL based on environment
83
- */
84
- private getBaseURL;
85
- /**
86
- * Build full URL from endpoint and params
87
- */
88
- private buildURL;
89
- /**
90
- * Generate idempotency key
91
- */
92
- private generateIdempotencyKey;
93
- /**
94
- * Sleep for specified milliseconds
95
- */
96
- private sleep;
97
- }
98
-
99
- interface Customer {
100
- id: CustomerID;
101
- organizationId: string;
102
- externalId?: string;
103
- legalName: string;
104
- displayName?: string;
105
- domain?: string;
106
- website?: string;
107
- taxStatus: "TAXED" | "TAX_EXEMPT" | "REVERSE_CHARGE" | "NOT_APPLICABLE";
108
- currency: Currency;
109
- addressId: string;
110
- billingEmail?: string;
111
- paymentTerms?: string;
112
- timezone?: string;
113
- language?: string;
114
- industry?: string;
115
- employeeCount?: string;
116
- metadata?: Record<string, unknown>;
117
- isActive: boolean;
118
- createdAt: string;
119
- updatedAt: string;
120
- }
121
- interface CreateCustomerBaseParams {
122
- externalId?: string;
123
- legalName: string;
124
- displayName?: string;
125
- domain?: string;
126
- website?: string;
127
- currency?: Currency;
128
- billingEmail?: string;
129
- paymentTerms?: string;
130
- timezone?: string;
131
- language?: string;
132
- industry?: string;
133
- employeeCount?: string;
134
- metadata?: Record<string, unknown>;
135
- }
136
- interface CustomerAddress {
137
- line1: string;
138
- line2?: string;
139
- city: string;
140
- state?: string;
141
- postalCode: string;
142
- country: string;
143
- region?: string;
144
- }
145
- interface CreateCustomerTaxed extends CreateCustomerBaseParams {
146
- taxStatus: "TAXED";
147
- address: CustomerAddress;
148
- }
149
- interface CreateCustomerOtherTaxStatus extends CreateCustomerBaseParams {
150
- taxStatus?: "TAX_EXEMPT" | "REVERSE_CHARGE" | "NOT_APPLICABLE";
151
- address?: CustomerAddress;
152
- }
153
- type CreateCustomerParams = CreateCustomerTaxed | CreateCustomerOtherTaxStatus;
154
- interface UpdateCustomerParams {
155
- externalId?: string;
156
- legalName?: string;
157
- displayName?: string;
158
- domain?: string;
159
- website?: string;
160
- taxStatus?: "TAXED" | "TAX_EXEMPT" | "REVERSE_CHARGE" | "NOT_APPLICABLE";
161
- currency?: Currency;
162
- billingEmail?: string;
163
- paymentTerms?: string;
164
- timezone?: string;
165
- language?: string;
166
- industry?: string;
167
- employeeCount?: string;
168
- metadata?: Record<string, unknown>;
169
- isActive?: boolean;
170
- }
171
- interface ListCustomersParams extends ListParams {
172
- externalId?: string;
173
- taxStatus?: "TAXED" | "TAX_EXEMPT" | "REVERSE_CHARGE" | "NOT_APPLICABLE";
174
- currency?: Currency;
175
- isActive?: boolean;
176
- search?: string;
177
- }
178
- /**
179
- * Customer resource for managing customer data
180
- */
181
- declare class CustomersResource {
182
- private httpClient;
183
- constructor(httpClient: CommetHTTPClient);
184
- create(params: CreateCustomerParams, options?: RequestOptions): Promise<ApiResponse<Customer>>;
185
- retrieve(customerId: CustomerID, options?: RetrieveOptions): Promise<ApiResponse<Customer>>;
186
- update(customerId: CustomerID, params: UpdateCustomerParams, options?: RequestOptions): Promise<ApiResponse<Customer>>;
187
- list(params?: ListCustomersParams): Promise<ApiResponse<Customer[]>>;
188
- /**
189
- * Deactivate a customer (soft delete)
190
- */
191
- deactivate(customerId: CustomerID, options?: RequestOptions): Promise<ApiResponse<Customer>>;
192
- }
193
-
194
- interface SeatBalance {
195
- id: string;
196
- organizationId: string;
197
- customerId: CustomerID;
198
- seatType: string;
199
- balance: number;
200
- asOf: string;
201
- createdAt: string;
202
- updatedAt: string;
203
- }
204
- interface SeatEvent {
205
- id: string;
206
- organizationId: string;
207
- customerId: CustomerID;
208
- seatType: string;
209
- eventType: "add" | "remove" | "set";
210
- quantity: number;
211
- previousBalance?: number;
212
- newBalance: number;
213
- ts: string;
214
- createdAt: string;
215
- }
216
- interface SeatBalanceResponse {
217
- current: number;
218
- asOf: string;
219
- }
220
- interface BulkSeatUpdate {
221
- [seatType: string]: number;
222
- }
223
- interface ListSeatEventsParams extends ListParams {
224
- customerId?: CustomerID;
225
- seatType?: string;
226
- eventType?: "add" | "remove" | "set";
227
- }
228
- /**
229
- * Seats resource for seat-based billing management
230
- */
231
- declare class SeatsResource {
232
- private httpClient;
233
- constructor(httpClient: CommetHTTPClient);
234
- add(customerId: CustomerID, seatType: string, count: number, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
235
- remove(customerId: CustomerID, seatType: string, count: number, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
236
- set(customerId: CustomerID, seatType: string, count: number, options?: RequestOptions): Promise<ApiResponse<SeatEvent>>;
237
- bulkUpdate(customerId: CustomerID, seats: BulkSeatUpdate, options?: RequestOptions): Promise<ApiResponse<SeatEvent[]>>;
238
- getBalance(customerId: CustomerID, seatType: string): Promise<ApiResponse<SeatBalanceResponse>>;
239
- getAllBalances(customerId: CustomerID): Promise<ApiResponse<Record<string, SeatBalanceResponse>>>;
240
- getHistory(customerId: CustomerID, seatType: string, params?: ListSeatEventsParams): Promise<ApiResponse<SeatEvent[]>>;
241
- listEvents(params?: ListSeatEventsParams): Promise<ApiResponse<SeatEvent[]>>;
242
- }
243
-
244
- interface UsageEvent {
245
- id: EventID;
246
- organizationId: string;
247
- customerId: CustomerID;
248
- eventType: string;
249
- idempotencyKey?: string;
250
- ts: string;
251
- properties?: UsageEventProperty[];
252
- createdAt: string;
253
- }
254
- interface UsageEventProperty {
255
- id: string;
256
- usageEventId: EventID;
257
- property: string;
258
- value: string;
259
- createdAt: string;
260
- }
261
- interface CreateUsageEventParams {
262
- eventType: string;
263
- customerId: CustomerID;
264
- idempotencyKey?: string;
265
- timestamp?: string;
266
- properties?: Array<{
267
- property: string;
268
- value: string;
269
- }>;
270
- }
271
- interface CreateBatchUsageEventsParams {
272
- events: CreateUsageEventParams[];
273
- }
274
- interface BatchResult<T> {
275
- successful: T[];
276
- failed: Array<{
277
- index: number;
278
- error: string;
279
- data: CreateUsageEventParams;
280
- }>;
281
- }
282
- interface ListUsageEventsParams extends ListParams {
283
- customerId?: CustomerID;
284
- eventType?: string;
285
- idempotencyKey?: string;
286
- }
287
- /**
288
- * Usage Events resource - Track business events for usage-based billing
289
- */
290
- declare class UsageEventsResource {
291
- private httpClient;
292
- constructor(httpClient: CommetHTTPClient);
293
- create(params: CreateUsageEventParams, options?: RequestOptions): Promise<ApiResponse<UsageEvent>>;
294
- createBatch(params: CreateBatchUsageEventsParams, options?: RequestOptions): Promise<ApiResponse<BatchResult<UsageEvent>>>;
295
- retrieve(eventId: EventID): Promise<ApiResponse<UsageEvent>>;
296
- list(params?: ListUsageEventsParams): Promise<ApiResponse<UsageEvent[]>>;
297
- delete(eventId: EventID, options?: RequestOptions): Promise<ApiResponse<{
298
- deleted: boolean;
299
- }>>;
300
- }
301
- interface UsageMetric {
302
- id: string;
303
- organizationId: string;
304
- name: string;
305
- eventType: string;
306
- aggregation: "count" | "unique" | "sum";
307
- property?: string;
308
- filters?: UsageMetricFilter[];
309
- createdAt: string;
310
- updatedAt: string;
311
- }
312
- interface UsageMetricFilter {
313
- id: string;
314
- usageMetricId: string;
315
- property: string;
316
- operator: "equals" | "not_equals" | "greater_than" | "less_than" | "contains";
317
- value: string;
318
- createdAt: string;
319
- }
320
- /**
321
- * Usage Metrics resource - Read-only access to metrics
322
- */
323
- declare class UsageMetricsResource {
324
- private httpClient;
325
- constructor(httpClient: CommetHTTPClient);
326
- list(): Promise<ApiResponse<UsageMetric[]>>;
327
- retrieve(metricId: string): Promise<ApiResponse<UsageMetric>>;
328
- }
329
- /**
330
- * Usage resource combining events and metrics
331
- */
332
- declare class UsageResource {
333
- readonly events: UsageEventsResource;
334
- readonly metrics: UsageMetricsResource;
335
- constructor(httpClient: CommetHTTPClient);
336
- }
337
-
338
- /**
339
- * Main Commet SDK client
340
- */
341
- declare class Commet {
342
- private httpClient;
343
- private environment;
344
- readonly customers: CustomersResource;
345
- readonly usage: UsageResource;
346
- readonly seats: SeatsResource;
347
- constructor(config: CommetConfig);
348
- getEnvironment(): Environment;
349
- isSandbox(): boolean;
350
- isProduction(): boolean;
351
- }
352
-
353
- /**
354
- * Check if environment is sandbox
355
- */
356
- declare function isSandbox(environment: Environment): boolean;
357
- /**
358
- * Check if environment is production
359
- */
360
- declare function isProduction(environment: Environment): boolean;
361
-
362
- /**
363
- * Commet SDK - Billing and usage tracking SDK
364
- */
365
-
366
- export { type AgreementID, type ApiResponse, type BatchResult, type BulkSeatUpdate, Commet, CommetAPIError, type CommetConfig, CommetError, CommetValidationError, type CreateBatchUsageEventsParams, type CreateCustomerParams, type CreateUsageEventParams, type Currency, type Customer, type CustomerID, type Environment, type EventID, type InvoiceID, type ItemID, type ListCustomersParams, type ListParams, type ListSeatEventsParams, type ListUsageEventsParams, type PaginatedList, type PaginatedResponse, type PhaseID, type ProductID, type RequestOptions, type RetrieveOptions, type SeatBalance, type SeatBalanceResponse, type SeatEvent, type UpdateCustomerParams, type UsageEvent, type UsageEventProperty, type UsageMetric, type UsageMetricFilter, type WebhookID, Commet as default, isProduction, isSandbox };