@backifydev/cli 0.4.11 → 0.4.12

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 +3 -0
  2. package/dist/index.js +406 -122
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -21,6 +21,9 @@ backify task get|wait|open <task-id>
21
21
  backify org | backify billing | backify members invite ada@example.com --role Admin
22
22
  backify members add ada@example.com bo@example.com --app <application-id>="Application owner" # members get it now, new people by invitation
23
23
  backify members list --status invited | backify members invitations | backify members join-links | backify members domains
24
+ backify teams show Payments | backify teams add Payments ada@example.com --role manager # managers add people; new people are invited
25
+ backify teams suggest Payments bo@example.com --note "Payouts" | backify teams requests | backify teams approve <request-id>
26
+ backify apps owner <application-id> --team Payments # a team owner gives its members Application owner
24
27
  ```
25
28
 
26
29
  `update-runtime` approves the upgrade Backify proposed and verified: applications are not redeployed and the previous version is kept until the upgrade is committed. If an upgrade is already in progress it exits 0 and prints the current phase.
package/dist/index.js CHANGED
@@ -1577,8 +1577,8 @@ function searchOperations(operations, query = "", group) {
1577
1577
  let best = 0;
1578
1578
  for (const [fieldWords, weight] of fields)
1579
1579
  for (const word of fieldWords) {
1580
- const base = singular(word);
1581
- const value = base === exact ? weight : related.has(base) ? weight * 0.8 : base.startsWith(exact) && term.length >= 3 ? weight * 0.6 : nearlyEqual(base, exact) ? weight * 0.5 : 0;
1580
+ const base2 = singular(word);
1581
+ const value = base2 === exact ? weight : related.has(base2) ? weight * 0.8 : base2.startsWith(exact) && term.length >= 3 ? weight * 0.6 : nearlyEqual(base2, exact) ? weight * 0.5 : 0;
1582
1582
  if (value > best)
1583
1583
  best = value;
1584
1584
  }
@@ -7683,7 +7683,7 @@ async function runMove(call2, prefix, options, context2) {
7683
7683
  const placements = await call2(prefix + "/environments/placements");
7684
7684
  const current = placements.find((item) => item.kind === options.kind);
7685
7685
  if (!current) throw new CommandError("This application has no " + options.kind + " environment.", "environment_not_activated", { kind: options.kind });
7686
- const base = prefix + "/environments/" + current.environmentId + "/moves";
7686
+ const base2 = prefix + "/environments/" + current.environmentId + "/moves";
7687
7687
  const confirmed = async (summary, details) => {
7688
7688
  if (options.yes) return;
7689
7689
  if (!context2.confirm) throw new CommandError("Refusing to change a hosting move without confirmation. Review this and re-run with --yes:\n" + summary, "confirmation_required", { kind: options.kind, ...details });
@@ -7691,17 +7691,17 @@ async function runMove(call2, prefix, options, context2) {
7691
7691
  };
7692
7692
  if (options.moveAction === "request") {
7693
7693
  const query = "destinationTargetId=" + encodeURIComponent(options.target) + "&windowStart=" + encodeURIComponent(options.windowStart) + "&windowEnd=" + encodeURIComponent(options.windowEnd);
7694
- const preflight = await call2(base + "/preflight?" + query);
7694
+ const preflight = await call2(base2 + "/preflight?" + query);
7695
7695
  const checks = pad([["CHECK", "RESULT", "DETAIL"], ...preflight.checks.map((check) => [check.name, check.state, check.detail ?? ""])]);
7696
7696
  const failed = preflight.checks.filter((check) => check.state === "failed").map((check) => check.id);
7697
7697
  if (!preflight.ready) return { exitCode: 2, value: { status: "blocked", kind: options.kind, destinationTargetId: options.target, failed, checks: preflight.checks }, text: [...checks, "", "The " + options.kind + " environment cannot be moved to this hosting target in this window. Nothing was changed."].join("\n") };
7698
7698
  if (options.check) return { value: { status: "ready", kind: options.kind, destinationTargetId: options.target, checks: preflight.checks }, text: [...checks, "", "All checks passed. Nothing was changed; re-run without --check to request the move."].join("\n") };
7699
7699
  await confirmed("Request moving the " + options.kind + " environment to deployment target " + options.target + " in the window " + options.windowStart + " to " + options.windowEnd + ". Another person must approve it; the environment goes into maintenance only when the move is started.", { destinationTargetId: options.target });
7700
- const result = await call2(base, { method: "POST", body: JSON.stringify({ destinationTargetId: options.target, windowStart: options.windowStart, windowEnd: options.windowEnd }) });
7700
+ const result = await call2(base2, { method: "POST", body: JSON.stringify({ destinationTargetId: options.target, windowStart: options.windowStart, windowEnd: options.windowEnd }) });
7701
7701
  if (!result.created || !result.move) return { exitCode: 2, value: { status: "blocked", kind: options.kind, destinationTargetId: options.target, failed: result.preflight.checks.filter((check) => check.state === "failed").map((check) => check.id), checks: result.preflight.checks }, text: "The checks no longer pass. Nothing was changed." };
7702
7702
  return { value: { status: "requested", kind: options.kind, move: result.move }, text: ["The move of the " + options.kind + " environment awaits approval. Another person approves it on the organization's Approvals page.", "", ...moveSummary(result.move)].join("\n") };
7703
7703
  }
7704
- const moves = await call2(base);
7704
+ const moves = await call2(base2);
7705
7705
  const move = moves.find((item) => !moveTerminal(item)) ?? moves[0];
7706
7706
  if (options.moveAction === "status") return { value: { move: move ?? null }, text: move ? moveSummary(move).join("\n") : "The " + options.kind + " environment has no hosting move." };
7707
7707
  if (!move) throw new CommandError("The " + options.kind + " environment has no hosting move.", "hosting_move_not_found", { kind: options.kind });
@@ -7713,15 +7713,15 @@ async function runMove(call2, prefix, options, context2) {
7713
7713
  if (options.active !== move.sourceTargetId && options.active !== move.destinationTargetId) throw new CommandError("--active must be the current target " + move.sourceTargetId + " or the destination " + move.destinationTargetId + ".", "hosting_move_confirm_target_invalid", { kind: options.kind });
7714
7714
  await confirmed("Confirm that deployment target " + options.active + " is serving the " + options.kind + " environment. The outcome of the switch is unknown; only confirm after checking.", { action, active: options.active });
7715
7715
  }
7716
- const updated = await call2(base + "/" + move.id + "/" + action, { method: "POST", ...action === "confirm" ? { body: JSON.stringify({ activeTargetId: options.active }) } : {} });
7716
+ const updated = await call2(base2 + "/" + move.id + "/" + action, { method: "POST", ...action === "confirm" ? { body: JSON.stringify({ activeTargetId: options.active }) } : {} });
7717
7717
  return { value: { status: action, kind: options.kind, move: updated }, text: ["The " + options.kind + " move: " + action + " accepted.", "", ...moveSummary(updated)].join("\n") };
7718
7718
  }
7719
7719
  async function runMoveBack(call2, prefix, options) {
7720
7720
  const placements = await call2(prefix + "/environments/placements");
7721
7721
  const current = placements.find((item) => item.kind === options.kind);
7722
7722
  if (!current) throw new CommandError("This application has no " + options.kind + " environment.", "environment_not_activated", { kind: options.kind });
7723
- const base = prefix + "/environments/" + current.environmentId + "/moves";
7724
- const moves = await call2(base);
7723
+ const base2 = prefix + "/environments/" + current.environmentId + "/moves";
7724
+ const moves = await call2(base2);
7725
7725
  const completed = moves.find((item) => item.state === "completed");
7726
7726
  if (!completed) throw new CommandError("The " + options.kind + " environment has no completed hosting move to move back.", "hosting_move_not_found", { kind: options.kind });
7727
7727
  const kept2 = completed.retained ? " The copy there is kept until " + completed.retained.retainedUntil + "; it is reused and checked first." : "";
@@ -7733,7 +7733,7 @@ async function runMoveBack(call2, prefix, options) {
7733
7733
  "confirmation_required",
7734
7734
  { kind: options.kind, moveId: completed.id, ...slug ? { confirm: slug } : {} }
7735
7735
  );
7736
- const result = await call2(base + "/" + completed.id + "/move-back", { method: "POST", body: JSON.stringify({ windowStart: options.windowStart, windowEnd: options.windowEnd }) });
7736
+ const result = await call2(base2 + "/" + completed.id + "/move-back", { method: "POST", body: JSON.stringify({ windowStart: options.windowStart, windowEnd: options.windowEnd }) });
7737
7737
  if (!result.created || !result.move) {
7738
7738
  const failed = result.preflight.checks.filter((check) => check.state === "failed");
7739
7739
  return {
@@ -8043,7 +8043,7 @@ var init_package = __esm({
8043
8043
  "package.json"() {
8044
8044
  package_default = {
8045
8045
  name: "@backifydev/cli",
8046
- version: "0.4.11",
8046
+ version: "0.4.12",
8047
8047
  description: "Command-line setup and diagnostics for Backify applications",
8048
8048
  type: "module",
8049
8049
  bin: {
@@ -8510,11 +8510,11 @@ function ensureSessionOutlasts(session, durationMs, now = Date.now()) {
8510
8510
  if (remaining < durationMs) throw new CliAuthenticationRequired(`Backify CLI access for this app ends in ${Math.max(1, Math.floor(remaining / 6e4))} minute(s), before backify ship could finish (it waits up to ${Math.ceil(durationMs / 6e4)} minutes). Nothing was pushed. Ask the user to sign in, then run backify connect --reauth and ship again. The browser lets them choose 7, 14, 30, or 90 days.`);
8511
8511
  }
8512
8512
  function apiClient(session, transport = fetch) {
8513
- const base = apiAddress(session.apiUrl);
8513
+ const base2 = apiAddress(session.apiUrl);
8514
8514
  return async (path, init) => {
8515
8515
  if (!path.startsWith("/") || path.startsWith("//")) throw new Error("Invalid API path.");
8516
8516
  if (session.expiresAt && Date.parse(session.expiresAt) <= Date.now()) throw new CliAuthenticationRequired();
8517
- const response = await transport(base + path, { ...init, redirect: "error", signal: AbortSignal.timeout(3e4), headers: { ...init?.body instanceof FormData ? {} : { "content-type": "application/json" }, ...cliHeaders, "X-Organization-ID": session.organizationId, ...session.token ? { authorization: "Bearer " + session.token } : {}, ...init?.headers } });
8517
+ const response = await transport(base2 + path, { ...init, redirect: "error", signal: AbortSignal.timeout(3e4), headers: { ...init?.body instanceof FormData ? {} : { "content-type": "application/json" }, ...cliHeaders, "X-Organization-ID": session.organizationId, ...session.token ? { authorization: "Bearer " + session.token } : {}, ...init?.headers } });
8518
8518
  showClientNotice(response);
8519
8519
  if (!response.ok) {
8520
8520
  if (response.status === 401) throw new CliAuthenticationRequired();
@@ -11099,7 +11099,7 @@ function datetime(args2) {
11099
11099
  const timeRegex = args2.local ? `${qualified}|${timeSource({ precision: args2.precision })}` : qualified;
11100
11100
  return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
11101
11101
  }
11102
- var cuid, cuid2, ulid, xid, ksuid, nanoid, duration2, guid4, uuid9, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base642, base64url, httpProtocol, e164, dateSource, date, anyString, bigint, integer2, number, boolean, _null, lowercase, uppercase;
11102
+ var cuid, cuid2, ulid, xid, ksuid, nanoid, duration2, guid5, uuid9, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base642, base64url, httpProtocol, e164, dateSource, date, anyString, bigint, integer2, number, boolean, _null, lowercase, uppercase;
11103
11103
  var init_regexes = __esm({
11104
11104
  "../../node_modules/zod/v4/core/regexes.js"() {
11105
11105
  cuid = /^[cC][0-9a-z]{6,}$/;
@@ -11109,7 +11109,7 @@ var init_regexes = __esm({
11109
11109
  ksuid = /^[A-Za-z0-9]{27}$/;
11110
11110
  nanoid = /^[a-zA-Z0-9_-]{21}$/;
11111
11111
  duration2 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
11112
- guid4 = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
11112
+ guid5 = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
11113
11113
  uuid9 = (version2) => {
11114
11114
  if (!version2)
11115
11115
  return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
@@ -12124,7 +12124,7 @@ var init_schemas = __esm({
12124
12124
  $ZodString.init(inst, def);
12125
12125
  });
12126
12126
  $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
12127
- def.pattern ?? (def.pattern = guid4);
12127
+ def.pattern ?? (def.pattern = guid5);
12128
12128
  $ZodStringFormat.init(inst, def);
12129
12129
  });
12130
12130
  $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
@@ -13442,14 +13442,14 @@ var init_memoizer = __esm({
13442
13442
  var _a3;
13443
13443
  (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
13444
13444
  inst._zod.deferred.push(() => {
13445
- const base = inst._zod.parse;
13445
+ const base2 = inst._zod.parse;
13446
13446
  const wrapped = (payload, ctx) => {
13447
13447
  if (ctx.direction !== "backward" && isBackEdge(ctx, payload.value))
13448
13448
  throw new $ZodCyclicError();
13449
- return base(payload, ctx);
13449
+ return base2(payload, ctx);
13450
13450
  };
13451
13451
  inst._zod.parse = wrapped;
13452
- if (inst._zod.run === base)
13452
+ if (inst._zod.run === base2)
13453
13453
  inst._zod.run = wrapped;
13454
13454
  });
13455
13455
  },
@@ -13461,15 +13461,15 @@ var init_memoizer = __esm({
13461
13461
  let lastBucket;
13462
13462
  (_a3 = inst._zod).deferred ?? (_a3.deferred = []);
13463
13463
  inst._zod.deferred.push(() => {
13464
- const base = inst._zod.parse;
13464
+ const base2 = inst._zod.parse;
13465
13465
  const wrapped = (payload, ctx) => {
13466
13466
  if (isRecursiveInst === void 0) {
13467
13467
  const walked = isRecursive(inst, /* @__PURE__ */ new Set(), false);
13468
13468
  if (walked === NONE) {
13469
- inst._zod.parse = base;
13469
+ inst._zod.parse = base2;
13470
13470
  if (inst._zod.run === wrapped)
13471
- inst._zod.run = base;
13472
- return base(payload, ctx);
13471
+ inst._zod.run = base2;
13472
+ return base2(payload, ctx);
13473
13473
  }
13474
13474
  if (walked === PROVEN || rechecked)
13475
13475
  isRecursiveInst = true;
@@ -13478,7 +13478,7 @@ var init_memoizer = __esm({
13478
13478
  }
13479
13479
  const input = payload.value;
13480
13480
  if (!isRef(input))
13481
- return base(payload, ctx);
13481
+ return base2(payload, ctx);
13482
13482
  let state = ctx[STATE];
13483
13483
  if (!state) {
13484
13484
  state = { buckets: /* @__PURE__ */ new WeakMap(), backEdges: void 0 };
@@ -13507,7 +13507,7 @@ var init_memoizer = __esm({
13507
13507
  }
13508
13508
  handoff = bucket;
13509
13509
  const depth = open.length;
13510
- const result = base(payload, ctx);
13510
+ const result = base2(payload, ctx);
13511
13511
  handoff = void 0;
13512
13512
  const entry = open.length > depth ? open.pop() : void 0;
13513
13513
  if (result instanceof Promise) {
@@ -13522,7 +13522,7 @@ var init_memoizer = __esm({
13522
13522
  return result;
13523
13523
  };
13524
13524
  inst._zod.parse = wrapped;
13525
- if (inst._zod.run === base)
13525
+ if (inst._zod.run === base2)
13526
13526
  inst._zod.run = wrapped;
13527
13527
  });
13528
13528
  }
@@ -18684,8 +18684,8 @@ var init_zod_json_schema_compat = __esm({
18684
18684
  function isPlainObject2(value) {
18685
18685
  return value !== null && typeof value === "object" && !Array.isArray(value);
18686
18686
  }
18687
- function mergeCapabilities(base, additional) {
18688
- const result = { ...base };
18687
+ function mergeCapabilities(base2, additional) {
18688
+ const result = { ...base2 };
18689
18689
  for (const key in additional) {
18690
18690
  const k = key;
18691
18691
  const addValue = additional[k];
@@ -23544,10 +23544,10 @@ var require_fast_uri = __commonJS({
23544
23544
  schemelessOptions.skipEscape = true;
23545
23545
  return serialize(resolved, schemelessOptions);
23546
23546
  }
23547
- function resolveComponent(base, relative5, options, skipNormalization) {
23547
+ function resolveComponent(base2, relative5, options, skipNormalization) {
23548
23548
  const target = {};
23549
23549
  if (!skipNormalization) {
23550
- base = parse4(serialize(base, options), options);
23550
+ base2 = parse4(serialize(base2, options), options);
23551
23551
  relative5 = parse4(serialize(relative5, options), options);
23552
23552
  }
23553
23553
  options = options || {};
@@ -23567,33 +23567,33 @@ var require_fast_uri = __commonJS({
23567
23567
  target.query = relative5.query;
23568
23568
  } else {
23569
23569
  if (!relative5.path) {
23570
- target.path = base.path;
23570
+ target.path = base2.path;
23571
23571
  if (relative5.query !== void 0) {
23572
23572
  target.query = relative5.query;
23573
23573
  } else {
23574
- target.query = base.query;
23574
+ target.query = base2.query;
23575
23575
  }
23576
23576
  } else {
23577
23577
  if (relative5.path[0] === "/") {
23578
23578
  target.path = removeDotSegments(relative5.path);
23579
23579
  } else {
23580
- const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
23581
- if (baseHasAuthority && !base.path) {
23580
+ const baseHasAuthority = base2.userinfo !== void 0 || base2.host !== void 0 || base2.port !== void 0;
23581
+ if (baseHasAuthority && !base2.path) {
23582
23582
  target.path = "/" + relative5.path;
23583
- } else if (!base.path) {
23583
+ } else if (!base2.path) {
23584
23584
  target.path = relative5.path;
23585
23585
  } else {
23586
- target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative5.path;
23586
+ target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative5.path;
23587
23587
  }
23588
- target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
23588
+ target.path = base2.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
23589
23589
  }
23590
23590
  target.query = relative5.query;
23591
23591
  }
23592
- target.userinfo = base.userinfo;
23593
- target.host = base.host;
23594
- target.port = base.port;
23592
+ target.userinfo = base2.userinfo;
23593
+ target.host = base2.host;
23594
+ target.port = base2.port;
23595
23595
  }
23596
- target.scheme = base.scheme;
23596
+ target.scheme = base2.scheme;
23597
23597
  }
23598
23598
  target.fragment = relative5.fragment;
23599
23599
  return target;
@@ -30297,9 +30297,11 @@ __export(tasks_exports, {
30297
30297
  runTaskCommand: () => runTaskCommand,
30298
30298
  runtimeUpgradeText: () => runtimeUpgradeText,
30299
30299
  startTask: () => startTask,
30300
+ suggestionText: () => suggestionText,
30300
30301
  taskArguments: () => taskArguments,
30301
30302
  taskDraft: () => taskDraft,
30302
30303
  taskHelp: () => taskHelp,
30304
+ teamDetailsText: () => teamDetailsText,
30303
30305
  teamsText: () => teamsText
30304
30306
  });
30305
30307
  import { readFileSync as readFileSync15 } from "node:fs";
@@ -30558,19 +30560,24 @@ function teamsText(snapshot) {
30558
30560
  ].join("\n");
30559
30561
  }).join("\n");
30560
30562
  }
30561
- async function teamCommand(call2, organizationId, sub, target, values, options, context2) {
30563
+ function changeConfirmation(options, context2) {
30564
+ return async (summary) => {
30565
+ if (options.yes) return;
30566
+ if (!context2.confirm) throw new OpsError(`Refusing to change team access without confirmation. Re-run with --yes to ${summary}.`, "confirmation_required");
30567
+ if (!await context2.confirm(summary[0].toUpperCase() + summary.slice(1) + "?")) throw new OpsError("Not confirmed. Nothing was changed.", "not_confirmed");
30568
+ };
30569
+ }
30570
+ async function teamCommand(call2, organizationId, positional, values, options, context2) {
30562
30571
  const root = `/organizations/${organizationId}`;
30572
+ const [sub, target] = positional;
30573
+ const confirm = changeConfirmation(options, context2);
30574
+ if (sub && !["list", "grant", "revoke"].includes(sub)) return teamPeopleCommand(call2, organizationId, sub, positional, values, confirm);
30563
30575
  const snapshot = await call2(`${root}/access`);
30564
30576
  if (!sub || sub === "list") return { value: snapshot.teams.map((team) => ({
30565
30577
  ...team,
30566
30578
  members: snapshot.teamMembers.filter((member) => member.teamId === team.id).map((member) => member.userId),
30567
30579
  roles: snapshot.assignments.filter((assignment) => assignment.subjectType === "team" && assignment.subjectId === team.id)
30568
30580
  })), text: teamsText(snapshot) };
30569
- const confirm = async (summary) => {
30570
- if (options.yes) return;
30571
- if (!context2.confirm) throw new OpsError(`Refusing to change team access without confirmation. Re-run with --yes to ${summary}.`, "confirmation_required");
30572
- if (!await context2.confirm(summary[0].toUpperCase() + summary.slice(1) + "?")) throw new OpsError("Not confirmed. Nothing was changed.", "not_confirmed");
30573
- };
30574
30581
  if (sub === "grant") {
30575
30582
  const team = snapshot.teams.find((value) => value.id === target || value.name.toLowerCase() === target?.toLowerCase());
30576
30583
  if (!team) throw new Error("Name the team by ID or name, e.g. backify teams grant Support --role Viewer --app <id>.");
@@ -30589,7 +30596,128 @@ async function teamCommand(call2, organizationId, sub, target, values, options,
30589
30596
  await call2(`${root}/access/assignments/${grant.id}`, { method: "DELETE" });
30590
30597
  return { value: { revoked: grant.id }, text: `${grant.role} revoked from ${team?.name ?? "the team"}.`, exitCode: 0 };
30591
30598
  }
30592
- throw new Error("Use backify teams, backify teams grant <team> --role <role> [--workspace <id>|--app <id>], or backify teams revoke <assignment-id>.");
30599
+ throw new Error("Use backify teams, backify teams show|create|add|suggest|remove|join|requests|approve|decline|activity, backify teams grant <team> --role <role> [--workspace <id>|--app <id>], or backify teams revoke <assignment-id>.");
30600
+ }
30601
+ function teamDetailsText(team) {
30602
+ return [
30603
+ `${team.name} (${team.id})${team.myRole ? " \u2014 you are " + (team.myRole === "manager" ? "a manager" : "a member") : ""}`,
30604
+ `Members (${team.members.length}):`,
30605
+ ...team.members.length ? team.members.map((member) => ` ${member.displayName} <${member.email}>${member.role === "manager" ? " [manager]" : ""}${member.isSuspended ? " [suspended]" : ""}`) : [" none"],
30606
+ ...team.pending.length ? ["On their way in:", ...team.pending.map((person) => ` ${person.email}: ${person.status === "suggested" ? "suggested" + (person.requestedBy ? " by " + person.requestedBy : "") + ", waiting for a manager" + (person.requestId ? ` [request ${person.requestId}]` : "") : "invited, not joined yet"}`)] : [],
30607
+ `Owns (${team.applications.length + team.hiddenApplications}):`,
30608
+ ...team.applications.length ? team.applications.map((app) => ` ${app.name} (${app.workspaceName}, ${app.status}): members have Application owner`) : [" no applications you can see"],
30609
+ "Roles granted:",
30610
+ ...team.grants.length ? team.grants.map((grant) => ` ${grant.role} on ${grant.scopeType} ${grant.scopeId} [assignment ${grant.id}]`) : [" none"]
30611
+ ].join("\n");
30612
+ }
30613
+ function suggestionText(reply) {
30614
+ return reply.people.map((person) => `${person.email}: ${outcomeText[person.outcome] ?? person.outcome}${person.detail ? " (" + person.detail + ")" : ""}`).join("\n");
30615
+ }
30616
+ async function resolveTeam(call2, root, target, example) {
30617
+ const team = (await call2(`${root}/teams/summary`)).find((value) => value.id === target || value.name.toLowerCase() === target?.toLowerCase());
30618
+ if (!team) throw new Error(`Name the team by ID or name, e.g. ${example}.`);
30619
+ return team;
30620
+ }
30621
+ async function teamPeopleCommand(call2, organizationId, sub, positional, values, confirm) {
30622
+ const root = `/organizations/${organizationId}`;
30623
+ const [, target] = positional;
30624
+ switch (sub) {
30625
+ case "show": {
30626
+ const team = await resolveTeam(call2, root, target, "backify teams show Support");
30627
+ const details = await call2(`${root}/teams/${team.id}`);
30628
+ return { value: details, text: teamDetailsText(details) };
30629
+ }
30630
+ case "create": {
30631
+ const name2 = positional.slice(1).join(" ").trim();
30632
+ if (!name2) throw new Error("Name the team, e.g. backify teams create Payments.");
30633
+ await confirm(`create team ${name2}`);
30634
+ const created = await call2(`${root}/teams`, { method: "POST", headers: json4, body: JSON.stringify({ name: name2, description: values.description?.[0] ?? "" }) });
30635
+ return { value: created, text: `Team ${created.name} created (${created.id}). Add people with backify teams add "${created.name}" <email...>.`, exitCode: 0 };
30636
+ }
30637
+ case "add":
30638
+ case "suggest": {
30639
+ const team = await resolveTeam(call2, root, target, `backify teams ${sub} Support ada@example.com`);
30640
+ const emails = positional.slice(2);
30641
+ if (!emails.length || emails.some((email2) => !emailPattern.test(email2))) throw new Error(`Pass one or more email addresses, e.g. backify teams ${sub} ${team.name} ada@example.com.`);
30642
+ const [role] = values.role ?? [];
30643
+ if (role !== void 0 && !["member", "manager"].includes(role)) throw new Error("--role is member or manager.");
30644
+ await confirm(`${sub} ${emails.join(", ")} ${sub === "add" ? "to" : "for"} team ${team.name}`);
30645
+ const reply = await call2(`${root}/teams/${team.id}/requests`, { method: "POST", headers: json4, body: JSON.stringify({ emails, note: values.note?.[0] ?? null }) });
30646
+ const lines = [suggestionText(reply)];
30647
+ if (role === "manager") {
30648
+ const details = await call2(`${root}/teams/${team.id}`);
30649
+ for (const email2 of emails) {
30650
+ const member = details.members.find((value) => value.email.toLowerCase() === email2.toLowerCase());
30651
+ if (!member) {
30652
+ lines.push(`${email2}: not in the team yet, so not made a manager`);
30653
+ continue;
30654
+ }
30655
+ await call2(`${root}/teams/${team.id}/members/${member.userId}`, { method: "PUT", headers: json4, body: JSON.stringify({ role: "manager" }) });
30656
+ lines.push(`${email2}: now a manager of ${team.name}`);
30657
+ }
30658
+ }
30659
+ return { value: reply, text: lines.join("\n"), exitCode: reply.people.every((person) => person.outcome === "skipped") ? 1 : 0 };
30660
+ }
30661
+ case "remove": {
30662
+ const team = await resolveTeam(call2, root, target, "backify teams remove Support ada@example.com");
30663
+ const email2 = positional[2];
30664
+ const details = await call2(`${root}/teams/${team.id}`);
30665
+ const member = details.members.find((value) => value.email.toLowerCase() === email2?.toLowerCase());
30666
+ if (!member) throw new Error(`Pass the email of someone in ${team.name}; backify teams show ${team.name} lists them.`);
30667
+ await confirm(`remove ${member.displayName} from team ${team.name}; they lose the access the team gives`);
30668
+ await call2(`${root}/teams/${team.id}/members/${member.userId}`, { method: "DELETE" });
30669
+ return { value: { removed: member.userId }, text: `${member.displayName} removed from ${team.name}.`, exitCode: 0 };
30670
+ }
30671
+ case "join": {
30672
+ const team = await resolveTeam(call2, root, target, "backify teams join Support");
30673
+ const reply = await call2(`${root}/teams/${team.id}/requests`, { method: "POST", headers: json4, body: JSON.stringify({ join: true, note: values.note?.[0] ?? null }) });
30674
+ return { value: reply, text: suggestionText(reply), exitCode: reply.people.every((person) => person.outcome === "skipped") ? 1 : 0 };
30675
+ }
30676
+ case "requests": {
30677
+ const path = target ? `${root}/teams/${(await resolveTeam(call2, root, target, "backify teams requests Support")).id}/requests` : `${root}/team-requests`;
30678
+ const rows = await call2(path);
30679
+ return { value: rows, text: rows.length ? rows.map((row) => `${row.id} ${row.teamName} ${row.displayName ?? row.email} ${row.status} suggested by ${row.requestedBy}${row.note ? ": " + row.note : ""}${row.canDecide && row.status === "pending" ? " (you can approve)" : ""}`).join("\n") : "No team requests." };
30680
+ }
30681
+ case "approve":
30682
+ case "decline": {
30683
+ if (!target || !isUuid(target)) throw new Error("Pass the request ID; backify teams requests lists them.");
30684
+ await confirm(`${sub} team request ${target}`);
30685
+ const reply = await call2(`${root}/team-requests/${target}/${sub}`, { method: "POST" });
30686
+ return { value: reply, text: suggestionText({ people: [reply] }), exitCode: 0 };
30687
+ }
30688
+ case "activity": {
30689
+ const team = await resolveTeam(call2, root, target, "backify teams activity Support");
30690
+ const page = await call2(`${root}/teams/${team.id}/activity?pageSize=50`);
30691
+ return { value: page, text: page.items.length ? page.items.map((item) => `${item.createdAt} ${item.actorName ?? item.actor} ${item.action.toLowerCase().replace(/_/g, " ")} ${item.resourceId}`).join("\n") : `No recent activity on applications ${team.name} owns.` };
30692
+ }
30693
+ }
30694
+ throw new Error("Unknown teams command.");
30695
+ }
30696
+ async function appOwnerCommand(call2, organizationId, appId, values, confirm) {
30697
+ if (!appId || !isUuid(appId)) throw new Error("Pass the application ID: backify apps owner <app-id> [--user <email> | --team <team>].");
30698
+ const [email2] = values.user ?? [], [teamName] = values.team ?? [];
30699
+ if (email2 && teamName) throw new Error("Pass --user or --team, not both.");
30700
+ const ownership = await call2(`/apps/${appId}/ownership`);
30701
+ if (!email2 && !teamName) {
30702
+ const who = ownership.ownerTeam ? `team ${ownership.ownerTeam.displayName}` : ownership.owner?.displayName ?? "nobody";
30703
+ return { value: ownership, text: `Owner: ${who}.${ownership.canChangeOwner ? " Change it with --user <email> or --team <team>." : ""}` };
30704
+ }
30705
+ let body, name2;
30706
+ if (teamName) {
30707
+ const team = await resolveTeam(call2, `/organizations/${organizationId}`, teamName, "backify apps owner <app-id> --team Payments");
30708
+ body = { userId: null, teamId: team.id, version: ownership.version };
30709
+ name2 = "team " + team.name;
30710
+ } else {
30711
+ if (!emailPattern.test(email2)) throw new Error("--user takes an email address.");
30712
+ const people = await call2(`/organizations/${organizationId}/access/people?search=${encodeURIComponent(email2)}&pageSize=10`);
30713
+ const person = people.items.find((item) => item.email.toLowerCase() === email2.toLowerCase());
30714
+ if (!person) throw new Error(`${email2} is not a member of this organization.`);
30715
+ body = { userId: person.id, teamId: null, version: ownership.version };
30716
+ name2 = person.displayName;
30717
+ }
30718
+ await confirm(`make ${name2} the owner of application ${appId}; ${teamName ? "everyone in the team gets" : "they get"} Application owner there`);
30719
+ await call2(`/apps/${appId}/owner`, { method: "PUT", headers: json4, body: JSON.stringify(body) });
30720
+ return { value: body, text: `${name2[0].toUpperCase() + name2.slice(1)} now owns application ${appId}.`, exitCode: 0 };
30593
30721
  }
30594
30722
  function costsText(view) {
30595
30723
  const trend = view.change === null ? "no costs in the previous " + view.days + " days" : `${view.change >= 0 ? "up" : "down"} ${Math.abs(Math.round(view.change * 100))}% from the previous ${view.days} days (${usd(view.previousTotal)})`;
@@ -30691,7 +30819,19 @@ async function runTaskCommand(command2, args2, context2) {
30691
30819
  case "teams list":
30692
30820
  case "teams grant":
30693
30821
  case "teams revoke":
30694
- return { result: await teamCommand(call2, organizationId, sub, target, values, options, context2), json: options.json };
30822
+ case "teams show":
30823
+ case "teams create":
30824
+ case "teams add":
30825
+ case "teams suggest":
30826
+ case "teams remove":
30827
+ case "teams join":
30828
+ case "teams requests":
30829
+ case "teams approve":
30830
+ case "teams decline":
30831
+ case "teams activity":
30832
+ return { result: await teamCommand(call2, organizationId, positional, values, options, context2), json: options.json };
30833
+ case "apps owner":
30834
+ return { result: await appOwnerCommand(call2, organizationId, target, values, changeConfirmation(options, context2)), json: options.json };
30695
30835
  case "costs": {
30696
30836
  const [days] = values.days ?? [], [groupBy] = values.by ?? [], [workspaceId] = values.workspace ?? [], [applicationId] = values.app ?? [], [ownerId] = values.owner ?? [];
30697
30837
  if (days !== void 0 && !/^\d{1,3}$/.test(days)) throw new Error("--days takes a number of days from 1 to 366.");
@@ -30784,7 +30924,7 @@ async function runTaskCommand(command2, args2, context2) {
30784
30924
  throw new Error("Unknown command.\n\n" + taskHelp);
30785
30925
  }
30786
30926
  }
30787
- var taskHelp, purposes, upgradeEnded, upgradeInProgress, json4, workspaceOption, connection, usd, percent;
30927
+ var taskHelp, purposes, upgradeEnded, upgradeInProgress, json4, workspaceOption, connection, emailPattern, outcomeText, usd, percent;
30788
30928
  var init_tasks = __esm({
30789
30929
  "src/tasks.ts"() {
30790
30930
  "use strict";
@@ -30829,6 +30969,18 @@ var init_tasks = __esm({
30829
30969
  " backify teams Teams, their members and the roles they grant",
30830
30970
  " backify teams grant <team> --role <role> [--workspace <id>|--app <id>] [--yes]",
30831
30971
  " backify teams revoke <assignment-id> [--yes] Grant or revoke a team role on the organization, a workspace or an application",
30972
+ " backify teams show <team> Members and managers, people on their way in, owned applications and roles",
30973
+ " backify teams create <name> [--description <text>] [--yes]",
30974
+ " backify teams add <team> <email...> [--role manager] [--yes] Add people (managers); people not in the organization yet are invited",
30975
+ " backify teams suggest <team> <email...> [--note <text>] [--yes]",
30976
+ " Suggest people; a team manager approves",
30977
+ " backify teams join <team> [--note <text>] Ask to join a team",
30978
+ " backify teams remove <team> <email> [--yes] Remove someone from a team",
30979
+ " backify teams requests [<team>] Suggestions waiting for you, or one team's",
30980
+ " backify teams approve|decline <request-id> [--yes] Decide a suggestion",
30981
+ " backify teams activity <team> Recent work by the team on the applications it owns",
30982
+ " backify apps owner <app-id> [--user <email>|--team <team>] [--yes]",
30983
+ " Show or change who owns an application: a person or a team",
30832
30984
  ...orgProtectionUsage,
30833
30985
  ...orgPatchesUsage,
30834
30986
  ...orgUpdatesUsage,
@@ -30900,6 +31052,15 @@ var init_tasks = __esm({
30900
31052
  if (!id || !isUuid(id)) throw new Error("Pass --connection <cloud-connection-id>.");
30901
31053
  return id;
30902
31054
  };
31055
+ emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
31056
+ outcomeText = {
31057
+ requested: "suggested, waiting for a team manager",
31058
+ added: "added to the team",
31059
+ invited: "invited to the organization; joins the team on accepting",
31060
+ invitation_updated: "team added to their pending invitation",
31061
+ declined: "declined",
31062
+ skipped: "skipped"
31063
+ };
30903
31064
  usd = (amount) => "$" + amount.toFixed(2);
30904
31065
  percent = (value) => value === null ? "new" : (value >= 0 ? "+" : "") + Math.round(value * 100) + "%";
30905
31066
  }
@@ -30916,7 +31077,7 @@ async function runSsoCommand(args2, context2) {
30916
31077
  const secretOnStdin = args2.includes("--client-secret-stdin");
30917
31078
  const { options, positional, values } = taskArguments(args2.filter((arg) => arg !== "--client-secret-stdin"));
30918
31079
  const { call: call2, organizationId } = await organizationCall(context2, options.organizationId);
30919
- const base = `/organizations/${organizationId}/sso`;
31080
+ const base2 = `/organizations/${organizationId}/sso`;
30920
31081
  const value = (name2) => values[name2]?.at(-1);
30921
31082
  const id = (index, what) => {
30922
31083
  const raw = positional[index];
@@ -30928,9 +31089,9 @@ async function runSsoCommand(args2, context2) {
30928
31089
  if (!context2.confirm) throw new OpsError("Pass --yes to confirm when no terminal can ask: " + message, "confirmation_required");
30929
31090
  if (!await context2.confirm(message)) throw new OpsError("Not confirmed. Nothing changed.", "not_confirmed");
30930
31091
  };
30931
- const overview = async () => (await call2(base)).overview;
31092
+ const overview = async () => (await call2(base2)).overview;
30932
31093
  const done = (result, text2) => ({ result: { value: result, text: text2 }, json: options.json });
30933
- const send2 = (path, method, body) => call2(base + path, { method, headers: json5, body: body === void 0 ? void 0 : JSON.stringify(body) });
31094
+ const send2 = (path, method, body) => call2(base2 + path, { method, headers: json5, body: body === void 0 ? void 0 : JSON.stringify(body) });
30934
31095
  const [area, action] = positional;
30935
31096
  switch (`${area ?? ""} ${["connections", "domains", "mappings", "scim"].includes(area ?? "") ? action ?? "" : ""}`.trim()) {
30936
31097
  case "": {
@@ -31022,7 +31183,7 @@ async function runSsoCommand(args2, context2) {
31022
31183
  return done(connection2, "Metadata refreshed.\n" + connectionLine(connection2));
31023
31184
  }
31024
31185
  case "sign-ins": {
31025
- const attempts = await call2(`${base}/connections/${id(1, "connection")}/sign-ins`);
31186
+ const attempts = await call2(`${base2}/connections/${id(1, "connection")}/sign-ins`);
31026
31187
  return done(attempts, attempts.length ? attempts.map((attempt) => [
31027
31188
  `${attempt.at} ${attempt.succeeded ? "ok" : "FAILED"}${attempt.isTest ? " (test)" : ""} ${attempt.email ?? ""} ${attempt.code ?? ""}`,
31028
31189
  attempt.diagnostic ? " " + attempt.diagnostic : "",
@@ -31056,7 +31217,7 @@ async function runSsoCommand(args2, context2) {
31056
31217
  }
31057
31218
  case "require": {
31058
31219
  const domainId = id(1, "domain");
31059
- const preview = await call2(`${base}/domains/${domainId}/enforcement-preview`);
31220
+ const preview = await call2(`${base2}/domains/${domainId}/enforcement-preview`);
31060
31221
  const impact = `${preview.affected} members use @${preview.domain}: ${preview.alreadyUsingSso} already use single sign-on, ${preview.needToSwitch} must switch on their next sign-in, ${preview.exempt} break-glass owners are exempt.`;
31061
31222
  if (!preview.ready) throw new OpsError("Single sign-on can't be required yet. " + preview.blockers.join(" "), "sso_not_ready", { preview });
31062
31223
  await confirm(`Require single sign-on for ${preview.domain} through ${preview.connectionName}? ${impact}`);
@@ -31357,15 +31518,15 @@ function resolveEnvironment(input, environments, statuses) {
31357
31518
  }
31358
31519
  async function runAuthIdentity(call2, applicationId, options) {
31359
31520
  if (!uuid10.test(applicationId)) throw new Error("Use a valid application ID.");
31360
- const prefix = "/apps/" + applicationId, base = prefix + "/auth/identity";
31361
- const statuses = await call2(base);
31521
+ const prefix = "/apps/" + applicationId, base2 = prefix + "/auth/identity";
31522
+ const statuses = await call2(base2);
31362
31523
  const environments = await call2(prefix + "/environments").catch(() => []);
31363
31524
  const names = new Map(environments.map((value) => [value.id, value.name]));
31364
31525
  if (options.action === "status") return { value: statuses, text: identityStatusText(statuses, names) };
31365
31526
  const target = resolveEnvironment(options.environment, environments, statuses), label = names.get(target.environmentId) ?? target.kind;
31366
31527
  if (target.authority === "relocating" || target.authority === "returning") throw new CommandError("Sign-in data for " + label + " is already being moved.", "identity_relocation_in_progress", { environmentId: target.environmentId });
31367
31528
  if (options.action === "clear") {
31368
- const relocation2 = await call2(base + "/clear", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ environmentId: target.environmentId }) });
31529
+ const relocation2 = await call2(base2 + "/clear", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ environmentId: target.environmentId }) });
31369
31530
  return {
31370
31531
  value: { status: relocation2.clearedAt ? "cleared" : "clearing", environmentId: target.environmentId, relocation: relocation2 },
31371
31532
  text: relocation2.clearedAt ? "What the failed move left in " + label + "'s database is already cleared." : "Clearing what the failed move left in " + label + "'s database. Sign-in for " + label + " stays with Backify.\nCheck progress with: backify auth identity"
@@ -31378,7 +31539,7 @@ async function runAuthIdentity(call2, applicationId, options) {
31378
31539
  const summary = "Moving sign-in data for " + label + " back to Backify pauses sign-in for that environment and user management for the application while the data is moved. Users, roles, passkeys and signed-in sessions are kept. Afterwards, sign-in for " + label + " stops working while Backify is unavailable.";
31379
31540
  throw new CommandError((options.confirm ? "The confirmation does not match the application slug. " : "") + summary + "\nConfirm with the application slug: backify auth identity move-back --environment " + options.environment + " --confirm " + (slug2 ?? "<application-slug>"), options.confirm ? "confirmation_mismatch" : "confirmation_required", slug2 ? { confirm: slug2 } : {});
31380
31541
  }
31381
- const relocation2 = await call2(base + "/move-back", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ environmentId: target.environmentId }) });
31542
+ const relocation2 = await call2(base2 + "/move-back", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ environmentId: target.environmentId }) });
31382
31543
  return { value: { status: "moving-back", environmentId: target.environmentId, relocation: relocation2 }, text: ["Moving sign-in data for " + label + " back to Backify.", "Sign-in for this environment and user management for the application are paused until it finishes, usually within a minute.", "Check progress with: backify auth identity"].join("\n") };
31383
31544
  }
31384
31545
  if (target.authority === "relocating") throw new CommandError("Sign-in data for " + label + " is already being moved.", "identity_relocation_in_progress", { environmentId: target.environmentId });
@@ -31388,7 +31549,7 @@ async function runAuthIdentity(call2, applicationId, options) {
31388
31549
  const summary = "Moving sign-in data for " + label + " pauses sign-in for that environment and user management for the application while the data is moved. It can be moved back later with backify auth identity move-back. Afterwards, sign-in for " + label + " keeps working if Backify is unavailable.";
31389
31550
  throw new CommandError((options.confirm ? "The confirmation does not match the application slug. " : "") + summary + "\nConfirm with the application slug: backify auth identity move --environment " + options.environment + " --confirm " + (slug ?? "<application-slug>"), options.confirm ? "confirmation_mismatch" : "confirmation_required", slug ? { confirm: slug } : {});
31390
31551
  }
31391
- const relocation = await call2(base + "/relocate", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ environmentId: target.environmentId }) });
31552
+ const relocation = await call2(base2 + "/relocate", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ environmentId: target.environmentId }) });
31392
31553
  return { value: { status: "moving", environmentId: target.environmentId, relocation }, text: ["Moving sign-in data for " + label + ": " + relocation.users + " users, " + relocation.links + " linked identities, " + relocation.passkeys + " passkeys, " + relocation.sessions + " sessions.", "Sign-in for this environment and user management for the application are paused until it finishes, usually within a minute.", "Check progress with: backify auth identity"].join("\n") };
31393
31554
  }
31394
31555
  var authIdentityHelp, uuid10, where, identityFailureText;
@@ -31797,10 +31958,10 @@ function exportReference(name2) {
31797
31958
  const capability2 = sdkCapability(name2);
31798
31959
  return capability2 ? { kind: "capability", capability: capability2 } : void 0;
31799
31960
  }
31800
- function memberReference(base, name2) {
31801
- if (base?.kind === "namespace")
31802
- return exportReference(base.member(name2));
31803
- if (base?.kind === "root") {
31961
+ function memberReference(base2, name2) {
31962
+ if (base2?.kind === "namespace")
31963
+ return exportReference(base2.member(name2));
31964
+ if (base2?.kind === "root") {
31804
31965
  const capability2 = sdkCapability(name2);
31805
31966
  return capability2 ? { kind: "capability", capability: capability2 } : void 0;
31806
31967
  }
@@ -31907,15 +32068,15 @@ function analyzeFile(file, used, diagnostics, wrappers) {
31907
32068
  report({ severity: "error", code: "retired-sdk-import", docs: "https://docs.backify.dev/sdk", message: "This SDK entrypoint was removed. Use @backifydev/sdk/app in server code and fetch application APIs from browsers." }, statement);
31908
32069
  if (module === "@backifydev/sdk/app")
31909
32070
  serverOnly = true;
31910
- const base = moduleReference(module), clause = statement.importClause;
31911
- if (!base || !clause || clause.isTypeOnly || !clause.namedBindings)
32071
+ const base2 = moduleReference(module), clause = statement.importClause;
32072
+ if (!base2 || !clause || clause.isTypeOnly || !clause.namedBindings)
31912
32073
  continue;
31913
32074
  if (ts3.isNamespaceImport(clause.namedBindings))
31914
- bind(clause.namedBindings.name, base);
32075
+ bind(clause.namedBindings.name, base2);
31915
32076
  else
31916
32077
  for (const element of clause.namedBindings.elements)
31917
32078
  if (!element.isTypeOnly)
31918
- bind(element.name, memberReference(base, (element.propertyName ?? element.name).text));
32079
+ bind(element.name, memberReference(base2, (element.propertyName ?? element.name).text));
31919
32080
  }
31920
32081
  const resolve10 = (node2) => {
31921
32082
  if (ts3.isParenthesizedExpression(node2) || ts3.isAsExpression(node2) || ts3.isNonNullExpression(node2) || ts3.isAwaitExpression(node2) || ts3.isSatisfiesExpression(node2))
@@ -31942,16 +32103,16 @@ function analyzeFile(file, used, diagnostics, wrappers) {
31942
32103
  };
31943
32104
  const collect = (node2) => {
31944
32105
  if (ts3.isVariableDeclaration(node2) && node2.initializer) {
31945
- const base = resolve10(node2.initializer);
31946
- if (base && ts3.isIdentifier(node2.name))
31947
- bind(node2.name, base);
31948
- else if (base && ts3.isObjectBindingPattern(node2.name))
32106
+ const base2 = resolve10(node2.initializer);
32107
+ if (base2 && ts3.isIdentifier(node2.name))
32108
+ bind(node2.name, base2);
32109
+ else if (base2 && ts3.isObjectBindingPattern(node2.name))
31949
32110
  for (const element of node2.name.elements) {
31950
32111
  if (element.dotDotDotToken || !ts3.isIdentifier(element.name))
31951
32112
  continue;
31952
32113
  const property3 = element.propertyName ?? element.name;
31953
32114
  if (ts3.isIdentifier(property3) || ts3.isStringLiteral(property3))
31954
- bind(element.name, memberReference(base, property3.text));
32115
+ bind(element.name, memberReference(base2, property3.text));
31955
32116
  }
31956
32117
  }
31957
32118
  ts3.forEachChild(node2, collect);
@@ -32337,9 +32498,9 @@ function startGateway(options) {
32337
32498
  const storageCredential = sealed({ kind: "storage" });
32338
32499
  const buckets = new Map((config2.storage?.buckets ?? []).map((b) => [b.name, b]));
32339
32500
  const objectPath = (bucket, key) => {
32340
- const base = resolve7(storageDir, bucket);
32341
- const path = resolve7(base, ...key.split("/"));
32342
- if (!buckets.has(bucket) || !path.startsWith(base + sep)) throw new InvalidKey();
32501
+ const base2 = resolve7(storageDir, bucket);
32502
+ const path = resolve7(base2, ...key.split("/"));
32503
+ if (!buckets.has(bucket) || !path.startsWith(base2 + sep)) throw new InvalidKey();
32343
32504
  return path;
32344
32505
  };
32345
32506
  const cookie = (req, name2) => req.headers.cookie?.split(/;\s*/).map((p) => p.split("=")).find(([k]) => k === name2)?.[1];
@@ -33035,17 +33196,17 @@ function replacementSettings(settings) {
33035
33196
  return result;
33036
33197
  }
33037
33198
  async function runReplacements(call2, prefix, options, context2) {
33038
- const replacement = options.replacement, base = prefix + "/replacements";
33199
+ const replacement = options.replacement, base2 = prefix + "/replacements";
33039
33200
  if (replacement.action === "add") {
33040
33201
  const { kind: kind2, subject, secretName, environment: named } = replacement;
33041
33202
  if (!replacement.consent) throw new CommandError(consentSummary(kind2, subject, named, secretName) + "\nNothing was changed. Add --consent to record it.", "consent_required", { kind: kind2, subject, secretName });
33042
33203
  const status = await call2(prefix), environmentId = resolveReplacementEnvironment(named, status.inventory?.environments);
33043
- const created = await call2(base, { method: "POST", body: JSON.stringify({ environmentId, kind: kind2, subject, settings: replacementSettings(replacement.settings), secretReference: secretName, consent: true }) });
33204
+ const created = await call2(base2, { method: "POST", body: JSON.stringify({ environmentId, kind: kind2, subject, settings: replacementSettings(replacement.settings), secretReference: secretName, consent: true }) });
33044
33205
  return { value: { status: "recorded", replacement: created }, text: ["Replacement recorded for " + subjectText(created) + " in " + named + ".", "Your environment is checking it: " + replacementState(created) + ". Run backify handoff replacements to see the result, or backify handoff replacements verify " + created.id + " to check again."].join("\n") };
33045
33206
  }
33046
33207
  if (replacement.action === "verify") {
33047
33208
  if (!uuid12.test(replacement.id)) throw new Error("Use a valid replacement ID. List them with backify handoff replacements.");
33048
- const checked2 = await call2(base + "/" + replacement.id + "/verify", { method: "POST" });
33209
+ const checked2 = await call2(base2 + "/" + replacement.id + "/verify", { method: "POST" });
33049
33210
  return { value: { status: "verifying", replacement: checked2 }, text: "Check requested for " + subjectText(checked2) + ": " + replacementState(checked2) + ". It usually takes a minute; run backify handoff replacements to see the result." };
33050
33211
  }
33051
33212
  if (replacement.action === "remove") {
@@ -33055,10 +33216,10 @@ async function runReplacements(call2, prefix, options, context2) {
33055
33216
  if (!context2.confirm) throw new CommandError("Refusing to remove a replacement without confirmation. Review this and re-run with --yes:\n" + summary, "confirmation_required", { id: replacement.id });
33056
33217
  if (!await context2.confirm(summary)) throw new CommandError("Not confirmed. Nothing was changed.", "not_confirmed");
33057
33218
  }
33058
- await call2(base + "/" + replacement.id, { method: "DELETE" });
33219
+ await call2(base2 + "/" + replacement.id, { method: "DELETE" });
33059
33220
  return { value: { status: "removed", id: replacement.id }, text: "Replacement removed. The dependency counts as hosted by Backify again." };
33060
33221
  }
33061
- const list = await call2(base);
33222
+ const list = await call2(base2);
33062
33223
  let environments = [];
33063
33224
  try {
33064
33225
  environments = (await call2(prefix)).inventory?.environments ?? [];
@@ -33400,12 +33561,12 @@ async function runMonitoringDashboards(call2, applicationId, options) {
33400
33561
  }
33401
33562
  const scope = "scope" in options ? options.scope : void 0;
33402
33563
  if (!scope && !uuid14.test(applicationId)) throw new Error("Use a valid application ID.");
33403
- const base = scope?.kind === "organization" ? "/monitoring/organization" : scope?.kind === "workspace" ? "/monitoring/workspaces/" + scope.id : "/monitoring/applications/" + applicationId;
33564
+ const base2 = scope?.kind === "organization" ? "/monitoring/organization" : scope?.kind === "workspace" ? "/monitoring/workspaces/" + scope.id : "/monitoring/applications/" + applicationId;
33404
33565
  switch (options.action) {
33405
33566
  case "capabilities": {
33406
33567
  const query = new URLSearchParams({ range: options.range });
33407
33568
  if (options.environment) query.set("environmentId", await resolveEnvironment2(call2, "/apps/" + applicationId, options.environment));
33408
- const data = await call2(base + "/capabilities?" + query.toString());
33569
+ const data = await call2(base2 + "/capabilities?" + query.toString());
33409
33570
  const ai = data.ai;
33410
33571
  const lines = [
33411
33572
  `Capabilities with monitoring pages: ${data.monitored.join(", ") || "none"}. Range ${data.range}, generated ${data.generatedAt}.`,
@@ -33420,28 +33581,28 @@ async function runMonitoringDashboards(call2, applicationId, options) {
33420
33581
  return { value: data, text: lines.join("\n") };
33421
33582
  }
33422
33583
  case "list": {
33423
- const items = await call2(base + "/dashboards");
33584
+ const items = await call2(base2 + "/dashboards");
33424
33585
  return { value: items, text: dashboardLines(items).join("\n") };
33425
33586
  }
33426
33587
  case "create": {
33427
- const created = await call2(base + "/dashboards", { method: "POST", body: JSON.stringify({ name: options.name, widgets: options.widgets }) });
33588
+ const created = await call2(base2 + "/dashboards", { method: "POST", body: JSON.stringify({ name: options.name, widgets: options.widgets }) });
33428
33589
  return { value: created, text: `Created monitoring page ${created.id}.
33429
33590
  ` + dashboardLines([created]).join("\n") };
33430
33591
  }
33431
33592
  case "update": {
33432
33593
  let widgets = options.widgets;
33433
33594
  if (!widgets && (options.add.length || options.remove.length)) {
33434
- const current = (await call2(base + "/dashboards")).find((item) => options.dashboard === "overview" ? item.kind === "overview" : item.id?.toLowerCase() === options.dashboard);
33595
+ const current = (await call2(base2 + "/dashboards")).find((item) => options.dashboard === "overview" ? item.kind === "overview" : item.id?.toLowerCase() === options.dashboard);
33435
33596
  if (!current) throw new Error("The monitoring page was not found.");
33436
33597
  const missing = options.remove.filter((id) => !current.widgets.some((widget) => widget.id === id));
33437
33598
  if (missing.length) throw new Error("No widget with id " + missing.join(", ") + " on this page.");
33438
33599
  widgets = [...current.widgets.filter((widget) => !options.remove.includes(widget.id)).map((widget) => ({ id: widget.id, type: widget.type, size: widget.size })), ...options.add];
33439
33600
  }
33440
- const updated = await call2(base + "/dashboards/" + encodeURIComponent(options.dashboard), { method: "PUT", body: JSON.stringify({ ...options.name ? { name: options.name } : {}, ...widgets ? { widgets } : {} }) });
33601
+ const updated = await call2(base2 + "/dashboards/" + encodeURIComponent(options.dashboard), { method: "PUT", body: JSON.stringify({ ...options.name ? { name: options.name } : {}, ...widgets ? { widgets } : {} }) });
33441
33602
  return { value: updated, text: "Updated.\n" + dashboardLines([updated]).join("\n") };
33442
33603
  }
33443
33604
  case "delete": {
33444
- await call2(base + "/dashboards/" + encodeURIComponent(options.dashboard), { method: "DELETE" });
33605
+ await call2(base2 + "/dashboards/" + encodeURIComponent(options.dashboard), { method: "DELETE" });
33445
33606
  return { value: { deleted: options.dashboard }, text: options.dashboard === "overview" ? "The overview shows the automatic widgets again." : "Deleted monitoring page " + options.dashboard + "." };
33446
33607
  }
33447
33608
  }
@@ -33824,8 +33985,8 @@ async function diagnoseEnvironment(root = process.cwd(), options = {}, probes =
33824
33985
  function integrationDiscoveryPath(command2, options) {
33825
33986
  const uuid17 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
33826
33987
  if (!uuid17.test(options.applicationId)) throw new Error("An application UUID is required");
33827
- const base = "/apps/" + options.applicationId + "/integrations/connectors";
33828
- if (command2 === "list") return base;
33988
+ const base2 = "/apps/" + options.applicationId + "/integrations/connectors";
33989
+ if (command2 === "list") return base2;
33829
33990
  if (command2 === "catalog") return "/apps/" + options.applicationId + "/integrations/catalog";
33830
33991
  if (command2 === "discover") return "/apps/" + options.applicationId + "/integrations/discover?" + new URLSearchParams({ query: options.query ?? "" });
33831
33992
  if (command2 === "prepare") return "/apps/" + options.applicationId + "/integrations/prepare";
@@ -33838,7 +33999,7 @@ function integrationDiscoveryPath(command2, options) {
33838
33999
  return "/apps/" + options.applicationId + "/integrations/adoptions/" + options.adoptionId;
33839
34000
  }
33840
34001
  if (!options.connectionId || !uuid17.test(options.connectionId)) throw new Error("Use --connection with an integration connection UUID");
33841
- const connection2 = base + "/" + options.connectionId;
34002
+ const connection2 = base2 + "/" + options.connectionId;
33842
34003
  if (command2 === "contract" || command2 === "types") return connection2 + "/" + command2;
33843
34004
  if (command2 === "describe") {
33844
34005
  if (!options.operationId) throw new Error("Use --operation to select an operation");
@@ -34129,12 +34290,12 @@ async function setupAuth(call2, options) {
34129
34290
  if (!uuid6.test(app) || options.requestId && !uuid6.test(options.requestId)) throw new Error("Use valid application and sign-in setup request IDs.");
34130
34291
  if (!Number.isFinite(timeout) || timeout < 1e3 || timeout > 36e5) throw new Error("Use --timeout between 1 and 3600 seconds.");
34131
34292
  const origin = authOrigin(options.authUrl), now = options.now ?? Date.now, deadline = now() + timeout;
34132
- const base = "/apps/" + app + "/auth/setup/requests";
34293
+ const base2 = "/apps/" + app + "/auth/setup/requests";
34133
34294
  const read = async (value) => {
34134
34295
  validateAuthSetupStatus(value, app);
34135
34296
  return value;
34136
34297
  };
34137
- let status = await read(options.requestId ? await call2(base + "/" + options.requestId) : await call2(base, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ providers: configuredProviders(options.providers), requestKey: randomUUID3(), source: "cli" }) }));
34298
+ let status = await read(options.requestId ? await call2(base2 + "/" + options.requestId) : await call2(base2, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ providers: configuredProviders(options.providers), requestKey: randomUUID3(), source: "cli" }) }));
34138
34299
  const link = setupUrl(origin, app, status);
34139
34300
  const missing = () => [...new Set(status.effective.filter((cell) => status.providers.includes(cell.provider) && !cell.configured).map((cell) => cell.provider))];
34140
34301
  const result = (reason) => ({
@@ -34175,7 +34336,7 @@ async function setupAuth(call2, options) {
34175
34336
  throw error2;
34176
34337
  }
34177
34338
  if (options.signal?.aborted) return result("cancelled");
34178
- status = await read(await call2(base + "/" + status.id));
34339
+ status = await read(await call2(base2 + "/" + status.id));
34179
34340
  if (setupUrl(origin, app, status) !== link) throw new Error("The sign-in setup request changed while waiting.");
34180
34341
  }
34181
34342
  }
@@ -34221,15 +34382,15 @@ function privacyRequestCall(appId, args2) {
34221
34382
  };
34222
34383
  const [area, action, id] = args2;
34223
34384
  if (area !== "requests" || !action) throw new Error(privacyRequestsUsage);
34224
- const base = `/apps/${appId}/compliance/requests`;
34385
+ const base2 = `/apps/${appId}/compliance/requests`;
34225
34386
  const request = () => {
34226
34387
  if (!id || !guid.test(id)) throw new Error(`Give the request ID: backify privacy requests ${action} <request-id>.`);
34227
- return `${base}/${id}`;
34388
+ return `${base2}/${id}`;
34228
34389
  };
34229
34390
  switch (action) {
34230
34391
  case "list": {
34231
34392
  const status = option2("--status");
34232
- return { method: "GET", path: status ? `${base}?status=${encodeURIComponent(status)}` : base };
34393
+ return { method: "GET", path: status ? `${base2}?status=${encodeURIComponent(status)}` : base2 };
34233
34394
  }
34234
34395
  case "show":
34235
34396
  return { method: "GET", path: request() };
@@ -34240,7 +34401,7 @@ function privacyRequestCall(appId, args2) {
34240
34401
  if (!type || !subjectKind || !subject || !verificationMethod) throw new Error("Specify --type, --subject-kind, --subject and --verified-by.\n" + privacyRequestsUsage);
34241
34402
  const environment = option2("--environment");
34242
34403
  if (environment !== void 0 && !guid.test(environment)) throw new Error("--environment must be an environment UUID.");
34243
- return { method: "POST", path: base, body: { type, subjectKind, subject, verificationMethod, verificationNote: option2("--note"), receivedAt: option2("--received"), environmentId: environment } };
34404
+ return { method: "POST", path: base2, body: { type, subjectKind, subject, verificationMethod, verificationNote: option2("--note"), receivedAt: option2("--received"), environmentId: environment } };
34244
34405
  }
34245
34406
  case "update": {
34246
34407
  const extend2 = option2("--extend");
@@ -34259,6 +34420,113 @@ function privacyRequestCall(appId, args2) {
34259
34420
  }
34260
34421
  }
34261
34422
 
34423
+ // src/notifications.ts
34424
+ var notificationsUsage = [
34425
+ "Use backify notifications <action>:",
34426
+ " list [--action | --unread] [--organization <id>] [--workspace <id>] [--app <id>] [--category <category>] [--cursor <cursor>] [--limit <n>] [--json]",
34427
+ " --action lists open items that need you; a wider scope includes the narrower ones",
34428
+ " summary [--json] unread and open-action counts per organization, workspace and application",
34429
+ " read <notification-id> | read --all [--organization <id>] [--workspace <id>] [--app <id>]",
34430
+ " dismiss <notification-id> removes it from your inbox only; the underlying request is unchanged",
34431
+ " preferences [--json] your channels per category",
34432
+ " preferences set <category> [--email on|off|default] [--in-app on|off|default] [--organization <id>] [--workspace <id> | --app <id>]",
34433
+ `Categories: ${["approvals", "requests", "deployments", "reliability", "security", "vulnerabilities", "billing", "domains", "access", "operations"].join(", ")}.`,
34434
+ "Items that need your action always reach the portal inbox, and required security and billing notices are always emailed."
34435
+ ].join("\n");
34436
+ var notificationCategories = ["approvals", "requests", "deployments", "reliability", "security", "vulnerabilities", "billing", "domains", "access", "operations"];
34437
+ var guid2 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
34438
+ var base = "/account/notifications";
34439
+ function notificationCall(args2) {
34440
+ const option2 = (name2) => {
34441
+ const index = args2.indexOf(name2);
34442
+ return index >= 0 ? args2[index + 1] : void 0;
34443
+ };
34444
+ const id = (value, name2) => {
34445
+ if (value === void 0) return void 0;
34446
+ if (!guid2.test(value)) throw new Error(`${name2} must be a UUID.`);
34447
+ return value;
34448
+ };
34449
+ const scope = () => ({ organizationId: id(option2("--organization"), "--organization"), workspaceId: id(option2("--workspace"), "--workspace"), applicationId: id(option2("--app"), "--app") });
34450
+ const [action = "list", target] = args2;
34451
+ switch (action) {
34452
+ case "list": {
34453
+ if (args2.includes("--action") && args2.includes("--unread")) throw new Error("Choose --action or --unread, not both.");
34454
+ const query = new URLSearchParams({ view: args2.includes("--action") ? "action" : args2.includes("--unread") ? "unread" : "all" });
34455
+ for (const [key, value] of Object.entries(scope())) if (value) query.set(key, value);
34456
+ const category = option2("--category");
34457
+ if (category !== void 0) {
34458
+ if (!notificationCategories.includes(category)) throw new Error("--category must be one of: " + notificationCategories.join(", ") + ".");
34459
+ query.set("category", category);
34460
+ }
34461
+ const cursor = option2("--cursor"), limit = option2("--limit");
34462
+ if (cursor !== void 0) {
34463
+ if (!/^\d+$/.test(cursor)) throw new Error("--cursor takes the nextCursor value of the previous page.");
34464
+ query.set("cursor", cursor);
34465
+ }
34466
+ if (limit !== void 0) {
34467
+ if (!/^\d+$/.test(limit) || Number(limit) < 1 || Number(limit) > 100) throw new Error("--limit takes 1 to 100.");
34468
+ query.set("limit", limit);
34469
+ }
34470
+ return { method: "GET", path: `${base}?${query}` };
34471
+ }
34472
+ case "summary":
34473
+ return { method: "GET", path: `${base}/summary` };
34474
+ case "read": {
34475
+ if (args2.includes("--all")) return { method: "POST", path: `${base}/read`, body: scope() };
34476
+ if (!target || !guid2.test(target)) throw new Error("Give the notification ID (backify notifications read <notification-id>) or --all.");
34477
+ return { method: "POST", path: `${base}/${target}/read` };
34478
+ }
34479
+ case "dismiss":
34480
+ if (!target || !guid2.test(target)) throw new Error("Give the notification ID: backify notifications dismiss <notification-id>.");
34481
+ return { method: "POST", path: `${base}/${target}/archive` };
34482
+ case "preferences": {
34483
+ if (target === void 0 || target.startsWith("--")) return { method: "GET", path: `${base}/preferences` };
34484
+ if (target !== "set") throw new Error(notificationsUsage);
34485
+ const category = args2[2];
34486
+ if (!category || !notificationCategories.includes(category)) throw new Error("Give a category: " + notificationCategories.join(", ") + ".");
34487
+ const channel = (name2) => {
34488
+ const value = option2(name2);
34489
+ if (value === void 0) return void 0;
34490
+ if (!["on", "off", "default"].includes(value)) throw new Error(`${name2} takes on, off or default.`);
34491
+ return value === "default" ? null : value === "on";
34492
+ };
34493
+ const email2 = channel("--email"), inApp = channel("--in-app");
34494
+ if (email2 === void 0 && inApp === void 0) throw new Error("Specify --email and/or --in-app.");
34495
+ const scoped = scope();
34496
+ if ((scoped.workspaceId || scoped.applicationId) && !scoped.organizationId) throw new Error("A workspace or application setting needs --organization.");
34497
+ if (scoped.workspaceId && scoped.applicationId) throw new Error("Choose --workspace or --app, not both.");
34498
+ const entry = {
34499
+ category,
34500
+ ...email2 !== void 0 ? { email: email2 } : {},
34501
+ ...inApp !== void 0 ? { inApp } : {},
34502
+ organizationId: scoped.organizationId ?? null,
34503
+ workspaceId: scoped.workspaceId ?? null,
34504
+ applicationId: scoped.applicationId ?? null
34505
+ };
34506
+ return { method: "PUT", path: `${base}/preferences`, preferences: { entry } };
34507
+ }
34508
+ default:
34509
+ throw new Error(notificationsUsage);
34510
+ }
34511
+ }
34512
+ var sameScope = (first, second) => first.category === second.category && (first.organizationId ?? null) === (second.organizationId ?? null) && (first.workspaceId ?? null) === (second.workspaceId ?? null) && (first.applicationId ?? null) === (second.applicationId ?? null);
34513
+ function mergePreference(current, change) {
34514
+ const existing = current.find((entry) => sameScope(entry, change.entry));
34515
+ const merged = { ...existing, ...change.entry };
34516
+ return { preferences: [...current.filter((entry) => !sameScope(entry, change.entry)), merged] };
34517
+ }
34518
+ function formatNotifications(page) {
34519
+ if (!page.items.length) return "No notifications.";
34520
+ const lines = page.items.map((item) => {
34521
+ const state = item.actionable && !item.resolvedAt ? "ACTION" : item.resolvedAt ? (item.resolution ?? "resolved").toUpperCase() : item.readAt ? "read" : "NEW";
34522
+ return `${item.createdAt} [${state}] [${item.severity}] ${item.title}
34523
+ ${item.body}
34524
+ ${item.path} (id ${item.id})`;
34525
+ });
34526
+ if (page.nextCursor) lines.push(`More: backify notifications list --cursor ${page.nextCursor}`);
34527
+ return lines.join("\n");
34528
+ }
34529
+
34262
34530
  // src/outbound-http.ts
34263
34531
  var outboundHttpUsage = [
34264
34532
  "Use backify outbound <action> --environment <UUID> [--app <application-id>]:",
@@ -34271,7 +34539,7 @@ var outboundHttpUsage = [
34271
34539
  " requests [--search <text>] [--outcome allowed|blocked|not-allowed]",
34272
34540
  "List environments with backify events environments. Quote wildcards so your shell does not expand them."
34273
34541
  ].join("\n");
34274
- var guid2 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
34542
+ var guid3 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
34275
34543
  function outboundHttpCall(appId, args2) {
34276
34544
  const option2 = (name2) => {
34277
34545
  const index = args2.indexOf(name2);
@@ -34279,8 +34547,8 @@ function outboundHttpCall(appId, args2) {
34279
34547
  };
34280
34548
  const [action, value] = args2;
34281
34549
  const environment = option2("--environment");
34282
- if (!action || !environment || !guid2.test(environment)) throw new Error(outboundHttpUsage);
34283
- const base = `/apps/${appId}/outbound-http/environments/${environment}`;
34550
+ if (!action || !environment || !guid3.test(environment)) throw new Error(outboundHttpUsage);
34551
+ const base2 = `/apps/${appId}/outbound-http/environments/${environment}`;
34284
34552
  const query = (names) => {
34285
34553
  const params = new URLSearchParams();
34286
34554
  for (const name2 of names) {
@@ -34293,23 +34561,23 @@ function outboundHttpCall(appId, args2) {
34293
34561
  const positional = value !== void 0 && !value.startsWith("--") ? value : void 0;
34294
34562
  switch (action) {
34295
34563
  case "show":
34296
- return { method: "GET", path: base };
34564
+ return { method: "GET", path: base2 };
34297
34565
  case "default":
34298
34566
  if (positional !== "allow" && positional !== "deny") throw new Error("Use backify outbound default allow|deny --environment <UUID>.");
34299
- return { method: "PUT", path: base + "/default", body: { action: positional } };
34567
+ return { method: "PUT", path: base2 + "/default", body: { action: positional } };
34300
34568
  case "allow":
34301
34569
  case "block":
34302
34570
  if (!positional) throw new Error(`Give a host, wildcard or HTTPS URL: backify outbound ${action} <pattern> --environment <UUID>.`);
34303
- return { method: "POST", path: base + "/rules", body: { pattern: positional, action } };
34571
+ return { method: "POST", path: base2 + "/rules", body: { pattern: positional, action } };
34304
34572
  case "remove":
34305
- if (!positional || !guid2.test(positional)) throw new Error("Give the rule ID from backify outbound show: backify outbound remove <rule-id> --environment <UUID>.");
34306
- return { method: "DELETE", path: `${base}/rules/${positional}` };
34573
+ if (!positional || !guid3.test(positional)) throw new Error("Give the rule ID from backify outbound show: backify outbound remove <rule-id> --environment <UUID>.");
34574
+ return { method: "DELETE", path: `${base2}/rules/${positional}` };
34307
34575
  case "destinations":
34308
- return { method: "GET", path: base + "/destinations" + query(["search"]) };
34576
+ return { method: "GET", path: base2 + "/destinations" + query(["search"]) };
34309
34577
  case "requests": {
34310
34578
  const outcome = option2("--outcome");
34311
34579
  if (outcome !== void 0 && !["allowed", "blocked", "not-allowed"].includes(outcome)) throw new Error("--outcome must be allowed, blocked or not-allowed.");
34312
- return { method: "GET", path: base + "/requests" + query(["search", "outcome"]) };
34580
+ return { method: "GET", path: base2 + "/requests" + query(["search", "outcome"]) };
34313
34581
  }
34314
34582
  default:
34315
34583
  throw new Error(outboundHttpUsage);
@@ -34317,7 +34585,7 @@ function outboundHttpCall(appId, args2) {
34317
34585
  }
34318
34586
 
34319
34587
  // src/capability-data.ts
34320
- var guid3 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
34588
+ var guid4 = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
34321
34589
  var bucketName = /^[a-z0-9](?:[a-z0-9-]{1,61}[a-z0-9])$/;
34322
34590
  function reader(args2) {
34323
34591
  const option2 = (name2) => {
@@ -34339,7 +34607,7 @@ function reader(args2) {
34339
34607
  }
34340
34608
  function environmentOf(args2, usage) {
34341
34609
  const environment = reader(args2).option("--environment");
34342
- if (!environment || !guid3.test(environment)) throw new Error(usage);
34610
+ if (!environment || !guid4.test(environment)) throw new Error(usage);
34343
34611
  return environment;
34344
34612
  }
34345
34613
  var storageUsage = [
@@ -34361,11 +34629,11 @@ function storageCall(appId, args2) {
34361
34629
  if (action === "environments") return { method: "GET", path: root + "/environments" };
34362
34630
  if (action === "usage") return { method: "GET", path: root + "/usage" };
34363
34631
  const environment = environmentOf(args2, storageUsage);
34364
- const base = `${root}/environments/${environment}`;
34365
- if (action === "buckets") return { method: "GET", path: base + "/buckets" };
34632
+ const base2 = `${root}/environments/${environment}`;
34633
+ if (action === "buckets") return { method: "GET", path: base2 + "/buckets" };
34366
34634
  const bucket = option2("--bucket");
34367
34635
  if (!bucket || !bucketName.test(bucket)) throw new Error("Give the bucket with --bucket <name>; list them with backify storage buckets --environment <UUID>.");
34368
- const files = `${base}/buckets/${encodeURIComponent(bucket)}`;
34636
+ const files = `${base2}/buckets/${encodeURIComponent(bucket)}`;
34369
34637
  const key = option2("--key");
34370
34638
  const needKey = () => {
34371
34639
  if (!key) throw new Error(`Give the file with --key <key>: backify storage ${action} --environment <UUID> --bucket ${bucket} --key <key>.`);
@@ -34466,9 +34734,9 @@ var backendUsage = [
34466
34734
  function backendCall(appId, args2) {
34467
34735
  const action = args2[0];
34468
34736
  const environment = environmentOf(args2, backendUsage);
34469
- const base = `/apps/${appId}/environments/${environment}/backend`;
34470
- if (action === "show" || action === "routes") return { method: "GET", path: base };
34471
- if (action === "openapi") return { method: "GET", path: base + "/openapi.json", download: { key: "openapi.json", out: reader(args2).option("--out") } };
34737
+ const base2 = `/apps/${appId}/environments/${environment}/backend`;
34738
+ if (action === "show" || action === "routes") return { method: "GET", path: base2 };
34739
+ if (action === "openapi") return { method: "GET", path: base2 + "/openapi.json", download: { key: "openapi.json", out: reader(args2).option("--out") } };
34472
34740
  throw new Error(backendUsage);
34473
34741
  }
34474
34742
  function routeLines(routes) {
@@ -34485,22 +34753,22 @@ function jobsCall(appId, args2) {
34485
34753
  const { option: option2 } = reader(args2);
34486
34754
  const action = args2[0];
34487
34755
  const environment = environmentOf(args2, jobsUsage);
34488
- const base = `/apps/${appId}/environments/${environment}/jobs`;
34756
+ const base2 = `/apps/${appId}/environments/${environment}/jobs`;
34489
34757
  switch (action) {
34490
34758
  case "show":
34491
- return { method: "GET", path: base };
34759
+ return { method: "GET", path: base2 };
34492
34760
  case "runs": {
34493
34761
  const query = new URLSearchParams();
34494
34762
  const job = option2("--job"), status = option2("--status");
34495
34763
  if (status && !["pending", "running", "completed", "failed", "cancelled"].includes(status)) throw new Error("--status must be pending, running, completed, failed or cancelled.");
34496
34764
  if (job) query.set("job", job);
34497
34765
  if (status) query.set("status", status);
34498
- return { method: "GET", path: base + "/runs" + (query.size ? "?" + query : "") };
34766
+ return { method: "GET", path: base2 + "/runs" + (query.size ? "?" + query : "") };
34499
34767
  }
34500
34768
  case "insights": {
34501
34769
  const range = option2("--range") ?? "7d";
34502
34770
  if (!["24h", "7d", "30d"].includes(range)) throw new Error("--range must be 24h, 7d or 30d.");
34503
- return { method: "GET", path: base + "/insights?range=" + range };
34771
+ return { method: "GET", path: base2 + "/insights?range=" + range };
34504
34772
  }
34505
34773
  default:
34506
34774
  throw new Error(jobsUsage);
@@ -34804,6 +35072,7 @@ var help = [
34804
35072
  "Apps: new <name> [--template web|api|worker] [--dir <directory>] | lock [--check] | check [--lockfile-only] | dev [--port <port>]",
34805
35073
  "Setup: init | sync | doctor [--environment] | upgrade [--json]",
34806
35074
  "Account: signup [--name <organization>] [--plan <plan>] | login | logout | connect | disconnect | status | apps",
35075
+ " notifications [list [--action|--unread] | summary | read <id>|--all | dismiss <id> | preferences [set <category> --email on|off|default --in-app on|off|default]] (backify notifications --help)",
34807
35076
  "Coding: tools configure --agent <tool> [--transport http|stdio] [--config <path>] [--dry-run] | mcp [--organization <organization-id>]",
34808
35077
  "Org admin: ops search [<query>] | ops describe <operation-id> | ops get|run <operation-id> [--param <name>=<value>] [--body <file>] [--yes] [--organization <id>] [--json]",
34809
35078
  "SSO: sso [guide <provider> | connections add|update|remove | test|on|off|sign-ins <connection-id> | domains | require|unrequire <domain-id> | break-glass | group-sync | mappings | scim] (backify sso --help)",
@@ -34860,7 +35129,7 @@ async function main() {
34860
35129
  console.log(help);
34861
35130
  return;
34862
35131
  }
34863
- switch (command) {
35132
+ switch (command === "apps" && args[0] === "owner" ? "app-owner" : command) {
34864
35133
  case "version":
34865
35134
  case "--version":
34866
35135
  case "-v": {
@@ -34886,7 +35155,8 @@ async function main() {
34886
35155
  case "billing":
34887
35156
  case "members":
34888
35157
  case "costs":
34889
- case "teams": {
35158
+ case "teams":
35159
+ case "app-owner": {
34890
35160
  const { OpsError: OpsError2, terminalConfirm: terminalConfirm2 } = await Promise.resolve().then(() => (init_ops(), ops_exports));
34891
35161
  const { runTaskCommand: runTaskCommand2, taskHelp: taskHelp2 } = await Promise.resolve().then(() => (init_tasks(), tasks_exports));
34892
35162
  if (args.includes("--help") || command === "task" && !args.length) {
@@ -35512,6 +35782,20 @@ Next: ${here ? "" : `cd ${directory} && `}npm install && npm run dev`);
35512
35782
  console.log(JSON.stringify(await call(request.path), null, 2));
35513
35783
  break;
35514
35784
  }
35785
+ case "notifications": {
35786
+ if (args.includes("--help")) {
35787
+ console.log(notificationsUsage);
35788
+ break;
35789
+ }
35790
+ if (!userConfig.token) throw new Error("Sign in first: backify login");
35791
+ const account = apiClient({ token: userConfig.token, organizationId: userConfig.organizationId ?? "", apiUrl: process.env.BACKIFY_API_URL ?? userConfig.apiUrl ?? "https://api.backify.dev/api" });
35792
+ const request = notificationCall(args);
35793
+ const body = request.preferences ? mergePreference((await account(request.path)).preferences, request.preferences) : request.body;
35794
+ const result = await account(request.path, { method: request.method, body: body ? JSON.stringify(body) : void 0 });
35795
+ const listing = request.method === "GET" && request.path.startsWith("/account/notifications?");
35796
+ console.log(listing && !args.includes("--json") ? formatNotifications(result) : JSON.stringify(result, null, 2));
35797
+ break;
35798
+ }
35515
35799
  case "privacy": {
35516
35800
  if (args.includes("--help")) {
35517
35801
  console.log(privacyRequestsUsage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backifydev/cli",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "Command-line setup and diagnostics for Backify applications",
5
5
  "type": "module",
6
6
  "bin": {