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 CHANGED
@@ -1,39 +1,235 @@
1
1
  # commet
2
2
 
3
- TypeScript SDK for Commet billing and usage tracking.
3
+ CLI tool for Commet billing platform - authentication, project linking, and type generation.
4
4
 
5
- ## Install
5
+ ## Installation
6
6
 
7
7
  ```bash
8
- npm install commet
8
+ npm install -g commet
9
+ # or
10
+ pnpm add -g commet
11
+ # or
12
+ yarn global add commet
9
13
  ```
10
14
 
11
15
  ## Quick Start
12
16
 
17
+ ```bash
18
+ # 1. Authenticate with Commet
19
+ commet login
20
+
21
+ # 2. Link your project to an organization
22
+ commet link
23
+
24
+ # 3. Generate TypeScript types
25
+ commet pull
26
+ ```
27
+
28
+ ## Commands
29
+
30
+ ### Authentication
31
+
32
+ #### `commet login`
33
+
34
+ Authenticate with Commet using OAuth device flow.
35
+
36
+ ```bash
37
+ commet login
38
+ ```
39
+
40
+ Opens your browser to authenticate. Creates `~/.commet/auth.json` with your credentials.
41
+
42
+ #### `commet logout`
43
+
44
+ Log out and remove stored credentials.
45
+
46
+ ```bash
47
+ commet logout
48
+ ```
49
+
50
+ #### `commet whoami`
51
+
52
+ Display current authentication and project status.
53
+
54
+ ```bash
55
+ commet whoami
56
+ ```
57
+
58
+ ### Project Management
59
+
60
+ #### `commet link`
61
+
62
+ Link the current directory to a Commet organization.
63
+
64
+ ```bash
65
+ commet link
66
+ ```
67
+
68
+ Creates `.commet` file in the current directory with organization configuration.
69
+
70
+ #### `commet unlink`
71
+
72
+ Unlink the current directory from Commet.
73
+
74
+ ```bash
75
+ commet unlink
76
+ ```
77
+
78
+ #### `commet switch`
79
+
80
+ Switch to a different organization or environment.
81
+
82
+ ```bash
83
+ commet switch
84
+ ```
85
+
86
+ #### `commet info`
87
+
88
+ Display detailed information about the current project.
89
+
90
+ ```bash
91
+ commet info
92
+ ```
93
+
94
+ ### Type Generation
95
+
96
+ #### `commet pull`
97
+
98
+ Generate TypeScript type definitions from your Commet configuration.
99
+
100
+ ```bash
101
+ commet pull
102
+ # or specify output file
103
+ commet pull -o types/commet.d.ts
104
+ ```
105
+
106
+ Creates `.commet.d.ts` with your event and seat types:
107
+
13
108
  ```typescript
14
- import { Commet } from 'commet';
109
+ // .commet.d.ts
110
+ export type CommetEventType = "api_call" | "email_sent" | "payment_processed";
111
+ export type CommetSeatType = "admin" | "editor" | "viewer";
112
+ ```
15
113
 
16
- const commet = new Commet({
17
- apiKey: process.env.COMMET_API_KEY!,
18
- });
114
+ Use with the SDK:
19
115
 
20
- // Track usage
21
- await commet.usage.events.create({
22
- eventType: 'api_call',
116
+ ```typescript
117
+ import { Commet } from '@commet/node';
118
+ import type { CommetEventType, CommetSeatType } from './.commet';
119
+
120
+ const commet = new Commet({ apiKey: '...' });
121
+
122
+ // Type-safe event tracking
123
+ await commet.usage.events.create<CommetEventType>({
23
124
  customerId: 'cus_123',
125
+ eventType: 'api_call', // Autocomplete works!
126
+ timestamp: new Date().toISOString(),
24
127
  });
25
128
 
26
- // Manage seats
27
- await commet.seats.add('cus_123', 'admin', 5);
129
+ // Type-safe seat management
130
+ await commet.seats.add<CommetSeatType>('cus_123', 'admin', 5);
131
+ ```
28
132
 
29
- // Create customer
30
- const customer = await commet.customers.create({
31
- legalName: 'Acme Corporation',
32
- currency: 'USD',
33
- address: { /* address info */ }
34
- });
133
+ ### Type Inspection
134
+
135
+ #### `commet list events`
136
+
137
+ List all event types in your organization.
138
+
139
+ ```bash
140
+ commet list events
141
+ ```
142
+
143
+ #### `commet list seats`
144
+
145
+ List all seat types in your organization.
146
+
147
+ ```bash
148
+ commet list seats
149
+ ```
150
+
151
+ ## Configuration Files
152
+
153
+ ### Global Config (`~/.commet/auth.json`)
154
+
155
+ Stores authentication credentials. Created by `commet login`.
156
+
157
+ ```json
158
+ {
159
+ "token": "...",
160
+ "refreshToken": "...",
161
+ "expiresAt": 1234567890
162
+ }
163
+ ```
164
+
165
+ ### Project Config (`.commet`)
166
+
167
+ Stores project-specific configuration. Created by `commet link`.
168
+
169
+ ```json
170
+ {
171
+ "orgId": "org_123",
172
+ "orgName": "My Organization",
173
+ "environment": "sandbox"
174
+ }
35
175
  ```
36
176
 
37
- ## Documentation
177
+ **Note:** Add `.commet` to `.gitignore` if different developers use different organizations.
178
+
179
+ ## Environments
180
+
181
+ Commet supports two environments:
182
+
183
+ - **Sandbox**: Development and testing (default)
184
+ - **Production**: Live billing operations
185
+
186
+ Select environment during `commet link` or `commet switch`.
187
+
188
+ ## Workflow
189
+
190
+ Typical development workflow:
191
+
192
+ ```bash
193
+ # 1. One-time setup
194
+ commet login
195
+ commet link
196
+
197
+ # 2. Generate types when you add/change event or seat types
198
+ commet pull
199
+
200
+ # 3. Use types in your code with autocomplete
201
+ # (see TypeScript examples above)
202
+
203
+ # 4. Switch environments when needed
204
+ commet switch # Select production
205
+ ```
206
+
207
+ ## Troubleshooting
208
+
209
+ ### "Not authenticated"
210
+
211
+ Run `commet login` to authenticate.
212
+
213
+ ### "Project not linked"
214
+
215
+ Run `commet link` to connect your project to an organization.
216
+
217
+ ### "No types found"
218
+
219
+ Create event types and seat types in your Commet dashboard first, then run `commet pull`.
220
+
221
+ ### Authentication expired
222
+
223
+ Run `commet login` again. Tokens expire after a certain period.
224
+
225
+ ## Links
226
+
227
+ - [Documentation](https://docs.commet.co)
228
+ - [API Reference](https://docs.commet.co/api)
229
+ - [GitHub](https://github.com/commet-labs/commet-node)
230
+ - [Issues](https://github.com/commet-labs/commet-node/issues)
231
+
232
+ ## License
233
+
234
+ MIT
38
235
 
39
- See [docs](https://docs.commet.co) for complete documentation.
package/bin/commet ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../dist/index.js');