apiblaze 0.3.1 → 0.3.3

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 (2) hide show
  1. package/dist/index.js +239 -324
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,13 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __esm = (fn, res) => function __init() {
10
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
11
- };
12
- var __export = (target, all) => {
13
- for (var name in all)
14
- __defProp(target, name, { get: all[name], enumerable: true });
15
- };
16
9
  var __copyProps = (to, from, except, desc) => {
17
10
  if (from && typeof from === "object" || typeof from === "function") {
18
11
  for (let key of __getOwnPropNames(from))
@@ -30,23 +23,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
23
  mod
31
24
  ));
32
25
 
26
+ // src/index.ts
27
+ var import_commander = require("commander");
28
+ var import_chalk15 = __toESM(require("chalk"));
29
+
30
+ // package.json
31
+ var version = "0.3.3";
32
+
33
33
  // src/types.ts
34
- var ApiError;
35
- var init_types = __esm({
36
- "src/types.ts"() {
37
- "use strict";
38
- ApiError = class extends Error {
39
- constructor(status, message, body) {
40
- super(message);
41
- this.status = status;
42
- this.body = body;
43
- this.name = "ApiError";
44
- }
45
- };
34
+ var ApiError = class extends Error {
35
+ constructor(status, message, body) {
36
+ super(message);
37
+ this.status = status;
38
+ this.body = body;
39
+ this.name = "ApiError";
46
40
  }
47
- });
41
+ };
42
+
43
+ // src/commands/login.ts
44
+ var import_chalk2 = __toESM(require("chalk"));
45
+ var import_ora = __toESM(require("ora"));
48
46
 
49
47
  // src/lib/auth.ts
48
+ var fs = __toESM(require("fs"));
49
+ var os = __toESM(require("os"));
50
+ var path = __toESM(require("path"));
51
+ var APIBLAZE_DIR = path.join(os.homedir(), ".apiblaze");
52
+ var CREDENTIALS_PATH = path.join(APIBLAZE_DIR, "credentials.json");
50
53
  function saveCredentials(creds) {
51
54
  fs.mkdirSync(APIBLAZE_DIR, { recursive: true });
52
55
  fs.writeFileSync(CREDENTIALS_PATH, JSON.stringify(creds, null, 2), "utf-8");
@@ -78,32 +81,13 @@ function getAccessToken() {
78
81
  }
79
82
  return creds.accessToken;
80
83
  }
81
- var fs, os, path, APIBLAZE_DIR, CREDENTIALS_PATH;
82
- var init_auth = __esm({
83
- "src/lib/auth.ts"() {
84
- "use strict";
85
- fs = __toESM(require("fs"));
86
- os = __toESM(require("os"));
87
- path = __toESM(require("path"));
88
- APIBLAZE_DIR = path.join(os.homedir(), ".apiblaze");
89
- CREDENTIALS_PATH = path.join(APIBLAZE_DIR, "credentials.json");
90
- }
91
- });
84
+
85
+ // src/lib/team.ts
86
+ var import_chalk = __toESM(require("chalk"));
92
87
 
93
88
  // src/lib/api.ts
94
- var api_exports = {};
95
- __export(api_exports, {
96
- agentCall: () => agentCall,
97
- checkProxyName: () => checkProxyName,
98
- claimProxy: () => claimProxy,
99
- createProxy: () => createProxy,
100
- createProxyAnonymous: () => createProxyAnonymous,
101
- deleteDevTunnel: () => deleteDevTunnel,
102
- getLocalhostTargets: () => getLocalhostTargets,
103
- getProjects: () => getProjects,
104
- getTeams: () => getTeams,
105
- putDevTunnel: () => putDevTunnel
106
- });
89
+ var DASHBOARD_BASE = "https://dashboard.apiblaze.com";
90
+ var PUBLIC_API_BASE = "https://api.apiblaze.com";
107
91
  async function createProxyAnonymous(body) {
108
92
  const res = await fetch(`${PUBLIC_API_BASE}/proxy`, {
109
93
  method: "POST",
@@ -205,32 +189,41 @@ async function deleteDevTunnel(restore) {
205
189
  body: JSON.stringify({ restore })
206
190
  });
207
191
  }
208
- var DASHBOARD_BASE, PUBLIC_API_BASE;
209
- var init_api = __esm({
210
- "src/lib/api.ts"() {
211
- "use strict";
212
- init_auth();
213
- init_types();
214
- DASHBOARD_BASE = "https://dashboard.apiblaze.com";
215
- PUBLIC_API_BASE = "https://api.apiblaze.com";
216
- }
217
- });
218
-
219
- // src/index.ts
220
- var import_commander = require("commander");
221
- var import_chalk14 = __toESM(require("chalk"));
222
-
223
- // package.json
224
- var version = "0.3.1";
225
192
 
226
- // src/index.ts
227
- init_types();
193
+ // src/lib/team.ts
194
+ async function resolveLinkedTeam(opts) {
195
+ let teams;
196
+ try {
197
+ teams = await getTeams();
198
+ } catch {
199
+ return opts.preferredId ? { teamId: opts.preferredId } : null;
200
+ }
201
+ if (teams.length === 0) return null;
202
+ const preferred = opts.preferredId ? teams.find((t) => t.teamId === opts.preferredId) : void 0;
203
+ if (preferred) return { teamId: preferred.teamId, teamName: preferred.name };
204
+ if (opts.preferredId) {
205
+ console.log(import_chalk.default.yellow("\nYour previously linked team is no longer available."));
206
+ }
207
+ if (teams.length === 1) {
208
+ console.log(`${import_chalk.default.cyan("\u2192")} Linking to your team ${import_chalk.default.bold(teams[0].name)}.`);
209
+ return { teamId: teams[0].teamId, teamName: teams[0].name };
210
+ }
211
+ if (!opts.interactive) {
212
+ console.log(import_chalk.default.yellow(`Linking to "${teams[0].name}" \u2014 pass --team to choose another.`));
213
+ return { teamId: teams[0].teamId, teamName: teams[0].name };
214
+ }
215
+ const { default: inquirer2 } = await import("inquirer");
216
+ const { chosen } = await inquirer2.prompt([{
217
+ type: "list",
218
+ name: "chosen",
219
+ message: "Which team do you want to link to?",
220
+ choices: teams.map((t) => ({ name: t.name, value: t.teamId }))
221
+ }]);
222
+ const picked = teams.find((t) => t.teamId === chosen);
223
+ return { teamId: picked.teamId, teamName: picked.name };
224
+ }
228
225
 
229
226
  // src/commands/login.ts
230
- var import_chalk = __toESM(require("chalk"));
231
- var import_ora = __toESM(require("ora"));
232
- init_auth();
233
- init_api();
234
227
  var DASHBOARD_BASE2 = "https://dashboard.apiblaze.com";
235
228
  function openBrowser(url) {
236
229
  const { exec } = require("child_process");
@@ -242,17 +235,17 @@ function decodeJWTPayload(token) {
242
235
  return JSON.parse(Buffer.from(part, "base64url").toString());
243
236
  }
244
237
  async function runLogin() {
245
- console.log(import_chalk.default.bold("\nLogging in to APIblaze...\n"));
238
+ console.log(import_chalk2.default.bold("\nLogging in to APIblaze...\n"));
246
239
  const codeRes = await fetch(`${DASHBOARD_BASE2}/api/device/code`, { method: "POST" });
247
240
  if (!codeRes.ok) {
248
241
  throw new Error(`Failed to start login: ${codeRes.status}`);
249
242
  }
250
243
  const deviceAuth = await codeRes.json();
251
244
  const loginUrl = deviceAuth.verification_uri_complete ?? deviceAuth.verification_uri;
252
- console.log(`${import_chalk.default.cyan("\u2192")} Open this URL in your browser to confirm login:`);
253
- console.log(` ${import_chalk.default.bold.underline(loginUrl)}
245
+ console.log(`${import_chalk2.default.cyan("\u2192")} Open this URL in your browser to confirm login:`);
246
+ console.log(` ${import_chalk2.default.bold.underline(loginUrl)}
254
247
  `);
255
- console.log(`${import_chalk.default.cyan("\u2192")} Your code: ${import_chalk.default.bold(deviceAuth.user_code)}
248
+ console.log(`${import_chalk2.default.cyan("\u2192")} Your code: ${import_chalk2.default.bold(deviceAuth.user_code)}
256
249
  `);
257
250
  openBrowser(loginUrl);
258
251
  const spinner = (0, import_ora.default)("Waiting for authorization in browser...").start();
@@ -300,33 +293,20 @@ async function runLogin() {
300
293
  email,
301
294
  teamId: defaultTeamId ?? void 0
302
295
  });
303
- spinner.succeed(import_chalk.default.green("Authorized!"));
296
+ spinner.succeed(import_chalk2.default.green("Authorized!"));
304
297
  if (githubHandle) {
305
- console.log(`${import_chalk.default.cyan("\u2192")} Logged in as ${import_chalk.default.bold("@" + githubHandle)}`);
298
+ console.log(`${import_chalk2.default.cyan("\u2192")} Logged in as ${import_chalk2.default.bold("@" + githubHandle)}`);
306
299
  }
307
300
  let teamId = defaultTeamId ?? void 0;
308
301
  let teamName;
309
- try {
310
- const teams = await getTeams();
311
- if (teams.length === 0) {
312
- console.log(import_chalk.default.yellow("\nNo teams found \u2014 you can still use apiblaze dev with a personal workspace."));
313
- } else if (teams.length === 1) {
314
- teamId = teams[0].teamId;
315
- teamName = teams[0].name;
316
- console.log(`
317
- ${import_chalk.default.cyan("\u2192")} Team: ${import_chalk.default.bold(teamName)}`);
318
- } else {
319
- const { default: inquirer2 } = await import("inquirer");
320
- const { chosen } = await inquirer2.prompt([{
321
- type: "list",
322
- name: "chosen",
323
- message: "Which team do you want to use?",
324
- choices: teams.map((t) => ({ name: t.name, value: t.teamId }))
325
- }]);
326
- teamId = chosen;
327
- teamName = teams.find((t) => t.teamId === chosen)?.name;
328
- }
329
- } catch {
302
+ const linked = await resolveLinkedTeam({ preferredId: defaultTeamId ?? void 0, interactive: !!process.stdin.isTTY });
303
+ if (linked) {
304
+ teamId = linked.teamId;
305
+ teamName = linked.teamName;
306
+ if (teamName) console.log(`
307
+ ${import_chalk2.default.cyan("\u2192")} Team: ${import_chalk2.default.bold(teamName)}`);
308
+ } else {
309
+ console.log(import_chalk2.default.yellow("\nNo teams found \u2014 your personal workspace will be created on first use."));
330
310
  }
331
311
  saveCredentials({
332
312
  accessToken,
@@ -338,50 +318,48 @@ ${import_chalk.default.cyan("\u2192")} Team: ${import_chalk.default.bold(teamNam
338
318
  teamId,
339
319
  teamName
340
320
  });
341
- console.log(import_chalk.default.green("\n\u2714 Logged in successfully!"));
321
+ console.log(import_chalk2.default.green("\n\u2714 Logged in successfully!"));
342
322
  }
343
323
 
344
324
  // src/commands/dev.ts
345
325
  var import_fs = __toESM(require("fs"));
346
- var import_chalk3 = __toESM(require("chalk"));
326
+ var import_chalk4 = __toESM(require("chalk"));
347
327
  var import_ora2 = __toESM(require("ora"));
348
328
  var import_inquirer = __toESM(require("inquirer"));
349
- init_auth();
350
- init_api();
351
329
 
352
330
  // src/lib/traffic.ts
353
- var import_chalk2 = __toESM(require("chalk"));
331
+ var import_chalk3 = __toESM(require("chalk"));
354
332
  var METHOD_COLORS = {
355
- GET: import_chalk2.default.cyan,
356
- POST: import_chalk2.default.green,
357
- PUT: import_chalk2.default.yellow,
358
- PATCH: import_chalk2.default.magenta,
359
- DELETE: import_chalk2.default.red,
360
- HEAD: import_chalk2.default.blue,
361
- OPTIONS: import_chalk2.default.gray
333
+ GET: import_chalk3.default.cyan,
334
+ POST: import_chalk3.default.green,
335
+ PUT: import_chalk3.default.yellow,
336
+ PATCH: import_chalk3.default.magenta,
337
+ DELETE: import_chalk3.default.red,
338
+ HEAD: import_chalk3.default.blue,
339
+ OPTIONS: import_chalk3.default.gray
362
340
  };
363
341
  function colorMethod(method) {
364
- const colorFn = METHOD_COLORS[method.toUpperCase()] ?? import_chalk2.default.white;
342
+ const colorFn = METHOD_COLORS[method.toUpperCase()] ?? import_chalk3.default.white;
365
343
  return colorFn(method.padEnd(7));
366
344
  }
367
345
  function colorStatus(status) {
368
346
  const s = String(status);
369
- if (status >= 500) return import_chalk2.default.red(s);
370
- if (status >= 400) return import_chalk2.default.yellow(s);
371
- if (status >= 300) return import_chalk2.default.cyan(s);
372
- return import_chalk2.default.green(s);
347
+ if (status >= 500) return import_chalk3.default.red(s);
348
+ if (status >= 400) return import_chalk3.default.yellow(s);
349
+ if (status >= 300) return import_chalk3.default.cyan(s);
350
+ return import_chalk3.default.green(s);
373
351
  }
374
352
  function colorLatency(latency) {
375
353
  const s = `${latency}ms`;
376
- if (latency < 100) return import_chalk2.default.green(s);
377
- if (latency < 500) return import_chalk2.default.yellow(s);
378
- return import_chalk2.default.red(s);
354
+ if (latency < 100) return import_chalk3.default.green(s);
355
+ if (latency < 500) return import_chalk3.default.yellow(s);
356
+ return import_chalk3.default.red(s);
379
357
  }
380
358
  function timestamp() {
381
359
  return (/* @__PURE__ */ new Date()).toTimeString().slice(0, 8);
382
360
  }
383
361
  function formatLogLine(entry) {
384
- return `${import_chalk2.default.gray(`[${timestamp()}]`)} ${colorMethod(entry.method)} ${import_chalk2.default.white(entry.path)} ${import_chalk2.default.gray("\u2192")} ${colorStatus(entry.status)} ${import_chalk2.default.gray(`(${colorLatency(entry.latency)})`)}`;
362
+ return `${import_chalk3.default.gray(`[${timestamp()}]`)} ${colorMethod(entry.method)} ${import_chalk3.default.white(entry.path)} ${import_chalk3.default.gray("\u2192")} ${colorStatus(entry.status)} ${import_chalk3.default.gray(`(${colorLatency(entry.latency)})`)}`;
385
363
  }
386
364
  var SENSITIVE_HEADERS = /* @__PURE__ */ new Set([
387
365
  "authorization",
@@ -416,7 +394,7 @@ function maskSecret(value) {
416
394
  if (v.length <= 8) return "\u2022\u2022\u2022\u2022";
417
395
  const head = v.slice(0, 4);
418
396
  const tail = v.slice(-4);
419
- return `${head}\u2026${tail} ${import_chalk2.default.gray(`(${v.length} chars, masked)`)}`;
397
+ return `${head}\u2026${tail} ${import_chalk3.default.gray(`(${v.length} chars, masked)`)}`;
420
398
  }
421
399
  function base64UrlDecode(seg) {
422
400
  try {
@@ -468,23 +446,23 @@ function formatHeaderLines(name, value) {
468
446
  const jwt = decodeJwt(token);
469
447
  if (jwt) {
470
448
  return [
471
- ` ${import_chalk2.default.dim(name)}: Bearer ${maskSecret(token)} ${import_chalk2.default.cyan("(JWT)")}`,
472
- ` ${import_chalk2.default.gray("\u251C header: ")} ${import_chalk2.default.gray(JSON.stringify(jwt.header))}`,
473
- ` ${import_chalk2.default.gray("\u2514 payload:")} ${import_chalk2.default.gray(JSON.stringify(jwt.payload))}`
449
+ ` ${import_chalk3.default.dim(name)}: Bearer ${maskSecret(token)} ${import_chalk3.default.cyan("(JWT)")}`,
450
+ ` ${import_chalk3.default.gray("\u251C header: ")} ${import_chalk3.default.gray(JSON.stringify(jwt.header))}`,
451
+ ` ${import_chalk3.default.gray("\u2514 payload:")} ${import_chalk3.default.gray(JSON.stringify(jwt.payload))}`
474
452
  ];
475
453
  }
476
- return [` ${import_chalk2.default.dim(name)}: Bearer ${maskSecret(token)}`];
454
+ return [` ${import_chalk3.default.dim(name)}: Bearer ${maskSecret(token)}`];
477
455
  }
478
- return [` ${import_chalk2.default.dim(name)}: ${maskSecret(value)}`];
456
+ return [` ${import_chalk3.default.dim(name)}: ${maskSecret(value)}`];
479
457
  }
480
458
  if (SENSITIVE_HEADERS.has(lower)) {
481
- return [` ${import_chalk2.default.dim(name)}: ${maskSecret(value)}`];
459
+ return [` ${import_chalk3.default.dim(name)}: ${maskSecret(value)}`];
482
460
  }
483
- return [` ${import_chalk2.default.dim(name)}: ${value}`];
461
+ return [` ${import_chalk3.default.dim(name)}: ${value}`];
484
462
  }
485
463
  function formatBody(body, contentType) {
486
- if (body.length === 0) return import_chalk2.default.gray(" (empty)");
487
- if (body.includes(0)) return import_chalk2.default.gray(` <binary, ${body.length} bytes>`);
464
+ if (body.length === 0) return import_chalk3.default.gray(" (empty)");
465
+ if (body.includes(0)) return import_chalk3.default.gray(` <binary, ${body.length} bytes>`);
488
466
  let text = body.toString("utf8");
489
467
  const ct = (contentType ?? "").toLowerCase();
490
468
  if (ct.includes("json") || /^[[{]/.test(text.trim())) {
@@ -497,17 +475,17 @@ function formatBody(body, contentType) {
497
475
  const truncated = text.length > MAX;
498
476
  const shown = truncated ? text.slice(0, MAX) : text;
499
477
  const indented = shown.split("\n").map((l) => ` ${l}`).join("\n");
500
- return indented + (truncated ? import_chalk2.default.gray(`
478
+ return indented + (truncated ? import_chalk3.default.gray(`
501
479
  \u2026 (${text.length - MAX} more bytes \u2014 see --capture-file for full)`) : "");
502
480
  }
503
481
  function formatCapturedRequest(req, note) {
504
482
  const headerLines = Object.keys(req.headers).flatMap((name) => formatHeaderLines(name, req.headers[name]));
505
483
  const contentType = Object.keys(req.headers).find((k) => k.toLowerCase() === "content-type");
506
484
  return [
507
- `${import_chalk2.default.gray(`[${timestamp()}]`)} ${import_chalk2.default.magenta("\u26B2 CAPTURED")} ${colorMethod(req.method)} ${import_chalk2.default.white(maskPath(req.path))} ${import_chalk2.default.gray(`\u2014 ${note}`)}`,
508
- import_chalk2.default.bold(" Headers:"),
485
+ `${import_chalk3.default.gray(`[${timestamp()}]`)} ${import_chalk3.default.magenta("\u26B2 CAPTURED")} ${colorMethod(req.method)} ${import_chalk3.default.white(maskPath(req.path))} ${import_chalk3.default.gray(`\u2014 ${note}`)}`,
486
+ import_chalk3.default.bold(" Headers:"),
509
487
  ...headerLines,
510
- import_chalk2.default.bold(" Body:"),
488
+ import_chalk3.default.bold(" Body:"),
511
489
  formatBody(req.body, contentType ? req.headers[contentType] : void 0),
512
490
  ""
513
491
  ].join("\n");
@@ -781,14 +759,14 @@ function startTunnelClient(opts) {
781
759
  // src/commands/dev.ts
782
760
  async function offerAutoCreate(teamId, port) {
783
761
  if (!process.stdin.isTTY) {
784
- console.log(import_chalk3.default.yellow("No projects found with an internal target."));
762
+ console.log(import_chalk4.default.yellow("No projects found with an internal target."));
785
763
  console.log("Point a project at localhost in the dashboard, or run `apiblaze dev` in an interactive terminal to create one automatically.");
786
764
  return null;
787
765
  }
788
766
  const { create } = await import_inquirer.default.prompt([{
789
767
  type: "confirm",
790
768
  name: "create",
791
- message: `No project points at this machine. Create a quick dev proxy \u2192 ${import_chalk3.default.bold(`http://localhost:${port}`)} and tunnel it?`,
769
+ message: `No project points at this machine. Create a quick dev proxy \u2192 ${import_chalk4.default.bold(`http://localhost:${port}`)} and tunnel it?`,
792
770
  default: true
793
771
  }]);
794
772
  if (!create) return null;
@@ -812,25 +790,25 @@ async function offerAutoCreate(teamId, port) {
812
790
  let result;
813
791
  try {
814
792
  result = await createProxy({ name, target_url: `http://localhost:${port}`, auth_type: auth, team_id: teamId });
815
- spinner.succeed(import_chalk3.default.green(`Created dev proxy "${name}".`));
793
+ spinner.succeed(import_chalk4.default.green(`Created dev proxy "${name}".`));
816
794
  } catch (err) {
817
795
  spinner.fail("Failed to create the dev proxy.");
818
796
  throw err;
819
797
  }
820
798
  const version2 = result.api_version || "1.0.0";
821
799
  const endpoint = `https://${name}.apiblaze.com/${version2}/dev`;
822
- console.log(` ${import_chalk3.default.dim("Endpoint:")} ${import_chalk3.default.bold(endpoint)}`);
800
+ console.log(` ${import_chalk4.default.dim("Endpoint:")} ${import_chalk4.default.bold(endpoint)}`);
823
801
  if (auth === "api_key") {
824
802
  const key = result.api_keys?.dev ?? Object.values(result.api_keys ?? {})[0];
825
803
  if (key) {
826
- console.log(` ${import_chalk3.default.dim("API key (dev):")} ${import_chalk3.default.bold.green(key)}`);
827
- console.log(import_chalk3.default.dim(" Send it as the X-API-Key header. It may not be shown again."));
804
+ console.log(` ${import_chalk4.default.dim("API key (dev):")} ${import_chalk4.default.bold.green(key)}`);
805
+ console.log(import_chalk4.default.dim(" Send it as the X-API-Key header. It may not be shown again."));
828
806
  }
829
807
  }
830
808
  const targets = await getLocalhostTargets(teamId).catch(() => []);
831
809
  const created = targets.find((t) => t.projectId === result.project_id);
832
810
  if (!created) {
833
- console.log(import_chalk3.default.yellow(" Proxy created, but it did not appear as a localhost target \u2014 try `apiblaze dev` again."));
811
+ console.log(import_chalk4.default.yellow(" Proxy created, but it did not appear as a localhost target \u2014 try `apiblaze dev` again."));
834
812
  return null;
835
813
  }
836
814
  return created;
@@ -852,31 +830,20 @@ async function probeLocalServer(port) {
852
830
  async function runDev(options) {
853
831
  const creds = loadCredentials();
854
832
  if (!creds) {
855
- console.error(import_chalk3.default.red("Not logged in. Run `apiblaze login` first."));
833
+ console.error(import_chalk4.default.red("Not logged in. Run `apiblaze login` first."));
856
834
  process.exit(1);
857
835
  }
858
- let teamId = creds.teamId;
859
- if (!teamId) {
860
- const { getTeams: getTeams2 } = await Promise.resolve().then(() => (init_api(), api_exports));
861
- const teams = await getTeams2().catch(() => []);
862
- if (teams.length === 1) {
863
- teamId = teams[0].teamId;
864
- } else if (teams.length > 1) {
865
- const { chosen } = await import_inquirer.default.prompt([{
866
- type: "list",
867
- name: "chosen",
868
- message: "Which team?",
869
- choices: teams.map((t) => ({ name: t.name, value: t.teamId }))
870
- }]);
871
- teamId = chosen;
872
- }
836
+ const linked = await resolveLinkedTeam({ preferredId: creds.teamId, interactive: !!process.stdin.isTTY });
837
+ if (!linked) {
838
+ console.error(import_chalk4.default.red("No team available. Run `apiblaze login` to set up your team."));
839
+ process.exit(1);
873
840
  }
874
- if (creds.teamName) {
875
- console.log(`${import_chalk3.default.cyan("\u2192")} Team: ${import_chalk3.default.bold(creds.teamName)}`);
841
+ const teamId = linked.teamId;
842
+ if (linked.teamId !== creds.teamId || linked.teamName !== creds.teamName) {
843
+ saveCredentials({ ...creds, teamId: linked.teamId, teamName: linked.teamName });
876
844
  }
877
- if (!teamId) {
878
- console.error(import_chalk3.default.red("No team selected. Run `apiblaze login` to set up your team."));
879
- process.exit(1);
845
+ if (linked.teamName) {
846
+ console.log(`${import_chalk4.default.cyan("\u2192")} Team: ${import_chalk4.default.bold(linked.teamName)}`);
880
847
  }
881
848
  let targets;
882
849
  {
@@ -901,7 +868,7 @@ async function runDev(options) {
901
868
  const { confirmed } = await import_inquirer.default.prompt([{
902
869
  type: "confirm",
903
870
  name: "confirmed",
904
- message: `Found 1 project with an internal target \u2014 tunnel "${import_chalk3.default.bold(targets[0].projectName)}" (${targets[0].tenantName})?`,
871
+ message: `Found 1 project with an internal target \u2014 tunnel "${import_chalk4.default.bold(targets[0].projectName)}" (${targets[0].tenantName})?`,
905
872
  default: true
906
873
  }]);
907
874
  if (!confirmed) {
@@ -917,7 +884,7 @@ async function runDev(options) {
917
884
  message: `Found ${targets.length} projects with an internal target \u2014 pick one to tunnel:`,
918
885
  choices: [
919
886
  ...targets.map((t) => ({
920
- name: `${import_chalk3.default.bold(t.projectName)} (${t.tenantName}) \u2014 ${t.target}`,
887
+ name: `${import_chalk4.default.bold(t.projectName)} (${t.tenantName}) \u2014 ${t.target}`,
921
888
  value: t
922
889
  })),
923
890
  new import_inquirer.default.Separator(),
@@ -927,7 +894,7 @@ async function runDev(options) {
927
894
  selectedTargets = chosen === ALL ? targets : [chosen];
928
895
  }
929
896
  console.log(
930
- import_chalk3.default.green(`
897
+ import_chalk4.default.green(`
931
898
  Tunneling ${selectedTargets.length} project(s) to localhost:${options.port}
932
899
  `)
933
900
  );
@@ -936,7 +903,7 @@ Tunneling ${selectedTargets.length} project(s) to localhost:${options.port}
936
903
  if (options.captureFile) {
937
904
  captureStream = import_fs.default.createWriteStream(options.captureFile, { flags: "a" });
938
905
  recordSink = (r) => captureStream.write(JSON.stringify(r) + "\n");
939
- console.log(import_chalk3.default.gray(`Streaming full traffic to ${options.captureFile}
906
+ console.log(import_chalk4.default.gray(`Streaming full traffic to ${options.captureFile}
940
907
  `));
941
908
  }
942
909
  let restore = [];
@@ -962,15 +929,15 @@ Tunneling ${selectedTargets.length} project(s) to localhost:${options.port}
962
929
  projectId,
963
930
  localPort: options.port,
964
931
  onEntry: (entry) => console.log(formatLogLine(entry)),
965
- onStatus: (status) => console.log(import_chalk3.default.gray(`[${projectId}] ${status}`)),
932
+ onStatus: (status) => console.log(import_chalk4.default.gray(`[${projectId}] ${status}`)),
966
933
  onCapture: (req, note) => console.log(formatCapturedRequest(req, note)),
967
934
  onCaptureStart: () => console.log(
968
- import_chalk3.default.magenta(`
935
+ import_chalk4.default.magenta(`
969
936
  \u26B2 No local server on port ${options.port} yet \u2014 capturing requests below. Start your server and they'll forward automatically.
970
937
  `)
971
938
  ),
972
939
  onResume: () => console.log(
973
- import_chalk3.default.green(`
940
+ import_chalk4.default.green(`
974
941
  \u2713 Local server detected on port ${options.port} \u2014 forwarding resumed.
975
942
  `)
976
943
  ),
@@ -978,22 +945,22 @@ Tunneling ${selectedTargets.length} project(s) to localhost:${options.port}
978
945
  })
979
946
  );
980
947
  const localUp = await probeLocalServer(options.port);
981
- console.log("\n" + import_chalk3.default.gray("\u2500".repeat(60)));
982
- console.log(import_chalk3.default.bold("Live traffic") + import_chalk3.default.gray(" (Ctrl+C to stop)"));
948
+ console.log("\n" + import_chalk4.default.gray("\u2500".repeat(60)));
949
+ console.log(import_chalk4.default.bold("Live traffic") + import_chalk4.default.gray(" (Ctrl+C to stop)"));
983
950
  console.log(
984
- localUp ? import_chalk3.default.green(`\u2713 Local server detected on port ${options.port} \u2014 forwarding live.`) : import_chalk3.default.magenta(`\u26B2 Nothing listening on port ${options.port} yet \u2014 requests will be captured until your server starts.`)
951
+ localUp ? import_chalk4.default.green(`\u2713 Local server detected on port ${options.port} \u2014 forwarding live.`) : import_chalk4.default.magenta(`\u26B2 Nothing listening on port ${options.port} yet \u2014 requests will be captured until your server starts.`)
985
952
  );
986
- console.log(import_chalk3.default.gray("\u2500".repeat(60)) + "\n");
953
+ console.log(import_chalk4.default.gray("\u2500".repeat(60)) + "\n");
987
954
  let isCleaningUp = false;
988
955
  async function cleanup() {
989
956
  if (isCleaningUp) return;
990
957
  isCleaningUp = true;
991
- console.log(import_chalk3.default.gray("\n\nShutting down..."));
958
+ console.log(import_chalk4.default.gray("\n\nShutting down..."));
992
959
  for (const client of clients) client.close();
993
960
  captureStream?.end();
994
961
  await deleteDevTunnel(restore).catch(() => {
995
962
  });
996
- console.log(import_chalk3.default.green("Tunnel stopped."));
963
+ console.log(import_chalk4.default.green("Tunnel stopped."));
997
964
  process.exit(0);
998
965
  }
999
966
  process.on("SIGINT", () => void cleanup());
@@ -1003,18 +970,16 @@ Tunneling ${selectedTargets.length} project(s) to localhost:${options.port}
1003
970
  }
1004
971
 
1005
972
  // src/commands/projects.ts
1006
- var import_chalk4 = __toESM(require("chalk"));
973
+ var import_chalk5 = __toESM(require("chalk"));
1007
974
  var import_ora3 = __toESM(require("ora"));
1008
- init_auth();
1009
- init_api();
1010
975
  async function runProjects() {
1011
976
  const creds = loadCredentials();
1012
977
  if (!creds) {
1013
- console.error(import_chalk4.default.red("Not logged in. Run `apiblaze login` first."));
978
+ console.error(import_chalk5.default.red("Not logged in. Run `apiblaze login` first."));
1014
979
  process.exit(1);
1015
980
  }
1016
981
  if (creds.githubHandle) {
1017
- console.log(`${import_chalk4.default.cyan("\u2192")} Logged in as ${import_chalk4.default.bold("@" + creds.githubHandle)}`);
982
+ console.log(`${import_chalk5.default.cyan("\u2192")} Logged in as ${import_chalk5.default.bold("@" + creds.githubHandle)}`);
1018
983
  }
1019
984
  let teamId = creds.teamId;
1020
985
  let teamName = creds.teamName;
@@ -1036,10 +1001,10 @@ async function runProjects() {
1036
1001
  }
1037
1002
  }
1038
1003
  if (!teamId) {
1039
- console.error(import_chalk4.default.red("No team found. Run `apiblaze login` to set up your team."));
1004
+ console.error(import_chalk5.default.red("No team found. Run `apiblaze login` to set up your team."));
1040
1005
  process.exit(1);
1041
1006
  }
1042
- console.log(`${import_chalk4.default.cyan("\u2192")} Team: ${import_chalk4.default.bold(teamName ?? teamId)}
1007
+ console.log(`${import_chalk5.default.cyan("\u2192")} Team: ${import_chalk5.default.bold(teamName ?? teamId)}
1043
1008
  `);
1044
1009
  const spinner = (0, import_ora3.default)("Fetching projects...").start();
1045
1010
  let projects;
@@ -1051,23 +1016,21 @@ async function runProjects() {
1051
1016
  throw err;
1052
1017
  }
1053
1018
  if (projects.length === 0) {
1054
- console.log(import_chalk4.default.yellow("No projects found for this team."));
1019
+ console.log(import_chalk5.default.yellow("No projects found for this team."));
1055
1020
  return;
1056
1021
  }
1057
1022
  const width = Math.max(...projects.map((p) => p.projectName.length));
1058
1023
  for (const p of projects) {
1059
- console.log(` ${import_chalk4.default.bold(p.projectName.padEnd(width))} ${import_chalk4.default.dim("v" + p.apiVersion)}`);
1024
+ console.log(` ${import_chalk5.default.bold(p.projectName.padEnd(width))} ${import_chalk5.default.dim("v" + p.apiVersion)}`);
1060
1025
  }
1061
- console.log(import_chalk4.default.dim(`
1026
+ console.log(import_chalk5.default.dim(`
1062
1027
  ${projects.length} project${projects.length === 1 ? "" : "s"}`));
1063
1028
  }
1064
1029
 
1065
1030
  // src/commands/create.ts
1066
1031
  var import_fs2 = __toESM(require("fs"));
1067
- var import_chalk5 = __toESM(require("chalk"));
1032
+ var import_chalk6 = __toESM(require("chalk"));
1068
1033
  var import_ora4 = __toESM(require("ora"));
1069
- init_auth();
1070
- init_api();
1071
1034
  function normalizeName(raw) {
1072
1035
  return (raw || "").toLowerCase().replace(/[^a-z0-9]/g, "");
1073
1036
  }
@@ -1092,17 +1055,17 @@ function stripTenantFromPortal(devPortal) {
1092
1055
  }
1093
1056
  }
1094
1057
  function fail(message) {
1095
- console.error(import_chalk5.default.red(`Error: ${message}`));
1058
+ console.error(import_chalk6.default.red(`Error: ${message}`));
1096
1059
  process.exit(1);
1097
1060
  }
1098
1061
  function printCurlExample(url, apiKey) {
1099
1062
  console.log();
1100
- console.log(` ${import_chalk5.default.dim("Try it with curl:")}`);
1063
+ console.log(` ${import_chalk6.default.dim("Try it with curl:")}`);
1101
1064
  if (apiKey) {
1102
- console.log(` ${import_chalk5.default.cyan(`curl ${url} \\`)}`);
1103
- console.log(` ${import_chalk5.default.cyan(` -H "X-API-Key: ${apiKey}"`)}`);
1065
+ console.log(` ${import_chalk6.default.cyan(`curl ${url} \\`)}`);
1066
+ console.log(` ${import_chalk6.default.cyan(` -H "X-API-Key: ${apiKey}"`)}`);
1104
1067
  } else {
1105
- console.log(` ${import_chalk5.default.cyan(`curl ${url}`)}`);
1068
+ console.log(` ${import_chalk6.default.cyan(`curl ${url}`)}`);
1106
1069
  }
1107
1070
  }
1108
1071
  var VALID_AUTH = ["api_key", "none", "oauth"];
@@ -1132,7 +1095,7 @@ async function runCreate(opts = {}) {
1132
1095
  teamId = match.teamId;
1133
1096
  }
1134
1097
  }
1135
- if (!opts.json) console.log(import_chalk5.default.bold("\nCreate an API proxy\n"));
1098
+ if (!opts.json) console.log(import_chalk6.default.bold("\nCreate an API proxy\n"));
1136
1099
  let name = "";
1137
1100
  if (opts.name !== void 0) {
1138
1101
  name = normalizeName(opts.name);
@@ -1152,7 +1115,7 @@ async function runCreate(opts = {}) {
1152
1115
  }]);
1153
1116
  name = normalizeName(rawName);
1154
1117
  if (name.length < 3) {
1155
- console.log(import_chalk5.default.yellow(" Name must be at least 3 characters (letters and digits only).\n"));
1118
+ console.log(import_chalk6.default.yellow(" Name must be at least 3 characters (letters and digits only).\n"));
1156
1119
  continue;
1157
1120
  }
1158
1121
  const spinner2 = (0, import_ora4.default)("Checking availability...").start();
@@ -1160,15 +1123,15 @@ async function runCreate(opts = {}) {
1160
1123
  const check = await checkProxyName(name, teamId, opts.apiversion);
1161
1124
  spinner2.stop();
1162
1125
  if (!check.canUseProjectName || !check.canUseApiVersion) {
1163
- console.log(import_chalk5.default.yellow(` "${name}" is not available${check.message ? ` \u2014 ${check.message}` : ""}. Try another.
1126
+ console.log(import_chalk6.default.yellow(` "${name}" is not available${check.message ? ` \u2014 ${check.message}` : ""}. Try another.
1164
1127
  `));
1165
1128
  continue;
1166
1129
  }
1167
1130
  } catch {
1168
1131
  spinner2.stop();
1169
- console.log(import_chalk5.default.dim(" (could not verify availability; continuing)"));
1132
+ console.log(import_chalk6.default.dim(" (could not verify availability; continuing)"));
1170
1133
  }
1171
- console.log(`${import_chalk5.default.cyan("\u2192")} Your API will live at ${import_chalk5.default.bold(`https://${name}.apiblaze.com`)}
1134
+ console.log(`${import_chalk6.default.cyan("\u2192")} Your API will live at ${import_chalk6.default.bold(`https://${name}.apiblaze.com`)}
1172
1135
  `);
1173
1136
  break;
1174
1137
  }
@@ -1188,7 +1151,7 @@ async function runCreate(opts = {}) {
1188
1151
  message: "Target URL to forward requests to (e.g. https://httpbin.org):"
1189
1152
  }]);
1190
1153
  if (!isHttpUrl(url)) {
1191
- console.log(import_chalk5.default.yellow(" Enter a valid http(s) URL.\n"));
1154
+ console.log(import_chalk6.default.yellow(" Enter a valid http(s) URL.\n"));
1192
1155
  continue;
1193
1156
  }
1194
1157
  targetUrl = url.trim();
@@ -1199,7 +1162,7 @@ async function runCreate(opts = {}) {
1199
1162
  }
1200
1163
  if (interactive && !opts.yes) {
1201
1164
  const { default: inquirer2 } = await import("inquirer");
1202
- console.log(`${import_chalk5.default.cyan("\u2192")} Auth: ${import_chalk5.default.bold(auth)}${auth === "api_key" ? " \u2014 consumers send an X-API-Key header" : ""}`);
1165
+ console.log(`${import_chalk6.default.cyan("\u2192")} Auth: ${import_chalk6.default.bold(auth)}${auth === "api_key" ? " \u2014 consumers send an X-API-Key header" : ""}`);
1203
1166
  const { ok } = await inquirer2.prompt([{
1204
1167
  type: "confirm",
1205
1168
  name: "ok",
@@ -1207,7 +1170,7 @@ async function runCreate(opts = {}) {
1207
1170
  default: true
1208
1171
  }]);
1209
1172
  if (!ok) {
1210
- console.log(import_chalk5.default.yellow("Cancelled."));
1173
+ console.log(import_chalk6.default.yellow("Cancelled."));
1211
1174
  return;
1212
1175
  }
1213
1176
  }
@@ -1215,45 +1178,10 @@ async function runCreate(opts = {}) {
1215
1178
  let result;
1216
1179
  try {
1217
1180
  result = await createProxy({ name, target_url: targetUrl, auth_type: auth, team_id: teamId, ...opts.apiversion ? { api_version: opts.apiversion } : {} });
1218
- spinner?.succeed(import_chalk5.default.green("Proxy created!"));
1181
+ spinner?.succeed(import_chalk6.default.green("Proxy created!"));
1219
1182
  } catch (err) {
1220
- const e = err;
1221
- const ownedByYou = e?.status === 409 && e?.body?.reason === "slug_owned_by_your_other_team" && !opts.team;
1222
1183
  spinner?.fail("Failed to create proxy.");
1223
- if (ownedByYou) {
1224
- const ownerId = e.body.owning_team_id;
1225
- const ownerName = e.body.owning_team_name || ownerId;
1226
- if (!opts.json) console.log(import_chalk5.default.yellow(`
1227
- You already own "${e.body.product_slug}" under your team "${ownerName}".`));
1228
- let doSwitch = false;
1229
- if (interactive && !opts.yes) {
1230
- const { default: inquirer2 } = await import("inquirer");
1231
- const { ok } = await inquirer2.prompt([{
1232
- type: "confirm",
1233
- name: "ok",
1234
- message: `Switch to team "${ownerName}" and create "${name}" there?`,
1235
- default: true
1236
- }]);
1237
- doSwitch = ok;
1238
- }
1239
- if (!doSwitch) {
1240
- if (!opts.json) console.log(import_chalk5.default.dim(` Run \`apiblaze team ${ownerId}\` to switch, then retry \u2014 or pick another --name.`));
1241
- throw err;
1242
- }
1243
- const creds2 = loadCredentials();
1244
- if (creds2) saveCredentials({ ...creds2, teamId: ownerId, teamName: ownerName });
1245
- teamId = ownerId;
1246
- const spinner2 = !opts.json ? (0, import_ora4.default)(`Creating proxy under "${ownerName}"...`).start() : null;
1247
- try {
1248
- result = await createProxy({ name, target_url: targetUrl, auth_type: auth, team_id: ownerId, ...opts.apiversion ? { api_version: opts.apiversion } : {} });
1249
- spinner2?.succeed(import_chalk5.default.green(`Proxy created \u2014 active team switched to "${ownerName}".`));
1250
- } catch (err2) {
1251
- spinner2?.fail("Failed to create proxy after switching team.");
1252
- throw err2;
1253
- }
1254
- } else {
1255
- throw err;
1256
- }
1184
+ throw err;
1257
1185
  }
1258
1186
  const version2 = result.api_version || "1.0.0";
1259
1187
  const keys = result.api_keys ?? {};
@@ -1273,16 +1201,16 @@ async function runCreate(opts = {}) {
1273
1201
  return;
1274
1202
  }
1275
1203
  console.log();
1276
- console.log(` ${import_chalk5.default.dim("Proxy URL: ")} ${import_chalk5.default.bold(proxyUrl)}`);
1277
- if (devPortal) console.log(` ${import_chalk5.default.dim("Dev portal:")} ${import_chalk5.default.bold(devPortal)}`);
1204
+ console.log(` ${import_chalk6.default.dim("Proxy URL: ")} ${import_chalk6.default.bold(proxyUrl)}`);
1205
+ if (devPortal) console.log(` ${import_chalk6.default.dim("Dev portal:")} ${import_chalk6.default.bold(devPortal)}`);
1278
1206
  if (adminKey) {
1279
1207
  console.log();
1280
- console.log(` ${import_chalk5.default.dim("Consumer admin API key (dev):")}`);
1281
- console.log(` ${import_chalk5.default.bold.green(adminKey)}`);
1282
- console.log(import_chalk5.default.dim("\n Save this now \u2014 send it as the X-API-Key header. It may not be shown again."));
1208
+ console.log(` ${import_chalk6.default.dim("Consumer admin API key (dev):")}`);
1209
+ console.log(` ${import_chalk6.default.bold.green(adminKey)}`);
1210
+ console.log(import_chalk6.default.dim("\n Save this now \u2014 send it as the X-API-Key header. It may not be shown again."));
1283
1211
  const otherEnvs = Object.keys(keys).filter((e) => e !== "dev");
1284
1212
  if (otherEnvs.length) {
1285
- console.log(import_chalk5.default.dim(` (Separate keys were also created for: ${otherEnvs.join(", ")}.)`));
1213
+ console.log(import_chalk6.default.dim(` (Separate keys were also created for: ${otherEnvs.join(", ")}.)`));
1286
1214
  }
1287
1215
  }
1288
1216
  printCurlExample(proxyUrl, auth === "none" ? void 0 : adminKey);
@@ -1291,8 +1219,8 @@ async function runCreate(opts = {}) {
1291
1219
  async function runAnonymousCreate(opts) {
1292
1220
  const interactive = !!process.stdin.isTTY && !opts.json;
1293
1221
  if (!opts.json) {
1294
- console.log(import_chalk5.default.bold("\nCreate an API proxy"));
1295
- console.log(import_chalk5.default.dim("Not logged in \u2014 creating an anonymous proxy. You can claim it to your account within 30 days.\n"));
1222
+ console.log(import_chalk6.default.bold("\nCreate an API proxy"));
1223
+ console.log(import_chalk6.default.dim("Not logged in \u2014 creating an anonymous proxy. You can claim it to your account within 30 days.\n"));
1296
1224
  }
1297
1225
  let body = {};
1298
1226
  if (opts.config) {
@@ -1338,7 +1266,7 @@ async function runAnonymousCreate(opts) {
1338
1266
  message: "Target URL to forward requests to (e.g. https://httpbin.org):"
1339
1267
  }]);
1340
1268
  if (!isHttpUrl(url)) {
1341
- console.log(import_chalk5.default.yellow(" Enter a valid http(s) URL.\n"));
1269
+ console.log(import_chalk6.default.yellow(" Enter a valid http(s) URL.\n"));
1342
1270
  continue;
1343
1271
  }
1344
1272
  target = url.trim();
@@ -1366,7 +1294,7 @@ async function runAnonymousCreate(opts) {
1366
1294
  let result;
1367
1295
  try {
1368
1296
  result = await createProxyAnonymous(body);
1369
- spinner?.succeed(import_chalk5.default.green("Proxy created!"));
1297
+ spinner?.succeed(import_chalk6.default.green("Proxy created!"));
1370
1298
  } catch (err) {
1371
1299
  spinner?.fail("Failed to create proxy.");
1372
1300
  throw err;
@@ -1388,30 +1316,28 @@ async function runAnonymousCreate(opts) {
1388
1316
  return;
1389
1317
  }
1390
1318
  console.log();
1391
- if (prodEndpoint) console.log(` ${import_chalk5.default.dim("Proxy URL: ")} ${import_chalk5.default.bold(prodEndpoint)}`);
1392
- if (result.portal) console.log(` ${import_chalk5.default.dim("Dev portal:")} ${import_chalk5.default.bold(result.portal)}`);
1319
+ if (prodEndpoint) console.log(` ${import_chalk6.default.dim("Proxy URL: ")} ${import_chalk6.default.bold(prodEndpoint)}`);
1320
+ if (result.portal) console.log(` ${import_chalk6.default.dim("Dev portal:")} ${import_chalk6.default.bold(result.portal)}`);
1393
1321
  if (apiKey) {
1394
1322
  console.log();
1395
- console.log(` ${import_chalk5.default.dim("API key:")}`);
1396
- console.log(` ${import_chalk5.default.bold.green(apiKey)}`);
1397
- console.log(import_chalk5.default.dim("\n Save this now \u2014 send it as the X-API-Key header. It may not be shown again."));
1323
+ console.log(` ${import_chalk6.default.dim("API key:")}`);
1324
+ console.log(` ${import_chalk6.default.bold.green(apiKey)}`);
1325
+ console.log(import_chalk6.default.dim("\n Save this now \u2014 send it as the X-API-Key header. It may not be shown again."));
1398
1326
  }
1399
1327
  if (prodEndpoint) printCurlExample(prodEndpoint, apiKey);
1400
1328
  if (result.claim_url) {
1401
1329
  console.log();
1402
- console.log(` ${import_chalk5.default.yellow("\u26A0 Anonymous proxy \u2014 claim it to your account within 30 days or it expires:")}`);
1403
- console.log(` ${import_chalk5.default.bold(result.claim_url)}`);
1404
- console.log(import_chalk5.default.dim(" (or run `apiblaze login`, then re-run `apiblaze create` to create it under your account)"));
1330
+ console.log(` ${import_chalk6.default.yellow("\u26A0 Anonymous proxy \u2014 claim it to your account within 30 days or it expires:")}`);
1331
+ console.log(` ${import_chalk6.default.bold(result.claim_url)}`);
1332
+ console.log(import_chalk6.default.dim(" (or run `apiblaze login`, then re-run `apiblaze create` to create it under your account)"));
1405
1333
  }
1406
1334
  console.log();
1407
1335
  }
1408
1336
 
1409
1337
  // src/commands/claim.ts
1410
- var import_chalk6 = __toESM(require("chalk"));
1411
- init_auth();
1412
- init_api();
1338
+ var import_chalk7 = __toESM(require("chalk"));
1413
1339
  function fail2(message) {
1414
- console.error(import_chalk6.default.red(`Error: ${message}`));
1340
+ console.error(import_chalk7.default.red(`Error: ${message}`));
1415
1341
  process.exit(1);
1416
1342
  }
1417
1343
  async function runClaim(claimCodeArg, opts) {
@@ -1467,41 +1393,39 @@ async function runClaim(claimCodeArg, opts) {
1467
1393
  console.log(JSON.stringify(result, null, 2));
1468
1394
  return;
1469
1395
  }
1470
- console.log(import_chalk6.default.green(`
1471
- \u2714 Claimed into ${import_chalk6.default.bold(teamName)}.`));
1472
- if (result.project_id) console.log(` Project: ${import_chalk6.default.bold(result.project_id)}`);
1396
+ console.log(import_chalk7.default.green(`
1397
+ \u2714 Claimed into ${import_chalk7.default.bold(teamName)}.`));
1398
+ if (result.project_id) console.log(` Project: ${import_chalk7.default.bold(result.project_id)}`);
1473
1399
  if (result.endpoints?.length) {
1474
1400
  console.log(" Endpoints:");
1475
1401
  for (const e of result.endpoints) console.log(` ${e}`);
1476
1402
  }
1477
1403
  console.log(`
1478
- Manage it at ${import_chalk6.default.cyan("https://dashboard.apiblaze.com/dashboard")}`);
1404
+ Manage it at ${import_chalk7.default.cyan("https://dashboard.apiblaze.com/dashboard")}`);
1479
1405
  }
1480
1406
 
1481
1407
  // src/commands/logout.ts
1482
- var import_chalk7 = __toESM(require("chalk"));
1483
- init_auth();
1408
+ var import_chalk8 = __toESM(require("chalk"));
1484
1409
  async function runLogout() {
1485
1410
  const creds = loadCredentials();
1486
1411
  const removed = clearCredentials();
1487
1412
  if (!removed) {
1488
- console.log(import_chalk7.default.yellow("You were not logged in."));
1413
+ console.log(import_chalk8.default.yellow("You were not logged in."));
1489
1414
  return;
1490
1415
  }
1491
1416
  const who = creds?.githubHandle ?? creds?.email;
1492
- console.log(import_chalk7.default.green(`\u2714 Logged out${who ? ` (${who})` : ""}.`));
1417
+ console.log(import_chalk8.default.green(`\u2714 Logged out${who ? ` (${who})` : ""}.`));
1493
1418
  }
1494
1419
 
1495
1420
  // src/commands/whoami.ts
1496
- var import_chalk8 = __toESM(require("chalk"));
1497
- init_auth();
1421
+ var import_chalk9 = __toESM(require("chalk"));
1498
1422
  async function runWhoami(opts = {}) {
1499
1423
  const creds = loadCredentials();
1500
1424
  if (!creds) {
1501
1425
  if (opts.json) {
1502
1426
  console.log(JSON.stringify({ loggedIn: false }, null, 2));
1503
1427
  } else {
1504
- console.log(import_chalk8.default.yellow("Not logged in. Run `apiblaze login` first."));
1428
+ console.log(import_chalk9.default.yellow("Not logged in. Run `apiblaze login` first."));
1505
1429
  }
1506
1430
  return;
1507
1431
  }
@@ -1519,23 +1443,21 @@ async function runWhoami(opts = {}) {
1519
1443
  return;
1520
1444
  }
1521
1445
  const who = creds.githubHandle ?? creds.email ?? creds.apiblazeUserId ?? "unknown";
1522
- console.log(`${import_chalk8.default.cyan("Signed in as")} ${import_chalk8.default.bold(who)}`);
1446
+ console.log(`${import_chalk9.default.cyan("Signed in as")} ${import_chalk9.default.bold(who)}`);
1523
1447
  if (creds.email && creds.email !== who) console.log(` Email: ${creds.email}`);
1524
1448
  if (creds.apiblazeUserId) console.log(` User ID: ${creds.apiblazeUserId}`);
1525
1449
  if (creds.teamName || creds.teamId) {
1526
- console.log(` Team: ${import_chalk8.default.bold(creds.teamName ?? creds.teamId)}${creds.teamName && creds.teamId ? import_chalk8.default.gray(` (${creds.teamId})`) : ""}`);
1450
+ console.log(` Team: ${import_chalk9.default.bold(creds.teamName ?? creds.teamId)}${creds.teamName && creds.teamId ? import_chalk9.default.gray(` (${creds.teamId})`) : ""}`);
1527
1451
  }
1528
1452
  if (expired) {
1529
- console.log(import_chalk8.default.yellow("\n\u26A0 Session expired. Run `apiblaze login` to re-authenticate."));
1453
+ console.log(import_chalk9.default.yellow("\n\u26A0 Session expired. Run `apiblaze login` to re-authenticate."));
1530
1454
  }
1531
1455
  }
1532
1456
 
1533
1457
  // src/commands/team.ts
1534
- var import_chalk9 = __toESM(require("chalk"));
1535
- init_auth();
1536
- init_api();
1458
+ var import_chalk10 = __toESM(require("chalk"));
1537
1459
  function fail3(message) {
1538
- console.error(import_chalk9.default.red(`Error: ${message}`));
1460
+ console.error(import_chalk10.default.red(`Error: ${message}`));
1539
1461
  process.exit(1);
1540
1462
  }
1541
1463
  async function runTeam(arg) {
@@ -1557,7 +1479,7 @@ async function runTeam(arg) {
1557
1479
  }
1558
1480
  } else if (teams.length === 1) {
1559
1481
  chosen = teams[0];
1560
- console.log(`${import_chalk9.default.cyan("\u2192")} You only have one team: ${import_chalk9.default.bold(chosen.name)}`);
1482
+ console.log(`${import_chalk10.default.cyan("\u2192")} You only have one team: ${import_chalk10.default.bold(chosen.name)}`);
1561
1483
  } else if (process.stdin.isTTY) {
1562
1484
  const { default: inquirer2 } = await import("inquirer");
1563
1485
  const { picked } = await inquirer2.prompt([{
@@ -1572,46 +1494,43 @@ async function runTeam(arg) {
1572
1494
  fail3(`Specify a team: \`apiblaze team <name|id>\`. Available: ${teams.map((t) => t.name).join(", ")}.`);
1573
1495
  }
1574
1496
  saveCredentials({ ...creds, teamId: chosen.teamId, teamName: chosen.name });
1575
- console.log(import_chalk9.default.green(`
1576
- \u2714 Active team: ${import_chalk9.default.bold(chosen.name)}`));
1497
+ console.log(import_chalk10.default.green(`
1498
+ \u2714 Active team: ${import_chalk10.default.bold(chosen.name)}`));
1577
1499
  }
1578
1500
 
1579
1501
  // src/commands/authz.ts
1580
- var import_chalk11 = __toESM(require("chalk"));
1581
- init_auth();
1582
- init_api();
1502
+ var import_chalk12 = __toESM(require("chalk"));
1583
1503
 
1584
1504
  // src/lib/agent-chat.ts
1585
1505
  var import_readline = __toESM(require("readline"));
1586
- var import_chalk10 = __toESM(require("chalk"));
1587
- init_api();
1506
+ var import_chalk11 = __toESM(require("chalk"));
1588
1507
  async function runAgentChatRepl(opts) {
1589
1508
  const { title, subtitle, endpoint, buildBody, seedPrompt, summarizeProposal, commands } = opts;
1590
- console.log("\n" + import_chalk10.default.cyan.bold(title));
1591
- if (subtitle) console.log(import_chalk10.default.dim(subtitle));
1509
+ console.log("\n" + import_chalk11.default.cyan.bold(title));
1510
+ if (subtitle) console.log(import_chalk11.default.dim(subtitle));
1592
1511
  const messages = [];
1593
1512
  const ctx = { proposal: null, lastData: null, log: (s) => console.log(s) };
1594
1513
  const cmdByName = new Map(commands.map((c) => [c.name, c]));
1595
1514
  const footer = () => {
1596
1515
  const parts = [
1597
- import_chalk10.default.dim("type to chat/refine"),
1598
- ...commands.map((c) => import_chalk10.default.dim(`/${c.name} ${c.describe}`)),
1599
- import_chalk10.default.dim("/show"),
1600
- import_chalk10.default.dim("/drop discard & exit")
1516
+ import_chalk11.default.dim("type to chat/refine"),
1517
+ ...commands.map((c) => import_chalk11.default.dim(`/${c.name} ${c.describe}`)),
1518
+ import_chalk11.default.dim("/show"),
1519
+ import_chalk11.default.dim("/drop discard & exit")
1601
1520
  ];
1602
- return " " + import_chalk10.default.dim("[ ") + parts.join(import_chalk10.default.dim(" \xB7 ")) + import_chalk10.default.dim(" ]");
1521
+ return " " + import_chalk11.default.dim("[ ") + parts.join(import_chalk11.default.dim(" \xB7 ")) + import_chalk11.default.dim(" ]");
1603
1522
  };
1604
1523
  async function turn(content) {
1605
1524
  messages.push({ role: "user", content });
1606
- process.stdout.write(import_chalk10.default.dim(" \u2026thinking\n"));
1525
+ process.stdout.write(import_chalk11.default.dim(" \u2026thinking\n"));
1607
1526
  const { status, data } = await agentCall(endpoint, "POST", { messages, ...buildBody(messages) });
1608
1527
  if (status === 402) {
1609
- console.log(import_chalk10.default.red(" Insufficient credits \u2014 top up to keep using the agents.\n"));
1528
+ console.log(import_chalk11.default.red(" Insufficient credits \u2014 top up to keep using the agents.\n"));
1610
1529
  messages.pop();
1611
1530
  return;
1612
1531
  }
1613
1532
  if (status >= 400 || !data) {
1614
- console.log(import_chalk10.default.red(` Error (${status}): ${(data && data.error) ?? "request failed"}
1533
+ console.log(import_chalk11.default.red(` Error (${status}): ${(data && data.error) ?? "request failed"}
1615
1534
  `));
1616
1535
  messages.pop();
1617
1536
  return;
@@ -1619,20 +1538,20 @@ async function runAgentChatRepl(opts) {
1619
1538
  ctx.lastData = data;
1620
1539
  const reply = data.reply ?? data.message ?? "(no reply)";
1621
1540
  messages.push({ role: "assistant", content: reply });
1622
- console.log("\n" + import_chalk10.default.cyan("agent \u203A ") + reply + "\n");
1541
+ console.log("\n" + import_chalk11.default.cyan("agent \u203A ") + reply + "\n");
1623
1542
  if (data.proposal) {
1624
1543
  ctx.proposal = data.proposal;
1625
1544
  const summary = summarizeProposal?.(data);
1626
- if (summary) console.log(import_chalk10.default.yellow(" " + summary));
1545
+ if (summary) console.log(import_chalk11.default.yellow(" " + summary));
1627
1546
  const ready = commands.filter((c) => c.needsProposal).map((c) => `/${c.name}`).join(" or ");
1628
- if (ready) console.log(import_chalk10.default.dim(` Ready \u2014 ${ready} to make it official, or keep refining.`));
1547
+ if (ready) console.log(import_chalk11.default.dim(` Ready \u2014 ${ready} to make it official, or keep refining.`));
1629
1548
  console.log();
1630
1549
  }
1631
1550
  const llm = data.llm;
1632
1551
  if (llm) {
1633
1552
  const credits = data.credits_remaining;
1634
1553
  const left = typeof credits === "number" ? ` \xB7 $${(credits / 100).toFixed(2)} credit left` : "";
1635
- console.log(import_chalk10.default.dim(` ~$${(llm.cost_estimate ?? 0).toFixed(4)} \xB7 ${llm.model ?? "?"}${left}`));
1554
+ console.log(import_chalk11.default.dim(` ~$${(llm.cost_estimate ?? 0).toFixed(4)} \xB7 ${llm.model ?? "?"}${left}`));
1636
1555
  }
1637
1556
  }
1638
1557
  const rl = import_readline.default.createInterface({ input: process.stdin, output: process.stdout });
@@ -1640,26 +1559,26 @@ async function runAgentChatRepl(opts) {
1640
1559
  await turn(seedPrompt);
1641
1560
  for (; ; ) {
1642
1561
  console.log(footer());
1643
- const line = (await ask(import_chalk10.default.green("you \u203A "))).trim();
1562
+ const line = (await ask(import_chalk11.default.green("you \u203A "))).trim();
1644
1563
  if (!line) continue;
1645
1564
  if (line === "/drop" || line === "/exit" || line === "/quit") {
1646
- console.log(import_chalk10.default.dim(" Dropped \u2014 nothing applied.\n"));
1565
+ console.log(import_chalk11.default.dim(" Dropped \u2014 nothing applied.\n"));
1647
1566
  break;
1648
1567
  }
1649
1568
  if (line === "/show") {
1650
- if (!ctx.proposal) console.log(import_chalk10.default.dim(" No proposal yet \u2014 keep chatting until the agent proposes one.\n"));
1569
+ if (!ctx.proposal) console.log(import_chalk11.default.dim(" No proposal yet \u2014 keep chatting until the agent proposes one.\n"));
1651
1570
  else console.log("\n" + JSON.stringify(ctx.proposal, null, 2) + "\n");
1652
1571
  continue;
1653
1572
  }
1654
1573
  if (line.startsWith("/")) {
1655
1574
  const cmd = cmdByName.get(line.slice(1));
1656
1575
  if (!cmd) {
1657
- console.log(import_chalk10.default.red(` Unknown command "${line}". Try one of: ${commands.map((c) => "/" + c.name).join(", ")}, /show, /drop
1576
+ console.log(import_chalk11.default.red(` Unknown command "${line}". Try one of: ${commands.map((c) => "/" + c.name).join(", ")}, /show, /drop
1658
1577
  `));
1659
1578
  continue;
1660
1579
  }
1661
1580
  if (cmd.needsProposal && !ctx.proposal) {
1662
- console.log(import_chalk10.default.yellow(" No proposal yet \u2014 keep chatting until the agent generates one, then try again.\n"));
1581
+ console.log(import_chalk11.default.yellow(" No proposal yet \u2014 keep chatting until the agent generates one, then try again.\n"));
1663
1582
  continue;
1664
1583
  }
1665
1584
  await cmd.run(ctx);
@@ -1688,11 +1607,11 @@ async function runAuthz(projectArg, apiVersionArg) {
1688
1607
  if (!enable) {
1689
1608
  const m = await agentCall(`/projects/${projectId}/${apiVersion}/policies/model?tenantId=${encodeURIComponent(tenant)}`, "POST", proposal.model);
1690
1609
  if (m.status === 404) {
1691
- ctx.log(import_chalk11.default.red(" Authorization store not provisioned yet. Open the dashboard Authorization tab for this project once (it auto-provisions the store), then re-run.\n"));
1610
+ ctx.log(import_chalk12.default.red(" Authorization store not provisioned yet. Open the dashboard Authorization tab for this project once (it auto-provisions the store), then re-run.\n"));
1692
1611
  return;
1693
1612
  }
1694
1613
  if (m.status >= 400) {
1695
- ctx.log(import_chalk11.default.red(` Model save failed (${m.status}): ${m.data?.error ?? ""}
1614
+ ctx.log(import_chalk12.default.red(` Model save failed (${m.status}): ${m.data?.error ?? ""}
1696
1615
  `));
1697
1616
  return;
1698
1617
  }
@@ -1721,14 +1640,14 @@ async function runAuthz(projectArg, apiVersionArg) {
1721
1640
  if (enable) {
1722
1641
  const e = await agentCall(`/${projectId}/${apiVersion}/config`, "PATCH", { authorization: { enforce_authorization: true }, tenant });
1723
1642
  if (e.status >= 400) {
1724
- ctx.log(import_chalk11.default.red(` Enforced ${ok} route(s) but turning on the project-level switch failed (${e.status}). Toggle "Enforce Authorization" on in the dashboard.
1643
+ ctx.log(import_chalk12.default.red(` Enforced ${ok} route(s) but turning on the project-level switch failed (${e.status}). Toggle "Enforce Authorization" on in the dashboard.
1725
1644
  `));
1726
1645
  return;
1727
1646
  }
1728
- ctx.log(import_chalk11.default.green(` \u2713 Enforcement ON \u2014 ${ok} route(s) + project switch on${fail4 ? `, ${fail4} failed` : ""}.
1647
+ ctx.log(import_chalk12.default.green(` \u2713 Enforcement ON \u2014 ${ok} route(s) + project switch on${fail4 ? `, ${fail4} failed` : ""}.
1729
1648
  `));
1730
1649
  } else {
1731
- ctx.log(import_chalk11.default.green(` \u2713 Published (shadow): model + ${ok} route(s)${fail4 ? `, ${fail4} failed` : ""}. Review, then /enable.
1650
+ ctx.log(import_chalk12.default.green(` \u2713 Published (shadow): model + ${ok} route(s)${fail4 ? `, ${fail4} failed` : ""}. Review, then /enable.
1732
1651
  `));
1733
1652
  }
1734
1653
  }
@@ -1753,9 +1672,7 @@ async function runAuthz(projectArg, apiVersionArg) {
1753
1672
  }
1754
1673
 
1755
1674
  // src/commands/openapi.ts
1756
- var import_chalk12 = __toESM(require("chalk"));
1757
- init_auth();
1758
- init_api();
1675
+ var import_chalk13 = __toESM(require("chalk"));
1759
1676
  async function runOpenapi(projectArg, apiVersionArg) {
1760
1677
  const creds = loadCredentials();
1761
1678
  if (!creds) throw new Error("Not authenticated. Run `apiblaze login` first.");
@@ -1764,10 +1681,10 @@ async function runOpenapi(projectArg, apiVersionArg) {
1764
1681
  if (!match) throw new Error(`Project "${projectArg}" not found in your active team. Run \`apiblaze projects\`.`);
1765
1682
  const projectId = match.projectId;
1766
1683
  const apiVersion = apiVersionArg || match.apiVersion;
1767
- console.log(import_chalk12.default.dim("Gathering captured traffic samples\u2026"));
1684
+ console.log(import_chalk13.default.dim("Gathering captured traffic samples\u2026"));
1768
1685
  const routesRes = await agentCall(`/projects/${projectId}/${apiVersion}/samples/routes`, "GET");
1769
1686
  if (routesRes.status >= 400) {
1770
- console.log(import_chalk12.default.red(`Could not list traffic (${routesRes.status}): ${routesRes.data?.error ?? ""}`));
1687
+ console.log(import_chalk13.default.red(`Could not list traffic (${routesRes.status}): ${routesRes.data?.error ?? ""}`));
1771
1688
  return;
1772
1689
  }
1773
1690
  const routes = routesRes.data?.routes ?? (Array.isArray(routesRes.data) ? routesRes.data : []);
@@ -1780,25 +1697,25 @@ async function runOpenapi(projectArg, apiVersionArg) {
1780
1697
  }
1781
1698
  const sampleIds = [...ids];
1782
1699
  if (sampleIds.length === 0) {
1783
- console.log(import_chalk12.default.yellow("No captured traffic samples found. Hit the dev environment of this proxy to capture some traces, then retry."));
1700
+ console.log(import_chalk13.default.yellow("No captured traffic samples found. Hit the dev environment of this proxy to capture some traces, then retry."));
1784
1701
  return;
1785
1702
  }
1786
1703
  async function publish(ctx) {
1787
1704
  const patch = ctx.proposal.patch;
1788
1705
  if (!Array.isArray(patch) || patch.length === 0) {
1789
- ctx.log(import_chalk12.default.green(" Nothing to publish \u2014 the spec already covers the observed traffic.\n"));
1706
+ ctx.log(import_chalk13.default.green(" Nothing to publish \u2014 the spec already covers the observed traffic.\n"));
1790
1707
  return;
1791
1708
  }
1792
1709
  const specSource = ctx.lastData?.spec_source ?? "unknown";
1793
1710
  const endpoint = specSource === "github" ? "open-pr" : "publish-openapi";
1794
1711
  const pub = await agentCall(`/projects/${projectId}/${apiVersion}/samples/${endpoint}`, "POST", { patch, sample_ids_used: sampleIds });
1795
1712
  if (pub.status >= 400) {
1796
- ctx.log(import_chalk12.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
1713
+ ctx.log(import_chalk13.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
1797
1714
  `));
1798
1715
  return;
1799
1716
  }
1800
1717
  const prUrl = pub.data?.pr_url;
1801
- ctx.log(import_chalk12.default.green(prUrl ? ` \u2713 Pull request opened: ${prUrl}
1718
+ ctx.log(import_chalk13.default.green(prUrl ? ` \u2713 Pull request opened: ${prUrl}
1802
1719
  ` : " \u2713 Published updated OpenAPI spec.\n"));
1803
1720
  }
1804
1721
  await runAgentChatRepl({
@@ -1819,9 +1736,7 @@ async function runOpenapi(projectArg, apiVersionArg) {
1819
1736
  }
1820
1737
 
1821
1738
  // src/commands/mcp.ts
1822
- var import_chalk13 = __toESM(require("chalk"));
1823
- init_auth();
1824
- init_api();
1739
+ var import_chalk14 = __toESM(require("chalk"));
1825
1740
  async function runMcp(projectArg, apiVersionArg, opts) {
1826
1741
  const creds = loadCredentials();
1827
1742
  if (!creds) throw new Error("Not authenticated. Run `apiblaze login` first.");
@@ -1835,11 +1750,11 @@ async function runMcp(projectArg, apiVersionArg, opts) {
1835
1750
  const spec = ctx.proposal;
1836
1751
  const pub = await agentCall(`/projects/${projectId}/${apiVersion}/mcp/spec`, "PUT", { environment, spec });
1837
1752
  if (pub.status >= 400) {
1838
- ctx.log(import_chalk13.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
1753
+ ctx.log(import_chalk14.default.red(` Publish failed (${pub.status}): ${pub.data?.error ?? ""}
1839
1754
  `));
1840
1755
  return;
1841
1756
  }
1842
- ctx.log(import_chalk13.default.green(` \u2713 Published MCP server \u2014 ${projectId}.mcp.apiblaze.com/${apiVersion}/${environment}.
1757
+ ctx.log(import_chalk14.default.green(` \u2713 Published MCP server \u2014 ${projectId}.mcp.apiblaze.com/${apiVersion}/${environment}.
1843
1758
  `));
1844
1759
  }
1845
1760
  await runAgentChatRepl({
@@ -1871,7 +1786,7 @@ program.command("login").description("Authenticate with APIblaze").action(async
1871
1786
  process.exit(1);
1872
1787
  }
1873
1788
  });
1874
- program.command("create").description("Create a new API proxy (no login needed \u2014 without auth it creates an anonymous proxy and prints a claim URL)").option("--name <name>", "Proxy name (becomes <name>.apiblaze.com)").option("--target <url>", "Target URL to forward requests to").option("--team <id|name>", "Team to create under (defaults to your active team)").option("--auth <type>", "Auth type: api_key | none | oauth", "api_key").option("--apiversion <version>", "API version to create (e.g. 2.0.0). Creating a new version of a proxy you own adds a version to the existing project.").option("--tenant <slug>", "Tenant slug (anonymous create; generated if omitted)").option("--product <slug>", "Product slug (anonymous create; defaults to the proxy name)").option("--display-name <name>", "Human-friendly display name").option("--subdomain <slug>", "Explicit subdomain (defaults to --name)").option("--config <file>", "JSON file with the full request body (anonymous create): requests_auth, login providers + client/server token types, scopes, callback URLs, etc. See apiblaze_anonymous.yaml. Flags override its fields.").option("-y, --yes", "Skip the confirmation prompt").option("--json", "Output machine-readable JSON (non-interactive)").action(async (opts) => {
1789
+ program.command("create").description("Create a new API proxy (no login needed \u2014 without auth it creates an anonymous proxy and prints a claim URL)").option("--name <name>", "Proxy name (becomes <name>.apiblaze.com)").option("--target <url>", "Target URL to forward requests to").option("--team <id|name>", "Team to create under (defaults to your active team)").option("--auth <type>", "Auth type: api_key | none | oauth", "api_key").option("--apiversion <version>", "API version to create (e.g. 2.0.0). Creating a new version of a proxy you own adds a version to the existing project.").option("--tenant <slug>", "Tenant slug (anonymous create; generated if omitted)").option("--product <slug>", "Product tag to group this project under in the portal (team-scoped; anonymous create). Defaults to your team's existing/placeholder tag.").option("--display-name <name>", "Human-friendly display name").option("--subdomain <slug>", "Explicit subdomain (defaults to --name)").option("--config <file>", "JSON file with the full request body (anonymous create): requests_auth, login providers + client/server token types, scopes, callback URLs, etc. See apiblaze_anonymous.yaml. Flags override its fields.").option("-y, --yes", "Skip the confirmation prompt").option("--json", "Output machine-readable JSON (non-interactive)").action(async (opts) => {
1875
1790
  try {
1876
1791
  await runCreate(opts);
1877
1792
  } catch (err) {
@@ -1947,7 +1862,7 @@ program.command("dev").description("Start a dev tunnel for your localhost projec
1947
1862
  try {
1948
1863
  const resolved = parseInt(port ?? opts.port, 10);
1949
1864
  if (Number.isNaN(resolved)) {
1950
- console.error(import_chalk14.default.red(`Invalid port: ${port ?? opts.port}`));
1865
+ console.error(import_chalk15.default.red(`Invalid port: ${port ?? opts.port}`));
1951
1866
  process.exit(1);
1952
1867
  }
1953
1868
  await runDev({ port: resolved, captureFile: opts.captureFile });
@@ -1984,13 +1899,13 @@ Examples:
1984
1899
  );
1985
1900
  function printError(err) {
1986
1901
  if (err instanceof ApiError) {
1987
- console.error(import_chalk14.default.red(`
1902
+ console.error(import_chalk15.default.red(`
1988
1903
  API error (${err.status}): ${err.message}`));
1989
1904
  } else if (err instanceof Error) {
1990
- console.error(import_chalk14.default.red(`
1905
+ console.error(import_chalk15.default.red(`
1991
1906
  Error: ${err.message}`));
1992
1907
  } else {
1993
- console.error(import_chalk14.default.red("\nUnknown error"));
1908
+ console.error(import_chalk15.default.red("\nUnknown error"));
1994
1909
  }
1995
1910
  }
1996
1911
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Dev tunnel CLI for APIblaze — route localhost projects through your APIblaze endpoints",
5
5
  "keywords": [
6
6
  "apiblaze",