@scalar/cli 2.15.0 → 2.18.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 (112) hide show
  1. package/README.md +121 -25
  2. package/chunks/{action-3W4IC7QL.js → action-2WVJ2WEW.js} +26 -27
  3. package/chunks/{action-HOCCP353.js → action-4BDZ2CXP.js} +12 -13
  4. package/chunks/{action-3QQSKGM3.js → action-5AXDB5VN.js} +21 -23
  5. package/chunks/{action-LD5B5QQ4.js → action-6I3TJLRO.js} +34 -33
  6. package/chunks/{action-T7SD3ETN.js → action-6WZN63LT.js} +299 -75
  7. package/chunks/{action-IUAYC2SC.js → action-7GZGVTYI.js} +1071 -775
  8. package/chunks/{action-2BGAMGXU.js → action-7ZCJAWI2.js} +9 -9
  9. package/chunks/{action-6HFH7DAW.js → action-A6YOY24G.js} +14 -10
  10. package/chunks/{action-IU2AVNOW.js → action-AGGHY4N2.js} +26 -26
  11. package/chunks/{action-B2WWTOF6.js → action-BVZOA2G5.js} +15 -16
  12. package/chunks/{action-2UZWKMSJ.js → action-BYDJ4R4F.js} +18 -19
  13. package/chunks/{action-HDT7EO7W.js → action-CBAL5CYB.js} +19 -21
  14. package/chunks/action-COFGCCYS.js +89 -0
  15. package/chunks/action-CYU5Q5LT.js +254 -0
  16. package/chunks/{action-MJHLG7AE.js → action-DTQH6CKR.js} +33 -33
  17. package/chunks/{action-P2RPH5R2.js → action-ED5WLLIE.js} +11 -12
  18. package/chunks/action-F4CQ4DW3.js +654 -0
  19. package/chunks/{action-SRFBOLDL.js → action-GQDQU2WE.js} +1 -1
  20. package/chunks/{action-PDSSIW2A.js → action-GVW5PSPT.js} +26 -28
  21. package/chunks/{action-WOLNPEUQ.js → action-H5VRLFCY.js} +16 -12
  22. package/chunks/{action-G2WBTXOK.js → action-IWEAWDT3.js} +19 -19
  23. package/chunks/{action-NZJ4Z64U.js → action-JN6JVQUV.js} +16 -18
  24. package/chunks/{action-PNSWHIHC.js → action-KVM76ZKQ.js} +20 -20
  25. package/chunks/{action-JNH4DCZX.js → action-LLMFEBHH.js} +3 -4
  26. package/chunks/{action-QJMRAFOF.js → action-PEG7AUA6.js} +20 -19
  27. package/chunks/{action-2HPMP473.js → action-QC72LLYE.js} +13 -11
  28. package/chunks/{action-ZTLOQZTT.js → action-QP6MRSQW.js} +16 -15
  29. package/chunks/{action-4HXB3YQR.js → action-R53K22GE.js} +230 -52
  30. package/chunks/{action-U2RJ3ZAU.js → action-SJPWL723.js} +6 -5
  31. package/chunks/{action-57SV3ZBM.js → action-T3R4SDAI.js} +9 -9
  32. package/chunks/{action-777R7LOG.js → action-TT7ZJNST.js} +25 -25
  33. package/chunks/{action-TY4BZEMN.js → action-UPVVJE26.js} +18 -19
  34. package/chunks/{action-MBAAYXKK.js → action-V35W4MRK.js} +18 -19
  35. package/chunks/{action-TR2T2UYB.js → action-W4KGRBRV.js} +9 -9
  36. package/chunks/{action-ENDUKGWS.js → action-ZIVYJCC2.js} +16 -18
  37. package/chunks/{action-7LK4RUDP.js → action-ZU5X2KQX.js} +52 -49
  38. package/chunks/{actions-D5OHPBWC.js → actions-CERT7BL4.js} +25 -26
  39. package/chunks/{actions-RI42JY6H.js → actions-RCIS37Y6.js} +22 -24
  40. package/chunks/{agent-NA3QFKJX.js → agent-CT3RRYPJ.js} +7 -7
  41. package/chunks/{asyncapi-YBTWMTW6.js → asyncapi-DVBS23QW.js} +17 -18
  42. package/chunks/{build.action-4YDNDBXC.js → build.action-7MKMMV6V.js} +38 -32
  43. package/chunks/{chunk-MGGMCT77.js → chunk-36UI2W7I.js} +1 -1
  44. package/chunks/chunk-4BMOCIYO.js +536 -0
  45. package/chunks/{chunk-ADQ6B6QI.js → chunk-5DRLDTTU.js} +1 -1
  46. package/chunks/{chunk-G5WWW7VD.js → chunk-5EO2CVAR.js} +6 -6
  47. package/chunks/{chunk-Q26DFKTY.js → chunk-5GZAGHKL.js} +1 -1
  48. package/chunks/{chunk-DWJMPHLY.js → chunk-7LUXRNKV.js} +27 -2
  49. package/chunks/{chunk-BY4NGQ5D.js → chunk-A2MPF6GE.js} +7 -3
  50. package/chunks/{chunk-5D3T63G4.js → chunk-BIQFYZP6.js} +1 -1
  51. package/chunks/chunk-CNJ4TLU7.js +83 -0
  52. package/chunks/{chunk-UM3WZUGF.js → chunk-CWCRBWA6.js} +7 -3
  53. package/chunks/{chunk-Z6HOHGUJ.js → chunk-CYIGEQOJ.js} +2 -2
  54. package/chunks/{chunk-4S3DGMMZ.js → chunk-DUIMDHQQ.js} +1 -1
  55. package/chunks/{chunk-W7P6VTCG.js → chunk-DVA4NCCY.js} +6 -4
  56. package/chunks/chunk-DWWY3LPC.js +85 -0
  57. package/chunks/{chunk-USVU6AC2.js → chunk-F6E7FJEC.js} +18 -12
  58. package/chunks/{chunk-E24BNP6E.js → chunk-FDW4LC45.js} +1 -1
  59. package/chunks/{chunk-TW2UASEW.js → chunk-FMPJSW6A.js} +4 -4
  60. package/chunks/{chunk-IPWJEGPD.js → chunk-GCVB22TG.js} +2 -2
  61. package/chunks/{chunk-6BQHLHBE.js → chunk-GXKNYM54.js} +3 -3
  62. package/chunks/chunk-I25ZCHBJ.js +22 -0
  63. package/chunks/{chunk-I57ID5K7.js → chunk-JBMHCTZD.js} +8 -1
  64. package/chunks/{chunk-KOLEQNLG.js → chunk-JEOQ7LSA.js} +1 -1
  65. package/chunks/{chunk-QMERQSPM.js → chunk-KI2AVDKM.js} +8 -6
  66. package/chunks/{chunk-2KSOARE4.js → chunk-KSY2GH53.js} +3 -3
  67. package/chunks/{chunk-SHRUJFQI.js → chunk-KWQVA66H.js} +105 -18
  68. package/chunks/{chunk-DLYMDGFW.js → chunk-LPWRG2MS.js} +4 -4
  69. package/chunks/{chunk-Y6GKZ2FM.js → chunk-LVUMNGVA.js} +1 -1
  70. package/chunks/{chunk-PIDLENYN.js → chunk-M34HMQMV.js} +42 -83
  71. package/chunks/{chunk-7FS7BAUX.js → chunk-MRZ5A7LB.js} +133 -19
  72. package/chunks/chunk-O3I3LTTJ.js +24 -0
  73. package/chunks/{chunk-VBHPHAGS.js → chunk-O4DJIA6Y.js} +2 -18
  74. package/chunks/chunk-OKLL5422.js +263 -0
  75. package/chunks/{chunk-HIDIW2FN.js → chunk-OQE3WKI3.js} +1 -1
  76. package/chunks/{chunk-ERZ3HYB5.js → chunk-PMDHYIB4.js} +9 -21
  77. package/chunks/{chunk-IDGT5RAQ.js → chunk-RELSIFIL.js} +2 -2
  78. package/chunks/{chunk-BOCMOHQA.js → chunk-RGJPENX7.js} +1 -1
  79. package/chunks/{chunk-7FGJIUDN.js → chunk-RHAQ4XBA.js} +3 -3
  80. package/chunks/chunk-RQ7QBRJT.js +93 -0
  81. package/chunks/chunk-S3LY7RKP.js +54 -0
  82. package/chunks/{chunk-T76K7QNX.js → chunk-S5OGPH2P.js} +3 -3
  83. package/chunks/{chunk-ANP5XF26.js → chunk-U36HEOGO.js} +12625 -1369
  84. package/chunks/{chunk-IPUJEBMI.js → chunk-UWRJCJVG.js} +1 -1
  85. package/chunks/chunk-V7DBDXSJ.js +24 -0
  86. package/chunks/{chunk-RRYUCZYO.js → chunk-WGTZEX4Y.js} +7 -3
  87. package/chunks/{chunk-7PNOYE6B.js → chunk-Y3CXAIAG.js} +30 -3
  88. package/chunks/{chunk-GOKHFNB2.js → chunk-Z7EH7CJC.js} +3 -3
  89. package/chunks/{chunk-42MIV6WF.js → chunk-ZMJW5UWU.js} +6 -5
  90. package/chunks/chunk-ZQDAPKWX.js +111 -0
  91. package/chunks/{create.action-52K3XAYN.js → create.action-VA2ISPIM.js} +27 -29
  92. package/chunks/{delete.action-47LPLTOX.js → delete.action-AIWMDGXV.js} +26 -28
  93. package/chunks/{delete.action-3NMOQPIR.js → delete.action-GEN6OD7A.js} +26 -28
  94. package/chunks/{diff.action-5TLC2EHT.js → diff.action-LBK656RN.js} +32 -27
  95. package/chunks/{get.action-BCMLG7C7.js → get.action-5SWRNQ3D.js} +20 -19
  96. package/chunks/{get.action-TOZ474GO.js → get.action-UPPPGGI4.js} +29 -23
  97. package/chunks/{list.action-6ZWEENT6.js → list.action-YJZBC25S.js} +26 -28
  98. package/chunks/{list.action-CMAA5KTY.js → list.action-YOWWC4I4.js} +54 -25
  99. package/chunks/{publish.action-U3VIU5LZ.js → publish.action-QMVDHDJZ.js} +52 -49
  100. package/chunks/{update.action-UQHZYVTP.js → update.action-GFDZIGEP.js} +27 -29
  101. package/chunks/{update.action-QZOP25ME.js → update.action-SNGKPS7A.js} +26 -28
  102. package/index.js +688 -212
  103. package/package.json +11 -11
  104. package/skills/scalar-cli/SKILL.md +4 -3
  105. package/template.md +120 -24
  106. package/chunks/action-3KP3WVPZ.js +0 -112
  107. package/chunks/action-APBLB3IU.js +0 -235
  108. package/chunks/chunk-BLY2CF4S.js +0 -58
  109. package/chunks/chunk-BMQFEKHA.js +0 -3534
  110. package/chunks/chunk-EOTD7HAV.js +0 -318
  111. package/chunks/chunk-QXOUDBFK.js +0 -92
  112. package/chunks/chunk-TR5U7G7T.js +0 -32
@@ -1,36 +1,42 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
- isPollutionKey
4
- } from "./chunk-IPUJEBMI.js";
3
+ childReferenceContext
4
+ } from "./chunk-DWWY3LPC.js";
5
+ import {
6
+ writeFileAtomic
7
+ } from "./chunk-CNJ4TLU7.js";
5
8
  import {
6
9
  measureTime
7
10
  } from "./chunk-KHDYYVYF.js";
11
+ import {
12
+ isPollutionKey
13
+ } from "./chunk-UWRJCJVG.js";
8
14
  import {
9
15
  isDocument
10
- } from "./chunk-RRYUCZYO.js";
16
+ } from "./chunk-WGTZEX4Y.js";
11
17
  import {
12
18
  isAsyncApiDocument
13
- } from "./chunk-UM3WZUGF.js";
19
+ } from "./chunk-CWCRBWA6.js";
14
20
  import {
15
21
  safeNormalize
16
- } from "./chunk-BY4NGQ5D.js";
17
- import "./chunk-E24BNP6E.js";
22
+ } from "./chunk-A2MPF6GE.js";
23
+ import "./chunk-FDW4LC45.js";
18
24
  import {
19
25
  isYamlFileName
20
26
  } from "./chunk-4ORL4MST.js";
21
- import "./chunk-2KSOARE4.js";
27
+ import "./chunk-KSY2GH53.js";
22
28
  import {
23
29
  output
24
30
  } from "./chunk-T5HJUAWB.js";
25
31
  import {
26
32
  err,
27
33
  ok
28
- } from "./chunk-4S3DGMMZ.js";
29
- import "./chunk-7PNOYE6B.js";
30
- import "./chunk-Q26DFKTY.js";
34
+ } from "./chunk-DUIMDHQQ.js";
35
+ import "./chunk-Y3CXAIAG.js";
36
+ import "./chunk-5GZAGHKL.js";
31
37
  import {
32
38
  external_exports
33
- } from "./chunk-I57ID5K7.js";
39
+ } from "./chunk-JBMHCTZD.js";
34
40
  import "./chunk-3MZYUBJ6.js";
35
41
 
36
42
  // src/domains/document/join/action.ts
@@ -38,7 +44,9 @@ import fs from "node:fs/promises";
38
44
  import path from "node:path";
39
45
  import as from "ansis";
40
46
  import YAML from "yaml";
41
- import { bundle as bundle2 } from "@scalar/json-magic/bundle";
47
+ import {
48
+ bundle
49
+ } from "@scalar/json-magic/bundle";
42
50
  import { fetchUrls, readFiles } from "@scalar/json-magic/bundle/plugins/node";
43
51
 
44
52
  // src/domains/document/join/helpers.ts
@@ -177,8 +185,136 @@ var joinAsyncApi = (inputs, prefixes) => {
177
185
  return conflicts.length ? { ok: false, conflicts } : { ok: true, document: result };
178
186
  };
179
187
 
188
+ // src/domains/document/join/bundle.ts
189
+ import { randomUUID } from "node:crypto";
190
+ import {
191
+ bundleWithDiagnostics
192
+ } from "@scalar/json-magic/bundle";
193
+ var bundleJoinDocument = async (input, config) => {
194
+ const hidden = /* @__PURE__ */ new Map();
195
+ const documents = [];
196
+ const partials = /* @__PURE__ */ new WeakSet();
197
+ const diagnostics = [];
198
+ const mask = (document) => {
199
+ if (document !== null && typeof document === "object" && partials.has(document))
200
+ return;
201
+ documents.push(document);
202
+ const visited = /* @__PURE__ */ new WeakSet();
203
+ const swagger = document !== null && typeof document === "object" && "swagger" in document && document.swagger === "2.0";
204
+ const visit = (value, context) => {
205
+ if (value === null || typeof value !== "object" || visited.has(value))
206
+ return;
207
+ visited.add(value);
208
+ const api = ["openapi", "swagger", "asyncapi"].some((key) => key in value);
209
+ const schema = [
210
+ "type",
211
+ "$id",
212
+ "$schema",
213
+ "$defs",
214
+ "definitions",
215
+ "properties",
216
+ "patternProperties",
217
+ "dependentSchemas",
218
+ "dependencies",
219
+ "items",
220
+ "additionalItems",
221
+ "additionalProperties",
222
+ "unevaluatedItems",
223
+ "unevaluatedProperties",
224
+ "contains",
225
+ "contentSchema",
226
+ "propertyNames",
227
+ "not",
228
+ "if",
229
+ "then",
230
+ "else",
231
+ "allOf",
232
+ "anyOf",
233
+ "oneOf",
234
+ "prefixItems"
235
+ ].some((key) => key in value) || "examples" in value && Array.isArray(value.examples);
236
+ const current = context === "object" && !api && schema ? "schema" : context;
237
+ for (const [key, child] of Object.entries(value)) {
238
+ if (value === document && key === (config.externalDocumentsKey ?? "x-ext"))
239
+ continue;
240
+ const next = Array.isArray(value) && !["objects", "schemas", "messages"].includes(current) ? current : childReferenceContext(current, key, swagger, "bundle");
241
+ if (next === "data" && child !== null && typeof child === "object") {
242
+ const token = randomUUID();
243
+ hidden.set(token, child);
244
+ Object.defineProperty(value, key, {
245
+ value: token,
246
+ enumerable: true,
247
+ configurable: true,
248
+ writable: true
249
+ });
250
+ } else visit(child, next);
251
+ }
252
+ };
253
+ visit(document, "object");
254
+ };
255
+ const restore = (value, seen = /* @__PURE__ */ new WeakSet()) => {
256
+ if (value === null || typeof value !== "object" || seen.has(value)) return;
257
+ seen.add(value);
258
+ for (const [key, child] of Object.entries(value)) {
259
+ if (typeof child === "string" && hidden.has(child)) {
260
+ Object.defineProperty(value, key, {
261
+ value: hidden.get(child),
262
+ enumerable: true,
263
+ configurable: true,
264
+ writable: true
265
+ });
266
+ restore(hidden.get(child), seen);
267
+ } else restore(child, seen);
268
+ }
269
+ };
270
+ const settings = {
271
+ ...config,
272
+ traversal: "generic",
273
+ visitedNodes: config.visitedNodes ?? /* @__PURE__ */ new Set(),
274
+ hooks: {
275
+ ...config.hooks,
276
+ resolveDocument: (document, origin) => {
277
+ const identity = config.hooks?.resolveDocument?.(document, origin);
278
+ mask(document);
279
+ return identity;
280
+ },
281
+ onAfterNodeProcess: async (node, context) => {
282
+ await config.hooks?.onAfterNodeProcess?.(node, context);
283
+ if (typeof node.$ref !== "string") return;
284
+ const children = Object.fromEntries(
285
+ Object.entries(node).filter(
286
+ ([key, value]) => key !== "$ref" && key !== "$id" && value !== null && typeof value === "object"
287
+ )
288
+ );
289
+ if (!Object.keys(children).length) return;
290
+ const partial = { ...children, $id: context.origin };
291
+ partials.add(partial);
292
+ const nested = await bundleWithDiagnostics(partial, {
293
+ ...settings,
294
+ origin: config.origin ?? (typeof input === "string" ? input : "/"),
295
+ root: context.rootNode,
296
+ cache: context.resolutionCache,
297
+ urlMap: true
298
+ });
299
+ diagnostics.push(...nested.diagnostics);
300
+ }
301
+ }
302
+ };
303
+ try {
304
+ const result = await bundleWithDiagnostics(input, settings);
305
+ restore(result.document);
306
+ return {
307
+ ...result,
308
+ complete: result.complete && diagnostics.length === 0,
309
+ diagnostics: [...result.diagnostics, ...diagnostics]
310
+ };
311
+ } finally {
312
+ for (const document of documents) restore(document);
313
+ }
314
+ };
315
+
180
316
  // src/domains/document/join/openapi.ts
181
- import { bundle } from "@scalar/json-magic/bundle";
317
+ import { escapeJsonPointer } from "@scalar/json-magic/helpers/escape-json-pointer";
182
318
  import { join } from "@scalar/json-magic/join";
183
319
  import { upgrade as upgrade2 } from "@scalar/openapi-upgrader";
184
320
  var omitEmptySection = (value) => {
@@ -186,45 +322,52 @@ var omitEmptySection = (value) => {
186
322
  if (isDocument(value)) return Object.keys(value).length ? value : void 0;
187
323
  return value ?? void 0;
188
324
  };
189
- var prefixComponents = async (document, prefix) => {
190
- await bundle(document, {
325
+ var prepareReferences = async (document, componentPrefix, externalPrefix) => {
326
+ const rewrites = [];
327
+ await bundleJoinDocument(document, {
328
+ plugins: [],
191
329
  treeShake: false,
192
- urlMap: false,
193
- plugins: [
194
- {
195
- type: "lifecycle",
196
- onBeforeNodeProcess: (node) => {
197
- const ref = node.$ref;
198
- if (typeof ref !== "string" || !ref.startsWith("#/components/"))
199
- return;
200
- const parts = ref.split("/");
201
- if (parts.length < 4) return;
202
- parts[3] = `${prefix}${parts[3]}`;
203
- node.$ref = parts.join("/");
204
- }
205
- },
206
- {
207
- type: "lifecycle",
208
- onBeforeNodeProcess: (node, context) => {
209
- if (context.path.length !== 2 || context.path[0] !== "components")
210
- return;
211
- for (const key of Object.keys(node)) {
212
- const value = node[key];
213
- delete node[key];
214
- const name = `${prefix}${key}`;
215
- if (!isPollutionKey(key) && !isPollutionKey(name))
216
- node[name] = value;
217
- }
218
- }
330
+ hooks: {
331
+ onAfterNodeProcess: (node, context) => {
332
+ if (typeof node.$ref !== "string") return;
333
+ const target = context.resolveReference(node.$ref);
334
+ if (!target || target.resourceRelative) return;
335
+ const parts = [...target.path];
336
+ const offset = parts[0] === "components" ? 2 : parts[0] === "x-ext" ? 1 : void 0;
337
+ if (offset === void 0 || parts[offset] === void 0) return;
338
+ parts[offset] = (offset === 2 ? componentPrefix : externalPrefix) + parts[offset];
339
+ const reference = "#/" + parts.map((part) => encodeURIComponent(escapeJsonPointer(part))).join("/");
340
+ rewrites.push(() => {
341
+ node.$ref = reference;
342
+ });
219
343
  }
220
- ]
344
+ }
221
345
  });
346
+ for (const rewrite of rewrites) rewrite();
347
+ const rename = (entries, prefix) => Object.fromEntries(
348
+ Object.entries(entries).filter(
349
+ ([key]) => !isPollutionKey(key) && !isPollutionKey(prefix + key)
350
+ ).map(([key, value]) => [prefix + key, value])
351
+ );
352
+ if (isDocument(document.components)) {
353
+ for (const [kind, entries] of Object.entries(document.components)) {
354
+ if (isDocument(entries))
355
+ document.components[kind] = rename(entries, componentPrefix);
356
+ }
357
+ }
358
+ if (isDocument(document["x-ext"])) {
359
+ document["x-ext"] = rename(document["x-ext"], externalPrefix);
360
+ }
222
361
  };
223
362
  var joinOpenApi = async (inputs, prefixes) => {
224
363
  const documents = await Promise.all(
225
364
  inputs.map(async (input, index) => {
226
365
  const document = upgrade2(structuredClone(input), "3.1");
227
- await prefixComponents(document, prefixes[index] ?? "");
366
+ await prepareReferences(
367
+ document,
368
+ prefixes[index] ?? "",
369
+ `document${index}-`
370
+ );
228
371
  return {
229
372
  ...document,
230
373
  info: isDocument(document.info) ? document.info : {},
@@ -241,6 +384,7 @@ var joinOpenApi = async (inputs, prefixes) => {
241
384
  const [field] = path2;
242
385
  if (isPollutionKey(path2.at(-1) ?? "") && (field === "info" || field === "components" || path2.length === 2))
243
386
  return "skip";
387
+ if (field === "x-ext") return path2.length === 1 ? "merge" : "replace";
244
388
  if (field === "info") return "merge-by-index";
245
389
  if (field === "tags") return { uniqueBy: "name" };
246
390
  if (field === "servers") return { uniqueBy: "url" };
@@ -292,6 +436,9 @@ var formatErrorMessage = (conflicts) => {
292
436
  return `Webhook '${conflict.path} ${conflict.method}' has conflicts`;
293
437
  });
294
438
  };
439
+ var formatReferenceDiagnostics = (diagnostics) => diagnostics.map(
440
+ ({ source, pointer, reference, kind }) => `${source}${pointer}: ${kind === "missing-target" ? "Missing target" : "Could not load document"} for ${reference}`
441
+ ).join("\n");
295
442
  async function joinAction(rawInput, rawOpt) {
296
443
  const { error, data: input } = external_exports.array(external_exports.string()).safeParse(rawInput);
297
444
  if (error) {
@@ -309,7 +456,11 @@ async function joinAction(rawInput, rawOpt) {
309
456
  ).line("").exit("error");
310
457
  }
311
458
  const files = (await Promise.all(input.map((file) => fs.readFile(file, "utf-8")))).map((it) => {
312
- const document = safeNormalize(it);
459
+ const normalized = safeNormalize(it);
460
+ if (!normalized.ok) {
461
+ return output.error().title("Invalid input").message(normalized.error).exit("error");
462
+ }
463
+ const document = normalized.data;
313
464
  if (!isDocument(document)) {
314
465
  return output.error().title("Invalid input").message(
315
466
  "Could not read an API document from one of the input files. Provide valid JSON or YAML files."
@@ -322,12 +473,27 @@ async function joinAction(rawInput, rawOpt) {
322
473
  return output.error().title("Cannot join OpenAPI and AsyncAPI documents together").exit("error");
323
474
  }
324
475
  const specification = asyncApiCount ? "AsyncAPI" : "OpenAPI";
325
- const documents = asyncApiCount ? await Promise.all(
476
+ const documents = await Promise.all(
326
477
  input.map(async (file) => {
327
- const document = await bundle2(path.resolve(file), {
478
+ const bundleInput = asyncApiCount ? async (source, config) => ({
479
+ document: await bundle(source, config),
480
+ complete: true,
481
+ diagnostics: []
482
+ }) : bundleJoinDocument;
483
+ const bundled = await bundleInput(path.resolve(file), {
328
484
  plugins: [readFiles(), fetchUrls()],
329
485
  treeShake: false
486
+ }).catch((error2) => {
487
+ return output.error().title("Invalid input").message(
488
+ `${file}: ${error2 instanceof Error ? error2.message : String(error2)}`
489
+ ).exit("error");
330
490
  });
491
+ const document = bundled.document;
492
+ if (!asyncApiCount && !bundled.complete) {
493
+ return output.error().title("Invalid reference").message(
494
+ `${file}: ${formatReferenceDiagnostics(bundled.diagnostics)}`
495
+ ).exit("error");
496
+ }
331
497
  if (!isDocument(document)) {
332
498
  return output.error().title("Invalid input").message(
333
499
  "Could not read an API document from one of the input files. Provide valid JSON or YAML files."
@@ -335,10 +501,10 @@ async function joinAction(rawInput, rawOpt) {
335
501
  }
336
502
  return document;
337
503
  })
338
- ) : files;
504
+ );
339
505
  const prefixes = opts.prefixComponentsWithPathValue ? getPrefixes(files, opts.prefixComponentsWithPathValue) : [];
340
506
  const { executionTimeMs, result } = await measureTime(async () => {
341
- if (!asyncApiCount) return joinOpenApi(files, prefixes);
507
+ if (!asyncApiCount) return joinOpenApi(documents, prefixes);
342
508
  const joined = joinAsyncApi(documents, prefixes);
343
509
  return joined.ok ? ok(joined.document) : err(joined.conflicts);
344
510
  });
@@ -346,12 +512,24 @@ async function joinAction(rawInput, rawOpt) {
346
512
  return output.error().title(`Failed to join ${specification} documents`).line().line(`Conflicts:
347
513
  ${formatErrorMessage(result.error).join("\n")}`).line().exit("error");
348
514
  }
515
+ if (!asyncApiCount) {
516
+ const resolved = await bundleJoinDocument(result.data, {
517
+ plugins: [],
518
+ treeShake: false
519
+ });
520
+ if (!resolved.complete) {
521
+ return output.error().title("Invalid reference in joined API description").message(formatReferenceDiagnostics(resolved.diagnostics)).exit("error");
522
+ }
523
+ }
349
524
  const isYaml = isYamlFileName(opts.output);
350
- await fs.writeFile(
525
+ const written = await writeFileAtomic(
351
526
  opts.output,
352
- isYaml ? YAML.stringify(result.data) : JSON.stringify(result.data, null, 2),
353
- "utf8"
527
+ isYaml ? YAML.stringify(result.data) : JSON.stringify(result.data, null, 2)
354
528
  );
529
+ if (!written.ok)
530
+ return output.error().message(
531
+ `Could not write joined API description to ${opts.output}: ${written.error}`
532
+ ).exit("error");
355
533
  output.info().message(
356
534
  `${as.green(`${specification} descriptions joined`)} (${as.white(`${as.bold(`${Math.round(executionTimeMs)}`)} ms`)})`
357
535
  ).line(`Written to ${as.cyan(opts.output)}`).print();
@@ -2,14 +2,15 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  readAndParseConfig,
4
4
  renderConfigError
5
- } from "./chunk-QMERQSPM.js";
6
- import "./chunk-PIDLENYN.js";
7
- import "./chunk-BOCMOHQA.js";
5
+ } from "./chunk-KI2AVDKM.js";
6
+ import "./chunk-S3LY7RKP.js";
7
+ import "./chunk-M34HMQMV.js";
8
8
  import {
9
9
  output
10
10
  } from "./chunk-T5HJUAWB.js";
11
- import "./chunk-4S3DGMMZ.js";
12
- import "./chunk-I57ID5K7.js";
11
+ import "./chunk-DUIMDHQQ.js";
12
+ import "./chunk-RGJPENX7.js";
13
+ import "./chunk-JBMHCTZD.js";
13
14
  import "./chunk-3MZYUBJ6.js";
14
15
 
15
16
  // src/domains/project/check-config/action.ts
@@ -1,19 +1,19 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getFileOrUrl
4
- } from "./chunk-RRYUCZYO.js";
5
- import "./chunk-UM3WZUGF.js";
6
- import "./chunk-BY4NGQ5D.js";
7
- import "./chunk-E24BNP6E.js";
4
+ } from "./chunk-WGTZEX4Y.js";
5
+ import "./chunk-CWCRBWA6.js";
6
+ import "./chunk-A2MPF6GE.js";
7
+ import "./chunk-FDW4LC45.js";
8
8
  import "./chunk-4ORL4MST.js";
9
- import "./chunk-2KSOARE4.js";
9
+ import "./chunk-KSY2GH53.js";
10
10
  import {
11
11
  output
12
12
  } from "./chunk-T5HJUAWB.js";
13
- import "./chunk-4S3DGMMZ.js";
14
- import "./chunk-7PNOYE6B.js";
15
- import "./chunk-Q26DFKTY.js";
16
- import "./chunk-I57ID5K7.js";
13
+ import "./chunk-DUIMDHQQ.js";
14
+ import "./chunk-Y3CXAIAG.js";
15
+ import "./chunk-5GZAGHKL.js";
16
+ import "./chunk-JBMHCTZD.js";
17
17
  import "./chunk-3MZYUBJ6.js";
18
18
 
19
19
  // src/domains/document/markdown/action.ts
@@ -8,45 +8,45 @@ import {
8
8
  import "./chunk-AEFPCC4U.js";
9
9
  import {
10
10
  getPublishUrl
11
- } from "./chunk-ERZ3HYB5.js";
12
- import "./chunk-VBHPHAGS.js";
11
+ } from "./chunk-I25ZCHBJ.js";
12
+ import "./chunk-O3I3LTTJ.js";
13
+ import "./chunk-PMDHYIB4.js";
14
+ import "./chunk-O4DJIA6Y.js";
13
15
  import {
14
16
  BaseCollections
15
- } from "./chunk-SHRUJFQI.js";
17
+ } from "./chunk-KWQVA66H.js";
16
18
  import {
17
19
  getDatabaseClient
18
- } from "./chunk-GOKHFNB2.js";
20
+ } from "./chunk-Z7EH7CJC.js";
19
21
  import {
20
22
  apiService
21
- } from "./chunk-BMQFEKHA.js";
22
- import "./chunk-ANP5XF26.js";
23
- import "./chunk-7FS7BAUX.js";
24
- import "./chunk-Z6HOHGUJ.js";
25
- import "./chunk-EOTD7HAV.js";
26
- import "./chunk-USVU6AC2.js";
27
- import "./chunk-W7P6VTCG.js";
28
- import "./chunk-5D3T63G4.js";
23
+ } from "./chunk-U36HEOGO.js";
24
+ import "./chunk-MRZ5A7LB.js";
25
+ import "./chunk-CYIGEQOJ.js";
26
+ import "./chunk-4BMOCIYO.js";
27
+ import "./chunk-F6E7FJEC.js";
28
+ import "./chunk-DVA4NCCY.js";
29
+ import "./chunk-BIQFYZP6.js";
29
30
  import "./chunk-RE5Z56QD.js";
31
+ import "./chunk-4ORL4MST.js";
32
+ import "./chunk-KSY2GH53.js";
30
33
  import "./chunk-VUXPDHTQ.js";
31
34
  import {
32
35
  getAuthData
33
- } from "./chunk-42MIV6WF.js";
34
- import "./chunk-TR5U7G7T.js";
35
- import "./chunk-DWJMPHLY.js";
36
- import "./chunk-6BQHLHBE.js";
37
- import {
38
- publishRecordSchema
39
- } from "./chunk-BOCMOHQA.js";
40
- import "./chunk-4ORL4MST.js";
41
- import "./chunk-2KSOARE4.js";
36
+ } from "./chunk-ZMJW5UWU.js";
37
+ import "./chunk-7LUXRNKV.js";
42
38
  import {
43
39
  output,
44
40
  printTable
45
41
  } from "./chunk-T5HJUAWB.js";
46
- import "./chunk-4S3DGMMZ.js";
47
- import "./chunk-7PNOYE6B.js";
48
- import "./chunk-Q26DFKTY.js";
49
- import "./chunk-I57ID5K7.js";
42
+ import "./chunk-DUIMDHQQ.js";
43
+ import "./chunk-Y3CXAIAG.js";
44
+ import "./chunk-GXKNYM54.js";
45
+ import {
46
+ publishRecordSchema
47
+ } from "./chunk-RGJPENX7.js";
48
+ import "./chunk-5GZAGHKL.js";
49
+ import "./chunk-JBMHCTZD.js";
50
50
  import "./chunk-3MZYUBJ6.js";
51
51
 
52
52
  // src/domains/project/list/action.ts
@@ -1,34 +1,33 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  BaseCollections
4
- } from "./chunk-SHRUJFQI.js";
4
+ } from "./chunk-KWQVA66H.js";
5
5
  import {
6
6
  getDatabaseClient
7
- } from "./chunk-GOKHFNB2.js";
8
- import "./chunk-7FS7BAUX.js";
9
- import "./chunk-Z6HOHGUJ.js";
10
- import "./chunk-EOTD7HAV.js";
11
- import "./chunk-W7P6VTCG.js";
7
+ } from "./chunk-Z7EH7CJC.js";
8
+ import "./chunk-MRZ5A7LB.js";
9
+ import "./chunk-CYIGEQOJ.js";
10
+ import "./chunk-4BMOCIYO.js";
11
+ import "./chunk-DVA4NCCY.js";
12
12
  import "./chunk-RE5Z56QD.js";
13
+ import "./chunk-4ORL4MST.js";
14
+ import "./chunk-KSY2GH53.js";
13
15
  import "./chunk-VUXPDHTQ.js";
14
16
  import {
15
17
  getAuthData
16
- } from "./chunk-42MIV6WF.js";
17
- import "./chunk-TR5U7G7T.js";
18
- import "./chunk-DWJMPHLY.js";
19
- import {
20
- teamSchema
21
- } from "./chunk-6BQHLHBE.js";
22
- import "./chunk-BOCMOHQA.js";
23
- import "./chunk-4ORL4MST.js";
24
- import "./chunk-2KSOARE4.js";
18
+ } from "./chunk-ZMJW5UWU.js";
19
+ import "./chunk-7LUXRNKV.js";
25
20
  import {
26
21
  output
27
22
  } from "./chunk-T5HJUAWB.js";
28
- import "./chunk-4S3DGMMZ.js";
29
- import "./chunk-7PNOYE6B.js";
30
- import "./chunk-Q26DFKTY.js";
31
- import "./chunk-I57ID5K7.js";
23
+ import "./chunk-DUIMDHQQ.js";
24
+ import "./chunk-Y3CXAIAG.js";
25
+ import {
26
+ teamSchema
27
+ } from "./chunk-GXKNYM54.js";
28
+ import "./chunk-RGJPENX7.js";
29
+ import "./chunk-5GZAGHKL.js";
30
+ import "./chunk-JBMHCTZD.js";
32
31
  import "./chunk-3MZYUBJ6.js";
33
32
 
34
33
  // src/domains/auth/whoami/action.ts
@@ -2,36 +2,35 @@ import { createRequire as $$cR } from "node:module"; const require = $$cR(import
2
2
  import {
3
3
  createServerSession
4
4
  } from "./chunk-2I6V7AI3.js";
5
- import {
6
- watchFile
7
- } from "./chunk-RE5Z56QD.js";
8
- import "./chunk-VUXPDHTQ.js";
9
- import "./chunk-42MIV6WF.js";
10
- import "./chunk-TR5U7G7T.js";
11
- import "./chunk-DWJMPHLY.js";
12
- import "./chunk-6BQHLHBE.js";
13
- import "./chunk-BOCMOHQA.js";
14
5
  import {
15
6
  getFileOrUrl,
16
7
  loadOpenApiDocument,
17
8
  printSpecificationBanner
18
- } from "./chunk-RRYUCZYO.js";
9
+ } from "./chunk-WGTZEX4Y.js";
19
10
  import {
20
11
  isAsyncApiContent
21
- } from "./chunk-UM3WZUGF.js";
22
- import "./chunk-BY4NGQ5D.js";
23
- import "./chunk-E24BNP6E.js";
12
+ } from "./chunk-CWCRBWA6.js";
13
+ import "./chunk-A2MPF6GE.js";
14
+ import "./chunk-FDW4LC45.js";
15
+ import {
16
+ watchFile
17
+ } from "./chunk-RE5Z56QD.js";
24
18
  import {
25
19
  isUrl
26
20
  } from "./chunk-4ORL4MST.js";
27
- import "./chunk-2KSOARE4.js";
21
+ import "./chunk-KSY2GH53.js";
22
+ import "./chunk-VUXPDHTQ.js";
23
+ import "./chunk-ZMJW5UWU.js";
24
+ import "./chunk-7LUXRNKV.js";
28
25
  import {
29
26
  output
30
27
  } from "./chunk-T5HJUAWB.js";
31
- import "./chunk-4S3DGMMZ.js";
32
- import "./chunk-7PNOYE6B.js";
33
- import "./chunk-Q26DFKTY.js";
34
- import "./chunk-I57ID5K7.js";
28
+ import "./chunk-DUIMDHQQ.js";
29
+ import "./chunk-Y3CXAIAG.js";
30
+ import "./chunk-GXKNYM54.js";
31
+ import "./chunk-RGJPENX7.js";
32
+ import "./chunk-5GZAGHKL.js";
33
+ import "./chunk-JBMHCTZD.js";
35
34
  import "./chunk-3MZYUBJ6.js";
36
35
 
37
36
  // src/domains/document/mock/action.ts
@@ -122,7 +121,7 @@ function getMethodColor(method) {
122
121
  async function mockAction(fileArgument, { watch, port }) {
123
122
  const content = await getFileOrUrl(fileArgument);
124
123
  if (isAsyncApiContent(content)) {
125
- const { mockAsyncApi } = await import("./asyncapi-YBTWMTW6.js");
124
+ const { mockAsyncApi } = await import("./asyncapi-DVBS23QW.js");
126
125
  return mockAsyncApi(fileArgument, { watch, port });
127
126
  }
128
127
  const origin = isUrl(fileArgument) ? fileArgument : path2.resolve(fileArgument);
@@ -1,21 +1,21 @@
1
1
  import { createRequire as $$cR } from "node:module"; const require = $$cR(import.meta.url);
2
2
  import {
3
3
  getFileOrUrl
4
- } from "./chunk-RRYUCZYO.js";
5
- import "./chunk-UM3WZUGF.js";
6
- import "./chunk-BY4NGQ5D.js";
7
- import "./chunk-E24BNP6E.js";
4
+ } from "./chunk-WGTZEX4Y.js";
5
+ import "./chunk-CWCRBWA6.js";
6
+ import "./chunk-A2MPF6GE.js";
7
+ import "./chunk-FDW4LC45.js";
8
8
  import {
9
9
  isYamlFileName
10
10
  } from "./chunk-4ORL4MST.js";
11
- import "./chunk-2KSOARE4.js";
11
+ import "./chunk-KSY2GH53.js";
12
12
  import {
13
13
  output
14
14
  } from "./chunk-T5HJUAWB.js";
15
- import "./chunk-4S3DGMMZ.js";
16
- import "./chunk-7PNOYE6B.js";
17
- import "./chunk-Q26DFKTY.js";
18
- import "./chunk-I57ID5K7.js";
15
+ import "./chunk-DUIMDHQQ.js";
16
+ import "./chunk-Y3CXAIAG.js";
17
+ import "./chunk-5GZAGHKL.js";
18
+ import "./chunk-JBMHCTZD.js";
19
19
  import "./chunk-3MZYUBJ6.js";
20
20
 
21
21
  // src/domains/document/postman/action.ts