@epilot/cli 0.1.6 → 0.1.8

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 (59) hide show
  1. package/README.md +3 -2
  2. package/dist/{access-token-BDNU3ZFC.js → access-token-ZDNEKP3G.js} +7 -4
  3. package/dist/{address-ZCYZYRP4.js → address-2SW3VMN3.js} +7 -4
  4. package/dist/{address-suggestions-RP5N7NVQ.js → address-suggestions-26ZRCECN.js} +7 -4
  5. package/dist/{ai-agents-PLUGVZTI.js → ai-agents-PDOHJ7VB.js} +7 -4
  6. package/dist/{app-HZECIN6N.js → app-XJNMGPZO.js} +7 -4
  7. package/dist/{audit-logs-JWKGNHPP.js → audit-logs-L2OCFRGO.js} +7 -4
  8. package/dist/{auth-JRW6QLKR.js → auth-AAF6Z5WZ.js} +3 -3
  9. package/dist/{auth-login-7B4GCQWY.js → auth-login-AJ6F5GPQ.js} +12 -11
  10. package/dist/{auth-token-VSNRXUBI.js → auth-token-J4FI2RMT.js} +1 -1
  11. package/dist/{automation-73BC4PYK.js → automation-UB7OFM4Q.js} +7 -4
  12. package/dist/{billing-GQDSK4H2.js → billing-ZXHTBUAP.js} +7 -4
  13. package/dist/bin/epilot.js +65 -54
  14. package/dist/{blueprint-manifest-4M7DNWYE.js → blueprint-manifest-RMKS5EQA.js} +7 -4
  15. package/dist/{chunk-6RBLA5YE.js → chunk-7ZQ666ZQ.js} +44 -1
  16. package/dist/{chunk-BJOXXFMA.js → chunk-HWUVFZIB.js} +172 -56
  17. package/dist/{chunk-HN4QDJOJ.js → chunk-IOLKUHUB.js} +10 -10
  18. package/dist/{completion-RCVUCEMM.js → completion-EKFXGPNK.js} +1 -1
  19. package/dist/{consent-OJBGOI54.js → consent-AQ2DKCDR.js} +7 -4
  20. package/dist/{customer-portal-BDKNWKHA.js → customer-portal-CGP4ZX4R.js} +7 -4
  21. package/dist/{dashboard-IAEU3JFY.js → dashboard-IDWUGNZW.js} +7 -4
  22. package/dist/{data-management-UEDSGAKB.js → data-management-U7ZRAGLQ.js} +7 -4
  23. package/dist/{deduplication-JJS3TOJ2.js → deduplication-QQUSPXAF.js} +7 -4
  24. package/dist/{design-WKSDZFBJ.js → design-PQ2FUC2D.js} +7 -4
  25. package/dist/{document-P5OL4NYY.js → document-Y76RC3MP.js} +7 -4
  26. package/dist/{email-settings-743JHCKS.js → email-settings-XM3ADDAU.js} +7 -4
  27. package/dist/{email-template-MW4IVDPM.js → email-template-72P5GBEO.js} +7 -4
  28. package/dist/{entity-K5X6FWJI.js → entity-XHM54EGF.js} +7 -4
  29. package/dist/{entity-mapping-QBJ2I2VR.js → entity-mapping-L5QITA2E.js} +7 -4
  30. package/dist/{environments-VUR7ME42.js → environments-VW3SQQ6D.js} +7 -4
  31. package/dist/{erp-integration-A2KAIXUQ.js → erp-integration-XCFKHGOU.js} +7 -4
  32. package/dist/{event-catalog-6YEG5CEM.js → event-catalog-XZ233C2K.js} +7 -4
  33. package/dist/{file-J6PHZ447.js → file-TYBZ6WUC.js} +7 -4
  34. package/dist/{iban-DJSUCRU6.js → iban-IEGS2B6M.js} +7 -4
  35. package/dist/{interactive-XXYFAJEI.js → interactive-LSY5SADM.js} +4 -4
  36. package/dist/{journey-QJZKU3PZ.js → journey-HY3MNAHS.js} +7 -4
  37. package/dist/{kanban-ZF4IIG7Q.js → kanban-7RLHAPAB.js} +7 -4
  38. package/dist/{message-WH4GD5SC.js → message-K7E26IZC.js} +7 -4
  39. package/dist/{metering-FCWUZ2TC.js → metering-2OGVZIBR.js} +7 -4
  40. package/dist/{notes-KKVPGK7K.js → notes-KQVLCMGP.js} +7 -4
  41. package/dist/{notification-4MVAZTRP.js → notification-BFBWDPZV.js} +7 -4
  42. package/dist/{organization-2UT2KFMB.js → organization-LI7FM5BQ.js} +7 -4
  43. package/dist/{partner-directory-SUNW4XN7.js → partner-directory-XPAISFGT.js} +7 -4
  44. package/dist/{permissions-36VGB4BQ.js → permissions-R5A4XMTY.js} +7 -4
  45. package/dist/{pricing-RCNFEEHO.js → pricing-Y4T6VKYN.js} +7 -4
  46. package/dist/{pricing-tier-MNCLLXD5.js → pricing-tier-HWKSYSVR.js} +7 -4
  47. package/dist/{profile-MZ3VK7PO.js → profile-EK4HSQ57.js} +1 -1
  48. package/dist/{purpose-3JN63WTQ.js → purpose-5AUHF3IO.js} +7 -4
  49. package/dist/{sandbox-C676YDRV.js → sandbox-QSGFCXMZ.js} +7 -4
  50. package/dist/{submission-5XTNMMCK.js → submission-Z73M4XKQ.js} +7 -4
  51. package/dist/{targeting-C52KV6IW.js → targeting-U5YIFO6Q.js} +7 -4
  52. package/dist/{template-variables-5SKJEJF4.js → template-variables-AV4T4OL2.js} +7 -4
  53. package/dist/{upgrade-GSUVIXOB.js → upgrade-2SY2XG5S.js} +2 -2
  54. package/dist/{user-DYAR3N6L.js → user-S7XP7EFG.js} +7 -4
  55. package/dist/{validation-rules-LDAOUPOO.js → validation-rules-MJRLZCHT.js} +7 -4
  56. package/dist/{webhooks-MT2P33A2.js → webhooks-X2VR5SVC.js} +7 -4
  57. package/dist/{workflow-YGWGE6L4.js → workflow-EGOFLIKI.js} +7 -4
  58. package/dist/{workflow-definition-JG54ZWGL.js → workflow-definition-65ZR33O5.js} +7 -4
  59. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/lib/utils.ts
4
+ import { spawnSync } from "child_process";
4
5
  var isValidJson = (str) => {
5
6
  try {
6
7
  JSON.parse(str);
@@ -51,6 +52,29 @@ var methodColor = (method) => {
51
52
  return "\x1B[37m";
52
53
  }
53
54
  };
55
+ var pager = (content) => {
56
+ if (!process.stdout.isTTY) {
57
+ process.stdout.write(content);
58
+ return;
59
+ }
60
+ const lines = content.split("\n").length;
61
+ const rows = process.stdout.rows || 24;
62
+ if (lines <= rows) {
63
+ process.stdout.write(content);
64
+ return;
65
+ }
66
+ try {
67
+ const result = spawnSync("less", ["-R", "-F", "-X"], {
68
+ input: content,
69
+ stdio: ["pipe", "inherit", "inherit"]
70
+ });
71
+ if (result.status !== 0 && result.status !== null) {
72
+ process.stdout.write(content);
73
+ }
74
+ } catch {
75
+ process.stdout.write(content);
76
+ }
77
+ };
54
78
  var RESET = "\x1B[0m";
55
79
  var BOLD = "\x1B[1m";
56
80
  var DIM = "\x1B[2m";
@@ -58,17 +82,36 @@ var GREEN = "\x1B[32m";
58
82
  var RED = "\x1B[31m";
59
83
  var YELLOW = "\x1B[33m";
60
84
  var CYAN = "\x1B[36m";
85
+ var WHITE = "\x1B[37m";
86
+ var BG_GREEN = "\x1B[42m";
87
+ var BG_RED = "\x1B[41m";
88
+ var MAGENTA = "\x1B[35m";
89
+ var highlightJson = (jsonStr) => jsonStr.replace(
90
+ /("(?:\\.|[^"\\])*")\s*(:)?|(\b(?:true|false|null)\b)|(-?\b\d+(?:\.\d+)?(?:[eE][+-]?\d+)?\b)/g,
91
+ (match, str, colon, bool, num) => {
92
+ if (str && colon) return `${CYAN}${str}${RESET}${colon}`;
93
+ if (str) return `${GREEN}${str}${RESET}`;
94
+ if (bool) return `${MAGENTA}${bool}${RESET}`;
95
+ if (num) return `${YELLOW}${num}${RESET}`;
96
+ return match;
97
+ }
98
+ );
61
99
 
62
100
  export {
63
101
  isValidJson,
64
102
  parseKeyValue,
65
103
  parseParamValue,
66
104
  methodColor,
105
+ pager,
67
106
  RESET,
68
107
  BOLD,
69
108
  DIM,
70
109
  GREEN,
71
110
  RED,
72
111
  YELLOW,
73
- CYAN
112
+ CYAN,
113
+ WHITE,
114
+ BG_GREEN,
115
+ BG_RED,
116
+ highlightJson
74
117
  };
@@ -6,23 +6,28 @@ import {
6
6
  getResolvedProfile
7
7
  } from "./chunk-PDMWUCWD.js";
8
8
  import {
9
+ formatOperationsTable,
9
10
  isInteractive,
10
11
  pickOperation,
11
- printOperationsTable,
12
12
  promptParam
13
- } from "./chunk-HN4QDJOJ.js";
13
+ } from "./chunk-IOLKUHUB.js";
14
14
  import {
15
+ BG_GREEN,
16
+ BG_RED,
15
17
  BOLD,
16
18
  DIM,
17
19
  GREEN,
18
20
  RED,
19
21
  RESET,
22
+ WHITE,
20
23
  YELLOW,
24
+ highlightJson,
21
25
  isValidJson,
22
26
  methodColor,
27
+ pager,
23
28
  parseKeyValue,
24
29
  parseParamValue
25
- } from "./chunk-6RBLA5YE.js";
30
+ } from "./chunk-7ZQ666ZQ.js";
26
31
 
27
32
  // src/lib/call.ts
28
33
  import OpenAPIClientAxiosModule from "openapi-client-axios";
@@ -253,40 +258,73 @@ var readStdin = () => {
253
258
  };
254
259
 
255
260
  // src/lib/response-formatter.ts
261
+ var statusBg = (code) => {
262
+ if (code >= 400) return BG_RED;
263
+ return BG_GREEN;
264
+ };
256
265
  var formatResponse = async (response, options) => {
257
- const { json, include, verbose, jsonata } = options;
266
+ const { json, include, verbose, jsonata, interactive, operationId } = options;
267
+ const isTTY = process.stdout.isTTY && process.stderr.isTTY;
268
+ const usePager = !json && isTTY && interactive !== false;
269
+ let buf = "";
270
+ const meta = (text) => {
271
+ if (usePager) {
272
+ buf += text;
273
+ } else {
274
+ process.stderr.write(text);
275
+ }
276
+ };
277
+ const req = response.config;
278
+ const method = (req.method || "GET").toUpperCase();
279
+ const baseURL = req.baseURL || "";
280
+ const reqUrl = req.url || "";
281
+ const url = reqUrl.startsWith("http") ? reqUrl : `${baseURL.replace(/\/$/, "")}${reqUrl.startsWith("/") ? "" : "/"}${reqUrl}`;
258
282
  if (verbose) {
259
- const req = response.config;
260
- process.stderr.write(`${DIM}${req.method?.toUpperCase()} ${req.url}${RESET}
261
- `);
283
+ meta(`${DIM}REQUEST META:${RESET}
284
+ `);
285
+ const requestMeta = {
286
+ operationId,
287
+ method,
288
+ url
289
+ };
290
+ if (req.params && Object.keys(req.params).length > 0) {
291
+ requestMeta.params = req.params;
292
+ }
262
293
  if (req.headers) {
294
+ const headers = {};
263
295
  for (const [key, value] of Object.entries(req.headers)) {
264
- if (typeof value === "string" && key.toLowerCase() !== "authorization") {
265
- process.stderr.write(`${DIM}> ${key}: ${value}${RESET}
266
- `);
267
- } else if (key.toLowerCase() === "authorization") {
268
- process.stderr.write(`${DIM}> ${key}: Bearer ***${RESET}
269
- `);
296
+ if (key.toLowerCase() === "authorization") {
297
+ headers[key] = "Bearer ***";
298
+ } else if (typeof value === "string") {
299
+ headers[key] = value;
270
300
  }
271
301
  }
302
+ requestMeta.headers = headers;
272
303
  }
273
- process.stderr.write("\n");
274
- }
275
- if (!json && !include && process.stdout.isTTY && process.stderr.isTTY) {
276
- const statusColor = response.status >= 200 && response.status < 300 ? GREEN : response.status >= 400 ? RED : YELLOW;
277
- process.stderr.write(
278
- `${statusColor}${BOLD}${response.status}${RESET} ${statusColor}${response.statusText}${RESET}
279
- `
280
- );
281
- }
282
- if (include) {
283
- process.stderr.write(`${DIM}HTTP/${response.status} ${response.statusText}${RESET}
304
+ meta(`${DIM}${JSON.stringify(requestMeta, null, 2)}${RESET}
305
+
284
306
  `);
285
- for (const [key, value] of Object.entries(response.headers)) {
286
- process.stderr.write(`${DIM}${key}: ${value}${RESET}
307
+ }
308
+ if (verbose || include) {
309
+ meta(`${DIM}RESPONSE META:${RESET}
287
310
  `);
311
+ const responseMeta = {
312
+ code: response.status,
313
+ status: response.statusText
314
+ };
315
+ if (include) {
316
+ responseMeta.headers = response.headers;
288
317
  }
289
- process.stderr.write("\n");
318
+ meta(`${DIM}${JSON.stringify(responseMeta, null, 2)}${RESET}
319
+
320
+ `);
321
+ } else if (!json && isTTY) {
322
+ const mColor = methodColor(method);
323
+ meta(`${mColor}${BOLD}${method}${RESET} ${url}
324
+ `);
325
+ const bg = statusBg(response.status);
326
+ meta(`${bg}${WHITE}${BOLD} ${response.status} ${RESET} ${response.statusText}
327
+ `);
290
328
  }
291
329
  let data = response.data;
292
330
  if (jsonata && data) {
@@ -301,13 +339,33 @@ var formatResponse = async (response, options) => {
301
339
  }
302
340
  }
303
341
  if (data !== void 0 && data !== null) {
304
- if (typeof data === "string") {
305
- process.stdout.write(`${data}
342
+ if (verbose || include) {
343
+ meta(`${DIM}RESPONSE BODY:${RESET}
306
344
  `);
345
+ }
346
+ let body;
347
+ if (typeof data === "string") {
348
+ body = `${data}
349
+ `;
350
+ } else if (json) {
351
+ body = `${JSON.stringify(data)}
352
+ `;
353
+ } else {
354
+ const pretty = JSON.stringify(data, null, 2);
355
+ body = isTTY ? `${highlightJson(pretty)}
356
+ ` : `${pretty}
357
+ `;
358
+ }
359
+ if (usePager) {
360
+ pager(buf + body);
307
361
  } else {
308
- const indent = json ? 0 : 2;
309
- process.stdout.write(`${JSON.stringify(data, null, indent)}
362
+ process.stdout.write(body);
363
+ }
364
+ } else {
365
+ meta(`${DIM}(empty response)${RESET}
310
366
  `);
367
+ if (usePager && buf) {
368
+ pager(buf);
311
369
  }
312
370
  }
313
371
  };
@@ -363,7 +421,6 @@ var mockFromSchema = (schema) => {
363
421
  return mock(schema);
364
422
  };
365
423
  var { dereferenceSync } = dereferenceJsonSchema;
366
- var w = (text) => process.stdout.write(text);
367
424
  var getBodySchema = (spec, operationId) => {
368
425
  const paths = spec.paths ?? {};
369
426
  for (const methods of Object.values(paths)) {
@@ -379,7 +436,11 @@ var getBodySchema = (spec, operationId) => {
379
436
  }
380
437
  return void 0;
381
438
  };
382
- var printOperationHelp = (apiName, operationId, spec) => {
439
+ var formatOperationHelp = (apiName, operationId, spec) => {
440
+ let out = "";
441
+ const w = (text) => {
442
+ out += text;
443
+ };
383
444
  for (const [path, methods] of Object.entries(spec.paths ?? {})) {
384
445
  if (!methods) continue;
385
446
  for (const method of ["get", "post", "put", "patch", "delete", "head", "options"]) {
@@ -432,15 +493,15 @@ ${BOLD}epilot ${apiName} ${operationId}${RESET}`);
432
493
  if (bodySchema) {
433
494
  try {
434
495
  const mockBody = truncateJson(mockFromSchema(bodySchema));
435
- const bodyStr = JSON.stringify(mockBody, null, 2);
496
+ const bodyStr = highlightJson(JSON.stringify(mockBody, null, 2));
436
497
  const lines = bodyStr.split("\n");
437
498
  w(`
438
499
  `);
439
500
  if (lines.length <= MAX_BODY_LINES) {
440
- for (const line of lines) w(` ${DIM}${line}${RESET}
501
+ for (const line of lines) w(` ${line}
441
502
  `);
442
503
  } else {
443
- for (const line of lines.slice(0, MAX_BODY_LINES)) w(` ${DIM}${line}${RESET}
504
+ for (const line of lines.slice(0, MAX_BODY_LINES)) w(` ${line}
444
505
  `);
445
506
  w(` ${DIM} ...${RESET}
446
507
  `);
@@ -451,6 +512,37 @@ ${BOLD}epilot ${apiName} ${operationId}${RESET}`);
451
512
  w(`
452
513
  `);
453
514
  }
515
+ w(`${BOLD}FLAGS${RESET}
516
+
517
+ `);
518
+ w(` ${GREEN}-p${RESET} key=value Set a named parameter
519
+ `);
520
+ w(` ${GREEN}-d${RESET} '{...}' Request body JSON
521
+ `);
522
+ w(` ${GREEN}-H${RESET} 'Key: Value' Custom header
523
+ `);
524
+ w(` ${GREEN}-t, --token${RESET} <token> Bearer token for authentication
525
+ `);
526
+ w(` ${GREEN}--profile${RESET} <name> Use a named profile
527
+ `);
528
+ w(` ${GREEN}-s, --server${RESET} <url> Override server base URL
529
+ `);
530
+ w(` ${GREEN}-i, --include${RESET} Include response headers in output
531
+ `);
532
+ w(` ${GREEN}--json${RESET} Output raw JSON (no formatting)
533
+ `);
534
+ w(` ${GREEN}-v, --verbose${RESET} Verbose output (show request details)
535
+ `);
536
+ w(` ${GREEN}--jsonata${RESET} <expr> JSONata expression to transform response
537
+ `);
538
+ w(` ${GREEN}--definition${RESET} <file> Override OpenAPI spec file/URL
539
+ `);
540
+ w(` ${GREEN}--guided${RESET} Prompt for all parameters interactively
541
+ `);
542
+ w(` ${GREEN}--no-interactive${RESET} Disable interactive prompts
543
+ `);
544
+ w(`
545
+ `);
454
546
  w(`${BOLD}EXAMPLES${RESET}
455
547
 
456
548
  `);
@@ -544,7 +636,8 @@ ${BOLD}epilot ${apiName} ${operationId}${RESET}`);
544
636
  `);
545
637
  const limit = 40;
546
638
  const shown = lines.length <= limit ? lines : lines.slice(0, limit);
547
- for (const line of shown) w(` ${DIM}${line}${RESET}
639
+ const highlighted = highlightJson(shown.join("\n"));
640
+ for (const hLine of highlighted.split("\n")) w(` ${hLine}
548
641
  `);
549
642
  if (lines.length > limit) w(` ${DIM} ... (${lines.length - limit} more lines)${RESET}
550
643
  `);
@@ -554,12 +647,10 @@ ${BOLD}epilot ${apiName} ${operationId}${RESET}`);
554
647
  }
555
648
  }
556
649
  }
557
- return;
650
+ return out;
558
651
  }
559
652
  }
560
- process.stderr.write(`${RED}Operation "${operationId}" not found.${RESET}
561
- `);
562
- process.exit(1);
653
+ return null;
563
654
  };
564
655
  var guessJsonataExpr = (op) => {
565
656
  const successResp = op.responses?.["200"] || op.responses?.["201"];
@@ -583,25 +674,38 @@ var callApi = async (apiName, args) => {
583
674
  const spec = dereferenceSync(rawSpec);
584
675
  const operations = extractOperations(spec);
585
676
  if (!args.operation) {
586
- process.stdout.write(
587
- `
677
+ const header = `
588
678
  ${BOLD}epilot ${apiName}${RESET} - ${spec.info?.title || apiName}
589
679
 
590
- `
591
- );
592
- process.stdout.write(`${BOLD}Available operations:${RESET}
680
+ ${BOLD}Available operations:${RESET}
593
681
 
594
- `);
595
- if (isInteractive({ interactive: args.interactive })) {
682
+ `;
683
+ if (!args._apihelp && isInteractive({ interactive: args.interactive })) {
684
+ process.stdout.write(header);
596
685
  const operationId2 = await pickOperation(operations);
597
686
  return callApi(apiName, { ...args, operation: operationId2 });
598
687
  }
599
- printOperationsTable(apiName, operations);
688
+ if (args.interactive === false) {
689
+ process.stdout.write(header + formatOperationsTable(apiName, operations));
690
+ } else {
691
+ pager(header + formatOperationsTable(apiName, operations));
692
+ }
600
693
  return;
601
694
  }
602
695
  const operationId = args.operation;
603
696
  if (args.help) {
604
- printOperationHelp(apiName, operationId, spec);
697
+ const helpText = formatOperationHelp(apiName, operationId, spec);
698
+ if (helpText) {
699
+ if (args.interactive === false) {
700
+ process.stdout.write(helpText);
701
+ } else {
702
+ pager(helpText);
703
+ }
704
+ } else {
705
+ process.stderr.write(`${RED}Operation "${operationId}" not found.${RESET}
706
+ `);
707
+ process.exit(1);
708
+ }
605
709
  return;
606
710
  }
607
711
  const opExists = operations.some((op) => op.operationId === operationId);
@@ -616,7 +720,7 @@ ${BOLD}epilot ${apiName}${RESET} - ${spec.info?.title || apiName}
616
720
  let token = resolveToken(args.token, args.profile);
617
721
  if (!token) {
618
722
  if (isInteractive({ interactive: args.interactive })) {
619
- const { promptToken } = await import("./interactive-XXYFAJEI.js");
723
+ const { promptToken } = await import("./interactive-LSY5SADM.js");
620
724
  token = await promptToken();
621
725
  }
622
726
  if (!token) {
@@ -630,14 +734,23 @@ ${BOLD}epilot ${apiName}${RESET} - ${spec.info?.title || apiName}
630
734
  const opParams = getOperationParams(spec, operationId);
631
735
  const positionalArgs = args._args ?? [];
632
736
  const collected = collectParams(opParams, args.param, positionalArgs);
633
- const missing = getMissingRequired(opParams, collected);
634
- if (missing.length > 0 && isInteractive({ interactive: args.interactive })) {
737
+ if (args.guided && isInteractive({ interactive: args.interactive })) {
635
738
  for (const param of opParams) {
636
- if (param.required && !(param.name in collected)) {
739
+ if (!(param.name in collected)) {
637
740
  const value = await promptParam(param.name, param);
638
741
  if (value) collected[param.name] = value;
639
742
  }
640
743
  }
744
+ } else {
745
+ const missing = getMissingRequired(opParams, collected);
746
+ if (missing.length > 0 && isInteractive({ interactive: args.interactive })) {
747
+ for (const param of opParams) {
748
+ if (param.required && !(param.name in collected)) {
749
+ const value = await promptParam(param.name, param);
750
+ if (value) collected[param.name] = value;
751
+ }
752
+ }
753
+ }
641
754
  }
642
755
  const stillMissing = getMissingRequired(opParams, collected);
643
756
  if (stillMissing.length > 0) {
@@ -646,8 +759,9 @@ ${BOLD}epilot ${apiName}${RESET} - ${spec.info?.title || apiName}
646
759
  process.exit(1);
647
760
  }
648
761
  const { hasBody, isRequired } = getRequestBodyInfo(spec, operationId);
762
+ const forceBodyPrompt = args.guided && hasBody;
649
763
  let bodyTemplate;
650
- if (hasBody && isInteractive({ interactive: args.interactive })) {
764
+ if (hasBody && (forceBodyPrompt || isInteractive({ interactive: args.interactive }))) {
651
765
  const bodySchema = getBodySchema(spec, operationId);
652
766
  if (bodySchema) {
653
767
  try {
@@ -702,7 +816,9 @@ ${BOLD}epilot ${apiName}${RESET} - ${spec.info?.title || apiName}
702
816
  json: args.json,
703
817
  include: args.include,
704
818
  verbose: args.verbose,
705
- jsonata: args.jsonata
819
+ jsonata: args.jsonata,
820
+ interactive: args.interactive,
821
+ operationId
706
822
  });
707
823
  if (response.status >= 400) {
708
824
  process.exit(1);
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  DIM,
4
4
  RESET
5
- } from "./chunk-6RBLA5YE.js";
5
+ } from "./chunk-7ZQ666ZQ.js";
6
6
 
7
7
  // src/lib/interactive.ts
8
8
  var isInteractive = (flags) => {
@@ -21,9 +21,7 @@ var pickOperation = async (operations) => {
21
21
  source: (input) => {
22
22
  if (!input) return choices;
23
23
  const term = input.toLowerCase();
24
- return choices.filter(
25
- (c) => c.value.toLowerCase().includes(term) || c.name.toLowerCase().includes(term)
26
- );
24
+ return choices.filter((c) => c.value.toLowerCase().includes(term) || c.name.toLowerCase().includes(term));
27
25
  },
28
26
  pageSize: 20
29
27
  });
@@ -33,8 +31,9 @@ var promptParam = async (name, param) => {
33
31
  const { input } = await import("@inquirer/prompts");
34
32
  const schema = param.schema;
35
33
  const defaultValue = schema?.default != null ? String(schema.default) : void 0;
34
+ const hint = param.required ? "(required)" : "(optional, press Enter to skip)";
36
35
  const result = await input({
37
- message: `${name}${param.required ? " (required)" : ""}:`,
36
+ message: `${name} ${hint}:`,
38
37
  default: defaultValue,
39
38
  validate: (value) => {
40
39
  if (param.required && !value.trim()) {
@@ -57,15 +56,16 @@ var promptToken = async () => {
57
56
  });
58
57
  return token || null;
59
58
  };
60
- var printOperationsTable = (apiName, operations) => {
59
+ var formatOperationsTable = (apiName, operations) => {
60
+ const lines = [];
61
61
  for (const op of operations) {
62
62
  const desc = op.description ? ` \u2013 ${op.description}` : "";
63
- process.stdout.write(` ${op.operationId} ${DIM}${op.method.toUpperCase()} ${op.path}${desc}${RESET}
64
- `);
63
+ lines.push(` ${op.operationId} ${DIM}${op.method.toUpperCase()} ${op.path}${desc}${RESET}`);
65
64
  }
66
- process.stdout.write(`
65
+ lines.push(`
67
66
  Run \`epilot ${apiName} <operationId> --help\` for details.
68
67
  `);
68
+ return lines.join("\n");
69
69
  };
70
70
 
71
71
  export {
@@ -73,5 +73,5 @@ export {
73
73
  pickOperation,
74
74
  promptParam,
75
75
  promptToken,
76
- printOperationsTable
76
+ formatOperationsTable
77
77
  };
@@ -8,7 +8,7 @@ import {
8
8
  RED,
9
9
  RESET,
10
10
  YELLOW
11
- } from "./chunk-6RBLA5YE.js";
11
+ } from "./chunk-7ZQ666ZQ.js";
12
12
 
13
13
  // src/commands/completion.ts
14
14
  import { defineCommand } from "citty";
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-BJOXXFMA.js";
4
+ } from "./chunk-HWUVFZIB.js";
5
5
  import "./chunk-RSA7K5HB.js";
6
6
  import "./chunk-PDMWUCWD.js";
7
- import "./chunk-HN4QDJOJ.js";
8
- import "./chunk-6RBLA5YE.js";
7
+ import "./chunk-IOLKUHUB.js";
8
+ import "./chunk-7ZQ666ZQ.js";
9
9
 
10
10
  // src/commands/apis/consent.ts
11
11
  import { defineCommand } from "citty";
@@ -23,9 +23,11 @@ var consent_default = defineCommand({
23
23
  token: { type: "string", alias: "t", description: "Bearer token" },
24
24
  json: { type: "boolean", description: "Output raw JSON" },
25
25
  verbose: { type: "boolean", alias: "v", description: "Verbose output" },
26
+ guided: { type: "boolean", description: "Prompt for all parameters interactively" },
26
27
  interactive: { type: "boolean", description: "Interactive mode" },
27
28
  jsonata: { type: "string", description: "JSONata expression to transform response" },
28
- _ophelp: { type: "boolean", description: "Show operation help", required: false }
29
+ _ophelp: { type: "boolean", description: "Show operation help", required: false },
30
+ _apihelp: { type: "boolean", description: "Show API help", required: false }
29
31
  },
30
32
  run: ({ args, rawArgs }) => {
31
33
  const positionalArgs = [];
@@ -42,6 +44,7 @@ var consent_default = defineCommand({
42
44
  return callApi("consent", {
43
45
  ...args,
44
46
  help: !!args._ophelp,
47
+ _apihelp: !!args._apihelp,
45
48
  _args: positionalArgs
46
49
  });
47
50
  }
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-BJOXXFMA.js";
4
+ } from "./chunk-HWUVFZIB.js";
5
5
  import "./chunk-RSA7K5HB.js";
6
6
  import "./chunk-PDMWUCWD.js";
7
- import "./chunk-HN4QDJOJ.js";
8
- import "./chunk-6RBLA5YE.js";
7
+ import "./chunk-IOLKUHUB.js";
8
+ import "./chunk-7ZQ666ZQ.js";
9
9
 
10
10
  // src/commands/apis/customer-portal.ts
11
11
  import { defineCommand } from "citty";
@@ -23,9 +23,11 @@ var customer_portal_default = defineCommand({
23
23
  token: { type: "string", alias: "t", description: "Bearer token" },
24
24
  json: { type: "boolean", description: "Output raw JSON" },
25
25
  verbose: { type: "boolean", alias: "v", description: "Verbose output" },
26
+ guided: { type: "boolean", description: "Prompt for all parameters interactively" },
26
27
  interactive: { type: "boolean", description: "Interactive mode" },
27
28
  jsonata: { type: "string", description: "JSONata expression to transform response" },
28
- _ophelp: { type: "boolean", description: "Show operation help", required: false }
29
+ _ophelp: { type: "boolean", description: "Show operation help", required: false },
30
+ _apihelp: { type: "boolean", description: "Show API help", required: false }
29
31
  },
30
32
  run: ({ args, rawArgs }) => {
31
33
  const positionalArgs = [];
@@ -42,6 +44,7 @@ var customer_portal_default = defineCommand({
42
44
  return callApi("customer-portal", {
43
45
  ...args,
44
46
  help: !!args._ophelp,
47
+ _apihelp: !!args._apihelp,
45
48
  _args: positionalArgs
46
49
  });
47
50
  }
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-BJOXXFMA.js";
4
+ } from "./chunk-HWUVFZIB.js";
5
5
  import "./chunk-RSA7K5HB.js";
6
6
  import "./chunk-PDMWUCWD.js";
7
- import "./chunk-HN4QDJOJ.js";
8
- import "./chunk-6RBLA5YE.js";
7
+ import "./chunk-IOLKUHUB.js";
8
+ import "./chunk-7ZQ666ZQ.js";
9
9
 
10
10
  // src/commands/apis/dashboard.ts
11
11
  import { defineCommand } from "citty";
@@ -23,9 +23,11 @@ var dashboard_default = defineCommand({
23
23
  token: { type: "string", alias: "t", description: "Bearer token" },
24
24
  json: { type: "boolean", description: "Output raw JSON" },
25
25
  verbose: { type: "boolean", alias: "v", description: "Verbose output" },
26
+ guided: { type: "boolean", description: "Prompt for all parameters interactively" },
26
27
  interactive: { type: "boolean", description: "Interactive mode" },
27
28
  jsonata: { type: "string", description: "JSONata expression to transform response" },
28
- _ophelp: { type: "boolean", description: "Show operation help", required: false }
29
+ _ophelp: { type: "boolean", description: "Show operation help", required: false },
30
+ _apihelp: { type: "boolean", description: "Show API help", required: false }
29
31
  },
30
32
  run: ({ args, rawArgs }) => {
31
33
  const positionalArgs = [];
@@ -42,6 +44,7 @@ var dashboard_default = defineCommand({
42
44
  return callApi("dashboard", {
43
45
  ...args,
44
46
  help: !!args._ophelp,
47
+ _apihelp: !!args._apihelp,
45
48
  _args: positionalArgs
46
49
  });
47
50
  }
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  callApi
4
- } from "./chunk-BJOXXFMA.js";
4
+ } from "./chunk-HWUVFZIB.js";
5
5
  import "./chunk-RSA7K5HB.js";
6
6
  import "./chunk-PDMWUCWD.js";
7
- import "./chunk-HN4QDJOJ.js";
8
- import "./chunk-6RBLA5YE.js";
7
+ import "./chunk-IOLKUHUB.js";
8
+ import "./chunk-7ZQ666ZQ.js";
9
9
 
10
10
  // src/commands/apis/data-management.ts
11
11
  import { defineCommand } from "citty";
@@ -23,9 +23,11 @@ var data_management_default = defineCommand({
23
23
  token: { type: "string", alias: "t", description: "Bearer token" },
24
24
  json: { type: "boolean", description: "Output raw JSON" },
25
25
  verbose: { type: "boolean", alias: "v", description: "Verbose output" },
26
+ guided: { type: "boolean", description: "Prompt for all parameters interactively" },
26
27
  interactive: { type: "boolean", description: "Interactive mode" },
27
28
  jsonata: { type: "string", description: "JSONata expression to transform response" },
28
- _ophelp: { type: "boolean", description: "Show operation help", required: false }
29
+ _ophelp: { type: "boolean", description: "Show operation help", required: false },
30
+ _apihelp: { type: "boolean", description: "Show API help", required: false }
29
31
  },
30
32
  run: ({ args, rawArgs }) => {
31
33
  const positionalArgs = [];
@@ -42,6 +44,7 @@ var data_management_default = defineCommand({
42
44
  return callApi("data-management", {
43
45
  ...args,
44
46
  help: !!args._ophelp,
47
+ _apihelp: !!args._apihelp,
45
48
  _args: positionalArgs
46
49
  });
47
50
  }