@datarails-ai/dr-appspace-cli 0.12.88 → 0.12.89

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/cli.js +96 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import { fileURLToPath as fileURLToPath6 } from "url";
13
13
  // package.json
14
14
  var package_default = {
15
15
  name: "@datarails-ai/dr-appspace-cli",
16
- version: "0.12.88",
16
+ version: "0.12.89",
17
17
  description: "Datarails App Space CLI \u2014 build, try, push and publish App Space apps",
18
18
  type: "module",
19
19
  engines: {
@@ -57,7 +57,7 @@ var package_default = {
57
57
  };
58
58
 
59
59
  // src/buildInfo.ts
60
- var BUILD_TIME = "2026-11-15T13:05:59.646Z";
60
+ var BUILD_TIME = "2026-11-15T18:08:34.863Z";
61
61
  function formatBuildTime(iso) {
62
62
  if (iso === "") return "";
63
63
  const d = new Date(iso);
@@ -3181,10 +3181,8 @@ function formatUtc(unix) {
3181
3181
  return `${d.getUTCFullYear()}-${pad2(d.getUTCMonth() + 1)}-${pad2(d.getUTCDate())} ${pad2(d.getUTCHours())}:${pad2(d.getUTCMinutes())}:${pad2(d.getUTCSeconds())} UTC`;
3182
3182
  }
3183
3183
 
3184
- // src/commands/appspace/compare.ts
3185
- import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
3186
- import { chmod as chmod2, readFile as readFile12, writeFile as writeFile8 } from "fs/promises";
3187
- import { join as join17 } from "path";
3184
+ // src/commands/appspace/approveHosts.ts
3185
+ import { createInterface } from "readline/promises";
3188
3186
 
3189
3187
  // src/commands/appspace/_client.ts
3190
3188
  function withServerOptions(cmd) {
@@ -3512,6 +3510,97 @@ ${l}`).join("");
3512
3510
  ${detail}`}`;
3513
3511
  }
3514
3512
 
3513
+ // src/commands/appspace/approveHosts.ts
3514
+ function parseHosts(value) {
3515
+ return value.split(",").map((h) => h.trim()).filter((h) => h !== "");
3516
+ }
3517
+ function describeEntries(res) {
3518
+ if (res.entries.length === 0) return "The app declares no outside hosts.\n";
3519
+ const lines = res.entries.map((e) => {
3520
+ const prefix = e.prefix === "" ? "" : ` with prefix ${JSON.stringify(e.prefix)}`;
3521
+ const key = e.secret === null ? "" : `, sends secret ${e.secret} in ${e.header}${prefix}`;
3522
+ const state = e.approved ? "approved" : "WAITS FOR APPROVAL";
3523
+ return `${e.name}: ${e.methods.join("/")} https://${e.host}${key} \u2014 ${state}`;
3524
+ });
3525
+ return lines.join("\n") + "\n";
3526
+ }
3527
+ async function askYes(question, output) {
3528
+ const rl = createInterface({ input: process.stdin, output });
3529
+ try {
3530
+ const answer = await rl.question(question);
3531
+ return /^y(es)?$/i.test(answer.trim());
3532
+ } finally {
3533
+ rl.close();
3534
+ }
3535
+ }
3536
+ function approvalsPath(appId) {
3537
+ return `/apps/${encodeURIComponent(appId)}/http-approvals`;
3538
+ }
3539
+ function registerApproveHostsCommand(parent) {
3540
+ withJsonOption(
3541
+ withServerOptions(
3542
+ parent.command("approve-hosts <app-id>").description(
3543
+ "List an app's outside hosts, or approve them with --hosts (the app's Owner only, never an agent)."
3544
+ ).option("--hosts <hosts>", "comma-separated host names to approve").option("--yes", "approve the entries shown without asking")
3545
+ )
3546
+ ).action(async (appId, opts) => {
3547
+ const hosts = opts.hosts === void 0 ? void 0 : parseHosts(opts.hosts);
3548
+ if (hosts !== void 0 && hosts.length === 0) {
3549
+ throw new Error("--hosts needs at least one host name");
3550
+ }
3551
+ const client = await connect(opts);
3552
+ try {
3553
+ let res = await client.request(approvalsPath(appId));
3554
+ if (hosts !== void 0) {
3555
+ const wanted = new Set(hosts);
3556
+ const waiting = res.entries.filter((e) => wanted.has(e.host) && !e.approved);
3557
+ if (waiting.length > 0) {
3558
+ const say = opts.json === true ? process.stderr : process.stdout;
3559
+ say.write(`About to approve for ${appId}:
3560
+ `);
3561
+ say.write(describeEntries({ entries: waiting, pending_hosts: [] }));
3562
+ if (opts.yes !== true) {
3563
+ if (process.stdin.isTTY !== true) {
3564
+ throw new Error("pass --yes to approve without a terminal to confirm on");
3565
+ }
3566
+ if (!await askYes("Approve these? [y/N] ", say)) {
3567
+ throw new Error("not approved");
3568
+ }
3569
+ }
3570
+ }
3571
+ res = await client.request(approvalsPath(appId), {
3572
+ method: "POST",
3573
+ body: { hosts, fingerprints: waiting.map((e) => e.fingerprint) }
3574
+ });
3575
+ }
3576
+ if (opts.json === true) {
3577
+ printJson(res);
3578
+ return;
3579
+ }
3580
+ if (hosts !== void 0) {
3581
+ const done = res.approved ?? [];
3582
+ process.stdout.write(
3583
+ done.length === 0 ? `Nothing new to approve for ${appId}.
3584
+ ` : `Approved ${done.join(", ")} for ${appId}.
3585
+ `
3586
+ );
3587
+ }
3588
+ process.stdout.write(describeEntries(res));
3589
+ if (res.approve_with !== void 0) {
3590
+ process.stdout.write(`To approve: ${res.approve_with}
3591
+ `);
3592
+ }
3593
+ } finally {
3594
+ client.cleanup();
3595
+ }
3596
+ });
3597
+ }
3598
+
3599
+ // src/commands/appspace/compare.ts
3600
+ import { createHash as createHash4, randomBytes as randomBytes2 } from "crypto";
3601
+ import { chmod as chmod2, readFile as readFile12, writeFile as writeFile8 } from "fs/promises";
3602
+ import { join as join17 } from "path";
3603
+
3515
3604
  // src/commands/appspace/_folder.ts
3516
3605
  import { readFile, readdir, stat, writeFile as writeFile2 } from "fs/promises";
3517
3606
  import { join as join4 } from "path";
@@ -45639,6 +45728,7 @@ function registerAppSpaceCommand(root) {
45639
45728
  registerCompareCommand(cmd);
45640
45729
  registerPublishCommands(cmd);
45641
45730
  registerSecretsCommand(cmd);
45731
+ registerApproveHostsCommand(cmd);
45642
45732
  }
45643
45733
 
45644
45734
  // src/commands/update.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarails-ai/dr-appspace-cli",
3
- "version": "0.12.88",
3
+ "version": "0.12.89",
4
4
  "description": "Datarails App Space CLI — build, try, push and publish App Space apps",
5
5
  "type": "module",
6
6
  "engines": {