@scalar/cli 2.1.0 → 2.5.1

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 (88) hide show
  1. package/README.md +28 -24
  2. package/chunks/{action-CYP4VDK3.js → action-37EV4UHW.js} +12 -35
  3. package/chunks/{action-MENXFJH3.js → action-4XI7XJR4.js} +9 -9
  4. package/chunks/{action-H5OHT2GV.js → action-5IU77OII.js} +7 -3
  5. package/chunks/{action-STIEAXOE.js → action-B3KKREWQ.js} +16 -5
  6. package/chunks/{action-BYZUBXVB.js → action-CH24QGTE.js} +8 -4
  7. package/chunks/action-F3UX5E3M.js +522 -0
  8. package/chunks/{action-GB6DM53B.js → action-FDB7NEOK.js} +21 -10
  9. package/chunks/action-FIXBOJEW.js +244 -0
  10. package/chunks/{action-DFKHSDFV.js → action-G26LSVZ7.js} +7 -3
  11. package/chunks/{action-Q5UJ32D6.js → action-H3RTILLM.js} +1 -1
  12. package/chunks/{action-GEBRPNRT.js → action-HGBBV353.js} +15 -16
  13. package/chunks/{action-5R5FDF6S.js → action-IUE4IOWO.js} +67 -22
  14. package/chunks/{action-TPBKPHNS.js → action-JZLZ7ZAD.js} +22 -22
  15. package/chunks/action-LA6KVAXQ.js +374 -0
  16. package/chunks/{action-PVDDRIM6.js → action-M7RQKBSB.js} +65 -26
  17. package/chunks/{action-F4Y6Q2VB.js → action-MSLBC2SO.js} +21 -21
  18. package/chunks/{action-BNEGJBUH.js → action-NVSZT2ZD.js} +8 -9
  19. package/chunks/{action-ANU5HGC4.js → action-OGQSTRMX.js} +17 -14
  20. package/chunks/{action-CLSD7O2R.js → action-PAGJ5PWC.js} +10 -10
  21. package/chunks/action-QE2ZQQX7.js +250 -0
  22. package/chunks/{action-HD2T6BFJ.js → action-QPUSPD5M.js} +10 -10
  23. package/chunks/{action-45OGQB2M.js → action-R7IMFHQ5.js} +17 -8
  24. package/chunks/{action-UDZUUJSI.js → action-SH4UUXPL.js} +18 -7
  25. package/chunks/action-SNLCIBQC.js +84 -0
  26. package/chunks/{action-C5VB4ITT.js → action-SQG3JAII.js} +36 -18
  27. package/chunks/action-UZQJNYK4.js +18 -0
  28. package/chunks/{action-HNKM3Q65.js → action-VC4DCVST.js} +17 -14
  29. package/chunks/{action-BMFXENMX.js → action-VTVFY2MP.js} +39 -34
  30. package/chunks/{action-TZ5KGAQT.js → action-WFWYGY7O.js} +17 -14
  31. package/chunks/{action-W5BATF4Q.js → action-XMNX5ZYT.js} +24 -24
  32. package/chunks/{agent-XGLOHXNA.js → agent-HCQRMHQ5.js} +25 -5
  33. package/chunks/asyncapi-QM76O55R.js +105 -0
  34. package/chunks/{build.action-LKOILPA6.js → build.action-P7FCIMYU.js} +22 -22
  35. package/chunks/{chunk-23I5PKZZ.js → chunk-24WAOKGG.js} +32 -5
  36. package/chunks/chunk-3L6DLIXJ.js +25530 -0
  37. package/chunks/chunk-3ZJYGGAA.js +30 -0
  38. package/chunks/{chunk-ZTVWAKNJ.js → chunk-4NHMAG6F.js} +1 -1
  39. package/chunks/{chunk-IX7LJ3AD.js → chunk-4ORL4MST.js} +2 -3
  40. package/chunks/{chunk-OAXFCOJV.js → chunk-4ZDQXWBT.js} +2 -1
  41. package/chunks/{chunk-ASMHW5AY.js → chunk-6ZMT63IV.js} +1 -1
  42. package/chunks/{chunk-P2VH7DOC.js → chunk-7AGLC7WV.js} +6 -6
  43. package/chunks/{chunk-SXYALPYK.js → chunk-AO3F5XWR.js} +498 -60
  44. package/chunks/{chunk-B6QZJWCQ.js → chunk-B2MHTD3R.js} +4 -6
  45. package/chunks/{chunk-4QS7SJTG.js → chunk-CISTON3A.js} +51 -36
  46. package/chunks/chunk-COBPBRQF.js +25 -0
  47. package/chunks/{chunk-2BSG2QHO.js → chunk-F467BYYR.js} +133 -20
  48. package/chunks/{chunk-TLFMATXR.js → chunk-GSGZHE26.js} +33 -25
  49. package/chunks/{chunk-UPUTMFD4.js → chunk-HCPN3KNF.js} +185 -13
  50. package/chunks/{chunk-P646T2WH.js → chunk-HPL3ZZ2P.js} +131 -13
  51. package/chunks/{chunk-H2WRMLYY.js → chunk-IKT5F47M.js} +3571 -7
  52. package/chunks/{chunk-AHWWJ3MD.js → chunk-K4DTP5TV.js} +1 -1
  53. package/chunks/{chunk-TQ5XC2E3.js → chunk-LFU5ZUAP.js} +77 -11
  54. package/chunks/{chunk-5BISXQX4.js → chunk-M37TP6U2.js} +11 -13
  55. package/chunks/chunk-OQKDBLOZ.js +741 -0
  56. package/chunks/chunk-P7H7GY5A.js +14 -0
  57. package/chunks/{chunk-47Y4L5IT.js → chunk-PBXZN65A.js} +1031 -481
  58. package/chunks/{chunk-HQKBZOYU.js → chunk-PT5TI77I.js} +3 -3
  59. package/chunks/chunk-Q7DOQHZN.js +404 -0
  60. package/chunks/{chunk-X4QLDBB5.js → chunk-T5HJUAWB.js} +24 -3
  61. package/chunks/{chunk-NUXPNUSS.js → chunk-UGGNHILG.js} +1 -1
  62. package/chunks/{chunk-4DGQIAJX.js → chunk-VNYE4R7N.js} +154 -14
  63. package/chunks/{chunk-KWOL7A6J.js → chunk-X5T526CE.js} +2 -2
  64. package/chunks/chunk-XCSR4RIT.js +210 -0
  65. package/chunks/{chunk-SHSHFGA7.js → chunk-Z2KMGFE6.js} +4 -6
  66. package/chunks/{create.action-FFQLBSJH.js → create.action-HDD2WUON.js} +22 -22
  67. package/chunks/{delete.action-STHQHP4F.js → delete.action-7GOZY7ID.js} +22 -22
  68. package/chunks/{delete.action-QNN3LC2F.js → delete.action-VE66JFDS.js} +22 -22
  69. package/chunks/{get.action-OTKYOP3Z.js → get.action-2745EB4N.js} +15 -16
  70. package/chunks/{list.action-KDM5RHEH.js → list.action-3VTXQJRA.js} +19 -19
  71. package/chunks/{list.action-6I5EZAVB.js → list.action-4QDCZLSZ.js} +22 -22
  72. package/chunks/{publish.action-PODTVRXS.js → publish.action-ULQLZKWU.js} +44 -36
  73. package/chunks/{update.action-KMD4ZM75.js → update.action-6QEFP7NA.js} +22 -22
  74. package/chunks/{update.action-4F6STTEQ.js → update.action-OROQSP2S.js} +22 -22
  75. package/docs.html +104 -103
  76. package/index.js +84 -68
  77. package/package.json +16 -12
  78. package/chunks/action-CCW66QJN.js +0 -72
  79. package/chunks/action-CQ56FVES.js +0 -65
  80. package/chunks/action-JOSVV6YA.js +0 -71
  81. package/chunks/action-P7LN6FGY.js +0 -13
  82. package/chunks/action-R6ZZO26F.js +0 -299
  83. package/chunks/action-TWFJNQ2R.js +0 -95
  84. package/chunks/chunk-5BPPGTUU.js +0 -463
  85. package/chunks/chunk-DOVIWNKQ.js +0 -108
  86. package/chunks/chunk-ISGLWBXZ.js +0 -4265
  87. package/chunks/chunk-T7MDADON.js +0 -17
  88. package/chunks/chunk-VTYTPSXO.js +0 -161
@@ -0,0 +1,374 @@
1
+ import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
+ import {
3
+ getFileOrUrl,
4
+ isAsyncApiContent
5
+ } from "./chunk-24WAOKGG.js";
6
+ import {
7
+ err,
8
+ ok
9
+ } from "./chunk-P7H7GY5A.js";
10
+ import {
11
+ require_dist
12
+ } from "./chunk-K74E42RV.js";
13
+ import "./chunk-CISTON3A.js";
14
+ import "./chunk-Q7DOQHZN.js";
15
+ import "./chunk-4ORL4MST.js";
16
+ import {
17
+ output
18
+ } from "./chunk-T5HJUAWB.js";
19
+ import "./chunk-GSGZHE26.js";
20
+ import "./chunk-IKT5F47M.js";
21
+ import {
22
+ __toESM
23
+ } from "./chunk-3MZYUBJ6.js";
24
+
25
+ // src/domains/document/lint/action.ts
26
+ import as from "ansis";
27
+
28
+ // ../../packages/api-document-lint/dist/constants.js
29
+ var DEFAULT_RULESET = `extends: spectral:oas
30
+ rules: {}`;
31
+ var ASYNCAPI_RULESET = `extends: spectral:asyncapi
32
+ rules: {}`;
33
+
34
+ // ../../packages/api-document-lint/dist/default-ruleset.js
35
+ function isAsyncApiContent2(content) {
36
+ const head = content.slice(0, 500);
37
+ if (head.includes('"asyncapi"')) {
38
+ return true;
39
+ }
40
+ return head.split("\n").some((line) => /^asyncapi\s*:/.test(line.trimStart()));
41
+ }
42
+ function defaultRulesetFor(content) {
43
+ return isAsyncApiContent2(content) ? ASYNCAPI_RULESET : DEFAULT_RULESET;
44
+ }
45
+
46
+ // ../../packages/api-document-lint/dist/run-spectral.js
47
+ import spectralCore from "@stoplight/spectral-core";
48
+ import { bundleAndLoadRuleset } from "@stoplight/spectral-ruleset-bundler/with-loader";
49
+ import "@stoplight/spectral-rulesets";
50
+ var { Spectral } = spectralCore;
51
+ async function runSpectral(input) {
52
+ const rulesetSource = input.ruleset && input.ruleset.trim().length > 0 ? input.ruleset : defaultRulesetFor(input.document);
53
+ const ruleset = await loadRuleset(rulesetSource);
54
+ if (!ruleset.ok) {
55
+ return ruleset;
56
+ }
57
+ const spectral = new Spectral();
58
+ spectral.setRuleset(ruleset.data);
59
+ const diagnostics = await spectral.run(input.document).catch((error) => error instanceof Error ? error : new Error(String(error)));
60
+ if (diagnostics instanceof Error) {
61
+ return err(`Spectral failed to lint the document \u2014 ${diagnostics.message}`);
62
+ }
63
+ return ok(diagnostics);
64
+ }
65
+ async function loadRuleset(source) {
66
+ const ruleset = await bundleAndLoadRuleset("/.spectral.yaml", {
67
+ fs: {
68
+ promises: {
69
+ // @ts-expect-error The loader only ever reads our single virtual file.
70
+ async readFile() {
71
+ return source;
72
+ }
73
+ }
74
+ },
75
+ format: "esm"
76
+ }).catch((error) => error instanceof Error ? error : new Error(String(error)));
77
+ if (ruleset instanceof Error) {
78
+ return err(`Failed to load ruleset \u2014 ${ruleset.message}`);
79
+ }
80
+ return ok(ruleset);
81
+ }
82
+
83
+ // ../../packages/api-document-lint/dist/run-vacuum.js
84
+ import { execFile } from "node:child_process";
85
+ import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
86
+ import { tmpdir } from "node:os";
87
+ import { join as join2 } from "node:path";
88
+ import { promisify } from "node:util";
89
+
90
+ // ../../packages/api-document-lint/dist/normalize-diagnostics.js
91
+ var EMPTY_RANGE = {
92
+ start: { line: 0, character: 0 },
93
+ end: { line: 0, character: 0 }
94
+ };
95
+ function normalizeDiagnostics(raw) {
96
+ if (!Array.isArray(raw)) {
97
+ return [];
98
+ }
99
+ return raw.filter(isObject).map((item) => {
100
+ const source = item.source;
101
+ return {
102
+ code: isCode(item.code) ? item.code : "",
103
+ message: typeof item.message === "string" ? item.message : "",
104
+ severity: normalizeSeverity(item.severity),
105
+ path: Array.isArray(item.path) ? item.path.filter(isSegment) : [],
106
+ range: normalizeRange(item.range),
107
+ ...typeof source === "string" ? { source } : {}
108
+ };
109
+ });
110
+ }
111
+ function isObject(value) {
112
+ return typeof value === "object" && value !== null;
113
+ }
114
+ function isCode(value) {
115
+ return typeof value === "string" || typeof value === "number";
116
+ }
117
+ function isSegment(value) {
118
+ return typeof value === "string" || typeof value === "number";
119
+ }
120
+ function normalizeRange(range) {
121
+ if (!isObject(range)) {
122
+ return EMPTY_RANGE;
123
+ }
124
+ return {
125
+ start: normalizePosition(range.start),
126
+ end: normalizePosition(range.end)
127
+ };
128
+ }
129
+ function normalizePosition(position) {
130
+ if (!isObject(position)) {
131
+ return { line: 0, character: 0 };
132
+ }
133
+ return {
134
+ line: toCoordinate(position.line),
135
+ character: toCoordinate(position.character)
136
+ };
137
+ }
138
+ function toCoordinate(value) {
139
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : 0;
140
+ }
141
+ function normalizeSeverity(severity) {
142
+ return severity === 1 || severity === 2 || severity === 3 ? severity : 0;
143
+ }
144
+
145
+ // ../../packages/api-document-lint/dist/resolve-binary.js
146
+ import { statSync } from "node:fs";
147
+ import { createRequire } from "node:module";
148
+ import { dirname, join } from "node:path";
149
+ var binaryName = process.platform === "win32" ? "vacuum.exe" : "vacuum";
150
+ function resolveVacuumBinary(override) {
151
+ const explicit = override ?? process.env.VACUUM_BINARY;
152
+ if (explicit) {
153
+ return isFile(explicit) ? ok(explicit) : err(`vacuum binary not found at ${explicit}`);
154
+ }
155
+ const packaged = resolvePackagedBinary();
156
+ if (packaged) {
157
+ return ok(packaged);
158
+ }
159
+ return ok("vacuum");
160
+ }
161
+ function resolvePackagedBinary() {
162
+ try {
163
+ const require2 = createRequire(import.meta.url);
164
+ const packageJsonPath = require2.resolve("@quobix/vacuum/package.json");
165
+ const candidate = join(dirname(packageJsonPath), "bin", binaryName);
166
+ return isFile(candidate) ? candidate : null;
167
+ } catch {
168
+ return null;
169
+ }
170
+ }
171
+ function isFile(path) {
172
+ try {
173
+ return statSync(path, { throwIfNoEntry: false })?.isFile() ?? false;
174
+ } catch {
175
+ return false;
176
+ }
177
+ }
178
+
179
+ // ../../packages/api-document-lint/dist/run-vacuum.js
180
+ var execFileAsync = promisify(execFile);
181
+ var MAX_BUFFER = 64 * 1024 * 1024;
182
+ var TIMEOUT_MS = 6e4;
183
+ async function runVacuum(input, options = {}) {
184
+ if (input.document.trim().length === 0) {
185
+ return ok([]);
186
+ }
187
+ const binary = resolveVacuumBinary(options.binaryPath);
188
+ if (!binary.ok) {
189
+ return binary;
190
+ }
191
+ const directory = await mkdtemp(join2(tmpdir(), "scalar-lint-")).catch(() => null);
192
+ if (directory === null) {
193
+ return err("vacuum lint failed \u2014 could not create a temporary directory");
194
+ }
195
+ const documentPath = join2(directory, "document.yaml");
196
+ const reportPath = join2(directory, "report.json");
197
+ try {
198
+ const wroteDocument = await writeFile(documentPath, input.document, "utf8").then(() => true).catch(() => false);
199
+ if (!wroteDocument) {
200
+ return err("vacuum lint failed \u2014 could not write the document to a temporary file");
201
+ }
202
+ const args = [
203
+ "spectral-report",
204
+ "--no-style",
205
+ "--no-update-check",
206
+ "--skip-check",
207
+ // Match Spectral's working-directory base for document strings.
208
+ "--base",
209
+ process.cwd()
210
+ ];
211
+ if (input.ruleset && input.ruleset.trim().length > 0) {
212
+ const rulesetPath = join2(directory, "ruleset.yaml");
213
+ const wroteRuleset = await writeFile(rulesetPath, input.ruleset, "utf8").then(() => true).catch(() => false);
214
+ if (!wroteRuleset) {
215
+ return err("vacuum lint failed \u2014 could not write the ruleset to a temporary file");
216
+ }
217
+ args.push("--ruleset", rulesetPath);
218
+ }
219
+ args.push(documentPath, reportPath);
220
+ const failure = await execFileAsync(binary.data, args, {
221
+ maxBuffer: MAX_BUFFER,
222
+ timeout: TIMEOUT_MS
223
+ }).then(() => null).catch((error) => error);
224
+ const report = await readFile(reportPath, "utf8").catch(() => null);
225
+ if (report === null) {
226
+ if (failure === null) {
227
+ return err("vacuum ran but its report could not be read");
228
+ }
229
+ return err(`vacuum failed to lint the document \u2014 ${describeFailure(failure)}`);
230
+ }
231
+ const parsed = parseReport(report);
232
+ if (!parsed.ok) {
233
+ return parsed;
234
+ }
235
+ return ok(normalizeDiagnostics(parsed.data));
236
+ } finally {
237
+ await rm(directory, { recursive: true, force: true }).catch(() => void 0);
238
+ }
239
+ }
240
+ function describeFailure(failure) {
241
+ if (failure && typeof failure === "object") {
242
+ const stderr = failure.stderr;
243
+ if (typeof stderr === "string" && stderr.trim().length > 0) {
244
+ return stderr.trim();
245
+ }
246
+ if (failure instanceof Error) {
247
+ return failure.message;
248
+ }
249
+ }
250
+ return "no report was written";
251
+ }
252
+ function parseReport(report) {
253
+ try {
254
+ const parsed = JSON.parse(report);
255
+ if (!Array.isArray(parsed)) {
256
+ return err("vacuum produced a report in an unexpected shape");
257
+ }
258
+ return ok(parsed);
259
+ } catch {
260
+ return err("vacuum produced an unreadable report");
261
+ }
262
+ }
263
+
264
+ // ../../packages/api-document-lint/dist/select-engine.js
265
+ var import_yaml = __toESM(require_dist(), 1);
266
+ function selectEngine(ruleset) {
267
+ if (!ruleset || ruleset.trim().length === 0) {
268
+ return "vacuum";
269
+ }
270
+ const parsed = parseRuleset(ruleset);
271
+ if (parsed === null) {
272
+ return "spectral";
273
+ }
274
+ if (hasCustomFunctions(parsed) || hasRuleCustomizations(parsed) || extendsUninspectableRuleset(parsed) || overridesRequireSpectral(parsed)) {
275
+ return "spectral";
276
+ }
277
+ return "vacuum";
278
+ }
279
+ function overridesRequireSpectral(ruleset) {
280
+ const overrides = ruleset.overrides;
281
+ if (!Array.isArray(overrides)) {
282
+ return false;
283
+ }
284
+ return overrides.some((entry) => isRecord(entry) && (hasCustomFunctions(entry) || hasRuleCustomizations(entry) || extendsUninspectableRuleset(entry)));
285
+ }
286
+ function hasRuleCustomizations(ruleset) {
287
+ return ruleset.rules !== void 0 && (!isRecord(ruleset.rules) || Object.keys(ruleset.rules).length > 0);
288
+ }
289
+ function isRecord(value) {
290
+ return typeof value === "object" && value !== null && !Array.isArray(value);
291
+ }
292
+ function parseRuleset(ruleset) {
293
+ try {
294
+ const value = (0, import_yaml.parse)(ruleset);
295
+ if (value && typeof value === "object" && !Array.isArray(value)) {
296
+ return value;
297
+ }
298
+ return null;
299
+ } catch {
300
+ return null;
301
+ }
302
+ }
303
+ function hasCustomFunctions(ruleset) {
304
+ const functions = ruleset.functions;
305
+ if (Array.isArray(functions) && functions.length > 0) {
306
+ return true;
307
+ }
308
+ return typeof ruleset.functionsDir === "string" && ruleset.functionsDir.length > 0;
309
+ }
310
+ function extendsUninspectableRuleset(ruleset) {
311
+ const extended = ruleset.extends;
312
+ if (extended === void 0) {
313
+ return false;
314
+ }
315
+ const entries = Array.isArray(extended) ? extended : [extended];
316
+ return entries.some((entry) => !isBuiltInRuleset(entry));
317
+ }
318
+ function isBuiltInRuleset(entry) {
319
+ const source = Array.isArray(entry) ? entry[0] : entry;
320
+ return source === "spectral:oas" || source === "spectral:asyncapi";
321
+ }
322
+
323
+ // ../../packages/api-document-lint/dist/lint.js
324
+ async function lint(input, options = {}) {
325
+ const ruleset = input.ruleset && input.ruleset.trim().length > 0 ? input.ruleset : defaultRulesetFor(input.document);
326
+ const resolved = { document: input.document, ruleset };
327
+ const engine = selectEngine(ruleset);
328
+ const diagnostics = engine === "vacuum" ? await runVacuum(resolved, options) : await runSpectral(resolved);
329
+ if (!diagnostics.ok) {
330
+ return diagnostics;
331
+ }
332
+ return ok({ diagnostics: diagnostics.data, engine });
333
+ }
334
+
335
+ // src/domains/document/lint/helpers.ts
336
+ var severityToLabel = (severity) => {
337
+ return {
338
+ 0: "Error",
339
+ 1: "Warning",
340
+ 2: "Information",
341
+ 3: "Hint"
342
+ }[severity];
343
+ };
344
+
345
+ // src/domains/document/lint/action.ts
346
+ async function lintAction(inputArgument, { rule: ruleArgument }) {
347
+ if (!inputArgument) {
348
+ return output.error().title("Invalid argument").message("Please provide a file path").exit("error");
349
+ }
350
+ const specification = await getFileOrUrl(inputArgument);
351
+ const ruleset = ruleArgument ? await getFileOrUrl(ruleArgument) : isAsyncApiContent(specification) ? ASYNCAPI_RULESET : DEFAULT_RULESET;
352
+ const result = await lint({ document: specification, ruleset });
353
+ if (!result.ok) {
354
+ return output.error().title("Failed to lint the document").message(result.error).exit("error");
355
+ }
356
+ const diagnostics = result.data.diagnostics;
357
+ const hasErrors = diagnostics.some((diagnostic) => diagnostic.severity === 0);
358
+ if (!hasErrors) {
359
+ output.info().message(as.green("\u2714 No issues found!")).print();
360
+ } else {
361
+ output.warn().line(as.red("\u2716 Issues found:")).print();
362
+ }
363
+ for (const diagnostic of diagnostics) {
364
+ output.info().line(`${as.yellow("Rule:")} ${as.bold(String(diagnostic.code))}`).line(`${as.yellow("Message:")} ${diagnostic.message}`).line(`${as.yellow("Severity:")} ${severityToLabel(diagnostic.severity)}`).line(
365
+ `${as.yellow("Location:")} ${diagnostic.range.start.line}:${diagnostic.range.start.character} - ${diagnostic.range.end.line}:${diagnostic.range.end.character}`
366
+ ).line(as.gray("---")).print();
367
+ }
368
+ if (hasErrors) {
369
+ output.error().exit("error");
370
+ }
371
+ }
372
+ export {
373
+ lintAction
374
+ };
@@ -1,19 +1,26 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
- loadOpenApiFile,
4
- printSpecificationBanner
5
- } from "./chunk-23I5PKZZ.js";
3
+ getFileOrUrl,
4
+ isAsyncApiDocument,
5
+ isDocument,
6
+ loadOpenApiDocument,
7
+ printSpecificationBanner,
8
+ safeNormalize
9
+ } from "./chunk-24WAOKGG.js";
6
10
  import {
7
11
  watchFile
8
- } from "./chunk-5BISXQX4.js";
9
- import "./chunk-OAXFCOJV.js";
10
- import "./chunk-4DGQIAJX.js";
11
- import "./chunk-ISGLWBXZ.js";
12
- import "./chunk-H2WRMLYY.js";
13
- import "./chunk-IX7LJ3AD.js";
12
+ } from "./chunk-M37TP6U2.js";
13
+ import "./chunk-4ZDQXWBT.js";
14
+ import "./chunk-VNYE4R7N.js";
15
+ import "./chunk-OQKDBLOZ.js";
16
+ import "./chunk-CISTON3A.js";
17
+ import "./chunk-Q7DOQHZN.js";
18
+ import "./chunk-4ORL4MST.js";
14
19
  import {
15
20
  output
16
- } from "./chunk-X4QLDBB5.js";
21
+ } from "./chunk-T5HJUAWB.js";
22
+ import "./chunk-GSGZHE26.js";
23
+ import "./chunk-IKT5F47M.js";
17
24
  import "./chunk-3MZYUBJ6.js";
18
25
 
19
26
  // src/domains/document/serve/action.ts
@@ -21,25 +28,47 @@ import { serve } from "@hono/node-server";
21
28
  import as from "ansis";
22
29
  import { Hono } from "hono";
23
30
  import { stream } from "hono/streaming";
31
+
32
+ // src/domains/document/serve/load-document.ts
33
+ import { validate } from "@scalar/asyncapi-validator";
34
+ var loadServeDocument = async (input) => {
35
+ const content = await getFileOrUrl(input);
36
+ const document = safeNormalize(content);
37
+ if (!isDocument(document) || !isAsyncApiDocument(document)) {
38
+ return loadOpenApiDocument(content);
39
+ }
40
+ const result = validate(document);
41
+ if (!result.valid) {
42
+ output.warn().title("File does not match the AsyncAPI specification.").print();
43
+ for (const error of result.errors ?? []) {
44
+ output.warn().title(error.message ?? "Invalid AsyncAPI document").print();
45
+ }
46
+ }
47
+ return {
48
+ valid: result.valid,
49
+ version: result.version,
50
+ specification: document,
51
+ schema: void 0
52
+ };
53
+ };
54
+
55
+ // src/domains/document/serve/action.ts
24
56
  async function serveAction(inputArgument, { watch, once, port }) {
25
57
  if (!inputArgument) {
26
58
  return output.error().title("Invalid argument").message("Please provide a file path").exit("error");
27
59
  }
28
- const result = await loadOpenApiFile(inputArgument);
29
- if (!result.valid) {
60
+ const result = await loadServeDocument(inputArgument);
61
+ if (result.specification === void 0) {
30
62
  return;
31
63
  }
32
64
  let { specification } = result;
33
- printSpecificationBanner({
34
- version: result.version,
35
- schema: result.schema
36
- });
37
- if (specification?.paths === void 0 || Object.keys(specification?.paths).length === 0) {
65
+ printServeBanner(result);
66
+ if (!isAsyncApiDocument(specification) && Object.keys(specification.paths ?? {}).length === 0) {
38
67
  output.warn().title("Could not find any paths in the OpenAPI file.").print();
39
68
  }
40
69
  const app = new Hono();
41
70
  app.get("/", (c) => {
42
- return c.html(getHtmlDocument(specification ?? {}, watch));
71
+ return c.html(getHtmlDocument(specification, watch));
43
72
  });
44
73
  app.use("/__watcher", async (c, next) => {
45
74
  c.header("Content-Type", "text/event-stream");
@@ -51,14 +80,14 @@ async function serveAction(inputArgument, { watch, once, port }) {
51
80
  return stream(c, async (s) => {
52
81
  if (watch) {
53
82
  const subscription = await watchFile(inputArgument, async () => {
54
- const newResult = await loadOpenApiFile(inputArgument);
55
- const specificationHasChanged = newResult?.specification && JSON.stringify(specification) !== JSON.stringify(newResult.specification);
56
- if (specificationHasChanged && newResult.valid) {
57
- output.info().title(as.grey("OpenAPI file modified")).print();
58
- printSpecificationBanner({
59
- version: newResult.version,
60
- schema: newResult.schema
61
- });
83
+ const newResult = await loadServeDocument(inputArgument);
84
+ if (newResult.specification && JSON.stringify(specification) !== JSON.stringify(newResult.specification)) {
85
+ output.info().title(
86
+ as.grey(
87
+ `${isAsyncApiDocument(newResult.specification) ? "AsyncAPI" : "OpenAPI"} file modified`
88
+ )
89
+ ).print();
90
+ printServeBanner(newResult);
62
91
  specification = newResult.specification;
63
92
  s.write("data: file modified\n\n");
64
93
  }
@@ -124,6 +153,16 @@ var getHtmlDocument = (specification, watch = false) => {
124
153
  </body>
125
154
  </html>`;
126
155
  };
156
+ var printServeBanner = (result) => {
157
+ if (isAsyncApiDocument(result.specification)) {
158
+ output.info().title(`AsyncAPI${result.version ? ` v${result.version}` : ""}`).print();
159
+ return;
160
+ }
161
+ printSpecificationBanner({
162
+ version: result.version,
163
+ schema: result.valid ? result.schema : void 0
164
+ });
165
+ };
127
166
  export {
128
167
  getHtmlDocument,
129
168
  serveAction
@@ -1,39 +1,39 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  apiService
4
- } from "./chunk-SXYALPYK.js";
4
+ } from "./chunk-AO3F5XWR.js";
5
5
  import {
6
6
  BaseCollections
7
- } from "./chunk-2BSG2QHO.js";
7
+ } from "./chunk-F467BYYR.js";
8
8
  import {
9
9
  getDatabaseClient
10
- } from "./chunk-SHSHFGA7.js";
11
- import "./chunk-UPUTMFD4.js";
12
- import "./chunk-B6QZJWCQ.js";
13
- import "./chunk-5BPPGTUU.js";
14
- import "./chunk-P646T2WH.js";
15
- import "./chunk-4QS7SJTG.js";
16
- import "./chunk-VTYTPSXO.js";
10
+ } from "./chunk-Z2KMGFE6.js";
11
+ import "./chunk-HCPN3KNF.js";
12
+ import "./chunk-B2MHTD3R.js";
13
+ import "./chunk-3L6DLIXJ.js";
14
+ import "./chunk-P7H7GY5A.js";
15
+ import "./chunk-HPL3ZZ2P.js";
17
16
  import {
18
17
  getAuthData
19
- } from "./chunk-5BISXQX4.js";
20
- import "./chunk-OAXFCOJV.js";
21
- import "./chunk-TLFMATXR.js";
18
+ } from "./chunk-M37TP6U2.js";
19
+ import "./chunk-4ZDQXWBT.js";
22
20
  import {
23
21
  teamSchema
24
- } from "./chunk-4DGQIAJX.js";
25
- import {
26
- namespaceSchema
27
- } from "./chunk-ISGLWBXZ.js";
28
- import {
29
- external_exports
30
- } from "./chunk-H2WRMLYY.js";
22
+ } from "./chunk-VNYE4R7N.js";
23
+ import "./chunk-OQKDBLOZ.js";
31
24
  import "./chunk-K74E42RV.js";
32
- import "./chunk-IX7LJ3AD.js";
25
+ import "./chunk-CISTON3A.js";
26
+ import "./chunk-Q7DOQHZN.js";
27
+ import "./chunk-4ORL4MST.js";
33
28
  import {
34
29
  output,
35
30
  printTable
36
- } from "./chunk-X4QLDBB5.js";
31
+ } from "./chunk-T5HJUAWB.js";
32
+ import "./chunk-GSGZHE26.js";
33
+ import {
34
+ external_exports,
35
+ namespaceSchema
36
+ } from "./chunk-IKT5F47M.js";
37
37
  import "./chunk-3MZYUBJ6.js";
38
38
 
39
39
  // src/domains/registry/list/action.ts
@@ -2,18 +2,17 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  readAndParseConfig,
4
4
  renderConfigError
5
- } from "./chunk-P2VH7DOC.js";
6
- import "./chunk-47Y4L5IT.js";
7
- import "./chunk-5BPPGTUU.js";
8
- import "./chunk-4QS7SJTG.js";
9
- import "./chunk-VTYTPSXO.js";
10
- import "./chunk-TLFMATXR.js";
11
- import "./chunk-ISGLWBXZ.js";
12
- import "./chunk-H2WRMLYY.js";
5
+ } from "./chunk-7AGLC7WV.js";
6
+ import "./chunk-PBXZN65A.js";
7
+ import "./chunk-OQKDBLOZ.js";
13
8
  import "./chunk-K74E42RV.js";
9
+ import "./chunk-CISTON3A.js";
10
+ import "./chunk-Q7DOQHZN.js";
14
11
  import {
15
12
  output
16
- } from "./chunk-X4QLDBB5.js";
13
+ } from "./chunk-T5HJUAWB.js";
14
+ import "./chunk-GSGZHE26.js";
15
+ import "./chunk-IKT5F47M.js";
17
16
  import "./chunk-3MZYUBJ6.js";
18
17
 
19
18
  // src/domains/project/check-config/action.ts
@@ -1,22 +1,25 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  apiService
4
- } from "./chunk-SXYALPYK.js";
5
- import "./chunk-UPUTMFD4.js";
6
- import "./chunk-B6QZJWCQ.js";
7
- import "./chunk-P646T2WH.js";
8
- import "./chunk-4QS7SJTG.js";
9
- import "./chunk-VTYTPSXO.js";
10
- import "./chunk-5BISXQX4.js";
11
- import "./chunk-OAXFCOJV.js";
12
- import "./chunk-TLFMATXR.js";
13
- import "./chunk-4DGQIAJX.js";
14
- import "./chunk-ISGLWBXZ.js";
15
- import "./chunk-H2WRMLYY.js";
16
- import "./chunk-IX7LJ3AD.js";
4
+ } from "./chunk-AO3F5XWR.js";
5
+ import "./chunk-HCPN3KNF.js";
6
+ import "./chunk-B2MHTD3R.js";
7
+ import "./chunk-3L6DLIXJ.js";
8
+ import "./chunk-P7H7GY5A.js";
9
+ import "./chunk-HPL3ZZ2P.js";
10
+ import "./chunk-M37TP6U2.js";
11
+ import "./chunk-4ZDQXWBT.js";
12
+ import "./chunk-VNYE4R7N.js";
13
+ import "./chunk-OQKDBLOZ.js";
14
+ import "./chunk-K74E42RV.js";
15
+ import "./chunk-CISTON3A.js";
16
+ import "./chunk-Q7DOQHZN.js";
17
+ import "./chunk-4ORL4MST.js";
17
18
  import {
18
19
  output
19
- } from "./chunk-X4QLDBB5.js";
20
+ } from "./chunk-T5HJUAWB.js";
21
+ import "./chunk-GSGZHE26.js";
22
+ import "./chunk-IKT5F47M.js";
20
23
  import "./chunk-3MZYUBJ6.js";
21
24
 
22
25
  // src/domains/registry/delete/action.ts
@@ -1,23 +1,23 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getUserTeams
4
- } from "./chunk-ASMHW5AY.js";
4
+ } from "./chunk-6ZMT63IV.js";
5
5
  import {
6
6
  getDatabaseClient
7
- } from "./chunk-SHSHFGA7.js";
8
- import "./chunk-B6QZJWCQ.js";
7
+ } from "./chunk-Z2KMGFE6.js";
8
+ import "./chunk-B2MHTD3R.js";
9
9
  import {
10
10
  getAuthData,
11
11
  refreshToken
12
- } from "./chunk-5BISXQX4.js";
13
- import "./chunk-OAXFCOJV.js";
14
- import "./chunk-4DGQIAJX.js";
15
- import "./chunk-ISGLWBXZ.js";
16
- import "./chunk-H2WRMLYY.js";
17
- import "./chunk-IX7LJ3AD.js";
12
+ } from "./chunk-M37TP6U2.js";
13
+ import "./chunk-4ZDQXWBT.js";
14
+ import "./chunk-VNYE4R7N.js";
15
+ import "./chunk-OQKDBLOZ.js";
16
+ import "./chunk-4ORL4MST.js";
18
17
  import {
19
18
  output
20
- } from "./chunk-X4QLDBB5.js";
19
+ } from "./chunk-T5HJUAWB.js";
20
+ import "./chunk-IKT5F47M.js";
21
21
  import "./chunk-3MZYUBJ6.js";
22
22
 
23
23
  // src/domains/team/set/action.ts