commet 0.8.1 → 1.1.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.
Files changed (3) hide show
  1. package/README.md +11 -10
  2. package/dist/index.js +477 -277
  3. package/package.json +11 -11
package/dist/index.js CHANGED
@@ -24,13 +24,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  ));
25
25
 
26
26
  // src/index.ts
27
- var import_chalk11 = __toESM(require("chalk"));
28
- var import_commander10 = require("commander");
27
+ var import_chalk12 = __toESM(require("chalk"));
28
+ var import_commander11 = require("commander");
29
29
 
30
30
  // package.json
31
31
  var package_default = {
32
32
  name: "commet",
33
- version: "0.8.1",
33
+ version: "1.1.0",
34
34
  description: "Commet CLI - Manage your billing platform from the command line",
35
35
  bin: {
36
36
  commet: "./bin/commet"
@@ -56,18 +56,18 @@ var package_default = {
56
56
  author: "Commet Team",
57
57
  license: "MIT",
58
58
  dependencies: {
59
- "@commet/node": "workspace:*",
60
- "@inquirer/prompts": "^7.8.6",
61
- chalk: "^5.3.0",
62
- commander: "^12.0.0",
63
- "jsonc-parser": "^3.3.1",
64
- open: "^10.0.0",
65
- ora: "^7.0.1"
59
+ "@inquirer/prompts": "8.0.1",
60
+ chalk: "5.6.2",
61
+ commander: "14.0.2",
62
+ "jsonc-parser": "3.3.1",
63
+ open: "11.0.0",
64
+ ora: "9.0.0",
65
+ tar: "^7.5.13"
66
66
  },
67
67
  devDependencies: {
68
- "@types/node": "^20.10.0",
69
- tsup: "^8.0.1",
70
- typescript: "^5.3.3"
68
+ "@types/node": "24.10.1",
69
+ tsup: "8.5.1",
70
+ typescript: "5.9.3"
71
71
  },
72
72
  engines: {
73
73
  node: ">=18.0.0"
@@ -84,33 +84,229 @@ var package_default = {
84
84
  }
85
85
  };
86
86
 
87
- // src/commands/info.ts
88
- var import_chalk = __toESM(require("chalk"));
89
- var import_commander = require("commander");
90
-
91
- // src/utils/config.ts
87
+ // src/commands/create.ts
88
+ var import_node_child_process = require("child_process");
92
89
  var fs = __toESM(require("fs"));
93
90
  var os = __toESM(require("os"));
94
91
  var path = __toESM(require("path"));
92
+ var import_prompts = require("@inquirer/prompts");
93
+ var import_chalk2 = __toESM(require("chalk"));
94
+ var import_commander = require("commander");
95
+ var import_ora = __toESM(require("ora"));
96
+ var import_tar = require("tar");
97
+
98
+ // src/utils/prompt-theme.ts
99
+ var import_chalk = __toESM(require("chalk"));
100
+ var commetColor = import_chalk.default.hex("#5BC0B0");
101
+ var promptTheme = {
102
+ prefix: commetColor("\u276F"),
103
+ style: {
104
+ answer: commetColor,
105
+ message: import_chalk.default.bold,
106
+ error: import_chalk.default.red,
107
+ help: import_chalk.default.dim,
108
+ highlight: commetColor.bold,
109
+ // Selected option in mint
110
+ description: import_chalk.default.dim,
111
+ defaultAnswer: import_chalk.default.dim
112
+ }
113
+ };
114
+
115
+ // src/commands/create.ts
116
+ var GITHUB_REPO = "commet-labs/commet";
117
+ var TEMPLATES = [
118
+ {
119
+ name: "fixed",
120
+ dir: "fixed-saas",
121
+ description: "Fixed subscriptions (monthly/yearly plans)"
122
+ },
123
+ {
124
+ name: "seats",
125
+ dir: "team-saas",
126
+ description: "Seat-based billing (per team member)"
127
+ },
128
+ {
129
+ name: "credits",
130
+ dir: "credits-saas",
131
+ description: "Credit-based billing (prepaid usage blocks)"
132
+ },
133
+ {
134
+ name: "usage-based",
135
+ dir: "usage-based-saas",
136
+ description: "Usage-based billing (metered, pay for what you use)"
137
+ }
138
+ ];
139
+ function detectPackageManager() {
140
+ const agent = process.env.npm_config_user_agent;
141
+ if (!agent) return "npm";
142
+ if (agent.startsWith("pnpm")) return "pnpm";
143
+ if (agent.startsWith("yarn")) return "yarn";
144
+ if (agent.startsWith("bun")) return "bun";
145
+ return "npm";
146
+ }
147
+ async function downloadTemplate(templateDir, dest, ref) {
148
+ const url = `https://codeload.github.com/${GITHUB_REPO}/tar.gz/${ref}`;
149
+ const response = await fetch(url);
150
+ if (!response.ok) {
151
+ throw new Error(`Failed to download (HTTP ${response.status})`);
152
+ }
153
+ const tempFile = path.join(os.tmpdir(), `commet-${Date.now()}.tar.gz`);
154
+ try {
155
+ const buffer = Buffer.from(await response.arrayBuffer());
156
+ fs.writeFileSync(tempFile, buffer);
157
+ fs.mkdirSync(dest, { recursive: true });
158
+ await (0, import_tar.extract)({
159
+ file: tempFile,
160
+ cwd: dest,
161
+ strip: 3,
162
+ filter: (entryPath) => {
163
+ const parts = entryPath.split("/");
164
+ return parts[1] === "examples" && parts[2] === templateDir;
165
+ }
166
+ });
167
+ } finally {
168
+ if (fs.existsSync(tempFile)) {
169
+ fs.unlinkSync(tempFile);
170
+ }
171
+ }
172
+ const files = fs.readdirSync(dest);
173
+ if (files.length === 0) {
174
+ throw new Error(`Template "${templateDir}" not found in repository`);
175
+ }
176
+ }
177
+ function updatePackageJson(dest, projectName) {
178
+ const pkgPath = path.join(dest, "package.json");
179
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
180
+ pkg.name = projectName;
181
+ pkg.version = "0.0.1";
182
+ pkg.private = true;
183
+ fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}
184
+ `);
185
+ }
186
+ function copyEnvExample(dest) {
187
+ const examplePath = path.join(dest, ".env.example");
188
+ const envPath = path.join(dest, ".env");
189
+ if (fs.existsSync(examplePath)) {
190
+ fs.copyFileSync(examplePath, envPath);
191
+ }
192
+ }
193
+ var createCommand = new import_commander.Command("create").description("Create a new Commet app from a template").argument("[name]", "Project name").option(
194
+ "-t, --template <template>",
195
+ "Template to use (fixed, seats, credits, usage-based)"
196
+ ).option("--ref <ref>", "Git ref to fetch templates from", "main").option("--list", "List available templates").action(async (argName, opts) => {
197
+ if (opts.list) {
198
+ console.log(import_chalk2.default.bold("\nAvailable templates:\n"));
199
+ for (const t of TEMPLATES) {
200
+ console.log(
201
+ ` ${commetColor(t.name.padEnd(14))}${import_chalk2.default.dim(t.description)}`
202
+ );
203
+ }
204
+ console.log();
205
+ return;
206
+ }
207
+ let projectName = argName;
208
+ try {
209
+ if (!projectName) {
210
+ projectName = await (0, import_prompts.input)({
211
+ message: "Project name:",
212
+ theme: promptTheme
213
+ });
214
+ }
215
+ } catch {
216
+ console.log(import_chalk2.default.yellow("\n\u26A0 Cancelled"));
217
+ return;
218
+ }
219
+ const dest = path.resolve(projectName);
220
+ if (fs.existsSync(dest)) {
221
+ console.log(import_chalk2.default.red(`\u2717 Directory "${projectName}" already exists`));
222
+ return;
223
+ }
224
+ let template = TEMPLATES.find((t) => t.name === opts.template);
225
+ if (opts.template && !template) {
226
+ console.log(import_chalk2.default.red(`\u2717 Unknown template "${opts.template}"`));
227
+ console.log(
228
+ import_chalk2.default.dim("Run `commet create --list` to see available templates")
229
+ );
230
+ return;
231
+ }
232
+ try {
233
+ if (!template) {
234
+ const selected = await (0, import_prompts.select)({
235
+ message: "Billing model:",
236
+ choices: TEMPLATES.map((t) => ({
237
+ name: `${t.name.padEnd(14)} ${import_chalk2.default.dim(t.description)}`,
238
+ value: t.name
239
+ })),
240
+ theme: promptTheme
241
+ });
242
+ template = TEMPLATES.find((t) => t.name === selected);
243
+ }
244
+ } catch {
245
+ console.log(import_chalk2.default.yellow("\n\u26A0 Cancelled"));
246
+ return;
247
+ }
248
+ const spinner = (0, import_ora.default)("Downloading template...").start();
249
+ try {
250
+ await downloadTemplate(template.dir, dest, opts.ref);
251
+ spinner.succeed("Template downloaded");
252
+ } catch (error) {
253
+ spinner.fail("Failed to download template");
254
+ if (error instanceof Error) {
255
+ console.error(import_chalk2.default.red(error.message));
256
+ }
257
+ if (fs.existsSync(dest)) {
258
+ fs.rmSync(dest, { recursive: true, force: true });
259
+ }
260
+ return;
261
+ }
262
+ updatePackageJson(dest, projectName);
263
+ copyEnvExample(dest);
264
+ const pm = detectPackageManager();
265
+ const installSpinner = (0, import_ora.default)(`Installing dependencies with ${pm}...`).start();
266
+ try {
267
+ (0, import_node_child_process.execSync)(`${pm} install`, { cwd: dest, stdio: "ignore" });
268
+ installSpinner.succeed("Dependencies installed");
269
+ } catch {
270
+ installSpinner.warn("Could not install dependencies");
271
+ console.log(import_chalk2.default.dim(` Run \`${pm} install\` manually`));
272
+ }
273
+ console.log(import_chalk2.default.green(`
274
+ \u2713 Created ${projectName}`));
275
+ console.log(import_chalk2.default.dim(` Template: ${template.name}`));
276
+ console.log();
277
+ console.log(` ${import_chalk2.default.cyan("cd")} ${projectName}`);
278
+ console.log(` ${import_chalk2.default.dim("Update .env with your keys")}`);
279
+ console.log(` ${import_chalk2.default.cyan(`${pm} dev`)}`);
280
+ console.log();
281
+ });
282
+
283
+ // src/commands/info.ts
284
+ var import_chalk3 = __toESM(require("chalk"));
285
+ var import_commander2 = require("commander");
286
+
287
+ // src/utils/config.ts
288
+ var fs2 = __toESM(require("fs"));
289
+ var os2 = __toESM(require("os"));
290
+ var path2 = __toESM(require("path"));
95
291
  function getAuthPath() {
96
- return path.join(os.homedir(), ".commet", "auth.json");
292
+ return path2.join(os2.homedir(), ".commet", "auth.json");
97
293
  }
98
294
  function getProjectConfigPath() {
99
- return path.join(process.cwd(), ".commet", "config.json");
295
+ return path2.join(process.cwd(), ".commet", "config.json");
100
296
  }
101
297
  function getProjectConfigDir() {
102
- return path.join(process.cwd(), ".commet");
298
+ return path2.join(process.cwd(), ".commet");
103
299
  }
104
300
  function authExists() {
105
- return fs.existsSync(getAuthPath());
301
+ return fs2.existsSync(getAuthPath());
106
302
  }
107
303
  function loadAuth() {
108
304
  try {
109
305
  const authPath = getAuthPath();
110
- if (!fs.existsSync(authPath)) {
306
+ if (!fs2.existsSync(authPath)) {
111
307
  return null;
112
308
  }
113
- const data = fs.readFileSync(authPath, "utf8");
309
+ const data = fs2.readFileSync(authPath, "utf8");
114
310
  return JSON.parse(data);
115
311
  } catch {
116
312
  return null;
@@ -118,25 +314,25 @@ function loadAuth() {
118
314
  }
119
315
  function saveAuth(data) {
120
316
  const authPath = getAuthPath();
121
- fs.mkdirSync(path.dirname(authPath), { recursive: true });
122
- fs.writeFileSync(authPath, JSON.stringify(data, null, 2), "utf8");
317
+ fs2.mkdirSync(path2.dirname(authPath), { recursive: true });
318
+ fs2.writeFileSync(authPath, JSON.stringify(data, null, 2), "utf8");
123
319
  }
124
320
  function clearAuth() {
125
321
  const authPath = getAuthPath();
126
- if (fs.existsSync(authPath)) {
127
- fs.unlinkSync(authPath);
322
+ if (fs2.existsSync(authPath)) {
323
+ fs2.unlinkSync(authPath);
128
324
  }
129
325
  }
130
326
  function projectConfigExists() {
131
- return fs.existsSync(getProjectConfigPath());
327
+ return fs2.existsSync(getProjectConfigPath());
132
328
  }
133
329
  function loadProjectConfig() {
134
330
  try {
135
331
  const configPath = getProjectConfigPath();
136
- if (!fs.existsSync(configPath)) {
332
+ if (!fs2.existsSync(configPath)) {
137
333
  return null;
138
334
  }
139
- const data = fs.readFileSync(configPath, "utf8");
335
+ const data = fs2.readFileSync(configPath, "utf8");
140
336
  return JSON.parse(data);
141
337
  } catch {
142
338
  return null;
@@ -145,51 +341,51 @@ function loadProjectConfig() {
145
341
  function saveProjectConfig(data) {
146
342
  const configDir = getProjectConfigDir();
147
343
  const configPath = getProjectConfigPath();
148
- fs.mkdirSync(configDir, { recursive: true });
149
- fs.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf8");
344
+ fs2.mkdirSync(configDir, { recursive: true });
345
+ fs2.writeFileSync(configPath, JSON.stringify(data, null, 2), "utf8");
150
346
  }
151
347
  function clearProjectConfig() {
152
348
  const configDir = getProjectConfigDir();
153
- if (fs.existsSync(configDir)) {
154
- fs.rmSync(configDir, { recursive: true, force: true });
349
+ if (fs2.existsSync(configDir)) {
350
+ fs2.rmSync(configDir, { recursive: true, force: true });
155
351
  }
156
352
  }
157
353
 
158
354
  // src/commands/info.ts
159
- var infoCommand = new import_commander.Command("info").description("Display information about the current project").action(async () => {
160
- console.log(import_chalk.default.bold("\n\u{1F4E6} Project Information\n"));
355
+ var infoCommand = new import_commander2.Command("info").description("Display information about the current project").action(async () => {
356
+ console.log(import_chalk3.default.bold("\n\u{1F4E6} Project Information\n"));
161
357
  if (!authExists()) {
162
- console.log(import_chalk.default.yellow("Authentication: Not logged in"));
163
- console.log(import_chalk.default.dim("Run `commet login` to authenticate\n"));
358
+ console.log(import_chalk3.default.yellow("Authentication: Not logged in"));
359
+ console.log(import_chalk3.default.dim("Run `commet login` to authenticate\n"));
164
360
  return;
165
361
  }
166
- console.log(import_chalk.default.green("Authentication: Logged in \u2713"));
362
+ console.log(import_chalk3.default.green("Authentication: Logged in \u2713"));
167
363
  if (!projectConfigExists()) {
168
- console.log(import_chalk.default.yellow("\nProject: Not linked"));
364
+ console.log(import_chalk3.default.yellow("\nProject: Not linked"));
169
365
  console.log(
170
- import_chalk.default.dim("Run `commet link` to connect to an organization\n")
366
+ import_chalk3.default.dim("Run `commet link` to connect to an organization\n")
171
367
  );
172
368
  return;
173
369
  }
174
370
  const projectConfig = loadProjectConfig();
175
371
  if (!projectConfig) {
176
- console.log(import_chalk.default.red("\nProject: Invalid configuration"));
372
+ console.log(import_chalk3.default.red("\nProject: Invalid configuration"));
177
373
  return;
178
374
  }
179
- console.log(import_chalk.default.green("\nProject: Linked \u2713"));
180
- console.log(import_chalk.default.dim(" Organization:"), projectConfig.orgName);
181
- console.log(import_chalk.default.dim(" Organization ID:"), projectConfig.orgId);
182
- console.log(import_chalk.default.dim(" Environment:"), projectConfig.environment);
375
+ console.log(import_chalk3.default.green("\nProject: Linked \u2713"));
376
+ console.log(import_chalk3.default.dim(" Organization:"), projectConfig.orgName);
377
+ console.log(import_chalk3.default.dim(" Organization ID:"), projectConfig.orgId);
378
+ console.log(import_chalk3.default.dim(" Environment:"), projectConfig.environment);
183
379
  console.log(
184
- import_chalk.default.dim("\nRun `commet pull` to generate type definitions\n")
380
+ import_chalk3.default.dim("\nRun `commet pull` to generate type definitions\n")
185
381
  );
186
382
  });
187
383
 
188
384
  // src/commands/link.ts
189
- var import_prompts = require("@inquirer/prompts");
190
- var import_chalk3 = __toESM(require("chalk"));
191
- var import_commander2 = require("commander");
192
- var import_ora = __toESM(require("ora"));
385
+ var import_prompts2 = require("@inquirer/prompts");
386
+ var import_chalk4 = __toESM(require("chalk"));
387
+ var import_commander3 = require("commander");
388
+ var import_ora2 = __toESM(require("ora"));
193
389
 
194
390
  // src/utils/api.ts
195
391
  function getBaseURL(environment) {
@@ -228,15 +424,15 @@ async function apiRequest(endpoint, options = {}) {
228
424
  }
229
425
 
230
426
  // src/utils/gitignore-updater.ts
231
- var fs2 = __toESM(require("fs"));
232
- var path2 = __toESM(require("path"));
427
+ var fs3 = __toESM(require("fs"));
428
+ var path3 = __toESM(require("path"));
233
429
  function updateGitignore(entry) {
234
430
  const cwd = process.cwd();
235
- const gitignorePath = path2.join(cwd, ".gitignore");
431
+ const gitignorePath = path3.join(cwd, ".gitignore");
236
432
  try {
237
433
  let content = "";
238
- if (fs2.existsSync(gitignorePath)) {
239
- content = fs2.readFileSync(gitignorePath, "utf8");
434
+ if (fs3.existsSync(gitignorePath)) {
435
+ content = fs3.readFileSync(gitignorePath, "utf8");
240
436
  const lines = content.split("\n");
241
437
  for (const line of lines) {
242
438
  const trimmed = line.trim();
@@ -250,7 +446,7 @@ function updateGitignore(entry) {
250
446
  }
251
447
  content += `${entry}
252
448
  `;
253
- fs2.writeFileSync(gitignorePath, content, "utf8");
449
+ fs3.writeFileSync(gitignorePath, content, "utf8");
254
450
  return { success: true };
255
451
  } catch (error) {
256
452
  return {
@@ -260,48 +456,31 @@ function updateGitignore(entry) {
260
456
  }
261
457
  }
262
458
 
263
- // src/utils/prompt-theme.ts
264
- var import_chalk2 = __toESM(require("chalk"));
265
- var commetColor = import_chalk2.default.hex("#5BC0B0");
266
- var promptTheme = {
267
- prefix: commetColor("\u276F"),
268
- style: {
269
- answer: commetColor,
270
- message: import_chalk2.default.bold,
271
- error: import_chalk2.default.red,
272
- help: import_chalk2.default.dim,
273
- highlight: commetColor.bold,
274
- // Selected option in mint
275
- description: import_chalk2.default.dim,
276
- defaultAnswer: import_chalk2.default.dim
277
- }
278
- };
279
-
280
459
  // src/commands/link.ts
281
- var linkCommand = new import_commander2.Command("link").description("Link this project to a Commet organization").action(async () => {
460
+ var linkCommand = new import_commander3.Command("link").description("Link this project to a Commet organization").action(async () => {
282
461
  if (!authExists()) {
283
- console.log(import_chalk3.default.red("\u2717 Not authenticated"));
284
- console.log(import_chalk3.default.dim("Run `commet login` first"));
462
+ console.log(import_chalk4.default.red("\u2717 Not authenticated"));
463
+ console.log(import_chalk4.default.dim("Run `commet login` first"));
285
464
  return;
286
465
  }
287
466
  if (projectConfigExists()) {
288
467
  const config = loadProjectConfig();
289
- console.log(import_chalk3.default.yellow("\u26A0 This project is already linked"));
468
+ console.log(import_chalk4.default.yellow("\u26A0 This project is already linked"));
290
469
  console.log(
291
- import_chalk3.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
470
+ import_chalk4.default.dim(`Organization: ${config?.orgName} (${config?.environment})`)
292
471
  );
293
472
  console.log(
294
- import_chalk3.default.dim(
473
+ import_chalk4.default.dim(
295
474
  "\nRun `commet unlink` first if you want to change the organization"
296
475
  )
297
476
  );
298
477
  return;
299
478
  }
300
- const spinner = (0, import_ora.default)("Fetching organizations...").start();
479
+ const spinner = (0, import_ora2.default)("Fetching organizations...").start();
301
480
  const auth = loadAuth();
302
481
  if (!auth) {
303
482
  spinner.fail("Authentication error");
304
- console.log(import_chalk3.default.red("\u2717 Could not load authentication"));
483
+ console.log(import_chalk4.default.red("\u2717 Could not load authentication"));
305
484
  return;
306
485
  }
307
486
  const baseURL = getBaseURL(auth.environment);
@@ -310,36 +489,36 @@ var linkCommand = new import_commander2.Command("link").description("Link this p
310
489
  );
311
490
  if (result.error || !result.data) {
312
491
  spinner.fail("Failed to fetch organizations");
313
- console.error(import_chalk3.default.red("Error:"), result.error);
492
+ console.error(import_chalk4.default.red("Error:"), result.error);
314
493
  return;
315
494
  }
316
495
  const { organizations } = result.data;
317
496
  if (organizations.length === 0) {
318
497
  spinner.stop();
319
- console.log(import_chalk3.default.yellow("\u26A0 No organizations found"));
498
+ console.log(import_chalk4.default.yellow("\u26A0 No organizations found"));
320
499
  console.log(
321
- import_chalk3.default.dim("Create an organization at https://commet.co first")
500
+ import_chalk4.default.dim("Create an organization at https://commet.co first")
322
501
  );
323
502
  return;
324
503
  }
325
504
  spinner.stop();
326
505
  let orgId;
327
506
  try {
328
- orgId = await (0, import_prompts.select)({
507
+ orgId = await (0, import_prompts2.select)({
329
508
  message: "Select organization:",
330
509
  choices: organizations.map((org) => ({
331
- name: `${org.name} ${import_chalk3.default.dim(`(${org.slug})`)}`,
510
+ name: `${org.name} ${import_chalk4.default.dim(`(${org.slug})`)}`,
332
511
  value: org.id
333
512
  })),
334
513
  theme: promptTheme
335
514
  });
336
515
  } catch (error) {
337
- console.log(import_chalk3.default.yellow("\n\u26A0 Link cancelled"));
516
+ console.log(import_chalk4.default.yellow("\n\u26A0 Link cancelled"));
338
517
  return;
339
518
  }
340
519
  const selectedOrg = organizations.find((org) => org.id === orgId);
341
520
  if (!selectedOrg) {
342
- console.log(import_chalk3.default.red("\u2717 Organization not found"));
521
+ console.log(import_chalk4.default.red("\u2717 Organization not found"));
343
522
  return;
344
523
  }
345
524
  saveProjectConfig({
@@ -348,97 +527,119 @@ var linkCommand = new import_commander2.Command("link").description("Link this p
348
527
  environment: auth.environment
349
528
  });
350
529
  const gitignoreResult = updateGitignore(".commet/");
351
- console.log(import_chalk3.default.green("\n\u2713 Project linked successfully"));
352
- console.log(import_chalk3.default.dim(`Organization: ${selectedOrg.name}`));
353
- console.log(import_chalk3.default.dim(`Environment: ${auth.environment}`));
530
+ console.log(import_chalk4.default.green("\n\u2713 Project linked successfully"));
531
+ console.log(import_chalk4.default.dim(`Organization: ${selectedOrg.name}`));
532
+ console.log(import_chalk4.default.dim(`Environment: ${auth.environment}`));
354
533
  if (gitignoreResult.success) {
355
- console.log(import_chalk3.default.green("\u2713 Updated .gitignore"));
534
+ console.log(import_chalk4.default.green("\u2713 Updated .gitignore"));
356
535
  } else {
357
- console.log(import_chalk3.default.yellow("\u26A0 No .gitignore found"));
358
- console.log(import_chalk3.default.dim("Add .commet/ to your .gitignore file"));
536
+ console.log(import_chalk4.default.yellow("\u26A0 No .gitignore found"));
537
+ console.log(import_chalk4.default.dim("Add .commet/ to your .gitignore file"));
359
538
  }
360
- console.log(import_chalk3.default.dim("\nRun 'commet pull' to generate TypeScript types"));
539
+ console.log(import_chalk4.default.dim("\nRun 'commet pull' to generate TypeScript types"));
361
540
  });
362
541
 
363
542
  // src/commands/list.ts
364
- var import_chalk4 = __toESM(require("chalk"));
365
- var import_commander3 = require("commander");
366
- var import_ora2 = __toESM(require("ora"));
367
- var listCommand = new import_commander3.Command("list").description("List event types or seat types").argument("<type>", "Type to list (events or seats)").action(async (type) => {
368
- if (type !== "events" && type !== "seats") {
369
- console.log(import_chalk4.default.red('\u2717 Invalid type. Use "events" or "seats"'));
370
- console.log(import_chalk4.default.dim("\nExamples:"));
371
- console.log(import_chalk4.default.dim(" commet list events"));
372
- console.log(import_chalk4.default.dim(" commet list seats"));
543
+ var import_chalk5 = __toESM(require("chalk"));
544
+ var import_commander4 = require("commander");
545
+ var import_ora3 = __toESM(require("ora"));
546
+ var validTypes = ["features", "seats", "plans"];
547
+ var listCommand = new import_commander4.Command("list").description("List features, seat types, or plans").argument("<type>", "Type to list (features, seats, or plans)").action(async (type) => {
548
+ if (!validTypes.includes(type)) {
549
+ console.log(
550
+ import_chalk5.default.red('\u2717 Invalid type. Use "features", "seats", or "plans"')
551
+ );
552
+ console.log(import_chalk5.default.dim("\nExamples:"));
553
+ console.log(import_chalk5.default.dim(" commet list features"));
554
+ console.log(import_chalk5.default.dim(" commet list seats"));
555
+ console.log(import_chalk5.default.dim(" commet list plans"));
373
556
  return;
374
557
  }
375
558
  if (!authExists()) {
376
- console.log(import_chalk4.default.red("\u2717 Not authenticated"));
377
- console.log(import_chalk4.default.dim("Run `commet login` first"));
559
+ console.log(import_chalk5.default.red("\u2717 Not authenticated"));
560
+ console.log(import_chalk5.default.dim("Run `commet login` first"));
378
561
  return;
379
562
  }
380
563
  if (!projectConfigExists()) {
381
- console.log(import_chalk4.default.red("\u2717 Project not linked"));
564
+ console.log(import_chalk5.default.red("\u2717 Project not linked"));
382
565
  console.log(
383
- import_chalk4.default.dim("Run `commet link` first to connect to an organization")
566
+ import_chalk5.default.dim("Run `commet link` first to connect to an organization")
384
567
  );
385
568
  return;
386
569
  }
387
570
  const projectConfig = loadProjectConfig();
388
571
  if (!projectConfig) {
389
- console.log(import_chalk4.default.red("\u2717 Invalid project configuration"));
572
+ console.log(import_chalk5.default.red("\u2717 Invalid project configuration"));
390
573
  return;
391
574
  }
392
- const spinner = (0, import_ora2.default)(`Fetching ${type}...`).start();
575
+ const spinner = (0, import_ora3.default)(`Fetching ${type}...`).start();
393
576
  const baseURL = getBaseURL(projectConfig.environment);
394
577
  const result = await apiRequest(
395
578
  `${baseURL}/api/cli/types?orgId=${projectConfig.orgId}`
396
579
  );
397
580
  if (result.error || !result.data) {
398
581
  spinner.fail(`Failed to fetch ${type}`);
399
- console.error(import_chalk4.default.red("Error:"), result.error);
582
+ console.error(import_chalk5.default.red("Error:"), result.error);
400
583
  return;
401
584
  }
402
585
  spinner.stop();
403
- if (type === "events") {
404
- const { eventTypes } = result.data;
405
- if (eventTypes.length === 0) {
406
- console.log(import_chalk4.default.yellow("\u26A0 No event types found"));
586
+ if (type === "features") {
587
+ const { features } = result.data;
588
+ if (features.length === 0) {
589
+ console.log(import_chalk5.default.yellow("\u26A0 No features found"));
407
590
  console.log(
408
- import_chalk4.default.dim("Create event types in your Commet dashboard first")
591
+ import_chalk5.default.dim("Create features in your Commet dashboard first")
409
592
  );
410
593
  return;
411
594
  }
412
- console.log(import_chalk4.default.bold(`
413
- \u{1F4CA} Event Types (${eventTypes.length})
595
+ console.log(import_chalk5.default.bold(`
596
+ \u{1F4CA} Features (${features.length})
414
597
  `));
415
- for (const eventType of eventTypes) {
416
- console.log(import_chalk4.default.green(`\u2022 ${eventType.code}`));
417
- console.log(import_chalk4.default.dim(` ${eventType.name}`));
418
- if (eventType.description) {
419
- console.log(import_chalk4.default.dim(` ${eventType.description}`));
598
+ for (const feature of features) {
599
+ console.log(import_chalk5.default.green(`\u2022 ${feature.code} (${feature.type})`));
600
+ console.log(import_chalk5.default.dim(` ${feature.name}`));
601
+ if (feature.description) {
602
+ console.log(import_chalk5.default.dim(` ${feature.description}`));
420
603
  }
421
604
  console.log("");
422
605
  }
423
- } else {
606
+ } else if (type === "seats") {
424
607
  const { seatTypes } = result.data;
425
608
  if (seatTypes.length === 0) {
426
- console.log(import_chalk4.default.yellow("\u26A0 No seat types found"));
609
+ console.log(import_chalk5.default.yellow("\u26A0 No seat types found"));
427
610
  console.log(
428
- import_chalk4.default.dim("Create seat types in your Commet dashboard first")
611
+ import_chalk5.default.dim("Create seat types in your Commet dashboard first")
429
612
  );
430
613
  return;
431
614
  }
432
- console.log(import_chalk4.default.bold(`
615
+ console.log(import_chalk5.default.bold(`
433
616
  \u{1F4BA} Seat Types (${seatTypes.length})
434
617
  `));
435
618
  for (const seatType of seatTypes) {
436
619
  console.log(
437
- import_chalk4.default.green(`\u2022 ${seatType.code}${seatType.isFree ? " (Free)" : ""}`)
620
+ import_chalk5.default.green(`\u2022 ${seatType.code}${seatType.isFree ? " (Free)" : ""}`)
438
621
  );
439
- console.log(import_chalk4.default.dim(` ${seatType.name}`));
622
+ console.log(import_chalk5.default.dim(` ${seatType.name}`));
440
623
  if (seatType.description) {
441
- console.log(import_chalk4.default.dim(` ${seatType.description}`));
624
+ console.log(import_chalk5.default.dim(` ${seatType.description}`));
625
+ }
626
+ console.log("");
627
+ }
628
+ } else {
629
+ const { plans } = result.data;
630
+ if (plans.length === 0) {
631
+ console.log(import_chalk5.default.yellow("\u26A0 No plans found"));
632
+ console.log(import_chalk5.default.dim("Create plans in your Commet dashboard first"));
633
+ return;
634
+ }
635
+ console.log(import_chalk5.default.bold(`
636
+ \u{1F4CB} Plans (${plans.length})
637
+ `));
638
+ for (const plan of plans) {
639
+ console.log(import_chalk5.default.green(`\u2022 ${plan.code}`));
640
+ console.log(import_chalk5.default.dim(` ${plan.name}`));
641
+ if (plan.description) {
642
+ console.log(import_chalk5.default.dim(` ${plan.description}`));
442
643
  }
443
644
  console.log("");
444
645
  }
@@ -446,17 +647,17 @@ var listCommand = new import_commander3.Command("list").description("List event
446
647
  });
447
648
 
448
649
  // src/commands/login.ts
449
- var import_prompts2 = require("@inquirer/prompts");
450
- var import_chalk5 = __toESM(require("chalk"));
451
- var import_commander4 = require("commander");
650
+ var import_prompts3 = require("@inquirer/prompts");
651
+ var import_chalk6 = __toESM(require("chalk"));
652
+ var import_commander5 = require("commander");
452
653
  var import_open = __toESM(require("open"));
453
- var import_ora3 = __toESM(require("ora"));
454
- var loginCommand = new import_commander4.Command("login").description("Authenticate with Commet").action(async () => {
654
+ var import_ora4 = __toESM(require("ora"));
655
+ var loginCommand = new import_commander5.Command("login").description("Authenticate with Commet").action(async () => {
455
656
  if (authExists()) {
456
657
  const auth = loadAuth();
457
- console.log(import_chalk5.default.yellow("\u26A0 You are already logged in."));
658
+ console.log(import_chalk6.default.yellow("\u26A0 You are already logged in."));
458
659
  console.log(
459
- import_chalk5.default.dim(
660
+ import_chalk6.default.dim(
460
661
  "Run `commet logout` first if you want to login with a different account."
461
662
  )
462
663
  );
@@ -464,11 +665,11 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
464
665
  }
465
666
  let environment;
466
667
  try {
467
- environment = await (0, import_prompts2.select)({
668
+ environment = await (0, import_prompts3.select)({
468
669
  message: "Select environment to login:",
469
670
  choices: [
470
671
  {
471
- name: `Sandbox ${import_chalk5.default.dim("(Development)")}`,
672
+ name: `Sandbox ${import_chalk6.default.dim("(Development)")}`,
472
673
  value: "sandbox"
473
674
  },
474
675
  {
@@ -480,10 +681,10 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
480
681
  theme: promptTheme
481
682
  });
482
683
  } catch (error) {
483
- console.log(import_chalk5.default.yellow("\n\u26A0 Login cancelled"));
684
+ console.log(import_chalk6.default.yellow("\n\u26A0 Login cancelled"));
484
685
  return;
485
686
  }
486
- const spinner = (0, import_ora3.default)("Initiating login flow...").start();
687
+ const spinner = (0, import_ora4.default)("Initiating login flow...").start();
487
688
  const baseURL = getBaseURL(environment);
488
689
  try {
489
690
  const deviceResponse = await fetch(`${baseURL}/api/auth/device/code`, {
@@ -496,7 +697,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
496
697
  });
497
698
  if (!deviceResponse.ok) {
498
699
  spinner.fail("Failed to initiate login");
499
- console.error(import_chalk5.default.red("Error:"), await deviceResponse.text());
700
+ console.error(import_chalk6.default.red("Error:"), await deviceResponse.text());
500
701
  return;
501
702
  }
502
703
  const deviceData = await deviceResponse.json();
@@ -507,25 +708,25 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
507
708
  interval = 5
508
709
  } = deviceData;
509
710
  spinner.stop();
510
- console.log(import_chalk5.default.bold("\n\u{1F510} Commet CLI Login\n"));
711
+ console.log(import_chalk6.default.bold("\n\u{1F510} Commet CLI Login\n"));
511
712
  console.log("Visit the following URL in your browser:");
512
- console.log(import_chalk5.default.cyan.underline(verification_uri_complete));
713
+ console.log(import_chalk6.default.cyan.underline(verification_uri_complete));
513
714
  console.log("\nOr enter this code manually:");
514
- console.log(import_chalk5.default.bold.green(` ${user_code}`));
515
- console.log(import_chalk5.default.dim("\nOpening browser...\n"));
715
+ console.log(import_chalk6.default.bold.green(` ${user_code}`));
716
+ console.log(import_chalk6.default.dim("\nOpening browser...\n"));
516
717
  try {
517
718
  await (0, import_open.default)(verification_uri_complete);
518
719
  } catch {
519
- console.log(import_chalk5.default.yellow("\u26A0 Could not open browser automatically."));
720
+ console.log(import_chalk6.default.yellow("\u26A0 Could not open browser automatically."));
520
721
  }
521
- const pollSpinner = (0, import_ora3.default)("Waiting for authorization...").start();
722
+ const pollSpinner = (0, import_ora4.default)("Waiting for authorization...").start();
522
723
  let pollingInterval = interval;
523
724
  let attempts = 0;
524
725
  const maxAttempts = 180 / pollingInterval;
525
726
  const poll = async () => {
526
727
  if (attempts >= maxAttempts) {
527
728
  pollSpinner.fail("Login timed out");
528
- console.log(import_chalk5.default.red("Authorization timed out. Please try again."));
729
+ console.log(import_chalk6.default.red("Authorization timed out. Please try again."));
529
730
  return;
530
731
  }
531
732
  attempts++;
@@ -556,9 +757,9 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
556
757
  }
557
758
  saveAuth(authConfig);
558
759
  pollSpinner.succeed("Successfully logged in!");
559
- console.log(import_chalk5.default.green("\n\u2713 Authentication complete"));
760
+ console.log(import_chalk6.default.green("\n\u2713 Authentication complete"));
560
761
  console.log(
561
- import_chalk5.default.dim(
762
+ import_chalk6.default.dim(
562
763
  "\nNext steps:\n 1. Run `commet link` to connect a project\n 2. Run `commet pull` to generate types\n"
563
764
  )
564
765
  );
@@ -571,12 +772,12 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
571
772
  setTimeout(() => poll(), pollingInterval * 1e3);
572
773
  } else if (tokenData.error === "access_denied") {
573
774
  pollSpinner.fail("Authorization denied");
574
- console.log(import_chalk5.default.red("\n\u2717 You denied the authorization request."));
775
+ console.log(import_chalk6.default.red("\n\u2717 You denied the authorization request."));
575
776
  return;
576
777
  } else if (tokenData.error === "expired_token") {
577
778
  pollSpinner.fail("Code expired");
578
779
  console.log(
579
- import_chalk5.default.red(
780
+ import_chalk6.default.red(
580
781
  "\n\u2717 The authorization code expired. Please try again."
581
782
  )
582
783
  );
@@ -584,7 +785,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
584
785
  } else {
585
786
  pollSpinner.fail("Authorization failed");
586
787
  console.log(
587
- import_chalk5.default.red("\n\u2717 Error:"),
788
+ import_chalk6.default.red("\n\u2717 Error:"),
588
789
  tokenData.error || "Unknown error"
589
790
  );
590
791
  return;
@@ -592,7 +793,7 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
592
793
  } catch (error) {
593
794
  pollSpinner.fail("Network error");
594
795
  console.error(
595
- import_chalk5.default.red("Error:"),
796
+ import_chalk6.default.red("Error:"),
596
797
  error instanceof Error ? error.message : "Unknown error"
597
798
  );
598
799
  }
@@ -601,42 +802,42 @@ var loginCommand = new import_commander4.Command("login").description("Authentic
601
802
  } catch (error) {
602
803
  spinner.fail("Login failed");
603
804
  console.error(
604
- import_chalk5.default.red("Error:"),
805
+ import_chalk6.default.red("Error:"),
605
806
  error instanceof Error ? error.message : "Unknown error"
606
807
  );
607
808
  }
608
809
  });
609
810
 
610
811
  // src/commands/logout.ts
611
- var import_chalk6 = __toESM(require("chalk"));
612
- var import_commander5 = require("commander");
613
- var logoutCommand = new import_commander5.Command("logout").description("Log out of Commet").action(async () => {
812
+ var import_chalk7 = __toESM(require("chalk"));
813
+ var import_commander6 = require("commander");
814
+ var logoutCommand = new import_commander6.Command("logout").description("Log out of Commet").action(async () => {
614
815
  if (!authExists()) {
615
- console.log(import_chalk6.default.yellow("\u26A0 You are not logged in."));
816
+ console.log(import_chalk7.default.yellow("\u26A0 You are not logged in."));
616
817
  return;
617
818
  }
618
819
  clearAuth();
619
- console.log(import_chalk6.default.green("\u2713 Successfully logged out"));
820
+ console.log(import_chalk7.default.green("\u2713 Successfully logged out"));
620
821
  });
621
822
 
622
823
  // src/commands/pull.ts
623
- var fs5 = __toESM(require("fs"));
624
- var path5 = __toESM(require("path"));
625
- var import_chalk7 = __toESM(require("chalk"));
626
- var import_commander6 = require("commander");
627
- var import_ora4 = __toESM(require("ora"));
824
+ var fs6 = __toESM(require("fs"));
825
+ var path6 = __toESM(require("path"));
826
+ var import_chalk8 = __toESM(require("chalk"));
827
+ var import_commander7 = require("commander");
828
+ var import_ora5 = __toESM(require("ora"));
628
829
 
629
830
  // src/utils/environment-validator.ts
630
- var fs3 = __toESM(require("fs"));
631
- var path3 = __toESM(require("path"));
831
+ var fs4 = __toESM(require("fs"));
832
+ var path4 = __toESM(require("path"));
632
833
  function validateTypeScriptProject() {
633
834
  const cwd = process.cwd();
634
- const tsconfigPath = path3.join(cwd, "tsconfig.json");
635
- if (!fs3.existsSync(tsconfigPath)) {
835
+ const tsconfigPath = path4.join(cwd, "tsconfig.json");
836
+ if (!fs4.existsSync(tsconfigPath)) {
636
837
  return false;
637
838
  }
638
839
  try {
639
- const content = fs3.readFileSync(tsconfigPath, "utf8");
840
+ const content = fs4.readFileSync(tsconfigPath, "utf8");
640
841
  JSON.parse(content);
641
842
  return true;
642
843
  } catch (error) {
@@ -645,65 +846,63 @@ function validateTypeScriptProject() {
645
846
  }
646
847
 
647
848
  // src/utils/generator.ts
648
- function generateTypes(eventTypes, seatTypes, products) {
649
- const eventTypeUnion = eventTypes.length > 0 ? eventTypes.map((e) => `"${e.code}"`).join(" | ") : "string";
849
+ function generateTypes(seatTypes, features, plans) {
650
850
  const seatTypeUnion = seatTypes.length > 0 ? seatTypes.map((s) => `"${s.code}"`).join(" | ") : "string";
651
- const productTypeUnion = products.length > 0 ? products.map((p) => `"${p.publicId}"`).join(" | ") : "string";
652
- const eventComments = eventTypes.map(
653
- (e) => ` * - "${e.code}": ${e.name}${e.description ? ` - ${e.description}` : ""}`
654
- ).join("\n");
851
+ const planCodeUnion = plans.length > 0 ? plans.map((p) => `"${p.code}"`).join(" | ") : "string";
852
+ const featureCodeUnion = features.length > 0 ? features.map((f) => `"${f.code}"`).join(" | ") : "string";
655
853
  const seatComments = seatTypes.map(
656
854
  (s) => ` * - "${s.code}": ${s.name}${s.description ? ` - ${s.description}` : ""} ${s.isFree ? "(Free)" : ""}`
657
855
  ).join("\n");
658
- const productComments = products.map(
659
- (p) => ` * - "${p.publicId}": ${p.name}${p.description ? ` - ${p.description}` : ""}`
856
+ const planComments = plans.map(
857
+ (p) => ` * - "${p.code}": ${p.name}${p.description ? ` - ${p.description}` : ""}`
858
+ ).join("\n");
859
+ const featureComments = features.map(
860
+ (f) => ` * - "${f.code}": ${f.name} (${f.type})${f.description ? ` - ${f.description}` : ""}`
660
861
  ).join("\n");
661
862
  return `// Auto-generated by Commet CLI
662
863
  // Do not edit this file manually - run 'commet pull' to update
663
864
 
664
865
  /**
665
- * This augments the Commet SDK to automatically use your organization's
666
- * specific event types, seat types, and products without requiring generic type parameters.
667
- *
668
- * Event types available in your organization:
669
- ${eventComments || " * (none)"}
670
- *
866
+ * This augments the Commet SDK with your organization's
867
+ * feature codes, seat types, and plan codes for autocomplete.
868
+ *
869
+ * Features available in your organization:
870
+ ${featureComments || " * (none)"}
871
+ *
671
872
  * Seat types available in your organization:
672
873
  ${seatComments || " * (none)"}
673
- *
674
- * Products available in your organization:
675
- ${productComments || " * (none)"}
676
- *
677
- */
874
+ *
875
+ * Plans available in your organization:
876
+ ${planComments || " * (none)"}
877
+ *
878
+ */
678
879
  declare module '@commet/node' {
679
880
  interface CommetGeneratedTypes {
680
- eventType: ${eventTypeUnion};
681
881
  seatType: ${seatTypeUnion};
682
- productId: ${productTypeUnion};
882
+ planCode: ${planCodeUnion};
883
+ featureCode: ${featureCodeUnion};
683
884
  }
684
885
  }
685
886
 
686
- // This export is required for TypeScript to treat this file as a module
687
- // and apply the module augmentation above
688
887
  export {};
689
888
  `;
690
889
  }
691
890
 
692
891
  // src/utils/tsconfig-updater.ts
693
- var fs4 = __toESM(require("fs"));
694
- var path4 = __toESM(require("path"));
892
+ var fs5 = __toESM(require("fs"));
893
+ var path5 = __toESM(require("path"));
695
894
  var import_jsonc_parser = require("jsonc-parser");
696
895
  function updateTsConfig(entry) {
697
896
  const cwd = process.cwd();
698
- const tsconfigPath = path4.join(cwd, "tsconfig.json");
897
+ const tsconfigPath = path5.join(cwd, "tsconfig.json");
699
898
  try {
700
- if (!fs4.existsSync(tsconfigPath)) {
899
+ if (!fs5.existsSync(tsconfigPath)) {
701
900
  return {
702
901
  success: false,
703
902
  error: "tsconfig.json not found"
704
903
  };
705
904
  }
706
- const content = fs4.readFileSync(tsconfigPath, "utf8");
905
+ const content = fs5.readFileSync(tsconfigPath, "utf8");
707
906
  const config = (0, import_jsonc_parser.parse)(content);
708
907
  if (config.include && Array.isArray(config.include)) {
709
908
  if (config.include.includes(entry)) {
@@ -719,7 +918,7 @@ function updateTsConfig(entry) {
719
918
  }
720
919
  });
721
920
  const updatedContent = (0, import_jsonc_parser.applyEdits)(content, edits);
722
- fs4.writeFileSync(tsconfigPath, updatedContent, "utf8");
921
+ fs5.writeFileSync(tsconfigPath, updatedContent, "utf8");
723
922
  return { success: true };
724
923
  } catch (error) {
725
924
  return {
@@ -730,120 +929,120 @@ function updateTsConfig(entry) {
730
929
  }
731
930
 
732
931
  // src/commands/pull.ts
733
- var pullCommand = new import_commander6.Command("pull").description("Pull type definitions from Commet").action(async () => {
932
+ var pullCommand = new import_commander7.Command("pull").description("Pull type definitions from Commet").action(async () => {
734
933
  if (!authExists()) {
735
- console.log(import_chalk7.default.red("\u2717 Not authenticated"));
736
- console.log(import_chalk7.default.dim("Run `commet login` first"));
934
+ console.log(import_chalk8.default.red("\u2717 Not authenticated"));
935
+ console.log(import_chalk8.default.dim("Run `commet login` first"));
737
936
  return;
738
937
  }
739
938
  const hasTsConfig = validateTypeScriptProject();
740
939
  if (!projectConfigExists()) {
741
- console.log(import_chalk7.default.red("\u2717 Project not linked"));
940
+ console.log(import_chalk8.default.red("\u2717 Project not linked"));
742
941
  console.log(
743
- import_chalk7.default.dim("Run `commet link` first to connect to an organization")
942
+ import_chalk8.default.dim("Run `commet link` first to connect to an organization")
744
943
  );
745
944
  return;
746
945
  }
747
946
  const projectConfig = loadProjectConfig();
748
947
  if (!projectConfig) {
749
- console.log(import_chalk7.default.red("\u2717 Invalid project configuration"));
948
+ console.log(import_chalk8.default.red("\u2717 Invalid project configuration"));
750
949
  return;
751
950
  }
752
- const spinner = (0, import_ora4.default)("Fetching type definitions...").start();
951
+ const spinner = (0, import_ora5.default)("Fetching type definitions...").start();
753
952
  const baseURL = getBaseURL(projectConfig.environment);
754
953
  const result = await apiRequest(
755
954
  `${baseURL}/api/cli/types?orgId=${projectConfig.orgId}`
756
955
  );
757
956
  if (result.error || !result.data) {
758
957
  spinner.fail("Failed to fetch types");
759
- console.error(import_chalk7.default.red("Error:"), result.error);
958
+ console.error(import_chalk8.default.red("Error:"), result.error);
760
959
  return;
761
960
  }
762
- const { eventTypes, seatTypes, products } = result.data;
763
- const typeDefinitions = generateTypes(eventTypes, seatTypes, products);
764
- const commetDir = path5.resolve(process.cwd(), ".commet");
765
- const outputPath = path5.join(commetDir, "types.d.ts");
766
- fs5.mkdirSync(commetDir, { recursive: true });
767
- fs5.writeFileSync(outputPath, typeDefinitions, "utf8");
961
+ const { seatTypes, features, plans } = result.data;
962
+ const typeDefinitions = generateTypes(seatTypes, features, plans);
963
+ const commetDir = path6.resolve(process.cwd(), ".commet");
964
+ const outputPath = path6.join(commetDir, "types.d.ts");
965
+ fs6.mkdirSync(commetDir, { recursive: true });
966
+ fs6.writeFileSync(outputPath, typeDefinitions, "utf8");
768
967
  spinner.succeed("Type definitions generated!");
769
968
  if (hasTsConfig) {
770
969
  const tsconfigResult = updateTsConfig(".commet/types.d.ts");
771
970
  if (tsconfigResult.success) {
772
- console.log(import_chalk7.default.green("\u2713 Updated tsconfig.json"));
971
+ console.log(import_chalk8.default.green("\u2713 Updated tsconfig.json"));
773
972
  } else {
774
- console.log(import_chalk7.default.yellow("\u26A0 Could not update tsconfig.json"));
973
+ console.log(import_chalk8.default.yellow("\u26A0 Could not update tsconfig.json"));
775
974
  console.log(
776
- import_chalk7.default.dim(
975
+ import_chalk8.default.dim(
777
976
  'Add ".commet/types.d.ts" to your tsconfig.json include array'
778
977
  )
779
978
  );
780
979
  }
781
980
  } else {
782
- console.log(import_chalk7.default.yellow("\u26A0 No tsconfig.json found"));
981
+ console.log(import_chalk8.default.yellow("\u26A0 No tsconfig.json found"));
783
982
  console.log(
784
- import_chalk7.default.dim(
983
+ import_chalk8.default.dim(
785
984
  'Add ".commet/types.d.ts" to your tsconfig.json to enable types'
786
985
  )
787
986
  );
788
987
  }
789
988
  const gitignoreResult = updateGitignore(".commet/");
790
989
  if (gitignoreResult.success) {
791
- console.log(import_chalk7.default.green("\u2713 Updated .gitignore"));
990
+ console.log(import_chalk8.default.green("\u2713 Updated .gitignore"));
792
991
  } else {
793
- console.log(import_chalk7.default.yellow("\u26A0 No .gitignore found"));
794
- console.log(import_chalk7.default.dim("Add .commet/ to your .gitignore file"));
992
+ console.log(import_chalk8.default.yellow("\u26A0 No .gitignore found"));
993
+ console.log(import_chalk8.default.dim("Add .commet/ to your .gitignore file"));
795
994
  }
796
- console.log(import_chalk7.default.green("\nSuccess!"));
797
- console.log(import_chalk7.default.dim("\nGenerated types:"));
995
+ console.log(import_chalk8.default.green("\nSuccess!"));
996
+ console.log(import_chalk8.default.dim("\nGenerated types:"));
798
997
  console.log(
799
- import_chalk7.default.dim(
800
- ` Event types: ${eventTypes.length > 0 ? eventTypes.map((e) => e.code).join(", ") : "none"}`
998
+ import_chalk8.default.dim(
999
+ ` Features: ${features.length > 0 ? features.map((f) => f.code).join(", ") : "none"}`
801
1000
  )
802
1001
  );
803
1002
  console.log(
804
- import_chalk7.default.dim(
1003
+ import_chalk8.default.dim(
805
1004
  ` Seat types: ${seatTypes.length > 0 ? seatTypes.map((s) => s.code).join(", ") : "none"}`
806
1005
  )
807
1006
  );
808
1007
  console.log(
809
- import_chalk7.default.dim(
810
- ` Products: ${products.length > 0 ? products.map((p) => p.publicId).join(", ") : "none"}`
1008
+ import_chalk8.default.dim(
1009
+ ` Plans: ${plans.length > 0 ? plans.map((p) => p.code).join(", ") : "none"}`
811
1010
  )
812
1011
  );
813
- console.log(import_chalk7.default.dim(`
1012
+ console.log(import_chalk8.default.dim(`
814
1013
  Output: ${outputPath}`));
815
- if (eventTypes.length === 0 && seatTypes.length === 0 && products.length === 0) {
1014
+ if (seatTypes.length === 0 && plans.length === 0 && features.length === 0) {
816
1015
  console.log(
817
- import_chalk7.default.yellow(
818
- "\n\u26A0 No types found. Create event types, seat types, and products in your Commet dashboard."
1016
+ import_chalk8.default.yellow(
1017
+ "\n\u26A0 No types found. Create features, seat types, and plans in your Commet dashboard."
819
1018
  )
820
1019
  );
821
1020
  }
822
1021
  });
823
1022
 
824
1023
  // src/commands/switch.ts
825
- var import_prompts3 = require("@inquirer/prompts");
826
- var import_chalk8 = __toESM(require("chalk"));
827
- var import_commander7 = require("commander");
828
- var import_ora5 = __toESM(require("ora"));
829
- var switchCommand = new import_commander7.Command("switch").description("Switch to a different organization").action(async () => {
1024
+ var import_prompts4 = require("@inquirer/prompts");
1025
+ var import_chalk9 = __toESM(require("chalk"));
1026
+ var import_commander8 = require("commander");
1027
+ var import_ora6 = __toESM(require("ora"));
1028
+ var switchCommand = new import_commander8.Command("switch").description("Switch to a different organization").action(async () => {
830
1029
  if (!authExists()) {
831
- console.log(import_chalk8.default.red("\u2717 Not authenticated"));
832
- console.log(import_chalk8.default.dim("Run `commet login` first"));
1030
+ console.log(import_chalk9.default.red("\u2717 Not authenticated"));
1031
+ console.log(import_chalk9.default.dim("Run `commet login` first"));
833
1032
  return;
834
1033
  }
835
1034
  if (!projectConfigExists()) {
836
- console.log(import_chalk8.default.yellow("\u26A0 Project not linked"));
1035
+ console.log(import_chalk9.default.yellow("\u26A0 Project not linked"));
837
1036
  console.log(
838
- import_chalk8.default.dim("Run `commet link` first to connect to an organization")
1037
+ import_chalk9.default.dim("Run `commet link` first to connect to an organization")
839
1038
  );
840
1039
  return;
841
1040
  }
842
- const spinner = (0, import_ora5.default)("Fetching organizations...").start();
1041
+ const spinner = (0, import_ora6.default)("Fetching organizations...").start();
843
1042
  const auth = loadAuth();
844
1043
  if (!auth) {
845
1044
  spinner.fail("Authentication error");
846
- console.log(import_chalk8.default.red("\u2717 Could not load authentication"));
1045
+ console.log(import_chalk9.default.red("\u2717 Could not load authentication"));
847
1046
  return;
848
1047
  }
849
1048
  const baseURL = getBaseURL(auth.environment);
@@ -852,33 +1051,33 @@ var switchCommand = new import_commander7.Command("switch").description("Switch
852
1051
  );
853
1052
  if (result.error || !result.data) {
854
1053
  spinner.fail("Failed to fetch organizations");
855
- console.error(import_chalk8.default.red("Error:"), result.error);
1054
+ console.error(import_chalk9.default.red("Error:"), result.error);
856
1055
  return;
857
1056
  }
858
1057
  const { organizations } = result.data;
859
1058
  if (organizations.length === 0) {
860
1059
  spinner.stop();
861
- console.log(import_chalk8.default.yellow("\u26A0 No organizations found"));
1060
+ console.log(import_chalk9.default.yellow("\u26A0 No organizations found"));
862
1061
  return;
863
1062
  }
864
1063
  spinner.stop();
865
1064
  let orgId;
866
1065
  try {
867
- orgId = await (0, import_prompts3.select)({
1066
+ orgId = await (0, import_prompts4.select)({
868
1067
  message: "Select organization:",
869
1068
  choices: organizations.map((org) => ({
870
- name: `${org.name} ${import_chalk8.default.dim(`(${org.slug})`)}`,
1069
+ name: `${org.name} ${import_chalk9.default.dim(`(${org.slug})`)}`,
871
1070
  value: org.id
872
1071
  })),
873
1072
  theme: promptTheme
874
1073
  });
875
1074
  } catch (error) {
876
- console.log(import_chalk8.default.yellow("\n\u26A0 Switch cancelled"));
1075
+ console.log(import_chalk9.default.yellow("\n\u26A0 Switch cancelled"));
877
1076
  return;
878
1077
  }
879
1078
  const selectedOrg = organizations.find((org) => org.id === orgId);
880
1079
  if (!selectedOrg) {
881
- console.log(import_chalk8.default.red("\u2717 Organization not found"));
1080
+ console.log(import_chalk9.default.red("\u2717 Organization not found"));
882
1081
  return;
883
1082
  }
884
1083
  saveProjectConfig({
@@ -886,54 +1085,54 @@ var switchCommand = new import_commander7.Command("switch").description("Switch
886
1085
  orgName: selectedOrg.name,
887
1086
  environment: auth.environment
888
1087
  });
889
- console.log(import_chalk8.default.green("\n\u2713 Switched organization successfully!"));
890
- console.log(import_chalk8.default.dim("\nNew configuration:"));
891
- console.log(import_chalk8.default.dim(` Organization: ${selectedOrg.name}`));
892
- console.log(import_chalk8.default.dim(` Environment: ${auth.environment}`));
1088
+ console.log(import_chalk9.default.green("\n\u2713 Switched organization successfully!"));
1089
+ console.log(import_chalk9.default.dim("\nNew configuration:"));
1090
+ console.log(import_chalk9.default.dim(` Organization: ${selectedOrg.name}`));
1091
+ console.log(import_chalk9.default.dim(` Environment: ${auth.environment}`));
893
1092
  console.log(
894
- import_chalk8.default.dim(
1093
+ import_chalk9.default.dim(
895
1094
  "\nRun `commet pull` to update TypeScript types for this organization"
896
1095
  )
897
1096
  );
898
1097
  });
899
1098
 
900
1099
  // src/commands/unlink.ts
901
- var import_chalk9 = __toESM(require("chalk"));
902
- var import_commander8 = require("commander");
903
- var unlinkCommand = new import_commander8.Command("unlink").description("Unlink this project from Commet").action(async () => {
1100
+ var import_chalk10 = __toESM(require("chalk"));
1101
+ var import_commander9 = require("commander");
1102
+ var unlinkCommand = new import_commander9.Command("unlink").description("Unlink this project from Commet").action(async () => {
904
1103
  if (!projectConfigExists()) {
905
1104
  console.log(
906
- import_chalk9.default.yellow("\u26A0 This project is not linked to any organization")
1105
+ import_chalk10.default.yellow("\u26A0 This project is not linked to any organization")
907
1106
  );
908
1107
  return;
909
1108
  }
910
1109
  clearProjectConfig();
911
- console.log(import_chalk9.default.green("\u2713 Project unlinked successfully"));
912
- console.log(import_chalk9.default.dim("\u2713 Removed .commet/ directory"));
1110
+ console.log(import_chalk10.default.green("\u2713 Project unlinked successfully"));
1111
+ console.log(import_chalk10.default.dim("\u2713 Removed .commet/ directory"));
913
1112
  console.log(
914
- import_chalk9.default.dim("\nRun `commet link` to connect to a different organization")
1113
+ import_chalk10.default.dim("\nRun `commet link` to connect to a different organization")
915
1114
  );
916
1115
  });
917
1116
 
918
1117
  // src/commands/whoami.ts
919
- var import_chalk10 = __toESM(require("chalk"));
920
- var import_commander9 = require("commander");
921
- var whoamiCommand = new import_commander9.Command("whoami").description("Display current authentication and project status").action(async () => {
1118
+ var import_chalk11 = __toESM(require("chalk"));
1119
+ var import_commander10 = require("commander");
1120
+ var whoamiCommand = new import_commander10.Command("whoami").description("Display current authentication and project status").action(async () => {
922
1121
  if (!authExists()) {
923
- console.log(import_chalk10.default.yellow("\u26A0 Not logged in"));
924
- console.log(import_chalk10.default.dim("Run `commet login` to authenticate"));
1122
+ console.log(import_chalk11.default.yellow("\u26A0 Not logged in"));
1123
+ console.log(import_chalk11.default.dim("Run `commet login` to authenticate"));
925
1124
  return;
926
1125
  }
927
- console.log(import_chalk10.default.green("\u2713 Logged in"));
1126
+ console.log(import_chalk11.default.green("\u2713 Logged in"));
928
1127
  const projectConfig = loadProjectConfig();
929
1128
  if (projectConfig) {
930
- console.log(import_chalk10.default.bold("\nProject:"));
931
- console.log(import_chalk10.default.dim("Organization:"), projectConfig.orgName);
932
- console.log(import_chalk10.default.dim("Environment:"), projectConfig.environment);
1129
+ console.log(import_chalk11.default.bold("\nProject:"));
1130
+ console.log(import_chalk11.default.dim("Organization:"), projectConfig.orgName);
1131
+ console.log(import_chalk11.default.dim("Environment:"), projectConfig.environment);
933
1132
  } else {
934
- console.log(import_chalk10.default.yellow("\n\u26A0 No project linked"));
1133
+ console.log(import_chalk11.default.yellow("\n\u26A0 No project linked"));
935
1134
  console.log(
936
- import_chalk10.default.dim(
1135
+ import_chalk11.default.dim(
937
1136
  "Run `commet link` to connect this directory to an organization"
938
1137
  )
939
1138
  );
@@ -941,10 +1140,11 @@ var whoamiCommand = new import_commander9.Command("whoami").description("Display
941
1140
  });
942
1141
 
943
1142
  // src/index.ts
944
- var program = new import_commander10.Command();
1143
+ var program = new import_commander11.Command();
945
1144
  program.name("commet").description(
946
1145
  "Commet CLI - Manage your billing platform from the command line"
947
1146
  ).version(package_default.version);
1147
+ program.addCommand(createCommand);
948
1148
  program.addCommand(loginCommand);
949
1149
  program.addCommand(logoutCommand);
950
1150
  program.addCommand(whoamiCommand);
@@ -962,7 +1162,7 @@ try {
962
1162
  if (error.message.includes("outputHelp")) {
963
1163
  process.exit(0);
964
1164
  }
965
- console.error(import_chalk11.default.red("Error:"), error.message);
1165
+ console.error(import_chalk12.default.red("Error:"), error.message);
966
1166
  }
967
1167
  process.exit(1);
968
1168
  }