@redocly/cli 2.57.0 → 2.58.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 (139) hide show
  1. package/README.md +2 -0
  2. package/THIRD_PARTY_NOTICES +44 -22
  3. package/lib/chunks/2523PDUF.js +160 -0
  4. package/lib/chunks/{VBHLPG5Q.js → 252ZXXJ7.js} +1 -1
  5. package/lib/chunks/{XYKNLM5G.js → 2ERUBDSZ.js} +1 -1
  6. package/lib/chunks/{DMW5VJBT.js → 2LDRZLQD.js} +1 -1
  7. package/lib/chunks/{S5PUZGYS.js → 3QTDDZ3U.js} +1 -1
  8. package/lib/chunks/{ZVXAH4QD.js → 3RJ5Q24M.js} +1 -1
  9. package/lib/chunks/{J3DL5HGI.js → 3TNSVCBC.js} +1 -1
  10. package/lib/chunks/3TRGOJ74.js +9 -0
  11. package/lib/chunks/{X5NXRMUW.js → 46SNGFKM.js} +1 -1
  12. package/lib/chunks/4BCJL2BX.js +13 -0
  13. package/lib/chunks/5WKNTF7W.js +22 -0
  14. package/lib/chunks/{MZWBJKK2.js → 65C4QORD.js} +1 -1
  15. package/lib/chunks/{D7WNH6Z5.js → 6ESHHDEM.js} +1 -1
  16. package/lib/chunks/{YOBULQYM.js → 6G6YWZOW.js} +1 -1
  17. package/lib/chunks/{UXFJO2OQ.js → 6HHP5O4K.js} +1 -1
  18. package/lib/chunks/{JMFIKCPX.js → 6XXDGMQI.js} +1 -1
  19. package/lib/chunks/{YDVOCOBI.js → 7BM3QKWP.js} +1 -1
  20. package/lib/chunks/{GEWI247R.js → 7HX6H6PZ.js} +1 -1
  21. package/lib/chunks/{H5OX3UOD.js → 7KZRKMQI.js} +1 -1
  22. package/lib/chunks/{3QGJWJKQ.js → ABUS6H76.js} +1 -1
  23. package/lib/chunks/{EDU3YBRA.js → BNAH4YGC.js} +1 -1
  24. package/lib/chunks/{7EB22KXX.js → BZNIB4HL.js} +1 -1
  25. package/lib/chunks/{AOCVSFC3.js → C6B5SYPM.js} +1 -1
  26. package/lib/chunks/{7XKYPQPI.js → D2IJWX6B.js} +1 -1
  27. package/lib/chunks/{LI6IH6DJ.js → DVJIGHFR.js} +1 -1
  28. package/lib/chunks/{CWEET26O.js → EPFKYDYC.js} +1 -1
  29. package/lib/chunks/ERFOEXTV.js +9 -0
  30. package/lib/chunks/{R2FG6TUX.js → FBHTM4LH.js} +1 -1
  31. package/lib/chunks/{5FVKAWNE.js → FIMSBOF2.js} +1 -1
  32. package/lib/chunks/{ZFJHZEI3.js → GDFQSHUE.js} +1 -1
  33. package/lib/chunks/H4VN2RX3.js +7 -0
  34. package/lib/chunks/{ZBOUASE7.js → H7Z35EAH.js} +1 -1
  35. package/lib/chunks/JF6HX6A6.js +7 -0
  36. package/lib/chunks/{FDOONAMV.js → JPHYX7OV.js} +1 -1
  37. package/lib/chunks/{SRCGYHDN.js → JXAUEF5V.js} +1 -1
  38. package/lib/chunks/{4HG5PCQA.js → LIAO3NFX.js} +1 -1
  39. package/lib/chunks/{LUW2ZJJO.js → LWTH3K75.js} +1 -1
  40. package/lib/chunks/{VIPV4IEH.js → M4JX2FBY.js} +1 -1
  41. package/lib/chunks/ML6MFXCA.js +7 -0
  42. package/lib/chunks/{M4YE5ALG.js → MT5H2R3P.js} +81 -81
  43. package/lib/chunks/{GHOLYNZA.js → MWJGFN4Y.js} +1 -1
  44. package/lib/chunks/N6VRECSO.js +34 -0
  45. package/lib/chunks/{65AQJO4M.js → NRU2WFMW.js} +2 -2
  46. package/lib/chunks/NSNQAVBA.js +17 -0
  47. package/lib/chunks/{N2GTHB37.js → NYQDTPTE.js} +1 -1
  48. package/lib/chunks/OJE7THLM.js +31 -0
  49. package/lib/chunks/{F5V42ZYY.js → OQ2G774U.js} +1 -1
  50. package/lib/chunks/{F57WBWGV.js → PB256IKB.js} +2 -2
  51. package/lib/chunks/{OR3KBRCI.js → PWVCTNVT.js} +1 -1
  52. package/lib/chunks/{4SXCDBB7.js → PZEYEOIF.js} +1 -1
  53. package/lib/chunks/{4JBK2BSL.js → QXUO5IQJ.js} +1 -1
  54. package/lib/chunks/{DT66L2TO.js → QZJD7SST.js} +1 -1
  55. package/lib/chunks/{GVJFU4AP.js → R5A3H7N2.js} +1 -1
  56. package/lib/chunks/{YMDFCK3F.js → ROE2PM62.js} +1 -1
  57. package/lib/chunks/{VE7VT5PT.js → RREAI5RF.js} +1 -1
  58. package/lib/chunks/{QDSAT32N.js → SXYE4UNQ.js} +1 -1
  59. package/lib/chunks/T2G7FRCU.js +23 -0
  60. package/lib/chunks/{664FDTDV.js → T6HGKHGP.js} +1 -1
  61. package/lib/chunks/{YEACSN2C.js → TAEOWXJJ.js} +1 -1
  62. package/lib/chunks/{Y2AFRRAT.js → TTWBJ74O.js} +1 -1
  63. package/lib/chunks/U4WMP25Y.js +7 -0
  64. package/lib/chunks/{5UDC2SWY.js → V34PUN4E.js} +1 -1
  65. package/lib/chunks/{IDI3SURO.js → VNSAGJ2H.js} +1 -1
  66. package/lib/chunks/{VT3BHT6S.js → WFGS4GSF.js} +3 -3
  67. package/lib/chunks/{NALRPITK.js → WSDNWUOV.js} +1 -1
  68. package/lib/chunks/{P7A7BCIN.js → X5U3XCIW.js} +1 -1
  69. package/lib/chunks/XARQ5LTM.js +15 -0
  70. package/lib/chunks/{WKCOTH3C.js → YFBPBQ7G.js} +1 -1
  71. package/lib/chunks/{52MXI4PU.js → YLFY2DKU.js} +1 -1
  72. package/lib/chunks/{VUU57INZ.js → YMMEOUYX.js} +1 -1
  73. package/lib/chunks/{XTTR5PBC.js → YPT2KQ2K.js} +1 -1
  74. package/lib/chunks/{MKS4O6F4.js → YTAL3SI4.js} +2 -2
  75. package/lib/chunks/index.aff +205 -0
  76. package/lib/chunks/index.dic +49569 -0
  77. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  78. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  79. package/lib/eject-assets/generators/cli/index.ts +2 -2
  80. package/lib/eject-assets/generators/cli/render.ts +1 -1
  81. package/lib/eject-assets/generators/go/client.ts +1 -1
  82. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  83. package/lib/eject-assets/generators/go/index.ts +2 -2
  84. package/lib/eject-assets/generators/go/models.ts +1 -1
  85. package/lib/eject-assets/generators/go/naming.ts +1 -1
  86. package/lib/eject-assets/generators/go/operations.ts +1 -1
  87. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  88. package/lib/eject-assets/generators/go/types.ts +1 -1
  89. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  90. package/lib/eject-assets/generators/mock/index.ts +2 -2
  91. package/lib/eject-assets/generators/mock/render.ts +1 -1
  92. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  93. package/lib/eject-assets/generators/mock/values.ts +1 -1
  94. package/lib/eject-assets/generators/php/client.ts +1 -1
  95. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  96. package/lib/eject-assets/generators/php/index.ts +2 -2
  97. package/lib/eject-assets/generators/php/models.ts +1 -1
  98. package/lib/eject-assets/generators/php/naming.ts +1 -1
  99. package/lib/eject-assets/generators/php/operations.ts +1 -1
  100. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  101. package/lib/eject-assets/generators/php/types.ts +1 -1
  102. package/lib/eject-assets/generators/python/client.ts +1 -1
  103. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  104. package/lib/eject-assets/generators/python/index.ts +2 -2
  105. package/lib/eject-assets/generators/python/models.ts +1 -1
  106. package/lib/eject-assets/generators/python/naming.ts +1 -1
  107. package/lib/eject-assets/generators/python/operations.ts +1 -1
  108. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  109. package/lib/eject-assets/generators/python/types.ts +1 -1
  110. package/lib/eject-assets/generators/swr/index.ts +2 -2
  111. package/lib/eject-assets/generators/swr/render.ts +1 -1
  112. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  113. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  114. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  115. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  116. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  117. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  118. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  119. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  120. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  121. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  122. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  123. package/lib/eject-assets/generators/typescript/operations.ts +1 -1
  124. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  125. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  126. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  127. package/lib/eject-assets/generators/zod/index.ts +2 -2
  128. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  129. package/lib/index.js +66 -61
  130. package/package.json +1 -1
  131. package/lib/chunks/2PGNW76R.js +0 -11
  132. package/lib/chunks/3I7XLHPY.js +0 -45
  133. package/lib/chunks/ARDTVDGR.js +0 -22
  134. package/lib/chunks/K2ENYHHD.js +0 -7
  135. package/lib/chunks/LJPUHAWE.js +0 -13
  136. package/lib/chunks/OM4VGI2Q.js +0 -9
  137. package/lib/chunks/VYHYEZI5.js +0 -7
  138. package/lib/chunks/YFI3NLJF.js +0 -9
  139. package/lib/chunks/YUNIBLZR.js +0 -30
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as c}from"./DT66L2TO.js";import{h as s,l as a}from"./OM4VGI2Q.js";import"./LRUXN6H5.js";import{P as t,X as e,ca as i}from"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function y({argv:r,config:l,version:d}){let o=s(l,r.residency);try{let n=new a(d);r.verbose&&(e.info(`OAuth client initialized.
7
+ import{a as c}from"./QZJD7SST.js";import{h as s,l as a}from"./3TRGOJ74.js";import"./LRUXN6H5.js";import{_ as t,ga as e,ma as i}from"./MT5H2R3P.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function y({argv:r,config:l,version:d}){let o=s(l,r.residency);try{let n=new a(d);r.verbose&&(e.info(`OAuth client initialized.
8
8
  `),e.info(`Local credentials file path: ${n.credentialsFilePath}
9
9
  `)),await n.login(o,c),e.output(t(`\u2705 Logged in
10
10
 
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{X as r}from"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as p}from"node:child_process";var u=async({argv:n})=>{r.info(`
7
+ import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{ga as r}from"./MT5H2R3P.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as p}from"node:child_process";var u=async({argv:n})=>{r.info(`
8
8
  Launching translate using NPX.
9
9
 
10
10
  `);let{npxExecutableName:s,sanitize:a,shell:i}=e(),l=a(n["project-dir"],o),c=a(n.locale,t);p(s,["-y","@redocly/realm","translate",c,`-d=${l}`],{stdio:"inherit",shell:i}).on("error",m=>{throw r.info(`Translate launch failed: ${m.message}`),new Error("Translate launch failed.")})};export{u as handleTranslations};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as O}from"./2U6O26CV.js";import{b as j,c as N,d as J,f as V,g as Q,h as Z,i as Y}from"./VIPV4IEH.js";import{a as H}from"./WZXA5XPB.js";import{a as F,b as T,c as C,d as P,e as W,g as B,h as M,i as _,j as A,k as z,l as U,n as K}from"./UW4UC7ZI.js";var G=C.go,S=class extends F{constructor(){super(" ")}typeName(t){return d(t)}memberName(t){return d(t)}identifier(t){return P(t,{style:"camel",reserved:G})}identifiers(t,n){let r=new Set(n??[]);return t.map(o=>{let s=d(o),a=s;for(let i=2;r.has(a);i++)a=`${s}${i}`;return r.add(a),a})}packageName(t){let n=t.toLowerCase().replace(/[^a-z0-9]/g,"");return n===""||/^[0-9]/.test(n)?"client":n}string(t){let n='"';for(let r of t){let o=r.codePointAt(0);r==="\\"?n+="\\\\":r==='"'?n+='\\"':r===`
7
+ import{a as O}from"./2U6O26CV.js";import{b as j,c as N,d as J,f as V,g as Q,h as Z,i as Y}from"./M4JX2FBY.js";import{a as H}from"./WZXA5XPB.js";import{a as F,b as T,c as C,d as P,e as W,g as B,h as M,i as _,j as A,k as z,l as U,n as K}from"./UW4UC7ZI.js";var G=C.go,S=class extends F{constructor(){super(" ")}typeName(t){return d(t)}memberName(t){return d(t)}identifier(t){return P(t,{style:"camel",reserved:G})}identifiers(t,n){let r=new Set(n??[]);return t.map(o=>{let s=d(o),a=s;for(let i=2;r.has(a);i++)a=`${s}${i}`;return r.add(a),a})}packageName(t){let n=t.toLowerCase().replace(/[^a-z0-9]/g,"");return n===""||/^[0-9]/.test(n)?"client":n}string(t){let n='"';for(let r of t){let o=r.codePointAt(0);r==="\\"?n+="\\\\":r==='"'?n+='\\"':r===`
8
8
  `?n+="\\n":r==="\r"?n+="\\r":r===" "?n+="\\t":o<32||o===127?n+=`\\x${o.toString(16).padStart(2,"0")}`:o>=55296&&o<=57343?n+="\\uFFFD":n+=r}return n+'"'}literal(t){return t==null?"nil":typeof t=="boolean"||typeof t=="number"?String(t):typeof t=="string"?this.string(t):Array.isArray(t)?`[]any{${t.map(r=>this.literal(r)).join(", ")}}`:`map[string]any{${Object.entries(t).map(([r,o])=>`${this.string(r)}: ${this.literal(o)}`).join(", ")}}`}comment(t){for(let n of U(t))this.line(n===""?"//":`// ${n}`);return this}doc(t,n){let r=U(n);if(r.length===0)return this;this.line(`// ${t} \u2014 ${r[0]}`);let o=!1;for(let s of r.slice(1)){if(s===""){o||this.line("//"),o=!0;continue}this.line(`// ${s}`),o=!1}return this}layout(t){return ie(le(t))}toString(){return this.layout(super.toString())}};function d(e){let t=P(e,{style:"pascal",reserved:G});return t.startsWith("_")?`N${t.slice(1)}`:t}function ie(e){return`${e.replace(/\n{3,}/g,`
9
9
 
10
10
  `).trimEnd()}
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{b as a,c as b,d as c}from"./Y2AFRRAT.js";import"./2U6O26CV.js";import"./J3DL5HGI.js";import"./JMFIKCPX.js";import"./VIPV4IEH.js";import"./65AQJO4M.js";import"./WZXA5XPB.js";import"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as cliDocs,a as cliGenerator,c as cliSample};
7
+ import{b as a,c as b,d as c}from"./TTWBJ74O.js";import"./2U6O26CV.js";import"./3TNSVCBC.js";import"./6XXDGMQI.js";import"./M4JX2FBY.js";import"./NRU2WFMW.js";import"./WZXA5XPB.js";import"./MT5H2R3P.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as cliDocs,a as cliGenerator,c as cliSample};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as C}from"./65AQJO4M.js";import{c as w}from"./M4YE5ALG.js";import{a as H,e as q,g as P,h as g,k as E}from"./LD5MEXEL.js";import{join as ae}from"node:path";var j=class{code;constructor(r){this.code=r}};function A(e,r,n={}){let t=new Map(r.map(s=>[s.name,s.schema])),o=k(e,t,new Set,n.dateType??"string");return o===b?null:o}var b=Symbol("cycle");function J(e,r){if(e.kind==="union"){for(let t of e.members){let o=J(t,r);if(o)return o}return}if(e.kind!=="scalar")return;let n=e.metadata?.format;if(n==="binary")return new j("new Blob([])");if(r==="Date"){if(n==="date-time")return new j('new Date("2024-01-01T00:00:00Z")');if(n==="date")return new j('new Date("2024-01-01")')}}function I(e,r){let n=new Map,t=[],o=!1;for(let s of e){if(s.kind==="unknown")continue;let i=G(s,r);if(i?.kind!=="object"){t.push(s);continue}o=!0;for(let a of i.properties){let u=O(a.schema,r,new Set),c=n.get(a.name);(c===void 0||u>=c.rank)&&n.set(a.name,{schema:a.schema,required:a.required||(c?.required??!1),rank:u})}}return o?{merged:{kind:"object",properties:[...n.entries()].map(([s,i])=>({name:s,schema:i.schema,required:i.required}))},rest:t}:{merged:void 0,rest:t}}function G(e,r){let n=new Set,t=e;for(;t?.kind==="ref";){if(n.has(t.name))return;n.add(t.name),t=r.get(t.name)}return t}function O(e,r,n){switch(e.kind){case"literal":return 40;case"enum":return e.values.length===1?40:30;case"union":return Math.max(0,...e.members.map(t=>O(t,r,n)))-1;case"ref":{if(n.has(e.name))return 20;let t=r.get(e.name);return t===void 0?20:O(t,r,new Set(n).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,r,n,t){let o=J(e,t);if(o)return o;let s=e.metadata,i=a=>a===null?e.kind==="null"||e.kind==="union"&&e.members.some(u=>u.kind==="null"):e.kind==="enum"?e.values.includes(a):e.kind==="literal"?a===e.value:!0;if(s?.example!==void 0&&i(s.example))return s.example;if(s?.default!==void 0&&i(s.default))return s.default;switch(e.kind){case"scalar":return K(e.scalar,s);case"array":{let a=k(e.items,r,n,t);return a===b?[]:[a]}case"object":return Object.fromEntries(e.properties.flatMap(a=>{let u=k(a.schema,r,n,t);return u===b?a.required?[[a.name,null]]:[]:[[a.name,u]]}));case"record":{let a=k(e.value,r,n,t);return a===b?{}:{key:a}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let a of e.members){let u=k(a,r,n,t);if(u!==b)return u}return e.members.length>0?b:null}case"intersection":{let{merged:a,rest:u}=I(e.members,r),c=u.map(m=>k(m,r,n,t)).filter(m=>m!==b);if(a){let m=k(a,r,n,t),M=w(m)?m:{};for(let V of c)w(V)&&Object.assign(M,V);return M}let h=c.filter(w);return h.length>0?h.reduce((m,M)=>Object.assign(m,M),{}):c.length>0?c[0]:{}}case"omit":{let a=r.get(e.base);if(!a)return null;let u=k(a,r,n,t);if(w(u)){let c={...u};for(let h of e.keys)delete c[h];return c}return u}case"ref":{if(n.has(e.name))return b;let a=r.get(e.name);if(!a)return null;n.add(e.name);let u=k(a,r,n,t);return n.delete(e.name),u}case"null":case"unknown":return null}}function K(e,r){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(r?.format){case"email":return"user@example.com";case"uuid":return"00000000-0000-4000-8000-000000000000";case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"uri":case"url":return"https://example.com";default:return"string"}}var f=e=>({kind:"expr",text:e}),d=e=>({kind:"object",entries:e});function l(e){return e.kind==="object"}function D(e,r){return l(e)?d([...e.entries,{spread:r}]):e}var L=" ";function x(e,r){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${x(e.value,r)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let n=r+L;return`[
7
+ import{a as C}from"./NRU2WFMW.js";import{c as w}from"./MT5H2R3P.js";import{a as H,e as q,g as P,h as g,k as E}from"./LD5MEXEL.js";import{join as ae}from"node:path";var j=class{code;constructor(r){this.code=r}};function A(e,r,n={}){let t=new Map(r.map(s=>[s.name,s.schema])),o=k(e,t,new Set,n.dateType??"string");return o===b?null:o}var b=Symbol("cycle");function J(e,r){if(e.kind==="union"){for(let t of e.members){let o=J(t,r);if(o)return o}return}if(e.kind!=="scalar")return;let n=e.metadata?.format;if(n==="binary")return new j("new Blob([])");if(r==="Date"){if(n==="date-time")return new j('new Date("2024-01-01T00:00:00Z")');if(n==="date")return new j('new Date("2024-01-01")')}}function I(e,r){let n=new Map,t=[],o=!1;for(let s of e){if(s.kind==="unknown")continue;let i=G(s,r);if(i?.kind!=="object"){t.push(s);continue}o=!0;for(let a of i.properties){let u=O(a.schema,r,new Set),c=n.get(a.name);(c===void 0||u>=c.rank)&&n.set(a.name,{schema:a.schema,required:a.required||(c?.required??!1),rank:u})}}return o?{merged:{kind:"object",properties:[...n.entries()].map(([s,i])=>({name:s,schema:i.schema,required:i.required}))},rest:t}:{merged:void 0,rest:t}}function G(e,r){let n=new Set,t=e;for(;t?.kind==="ref";){if(n.has(t.name))return;n.add(t.name),t=r.get(t.name)}return t}function O(e,r,n){switch(e.kind){case"literal":return 40;case"enum":return e.values.length===1?40:30;case"union":return Math.max(0,...e.members.map(t=>O(t,r,n)))-1;case"ref":{if(n.has(e.name))return 20;let t=r.get(e.name);return t===void 0?20:O(t,r,new Set(n).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,r,n,t){let o=J(e,t);if(o)return o;let s=e.metadata,i=a=>a===null?e.kind==="null"||e.kind==="union"&&e.members.some(u=>u.kind==="null"):e.kind==="enum"?e.values.includes(a):e.kind==="literal"?a===e.value:!0;if(s?.example!==void 0&&i(s.example))return s.example;if(s?.default!==void 0&&i(s.default))return s.default;switch(e.kind){case"scalar":return K(e.scalar,s);case"array":{let a=k(e.items,r,n,t);return a===b?[]:[a]}case"object":return Object.fromEntries(e.properties.flatMap(a=>{let u=k(a.schema,r,n,t);return u===b?a.required?[[a.name,null]]:[]:[[a.name,u]]}));case"record":{let a=k(e.value,r,n,t);return a===b?{}:{key:a}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let a of e.members){let u=k(a,r,n,t);if(u!==b)return u}return e.members.length>0?b:null}case"intersection":{let{merged:a,rest:u}=I(e.members,r),c=u.map(m=>k(m,r,n,t)).filter(m=>m!==b);if(a){let m=k(a,r,n,t),M=w(m)?m:{};for(let V of c)w(V)&&Object.assign(M,V);return M}let h=c.filter(w);return h.length>0?h.reduce((m,M)=>Object.assign(m,M),{}):c.length>0?c[0]:{}}case"omit":{let a=r.get(e.base);if(!a)return null;let u=k(a,r,n,t);if(w(u)){let c={...u};for(let h of e.keys)delete c[h];return c}return u}case"ref":{if(n.has(e.name))return b;let a=r.get(e.name);if(!a)return null;n.add(e.name);let u=k(a,r,n,t);return n.delete(e.name),u}case"null":case"unknown":return null}}function K(e,r){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(r?.format){case"email":return"user@example.com";case"uuid":return"00000000-0000-4000-8000-000000000000";case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"uri":case"url":return"https://example.com";default:return"string"}}var f=e=>({kind:"expr",text:e}),d=e=>({kind:"object",entries:e});function l(e){return e.kind==="object"}function D(e,r){return l(e)?d([...e.entries,{spread:r}]):e}var L=" ";function x(e,r){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${x(e.value,r)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let n=r+L;return`[
8
8
  ${e.items.map((o,s)=>`${n}${x(o,n)}${s===e.items.length-1?"":","}`).join(`
9
9
  `)}
10
10
  ${r}]`}case"object":{if(e.entries.length===0)return"{}";let n=r+L;return`{
@@ -4,6 +4,6 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a}from"./JMFIKCPX.js";import{X as p}from"./M4YE5ALG.js";function g(t,r){let n=t.services.flatMap(e=>e.operations),s=n.filter(e=>e.sse!==void 0);s.length>0&&p.warn(`generate-client: ${r} skipped ${s.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${s.map(e=>e.name).join(", ")}.
7
+ import{a}from"./6XXDGMQI.js";import{ga as p}from"./MT5H2R3P.js";function g(t,r){let n=t.services.flatMap(e=>e.operations),s=n.filter(e=>e.sse!==void 0);s.length>0&&p.warn(`generate-client: ${r} skipped ${s.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${s.map(e=>e.name).join(", ")}.
8
8
  `);let i=new Set(t.schemas.map(e=>e.name)),o=n.filter(e=>e.sse===void 0&&m(e,i));return o.length>0&&p.warn(`generate-client: ${r} skipped ${o.length} operation(s) whose variables type name collides with a schema \u2014 rename the schema or the operation: ${o.map(e=>e.name).join(", ")}.
9
9
  `),n.filter(e=>e.sse===void 0&&!m(e,i))}function m(t,r){let n=a(t);return n.hasInputs&&r.has(n.variablesTypeName)}function x(t){return t.method==="get"||t.method==="head"}function u(t){return a(t).hasInputs}function f(t){return a(t).variablesTypeName}function $(t,r,n){let s=[];return a(t).hasInputs?s.push(r):n&&s.push("{}"),n&&s.push("{ ...init, envelope: undefined }"),`${t.name}(${s.join(", ")})`}function v(t,r,n){let s=t.map(e=>e.name).sort(),i=t.filter(u).map(f).sort();return n&&i.push("RequestOptions"),`import { ${[...s,...i.map(e=>`type ${e}`)].join(", ")} } from ${JSON.stringify(r)};`}export{g as a,x as b,u as c,f as d,$ as e,v as f};
@@ -0,0 +1,9 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as ue}from"./LRUXN6H5.js";import{j as b,l as A,ma as m,o as z,p as H,ra as q,ya as Y}from"./MT5H2R3P.js";import{e as ce}from"./RFWIIJFG.js";var S=ce(ue(),1);function V(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function K(n){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(o=>o.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(n).hostname.toLowerCase()}catch{return!1}return e.some(o=>!!(o==="*"||r===o||o.startsWith(".")&&r.endsWith(o)||!o.startsWith(".")&&r.endsWith("."+o)))}var G=async(n,{timeout:t,...e}={})=>{let r=V(),o=r&&!K(n),s,i=t?{connect:{timeout:t}}:{};return o?s=new S.ProxyAgent({uri:r,...i}):t&&(s=new S.Agent(i)),await fetch(n,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:s})};var le=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function X(){let n=process.env.REDOCLY_ENVIRONMENT?.trim();return n&&le.test(n)?n:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},T=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=X(),o={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let s=await G(t,{...e,headers:o});return this.collectSunsetWarning(s),s}catch(s){let i="Failed to fetch.";throw s.cause&&(i+=` Caused by ${s.cause.message||s.cause.name}.`),(s.code||s.cause?.code)&&(i+=` Code: ${s.code||s.cause?.code}`),new Error(i)}}collectSunsetWarning(t){let e=this.getSunsetDate(t);if(!e)return;let r=new Date(e);e>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(t){let{headers:e}=t;if(!e)return;let r=e.get("sunset")||e.get("Sunset");if(r)return Date.parse(r)}},U=class{client;domain;apiKey;constructor(t,e,r){this.client=t,this.domain=e,this.apiKey=r}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},N=class extends U{async find(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return r.status===404?void 0:await this.getParsedResponse(r)}catch(r){let o=`Failed to fetch project. ${r.message}`;throw r instanceof u?new u(o,r.status):new Error(o)}}},j=class extends U{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/source`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return(await this.getParsedResponse(r)).branchName}catch(r){let o=`Failed to fetch default branch. ${r.message}`;throw r instanceof u?new u(o,r.status):new Error(o)}}async upsert(t,e,r){try{let o=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes`,{timeout:6e3,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(o)}catch(o){let s=`Failed to upsert remote. ${o.message}`;throw o instanceof u?new u(s,o.status):new Error(s)}}async push(t,e,r,o){let s=new globalThis.FormData;s.append("remoteId",r.remoteId),s.append("commit[message]",r.commit.message),s.append("commit[author][name]",r.commit.author.name),s.append("commit[author][email]",r.commit.author.email),s.append("commit[branchName]",r.commit.branchName),r.commit.url&&s.append("commit[url]",r.commit.url),r.commit.namespace&&s.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&s.append("commit[sha]",r.commit.sha),r.commit.repository&&s.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&s.append("commit[createdAt]",r.commit.createdAt);for(let i of o){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await de(i.stream)]);s.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&s.append("isMainBranch","true"),r.replace&&s.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:s});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getPush({organizationId:t,projectId:e,pushId:r}){try{let o=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes/${r}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(o)}catch(o){let s=`Failed to get push status. ${o.message}`;throw o instanceof u?new u(s,o.status):new Error(s)}}},g=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:o}){this.apiClient=new T(r,o),this.projects=new N(this.apiClient,t,e),this.remotes=new j(this.apiClient,t,e)}getSunsetWarning(){return Z(this.apiClient.sunsetWarnings)}};function Z(n){let[t]=[...n].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function de(n){let t=[];for await(let e of n)t.push(e);return Buffer.concat(t)}function he(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var P={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function fe(){return process.env.REDOCLY_DOMAIN||P.us}var J=pe((n,t)=>{try{let e=t||n?.resolvedConfig.residency;return me(e)?P[e]:e?new URL(e).origin:n?.resolvedConfig.scorecard?.fromProjectUrl?new URL(n.resolvedConfig.scorecard.fromProjectUrl).origin:P.us}catch{throw new E}});function D(n){try{J(void 0,n)}catch{return!1}return!0}function pe(n){return(...t)=>{let e=n(...t);if(!e.startsWith("https://"))throw new E;return e}}var E=class extends Error{constructor(){super("Invalid Reunite URL")}};function me(n){return typeof n=="string"&&n in P}import{Buffer as O}from"node:buffer";import F from"node:crypto";import{mkdirSync as ge,existsSync as ee,writeFileSync as we,readFileSync as ye,rmSync as ve}from"node:fs";import{homedir as Te}from"node:os";import te from"node:path";import*as Q from"node:child_process";var w=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new T("login",e)}async run(t){let e=await this.getDeviceCode();t?.({verificationUri:e.verificationUri,verificationUriComplete:e.verificationUriComplete,userCode:e.userCode}),this.openBrowser(e.verificationUriComplete);let r=await this.pollingAccessToken(e.deviceCode,e.interval,e.expiresIn);return this.withResidency(r)}openBrowser(t){if(!/^https?:\/\//.test(t))return;let[e,r]=process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:process.platform==="darwin"?["open",[t]]:["xdg-open",[t]];Q.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((o,s)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),o(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),s(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),s("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:o,interval:s=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:o,interval:s,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,o={}){let s=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(s,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...o},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var xe="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",re="aes-256-cbc",k=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Te();this.credentialsFolderPath=te.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=te.join(this.credentialsFolderPath,this.credentialsFileName),this.key=F.createHash("sha256").update(`${this.credentialsFolderPath}${xe}`).digest(),this.iv=F.createHash("md5").update(this.credentialsFolderPath).digest(),ge(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let o=await new w(t,this.version).run(e);if(!o)throw new Error("Failed to login. No credentials received.");await this.saveCredentials(o)}async logout(){try{this.removeCredentials()}catch{}}async isAuthorized(t,e){return e?new w(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new w(t,this.version),r=await this.readCredentials();if(!r||!D(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let s=await e.refreshToken(r.refresh_token);return await this.saveCredentials(s),s.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);we(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!ee(this.credentialsFilePath))return null;try{let t=ye(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){ee(this.credentialsFilePath)&&ve(this.credentialsFilePath)}encryptCredentials(t){let e=F.createCipheriv(re,this.key,this.iv);return O.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=F.createDecipheriv(re,this.key,this.iv),r=O.concat([e.update(O.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as y from"node:fs";import*as h from"node:path";var Ce=/\/orgs\/([^/]+)\/projects\//,Pe=[401,403];async function x(n,{organization:t,project:e,onSlugDeprecated:r}){let o=await Ee(n,t,e);if(!o)return{organizationId:t,projectId:e};let s={organizationId:Re(o.uri),projectId:o.id};return(s.organizationId!==t||s.projectId!==e)&&r?.(s),s}async function Ee(n,t,e){try{let r=await n.projects.find(t,e);if(!r)throw new u(`Project "${e}" was not found in organization "${t}". Use the IDs from the organization and project settings in Reunite.`,404);return r}catch(r){if(r instanceof u&&Pe.includes(r.status))return;throw r}}function Re(n){let t=n.match(Ce)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${n}".`);return t}async function $e({domain:n,apiKey:t,organization:e,project:r,mountPath:o,files:s,defaultBranch:i,commit:a,version:c,replace:R,onUploadStart:$,onSunsetWarning:v,onSlugDeprecated:I}){let f=new g({domain:n,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await x(f,{organization:e,project:r,onSlugDeprecated:I}),M=await f.remotes.getDefaultBranch(d,l),p=await f.remotes.upsert(d,l,{mountBranchName:M,mountPath:o});$?.(p);let{id:C}=await f.remotes.push(d,l,{remoteId:p.id,commit:a,isMainBranch:i===a.branchName,replace:R},s.map(W=>({path:z(W.name),stream:y.createReadStream(W.path)})));return{pushId:C,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&v?.(d)}}function Se(n,t){let e={};for(let o of n)if(y.statSync(o).isDirectory()){let s=o;ne(s,[]).forEach(a=>r(a,s))}else r(o,h.dirname(o));function r(o,s){let i=h.relative(s,o);e[i]&&t?.(e[i],o),e[i]=o}return Object.entries(e).map(([o,s])=>({name:o,path:h.resolve(s)}))}function ne(n,t){let e=y.readdirSync(n);for(let r of e){let o=h.join(n,r);y.statSync(o).isDirectory()?t=ne(o,t):t.push(o)}return t}async function se({operation:n,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:o=6e5,retryIntervalMs:s=5e3}){async function i(){let a=await n();if(t(a))return a;if(Date.now()-r>o)throw new Error("Timeout exceeded.");return await e?.(a),await b(s),i()}return i()}var _e=1200,Ue=5e3,Fe=["pending","running"];async function Ie(n){let t=oe(n);try{let e=await x(t,n);return await ae(t,e,n.pushId)}finally{ie(t,n)}}async function Ae({buildType:n,maxExecutionTime:t=_e,retryIntervalMs:e=Ue,startTime:r=Date.now(),onRetry:o,...s}){let i=oe(s);try{let a=await x(i,s);return await se({operation:()=>ae(i,a,s.pushId),condition:c=>!Fe.includes(c.status[n].deploy.status),onConditionNotMet:o,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ie(i,s)}}function oe({domain:n,apiKey:t,version:e}){return new g({domain:n,apiKey:t,command:"push-status",version:e})}function ie(n,{onSunsetWarning:t}){let e=n.getSunsetWarning();e&&t?.(e)}function ae(n,{organizationId:t,projectId:e},r){return n.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function Ne({projectUrl:n,auth:t,isApiKey:e=!1,onDebug:r}){let o=je(n);if(!o)throw new m(`Invalid project URL format: ${n}`);try{let s=await De({...o,auth:t,isApiKey:e,onDebug:r}),i=s.config.scorecardClassic||s.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=s.config.pluginsUrl,c=a?await Oe(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(s){throw new m(s instanceof Error?s.message:String(s))}}function je(n){let t=new URL(n),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:o}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:o}}async function De({residency:n,orgSlug:t,projectSlug:e,auth:r,isApiKey:o,onDebug:s}){let i=new URL(`${n}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:ke(r,o)});if(s?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw s?.(`Authentication failed with status ${a.status}.`),s?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return s?.("Successfully received project configuration."),a.json()}async function Oe(n,t){t?.(`Fetching plugins from: ${n}`);try{let e=await fetch(n);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function ke(n,t){return t?{Authorization:`Bearer ${n}`}:{Cookie:`accessToken=${n}`}}async function L(n,t,e=[],r=[],o){let s={};for(let i of e){let a={[i.name]:{root:n,rules:t}},c=await q({apis:a,...i,plugins:r},{configPath:o});s[i.name]=c.forAlias(i.name)}return s}function B(n,t){if(n){for(let e of n)if(Object.entries(e.where?.metadata||{}).every(([o,s])=>Le(o,s,t)))return e}}function Le(n,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[n])return!1;let[r,o]=t.split("/"),s=new Date(e[n]);return!(s<new Date(r)||o&&s>new Date(o))}else if(t.match(/^\/.*\//)){if(!e[n])return!1;try{return H(t).test(e[n])}catch{throw new m(`Invalid regex in scorecard target "${n}": ${t}`)}}return e[n]===t}import{pathToFileURL as Be}from"node:url";async function Me(n,t){if(!n)return[];let e=Be(t??process.cwd()).href+"/",r=n.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var We=".redocly.com";function be(n){try{return new URL(n).hostname.toLowerCase().endsWith(We)}catch{return!1}}async function ze({apiPath:n,document:t,externalRefResolver:e,scorecardConfig:r,configPath:o,plugins:s=[],targetLevel:i,metadata:a={},onDebug:c}){let R=[],$=new Map,v=r.levels||[];if(i&&!v.some(l=>l.name===i))throw new m(`Target level "${i}" not found in the scorecard configuration levels.
8
+ `);let I=B(r.targets,a)?.rules,f=await L(n,I,v,s,o||"");for(let l of v){c?.(`
9
+ Validating level: "${l.name}"`),s.length>0&&c?.(`Using ${s.length} ${A("plugin",s.length)} for this level.`),c?.("Linting document against level rules...");let p=(await Y({document:t,externalRefResolver:e,config:f[l.name]})).filter(({ignored:C})=>!C).map(C=>({...C,scorecardLevel:l.name}));c?.(`Found ${p.length} ${A("problem",p.length)} for level "${l.name}".`),$.set(l.name,p),R.push(...p)}let d=He($,v,i);return{problems:R,achievedLevel:d,targetLevelAchieved:i?d===i:!0}}function He(n,t,e){let r=null;for(let o of t){if((n.get(o.name)||[]).some(a=>a.severity==="error"))return r||"Non Conformant";if(r=o.name,e&&o.name===e)return o.name}return r||"Non Conformant"}export{u as a,T as b,g as c,Z as d,he as e,P as f,fe as g,J as h,D as i,E as j,w as k,k as l,x as m,$e as n,Se as o,Ie as p,Ae as q,Ne as r,L as s,B as t,Me as u,be as v,ze as w};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as F,b as ae,c as me,d as pe,e as K}from"./EDU3YBRA.js";import{a as ce,b as fe}from"./64G5RPLP.js";import{h as oe,i as x,j as ie,k as se,n as T,o as h,p as re}from"./3I7XLHPY.js";import{G as Z,O as ee,P as te,R as u,X as N,Z as ne,b as U,c as I,ca as b,d as O,h as L,o as d,r as S}from"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import*as Me from"node:fs";import{performance as We}from"perf_hooks";import*as ve from"node:fs";import*as G from"node:path";import*as le from"node:path";function A(e,t,n={}){pe(e,i=>{if(S(i)&&K(i.$ref))o(i,"$ref");else if(I(i.discriminator)&&I(i.discriminator.mapping)){let{mapping:s}=i.discriminator;for(let m of Object.keys(s)){let a=s[m];typeof a=="string"&&K(a)&&o(i.discriminator.mapping,m)}}});function o(i,s){let m=i[s].split("/"),a=m.pop(),p=m[2],r=n[p];if(!r||!r[a])return;let c=d(le.relative(t,r[a].filename));c.startsWith(".")||(c="./"+c),i[s]=c}}import*as Q from"node:path";import*as ye from"node:path";function E(e,t,n){return ye.join(e,t)+`.${n}`}var he=["schemas","messages","securitySchemes","parameters","correlationIds","messageTraits","operationTraits","serverBindings","channelBindings","operationBindings","messageBindings"];var Ae=["schemas","messages","securitySchemes","servers","serverVariables","parameters","replies","replyAddresses","correlationIds","messageTraits","operationTraits","tags","externalDocs","serverBindings","channelBindings","operationBindings","messageBindings"];function Y(e,t){return(t==="async2"?he:Ae).filter(o=>o in e)}function de({asyncapi:e,asyncapiDir:t,componentsFiles:n,ext:o,specVersion:i}){let s=e.components;if(!s)return;let m=Q.join(t,F),a=Y(s,i);for(let p of a){let r=Q.join(m,p);for(let c of Object.keys(s[p]||{})){let y=E(r,c,o),f=[];p==="schemas"&&(f=(s[p]?.[c]?.allOf||[]).map(({$ref:l})=>l).filter(L)),n[p]=n[p]||{},n[p][c]={inherits:f,filename:y}}}}import*as ue from"node:fs";import*as w from"node:path";import*as M from"node:path";function g(e,t,n){let o=M.resolve(e),i=M.resolve(t);if(i!==o&&!i.startsWith(o+M.sep))throw new b(`Refusing to write "${n}" outside the output directory.`)}import*as P from"node:fs";import*as ge from"node:path";function v(e,t,n){if(!P.existsSync(e)||!P.statSync(e).isDirectory())return;let o=P.readdirSync(e);for(let i of o){let s=ge.join(e,i);P.statSync(s).isDirectory()?v(s,t,n):t(s,e,n)}}function $(e,t,n){if(!Z(e))return;let o=T(e);A(o,t,n),h(o,e)}function Ce({channels:e,asyncapiDir:t,outDir:n,componentsFiles:o,pathSeparator:i,ext:s}){let m={};if(!e)return m;ue.mkdirSync(n,{recursive:!0});for(let a of Object.keys(e)){let p=`${w.join(n,x(a,i))}.${s}`,r=e[a];S(r)||(g(t,p,a),m[a]=p,A(r,w.dirname(p),o),h(r,p),e[a]={$ref:d(w.relative(t,p))},v(n,$,o))}return m}import*as De from"node:fs";import*as R from"node:path";import*as Oe from"node:fs";function j(e){return e!=="securitySchemes"}function V(e,t){j(t)&&Oe.mkdirSync(e,{recursive:!0})}import*as Se from"node:fs";function H(e,t){return Se.existsSync(e)&&!U(T(e),t)}import*as Ne from"node:path";function k(e,t,n){if(!(!I(e)&&!Array.isArray(e))){if(Array.isArray(e)){for(let o of e)k(o,t,n);return}for(let o of Object.keys(e)){let i=e[o];if(o==="$ref"&&typeof i=="string"&&i.startsWith("#/channels/")){let s=i.slice(11),m=s.indexOf("/"),a=m===-1?s:s.slice(0,m),p=m===-1?"":s.slice(m),r=n[a];if(r){let c=d(Ne.relative(t,r));e[o]=p?`${c}#${p}`:c}}else k(i,t,n)}}}function Fe(e,t){let n=e.components;n&&(O(n[t])&&delete n[t],O(n)&&delete e.components)}function xe({asyncapi:e,asyncapiDir:t,componentsFiles:n,channelsFiles:o,ext:i,specVersion:s}){let m=e.components;if(m){let r=function(c){let y=R.join(a,c);V(y,c);for(let f of Object.keys(m?.[c]||{})){let l=E(y,f,i);g(t,l,f);let C=m?.[c]?.[f];A(C,R.dirname(l),n),k(C,R.dirname(l),o),H(l,C)?N.warn(`warning: conflict for ${f} - file already exists with different content: ${u(l)} ... Skip.
7
+ import{a as F,b as ae,c as me,d as pe,e as K}from"./BNAH4YGC.js";import{a as ce,b as fe}from"./64G5RPLP.js";import{f as oe,g as x,h as ie,i as se,l as T,m as h,n as re}from"./N6VRECSO.js";import{R as Z,Z as ee,_ as te,aa as u,b as U,c as I,d as O,ga as N,h as L,ia as ne,ma as b,o as d,r as S}from"./MT5H2R3P.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import*as Me from"node:fs";import{performance as We}from"perf_hooks";import*as ve from"node:fs";import*as G from"node:path";import*as le from"node:path";function A(e,t,n={}){pe(e,i=>{if(S(i)&&K(i.$ref))o(i,"$ref");else if(I(i.discriminator)&&I(i.discriminator.mapping)){let{mapping:s}=i.discriminator;for(let m of Object.keys(s)){let a=s[m];typeof a=="string"&&K(a)&&o(i.discriminator.mapping,m)}}});function o(i,s){let m=i[s].split("/"),a=m.pop(),p=m[2],r=n[p];if(!r||!r[a])return;let c=d(le.relative(t,r[a].filename));c.startsWith(".")||(c="./"+c),i[s]=c}}import*as Q from"node:path";import*as ye from"node:path";function E(e,t,n){return ye.join(e,t)+`.${n}`}var he=["schemas","messages","securitySchemes","parameters","correlationIds","messageTraits","operationTraits","serverBindings","channelBindings","operationBindings","messageBindings"];var Ae=["schemas","messages","securitySchemes","servers","serverVariables","parameters","replies","replyAddresses","correlationIds","messageTraits","operationTraits","tags","externalDocs","serverBindings","channelBindings","operationBindings","messageBindings"];function Y(e,t){return(t==="async2"?he:Ae).filter(o=>o in e)}function de({asyncapi:e,asyncapiDir:t,componentsFiles:n,ext:o,specVersion:i}){let s=e.components;if(!s)return;let m=Q.join(t,F),a=Y(s,i);for(let p of a){let r=Q.join(m,p);for(let c of Object.keys(s[p]||{})){let y=E(r,c,o),f=[];p==="schemas"&&(f=(s[p]?.[c]?.allOf||[]).map(({$ref:l})=>l).filter(L)),n[p]=n[p]||{},n[p][c]={inherits:f,filename:y}}}}import*as ue from"node:fs";import*as w from"node:path";import*as M from"node:path";function g(e,t,n){let o=M.resolve(e),i=M.resolve(t);if(i!==o&&!i.startsWith(o+M.sep))throw new b(`Refusing to write "${n}" outside the output directory.`)}import*as P from"node:fs";import*as ge from"node:path";function v(e,t,n){if(!P.existsSync(e)||!P.statSync(e).isDirectory())return;let o=P.readdirSync(e);for(let i of o){let s=ge.join(e,i);P.statSync(s).isDirectory()?v(s,t,n):t(s,e,n)}}function $(e,t,n){if(!Z(e))return;let o=T(e);A(o,t,n),h(o,e)}function Ce({channels:e,asyncapiDir:t,outDir:n,componentsFiles:o,pathSeparator:i,ext:s}){let m={};if(!e)return m;ue.mkdirSync(n,{recursive:!0});for(let a of Object.keys(e)){let p=`${w.join(n,x(a,i))}.${s}`,r=e[a];S(r)||(g(t,p,a),m[a]=p,A(r,w.dirname(p),o),h(r,p),e[a]={$ref:d(w.relative(t,p))},v(n,$,o))}return m}import*as De from"node:fs";import*as R from"node:path";import*as Oe from"node:fs";function j(e){return e!=="securitySchemes"}function V(e,t){j(t)&&Oe.mkdirSync(e,{recursive:!0})}import*as Se from"node:fs";function H(e,t){return Se.existsSync(e)&&!U(T(e),t)}import*as Ne from"node:path";function k(e,t,n){if(!(!I(e)&&!Array.isArray(e))){if(Array.isArray(e)){for(let o of e)k(o,t,n);return}for(let o of Object.keys(e)){let i=e[o];if(o==="$ref"&&typeof i=="string"&&i.startsWith("#/channels/")){let s=i.slice(11),m=s.indexOf("/"),a=m===-1?s:s.slice(0,m),p=m===-1?"":s.slice(m),r=n[a];if(r){let c=d(Ne.relative(t,r));e[o]=p?`${c}#${p}`:c}}else k(i,t,n)}}}function Fe(e,t){let n=e.components;n&&(O(n[t])&&delete n[t],O(n)&&delete e.components)}function xe({asyncapi:e,asyncapiDir:t,componentsFiles:n,channelsFiles:o,ext:i,specVersion:s}){let m=e.components;if(m){let r=function(c){let y=R.join(a,c);V(y,c);for(let f of Object.keys(m?.[c]||{})){let l=E(y,f,i);g(t,l,f);let C=m?.[c]?.[f];A(C,R.dirname(l),n),k(C,R.dirname(l),o),H(l,C)?N.warn(`warning: conflict for ${f} - file already exists with different content: ${u(l)} ... Skip.
8
8
  `):h(C,l),delete m?.[c]?.[f]}Fe(e,c)},a=R.join(t,F);De.mkdirSync(a,{recursive:!0}),Y(m,s).forEach(r)}}import*as Ee from"node:fs";import*as _ from"node:path";function Pe({operations:e,asyncapiDir:t,outDir:n,componentsFiles:o,channelsFiles:i,pathSeparator:s,ext:m}){if(e){Ee.mkdirSync(n,{recursive:!0});for(let a of Object.keys(e)){let p=`${_.join(n,x(a,s))}.${m}`,r=e[a];S(r)||(g(t,p,a),A(r,_.dirname(p),o),k(r,_.dirname(p),i),h(r,p),e[a]={$ref:d(_.relative(t,p))},v(n,$,o))}}}function _e({asyncapi:e,asyncapiDir:t,pathSeparator:n,ext:o,specVersion:i}){ve.mkdirSync(t,{recursive:!0});let s={};de({asyncapi:e,asyncapiDir:t,componentsFiles:s,ext:o,specVersion:i});let m=e.channels,a=m?Ce({channels:m,asyncapiDir:t,outDir:G.join(t,ae),componentsFiles:s,pathSeparator:n,ext:o}):{};xe({asyncapi:e,asyncapiDir:t,componentsFiles:s,channelsFiles:a,ext:o,specVersion:i}),i==="async3"&&e.operations&&Pe({operations:e.operations,asyncapiDir:t,outDir:G.join(t,me),componentsFiles:s,channelsFiles:a,pathSeparator:n,ext:o}),A(e,t,s),h(e,G.join(t,`asyncapi.${o}`))}import*as Be from"node:fs";import*as J from"node:path";import*as ke from"node:fs";import*as B from"node:path";import*as q from"node:path";function be(e){return q.basename(e,q.extname(e))}function Te(e){return e?fe.filter(t=>j(t)&&Object.keys(e).includes(t)):[]}function $e(e,t,n,o,i){let s=[];n==="schemas"&&(s=(e?.[n]?.[o]?.allOf||[]).map(({$ref:m})=>m).filter(L)),t[n]=t[n]||{},t[n][o]={inherits:s,filename:i}}import*as X from"node:path";function we(e,t,n,o){if(!e.discriminator)return;let i=`#/${F}/schemas/${t}`,s={};for(let[r,{inherits:c,filename:y}]of Object.entries(o))if(c.indexOf(i)>-1){let f=d(X.relative(X.dirname(n),y));s[r]=f.startsWith(".")?f:"./"+f}if(O(s))return;let m=e.properties[e.discriminator.propertyName],a=m&&m.enum,p=e.discriminator.mapping=e.discriminator.mapping||{};for(let r of Object.keys(s))a&&!a.includes(r)||(p[r]&&p[r]!==s[r]&&N.warn(`warning: explicit mapping overlaps with local mapping entry ${ee(r)} at ${u(n)}. Please check it.`),p[r]=s[r])}function je(e,t){e.components&&O(e.components[t])&&delete e.components[t],O(e.components)&&delete e.components}function Re(e,t,n,o){let{components:i}=e;if(i){let a=function(r){let c=B.join(s,r);for(let y of Object.keys(i?.[r]||{})){let f=E(c,y,o);g(t,f,y),$e(i,n,r,y,f)}},p=function(r){let c=B.join(s,r);V(c,r);for(let y of Object.keys(i?.[r]||{})){let f=E(c,y,o),l=i?.[r]?.[y];A(l,B.dirname(f),n),we(l,be(f),f,n.schemas||{}),H(f,l)?N.warn(`warning: conflict for ${y} - file already exists with different content: ${u(f)} ... Skip.
9
9
  `):h(l,f),j(r)&&delete e.components?.[r]?.[y]}je(e,r)},s=B.join(t,F);ke.mkdirSync(s,{recursive:!0});let m=Te(i);m.forEach(a),m.forEach(p)}}import*as W from"node:fs";import*as D from"node:path";function z(e,t,n,o,i,s="",m){if(e){W.mkdirSync(n,{recursive:!0});for(let a of Object.keys(e)){let p=`${D.join(n,x(a,i))}.${m}`,r=e[a];if(!S(r)){g(t,p,a);for(let c of ce){let y=r[c],f=y?.["x-code-samples"]||y?.["x-codeSamples"];if(!(!f||!Array.isArray(f)))for(let l of f){if(l.source&&l.source.$ref)continue;let C=D.join(t,"code_samples",ie(l.lang),s+x(a,i),c+se(l.lang));g(t,C,l.lang),W.mkdirSync(D.dirname(C),{recursive:!0}),W.writeFileSync(C,l.source),l.source={$ref:d(D.relative(n,C))}}}h(r,p),e[a]={$ref:d(D.relative(t,p))},v(n,$,o)}}}}function Ie(e,t,n,o){Be.mkdirSync(t,{recursive:!0});let i={};Re(e,t,i,o),z(e.paths,t,J.join(t,"paths"),i,n,void 0,o);let s=e.webhooks||e["x-webhooks"];z(s,t,J.join(t,"webhooks"),i,n,"webhook_",o),A(e,t,i),h(e,J.join(t,`openapi.${o}`))}async function Vn({argv:e,collectSpecData:t}){let n=We.now(),{api:o,outDir:i,separator:s}=e,m=re(o);if(!Me.existsSync(o))throw new b(`File ${u(o)} does not exist.`);let a=T(o);t?.({parsed:a});let p=ne(a);switch(p){case"async2":case"async3":_e({asyncapi:a,asyncapiDir:i,pathSeparator:s,ext:m,specVersion:p});break;case"oas3_0":case"oas3_1":case"oas3_2":Ie(a,i,s,m);break;case"oas2":throw new b("OpenAPI 2 is not supported by this command.");default:throw new b("File does not conform to the OpenAPI or AsyncAPI Specification. Version is not specified.")}N.info(`\u{1FA93} Document: ${u(o)} ${te("is successfully split")}
10
10
  and all related files are saved to the directory: ${u(i)}
@@ -0,0 +1,13 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{b as A,c as F,d as S,e as l}from"./OJE7THLM.js";import"./TAEOWXJJ.js";import{e as $,g as x,n as I,o as P}from"./3TRGOJ74.js";import{f as p}from"./N6VRECSO.js";import"./LRUXN6H5.js";import{_ as w,ga as n,l as u}from"./MT5H2R3P.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function O({argv:t,config:o,version:c}){let h=performance.now(),j=Date.now(),{organization:g,project:d,"mount-path":z,verbose:D}=t,f=t.domain||x(),e,r,y,b,s=[];try{let i=$();if(e=P(t.files,(a,T)=>{n.warn(`File ${a} is overwritten by ${T}
8
+ `)}),!e.length)return p("push",h,"No files to upload");let m=await I({domain:f,apiKey:i,organization:g,project:d,mountPath:z,files:e,defaultBranch:t["default-branch"],commit:{message:t.message,branchName:t.branch,sha:t["commit-sha"],url:t["commit-url"],createdAt:t["created-at"],namespace:t.namespace,repository:t.repository,author:U(t.author)},version:c,replace:t.replace,onUploadStart:a=>{n.info(`Uploading to ${a.mountPath} ${e.length} ${u("file",e.length)}:
9
+ `)},onSunsetWarning:a=>s.push(a),onSlugDeprecated:S});r=m.pushId,y=m.organizationId,b=m.projectId}catch(i){l("push",s),F("\u2717 File upload failed.",i)}for(let i of e)n.info(w(`\u2713 ${i.name}
10
+ `));return n.info(`
11
+ `),n.info(`Push ID: ${r}
12
+ `),l("push",s),t["wait-for-deployment"]&&(n.info(`
13
+ `),await A({argv:{organization:y,project:b,pushId:r,wait:!0,domain:f,"max-execution-time":t["max-execution-time"],"start-time":j,"continue-on-deploy-failures":t["continue-on-deploy-failures"]},config:o,version:c})),D&&p("push",h,`${u("file",e.length)} uploaded to organization ${g}, project ${d}. Push ID: ${r}.`),{pushId:r}}function U(t){let o=t.match(/^(?<name>.+)\s<(?<email>[^<>]+)>$/);if(!o?.groups)throw new Error('Invalid author format. Use "Author Name <author@email.com>"');return{name:o.groups.name.trim(),email:o.groups.email.trim()}}export{O as handlePush};
@@ -0,0 +1,22 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{a as ye,e as ve,f as Se,g as we,h as O,i as Re,k,l as A,m as Ie,n as Pe,v as be,w as Oe}from"./YFBPBQ7G.js";import{$ as E,J as ot,T as ce,W as at,X as pe,Y as g,Z as $,_ as de,aa as q,c as d,ca as S,ea as v,ga as R,ha as le,ia as fe,ja as me,ka as he,pa as ge,q as ae,v as ue}from"./MT5H2R3P.js";import{e as oe}from"./RFWIIJFG.js";import ke from"node:path";function I(t){return t?t.trim():""}function B(t){let e=I(t.operationId)||I(t.path);return[I(t.ruleId),I(t.severity),I(t.message),e,I(t.target),I(t.schemaPath)].join("")}var _=t=>pe(S(t));function ut(t){return t==="error"?"error":t==="warning"?"warning":"note"}function ct(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
8
+ `)?e:`"${e.replace(/"/g,'""')}"`}function pt(t){return ke.isAbsolute(t)?ke.relative(process.cwd(),t)||".":t}function dt(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function lt(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function ft(t){let e=[],r=new Map;for(let n of t){let s=B({ruleId:n.ruleId,severity:n.severity,message:n.message,operationId:n.operationId,path:n.path,target:n.target,schemaPath:n.schemaPath}),i=r.get(s);if(i!==void 0){e[i].occurrences+=1;continue}r.set(s,e.length),e.push({finding:n,occurrences:1})}return e}function mt(t){let e=ft(t.findings).map(n=>({occurrences:n.occurrences,exchangeIndex:n.finding.exchangeIndex,ruleId:n.finding.ruleId,severity:n.finding.severity,category:n.finding.category,message:n.finding.message,operationId:n.finding.operationId,specSource:n.finding.specSource,target:n.finding.target,schemaPath:n.finding.schemaPath,dataPath:n.finding.dataPath,details:n.finding.details,method:n.finding.method,url:n.finding.url,path:n.finding.path,status:n.finding.status})),r={run:{id:t.runId,specSource:t.meta.specSource,trafficPath:t.meta.trafficPath,format:t.meta.format,matchMode:t.meta.matchMode,server:t.meta.server,totalExchanges:t.summary.totalExchanges,documentedExchanges:t.summary.documentedExchanges,undocumentedExchanges:t.summary.undocumentedExchanges,skippedExchanges:t.summary.skippedExchanges,findingsBySeverity:t.summary.findingsBySeverity,findingsByRule:t.summary.findingsByRule,totalProblems:t.summary.totalProblemGroups,durationMs:t.summary.durationMs},problems:e};return`${JSON.stringify(r,null,2)}
9
+ `}function ht(t){let e=["run_id","finding_id","exchange_index","severity","category","rule_id","message","method","path","url","status","operation_id","spec_source","target","schema_path","data_path"],r=t.findings.map(s=>[t.runId,s.id,s.exchangeIndex,s.severity,s.category,s.ruleId,s.message,s.method,s.path,s.url,s.status,s.operationId,s.specSource,s.target,s.schemaPath,s.dataPath]);return`${[e,...r].map(s=>s.map(ct).join(",")).join(`
10
+ `)}
11
+ `}function gt(t){let e=new Map;for(let s of t.findings)e.has(s.ruleId)||e.set(s.ruleId,{id:s.ruleId,name:s.ruleId,shortDescription:{text:`${s.category} detection`}});let r=t.findings.map(s=>{let i=s.specSource??s.url??void 0;return{ruleId:s.ruleId,level:ut(s.severity),message:{text:s.message},locations:i?[{physicalLocation:{artifactLocation:{uri:i}}}]:void 0,properties:{runId:t.runId,exchangeIndex:s.exchangeIndex,method:s.method,path:s.path,status:s.status,operationId:s.operationId,target:s.target,schemaPath:s.schemaPath,dataPath:s.dataPath}}}),n={$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{tool:{driver:{name:"drift",rules:Array.from(e.values())}},results:r}]};return`${JSON.stringify(n,null,2)}
12
+ `}function yt(t){return t.findingsBySeverity.error+t.findingsBySeverity.warning+t.findingsBySeverity.info}function vt(t){return t>=500?$:t>=400?E:t>=300?q:t>=200?de:v}function St(t,e,r){let n=(f,h)=>e?h(f):f,s=f=>f==="error"?n("\u2716",$):f==="warning"?n("\u25B2",E):n("\u25CF",q),i=f=>f==="error"?n("ERROR",$):f==="warning"?n("WARN",E):n("INFO",q),{summary:o,meta:a}=t,c=yt(o),l=o.previewFindings.slice(0,r),u=[];if(u.push(n("\u250F\u2501 Drift Report",_)),u.push(`\u2503 Run: ${t.runId}`),u.push(`\u2503 Spec: ${a.specSource}`),u.push(`\u2503 Traffic: ${a.trafficPath}`),u.push(a.server?`\u2503 Server: ${a.server} (overrides description servers)`:`\u2503 Match mode: ${a.matchMode}`),u.push(`\u2503 Traffic format: ${a.format}${a.format==="auto"?" (auto-detect)":""}`),u.push(`\u2503 Exchanges: total=${o.totalExchanges} documented=${o.documentedExchanges} undocumented=${o.undocumentedExchanges}${o.skippedExchanges>0?` skipped=${o.skippedExchanges}`:""}`),u.push(`\u2503 Findings: total=${c} ${n(`error=${o.findingsBySeverity.error}`,$)} ${n(`warning=${o.findingsBySeverity.warning}`,E)} ${n(`info=${o.findingsBySeverity.info}`,q)}`),u.push(`\u2503 Problems: total=${o.totalProblemGroups}`),u.push(`\u2517 Duration: ${o.durationMs}ms`),c===0)return u.push(""),u.push(n("\u2714 No findings.",S)),`${u.join(`
13
+ `)}
14
+ `;u.push(""),u.push(n(`Types (${Object.keys(o.problemGroupsByRule).length})`,_));for(let[f,h]of lt(o.problemGroupsByRule)){let y=o.findingsByRule[f]??h;u.push(` ${n("\u2022",v)} ${f}: ${h} problems / ${y} findings`)}let m=new Map;for(let f of l)m.has(f.ruleId)||m.set(f.ruleId,[]),m.get(f.ruleId).push(f);let w=Array.from(m.keys()).sort((f,h)=>{let y=(o.problemGroupsByRule[h]??0)-(o.problemGroupsByRule[f]??0);return y!==0?y:f.localeCompare(h)});u.push(""),u.push(n(`Problems by type (showing first ${l.length} of ${o.totalProblemGroups})`,_));let j=0;for(let f of w){let h=m.get(f);if(!h||h.length===0)continue;let y=o.problemGroupsByRule[f]??h.length,Y=o.findingsByRule[f]??y;u.push(""),u.push(`${n("\u25C9",S)} ${n(f,_)} ${n(`(${h.length} problems shown / ${y} total, ${Y} findings)`,v)}`);for(let p of h){j+=1;let re=p.occurrences,nt=p.status!==void 0?n(String(p.status),vt(p.status)):n("-",v),rt=dt(p.details)??p.path,st=p.operationId?` ${n(p.operationId,g)}`:"";if(u.push(`${s(p.severity)} ${i(p.severity)} #${j}${re>1?` ${n(`\xD7${re}`,v)}`:""} ${n("\u2192",v)} ${p.message}`),u.push(` \u21B3 sample exchange=${p.exchangeIndex} ${n(p.method,S)} ${rt} (${nt})${st}`),u.push(""),u.push(` ${n(p.url,v)}`),(p.specSource||p.schemaPath||p.dataPath)&&(u.push(""),p.specSource&&u.push(` ${n("spec:",g)} ${n(pt(p.specSource),S)}`),p.schemaPath&&u.push(` ${n("schemaPath=",g)} ${n(p.schemaPath,g)}`),p.dataPath&&u.push(` ${n("dataPath=",g)} ${n(p.dataPath,S)}`)),p.details)if(u.push(""),p.ruleId==="security-baseline"&&typeof p.details.summary=="string")u.push(` ${n("security:",g)} ${p.details.summary}`);else if(p.ruleId==="owasp-api-top10"&&typeof p.details.summary=="string"){let x=typeof p.details.issueId=="string"?p.details.issueId:null,C=typeof p.details.issueTitle=="string"?p.details.issueTitle:null;u.push(` ${n("owasp:",g)} ${p.details.summary}`),(x||C)&&u.push(` ${n("issue:",g)} ${[x,C].filter(Boolean).join(" - ")}`)}else if(p.ruleId==="schema-consistency"&&typeof p.details.summary=="string"){let x=typeof p.details.path=="string"?p.details.path:null,C=typeof p.details.expected=="string"?p.details.expected:null,se=typeof p.details.actual=="string"?p.details.actual:null,ie=typeof p.details.suggestion=="string"?p.details.suggestion:null;if(u.push(` ${n("schema:",g)} ${p.details.summary}`),x&&u.push(` ${n("path:",g)} ${n(x,S)}`),C&&u.push(` ${n("expected:",g)} ${C}`),se&&u.push(` ${n("actual:",g)} ${se}`),ie){u.push(` ${n("hint:",g)}`);for(let it of ie.split(`
15
+ `))u.push(` ${it}`)}}else u.push(` ${n("details:",g)} ${JSON.stringify(p.details)}`);u.push("")}}let b=o.totalProblemGroups-l.length;return b>0?(u[u.length-1]!==""&&u.push(""),u.push(n(`\u2026 ${b} problems omitted from terminal output. Use --format json/csv/sarif for the complete export.`,v))):u[u.length-1]===""&&u.pop(),`${u.join(`
16
+ `)}
17
+ `}function Zn(t,e){let r=e.maxFindings??10;switch(e.format){case"json":return mt(t);case"csv":return ht(t);case"sarif":return gt(t);case"pretty":return St(t,e.color??!1,r);default:throw new Error(`Unsupported report format: ${e.format}`)}}import{randomUUID as Qe}from"node:crypto";function wt(t,e){let r=O(t||"/")||"/",n=O(e.basePath||"/")||"/";return n==="/"?r:r===n?"/":r.startsWith(`${n}/`)?r.slice(n.length)||"/":null}function Rt(t,e){return!t.host||!e?!0:t.host===e.toLowerCase()}function It(t){try{return decodeURIComponent(t)}catch{return t}}function Pt(t,e,r){let n=r==="strict-host"?e.host?20:5:0;return t.pathScore*10+n}function Ae(t,e){let r={};for(let n=0;n<t.pathParams.length;n+=1){let s=t.pathParams[n],i=e[n+1];s&&i!==void 0&&(r[s]=It(i))}return r}function bt(t,e){let r=O(e)||"/";for(let n of t){let s=n.pathRegex.exec(r);if(s)return{operation:n,pathParams:Ae(n,s)}}return null}function xe(t,e,r,n){let s=e.request.method.toLowerCase(),i=t.operationsByMethod.get(s);if(!i||i.length===0)return null;if(n!==void 0)return bt(i,n);let o=null;for(let a of i)for(let c of a.servers){if(r==="strict-host"&&!Rt(c,e.request.host))continue;let l=wt(e.request.path,c);if(!l)continue;let u=a.pathRegex.exec(l);if(!u)continue;let m={score:Pt(a,c,r),matched:{operation:a,pathParams:Ae(a,u)}};(!o||m.score>o.score)&&(o=m)}return o?.matched??null}var Ce=6,Ot=2e3,kt=50,At=5,xt=1e6,Ct=/(?:token|api[_-]?key|apikey|password|passwd|secret|authorization|jwt)/i,$t=/(?:password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|private[_-]?key|ssn|credit[_-]?card|card[_-]?number|cvv)/i,Et=new Set(["page","limit","offset","cursor","per_page","perpage","size","start","after","before"]),$e=4,qt=$e*2;function Tt(t){return t.length<=qt?"***":`${t.slice(0,$e)}\u2026`}function Ft(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Mt(t){return typeof t=="string"||typeof t=="number"}function jt(t){let e=t.toLowerCase();return e.includes("secret")||e.includes("token")||e.includes("key")?e.startsWith("is")||e.startsWith("has")||e.startsWith("can")||e.startsWith("should")||e.startsWith("enable")||e.startsWith("allow"):!1}function Bt(t){if(typeof t=="number")return t===0||t===1;let e=t.trim().toLowerCase();return e==="true"||e==="false"||e==="0"||e==="1"}function _t(t){if(!d(t)&&!Array.isArray(t))return[];let e=[],r=[{value:t,path:""}],n=0;for(;r.length>0&&n<Ot&&e.length<Ce;){let s=r.pop();if(!s)break;if(n+=1,Array.isArray(s.value)){let i=Math.min(s.value.length,kt);for(let o=0;o<i;o+=1){let a=s.value[o];(d(a)||Array.isArray(a))&&r.push({value:a,path:`${s.path}/${o}`})}continue}if(d(s.value))for(let[i,o]of Object.entries(s.value)){let a=`${s.path}/${Ft(i)}`;if($t.test(i)&&Mt(o)){let c=String(o);if(jt(i)&&Bt(o))continue;if(c.length>0&&(e.push(a||"/"),e.length>=Ce))break}(d(o)||Array.isArray(o))&&r.push({value:o,path:a})}}return e}function Lt(t){for(let e of t.keys())if(Et.has(e.toLowerCase()))return!0;return!1}function P(t,e,r,n,s){return{ruleId:"owasp-api-top10",severity:n,category:"security",message:e,exchangeIndex:t.exchange.index,operationId:t.matchedOperation?.operation.operationId,specSource:t.matchedOperation?.operation.specSource,target:r,details:s}}function Nt(t){let e=[];for(let[r,n]of t.exchange.request.query.entries())if(Ct.test(r)&&(e.push({key:r,valuePreview:Tt(n)}),e.length>=At))break;return e.length===0?[]:[P(t,"Sensitive credential-like query parameters detected","request","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:"Authentication data should not be passed via query parameters because it can leak via logs, browser history, and referrers.",sensitiveQueryParams:e})]}function zt(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["access-control-allow-origin"]?.trim(),n=e.headers["access-control-allow-credentials"]?.trim().toLowerCase();return r!=="*"||n!=="true"?[]:[P(t,"Insecure CORS policy: wildcard origin with credentials enabled","response","error",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Access-Control-Allow-Origin is "*" while Access-Control-Allow-Credentials is true. Browsers may expose authenticated API responses to untrusted origins.',headers:{accessControlAllowOrigin:r,accessControlAllowCredentials:n}})]}function Vt(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["set-cookie"];if(!r)return[];let n=[];for(let s of Se(r)){let i=new Set(s.split(";").slice(1).map(o=>o.split("=")[0].trim().toLowerCase()));t.exchange.request.protocol==="https:"&&!i.has("secure")&&n.push(P(t,'Set-Cookie header is missing "Secure" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies over HTTPS should include "Secure" to prevent transmission over plain HTTP.',setCookiePreview:s.slice(0,200)})),i.has("httponly")||n.push(P(t,'Set-Cookie header is missing "HttpOnly" attribute',"response","warning",{issueId:"API2:2023",issueTitle:"Broken Authentication",summary:'Session cookies should include "HttpOnly" to reduce risk of token theft via client-side script access.',setCookiePreview:s.slice(0,200)})),i.has("samesite")||n.push(P(t,'Set-Cookie header is missing "SameSite" attribute',"response","info",{issueId:"API8:2023",issueTitle:"Security Misconfiguration",summary:'Set "SameSite" on session cookies to reduce CSRF risk for state-changing requests.',setCookiePreview:s.slice(0,200)}))}return n}function Ht(t){let e=t.exchange.response;if(!e||e.bodyJson===void 0)return[];let r=_t(e.bodyJson);return r.length===0?[]:[P(t,"Potential sensitive data exposure in response payload","response","warning",{issueId:"API3:2019",issueTitle:"Excessive Data Exposure",summary:`Sensitive-looking fields detected in response payload: ${r.join(", ")}`,exposedPaths:r})]}function Dt(t){let e=t.exchange.response;return!e||e.status>=400||t.exchange.request.method!=="GET"?[]:!e.bodyText||e.bodyText.length<xt?[]:Lt(t.exchange.request.query)?[]:[P(t,"Large response without pagination parameters (possible resource-consumption risk)","response","info",{issueId:"API4:2023",issueTitle:"Unrestricted Resource Consumption",summary:"A large response was returned without common pagination query parameters. Consider explicit page/limit controls for large collections.",responseBytes:e.bodyText.length})]}var L=class{id="owasp-api-top10";analyze(e){return e.matchedOperation?[...Nt(e),...zt(e),...Vt(e),...Ht(e),...Dt(e)]:[]}};function N(t,e){let r=t.replace(/\{([^}]+)\}/g,(i,o)=>{let a=e?.[o];return a?.default!==void 0?String(a.default):Array.isArray(a?.enum)&&a.enum.length>0?String(a.enum[0]):""}),n=we(r),s=!!(n.host&&!ve(n.host));return{rawUrl:t,protocol:s?n.protocol:void 0,host:s?n.host.toLowerCase():void 0,basePath:O(n.pathname||"/")}}function Ee(t){return t?t.startsWith("/")?t:`/${t}`:"/"}function z(t,e){let r=`${Math.floor(t/100)}XX`;return[String(t),r,r.toLowerCase(),"default"].find(n=>e.includes(n))}function qe(t){if(!t)return{};let e={};for(let r of t.split(";")){let[n,...s]=r.trim().split("=");if(!n)continue;let i=s.join("=").trim();e[n]=i}return e}var Kt=/^([^[\]]+)\[([^[\]]+)\]$/;function Q(t){let e=t.match(Kt);return e?{parameterName:e[1],property:e[2]}:void 0}function Ut(t,e){let r;for(let[n,s]of e){let i=Q(n);i?.parameterName===t&&(r??={},r[i.property]=s)}return r}function V(t,e,r,n){switch(t.in){case"path":return r[t.name];case"query":{if(t.style==="deepObject")return Ut(t.name,e.query);let s=e.query.getAll(t.name);return s.length===0?void 0:(d(t.schema)?t.schema.type:void 0)==="array"||s.length>1?s:s[0]}case"header":return e.headers[t.name.toLowerCase()];case"cookie":return n[t.name];default:return}}var Te=200;function Fe(t){return t!==void 0&&t!==""}function Gt(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Jt(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Wt(t){return!t||t==="#"?"":t.startsWith("#")?t.slice(1):t}function X(t){let e=Wt(t);return!e||e==="/"?[]:e.split("/").slice(1).map(r=>Gt(r))}function Me(t,e){return`/${[...X(t),Jt(e)].join("/")}`}function Yt(t,e){let r=X(e),n=t;for(let s of r){if(Array.isArray(n)){let i=Number.parseInt(s,10);if(!Number.isInteger(i)||i<0||i>=n.length)return;n=n[i];continue}if(!d(n))return;n=n[s]}return n}function Z(t){let e=t.instancePath??"",r=t.params??{};return t.keyword==="required"&&typeof r.missingProperty=="string"?Me(e,r.missingProperty):t.keyword==="additionalProperties"&&typeof r.additionalProperty=="string"?Me(e,r.additionalProperty):e}function Qt(t){let e=X(t);if(e.length===0)return"root";let r=[];for(let n of e)/^\d+$/.test(n)?r.push(`[${n}]`):r.length===0?r.push(n):r.push(`.${n}`);return r.join("")}function Xt(t){if(t===void 0)return"[missing]";let e=JSON.stringify(t);return e?e.length>Te?`${e.slice(0,Te)}\u2026`:e:String(t)}function Zt(t){let e=t.params??{};if(t.keyword==="required"&&typeof e.missingProperty=="string")return`required field "${e.missingProperty}"`;if(t.keyword==="type"&&typeof e.type=="string")return`type "${e.type}"`;if(t.keyword==="additionalProperties")return"no additional undocumented properties";if(t.keyword==="format"&&typeof e.format=="string")return`format "${e.format}"`}function en(t,e,r){let n=t==="request"?"Request":"Response",s=e.params??{},i=Qt(r);return e.keyword==="required"&&typeof s.missingProperty=="string"?`${n} is missing required field "${i}".`:e.keyword==="additionalProperties"&&typeof s.additionalProperty=="string"?`${n} has undocumented field "${i}".`:e.keyword==="type"&&typeof s.type=="string"?`${n} field "${i}" must be ${s.type}.`:e.keyword==="enum"?`${n} field "${i}" has a value outside allowed enum values.`:e.keyword==="format"&&typeof s.format=="string"?`${n} field "${i}" does not match format "${s.format}".`:`${n} schema mismatch at "${i}": ${e.message??"validation error"}`}function Be(t,e,r){let n=Z(e),s=Yt(t,n);return{summary:en(r,e,n),keyword:e.keyword??null,path:n||"/",expected:Zt(e)??null,actual:Xt(s),suggestion:null,params:e.params??{},ajvMessage:e.message??"validation error"}}function tn(t,e,r,n){if(e==null||!t.schema)return;let s=r.validateSchema(t.schema,e,{coerce:!0});if(!s.valid)for(let i of s.errors){let o=Be(e,i,"request");n.push({ruleId:"schema-consistency",severity:"error",category:"schema",message:`Invalid ${t.in} parameter "${t.name}": ${typeof o.summary=="string"?o.summary:i.message??"schema mismatch"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:"request",schemaPath:i.schemaPath,dataPath:Z(i),details:{...o,parameter:{name:t.name,in:t.in}}})}}function nn(t,e){let r=[],n={query:new Set,header:new Set,cookie:new Set},s=new Set;for(let i of e.operation.requestParameters)i.in==="header"?n.header.add(i.name.toLowerCase()):(i.in==="query"||i.in==="cookie")&&(n[i.in].add(i.name),i.in==="query"&&i.style==="deepObject"&&s.add(i.name));for(let i of new Set(t.exchange.request.query.keys())){if(n.query.has(i))continue;let o=Q(i);o&&s.has(o.parameterName)||r.push({ruleId:"schema-consistency",severity:"warning",category:"documentation",message:`Undocumented query parameter in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"})}for(let i of Object.keys(t.exchange.request.headers))Pe(i,t.ignoreHeaders)||n.header.has(i.toLowerCase())||r.push({ruleId:"schema-consistency",severity:"info",category:"documentation",message:`Undocumented header in traffic: "${i}"`,exchangeIndex:t.exchange.index,operationId:e.operation.operationId,specSource:e.operation.specSource,target:"request"});return r}function rn(t){let e=t.exchange.response;return e!==void 0&&e.status>=400&&e.status<500}function sn(t,e){let r=t.exchange.response;if(!r)return;let{responseStatuses:n,responseBodyContent:s}=e.operation,i=z(r.status,n);if(!(i===void 0||s[i]===void 0))return A(s[i],r.contentType)}function je(t,e,r,n){let s=r.validateSchema(t,e,{target:n});return s.valid?[]:s.errors.map(i=>{let o=Be(e,i,n);return{ruleId:"schema-consistency",severity:"error",category:"schema",message:typeof o.summary=="string"?o.summary:`Schema mismatch (${n}): ${i.message??"validation error"}`,exchangeIndex:r.exchange.index,operationId:r.matchedOperation?.operation.operationId,specSource:r.matchedOperation?.operation.specSource,target:n,schemaPath:i.schemaPath,dataPath:Z(i),details:o}})}var H=class{id="schema-consistency";analyze(e){let r=e.matchedOperation;if(!r)return[];let n=[];if(n.push(...nn(e,r)),!rn(e)){for(let c of r.operation.requestParameters){if(e.ignoreCookies&&c.in==="cookie")continue;let l=V(c,e.exchange.request,r.pathParams,e.cookies);if(c.required&&l==null){n.push({ruleId:this.id,severity:"error",category:"documentation",message:`Missing required ${c.in} parameter: "${c.name}"`,exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"});continue}tn(c,l,e,n)}let i=e.exchange.request.contentType,o=A(r.operation.requestBodyContent,i),a=Fe(e.exchange.request.bodyText);r.operation.requestBodyRequired&&!a&&n.push({ruleId:this.id,severity:"error",category:"documentation",message:"Missing required request body",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}),o&&a&&k(i)&&(e.exchange.request.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Request body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"}):n.push(...je(o,e.exchange.request.bodyJson,e,"request")))}let s=sn(e,r);if(s&&e.exchange.response&&Fe(e.exchange.response.bodyText)){let i=e.exchange.response.contentType;k(i)&&(e.exchange.response.bodyJson===void 0?n.push({ruleId:this.id,severity:"error",category:"schema",message:"Response body is not valid JSON for JSON content-type",exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"response"}):n.push(...je(s,e.exchange.response.bodyJson,e,"response")))}return n}};function ee(t){if(!t)return null;let[e]=t.trim().split(/\s+/,1);return e?e.toLowerCase():null}function Le(t){return!!t.exchange.request.headers.authorization}function on(t,e){return t?t.split(";").map(r=>r.trim()).some(r=>r.startsWith(`${e}=`)):!1}function an(t,e){let r=t.matchedOperation?.operation;if(!r)return{schemeName:e,schemeType:"unknown",satisfied:!0,reason:"No matched OpenAPI operation."};let n=r.securitySchemes[e];if(!n)return{schemeName:e,schemeType:"missing",satisfied:!1,reason:"Security scheme is referenced but not defined in components.securitySchemes."};let s=String(n.type??"unknown");if(n.type==="apiKey"){let i=String(n.name??""),o=String(n.in??"header");if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:'apiKey scheme is missing the "name" field in the OpenAPI spec.'};if(o==="header"){let a=!!t.exchange.request.headers[i.toLowerCase()];return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey header "${i}".`:`Missing required apiKey header "${i}".`}}if(o==="query"){let a=t.exchange.request.query.has(i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey query parameter "${i}".`:`Missing required apiKey query parameter "${i}".`}}if(o==="cookie"){if(t.ignoreCookies)return{schemeName:e,schemeType:s,satisfied:!0,skipped:!0,reason:`Skipped apiKey cookie "${i}" validation because --ignore-cookies is enabled.`};let a=on(t.exchange.request.headers.cookie,i);return{schemeName:e,schemeType:s,satisfied:a,reason:a?`Found required apiKey cookie "${i}".`:`Missing required apiKey cookie "${i}".`}}return{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported apiKey location "${o}" in OpenAPI security scheme.`}}if(n.type==="http"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header."};let o=String(n.scheme??"").toLowerCase(),a=ee(i);if(!o)return{schemeName:e,schemeType:s,satisfied:!0,reason:"Authorization header is present and no specific HTTP auth scheme is documented."};if(!a)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Authorization header is malformed and does not include an auth scheme."};let c=a===o;return{schemeName:e,schemeType:s,satisfied:c,reason:c?`Authorization uses expected "${o}" scheme.`:`Authorization uses "${a}" but "${o}" is required.`}}if(n.type==="oauth2"||n.type==="openIdConnect"){let i=t.exchange.request.headers.authorization;if(!i)return{schemeName:e,schemeType:s,satisfied:!1,reason:"Missing Authorization header for OAuth2/OpenID Connect scheme."};let o=ee(i),a=o==="bearer";return{schemeName:e,schemeType:s,satisfied:a,reason:a?"Authorization uses bearer token as expected for OAuth2/OpenID Connect.":`Authorization scheme "${o??"unknown"}" does not satisfy OAuth2/OpenID Connect (expected bearer).`}}return n.type==="mutualTLS"?{schemeName:e,schemeType:s,satisfied:!0,reason:"mutualTLS cannot be validated from HTTP traffic logs alone."}:{schemeName:e,schemeType:s,satisfied:!1,reason:`Unsupported security scheme type "${s}".`}}function un(t){let e=t.matchedOperation?.operation.security;if(!e)return{satisfied:!0,requirements:[]};if(e.length===0)return{satisfied:!0,requirements:[]};let r=e.map((n,s)=>{let i=Object.keys(n);if(i.length===0)return{requirementIndex:s,satisfied:!0,schemeResults:[]};let o=i.map(a=>an(t,a));return{requirementIndex:s,satisfied:o.every(a=>a.satisfied),schemeResults:o}});return{satisfied:r.some(n=>n.satisfied),requirements:r}}function cn(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.satisfied||e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function _e(t){let e=[];for(let r of t.requirements)for(let n of r.schemeResults)n.skipped&&e.push({requirement:r.requirementIndex+1,schemeName:n.schemeName,reason:n.reason});return e}function pn(t){if(t.length===0)return"All documented security requirements are satisfied.";let e=new Map;for(let n of t){let s=e.get(n.requirement);s?s.push(n):e.set(n.requirement,[n])}let r=Array.from(e.entries()).sort((n,s)=>n[0]-s[0]).map(([n,s])=>{let i=s.map(a=>a.schemeName).join(" + "),o=s.map(a=>a.reason).join(" ");return`Option ${n} (${i}): ${o}`});return r.length===1?`Authentication check failed. ${r[0]}`:`None of the documented authentication options matched. Any one of these options would satisfy the OpenAPI security requirements: ${r.join(" | ")}`}function dn(t){return Array.from(t.exchange.request.query.keys()).filter(e=>{let r=e.toLowerCase();return r.includes("token")||r.includes("apikey")||r.includes("api_key")||r.includes("access_key")})}var ln=/^(?:(?:.+\.)?localhost|127(?:\.\d{1,3}){3}|::1)$/i;function fn(t){let e;try{e=new URL(t.url).hostname}catch{e=t.host?.replace(/:\d+$/,"")}return e?ln.test(e.replace(/^\[|\]$/g,"")):!1}function mn(t){if(t.exchange.request.protocol!=="http:"||!t.exchange.request.protocolKnown||fn(t.exchange.request))return{flag:!1,hasAuthHeader:!1,sensitiveQueryKeys:[]};let e=Le(t),r=dn(t);return{flag:e||r.length>0,hasAuthHeader:e,sensitiveQueryKeys:r}}var D=class{id="security-baseline";analyze(e){if(!e.matchedOperation)return[];let r=[],n=un(e);if(n.satisfied){let i=_e(n);i.length>0&&r.push({ruleId:this.id,severity:"info",category:"security",message:"Some documented cookie-based security checks were skipped",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:i.map(o=>`Skipped option ${o.requirement} (${o.schemeName}): ${o.reason}`).join(" "),skippedChecks:i}})}else{let i=cn(n);r.push({ruleId:this.id,severity:"error",category:"security",message:"Request does not satisfy documented OpenAPI security requirements",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{summary:pn(i),failedChecks:i,skippedChecks:_e(n),authorizationScheme:ee(e.exchange.request.headers.authorization),hasAuthorizationHeader:Le(e)}})}let s=mn(e);return s.flag&&r.push({ruleId:this.id,severity:"warning",category:"security",message:"Potential credential exposure over insecure HTTP transport",exchangeIndex:e.exchange.index,operationId:e.matchedOperation.operation.operationId,specSource:e.matchedOperation.operation.specSource,target:"request",details:{protocol:e.exchange.request.protocol,hasAuthorizationHeader:s.hasAuthHeader,sensitiveQueryKeys:s.sensitiveQueryKeys}}),r}};var K=class{id="undocumented-endpoint";analyze(e){if(e.matchedOperation)return[];let{method:r,path:n,host:s}=e.exchange.request,o=e.matchMode==="strict-host"&&!e.hostCompatibleWithSpecServers?`Undocumented server: ${r} ${n} was sent to "${s}", which does not match any server in the description`:`Undocumented endpoint: ${r} ${n}`;return[{ruleId:this.id,severity:"error",category:"documentation",message:o,exchangeIndex:e.exchange.index,target:"request"}]}};var te={"undocumented-endpoint":()=>new K,"schema-consistency":()=>new H,"security-baseline":()=>new D,"owasp-api-top10":()=>new L},hn=Object.keys(te),gn=["undocumented-endpoint","schema-consistency","security-baseline"];function Ne(t){return!t||t.length===0?gn.map(e=>te[e]()):[...new Set(t)].map(e=>{let r=te[e];if(!r)throw new Error(`Unknown rule id: "${e}". Available rules: ${hn.join(", ")}`);return r()})}var He=oe(ot(),1);var De=oe(at(),1),ze=He.default,Ve=De.default;function ne(t,e){if(!d(t))return!1;let r=e==="request"?"readOnly":"writeOnly";return t[r]===!0||Array.isArray(t.allOf)&&t.allOf.some(n=>d(n)&&n[r]===!0)}function Ke(t,e,r,n=new WeakSet){if(!d(t)||n.has(t))return!1;n.add(t);let s=t.properties;return d(s)&&ne(s[e],r)?!0:[t.allOf,t.oneOf,t.anyOf].some(i=>Array.isArray(i)&&i.some(o=>Ke(o,e,r,n)))}var yn=new Set(["items","additionalItems","additionalProperties","unevaluatedItems","unevaluatedProperties","contains","propertyNames","not","if","then","else"]),vn=new Set(["allOf","anyOf","oneOf","prefixItems"]),Sn=new Set(["properties","patternProperties","dependentSchemas","$defs","definitions"]);function Ue(t,e,r=new WeakSet){if(!d(t))return t;if(r.has(t))return!0;r.add(t);let n=i=>Ue(i,e,r),s={};for(let[i,o]of Object.entries(t))yn.has(i)?s[i]=Array.isArray(o)?o.map(n):n(o):vn.has(i)&&Array.isArray(o)?s[i]=o.map(n):Sn.has(i)&&d(o)?s[i]=Object.fromEntries(Object.entries(o).map(([a,c])=>[a,n(c)])):s[i]=o;return Array.isArray(t.required)&&(s.required=t.required.filter(i=>typeof i!="string"||!Ke(t,i,e))),r.delete(t),s}var T=class{ajv;fallbackAjv;objectSchemaCaches={none:new WeakMap,request:new WeakMap,response:new WeakMap};scalarSchemaCache=new Map;constructor(e){let r={strict:!1,allErrors:!0,allowUnionTypes:!0,discriminator:!0,coerceTypes:e?.coerceTypes?"array":!1,validateFormats:!0,verbose:!0,formats:{enum:!0}};this.ajv=new ze(r),this.fallbackAjv=new ze({...r,discriminator:!1}),Ve(this.ajv),Ve(this.fallbackAjv)}validate(e,r,n){if(e===void 0)return{valid:!0,errors:[]};let s;try{s=this.getOrCompileValidator(e,n)}catch(a){return{valid:!1,errors:[{message:`Schema compilation failed: ${a.message}`}]}}let i=!!s(r),o=s.errors??[];return{valid:i,errors:o}}getOrCompileValidator(e,r){if(d(e)){let o=this.objectSchemaCaches[r??"none"],a=o.get(e);if(a)return a;let c=r?Ue(e,r):e,l=this.compileSchema(c);return o.set(e,l),l}let n=`${r??"none"}:${JSON.stringify(e)}`,s=this.scalarSchemaCache.get(n);if(s)return s;let i=this.compileSchema(e);return this.scalarSchemaCache.set(n,i),i}compileSchema(e){try{return this.ajv.compile(e)}catch{return this.fallbackAjv.compile(e)}}};function Ge(t){switch(t.kind){case"operation":return"operation";case"parameter":return`parameter:${t.in}:${t.name}`;case"response":return`response:${t.status}`;case"property":return`property:${t.target}:${t.status??""}:${t.path}`}}function G(t,e){let r=Ge(e);t.has(r)||t.set(r,{item:e,covered:!1})}function J(t,e){let r=t.get(Ge(e));r&&(r.covered=!0)}function Je(t,e){return t?`${t}.${e}`:e}function F(t,e,r,n,s){if(!(!d(t)||s.has(t))){s.add(t);for(let i of[t.allOf,t.oneOf,t.anyOf])if(Array.isArray(i))for(let o of i)F(o,e,r,n,s);if(d(t.properties))for(let[i,o]of Object.entries(t.properties)){if(ne(o,e.target))continue;let a=Je(r,i);G(n,{kind:"property",...e,path:a}),F(o,e,a,n,s)}d(t.items)&&F(t.items,e,`${r}[]`,n,s),s.delete(t)}}function M(t,e,r,n,s,i){if(!(!d(e)||i.has(e))){i.add(e);for(let o of[e.allOf,e.oneOf,e.anyOf])if(Array.isArray(o))for(let a of o)M(t,a,r,n,s,i);if(d(e.properties)&&d(t))for(let[o,a]of Object.entries(e.properties)){if(t[o]===void 0)continue;let c=Je(n,o);J(s,{kind:"property",...r,path:c}),M(t[o],a,r,c,s,i)}if(d(e.items)&&Array.isArray(t))for(let o of t)M(o,e.items,r,`${n}[]`,s,i);i.delete(e)}}function wn(t,e){let r=new Map;G(r,{kind:"operation"});for(let n of t.requestParameters)e&&n.in==="cookie"||G(r,{kind:"parameter",name:n.name,in:n.in});for(let[n,s]of Object.entries(t.requestBodyContent))k(n)&&F(s,{target:"request"},"",r,new Set);for(let n of t.responseStatuses){G(r,{kind:"response",status:n});for(let[s,i]of Object.entries(t.responseBodyContent[n]??{}))k(s)&&F(i,{target:"response",status:n},"",r,new Set)}return{operation:t,entries:r}}function Rn(t){return t.request.bodyJson!==void 0||t.response?.bodyJson!==void 0}function U(t,e){let r={covered:0,total:0};for(let n of t)for(let s of n.entries.values())s.item.kind===e&&(r.total+=1,s.covered&&(r.covered+=1));return r}function In(t){let e={method:t.operation.method.toUpperCase(),path:t.operation.pathTemplate,operationId:t.operation.operationId,missing:[],covered:[]};for(let r of t.entries.values())(r.covered?e.covered:e.missing).push(r.item);return e}var W=class{states=new Map;exchanges={total:0,matched:0,withBody:0};constructor(e){for(let r of e.openApiIndex.operationsByMethod.values())for(let n of r)this.states.set(n,wn(n,e.ignoreCookies))}record(e,r,n){if(this.exchanges.total+=1,!r)return;let s=this.states.get(r.operation);if(!s)return;this.exchanges.matched+=1,Rn(e)&&(this.exchanges.withBody+=1);let{operation:i,pathParams:o}=r,{entries:a}=s;J(a,{kind:"operation"});for(let u of i.requestParameters){let m=V(u,e.request,o,n);m!=null&&J(a,{kind:"parameter",name:u.name,in:u.in})}if(e.request.bodyJson!==void 0){let u=A(i.requestBodyContent,e.request.contentType);M(e.request.bodyJson,u,{target:"request"},"",a,new Set)}let c=e.response;if(!c)return;let l=z(c.status,i.responseStatuses);if(l!==void 0&&(J(a,{kind:"response",status:l}),c.bodyJson!==void 0)){let u=A(i.responseBodyContent[l]??{},c.contentType);M(c.bodyJson,u,{target:"response",status:l},"",a,new Set)}}finalize(){let e=Array.from(this.states.values()).sort((r,n)=>r.operation.pathTemplate.localeCompare(n.operation.pathTemplate)||r.operation.method.localeCompare(n.operation.method));return{exchanges:this.exchanges,totals:{operations:U(e,"operation"),parameters:U(e,"parameter"),properties:U(e,"property"),responses:U(e,"response")},operations:e.map(In)}}};var Pn=10,We={info:0,warning:1,error:2};function bn(){return{totalExchanges:0,documentedExchanges:0,undocumentedExchanges:0,skippedExchanges:0,hostCompatibleExchanges:0,findingsBySeverity:{info:0,warning:0,error:0},findingsByRule:{}}}function On(t,e){t.findingsBySeverity[e.severity]+=1,t.findingsByRule[e.ruleId]=(t.findingsByRule[e.ruleId]??0)+1}function kn(t,e){return{...t,id:Qe(),method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function An(t,e){return{exchangeIndex:t.exchangeIndex,ruleId:t.ruleId,severity:t.severity,category:t.category,message:t.message,occurrences:1,operationId:t.operationId,specSource:t.specSource,target:t.target,schemaPath:t.schemaPath,dataPath:t.dataPath,details:t.details,method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function xn(t,e){if(!e)return;t.operationId||(t.operationId=e.operation.operationId),t.specSource||(t.specSource=e.operation.specSource);let r=t.details??{};if(!d(r)){t.details={operationPathTemplate:e.operation.pathTemplate};return}typeof r.operationPathTemplate!="string"&&(r.operationPathTemplate=e.operation.pathTemplate),t.details=r}function Cn(t){let e=new Set,r=!1;for(let n of t.operationsByMethod.values())for(let s of n)for(let i of s.servers)i.host?e.add(i.host):r=!0;return{specServerHosts:e,hasHostlessSpecServer:r}}async function $n(t,e){let r=[];for(let n of t)try{let s=await n.analyze(e);s.length>0&&r.push(...s)}catch(s){R.warn(`Rule "${n.id}" failed to execute: ${s.message}
18
+ `)}return r}var Ye=class t{startedAt=Date.now();runId=Qe();previewLimit;rules;schemaValidator=new T;coercingSchemaValidator=new T({coerceTypes:!0});options;coverage;counters=bn();findings=[];previewFindings=[];problemGroupsByRule={};problemKeyStats=new Map;totalProblemGroups=0;server;ignoreHeaders;minSeverityRank;specServerHosts;hasHostlessSpecServer;constructor(e,r){this.options=e,this.rules=r,this.server=be(e.server),this.ignoreHeaders=e.ignoreHeaders?Ie(e.ignoreHeaders):void 0;let{specServerHosts:n,hasHostlessSpecServer:s}=Cn(e.openApiIndex);this.specServerHosts=n,this.hasHostlessSpecServer=s,this.minSeverityRank=We[e.minSeverity??"info"],this.previewLimit=e.previewFindingsLimit&&e.previewFindingsLimit>0?e.previewFindingsLimit:Pn,this.coverage=e.coverage?new W({openApiIndex:e.openApiIndex,ignoreCookies:e.ignoreCookies??!1}):void 0}static create(e){if(e.openApiIndex.loadedOperations===0)throw new Error("No OpenAPI operations available to validate traffic against.");return new t(e,Ne(e.activeRules))}async process(e){this.counters.totalExchanges+=1;let r=qe(e.request.headers.cookie),n;if(this.server!==void 0&&(n=Oe(e.request,this.server),n===void 0))return this.counters.skippedExchanges+=1,this.coverage?.record(e,null,r),[];let s=this.isHostCompatible(e.request.host);s&&(this.counters.hostCompatibleExchanges+=1);let i=xe(this.options.openApiIndex,e,this.options.matchMode,n);i?this.counters.documentedExchanges+=1:this.counters.undocumentedExchanges+=1,this.coverage?.record(e,i,r);let o=await $n(this.rules,{exchange:e,matchedOperation:i,matchMode:this.options.matchMode,hostCompatibleWithSpecServers:n!==void 0||s,ignoreCookies:this.options.ignoreCookies??!1,ignoreHeaders:this.ignoreHeaders,cookies:r,validateSchema:(c,l,u)=>u?.coerce?this.coercingSchemaValidator.validate(c,l,u?.target):this.schemaValidator.validate(c,l,u?.target)}),a=[];for(let c of o){if(We[c.severity]<this.minSeverityRank)continue;xn(c,i);let l=kn(c,e);this.findings.push(l),a.push(l),On(this.counters,c);let u=B({ruleId:c.ruleId,severity:c.severity,message:c.message,operationId:c.operationId,path:e.request.path,target:c.target,schemaPath:c.schemaPath}),m=this.problemKeyStats.get(u);if(m){m.occurrences+=1,m.previewIndex!==null&&(this.previewFindings[m.previewIndex].occurrences=m.occurrences);continue}if(this.totalProblemGroups+=1,this.problemGroupsByRule[c.ruleId]=(this.problemGroupsByRule[c.ruleId]??0)+1,this.previewFindings.length<this.previewLimit){let w=this.previewFindings.length;this.previewFindings.push(An(c,e)),this.problemKeyStats.set(u,{occurrences:1,previewIndex:w});continue}this.problemKeyStats.set(u,{occurrences:1,previewIndex:null})}return a}isHostCompatible(e){return!e||this.hasHostlessSpecServer||this.specServerHosts.has(e.toLowerCase())}finalize(){let e={runId:this.runId,totalExchanges:this.counters.totalExchanges,documentedExchanges:this.counters.documentedExchanges,undocumentedExchanges:this.counters.undocumentedExchanges,skippedExchanges:this.counters.skippedExchanges,hostCompatibleExchanges:this.counters.hostCompatibleExchanges,findingsBySeverity:this.counters.findingsBySeverity,findingsByRule:this.counters.findingsByRule,problemGroupsByRule:this.problemGroupsByRule,totalProblemGroups:this.totalProblemGroups,durationMs:Date.now()-this.startedAt,previewFindings:this.previewFindings,previewLimit:this.previewLimit,previewTruncated:this.totalProblemGroups>this.previewFindings.length};return{runId:this.runId,summary:e,findings:this.findings,coverage:this.coverage?.finalize()}}};import{stat as En}from"node:fs/promises";var qn=["get","put","post","delete","patch","head","options","trace"],Tn=new Set(["query","header","path","cookie"]),Fn=/^(default|[1-5](\d{2}|xx))$/i;function Mn(t){return qn.includes(t)}function jn(t){return Tn.has(t)}function Xe(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!d(r))continue;let n=r.in;typeof n!="string"||!jn(n)||e.push({name:String(r.name??""),in:n,required:!!r.required||n==="path",style:typeof r.style=="string"?r.style:void 0,schema:r.schema})}return e}function Ze(t){let e=t.in==="header";return`${t.in}:${e?t.name.toLowerCase():t.name}`}function Bn(t,e){let r=new Map;for(let n of t)r.set(Ze(n),n);for(let n of e)r.set(Ze(n),n);return Array.from(r.values())}function tt(t){let e={};if(!d(t))return e;for(let[r,n]of Object.entries(t))d(n)&&"schema"in n&&(e[r.toLowerCase()]=n.schema);return e}function _n(t){return d(t)?tt(t.content):{}}function Ln(t){let e={};for(let[r,n]of Object.entries(t))!d(n)||!("content"in n)||(e[r]=tt(n.content));return e}function Nn(t,e,r){let n=t??e??r;return!Array.isArray(n)||n.length===0?[N("/")]:n.map(s=>{if(!d(s))return N("/");let i=typeof s.url=="string"?s.url:"/",o=d(s.variables)?s.variables:void 0;return N(i,o)})}function zn(t,e,r){return r||`${t.toUpperCase()} ${e}`}function Vn(t){try{let e=fe(t.parsed);return le(e)==="oas3"?e:null}catch{return null}}function et(t){return Array.isArray(t)?t:void 0}function Hn(t,e){let r,n,s={},i="/",o=[],a;return{Root:{enter(c){r=c.servers,n=c.security;let l=d(c.components)?c.components.securitySchemes:void 0;s=d(l)?l:{}}},Paths:{PathItem:{enter(c,l){i=Ee(String(l.key)),o=Xe(c.parameters),a=c.servers},Operation:{enter(c,l){let u=String(l.key);if(!Mn(u))return;let m=Bn(o,Xe(c.parameters)),w=Re(i),j=Nn(c.servers,a,r),b=c.requestBody,f=d(c.responses)?Object.fromEntries(Object.entries(c.responses).filter(([Y])=>Fn.test(Y))):{},h={operationId:zn(u,i,typeof c.operationId=="string"?c.operationId:void 0),method:u,pathTemplate:i,pathRegex:w.regex,pathParams:w.params,pathScore:w.score,servers:j,requestParameters:m,requestBodyContent:_n(b),requestBodyRequired:d(b)&&!!b.required,responseStatuses:Object.keys(f),responseBodyContent:Ln(f),security:et(c.security)??et(n),securitySchemes:s,specSource:t},y=e.get(u)??[];y.push(h),e.set(u,y)}}}}}}function Dn(t,e,r,n,s){let i=ae(r.extendTypes(ue(e),e),r),o=new Map,a={problems:[],specVersion:e,config:r,visitorsData:{}},c=me([{severity:"warn",ruleId:"drift-index",visitor:Hn(n,s)}],i);he({document:t,rootType:i.Root,normalizedVisitors:c,resolvedRefMap:o,ctx:a})}function Kn(t){return`${t.host??""}|${t.basePath}`}function Un(t){for(let e of t.values()){let r=new Map;for(let n of e){let s=r.get(n.pathRegex.source)??[];s.push(n),r.set(n.pathRegex.source,s)}for(let n of r.values()){let s=new Map;for(let i of n)for(let o of i.servers){let a=Kn(o),c=s.get(a)??new Set;c.add(i.specSource),s.set(a,c)}for(let i of s.values())if(i.size>1){let[o]=n;R.warn(`"${o.method.toUpperCase()} ${o.pathTemplate}" is documented for the same server in multiple descriptions (${Array.from(i).join(", ")}). Matching traffic is validated against only one of them.
19
+ `);break}}}}function Gn(t,e){for(let n of t.values())n.sort((s,i)=>i.pathScore-s.pathScore);let r=Array.from(t.values()).reduce((n,s)=>n+s.length,0);return{operationsByMethod:t,loadedSpecs:e,loadedOperations:r}}async function Jn(t){return(await En(t)).isDirectory()?{specFiles:await ye(t),fromDirectory:!0}:{specFiles:[t],fromDirectory:!1}}async function Ur(t,e){let{specFiles:r,fromDirectory:n}=await Jn(t),s=new Map,i=new ce(e.resolve),o=0;for(let a of r){let c=await i.resolveDocument(null,a,!0);if(c instanceof Error){R.warn(`Failed to load OpenAPI description ${a}: ${c.message}
20
+ `);continue}let l=Vn(c);if(!l){n||R.warn(`Skipping ${a}: not an OpenAPI 3.x description.
21
+ `);continue}let u;try{let{bundle:m}=await ge({config:e,doc:c,externalRefResolver:i,dereference:!0});u=m}catch(m){R.warn(`Failed to bundle OpenAPI description ${a}: ${m.message}
22
+ `);continue}o+=1,Dn(u,l,e,a,s)}return o>1&&Un(s),Gn(s,o)}function Jr(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}export{Zn as a,Ye as b,Ur as c,Jr as d};
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a as o,c as n}from"./HBUZKWXC.js";import{X as t}from"./M4YE5ALG.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as m}from"node:child_process";var j=async({argv:e})=>{t.info(`
7
+ import{a as o,c as n}from"./HBUZKWXC.js";import{ga as t}from"./MT5H2R3P.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as m}from"node:child_process";var j=async({argv:e})=>{t.info(`
8
8
  Launching eject using NPX.
9
9
 
10
10
  `);let{npxExecutableName:c,sanitize:r,shell:i}=n(),p=r(e.path,o),a=r(e["project-dir"],o);m(c,["-y","@redocly/realm","eject",`${e.type}`,p,`-d=${a}`,e.force?`--force=${e.force}`:""],{stdio:"inherit",shell:i}).on("error",s=>{throw t.info(`Eject launch failed: ${s.message}`),new Error("Eject launch failed.")})};export{j as handleEject};