@withone/cli 1.47.10 → 1.47.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -272,7 +272,7 @@ one actions execute stripe <actionId> <connectionKey> \
272
272
  | `--dry-run` | Show the request without executing it |
273
273
  | `--mock` | Return example response without making an API call |
274
274
  | `--skip-validation` | Skip input validation against the action schema |
275
- | `--output <path>` | Save response to a file (for binary downloads) |
275
+ | `--output <path>` | Save response to a file (for genuine binary downloads — PDFs, images). Text responses (text/plain, HTML, CSV, XML) render inline automatically. |
276
276
  | `--no-cache` | Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached) |
277
277
 
278
278
  The CLI validates required parameters (path variables, query params, body fields) against the action schema before executing. Missing params return a clear error with the flag name and description. Pass `--skip-validation` to bypass.
@@ -31,6 +31,31 @@ var ApiError = class extends Error {
31
31
  this.name = "ApiError";
32
32
  }
33
33
  };
34
+ function isTextualContentType(contentType) {
35
+ const ct = contentType.toLowerCase().split(";")[0].trim();
36
+ if (ct.startsWith("text/")) return true;
37
+ if (ct.endsWith("+json") || ct.endsWith("+xml")) return true;
38
+ return [
39
+ "application/json",
40
+ "application/xml",
41
+ "application/javascript",
42
+ "application/ecmascript",
43
+ "application/x-www-form-urlencoded",
44
+ "application/yaml",
45
+ "application/x-yaml",
46
+ "application/csv"
47
+ ].includes(ct);
48
+ }
49
+ function looksLikeText(s) {
50
+ if (s.length === 0) return true;
51
+ if (s.includes("\0") || s.includes("\uFFFD")) return false;
52
+ let control = 0;
53
+ for (let i = 0; i < s.length; i++) {
54
+ const c = s.charCodeAt(i);
55
+ if (c < 9 || c > 13 && c < 32 || c === 127) control++;
56
+ }
57
+ return control / s.length < 0.05;
58
+ }
34
59
  function parseRetryAfter(value) {
35
60
  if (!value) return void 0;
36
61
  const seconds = parseInt(value, 10);
@@ -388,11 +413,17 @@ var OneApi = class {
388
413
  throw new ApiError(response.status, text || `HTTP ${response.status}`);
389
414
  }
390
415
  const responseContentType = response.headers.get("content-type") || "";
391
- const isExplicitJson = responseContentType.includes("application/json") || responseContentType.includes("text/");
392
- if (isExplicitJson || !responseContentType) {
416
+ if (isTextualContentType(responseContentType) || !responseContentType) {
393
417
  const responseText2 = await response.text();
394
- const responseData = responseText2 ? JSON.parse(responseText2) : {};
395
- return { requestConfig: sanitizedConfig, responseData };
418
+ if (!responseText2) return { requestConfig: sanitizedConfig, responseData: {} };
419
+ try {
420
+ return { requestConfig: sanitizedConfig, responseData: JSON.parse(responseText2) };
421
+ } catch {
422
+ return {
423
+ requestConfig: sanitizedConfig,
424
+ responseData: { text: responseText2, contentType: responseContentType || "text/plain" }
425
+ };
426
+ }
396
427
  }
397
428
  if (args.output) {
398
429
  const outputPath = resolve(args.output);
@@ -414,6 +445,12 @@ var OneApi = class {
414
445
  const responseData = responseText ? JSON.parse(responseText) : {};
415
446
  return { requestConfig: sanitizedConfig, responseData };
416
447
  } catch {
448
+ if (looksLikeText(responseText)) {
449
+ return {
450
+ requestConfig: sanitizedConfig,
451
+ responseData: { text: responseText, contentType: responseContentType }
452
+ };
453
+ }
417
454
  const contentLength = response.headers.get("content-length");
418
455
  const size = contentLength ? parseInt(contentLength, 10) : responseText.length;
419
456
  return {
@@ -2282,7 +2319,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
2282
2319
  if (flowStack.includes(resolvedKey)) {
2283
2320
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
2284
2321
  }
2285
- const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-JNEFFR2U.js");
2322
+ const { loadFlowWithMeta: loadFlowWithMeta2 } = await import("./flow-runner-KBTX5XYX.js");
2286
2323
  const { flow: subFlow, rootDir: subRootDir } = loadFlowWithMeta2(resolvedKey);
2287
2324
  const subContext = await executeFlow(
2288
2325
  subFlow,
@@ -12,7 +12,7 @@ import {
12
12
  stripStepsAlias,
13
13
  summarizeFlowInputs,
14
14
  walkSteps
15
- } from "./chunk-4AYHJFH3.js";
15
+ } from "./chunk-VW7J2RQW.js";
16
16
  import "./chunk-44CV5IMX.js";
17
17
  import "./chunk-K6MWE2ZH.js";
18
18
  export {
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import {
31
31
  validateActionInput,
32
32
  walkSteps,
33
33
  writeCache
34
- } from "./chunk-4AYHJFH3.js";
34
+ } from "./chunk-VW7J2RQW.js";
35
35
  import {
36
36
  memSqlCommand
37
37
  } from "./chunk-QV3Y5N5G.js";
@@ -2740,7 +2740,13 @@ async function actionsExecuteCommand(platform, actionId, connectionKey, options)
2740
2740
  } else {
2741
2741
  console.log();
2742
2742
  console.log(pc6.bold("Response:"));
2743
- console.log(JSON.stringify(result.responseData, null, 2));
2743
+ const rd = result.responseData;
2744
+ if (rd && typeof rd === "object" && typeof rd.text === "string" && "contentType" in rd) {
2745
+ if (rd.contentType) console.log(pc6.dim(`(${rd.contentType})`));
2746
+ console.log(rd.text);
2747
+ } else {
2748
+ console.log(JSON.stringify(result.responseData, null, 2));
2749
+ }
2744
2750
  }
2745
2751
  } catch (error2) {
2746
2752
  spinner5.stop("Execution failed");
@@ -9699,7 +9705,7 @@ one --agent actions execute <platform> <actionId> <key> -d '{}' # Execute it
9699
9705
  - \`--dry-run\` \u2014 Preview request without executing
9700
9706
  - \`--mock\` \u2014 Return example response without making an API call (useful for building UI against a response shape)
9701
9707
  - \`--skip-validation\` \u2014 Skip input validation against the action schema
9702
- - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents)
9708
+ - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents). Text responses (text/plain, HTML, CSV, XML) render inline automatically \u2014 \`--output\` is only needed for genuinely binary payloads.
9703
9709
  - \`--no-cache\` \u2014 Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached)
9704
9710
 
9705
9711
  The CLI validates required parameters against the action schema before executing. If you're missing a required path variable, query param, or body field, you'll get a clear error listing what's missing and which flag to use. Pass \`--skip-validation\` to bypass.
@@ -9831,7 +9837,7 @@ one --agent actions execute <platform> <actionId> <connectionKey> [options]
9831
9837
  - \`--dry-run\` \u2014 Preview without executing
9832
9838
  - \`--mock\` \u2014 Return example response without making an API call
9833
9839
  - \`--skip-validation\` \u2014 Skip input validation against the action schema
9834
- - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents)
9840
+ - \`--output <path>\` \u2014 Save response to a file (for binary downloads like PDFs, images, documents). Text responses (text/plain, HTML, CSV, XML) render inline automatically \u2014 \`--output\` is only needed for genuinely binary payloads.
9835
9841
  - \`--no-cache\` \u2014 Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached)
9836
9842
 
9837
9843
  Execute reuses the action details cached by \`actions knowledge\` (method, path, schema), so in the standard search \u2192 knowledge \u2192 execute flow it makes a single API call \u2014 the action being executed. The live response is never cached. In \`--agent\` mode the response includes \`"_preflight": {"cache": "hit"|"miss"}\` showing whether the lookup was served from disk.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "1.47.10",
3
+ "version": "1.47.11",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -89,7 +89,7 @@ Options:
89
89
  - `--dry-run` — Preview the request without executing
90
90
  - `--mock` — Return example response without making an API call (useful for building UI)
91
91
  - `--skip-validation` — Skip input validation against the action schema
92
- - `--output <path>` — Save response to a file (for binary downloads like PDFs, images, documents)
92
+ - `--output <path>` — Save response to a file (for binary downloads like PDFs, images, documents). Text responses (text/plain, HTML, CSV, XML) render inline automatically; `--output` is only needed for genuinely binary payloads.
93
93
  - `--no-cache` — Bypass the cached action details and re-fetch them; the fresh details still refresh the cache (execution itself is never cached)
94
94
 
95
95
  The CLI validates required parameters before executing. Missing params return a structured error with the flag name, parameter name, and description. Pass `--skip-validation` to bypass.