commet 0.7.4 → 0.8.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 +44 -259
- package/dist/index.js +22 -24
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,301 +1,86 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<p align="center">
|
|
3
|
+
<a href="https://commet.co">
|
|
4
|
+
<img src="https://commet.co/logo-bg-dark.png" height="96">
|
|
5
|
+
<h3 align="center">Commet CLI</h3>
|
|
6
|
+
</a>
|
|
7
|
+
</p>
|
|
8
|
+
<p>CLI for Commet billing platform</p>
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
<a href="https://www.npmjs.com/package/commet"><img alt="NPM version" src="https://img.shields.io/npm/v/commet.svg?style=for-the-badge&labelColor=000000"></a>
|
|
11
|
+
<a href="https://docs.commet.co/docs/library/cli/overview"><img alt="Documentation" src="https://img.shields.io/badge/docs-CLI-blue.svg?style=for-the-badge&labelColor=000000"></a>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<br/>
|
|
4
15
|
|
|
5
16
|
## Installation
|
|
6
17
|
|
|
7
18
|
```bash
|
|
8
19
|
npm install -g commet
|
|
9
|
-
# or
|
|
10
|
-
pnpm add -g commet
|
|
11
|
-
# or
|
|
12
|
-
yarn global add commet
|
|
13
20
|
```
|
|
14
21
|
|
|
15
22
|
## Quick Start
|
|
16
23
|
|
|
17
24
|
```bash
|
|
18
|
-
#
|
|
19
|
-
commet login
|
|
20
|
-
|
|
21
|
-
# 2. Navigate to your project directory
|
|
22
|
-
cd apps/dashboard # Recommended: use TypeScript project with tsconfig.json
|
|
23
|
-
|
|
24
|
-
# 3. Link your project to an organization
|
|
25
|
-
commet link
|
|
26
|
-
|
|
27
|
-
# 4. Generate TypeScript types (automatically updates tsconfig.json and .gitignore if found)
|
|
28
|
-
commet pull
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Commands
|
|
32
|
-
|
|
33
|
-
### Authentication
|
|
34
|
-
|
|
35
|
-
#### `commet login`
|
|
36
|
-
|
|
37
|
-
Authenticate with Commet using OAuth device flow.
|
|
38
|
-
|
|
39
|
-
```bash
|
|
25
|
+
# Authenticate
|
|
40
26
|
commet login
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Prompts you to select an environment (Sandbox or Production), then opens your browser to authenticate. Creates `~/.commet/auth.json` with your credentials.
|
|
44
|
-
|
|
45
|
-
**Important:** Sandbox and Production are completely isolated platforms with separate accounts:
|
|
46
|
-
- **Sandbox**: `sandbox.commet.co` - Development and testing
|
|
47
|
-
- **Production**: `commet.co` - Live billing operations
|
|
48
|
-
|
|
49
|
-
Make sure to login to the correct environment for your needs.
|
|
50
|
-
|
|
51
|
-
#### `commet logout`
|
|
52
|
-
|
|
53
|
-
Log out and remove stored credentials.
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
commet logout
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
#### `commet whoami`
|
|
60
|
-
|
|
61
|
-
Display current authentication and project status.
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
commet whoami
|
|
65
|
-
```
|
|
66
27
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
#### `commet link`
|
|
70
|
-
|
|
71
|
-
Link the current directory to a Commet organization.
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
cd apps/dashboard
|
|
28
|
+
# Link to organization
|
|
75
29
|
commet link
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**What it does:**
|
|
79
|
-
- Creates `.commet/config.json` with organization configuration
|
|
80
|
-
- Works anywhere, but for best experience use a TypeScript project directory
|
|
81
|
-
|
|
82
|
-
#### `commet unlink`
|
|
83
|
-
|
|
84
|
-
Unlink the current directory from Commet.
|
|
85
30
|
|
|
86
|
-
|
|
87
|
-
commet unlink
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
#### `commet switch`
|
|
91
|
-
|
|
92
|
-
Switch to a different organization or environment.
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
commet switch
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
#### `commet info`
|
|
99
|
-
|
|
100
|
-
Display detailed information about the current project.
|
|
101
|
-
|
|
102
|
-
```bash
|
|
103
|
-
commet info
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### Type Generation
|
|
107
|
-
|
|
108
|
-
#### `commet pull`
|
|
109
|
-
|
|
110
|
-
Generate TypeScript type definitions from your Commet configuration.
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
cd apps/dashboard # Recommended: TypeScript project directory
|
|
31
|
+
# Generate types
|
|
114
32
|
commet pull
|
|
115
33
|
```
|
|
116
34
|
|
|
117
|
-
|
|
118
|
-
1. Generates `.commet/types.d.ts` with your event and seat types
|
|
119
|
-
2. Automatically updates `tsconfig.json` to include the types file (if found)
|
|
120
|
-
3. Automatically updates `.gitignore` to exclude `.commet/` directory
|
|
121
|
-
|
|
122
|
-
**Note:** Works anywhere, but if no `tsconfig.json` is found, you'll need to manually configure TypeScript to include the generated types.
|
|
35
|
+
## Type Generation
|
|
123
36
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
// .commet/types.d.ts
|
|
128
|
-
declare module '@commet/node' {
|
|
129
|
-
interface CommetGeneratedTypes {
|
|
130
|
-
eventType: "api_call" | "email_sent" | "payment_processed";
|
|
131
|
-
seatType: "admin" | "editor" | "viewer";
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export {};
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
**Usage with the SDK:**
|
|
37
|
+
The CLI generates TypeScript types from your organization for type-safe autocomplete:
|
|
139
38
|
|
|
140
39
|
```typescript
|
|
40
|
+
// After running 'commet pull'
|
|
141
41
|
import { Commet } from '@commet/node';
|
|
142
42
|
|
|
143
43
|
const commet = new Commet({ apiKey: '...' });
|
|
144
44
|
|
|
145
|
-
|
|
146
|
-
await commet.usage.events.create({
|
|
147
|
-
customerId: 'cus_123',
|
|
45
|
+
await commet.usage.create({
|
|
148
46
|
eventType: 'api_call', // Autocomplete works!
|
|
149
|
-
|
|
47
|
+
customerId: 'cus_123'
|
|
150
48
|
});
|
|
151
49
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
### Type Inspection
|
|
157
|
-
|
|
158
|
-
#### `commet list events`
|
|
159
|
-
|
|
160
|
-
List all event types in your organization.
|
|
161
|
-
|
|
162
|
-
```bash
|
|
163
|
-
commet list events
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
#### `commet list seats`
|
|
167
|
-
|
|
168
|
-
List all seat types in your organization.
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
commet list seats
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
## Configuration Files
|
|
175
|
-
|
|
176
|
-
### Global Config (`~/.commet/auth.json`)
|
|
177
|
-
|
|
178
|
-
Stores authentication credentials. Created by `commet login`.
|
|
179
|
-
|
|
180
|
-
```json
|
|
181
|
-
{
|
|
182
|
-
"token": "...",
|
|
183
|
-
"refreshToken": "...",
|
|
184
|
-
"expiresAt": 1234567890,
|
|
185
|
-
"environment": "sandbox"
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
The `environment` field determines which platform your authentication is for (sandbox or production).
|
|
190
|
-
|
|
191
|
-
### Project Config (`.commet/config.json`)
|
|
192
|
-
|
|
193
|
-
Stores project-specific configuration. Created by `commet link`.
|
|
194
|
-
|
|
195
|
-
```json
|
|
196
|
-
{
|
|
197
|
-
"orgId": "org_123",
|
|
198
|
-
"orgName": "My Organization",
|
|
199
|
-
"environment": "sandbox"
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
**Note:** The `.commet/` directory is automatically added to `.gitignore` by `commet pull`. This directory contains:
|
|
204
|
-
- `config.json` - Project configuration
|
|
205
|
-
- `types.d.ts` - Generated TypeScript type definitions
|
|
206
|
-
|
|
207
|
-
Add `.commet/` to `.gitignore` if different developers use different organizations.
|
|
208
|
-
|
|
209
|
-
## Environments
|
|
210
|
-
|
|
211
|
-
Commet supports two completely isolated environments:
|
|
212
|
-
|
|
213
|
-
- **Sandbox** (`sandbox.commet.co`): Development and testing with separate data
|
|
214
|
-
- **Production** (`commet.co`): Live billing operations with real customers
|
|
215
|
-
|
|
216
|
-
**Important:** Each environment requires separate authentication because they are independent platforms. To work with both:
|
|
217
|
-
|
|
218
|
-
1. Login to sandbox: `commet login` → Select "Sandbox"
|
|
219
|
-
2. Do your work in sandbox
|
|
220
|
-
3. When ready for production: `commet logout` → `commet login` → Select "Production"
|
|
221
|
-
|
|
222
|
-
Organizations and data do NOT transfer between environments.
|
|
223
|
-
|
|
224
|
-
## Workflow
|
|
225
|
-
|
|
226
|
-
Typical development workflow:
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
# 1. One-time setup (Sandbox)
|
|
230
|
-
commet login # Select "Sandbox"
|
|
231
|
-
cd apps/dashboard # Navigate to your TypeScript project (must have tsconfig.json)
|
|
232
|
-
commet link # Choose your organization
|
|
233
|
-
commet pull # Generate types (auto-updates tsconfig.json and .gitignore)
|
|
234
|
-
|
|
235
|
-
# 2. Develop with type-safe autocomplete
|
|
236
|
-
# Your IDE now has full autocomplete for event and seat types!
|
|
237
|
-
|
|
238
|
-
# 3. When you add/change event or seat types in dashboard
|
|
239
|
-
commet pull # Regenerate types
|
|
240
|
-
|
|
241
|
-
# 4. When ready for production
|
|
242
|
-
commet logout
|
|
243
|
-
commet login # Select "Production"
|
|
244
|
-
cd apps/dashboard # Same TypeScript project directory
|
|
245
|
-
commet link # Link to production organization
|
|
246
|
-
commet pull # Generate production types
|
|
50
|
+
await commet.subscriptions.create({
|
|
51
|
+
productId: 'prod_xxx', // Autocomplete with your products!
|
|
52
|
+
customerId: 'cus_123'
|
|
53
|
+
});
|
|
247
54
|
```
|
|
248
55
|
|
|
249
|
-
##
|
|
250
|
-
|
|
251
|
-
### "Not authenticated"
|
|
252
|
-
|
|
253
|
-
Run `commet login` to authenticate.
|
|
254
|
-
|
|
255
|
-
### "No tsconfig.json found" (Warning)
|
|
256
|
-
|
|
257
|
-
This is just a warning - the CLI will still work, but won't automatically update your `tsconfig.json`.
|
|
258
|
-
|
|
259
|
-
For the best experience, run commands from a TypeScript project directory:
|
|
56
|
+
## Commands
|
|
260
57
|
|
|
261
58
|
```bash
|
|
262
|
-
|
|
263
|
-
commet
|
|
264
|
-
commet
|
|
59
|
+
commet login # Authenticate with Commet
|
|
60
|
+
commet logout # Remove credentials
|
|
61
|
+
commet link # Link project to organization
|
|
62
|
+
commet pull # Generate TypeScript types
|
|
63
|
+
commet info # Show project status
|
|
64
|
+
commet list events # List event types
|
|
65
|
+
commet list seats # List seat types
|
|
265
66
|
```
|
|
266
67
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
### "Project not linked"
|
|
270
|
-
|
|
271
|
-
Run `commet link` to connect your project to an organization.
|
|
68
|
+
## Documentation
|
|
272
69
|
|
|
273
|
-
|
|
70
|
+
Visit [docs.commet.co/cli](https://docs.commet.co/cli) for:
|
|
274
71
|
|
|
275
|
-
|
|
72
|
+
- Complete command reference
|
|
73
|
+
- Configuration guide
|
|
74
|
+
- Workflow examples
|
|
75
|
+
- Troubleshooting
|
|
276
76
|
|
|
277
|
-
|
|
77
|
+
## Resources
|
|
278
78
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
"include": [".commet/types.d.ts", "src/**/*"]
|
|
284
|
-
}
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### Authentication expired
|
|
288
|
-
|
|
289
|
-
Run `commet login` again. Tokens expire after a certain period.
|
|
290
|
-
|
|
291
|
-
## Links
|
|
292
|
-
|
|
293
|
-
- [Documentation](https://docs.commet.co)
|
|
294
|
-
- [API Reference](https://docs.commet.co/api)
|
|
295
|
-
- [GitHub](https://github.com/commet-labs/commet-node)
|
|
296
|
-
- [Issues](https://github.com/commet-labs/commet-node/issues)
|
|
79
|
+
- [CLI Documentation](https://docs.commet.co/docs/library/cli/overview)
|
|
80
|
+
- [SDK Reference](https://docs.commet.co/docs/library/quickstart)
|
|
81
|
+
- [GitHub](https://github.com/commet-labs/commet)
|
|
82
|
+
- [Issues](https://github.com/commet-labs/commet/issues)
|
|
297
83
|
|
|
298
84
|
## License
|
|
299
85
|
|
|
300
86
|
MIT
|
|
301
|
-
|
package/dist/index.js
CHANGED
|
@@ -588,48 +588,41 @@ function validateTypeScriptProject() {
|
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
// src/utils/generator.ts
|
|
591
|
-
function generateTypes(eventTypes, seatTypes) {
|
|
591
|
+
function generateTypes(eventTypes, seatTypes, products) {
|
|
592
592
|
const eventTypeUnion = eventTypes.length > 0 ? eventTypes.map((e) => `"${e.code}"`).join(" | ") : "string";
|
|
593
593
|
const seatTypeUnion = seatTypes.length > 0 ? seatTypes.map((s) => `"${s.code}"`).join(" | ") : "string";
|
|
594
|
+
const productTypeUnion = products.length > 0 ? products.map((p) => `"${p.publicId}"`).join(" | ") : "string";
|
|
594
595
|
const eventComments = eventTypes.map(
|
|
595
596
|
(e) => ` * - "${e.code}": ${e.name}${e.description ? ` - ${e.description}` : ""}`
|
|
596
597
|
).join("\n");
|
|
597
598
|
const seatComments = seatTypes.map(
|
|
598
599
|
(s) => ` * - "${s.code}": ${s.name}${s.description ? ` - ${s.description}` : ""} ${s.isFree ? "(Free)" : ""}`
|
|
599
600
|
).join("\n");
|
|
601
|
+
const productComments = products.map(
|
|
602
|
+
(p) => ` * - "${p.publicId}": ${p.name}${p.description ? ` - ${p.description}` : ""}`
|
|
603
|
+
).join("\n");
|
|
600
604
|
return `// Auto-generated by Commet CLI
|
|
601
605
|
// Do not edit this file manually - run 'commet pull' to update
|
|
602
606
|
|
|
603
607
|
/**
|
|
604
|
-
* Module augmentation for automatic type inference
|
|
605
|
-
*
|
|
606
608
|
* This augments the Commet SDK to automatically use your organization's
|
|
607
|
-
* specific event
|
|
609
|
+
* specific event types, seat types, and products without requiring generic type parameters.
|
|
608
610
|
*
|
|
609
611
|
* Event types available in your organization:
|
|
610
|
-
${eventComments}
|
|
612
|
+
${eventComments || " * (none)"}
|
|
611
613
|
*
|
|
612
614
|
* Seat types available in your organization:
|
|
613
|
-
${seatComments}
|
|
614
|
-
*
|
|
615
|
-
* @example
|
|
616
|
-
* import { Commet } from '@commet/node';
|
|
617
|
-
*
|
|
618
|
-
* const commet = new Commet({ apiKey: 'your-api-key' });
|
|
615
|
+
${seatComments || " * (none)"}
|
|
619
616
|
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
* eventType: 'api_call', // Only accepts your event types
|
|
623
|
-
* customerId: 'cus_123'
|
|
624
|
-
* });
|
|
617
|
+
* Products available in your organization:
|
|
618
|
+
${productComments || " * (none)"}
|
|
625
619
|
*
|
|
626
|
-
|
|
627
|
-
* await commet.seats.add('cus_123', 'admin', 5);
|
|
628
|
-
*/
|
|
620
|
+
*/
|
|
629
621
|
declare module '@commet/node' {
|
|
630
622
|
interface CommetGeneratedTypes {
|
|
631
623
|
eventType: ${eventTypeUnion};
|
|
632
624
|
seatType: ${seatTypeUnion};
|
|
625
|
+
productId: ${productTypeUnion};
|
|
633
626
|
}
|
|
634
627
|
}
|
|
635
628
|
|
|
@@ -709,8 +702,8 @@ var pullCommand = new import_commander6.Command("pull").description("Pull type d
|
|
|
709
702
|
console.error(import_chalk7.default.red("Error:"), result.error);
|
|
710
703
|
return;
|
|
711
704
|
}
|
|
712
|
-
const { eventTypes, seatTypes } = result.data;
|
|
713
|
-
const typeDefinitions = generateTypes(eventTypes, seatTypes);
|
|
705
|
+
const { eventTypes, seatTypes, products } = result.data;
|
|
706
|
+
const typeDefinitions = generateTypes(eventTypes, seatTypes, products);
|
|
714
707
|
const commetDir = path5.resolve(process.cwd(), ".commet");
|
|
715
708
|
const outputPath = path5.join(commetDir, "types.d.ts");
|
|
716
709
|
fs5.mkdirSync(commetDir, { recursive: true });
|
|
@@ -755,12 +748,17 @@ var pullCommand = new import_commander6.Command("pull").description("Pull type d
|
|
|
755
748
|
` Seat types: ${seatTypes.length > 0 ? seatTypes.map((s) => s.code).join(", ") : "none"}`
|
|
756
749
|
)
|
|
757
750
|
);
|
|
751
|
+
console.log(
|
|
752
|
+
import_chalk7.default.dim(
|
|
753
|
+
` Products: ${products.length > 0 ? products.map((p) => p.publicId).join(", ") : "none"}`
|
|
754
|
+
)
|
|
755
|
+
);
|
|
758
756
|
console.log(import_chalk7.default.dim(`
|
|
759
757
|
Output: ${outputPath}`));
|
|
760
|
-
if (eventTypes.length === 0 && seatTypes.length === 0) {
|
|
758
|
+
if (eventTypes.length === 0 && seatTypes.length === 0 && products.length === 0) {
|
|
761
759
|
console.log(
|
|
762
760
|
import_chalk7.default.yellow(
|
|
763
|
-
"\n\u26A0 No types found. Create event types
|
|
761
|
+
"\n\u26A0 No types found. Create event types, seat types, and products in your Commet dashboard."
|
|
764
762
|
)
|
|
765
763
|
);
|
|
766
764
|
}
|
|
@@ -888,7 +886,7 @@ var whoamiCommand = new import_commander9.Command("whoami").description("Display
|
|
|
888
886
|
// package.json
|
|
889
887
|
var package_default = {
|
|
890
888
|
name: "commet",
|
|
891
|
-
version: "0.
|
|
889
|
+
version: "0.8.0",
|
|
892
890
|
description: "Commet CLI - Manage your billing platform from the command line",
|
|
893
891
|
bin: {
|
|
894
892
|
commet: "./bin/commet"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commet",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Commet CLI - Manage your billing platform from the command line",
|
|
5
5
|
"bin": {
|
|
6
6
|
"commet": "./bin/commet"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"jsonc-parser": "^3.3.1",
|
|
26
26
|
"open": "^10.0.0",
|
|
27
27
|
"ora": "^7.0.1",
|
|
28
|
-
"@commet/node": "0.
|
|
28
|
+
"@commet/node": "0.9.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.10.0",
|