bdy 1.25.3-dev → 1.25.5-dev

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 (47) hide show
  1. package/distTs/package.json +2 -1
  2. package/distTs/src/agent/socket/tunnel.js +2 -0
  3. package/distTs/src/api/client.js +22 -55
  4. package/distTs/src/cliCommand.js +52 -0
  5. package/distTs/src/cliError.js +34 -0
  6. package/distTs/src/cliIndex.js +3 -1
  7. package/distTs/src/command/agent/proxy/status.js +9 -2
  8. package/distTs/src/command/agent/status.js +22 -6
  9. package/distTs/src/command/agent/tags/get.js +9 -2
  10. package/distTs/src/command/agent/target/status.js +9 -2
  11. package/distTs/src/command/agent/tunnel/list.js +6 -1
  12. package/distTs/src/command/agent/tunnel/status.js +13 -1
  13. package/distTs/src/command/agent/version.js +7 -2
  14. package/distTs/src/command/api/info.js +50 -2
  15. package/distTs/src/command/api/list.js +18 -2
  16. package/distTs/src/command/artifact/create.js +5 -0
  17. package/distTs/src/command/artifact/publish.js +20 -22
  18. package/distTs/src/command/artifact/version/create.js +5 -0
  19. package/distTs/src/command/config/get/tunnel.js +8 -3
  20. package/distTs/src/command/config/get/tunnels.js +8 -3
  21. package/distTs/src/command/discover.js +9 -11
  22. package/distTs/src/command/distro/create.js +5 -0
  23. package/distTs/src/command/distro/route/create.js +5 -0
  24. package/distTs/src/command/distro/route/update.js +5 -0
  25. package/distTs/src/command/distro/update.js +5 -0
  26. package/distTs/src/command/domain/search.js +31 -10
  27. package/distTs/src/command/environment/create.js +5 -0
  28. package/distTs/src/command/environment/update.js +5 -0
  29. package/distTs/src/command/sandbox/app/add.js +7 -1
  30. package/distTs/src/command/sandbox/app/logs.js +9 -4
  31. package/distTs/src/command/sandbox/create.js +13 -5
  32. package/distTs/src/command/sandbox/endpoint/add.js +5 -0
  33. package/distTs/src/command/sandbox/exec/command.js +15 -30
  34. package/distTs/src/command/sandbox/exec/logs.js +4 -29
  35. package/distTs/src/command/sandbox/finishExec.js +34 -0
  36. package/distTs/src/command/sandbox/logs.js +14 -1
  37. package/distTs/src/command/sandbox/snapshot/create.js +9 -1
  38. package/distTs/src/command/target/create.js +5 -0
  39. package/distTs/src/command/target/exec/logs.js +15 -2
  40. package/distTs/src/command/target/update.js +5 -0
  41. package/distTs/src/command/yaml/validate.js +111 -52
  42. package/distTs/src/index.js +6 -1
  43. package/distTs/src/input.js +12 -11
  44. package/distTs/src/openapi.js +8 -1
  45. package/distTs/src/output.js +55 -13
  46. package/distTs/src/texts.js +272 -59
  47. package/package.json +2 -1
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.apiEndpoints = apiEndpoints;
4
+ exports.apiSpecification = apiSpecification;
4
5
  const docs_schema_1 = require("@buddy-works/docs-schema");
5
6
  const texts_1 = require("./texts");
6
7
  const utils_1 = require("./utils");
7
8
  const diskCache_1 = require("./diskCache");
8
9
  let held = null;
10
+ let specification = null;
9
11
  async function apiEndpoints(baseUrl) {
10
12
  if (held)
11
13
  return held;
@@ -18,10 +20,15 @@ async function apiEndpoints(baseUrl) {
18
20
  if (!raw)
19
21
  throw new Error(texts_1.ERR_SCHEMA_FETCH_FAILED);
20
22
  try {
21
- held = docs_schema_1.BuddySchema.from({ api: JSON.parse(raw) }).api;
23
+ specification = JSON.parse(raw);
24
+ held = docs_schema_1.BuddySchema.from({ api: specification }).api;
22
25
  }
23
26
  catch {
24
27
  throw new Error(texts_1.ERR_SCHEMA_FETCH_FAILED);
25
28
  }
26
29
  return held;
27
30
  }
31
+ async function apiSpecification(baseUrl) {
32
+ await apiEndpoints(baseUrl);
33
+ return specification;
34
+ }
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const texts_1 = require("./texts");
7
7
  const utils_1 = require("./utils");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
+ const node_readline_1 = require("node:readline");
10
+ const cliError_1 = __importDefault(require("./cliError"));
9
11
  let _terminal = null;
10
12
  function getTerminal() {
11
13
  if (!_terminal) {
@@ -15,6 +17,7 @@ function getTerminal() {
15
17
  return _terminal;
16
18
  }
17
19
  class Output {
20
+ static errorFormat = 'text';
18
21
  static s;
19
22
  static _a;
20
23
  static getCyanColor(text) {
@@ -134,6 +137,15 @@ class Output {
134
137
  msg += '\n';
135
138
  getTerminal()(msg);
136
139
  }
140
+ static progress(quiet, output = this.normal.bind(this)) {
141
+ return (txt, newLine = true, replacePrevious = false) => {
142
+ if (quiet)
143
+ return;
144
+ if (replacePrevious)
145
+ this.clearPreviousLine();
146
+ output(txt, newLine);
147
+ };
148
+ }
137
149
  // Payload output (command results, logs, JSON): bypasses terminal-kit,
138
150
  // whose printf-style formatting and ^-markup corrupt data containing
139
151
  // % or ^ sequences. newLine=false emits a mid-stream chunk, keeping
@@ -652,26 +664,56 @@ class Output {
652
664
  static json(json) {
653
665
  this.data(JSON.stringify(json));
654
666
  }
667
+ static async streamCommandLogs(body, jsonl) {
668
+ // readline preserves UTF-8 and records split across transport chunks.
669
+ const lines = (0, node_readline_1.createInterface)({ input: body, crlfDelay: Infinity });
670
+ for await (const line of lines) {
671
+ if (!line.trim())
672
+ continue;
673
+ let record;
674
+ try {
675
+ record = JSON.parse(line);
676
+ }
677
+ catch {
678
+ continue;
679
+ }
680
+ if (typeof record?.data !== 'string')
681
+ continue;
682
+ if (jsonl) {
683
+ this.json({
684
+ type: 'log',
685
+ ...(record.stream === 'stdout' || record.stream === 'stderr'
686
+ ? { stream: record.stream }
687
+ : {}),
688
+ data: record.data,
689
+ });
690
+ }
691
+ else if (record.data) {
692
+ this.data(record.data);
693
+ }
694
+ }
695
+ }
655
696
  static exitError(err) {
656
697
  this.clearUndici();
657
698
  this.clearTerminal();
658
- const isDebug = process.env.DEBUG === '1';
659
- let msg;
660
- if (err instanceof Error) {
661
- msg = err.message;
662
- if (isDebug)
663
- msg += `\n${err.stack}`;
664
- }
665
- else {
666
- const e = new Error();
667
- msg = err;
668
- if (isDebug)
669
- msg += `\n${e.stack}`;
699
+ this.writeError(err);
700
+ process.exit(1);
701
+ }
702
+ static writeError(err, format = this.errorFormat) {
703
+ const error = cliError_1.default.details(err);
704
+ if (format !== 'text') {
705
+ this.json(format === 'jsonl' ? { type: 'error', error } : { error });
706
+ if (process.env.DEBUG === '1' && err instanceof Error && err.stack)
707
+ this.writeStderr(err.stack);
708
+ return;
670
709
  }
710
+ const isDebug = process.env.DEBUG === '1';
711
+ let msg = [error.message, error.hint].filter(Boolean).join(' ');
712
+ if (isDebug)
713
+ msg += `\n${err instanceof Error ? err.stack : new Error().stack}`;
671
714
  // Raw stderr: error messages carry user/API data (SQL, URLs) that
672
715
  // terminal-kit's %-formatting would corrupt.
673
716
  this.writeStderr(this.getRedColor(String(msg)));
674
- process.exit(1);
675
717
  }
676
718
  }
677
719
  exports.default = Output;