@scalar/cli 2.5.2 → 2.8.0

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 (79) hide show
  1. package/README.md +319 -55
  2. package/chunks/{action-XUQ7TKKJ.js → action-354TUG4H.js} +11 -7
  3. package/chunks/{action-PHLOE27S.js → action-43YBNBDR.js} +33 -26
  4. package/chunks/{action-DGD6Q6Y5.js → action-5SK5NE7E.js} +10 -4
  5. package/chunks/{action-Y6CEKYEK.js → action-6BYGBXRC.js} +40 -23
  6. package/chunks/{action-LUVBQEIQ.js → action-7PEQXDWT.js} +4 -4
  7. package/chunks/action-AQRPFQKI.js +231 -0
  8. package/chunks/{action-RBVPKCRI.js → action-CA4QYPI6.js} +6 -6
  9. package/chunks/{action-7H3XARJP.js → action-EOAVVL52.js} +11 -5
  10. package/chunks/action-F2ZJNURT.js +72 -0
  11. package/chunks/{action-AMNYOA4B.js → action-F7A2K74G.js} +4 -4
  12. package/chunks/{action-HIL5ZFNB.js → action-FCAYFPVR.js} +5 -5
  13. package/chunks/{action-42D2C47G.js → action-GWXLHL2Z.js} +3 -3
  14. package/chunks/{action-ZWQLQENM.js → action-H6OUJWWM.js} +4 -4
  15. package/chunks/{action-TWHLZW4V.js → action-HT2DJ34Z.js} +49 -26
  16. package/chunks/{action-PAA4NWUJ.js → action-JAHFRYWZ.js} +58 -9
  17. package/chunks/{action-HXHBU7XC.js → action-KTYOCA2V.js} +37 -12
  18. package/chunks/{action-LFL3ZZKN.js → action-LEUD5P2U.js} +17 -17
  19. package/chunks/{action-FF2OMGAS.js → action-LLH4QPXM.js} +34 -20
  20. package/chunks/{action-OILGZAMK.js → action-LXGXKXZZ.js} +20 -15
  21. package/chunks/{action-W62AIEBN.js → action-NVI5DWFP.js} +6 -6
  22. package/chunks/{action-EPNE5XCM.js → action-QQZLPI42.js} +17 -17
  23. package/chunks/{action-ZLTUMRO2.js → action-UIKH4SZX.js} +25 -21
  24. package/chunks/{action-6FAJNP6C.js → action-VOFDW3U2.js} +4 -4
  25. package/chunks/{action-OK55BFGM.js → action-W3C53GPH.js} +7 -7
  26. package/chunks/{action-P7RFXIC7.js → action-WFDNRA7D.js} +32 -23
  27. package/chunks/{action-V5KYG7XD.js → action-XIUO64C7.js} +10 -10
  28. package/chunks/{action-X7TZA3RE.js → action-Y6NXJQ4H.js} +89 -14
  29. package/chunks/{action-6MZZHPVQ.js → action-Y7OUGD56.js} +27 -14
  30. package/chunks/{action-DCINFQ57.js → action-YLF2G4G5.js} +13 -13
  31. package/chunks/{action-SJYAMXYI.js → action-YRX6SN5F.js} +10 -4
  32. package/chunks/actions-OGIVBQC7.js +158 -0
  33. package/chunks/{agent-JAXLLDPE.js → agent-ASPV3R5U.js} +4 -4
  34. package/chunks/{asyncapi-P6Y3L7RG.js → asyncapi-QNFKXHEI.js} +10 -11
  35. package/chunks/{build.action-AZ5ECU4B.js → build.action-NM6CAE5F.js} +37 -33
  36. package/chunks/{chunk-FOKFF4EP.js → chunk-22HYZ7LE.js} +3 -3
  37. package/chunks/{chunk-KEOCJ3NJ.js → chunk-2OCWX42S.js} +38 -87
  38. package/chunks/{chunk-RPVHJMQT.js → chunk-5DEU2DVL.js} +2 -2
  39. package/chunks/{chunk-OQKDBLOZ.js → chunk-5JLVQVKO.js} +8 -0
  40. package/chunks/{chunk-VNYE4R7N.js → chunk-5UHLAJQD.js} +2 -1
  41. package/chunks/{chunk-CX7ZRMTC.js → chunk-6XWCMJDB.js} +1 -1
  42. package/chunks/{chunk-6ZMT63IV.js → chunk-6YPQGVF4.js} +1 -1
  43. package/chunks/{chunk-HXIDUCSZ.js → chunk-BPGFSSUH.js} +1 -1
  44. package/chunks/{chunk-M622VXRQ.js → chunk-C2KAWRIX.js} +1 -1
  45. package/chunks/chunk-EGOXR5FB.js +15 -0
  46. package/chunks/{chunk-UB3XGOUW.js → chunk-EXY3ZTV4.js} +262 -9
  47. package/chunks/{chunk-3BWGTPPT.js → chunk-FDC2IESH.js} +1776 -1113
  48. package/chunks/{chunk-TYLWJ2UL.js → chunk-GTV2BVXV.js} +2 -2
  49. package/chunks/{chunk-SWWWYWHC.js → chunk-HGOD6THU.js} +27 -18
  50. package/chunks/{chunk-3DJ2GKEG.js → chunk-IMG35UXX.js} +1 -1
  51. package/chunks/{chunk-MNLXYOVF.js → chunk-KCCFN4F7.js} +2 -2
  52. package/chunks/{chunk-FQVVKQPU.js → chunk-KKRGBXCE.js} +137 -1
  53. package/chunks/{chunk-UMPODUJO.js → chunk-L3UXDCBI.js} +105 -15
  54. package/chunks/{chunk-B2MHTD3R.js → chunk-MLSZVVTT.js} +1 -1
  55. package/chunks/{chunk-LCPFHE4Z.js → chunk-OJ2EWIJH.js} +21 -2
  56. package/chunks/{chunk-RAO7VUGM.js → chunk-PH3WFNXJ.js} +1 -1
  57. package/chunks/{chunk-NIXG4KDE.js → chunk-QVQ4PNVL.js} +170 -5
  58. package/chunks/{chunk-CIFOFSZ3.js → chunk-R5LK6VPY.js} +72 -7
  59. package/chunks/{chunk-T7B6WNZC.js → chunk-TSURUX4A.js} +12 -3
  60. package/chunks/{chunk-JV7TUEXQ.js → chunk-UXJ753NV.js} +14 -1
  61. package/chunks/{chunk-HUCR333E.js → chunk-W24BETFG.js} +2 -2
  62. package/chunks/{chunk-LQN4S62O.js → chunk-XEDGMZJD.js} +18 -4
  63. package/chunks/{chunk-NNMSZVAB.js → chunk-XXSQUBXS.js} +82 -6
  64. package/chunks/{chunk-M6Q3ARBV.js → chunk-YILQODZF.js} +2 -2
  65. package/chunks/{create.action-34OTO2SB.js → create.action-FUQ2BVJA.js} +29 -17
  66. package/chunks/{delete.action-ZYXFMIOW.js → delete.action-47E66R3I.js} +26 -17
  67. package/chunks/{delete.action-6LRT4M3S.js → delete.action-BTDFH7WY.js} +26 -17
  68. package/chunks/{get.action-XP36SA2J.js → get.action-XC7KC2JO.js} +10 -10
  69. package/chunks/{list.action-6LF6KSD5.js → list.action-LXKEUYKO.js} +13 -13
  70. package/chunks/{list.action-WVRVLX5E.js → list.action-OFGLMRE7.js} +17 -17
  71. package/chunks/{publish.action-AHFUBT5C.js → publish.action-OS27XOX4.js} +50 -24
  72. package/chunks/{update.action-YQTVUDYE.js → update.action-AEIBLCWD.js} +27 -18
  73. package/chunks/{update.action-ZREAFJVG.js → update.action-ZMS4CQ3T.js} +27 -18
  74. package/docs.html +679 -175
  75. package/index.js +492 -406
  76. package/package.json +14 -22
  77. package/skills/scalar-cli/SKILL.md +77 -0
  78. package/template.md +101 -3
  79. package/chunks/action-YRWHX2AE.js +0 -64
@@ -1,47 +1,47 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getPublishDeploymentUrl
4
- } from "./chunk-3DJ2GKEG.js";
4
+ } from "./chunk-IMG35UXX.js";
5
+ import {
6
+ resolveProject
7
+ } from "./chunk-TSURUX4A.js";
5
8
  import {
6
9
  readAndParseConfig,
7
10
  renderConfigError
8
- } from "./chunk-HUCR333E.js";
11
+ } from "./chunk-W24BETFG.js";
9
12
  import {
10
13
  DEFAULT_ASSETS_DIR
11
- } from "./chunk-NNMSZVAB.js";
14
+ } from "./chunk-XXSQUBXS.js";
15
+ import "./chunk-YILQODZF.js";
12
16
  import {
13
- resolveProject
14
- } from "./chunk-T7B6WNZC.js";
15
- import "./chunk-M6Q3ARBV.js";
17
+ getDatabaseClient
18
+ } from "./chunk-5DEU2DVL.js";
16
19
  import {
17
20
  apiService
18
- } from "./chunk-UB3XGOUW.js";
19
- import {
20
- getDatabaseClient
21
- } from "./chunk-RPVHJMQT.js";
22
- import "./chunk-FQVVKQPU.js";
23
- import "./chunk-B2MHTD3R.js";
24
- import "./chunk-3BWGTPPT.js";
25
- import "./chunk-M622VXRQ.js";
26
- import "./chunk-CIFOFSZ3.js";
21
+ } from "./chunk-EXY3ZTV4.js";
22
+ import "./chunk-KKRGBXCE.js";
23
+ import "./chunk-MLSZVVTT.js";
24
+ import "./chunk-FDC2IESH.js";
25
+ import "./chunk-C2KAWRIX.js";
26
+ import "./chunk-R5LK6VPY.js";
27
27
  import {
28
28
  getAuthData
29
- } from "./chunk-NIXG4KDE.js";
30
- import "./chunk-JV7TUEXQ.js";
31
- import "./chunk-VNYE4R7N.js";
29
+ } from "./chunk-QVQ4PNVL.js";
30
+ import "./chunk-UXJ753NV.js";
31
+ import "./chunk-5UHLAJQD.js";
32
32
  import {
33
33
  ConfigVersion,
34
34
  isGithubBackedDocsProject,
35
35
  publishRecordSchema
36
- } from "./chunk-OQKDBLOZ.js";
36
+ } from "./chunk-5JLVQVKO.js";
37
37
  import "./chunk-K74E42RV.js";
38
- import "./chunk-MNLXYOVF.js";
39
- import "./chunk-CX7ZRMTC.js";
38
+ import "./chunk-KCCFN4F7.js";
39
+ import "./chunk-6XWCMJDB.js";
40
40
  import "./chunk-4ORL4MST.js";
41
41
  import {
42
42
  output
43
43
  } from "./chunk-T5HJUAWB.js";
44
- import "./chunk-LQN4S62O.js";
44
+ import "./chunk-XEDGMZJD.js";
45
45
  import {
46
46
  slugSchema,
47
47
  zod_default
@@ -131,7 +131,8 @@ var FILE_BEARING_CONFIG_KEYS = /* @__PURE__ */ new Set([
131
131
  "logo",
132
132
  "icon",
133
133
  "backgroundImage",
134
- "assetsDir"
134
+ "assetsDir",
135
+ "imageTemplate"
135
136
  ]);
136
137
  function collectConfigReferences(config) {
137
138
  const references = [];
@@ -222,6 +223,11 @@ function collectConfigReferences(config) {
222
223
  case "assetsDir":
223
224
  add(value, key);
224
225
  break;
226
+ // A site's own social card template, which the build compiles and runs
227
+ // for every page. Always a repository path, never a URL.
228
+ case "imageTemplate":
229
+ add(value, key);
230
+ break;
225
231
  }
226
232
  }
227
233
  };
@@ -500,8 +506,8 @@ async function waitForPublish({
500
506
  logger.exit("success");
501
507
  return;
502
508
  }
503
- if (deployStatus.data.status === "error") {
504
- logger.exit("error");
509
+ if (deployStatus.data.status === "error" || deployStatus.data.status === "cancelled") {
510
+ return logger.exit("error");
505
511
  }
506
512
  await sleep(3e3);
507
513
  }
@@ -518,5 +524,6 @@ async function getDeployStatus({
518
524
  });
519
525
  }
520
526
  export {
521
- publishAction
527
+ publishAction,
528
+ waitForPublish
522
529
  };
@@ -7,12 +7,15 @@ import {
7
7
  isAsyncApiDocument,
8
8
  isDocument,
9
9
  safeNormalize
10
- } from "./chunk-SWWWYWHC.js";
10
+ } from "./chunk-HGOD6THU.js";
11
+ import {
12
+ requireInteractive
13
+ } from "./chunk-EGOXR5FB.js";
11
14
  import {
12
15
  require_dist
13
16
  } from "./chunk-K74E42RV.js";
14
- import "./chunk-MNLXYOVF.js";
15
- import "./chunk-CX7ZRMTC.js";
17
+ import "./chunk-KCCFN4F7.js";
18
+ import "./chunk-6XWCMJDB.js";
16
19
  import {
17
20
  isUrl,
18
21
  isYamlFileName
@@ -20,7 +23,7 @@ import {
20
23
  import {
21
24
  output
22
25
  } from "./chunk-T5HJUAWB.js";
23
- import "./chunk-LQN4S62O.js";
26
+ import "./chunk-XEDGMZJD.js";
24
27
  import "./chunk-IKT5F47M.js";
25
28
  import {
26
29
  __toESM
@@ -44,6 +47,9 @@ async function upgradeAction(input, { output: outputFilePath }) {
44
47
  "Please provide an output file using the -o flag when upgrading from a URL."
45
48
  ).exit("error");
46
49
  }
50
+ requireInteractive(
51
+ "Pass --output to upgrade a document in non-interactive mode."
52
+ );
47
53
  const shouldContinue = await confirm({
48
54
  message: "No output file specified - this will overwrite the input file. Continue?",
49
55
  initialValue: false
@@ -2,52 +2,55 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  dashboardUrl,
4
4
  registryUrl
5
- } from "./chunk-TYLWJ2UL.js";
5
+ } from "./chunk-GTV2BVXV.js";
6
6
  import {
7
7
  registry
8
- } from "./chunk-M6Q3ARBV.js";
8
+ } from "./chunk-YILQODZF.js";
9
9
  import {
10
10
  getFileOrUrl,
11
11
  isDocument,
12
12
  safeNormalize
13
- } from "./chunk-SWWWYWHC.js";
13
+ } from "./chunk-HGOD6THU.js";
14
14
  import {
15
15
  DEFAULT_FETCH_CONCURRENCY
16
- } from "./chunk-LCPFHE4Z.js";
17
- import {
18
- apiService
19
- } from "./chunk-UB3XGOUW.js";
16
+ } from "./chunk-OJ2EWIJH.js";
20
17
  import {
21
18
  BaseCollections
22
- } from "./chunk-KEOCJ3NJ.js";
19
+ } from "./chunk-2OCWX42S.js";
23
20
  import {
24
21
  getDatabaseClient
25
- } from "./chunk-RPVHJMQT.js";
26
- import "./chunk-FQVVKQPU.js";
27
- import "./chunk-B2MHTD3R.js";
28
- import "./chunk-3BWGTPPT.js";
29
- import "./chunk-M622VXRQ.js";
30
- import "./chunk-CIFOFSZ3.js";
22
+ } from "./chunk-5DEU2DVL.js";
23
+ import {
24
+ apiService
25
+ } from "./chunk-EXY3ZTV4.js";
26
+ import "./chunk-KKRGBXCE.js";
27
+ import "./chunk-MLSZVVTT.js";
28
+ import "./chunk-FDC2IESH.js";
29
+ import "./chunk-C2KAWRIX.js";
30
+ import "./chunk-R5LK6VPY.js";
31
31
  import {
32
32
  getAuthData
33
- } from "./chunk-NIXG4KDE.js";
34
- import "./chunk-JV7TUEXQ.js";
33
+ } from "./chunk-QVQ4PNVL.js";
34
+ import "./chunk-UXJ753NV.js";
35
35
  import {
36
36
  teamSchema
37
- } from "./chunk-VNYE4R7N.js";
38
- import "./chunk-OQKDBLOZ.js";
37
+ } from "./chunk-5UHLAJQD.js";
38
+ import "./chunk-5JLVQVKO.js";
39
+ import {
40
+ requireInteractive
41
+ } from "./chunk-EGOXR5FB.js";
39
42
  import "./chunk-K74E42RV.js";
40
43
  import {
41
44
  RegistryAsset
42
- } from "./chunk-MNLXYOVF.js";
43
- import "./chunk-CX7ZRMTC.js";
45
+ } from "./chunk-KCCFN4F7.js";
46
+ import "./chunk-6XWCMJDB.js";
44
47
  import {
45
48
  isUrl
46
49
  } from "./chunk-4ORL4MST.js";
47
50
  import {
48
51
  output
49
52
  } from "./chunk-T5HJUAWB.js";
50
- import "./chunk-LQN4S62O.js";
53
+ import "./chunk-XEDGMZJD.js";
51
54
  import {
52
55
  docVersionSchema,
53
56
  external_exports,
@@ -58,6 +61,7 @@ import {
58
61
  import "./chunk-3MZYUBJ6.js";
59
62
 
60
63
  // src/domains/registry/publish/action.ts
64
+ import path from "node:path";
61
65
  import { text } from "@clack/prompts";
62
66
  import as from "ansis";
63
67
  import { bundle } from "@scalar/json-magic/bundle";
@@ -72,7 +76,7 @@ async function publishAction(file, args) {
72
76
  current: external_exports.coerce.boolean(),
73
77
  force: external_exports.coerce.boolean(),
74
78
  bundle: external_exports.coerce.boolean().optional(),
75
- fetchLimit: external_exports.coerce.number().optional(),
79
+ fetchLimit: external_exports.coerce.number().int().positive().optional(),
76
80
  urlMap: external_exports.coerce.boolean().default(false),
77
81
  treeShake: external_exports.coerce.boolean().default(false)
78
82
  }).safeParse({
@@ -82,7 +86,11 @@ async function publishAction(file, args) {
82
86
  version: args.version,
83
87
  private: args.private,
84
88
  current: args.current,
85
- force: args.force
89
+ force: args.force,
90
+ bundle: args.bundle,
91
+ treeShake: args.treeShake,
92
+ urlMap: args.urlMap,
93
+ fetchLimit: args.fetchLimit
86
94
  });
87
95
  if (error)
88
96
  return output.error().title("Invalid input").message(error.issues[0].message).exit("error");
@@ -108,6 +116,9 @@ async function publishAction(file, args) {
108
116
  const namespaceApisRes = await client.managedDocs.getApiDocs(namespace);
109
117
  if (namespaceApisRes.error)
110
118
  return output.error().title(namespaceApisRes.message).exit("error");
119
+ if (!data.file) {
120
+ requireInteractive("Please provide a file path or URL.");
121
+ }
111
122
  const apiFile = data.file || (await text({
112
123
  message: "Please enter a file path or URL for your document",
113
124
  placeholder: "./api.yaml",
@@ -131,6 +142,7 @@ async function publishAction(file, args) {
131
142
  );
132
143
  }
133
144
  const bundledDocument = await bundle(parsed, {
145
+ origin: isUrl(apiFile) ? apiFile : path.resolve(apiFile),
134
146
  plugins: bundlingPlugins,
135
147
  treeShake: data.treeShake,
136
148
  urlMap: data.urlMap
@@ -140,6 +152,11 @@ async function publishAction(file, args) {
140
152
  const parsedVersion = docVersionSchema.safeParse(
141
153
  data.version || specification.info?.version
142
154
  );
155
+ if (!parsedVersion.data) {
156
+ requireInteractive(
157
+ "Please provide --version or a document with a valid info.version."
158
+ );
159
+ }
143
160
  const version = parsedVersion.data || (await text({
144
161
  message: "What is the version of your document (e.g. 0.1.0)?",
145
162
  validate(value) {
@@ -6,19 +6,19 @@ import {
6
6
  isAsyncApiDocument,
7
7
  isDocument,
8
8
  safeNormalize
9
- } from "./chunk-SWWWYWHC.js";
9
+ } from "./chunk-HGOD6THU.js";
10
10
  import {
11
11
  require_dist
12
12
  } from "./chunk-K74E42RV.js";
13
- import "./chunk-MNLXYOVF.js";
14
- import "./chunk-CX7ZRMTC.js";
13
+ import "./chunk-KCCFN4F7.js";
14
+ import "./chunk-6XWCMJDB.js";
15
15
  import {
16
16
  isYamlFileName
17
17
  } from "./chunk-4ORL4MST.js";
18
18
  import {
19
19
  output
20
20
  } from "./chunk-T5HJUAWB.js";
21
- import "./chunk-LQN4S62O.js";
21
+ import "./chunk-XEDGMZJD.js";
22
22
  import {
23
23
  external_exports
24
24
  } from "./chunk-IKT5F47M.js";
@@ -0,0 +1,231 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ isAsyncApiDocument,
4
+ isDocument
5
+ } from "./chunk-HGOD6THU.js";
6
+ import {
7
+ err,
8
+ ok
9
+ } from "./chunk-C2KAWRIX.js";
10
+ import "./chunk-KCCFN4F7.js";
11
+ import "./chunk-6XWCMJDB.js";
12
+ import {
13
+ isUrl
14
+ } from "./chunk-4ORL4MST.js";
15
+ import {
16
+ output
17
+ } from "./chunk-T5HJUAWB.js";
18
+ import "./chunk-XEDGMZJD.js";
19
+ import "./chunk-IKT5F47M.js";
20
+ import "./chunk-3MZYUBJ6.js";
21
+
22
+ // src/domains/document/validate/action.ts
23
+ import path from "node:path";
24
+ import as from "ansis";
25
+ import prettyjson from "prettyjson";
26
+ import { validate as validateAsyncApi } from "@scalar/asyncapi-validator";
27
+ import { bundle } from "@scalar/json-magic/bundle";
28
+ import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
29
+ import { validate as validateOpenApi } from "@scalar/openapi-validator";
30
+
31
+ // src/domains/document/validate/resolve-for-validation.ts
32
+ import { createMagicProxy, getRaw } from "@scalar/json-magic/magic-proxy";
33
+ var childContext = (context, key, swagger) => {
34
+ if (context === "data") return "data";
35
+ if (context === "path-items") return "path-item";
36
+ if (context === "callbacks") return "callback";
37
+ if (context === "callback") return key.startsWith("x-") ? "data" : "path-item";
38
+ if (context === "schemas") return "schema";
39
+ if (context === "objects") return "object";
40
+ if (context === "responses") return "response";
41
+ if (context === "links") return "link";
42
+ if (context === "schema") {
43
+ if ([
44
+ "properties",
45
+ "patternProperties",
46
+ "dependentSchemas",
47
+ "$defs",
48
+ "definitions"
49
+ ].includes(key))
50
+ return "schemas";
51
+ if ([
52
+ "items",
53
+ "additionalProperties",
54
+ "unevaluatedProperties",
55
+ "unevaluatedItems",
56
+ "contains",
57
+ "contentSchema",
58
+ "propertyNames",
59
+ "not",
60
+ "if",
61
+ "then",
62
+ "else",
63
+ "allOf",
64
+ "anyOf",
65
+ "oneOf",
66
+ "prefixItems"
67
+ ].includes(key))
68
+ return "schema";
69
+ return "data";
70
+ }
71
+ if (context === "link" && ["parameters", "requestBody"].includes(key))
72
+ return "data";
73
+ if (context === "response" && swagger && key === "examples") return "data";
74
+ if (["paths", "webhooks", "pathItems"].includes(key)) return "path-items";
75
+ if (key === "callbacks") return "callbacks";
76
+ if (key === "responses") return "responses";
77
+ if (key === "links") return "links";
78
+ if (key.startsWith("x-")) return "data";
79
+ if (["example", "default", "enum", "const", "value"].includes(key))
80
+ return "data";
81
+ if (key === "examples") return "objects";
82
+ if (["schemas", "definitions", "$defs"].includes(key)) return "schemas";
83
+ if (key === "schema") return "schema";
84
+ if ([
85
+ "content",
86
+ "parameters",
87
+ "headers",
88
+ "requestBodies",
89
+ "securitySchemes",
90
+ "channels",
91
+ "messages",
92
+ "operations"
93
+ ].includes(key))
94
+ return "objects";
95
+ return "object";
96
+ };
97
+ var resolveForValidation = (document) => {
98
+ const errors = /* @__PURE__ */ new Set();
99
+ const schemaSiblingsApply = typeof document.openapi === "string" && /^3\.[1-9]/.test(document.openapi);
100
+ const cache = /* @__PURE__ */ new WeakMap();
101
+ const visit = (value, ancestors, context, referenceAncestors = /* @__PURE__ */ new Set()) => {
102
+ if (context === "data") return getRaw(value);
103
+ if (value === null || typeof value !== "object") {
104
+ return value;
105
+ }
106
+ const raw = getRaw(value);
107
+ if (ancestors.has(raw)) {
108
+ if (referenceAncestors.has(raw) && "$ref" in value) {
109
+ errors.add(`Circular reference has no concrete target: ${value.$ref}`);
110
+ }
111
+ return {};
112
+ }
113
+ const cached = cache.get(raw);
114
+ if (cached?.has(context)) return cached.get(context);
115
+ const remember = (result2) => {
116
+ const contexts = cache.get(raw) ?? /* @__PURE__ */ new Map();
117
+ contexts.set(context, result2);
118
+ cache.set(raw, contexts);
119
+ return result2;
120
+ };
121
+ const next = new Set(ancestors).add(raw);
122
+ if (Array.isArray(value)) {
123
+ return remember(
124
+ value.map(
125
+ (entry) => visit(
126
+ entry,
127
+ next,
128
+ context === "objects" ? "object" : context === "schemas" ? "schema" : context
129
+ )
130
+ )
131
+ );
132
+ }
133
+ const node = value;
134
+ const siblings = Object.fromEntries(
135
+ Object.entries(node).filter(
136
+ ([key]) => (typeof node.$ref !== "string" || context === "path-item" || context === "schema" && schemaSiblingsApply) && key !== "$ref-value" && (key !== "$ref" || typeof node.$ref !== "string")
137
+ ).map(([key, entry]) => [
138
+ key,
139
+ visit(
140
+ entry,
141
+ next,
142
+ childContext(context, key, document.swagger === "2.0")
143
+ )
144
+ ])
145
+ );
146
+ if (typeof node.$ref !== "string") {
147
+ return remember(siblings);
148
+ }
149
+ const target = node["$ref-value"];
150
+ if (target === void 0) {
151
+ errors.add(`Could not resolve reference: ${node.$ref}`);
152
+ return remember(siblings);
153
+ }
154
+ const resolved = visit(
155
+ target,
156
+ next,
157
+ context,
158
+ new Set(referenceAncestors).add(raw)
159
+ );
160
+ if (context === "schema" && schemaSiblingsApply) {
161
+ return remember({ allOf: [siblings, resolved] });
162
+ }
163
+ if (context === "path-item" && resolved !== null && typeof resolved === "object" && !Array.isArray(resolved)) {
164
+ return remember({ ...resolved, ...siblings });
165
+ }
166
+ return remember(resolved);
167
+ };
168
+ const result = visit(createMagicProxy(document), /* @__PURE__ */ new Set(), "object");
169
+ if (errors.size) return err([...errors].join("\n"));
170
+ if (!result || typeof result !== "object" || Array.isArray(result)) {
171
+ return err("The resolved document must be an object.");
172
+ }
173
+ return ok(result);
174
+ };
175
+
176
+ // src/domains/document/validate/action.ts
177
+ async function validateAction(inputArgument) {
178
+ const startTime = performance.now();
179
+ if (!inputArgument) {
180
+ return output.error().title("Invalid argument").message("Please provide a file path").exit("error");
181
+ }
182
+ const document = await bundle(
183
+ isUrl(inputArgument) ? inputArgument : path.resolve(inputArgument),
184
+ {
185
+ plugins: [readFiles(), fetchUrls()],
186
+ treeShake: false
187
+ }
188
+ ).catch((error) => {
189
+ return output.error().title("Invalid input").message(error instanceof Error ? error.message : String(error)).exit("error");
190
+ });
191
+ if (!isDocument(document)) {
192
+ return output.error().title("Invalid input").message("Please provide a valid JSON or YAML document.").exit("error");
193
+ }
194
+ const resolved = resolveForValidation(document);
195
+ if (!resolved.ok) {
196
+ return output.error().title("Invalid reference").message(resolved.error).exit("error");
197
+ }
198
+ const isAsyncApi = isAsyncApiDocument(document);
199
+ const specification = isAsyncApi ? "AsyncAPI" : "OpenAPI";
200
+ const initialResult = isAsyncApi ? validateAsyncApi(document) : validateOpenApi(document);
201
+ const result = isAsyncApi || !initialResult.valid ? initialResult : validateOpenApi(resolved.data, { checkPathParameters: true });
202
+ if (result.valid && result.version) {
203
+ const endTime = performance.now();
204
+ output.info().line(
205
+ as.green(
206
+ `Matches the ${specification} specification${as.white(` (${specification} ${as.bold(result.version)})`)}
207
+ `
208
+ )
209
+ ).line(
210
+ `${as.green("File validated")} ${as.grey(
211
+ `in ${as.white(`${as.bold(`${Math.round(endTime - startTime)}`)} ms`)}
212
+ `
213
+ )}`
214
+ ).print();
215
+ } else {
216
+ output.error().message(prettyjson.render(result.errors)).message(
217
+ as.red(
218
+ `File does not match the ${specification} ${result.version ? `${result.version} ` : ""}specification.`
219
+ )
220
+ ).message(
221
+ as.red(
222
+ `${as.bold(
223
+ `${result.errors?.length} error${result.errors && result.errors.length > 1 ? "s" : ""}`
224
+ )} found.`
225
+ )
226
+ ).exit("error");
227
+ }
228
+ }
229
+ export {
230
+ validateAction
231
+ };
@@ -6,22 +6,22 @@ import {
6
6
  import {
7
7
  readAndParseConfig,
8
8
  renderConfigError
9
- } from "./chunk-HUCR333E.js";
9
+ } from "./chunk-W24BETFG.js";
10
10
  import {
11
11
  CONFIG_FILE_DEFAULT,
12
12
  findConfig,
13
13
  legacyTo2_0_0
14
- } from "./chunk-NNMSZVAB.js";
14
+ } from "./chunk-XXSQUBXS.js";
15
15
  import {
16
16
  ConfigVersion
17
- } from "./chunk-OQKDBLOZ.js";
17
+ } from "./chunk-5JLVQVKO.js";
18
18
  import "./chunk-K74E42RV.js";
19
- import "./chunk-MNLXYOVF.js";
20
- import "./chunk-CX7ZRMTC.js";
19
+ import "./chunk-KCCFN4F7.js";
20
+ import "./chunk-6XWCMJDB.js";
21
21
  import {
22
22
  output
23
23
  } from "./chunk-T5HJUAWB.js";
24
- import "./chunk-LQN4S62O.js";
24
+ import "./chunk-XEDGMZJD.js";
25
25
  import "./chunk-IKT5F47M.js";
26
26
  import "./chunk-3MZYUBJ6.js";
27
27
 
@@ -2,15 +2,18 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  measureTime
4
4
  } from "./chunk-KHDYYVYF.js";
5
- import "./chunk-SWWWYWHC.js";
5
+ import "./chunk-HGOD6THU.js";
6
6
  import {
7
7
  DEFAULT_FETCH_CONCURRENCY
8
- } from "./chunk-LCPFHE4Z.js";
8
+ } from "./chunk-OJ2EWIJH.js";
9
+ import {
10
+ requireInteractive
11
+ } from "./chunk-EGOXR5FB.js";
9
12
  import {
10
13
  require_dist
11
14
  } from "./chunk-K74E42RV.js";
12
- import "./chunk-MNLXYOVF.js";
13
- import "./chunk-CX7ZRMTC.js";
15
+ import "./chunk-KCCFN4F7.js";
16
+ import "./chunk-6XWCMJDB.js";
14
17
  import {
15
18
  isUrl,
16
19
  isYamlFileName
@@ -18,7 +21,7 @@ import {
18
21
  import {
19
22
  output
20
23
  } from "./chunk-T5HJUAWB.js";
21
- import "./chunk-LQN4S62O.js";
24
+ import "./chunk-XEDGMZJD.js";
22
25
  import "./chunk-IKT5F47M.js";
23
26
  import {
24
27
  __toESM
@@ -49,6 +52,9 @@ async function bundleAction(input, {
49
52
  "Please provide an output file using the -o flag when bundling from a URL."
50
53
  ).exit("error");
51
54
  }
55
+ requireInteractive(
56
+ "Pass --output to bundle a document in non-interactive mode."
57
+ );
52
58
  const shouldContinue = await confirm({
53
59
  message: "No output file specified - this will overwrite the input file. Continue?",
54
60
  initialValue: false
@@ -0,0 +1,72 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import "./chunk-3MZYUBJ6.js";
3
+
4
+ // src/helpers/documentation/context.ts
5
+ var AGENT_NOTES = [
6
+ "Run `scalar <command>` when the CLI is installed, or `npx @scalar/cli <command>` when it is not.",
7
+ "Run `scalar context` for this command tree as JSON, or `scalar <command> --help` for a single command.",
8
+ "Authenticate with a personal token: `scalar auth login --token <token>`, or set `SCALAR_API_KEY` and run `scalar auth login`. Both store the session on disk for later commands. Without a token, `scalar auth login` opens a browser and waits for a person to sign in, so do not run it that way. Check the session with `scalar auth whoami`.",
9
+ "Many commands prompt when a value is left out, such as a slug, a team, or a confirmation before overwriting a file, and a prompt blocks a non-interactive run. Pass every value as an argument or flag: for example `--output` on `document bundle` and `document upgrade`, `--yes` on `project rollback`, and `--force` on `project init`.",
10
+ "Results go to stdout. Errors go to stderr, prefixed with `[ERROR]`."
11
+ ];
12
+ var EXIT_CODES = {
13
+ "0": "Success",
14
+ "1": "Failure, including invalid arguments or options. The reason is printed to stderr."
15
+ };
16
+ var isHidden = (command) => command._hidden === true;
17
+ var isRunnable = (command) => typeof command._actionHandler === "function";
18
+ var toArgument = (argument) => ({
19
+ name: argument.name(),
20
+ description: argument.description,
21
+ required: argument.required,
22
+ variadic: argument.variadic,
23
+ ...argument.defaultValue !== void 0 && {
24
+ default: argument.defaultValue
25
+ },
26
+ ...argument.argChoices && { choices: argument.argChoices }
27
+ });
28
+ var toOption = (option) => ({
29
+ flags: option.flags,
30
+ description: option.description,
31
+ value: option.required ? "required" : option.optional ? "optional" : "none",
32
+ variadic: option.variadic,
33
+ mandatory: option.mandatory,
34
+ ...option.defaultValue !== void 0 && { default: option.defaultValue },
35
+ ...option.argChoices && { choices: option.argChoices },
36
+ ...option.envVar && { env: option.envVar }
37
+ });
38
+ var visibleOptions = (command) => command.createHelp().visibleOptions(command).map(toOption);
39
+ var toCommand = (command, parentPath) => {
40
+ const path = `${parentPath} ${command.name()}`;
41
+ return {
42
+ name: command.name(),
43
+ command: path,
44
+ usage: `${path} ${command.usage()}`,
45
+ description: command.description(),
46
+ aliases: command.aliases(),
47
+ runnable: isRunnable(command),
48
+ arguments: command.registeredArguments.map(toArgument),
49
+ options: visibleOptions(command),
50
+ commands: command.commands.filter((child) => !isHidden(child)).map((child) => toCommand(child, path))
51
+ };
52
+ };
53
+ var buildCliContext = (program) => ({
54
+ name: program.name(),
55
+ version: program.version() ?? "",
56
+ description: program.description(),
57
+ notes: AGENT_NOTES,
58
+ exitCodes: EXIT_CODES,
59
+ options: visibleOptions(program),
60
+ commands: program.commands.filter((command) => !isHidden(command)).map((command) => toCommand(command, program.name()))
61
+ });
62
+
63
+ // src/domains/context/action.ts
64
+ var rootCommand = (command) => command.parent ? rootCommand(command.parent) : command;
65
+ function contextAction(command) {
66
+ const context = buildCliContext(rootCommand(command));
67
+ process.stdout.write(`${JSON.stringify(context, null, 2)}
68
+ `);
69
+ }
70
+ export {
71
+ contextAction
72
+ };