apiblaze 0.19.13 → 0.19.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -933,7 +933,7 @@ var import_commander = require("commander");
933
933
  var import_chalk44 = __toESM(require("chalk"));
934
934
 
935
935
  // package.json
936
- var version = "0.19.13";
936
+ var version = "0.19.16";
937
937
 
938
938
  // src/index.ts
939
939
  init_types();
@@ -953,7 +953,7 @@ function decodeJWTPayload(token) {
953
953
  const part = token.split(".")[1];
954
954
  return JSON.parse(Buffer.from(part, "base64url").toString());
955
955
  }
956
- async function runLogin() {
956
+ async function runLogin(opts = {}) {
957
957
  console.log(import_chalk2.default.bold("\nLogging in to APIblaze...\n"));
958
958
  const codeRes = await fetch(`${DASHBOARD_BASE2}/api/device/code`, { method: "POST" });
959
959
  if (!codeRes.ok) {
@@ -1018,15 +1018,28 @@ async function runLogin() {
1018
1018
  }
1019
1019
  let teamId = defaultTeamId ?? void 0;
1020
1020
  let teamName;
1021
- const linked = await resolveLinkedTeam({
1022
- preferredId: defaultTeamId ?? void 0,
1023
- interactive: !!process.stdin.isTTY,
1024
- // >1 team ASK, with the account default as the cursor (one Enter accepts
1025
- // it). One team → link silently. Jay 2026-07-26: silent default was tried
1026
- // and reverted landing in the wrong team unnoticed is worse than the
1027
- // extra Enter when you have several teams.
1028
- promptWhenMultiple: true
1029
- });
1021
+ let linked = null;
1022
+ if (opts.team && opts.team !== "default") {
1023
+ const { getTeams: getTeams2 } = await Promise.resolve().then(() => (init_api(), api_exports));
1024
+ const teams = await getTeams2();
1025
+ const want = opts.team.toLowerCase();
1026
+ const hit = teams.find((t) => t.teamId === opts.team || (t.name ?? "").toLowerCase() === want);
1027
+ if (!hit) {
1028
+ throw new Error(`--team "${opts.team}" doesn't match any of your teams: ${teams.map((t) => t.name || t.teamId).join(", ") || "(none)"}`);
1029
+ }
1030
+ linked = { teamId: hit.teamId, teamName: hit.name };
1031
+ } else {
1032
+ linked = await resolveLinkedTeam({
1033
+ preferredId: defaultTeamId ?? void 0,
1034
+ // --team default = take the account default silently, no picker.
1035
+ interactive: !opts.team && !!process.stdin.isTTY,
1036
+ // >1 team → ASK, with the account default as the cursor (one Enter accepts
1037
+ // it). One team → link silently. Jay 2026-07-26: silent default was tried
1038
+ // and reverted — landing in the wrong team unnoticed is worse than the
1039
+ // extra Enter when you have several teams.
1040
+ promptWhenMultiple: true
1041
+ });
1042
+ }
1030
1043
  if (linked) {
1031
1044
  teamId = linked.teamId;
1032
1045
  teamName = linked.teamName;
@@ -2671,8 +2684,13 @@ async function runAgentChatRepl(opts) {
2671
2684
  ctx.proposal = data.proposal;
2672
2685
  const summary = summarizeProposal?.(data);
2673
2686
  if (summary) console.log(import_chalk16.default.yellow(" " + summary));
2674
- const ready = commands.filter((c) => c.needsProposal).map((c) => `/${c.name}`).join(" or ");
2675
- if (ready) console.log(import_chalk16.default.dim(` Ready \u2014 ${ready} to make it official, or keep refining.`));
2687
+ const applies = commands.filter((c) => c.needsProposal);
2688
+ const primary = applies[applies.length - 1];
2689
+ if (primary) {
2690
+ console.log(import_chalk16.default.bold.green(" \u279C Next: type ") + import_chalk16.default.bold.cyan(`/${primary.name}`) + import_chalk16.default.bold.green(" to apply this, then ") + import_chalk16.default.bold.cyan("/exit") + import_chalk16.default.bold.green(" to leave."));
2691
+ const rest = applies.slice(0, -1).map((c) => `/${c.name} = ${c.describe}`).join(" \xB7 ");
2692
+ console.log(import_chalk16.default.dim(` (or keep chatting to refine${rest ? ` \xB7 ${rest}` : ""} \xB7 /show = inspect)`));
2693
+ }
2676
2694
  console.log();
2677
2695
  }
2678
2696
  const line = formatBilling(data.billing);
@@ -7390,9 +7408,9 @@ function action(fn) {
7390
7408
  }
7391
7409
  };
7392
7410
  }
7393
- program.command("login").description("Authenticate with APIblaze").action(async () => {
7411
+ program.command("login").description("Authenticate with APIblaze").option("--team <idOrName>", 'Link this team without prompting ("default" = accept the account default) \u2014 for scripted runs').action(async (opts) => {
7394
7412
  try {
7395
- await runLogin();
7413
+ await runLogin(opts);
7396
7414
  } catch (err) {
7397
7415
  await printError(err);
7398
7416
  process.exit(1);
@@ -26,6 +26,10 @@ interface UsersGroupsWidgetProps {
26
26
  theme?: UsersGroupsWidgetTheme;
27
27
  /** Heading text. Default "Users & groups". */
28
28
  title?: string;
29
+ /** Auto-expand the group with this NAME on first load (if it exists) — e.g.
30
+ * a demo landing the user on the group it just talked about. One-shot: the
31
+ * user can still collapse it; later refreshes don't force it back open. */
32
+ defaultOpenGroup?: string;
29
33
  className?: string;
30
34
  }
31
35
  interface UsersGroupsWidgetHandle {
@@ -26,6 +26,10 @@ interface UsersGroupsWidgetProps {
26
26
  theme?: UsersGroupsWidgetTheme;
27
27
  /** Heading text. Default "Users & groups". */
28
28
  title?: string;
29
+ /** Auto-expand the group with this NAME on first load (if it exists) — e.g.
30
+ * a demo landing the user on the group it just talked about. One-shot: the
31
+ * user can still collapse it; later refreshes don't force it back open. */
32
+ defaultOpenGroup?: string;
29
33
  className?: string;
30
34
  }
31
35
  interface UsersGroupsWidgetHandle {
@@ -169,7 +169,7 @@ function Typeahead(props) {
169
169
  ] })
170
170
  ] });
171
171
  }
172
- var UsersGroupsWidget = React.forwardRef(function UsersGroupsWidget2({ endpoint = "/api/apiblaze/groups", theme, title = "Users & groups", className }, ref) {
172
+ var UsersGroupsWidget = React.forwardRef(function UsersGroupsWidget2({ endpoint = "/api/apiblaze/groups", theme, title = "Users & groups", defaultOpenGroup, className }, ref) {
173
173
  const t = { ...DEFAULTS, ...theme ?? {} };
174
174
  const headerBg = t.headerBackground || t.surface;
175
175
  const [access, setAccess] = React.useState("ok");
@@ -298,6 +298,16 @@ var UsersGroupsWidget = React.forwardRef(function UsersGroupsWidget2({ endpoint
298
298
  setOpen(g.id);
299
299
  loadDetail(g.id);
300
300
  }
301
+ const autoOpened = React.useRef(false);
302
+ React.useEffect(() => {
303
+ if (autoOpened.current || !defaultOpenGroup || open) return;
304
+ const g = (groups ?? []).find((x) => x.name === defaultOpenGroup);
305
+ if (g) {
306
+ autoOpened.current = true;
307
+ setOpen(g.id);
308
+ loadDetail(g.id);
309
+ }
310
+ }, [groups, open, defaultOpenGroup, loadDetail]);
301
311
  async function act(label, body, after) {
302
312
  setPending(label);
303
313
  setErr(null);
@@ -134,7 +134,7 @@ function Typeahead(props) {
134
134
  ] })
135
135
  ] });
136
136
  }
137
- var UsersGroupsWidget = React.forwardRef(function UsersGroupsWidget2({ endpoint = "/api/apiblaze/groups", theme, title = "Users & groups", className }, ref) {
137
+ var UsersGroupsWidget = React.forwardRef(function UsersGroupsWidget2({ endpoint = "/api/apiblaze/groups", theme, title = "Users & groups", defaultOpenGroup, className }, ref) {
138
138
  const t = { ...DEFAULTS, ...theme ?? {} };
139
139
  const headerBg = t.headerBackground || t.surface;
140
140
  const [access, setAccess] = React.useState("ok");
@@ -263,6 +263,16 @@ var UsersGroupsWidget = React.forwardRef(function UsersGroupsWidget2({ endpoint
263
263
  setOpen(g.id);
264
264
  loadDetail(g.id);
265
265
  }
266
+ const autoOpened = React.useRef(false);
267
+ React.useEffect(() => {
268
+ if (autoOpened.current || !defaultOpenGroup || open) return;
269
+ const g = (groups ?? []).find((x) => x.name === defaultOpenGroup);
270
+ if (g) {
271
+ autoOpened.current = true;
272
+ setOpen(g.id);
273
+ loadDetail(g.id);
274
+ }
275
+ }, [groups, open, defaultOpenGroup, loadDetail]);
266
276
  async function act(label, body, after) {
267
277
  setPending(label);
268
278
  setErr(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.19.13",
3
+ "version": "0.19.16",
4
4
  "description": "APIblaze CLI — Chat with your APIs, Manage your API keys, users and groups with the APIblaze serverless proxy",
5
5
  "keywords": [
6
6
  "apiblaze",
@@ -77,10 +77,10 @@
77
77
  "devDependencies": {
78
78
  "@types/inquirer": "^8.2.10",
79
79
  "@types/node": "^20.0.0",
80
+ "@types/react": "^18.2.0",
80
81
  "@types/ws": "^8.5.10",
81
82
  "tsup": "^8.0.0",
82
- "typescript": "^5.4.0",
83
- "@types/react": "^18.2.0"
83
+ "typescript": "^5.4.0"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "react": ">=17"