@redocly/cli 2.71.2 → 2.72.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES +29 -7
  3. package/lib/chunks/{EHJ3FMW6.js → 2AW4F6ZZ.js} +1 -1
  4. package/lib/chunks/{3EQNI6CT.js → 2MF3MKAD.js} +1 -1
  5. package/lib/chunks/{UYZXI3NO.js → 2X2KHSF3.js} +1 -1
  6. package/lib/chunks/{YF4FMOTE.js → 3FA5W77S.js} +1 -1
  7. package/lib/chunks/{VPTYPV6P.js → 3FVHXIZN.js} +1 -1
  8. package/lib/chunks/{P5T6BIKW.js → 3N53VPSU.js} +1 -1
  9. package/lib/chunks/{KLGUZBJO.js → 3N73A66H.js} +1 -1
  10. package/lib/chunks/{JO76DPXR.js → 3WOXO2JS.js} +1 -1
  11. package/lib/chunks/{ORWIUECT.js → 4A5R4H5W.js} +1 -1
  12. package/lib/chunks/{NXREEI2S.js → 4LTPQZBP.js} +1 -1
  13. package/lib/chunks/{L325HIGK.js → 4QC7OVHI.js} +1 -1
  14. package/lib/chunks/{FDKY4PGX.js → 542GVIYM.js} +1 -1
  15. package/lib/chunks/5JF6EUWW.js +9 -0
  16. package/lib/chunks/{6X42UQ3O.js → 5MZU5MHZ.js} +1 -1
  17. package/lib/chunks/{DZT5NLUB.js → 5UPBGRBZ.js} +1 -1
  18. package/lib/chunks/{WO6IIVA3.js → 6LZX65VY.js} +8 -8
  19. package/lib/chunks/{NEWT5A6S.js → 6RTITFQA.js} +1 -1
  20. package/lib/chunks/{IQLQH23V.js → 6Y6B2SKE.js} +1 -1
  21. package/lib/chunks/765BYRQR.js +7 -0
  22. package/lib/chunks/{2TG3DP4I.js → 7NZS5HXU.js} +1 -1
  23. package/lib/chunks/{5CR6AOLY.js → A65OW7M7.js} +3 -3
  24. package/lib/chunks/ARUYNQHA.js +7 -0
  25. package/lib/chunks/BJ6Z66KZ.js +7 -0
  26. package/lib/chunks/{T77BOGYV.js → BWGBTYNU.js} +1 -1
  27. package/lib/chunks/{DM4EUYBB.js → BZTZIEWS.js} +2 -2
  28. package/lib/chunks/{4S6LRPCX.js → CBFNHKDJ.js} +1 -1
  29. package/lib/chunks/{OFIQ2EST.js → CYCPHJNX.js} +33 -33
  30. package/lib/chunks/DSBDKSRR.js +53 -0
  31. package/lib/chunks/E2CEKR6N.js +22 -0
  32. package/lib/chunks/{HRZLSSOF.js → EMWHLZB6.js} +1 -1
  33. package/lib/chunks/{DWXDCKZ7.js → ENIFTFYK.js} +1 -1
  34. package/lib/chunks/{BIS2ZFGS.js → ETJMQLWJ.js} +1 -1
  35. package/lib/chunks/{ADACRYTN.js → EU5WR2O3.js} +1 -1
  36. package/lib/chunks/{FAFMGLT6.js → FLQQ3VRQ.js} +1 -1
  37. package/lib/chunks/{BPJTNQBC.js → FZZACVYL.js} +1 -1
  38. package/lib/chunks/{N4GCIKY4.js → G7A4OE2M.js} +1 -1
  39. package/lib/chunks/{HP7UD4BA.js → GCAL2PYM.js} +1 -1
  40. package/lib/chunks/{MJ2NI6MR.js → GGHLD27S.js} +1 -1
  41. package/lib/chunks/{U4MI7HDM.js → GMPHU6KM.js} +1 -1
  42. package/lib/chunks/{HTFKP5HH.js → GWBLS542.js} +1 -1
  43. package/lib/chunks/{U2F3JOT2.js → GXILNSWK.js} +1 -1
  44. package/lib/chunks/{5AVTCY6F.js → HM7M6465.js} +1 -1
  45. package/lib/chunks/{5HPO77VR.js → I2JZXLJ6.js} +2 -2
  46. package/lib/chunks/I3YF3GEY.js +13 -0
  47. package/lib/chunks/{YWRFPTTI.js → IIQW437Z.js} +1 -1
  48. package/lib/chunks/{4H3DPQDW.js → IM4YIUUN.js} +1 -1
  49. package/lib/chunks/{LET2MPMU.js → JDMRVD45.js} +1 -1
  50. package/lib/chunks/{XVS7B4RZ.js → KIFXQTTL.js} +1 -1
  51. package/lib/chunks/{UVKUPD4U.js → L4VSY42B.js} +1 -1
  52. package/lib/chunks/LH3ONQEX.js +17 -0
  53. package/lib/chunks/{SSEMMWPY.js → LUNR7GV4.js} +1 -1
  54. package/lib/chunks/{LY6BDOEF.js → LY5MGNMA.js} +1 -1
  55. package/lib/chunks/{XQEXWC5L.js → MAACTVYP.js} +1 -1
  56. package/lib/chunks/{GFSMOHUE.js → MTKICX4T.js} +1 -1
  57. package/lib/chunks/{ZXOX7NF2.js → NMAWU5S4.js} +1 -1
  58. package/lib/chunks/{I4TK6NG7.js → PJHQKG7X.js} +1 -1
  59. package/lib/chunks/PTBPNZRZ.js +7 -0
  60. package/lib/chunks/{CZX7WE2R.js → PUZ5QSL3.js} +1 -1
  61. package/lib/chunks/{JRVXIEVC.js → PW2XFZOB.js} +1 -1
  62. package/lib/chunks/{TH44RKLO.js → QAT3DPT3.js} +1 -1
  63. package/lib/chunks/{QXXAC25O.js → R67IVFZH.js} +1 -1
  64. package/lib/chunks/RA4FAJM3.js +59 -0
  65. package/lib/chunks/{AZ5LIJEO.js → RF5LL2UZ.js} +1 -1
  66. package/lib/chunks/{JOUEVI3E.js → RQPH22PV.js} +1 -1
  67. package/lib/chunks/S3B562IT.js +7 -0
  68. package/lib/chunks/{3FR3456Q.js → S43EG4DB.js} +1 -1
  69. package/lib/chunks/{CER2D6ZD.js → S7VIXBKD.js} +7 -7
  70. package/lib/chunks/{VJZDR6KS.js → TFPMT2XD.js} +1529 -4
  71. package/lib/chunks/{AXGFQS75.js → U56BQ2BR.js} +2 -2
  72. package/lib/chunks/{KJNBOXDI.js → UOTHMCTM.js} +3 -3
  73. package/lib/chunks/{CR5TYFBN.js → VHZJNDWE.js} +2 -2
  74. package/lib/chunks/{BOTTA3HA.js → VOYPXV3Z.js} +1 -1
  75. package/lib/chunks/{UTEOWLD5.js → VS4MTPCM.js} +1 -1
  76. package/lib/chunks/{QTSECOQB.js → WEPGHS5R.js} +2 -2
  77. package/lib/chunks/{LKNL5LEV.js → WRKMMY3F.js} +1 -1
  78. package/lib/chunks/{7JS7JGWP.js → WTJ3S4D7.js} +1 -1
  79. package/lib/chunks/X22IMAJK.js +199 -0
  80. package/lib/chunks/{W7TN2XCW.js → X3FFOCXC.js} +1 -1
  81. package/lib/chunks/{CRJEY7P3.js → XTI7EXWX.js} +1 -1
  82. package/lib/chunks/{BH4FA7AH.js → YA5KTHFN.js} +1 -1
  83. package/lib/chunks/{Z6GFQV2Y.js → YA6D5EUI.js} +1 -1
  84. package/lib/chunks/{HMYFTLS7.js → ZFET6WME.js} +1 -1
  85. package/lib/chunks/{R32HBYOH.js → ZXB5O6JQ.js} +1 -1
  86. package/lib/eject-assets/AGENTS.md +1 -1
  87. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  88. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  89. package/lib/eject-assets/generators/cli/index.ts +2 -2
  90. package/lib/eject-assets/generators/cli/render.ts +1 -1
  91. package/lib/eject-assets/generators/go/client.ts +1 -1
  92. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  93. package/lib/eject-assets/generators/go/index.ts +2 -2
  94. package/lib/eject-assets/generators/go/models.ts +1 -1
  95. package/lib/eject-assets/generators/go/naming.ts +1 -1
  96. package/lib/eject-assets/generators/go/operations.ts +1 -1
  97. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  98. package/lib/eject-assets/generators/go/types.ts +1 -1
  99. package/lib/eject-assets/generators/java/client.ts +66 -0
  100. package/lib/eject-assets/generators/java/descriptor.ts +72 -0
  101. package/lib/eject-assets/generators/java/index.ts +245 -0
  102. package/lib/eject-assets/generators/java/models.ts +362 -0
  103. package/lib/eject-assets/generators/java/naming.ts +135 -0
  104. package/lib/eject-assets/generators/java/operations.ts +300 -0
  105. package/lib/eject-assets/generators/java/pagination.ts +94 -0
  106. package/lib/eject-assets/generators/java/types.ts +103 -0
  107. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  108. package/lib/eject-assets/generators/mock/index.ts +2 -2
  109. package/lib/eject-assets/generators/mock/render.ts +1 -1
  110. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  111. package/lib/eject-assets/generators/mock/values.ts +1 -1
  112. package/lib/eject-assets/generators/php/client.ts +1 -1
  113. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  114. package/lib/eject-assets/generators/php/index.ts +2 -2
  115. package/lib/eject-assets/generators/php/models.ts +1 -1
  116. package/lib/eject-assets/generators/php/naming.ts +1 -1
  117. package/lib/eject-assets/generators/php/operations.ts +1 -1
  118. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  119. package/lib/eject-assets/generators/php/types.ts +1 -1
  120. package/lib/eject-assets/generators/python/client.ts +1 -1
  121. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  122. package/lib/eject-assets/generators/python/index.ts +2 -2
  123. package/lib/eject-assets/generators/python/models.ts +1 -1
  124. package/lib/eject-assets/generators/python/naming.ts +1 -1
  125. package/lib/eject-assets/generators/python/operations.ts +1 -1
  126. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  127. package/lib/eject-assets/generators/python/types.ts +1 -1
  128. package/lib/eject-assets/generators/swr/index.ts +2 -2
  129. package/lib/eject-assets/generators/swr/render.ts +1 -1
  130. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  131. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  132. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  133. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  134. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  135. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  136. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  137. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  138. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  139. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  140. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  141. package/lib/eject-assets/generators/typescript/operations.ts +1 -1
  142. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  143. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  144. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  145. package/lib/eject-assets/generators/zod/index.ts +2 -2
  146. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  147. package/lib/eject-assets/skills/client-generators/SKILL.md +1 -1
  148. package/lib/eject-assets/skills/java-generator/SKILL.md +161 -0
  149. package/lib/index.js +91 -90
  150. package/lib/skills/redocly-cli/SKILL.md +3 -1
  151. package/package.json +1 -1
  152. package/lib/chunks/2ZEKFWJQ.js +0 -13
  153. package/lib/chunks/3VOQMXIZ.js +0 -7
  154. package/lib/chunks/7GADNOVY.js +0 -9
  155. package/lib/chunks/FRQHCFKP.js +0 -199
  156. package/lib/chunks/J2EPFEBO.js +0 -17
  157. package/lib/chunks/JZATGVUO.js +0 -53
  158. package/lib/chunks/KNMNSDHR.js +0 -7
  159. package/lib/chunks/U5DIFWGH.js +0 -7
@@ -166,7 +166,7 @@ Configure it durably under a `client` block in `redocly.yaml` instead of flags:
166
166
 
167
167
  ```yaml
168
168
  client:
169
- generators: [typescript, zod] # add-ons: tanstack-query, swr, mock, transformers, or a plugin path
169
+ generators: [typescript, zod] # add-ons: tanstack-query, swr, mock, transformers; SDKs: python, go, php, java; or a plugin path
170
170
  outputMode: split
171
171
  pagination: # config-only, no CLI flag
172
172
  style: cursor
@@ -204,6 +204,7 @@ The platform builds a preview in a few minutes; `redocly project pr status` then
204
204
 
205
205
  `respect` executes an [Arazzo](https://spec.openapis.org/arazzo/latest.html) description as a test suite against a running API, asserting real responses match the description.
206
206
  Start from `generate-arazzo <openapi>` to scaffold the workflows, then refine the steps and success criteria by hand.
207
+ A step that leaves out `parameters` or `requestBody` takes them from the description's examples, or generates them from the schema.
207
208
 
208
209
  ## Workflow
209
210
 
@@ -220,6 +221,7 @@ Start from `generate-arazzo <openapi>` to scaffold the workflows, then refine th
220
221
  - v2 is ESM-only: Node.js v22.12.0+ (or v20.19.0+).
221
222
  - `bundle` and `join` differ: `bundle` collapses one multi-file API into one file; `join` merges separate APIs into one description.
222
223
  - `respect` currently covers only synchronous HTTP flow.
224
+ - A `respect` step that lists any `parameters` takes no parameters from the API description; list every required one.
223
225
  - Any `redocly.yaml` in the working directory configures every command — a stray one changes lint results silently.
224
226
  - `--extends` on the command line sets the base ruleset for that run; useful for a quick `--extends=spec` conformance check.
225
227
  - `generate-client` needs the `typescript` package (6.x) available at generation time; the generated client itself compiles with any TypeScript, including 7.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/cli",
3
- "version": "2.71.2",
3
+ "version": "2.72.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,13 +0,0 @@
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 P,b as y,c as $}from"./XQEXWC5L.js";import{fa as h,wa as x}from"./FRQHCFKP.js";function N(t){let e=t.trim(),n=e.match(/^```(?:ya?ml|json)?\s*\n([\s\S]*?)\n```$/);return n?n[1]:e}async function O(t,e){let r=(await x({source:t,config:e})).filter(o=>o.severity==="error");if(r.length>0){let o=r.slice(0,5).map(s=>`${s.ruleId}: ${s.message}`).join("; ");throw new Error(`the result has ${r.length} validation problem(s): ${o}`)}}import{spawn as T}from"node:child_process";import{mkdtemp as v}from"node:fs/promises";import{tmpdir as R}from"node:os";import S from"node:path";var I=3e5,a=class extends Error{},C;function L(){return C??=v(S.join(R(),"redocly-ai-")),C}async function w(t,e,n,r){let o=await L();return new Promise((s,u)=>{let i=T(t,e,{stdio:["pipe","pipe","pipe"],cwd:o,env:{...process.env,...r}}),l="",f="",g=!1,d=setTimeout(()=>{g=!0,i.kill("SIGKILL")},I);i.stdout.on("data",c=>{l+=c.toString()}),i.stderr.on("data",c=>{f+=c.toString()}),i.on("error",c=>{if(clearTimeout(d),c.code==="ENOENT"){u(new a(`Could not find the "${t}" CLI on PATH. Is it installed?`));return}u(c)}),i.on("close",c=>{if(clearTimeout(d),g){u(new Error(`The "${t}" CLI did not respond within ${I/1e3} seconds.`));return}s({stdout:l,stderr:f,code:c})}),i.stdin.on("error",()=>{}),i.stdin.end(n)})}async function A(t){let e=["-p","--output-format","text","--tools","","--strict-mcp-config","--setting-sources","","--no-session-persistence","--append-system-prompt",t.system];t.model&&e.push("--model",t.model);let{stdout:n,stderr:r,code:o}=await w("claude",e,t.user,{CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC:"1"});if(o!==0)throw new Error(`claude CLI exited with code ${o}: ${r.trim()||n.trim()}`);if(!n.trim())throw new Error("claude CLI returned no output.");return{text:n}}async function b(t){let e=["exec","--skip-git-repo-check","--sandbox","read-only","-c","mcp_servers={}","-c","project_doc_max_bytes=0"];t.model&&e.push("--model",t.model),e.push("-");let n=`${t.system}
8
-
9
- ${t.user}`,{stdout:r,stderr:o,code:s}=await w("codex",e,n);if(s!==0)throw new Error(`codex CLI exited with code ${s}: ${o.trim()||r.trim()}`);if(!r.trim())throw new Error("codex CLI returned no output.");return{text:r}}async function _(t){let e=["-p","--output-format","text","--trust"];t.model&&e.push("--model",t.model);let n=`${t.system}
10
-
11
- ${t.user}`,r;try{r=await w("cursor-agent",e,n)}catch(i){if(!(i instanceof a))throw i;try{r=await w("agent",e,n)}catch(l){throw l instanceof a?new a('Could not find the Cursor CLI ("cursor-agent" or "agent") on PATH. Is it installed?'):l}}let{stdout:o,stderr:s,code:u}=r;if(u!==0)throw new Error(`cursor CLI exited with code ${u}: ${s.trim()||o.trim()}`);if(!o.trim())throw new Error("cursor CLI returned no output.");return{text:o}}async function U(t,e){switch(t){case"claude":return A(e);case"codex":return b(e);case"cursor":return _(e);default:throw new Error(`Unknown AI provider: ${t}`)}}async function K(t){let{items:e}=t,n=new Array(e.length).fill(null),r=new P,o=new Set,s=0,u=0,i=!1,l=()=>$(r,{action:t.action,inFlight:o,position:s+1,total:e.length}),f=async()=>{for(;!i&&u<e.length;){let d=u++,c=e[d],m=t.label(c),E=Date.now();o.add(m),l();try{n[d]=await t.run(c,d),s+=1,o.delete(m),y(r),h.info(`[${s}/${e.length}] ${m} \u2014 ${t.successNote} (${Math.round((Date.now()-E)/1e3)}s)
12
- `)}catch(p){if(s+=1,o.delete(m),y(r),p instanceof a)throw i=!0,p;h.warn(`[${s}/${e.length}] ${m} \u2014 ${t.failureNote}: ${p instanceof Error?p.message:String(p)}
13
- `)}l()}},g=Math.max(1,Math.min(t.concurrency,e.length));for(let d of await Promise.allSettled(Array.from({length:g},f)))if(d.status==="rejected")throw d.reason;return n}export{N as a,O as b,U as c,K as d};
@@ -1,7 +0,0 @@
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 ee,c as te,e as ne}from"./RFWIIJFG.js";var F=te((N,k)=>{(function(e,t){typeof N=="object"&&typeof k<"u"?t(N):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.ULID={}))})(N,(function(e){"use strict";function t(r){let c=new Error(r);return c.source="ulid",c}let n="0123456789ABCDEFGHJKMNPQRSTVWXYZ",o=n.length,i=Math.pow(2,48)-1,a=10,u=16;function m(r,c,s){return c>r.length-1?r:r.substr(0,c)+s+r.substr(c+1)}function p(r){let c,s=r.length,d,l,g=o-1;for(;!c&&s-->=0;){if(d=r[s],l=n.indexOf(d),l===-1)throw t("incorrectly encoded string");if(l===g){r=m(r,s,n[0]);continue}c=m(r,s,n[l+1])}if(typeof c=="string")return c;throw t("cannot increment this string")}function f(r){let c=Math.floor(r()*o);return c===o&&(c=o-1),n.charAt(c)}function v(r,c){if(isNaN(r))throw new Error(r+" must be a number");if(r>i)throw t("cannot encode time greater than "+i);if(r<0)throw t("time must be positive");if(Number.isInteger(Number(r))===!1)throw t("time must be an integer");let s,d="";for(;c>0;c--)s=r%o,d=n.charAt(s)+d,r=(r-s)/o;return d}function y(r,c){let s="";for(;r>0;r--)s=f(c)+s;return s}function E(r){if(r.length!==a+u)throw t("malformed ulid");var c=r.substr(0,a).split("").reverse().reduce((s,d,l)=>{let g=n.indexOf(d);if(g===-1)throw t("invalid character found: "+d);return s+=g*Math.pow(o,l)},0);if(c>i)throw t("malformed ulid, timestamp too large");return c}function I(r=!1,c){c||(c=typeof window<"u"?window:null);let s=c&&(c.crypto||c.msCrypto);if(s)return()=>{let d=new Uint8Array(1);return s.getRandomValues(d),d[0]/255};try{let d=ee("crypto");return()=>d.randomBytes(1).readUInt8()/255}catch{}if(r){try{console.error("secure crypto unusable, falling back to insecure Math.random()!")}catch{}return()=>Math.random()}throw t("secure crypto unusable, insecure Math.random not allowed")}function j(r){return r||(r=I()),function(s){return isNaN(s)&&(s=Date.now()),v(s,a)+y(u,r)}}function R(r){r||(r=I());let c=0,s;return function(l){if(isNaN(l)&&(l=Date.now()),l<=c){let A=s=p(s);return v(c,a)+A}c=l;let g=s=y(u,r);return v(l,a)+g}}let M=j();e.decodeTime=E,e.detectPrng=I,e.encodeRandom=y,e.encodeTime=v,e.factory=j,e.incrementBase32=p,e.monotonicFactory=R,e.randomChar=f,e.replaceCharAt=m,e.ulid=M}))});var $={name:"@redocly/cli",version:"2.71.2",description:"",license:"MIT",bin:{redocly:"bin/cli.js",openapi:"bin/cli.js"},type:"module",engines:{node:">=22.12.0 || >=20.19.0 <21.0.0",npm:">=10"},engineStrict:!0,scripts:{build:"node ./scripts/build.mjs","prepare:publish-dir":"node ./scripts/prepare-publish-dir.mjs","clean:publish-dir":`node -e "require('fs').rmSync('.publish', {recursive:true, force:true})"`},publishConfig:{directory:".publish"},repository:{type:"git",url:"git+https://github.com/Redocly/redocly-cli.git"},homepage:"https://github.com/Redocly/redocly-cli",keywords:["linter","OpenAPI","Swagger","OpenAPI linter","Swagger linter","AsyncAPI linter","Arazzo linter","oas"],contributors:["Roman Hotsiy <roman@redocly.com> (https://redocly.com/)"],devDependencies:{"@modelcontextprotocol/sdk":"^1.32.1","@opentelemetry/exporter-trace-otlp-http":"0.219.0","@opentelemetry/resources":"2.8.0","@opentelemetry/sdk-trace-node":"2.8.0","@opentelemetry/semantic-conventions":"1.41.1","@redocly/cli-otel":"0.3.7","@redocly/client-generator":"0.7.13","@redocly/openapi-core":"2.71.2","@redocly/recheck":"2.71.2","@redocly/respect-core":"2.71.2","@redocly/reunite-integration":"2.71.2","@types/cookie":"0.6.0","@types/har-format":"^1.2.16","@types/react":"^17.0.0 || ^18.2.21 || ^19.2.16","@types/react-dom":"^17.0.0 || ^18.2.7 || ^19.2.3","@types/semver":"^7.5.0","@types/set-cookie-parser":"2.4.10","@types/yargs":"17.0.32",colorette:"^1.2.0",cookie:"^0.7.2",dotenv:"16.4.7",esbuild:"^0.28.0",glob:"^13.0.5",handlebars:"^4.7.10",react:"^18.3.0 || ^19.2.7","react-dom":"^18.3.0 || ^19.2.7","react-router":"^7.18.4",redoc:"3.0.1",semver:"^7.5.2","set-cookie-parser":"^2.3.5","styled-components":"6.4.2",typescript:"6.0.2",ulid:"^3.0.1",undici:"^7.30.0",yargs:"17.0.1"}};var{version:we,name:De,engines:Te}=$,Ue=$.devDependencies.redoc;var re="https://otel.cloud.redocly.com",Re=process.env.OTEL_TRACES_URL||`${re}/v1/traces`,Me=6e3,Oe="redocly-cli-anonymous-id";var Z=ne(F(),1),ie=Object.defineProperty,ce=(e,t)=>{for(var n in t)ie(e,n,{get:t[n],enumerable:!0})},se={};ce(se,{CLOUD_EVENT_STANDARD_KEYS:()=>X,mapToCloudEvent:()=>ae});var X=["id","specversion","object","datacontenttype","type","time","origin","env","category","signal","source","subject","subjects","data","actor","requestId","clientIp","organizationId","organizationSlug","projectId","projectSlug","osPlatform","userAgent","sessionId"];function ae(e){let{type:t,data:n,actor:o,requestId:i,clientIp:a,origin:u,env:m,source:p,organizationId:f,organizationSlug:v,projectId:y,projectSlug:E,category:I="product",signal:j="log",osPlatform:R,userAgent:M,sessionId:r}=e,c=!!(n&&Array.isArray(n)),s=o?{id:o.id??`ann_${(0,Z.ulid)()}`,object:o.object??"user",uri:o.uri??""}:null,d=`evt_${(0,Z.ulid)()}`.toLowerCase(),l=new Date,g=p??s?.uri??null,A={...f!==void 0&&{organizationId:f},...v!==void 0&&{organizationSlug:v},...y!==void 0&&{projectId:y},...E!==void 0&&{projectSlug:E}},O={specversion:"1.0",object:"event",datacontenttype:"application/json; charset=utf-8",origin:u,env:m,category:I,signal:j,osPlatform:R,userAgent:M,clientIp:a,sessionId:r};if(c){let _=n,Y=_.map(S=>({id:S.id??"",object:S.object??"",uri:S.uri??""})),Q=_[0]?.id??null;Object.assign(O,{...A,id:d,type:t,time:l,source:g,actor:s,subject:Q,subjects:Y,data:_,requestId:i??""})}else{let _=(Array.isArray(n)?n[0]:n)?.id??null;Object.assign(O,{...A,id:d,type:t,time:l,source:g,actor:s,subject:_,requestId:i??"",data:n,...p!=null&&{request:{source:p}}})}return O}function T(e){return e.replace(/([A-Z])/g,"_$1").toLowerCase()}function L(e){return e!=null}function x(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function G(e,t,n,o=!0,i){let a=i?.length?new Set(i):null;for(let[u,m]of Object.entries(e))if(!a?.has(u)&&m!==void 0){let p=o?T(u):u;n[`${t}${p}`]=m}}function w(e,t,n,o){let i=o?.currentDepth??0,a=o?.useSnakeCase??!0,u=o?.maxNestingLevels??3,m=t.endsWith(".")?t.slice(0,-1):t;for(let[p,f]of Object.entries(e)){if(!L(f))continue;let v=a?T(p):p,y=`${m}.${v}`;typeof f=="object"&&!Array.isArray(f)?i<u&&w(f,y,n,{currentDepth:i+1,useSnakeCase:a,maxNestingLevels:u}):x(f)&&(n[y]=f)}}var V="context",P=[V];function q(e){let t={updated:[],notUpdated:[]};for(let n of e){if(!n||typeof n!="object")continue;let o=n.object;if(typeof o!="string")continue;let i=n,a=t.notUpdated.find(u=>u.object===o);a?(t.updated=[a,i],t.notUpdated=t.notUpdated.filter(u=>u.object!==o)):t.updated.some(u=>u.object===o)||t.notUpdated.push(i)}return t}function D(e,t,n){let o=n?`${n}.`:"",i=t===""?"":`${T(t)}.`;return`${e}.${o}${i}`}function H(e,t){let n=e[V];return n==="before"||n==="after"?n:t===0?"after":"before"}function B(e){let{[V]:t,...n}=e;return n}function z(e){return e.endsWith(".")?e:`${e}.`}function ue(e,t,n){let o=t instanceof Date?t.toISOString():new Date(t).toISOString();return{"cloudevents.event_id":e.id,"cloudevents.event_type":e.type,"cloudevents.event_source":e.source??void 0,"cloudevents.event_spec_version":e.specversion,"cloudevents.event_data_content_type":e.datacontenttype??"application/json; charset=utf-8","cloudevents.event_time":o,"cloudevents.event_subject":e.subject??"","cloudevents.event_version":n?.version,"cloudevents.event_origin":e.origin??n?.serviceName,"cloudevents.event_env":e.env,"cloudevents.event_client_ip":e.clientIp,"cloudevents.event_object":e.object||"event","cloudevents.event_category":e.category,"cloudevents.event_signal":e.signal,"cloudevents.event_actor.id":e.actor?.id??void 0,"cloudevents.event_actor.object":e.actor?.object??void 0,"cloudevents.event_actor.uri":e.actor?.uri??void 0,"cloudevents.event_organization_id":e.organizationId,"cloudevents.event_organization_slug":e.organizationSlug,"cloudevents.event_project_id":e.projectId,"cloudevents.event_project_slug":e.projectSlug,"cloudevents.event_request_id":e.requestId,"cloudevents.event_os_platform":e.osPlatform,"cloudevents.event_user_agent":e.userAgent,"cloudevents.event_session_id":e.sessionId}}function $e(e,t,n){let o=e.data,i={...ue(e,t,n)};return de(o,i),ve(e,i),ye(e,i),i}function de(e,t){!e||typeof e!="object"||(Array.isArray(e)?le(e,t):me(e,t))}function le(e,t){e.some(n=>n&&typeof n=="object"&&typeof n.object=="string")?fe(e,t):pe(e,t)}function fe(e,t){let n=q(e);n.updated.forEach((o,i)=>{let a=D("cloudevents.event_data",o.object,H(o,i));w(B(o),z(a),t)}),n.notUpdated.forEach(o=>{let i=D("cloudevents.event_data",o.object,void 0);w(B(o),z(i),t)})}function pe(e,t){for(let n of e)!n||typeof n!="object"||w(n,"cloudevents.event_data.",t)}function me(e,t){for(let[n,o]of Object.entries(e)){if(!L(o))continue;let i=T(n);if(typeof o=="object"&&!Array.isArray(o))for(let[a,u]of Object.entries(o))L(u)&&x(u)&&(t[`cloudevents.event_data.${i}.${a}`]=u);else x(o)&&(t[`cloudevents.event_data.${i}`]=o)}}function ve(e,t){if(!e.subjects||!Array.isArray(e.subjects))return;let n=q(e.subjects);n.updated.forEach((o,i)=>{let a=D("cloudevents.event_subjects",o.object,H(o,i));G(o,a,t,!1,P)}),n.notUpdated.forEach(o=>{let i=D("cloudevents.event_subjects",o.object,void 0);G(o,i,t,!1,P)})}function ye(e,t){for(let[n,o]of Object.entries(e))if(!(X.includes(n)||o===void 0))if(o instanceof Object)for(let[i,a]of Object.entries(o))a!==void 0&&(t[`cloudevents.${n}.${i}`]=a);else t[`cloudevents.${n}`]=o}import U from"node:crypto";var J="0123456789ABCDEFGHJKMNPQRSTVWXYZ",C=32;var ge=16,K=10,W=0xffffffffffff;var b;(function(e){e.Base32IncorrectEncoding="B32_ENC_INVALID",e.DecodeTimeInvalidCharacter="DEC_TIME_CHAR",e.DecodeTimeValueMalformed="DEC_TIME_MALFORMED",e.EncodeTimeNegative="ENC_TIME_NEG",e.EncodeTimeSizeExceeded="ENC_TIME_SIZE_EXCEED",e.EncodeTimeValueMalformed="ENC_TIME_MALFORMED",e.PRNGDetectFailure="PRNG_DETECT",e.ULIDInvalid="ULID_INVALID",e.Unexpected="UNEXPECTED",e.UUIDInvalid="UUID_INVALID"})(b||(b={}));var h=class extends Error{constructor(t,n){super(`${n} (${t})`),this.name="ULIDError",this.code=t}};function be(e){let t=Math.floor(e()*C)%C;return J.charAt(t)}function he(e){let t=Ie(),n=t&&(t.crypto||t.msCrypto)||(typeof U<"u"?U:null);if(typeof n?.getRandomValues=="function")return()=>{let o=new Uint8Array(1);return n.getRandomValues(o),o[0]/256};if(typeof n?.randomBytes=="function")return()=>n.randomBytes(1).readUInt8()/256;if(U?.randomBytes)return()=>U.randomBytes(1).readUInt8()/256;throw new h(b.PRNGDetectFailure,"Failed to find a reliable PRNG")}function Ie(){return je()?self:typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:null}function _e(e,t){let n="";for(;e>0;e--)n=be(t)+n;return n}function Ee(e,t=K){if(isNaN(e))throw new h(b.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>W)throw new h(b.EncodeTimeSizeExceeded,`Cannot encode a time larger than ${W}: ${e}`);if(e<0)throw new h(b.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new h(b.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,o="";for(let i=t;i>0;i--)n=e%C,o=J.charAt(n)+o,e=(e-n)/C;return o}function je(){return typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope}function xe(e,t){let n=t||he(),o=!e||isNaN(e)?Date.now():e;return Ee(o,K)+_e(ge,n)}export{we as a,De as b,Te as c,Ue as d,re as e,Re as f,Me as g,Oe as h,se as i,$e as j,xe as k};
@@ -1,9 +0,0 @@
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 xe,f as Pe}from"./BH4FA7AH.js";import{S as le,T as he,W as b,Y as fe,Z as de,_ as j,aa as ye,ba as U,c as L,ca as A,f as ie,fa as k,ga as Se,ha as ge,ia as Q,ja as K,la as Ce,oa as be,p as ae,q as pe,r as ce,u as me,v as ue}from"./FRQHCFKP.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{performance as mt}from"perf_hooks";var D={thresholds:{maxParamsGood:5,maxDepthGood:4,maxPolymorphismGood:2,maxDependencyDepthGood:3,maxAmbiguousGood:0,maxOperationsForDiscoverability:1e3},weights:{parameterSimplicity:.1,schemaSimplicity:.1,documentationQuality:.18,constraintClarity:.12,exampleCoverage:.18,errorClarity:.12,dependencyClarity:.1,identifierClarity:.05,polymorphismClarity:.05,anyOfPenaltyMultiplier:2,discoverabilityWeight:.1},hotspotLimit:10},Oe=new Set(["id","name","type","value","data","key","status","state","code","result","item","object","resource","entity","input","output","payload","body","content","info"]);function B(e){if(e.length===0)return 0;let r=[...e].sort((o,n)=>o-n),t=Math.floor(r.length/2);return r.length%2!==0?r[t]:(r[t-1]+r[t])/2}function He(e,r,t=D){let{thresholds:o,weights:n}=t,s=x(1-e.parameterCount/(o.maxParamsGood*2)),a=Math.max(e.maxRequestSchemaDepth,e.maxResponseSchemaDepth)/(o.maxDepthGood*2),c=De(e,n.anyOfPenaltyMultiplier)/(o.maxPolymorphismGood*3),h=x(1-a-c),u=(e.operationDescriptionPresent?1:0)+e.paramsWithDescription+e.schemaPropertiesWithDescription,f=1+e.parameterCount+e.totalSchemaProperties,$=f>0?x(u/f):1,O=e.totalSchemaProperties>0?x(e.constraintCount/e.totalSchemaProperties):1,y=(e.requestExamplePresent?1:0)+(e.responseExamplePresent?1:0),g=(e.requestBodyPresent?1:0)+1,M=x(y/g),T=e.totalErrorResponses>0?x(e.structuredErrorResponseCount/e.totalErrorResponses):1,I=x(1-r/(o.maxDependencyDepthGood*2)),l=x(1-e.ambiguousIdentifierCount/Math.max(o.maxAmbiguousGood+3,1)),m=De(e,n.anyOfPenaltyMultiplier),d=m===0?1:e.hasDiscriminator?x(1-m/(o.maxPolymorphismGood*4)):x(1-m/(o.maxPolymorphismGood*2));return{parameterSimplicity:s,schemaSimplicity:h,documentationQuality:$,constraintClarity:O,exampleCoverage:M,errorClarity:T,dependencyClarity:I,identifierClarity:l,polymorphismClarity:d}}function ze(e,r=D){let t=r.weights,o=e.parameterSimplicity*t.parameterSimplicity+e.schemaSimplicity*t.schemaSimplicity+e.documentationQuality*t.documentationQuality+e.constraintClarity*t.constraintClarity+e.exampleCoverage*t.exampleCoverage+e.errorClarity*t.errorClarity+e.dependencyClarity*t.dependencyClarity+e.identifierClarity*t.identifierClarity+e.polymorphismClarity*t.polymorphismClarity;return $e(x(o)*100)}function Re(e,r,t=D){let o=new Map;for(let[n,s]of e.operations){let i=r.get(n)??0,a=He(s,i,t);o.set(n,{agentReadiness:ze(a,t),subscores:a})}return o}function Me(e,r=D){return x(1-e/r.thresholds.maxOperationsForDiscoverability)}function ve(e,r,t=D){if(e.size===0)return{agentReadiness:100};let o=[];for(let i of e.values())o.push(i.agentReadiness);let n=t.weights.discoverabilityWeight,s=r*100;return{agentReadiness:$e(B(o)*(1-n)+s*n)}}function J(e,r,t){return e-r+r*t}function De(e,r){return J(e.polymorphismCount,e.anyOfCount,r)}function x(e){return Math.max(0,Math.min(1,e))}function Ee(e){let r=e.size||1,t={parameterSimplicity:0,schemaSimplicity:0,documentationQuality:0,constraintClarity:0,exampleCoverage:0,errorClarity:0,dependencyClarity:0,identifierClarity:0,polymorphismClarity:0};for(let o of e.values())t.parameterSimplicity+=o.subscores.parameterSimplicity,t.schemaSimplicity+=o.subscores.schemaSimplicity,t.documentationQuality+=o.subscores.documentationQuality,t.constraintClarity+=o.subscores.constraintClarity,t.exampleCoverage+=o.subscores.exampleCoverage,t.errorClarity+=o.subscores.errorClarity,t.dependencyClarity+=o.subscores.dependencyClarity,t.identifierClarity+=o.subscores.identifierClarity,t.polymorphismClarity+=o.subscores.polymorphismClarity;return t.parameterSimplicity/=r,t.schemaSimplicity/=r,t.documentationQuality/=r,t.constraintClarity/=r,t.exampleCoverage/=r,t.errorClarity/=r,t.dependencyClarity/=r,t.identifierClarity/=r,t.polymorphismClarity/=r,t}function $e(e){return Math.round(e*10)/10}function we(e,r,t){let o=Math.max(1,e);return r/o+t/o}function Qe(e,r){return r.totalSchemaProperties>e.totalSchemaProperties?!0:r.totalSchemaProperties<e.totalSchemaProperties?!1:we(r.totalSchemaProperties,r.schemaPropertiesWithDescription,r.constraintCount)>we(e.totalSchemaProperties,e.schemaPropertiesWithDescription,e.constraintCount)}var Ke=["enum","const","format","pattern","minimum","maximum","minLength","maxLength","minItems","maxItems","minProperties","maxProperties","multipleOf","exclusiveMinimum","exclusiveMaximum","uniqueItems"];function Y(){return{depth:-1,maxDepth:0,polymorphismCount:0,anyOfCount:0,hasDiscriminator:!1,totalSchemaProperties:0,schemaPropertiesWithDescription:0,constraintCount:0,hasPropertyExamples:!1,writableTopLevelFields:0,refsUsed:[],debugEntries:null,pendingRef:null}}function Ie(e){Object.assign(e,Y())}function Le(e){return{ref:{enter(r){typeof r?.$ref=="string"&&(e.refsUsed.push(r.$ref),e.pendingRef=r.$ref)}},Schema:{enter(r,t){e.depth++,e.maxDepth=Math.max(e.maxDepth,e.depth);let o=0;for(let i of Ke)r[i]!==void 0&&(e.constraintCount++,o++);r.discriminator?.propertyName&&(e.hasDiscriminator=!0);let n={};for(let i of["oneOf","anyOf","allOf"]){let a=r[i];Array.isArray(a)&&(e.polymorphismCount+=a.length,i==="anyOf"&&(e.anyOfCount+=a.length),n[i]=a.length)}let s=[];if(L(r.properties)){let i=Object.entries(r.properties);e.totalSchemaProperties+=i.length;for(let[a,c]of i){s.push(a);let h=c&&"$ref"in c&&c.$ref?t.resolve(c)?.node??c:c;h?.description&&e.schemaPropertiesWithDescription++,(h?.example!==void 0||h?.examples)&&(e.hasPropertyExamples=!0),h?.readOnly||e.writableTopLevelFields++}}e.debugEntries!==null&&e.debugEntries.push({ref:e.pendingRef,depth:e.depth,propertyNames:s,polymorphism:Object.keys(n).length>0?n:{},constraintCount:o}),e.pendingRef=null},leave(){e.depth--}}}}function qe(e,r,t){return{operations:new Map,currentPath:"",pathLevelParams:[],current:null,walkSchema:e,anyOfPenaltyMultiplier:r,debugOperationId:t,debugLogs:[]}}function Je(e,r,t){return{path:e,method:r,operationId:t.operationId,operationDescriptionPresent:!!t.description,parameterCount:0,requiredParameterCount:0,paramsWithDescription:0,ambiguousIdentifierCount:0,maxRequestSchemaDepth:0,maxResponseSchemaDepth:0,totalSchemaProperties:0,schemaPropertiesWithDescription:0,constraintCount:0,polymorphismCount:0,anyOfCount:0,hasDiscriminator:!1,topLevelWritableFieldCount:0,requestBodyPresent:!1,requestExamplePresent:!1,responseExamplePresent:!1,structuredErrorResponseCount:0,totalErrorResponses:0,inRequestBody:!1,inResponse:!1,currentResponseCode:"",errorStructuredCounted:!1,maxEffectivePolymorphism:-1,refsUsed:new Set}}function Ye(e){let{inRequestBody:r,inResponse:t,currentResponseCode:o,errorStructuredCounted:n,maxEffectivePolymorphism:s,...i}=e;return i}function We(e){return{RequestBody:{enter(){e.current&&(e.current.requestBodyPresent=!0,e.current.inRequestBody=!0)},leave(){e.current&&(e.current.inRequestBody=!1)}},Response:{enter(r,t){let o=e.current;if(!o)return;let n=String(t.key);o.inResponse=!0,o.currentResponseCode=n,o.errorStructuredCounted=!1,Te(n)&&(o.totalErrorResponses++,!r.content&&r.description&&(o.structuredErrorResponseCount++,o.errorStructuredCounted=!0))},leave(){e.current&&(e.current.inResponse=!1)}},MediaType:{enter(r){let t=e.current;if(t&&(Ze(r)&&(t.inRequestBody&&(t.requestExamplePresent=!0),t.inResponse&&(t.responseExamplePresent=!0)),t.inResponse&&Te(t.currentResponseCode)&&!t.errorStructuredCounted&&(t.structuredErrorResponseCount++,t.errorStructuredCounted=!0),r.schema)){let o=!!e.debugOperationId&&(t.operationId===e.debugOperationId||`${t.method.toUpperCase()} ${t.path}`===e.debugOperationId),n=e.walkSchema(r.schema,o);Qe(t,n)&&(t.totalSchemaProperties=n.totalSchemaProperties,t.schemaPropertiesWithDescription=n.schemaPropertiesWithDescription,t.constraintCount=n.constraintCount);let s=J(n.polymorphismCount,n.anyOfCount,e.anyOfPenaltyMultiplier);s>t.maxEffectivePolymorphism&&(t.maxEffectivePolymorphism=s,t.polymorphismCount=n.polymorphismCount,t.anyOfCount=n.anyOfCount),n.hasDiscriminator&&(t.hasDiscriminator=!0);for(let i of n.refsUsed)t.refsUsed.add(i);if(n.hasPropertyExamples&&(t.inRequestBody&&(t.requestExamplePresent=!0),t.inResponse&&(t.responseExamplePresent=!0)),t.inRequestBody&&(t.maxRequestSchemaDepth=Math.max(t.maxRequestSchemaDepth,n.maxDepth),t.topLevelWritableFieldCount=Math.max(t.topLevelWritableFieldCount,n.writableTopLevelFields)),t.inResponse&&(t.maxResponseSchemaDepth=Math.max(t.maxResponseSchemaDepth,n.maxDepth)),o&&n.debugEntries){let i=t.inRequestBody?"REQUEST BODY":`RESPONSE ${t.currentResponseCode}`;e.debugLogs.push({context:i,entries:n.debugEntries,totalProperties:n.totalSchemaProperties,totalPolymorphism:n.polymorphismCount,totalConstraints:n.constraintCount,maxDepth:n.maxDepth})}}}},Paths:{PathItem:{enter(r,t){e.currentPath=String(t.key),e.pathLevelParams=r.parameters??[]},Operation:{enter(r,t){let o=String(t.key),n=Je(e.currentPath,o,r);e.current=n;let s=Xe(e.pathLevelParams,r.parameters??[],t.resolve);for(let i of s.values())n.parameterCount++,i.required&&n.requiredParameterCount++,i.description&&n.paramsWithDescription++,et(i)&&n.ambiguousIdentifierCount++},leave(r){let t=e.current;if(!t)return;let o=r.operationId??`${t.method.toUpperCase()} ${t.path}`;e.operations.set(o,Ye(t)),e.current=null}}}}}}function Ue(e){return{operationCount:e.operations.size,operations:e.operations}}function Ae(e,r){return r(e).node}function Xe(e,r,t){let o=new Map;for(let n of e){let s=Ae(n,t);s?.name&&s.in&&o.set(`${s.in}:${s.name}`,s)}for(let n of r){let s=Ae(n,t);s?.name&&s.in&&o.set(`${s.in}:${s.name}`,s)}return o}function Ze(e){return e.example!==void 0||ie(e.examples)}function et(e){if(e.description)return!1;let r=(e.name??"").toLowerCase();return Oe.has(r)}function Te(e){if(e==="default"||/^4xx$/i.test(e)||/^5xx$/i.test(e))return!0;let r=parseInt(e,10);return r>=400&&r<600}function tt(e,r){if(!r.startsWith("#/"))return;let t=e;for(let o of r.slice(2).split("/"))t=t?.[ce(o)];return t}function ke({document:e,types:r,resolvedRefMap:t,ctx:o,debugOperationId:n,scoringConstants:s}){let i=s?.weights.anyOfPenaltyMultiplier??D.weights.anyOfPenaltyMultiplier,a=Y(),c=Le(a),h=Q([{severity:"warn",ruleId:"score-schema",visitor:c}],r),u=(l,m)=>{Ie(a),m&&(a.debugEntries=[]),K({document:{...e,parsed:l},rootType:r.Schema,normalizedVisitors:h,resolvedRefMap:t,ctx:o});let{depth:d,pendingRef:w,debugEntries:_,...N}=a;return{...N,refsUsed:[...a.refsUsed],debugEntries:m?a.debugEntries??void 0:void 0}},f=new Map,$=new WeakSet,O={maxDepth:0,polymorphismCount:0,anyOfCount:0,hasDiscriminator:!1,totalSchemaProperties:0,schemaPropertiesWithDescription:0,constraintCount:0,hasPropertyExamples:!1,writableTopLevelFields:0,refsUsed:[]};function y(l,m){return{maxDepth:Math.max(l.maxDepth,m.maxDepth),polymorphismCount:l.polymorphismCount+m.polymorphismCount,anyOfCount:l.anyOfCount+m.anyOfCount,hasDiscriminator:l.hasDiscriminator||m.hasDiscriminator,totalSchemaProperties:l.totalSchemaProperties+m.totalSchemaProperties,schemaPropertiesWithDescription:l.schemaPropertiesWithDescription+m.schemaPropertiesWithDescription,constraintCount:l.constraintCount+m.constraintCount,hasPropertyExamples:l.hasPropertyExamples||m.hasPropertyExamples,writableTopLevelFields:l.writableTopLevelFields+m.writableTopLevelFields,refsUsed:[...l.refsUsed,...m.refsUsed],debugEntries:l.debugEntries||m.debugEntries?[...l.debugEntries??[],...m.debugEntries??[]]:void 0}}let g=(l,m=!1)=>{let d=l,w=pe(l)?l.$ref:void 0;if(w){if(!m){let S=f.get(w);if(S)return S}d=tt(e.parsed,w)??l}if(L(d)&&$.has(d))return{...O};L(d)&&$.add(d);let _=d?.oneOf,N=d?.anyOf,Z=Array.isArray(_)&&_.length>1,ee=Array.isArray(N)&&N.length>1,G=Z||ee,te=Array.isArray(d?.allOf)&&d.allOf.length>0,V=d?.discriminator,q=!G&&L(V?.mapping)?Object.values(V.mapping).filter(S=>typeof S=="string"&&me(S)).map(S=>({$ref:S})):null,re=Array.isArray(q)&&q.length>0,C;if(G||te||re){let S={...d},F=null,oe=P=>{F=F?y(F,P):P},ne=(P,v)=>{let E=g(v[0],m);for(let z=1;z<v.length;z++){let se=g(v[z],m);se.totalSchemaProperties>E.totalSchemaProperties&&(E=se)}return{...E,polymorphismCount:E.polymorphismCount+v.length,anyOfCount:E.anyOfCount+(P==="anyOf"?v.length:0),hasDiscriminator:E.hasDiscriminator||!!V}};G&&delete S.discriminator,Z&&(delete S.oneOf,oe(ne("oneOf",_))),ee&&(delete S.anyOf,oe(ne("anyOf",N)));let H=null;if(re){delete S.discriminator;let P=g(q[0],m);for(let v=1;v<q.length;v++){let E=g(q[v],m);E.totalSchemaProperties>P.totalSchemaProperties&&(P=E)}H={...P,polymorphismCount:P.polymorphismCount+q.length,hasDiscriminator:!0}}let W=null;if(te){delete S.allOf,W={...O};for(let P of d.allOf)W=y(W,g(P,m));W.polymorphismCount+=d.allOf.length}C=u(S,m),W&&(C=y(C,W)),F&&(C=y(C,F)),H&&(C=y(C,H)),w&&(C={...C,refsUsed:[w,...C.refsUsed]})}else C=u(l,m);return L(d)&&$.delete(d),w&&!m&&f.set(w,C),C},M=qe(g,i,n),T=We(M),I=Q([{severity:"warn",ruleId:"score",visitor:T}],r);return K({document:e,rootType:r.Root,normalizedVisitors:I,resolvedRefMap:t,ctx:o}),{metrics:Ue(M),debugLogs:M.debugLogs}}function Ne(e){let r=new Map;for(let[n,s]of e)for(let i of s.refsUsed){let a=r.get(i);a||(a=new Set,r.set(i,a)),a.add(n)}let t=new Map;for(let n of e.keys())t.set(n,new Set);for(let n of r.values()){if(n.size<2)continue;let s=Array.from(n);for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++)t.get(s[i]).add(s[a]),t.get(s[a]).add(s[i])}let o=new Map;for(let n of e.keys()){let s=rt(n,t);o.set(n,s)}return o}function rt(e,r){let t=new Set([e]),o=[e],n=0;for(;o.length>0;){let s=[];for(let i of o)for(let a of r.get(i)??[])t.has(a)||(t.add(a),s.push(a));s.length>0&&n++,o=s}return n}function Fe(e){let r={agentReadiness:e.agentReadiness,discoverability:Math.round(e.discoverability*100),subscores:e.subscores,rawMetrics:{operationCount:e.rawMetrics.operationCount,operations:Object.fromEntries(Array.from(e.rawMetrics.operations.entries()).map(([t,o])=>{let{refsUsed:n,...s}=o;return[t,s]}))},operationScores:Object.fromEntries(e.operationScores),dependencyDepths:Object.fromEntries(e.dependencyDepths),hotspots:e.hotspots};k.output(JSON.stringify(r,null,2))}function je(e,r=!1){ot(e),nt(e),it(e),r&&at(e),pt(e)}function _e(e){return e>=80?de:e>=50?j:fe}function Be(e){return _e(e)(b(e.toFixed(1)))}function p(e){k.output(e+`
8
- `)}function ot(e){p(""),p(b(A(" Scores"))),p(""),p(` Agent Readiness: ${Be(e.agentReadiness)}/100`),p("")}function nt(e){p(b(A(" Subscores"))),p("");let r=e.subscores;R("Parameter Simplicity",r.parameterSimplicity),R("Schema Simplicity",r.schemaSimplicity),R("Documentation Quality",r.documentationQuality),R("Constraint Clarity",r.constraintClarity),R("Example Coverage",r.exampleCoverage),R("Error Clarity",r.errorClarity),R("Dependency Clarity",r.dependencyClarity),R("Identifier Clarity",r.identifierClarity),R("Polymorphism Clarity",r.polymorphismClarity),R("Discoverability",e.discoverability),p("")}function R(e,r){let t=Math.round(r*100),o=st(r);p(` ${e.padEnd(24)} ${o} ${_e(t)(t+"%")}`)}function st(e){let t=Math.round(e*20);return U("["+"\u2588".repeat(t)+"\u2591".repeat(20-t)+"]")}function it(e){if(p(b(A(" Raw Metrics Summary"))),p(""),p(` Total operations: ${e.rawMetrics.operationCount}`),e.rawMetrics.operationCount===0){p("");return}let r=[],t=[],o=[],n=[],s=0,i=0,a=0;for(let u of e.rawMetrics.operations.values())r.push(u.parameterCount),t.push(Math.max(u.maxRequestSchemaDepth,u.maxResponseSchemaDepth)),o.push(u.polymorphismCount),n.push(u.totalSchemaProperties),u.requestExamplePresent&&s++,u.responseExamplePresent&&i++,u.operationDescriptionPresent&&a++;let c=e.rawMetrics.operationCount;function h(u,f){let O=(f.reduce((T,I)=>T+I,0)/c).toFixed(1),y=B(f).toFixed(1),g=Math.min(...f),M=Math.max(...f);p(` ${u.padEnd(26)} avg ${O.padStart(6)} median ${y.padStart(6)} min ${String(g).padStart(5)} max ${String(M).padStart(5)}`)}h("Parameters/operation:",r),h("Schema depth:",t),h("Polymorphism/operation:",o),h("Properties/operation:",n),p(` Operations with request examples: ${s}/${c} (${X(s,c)})`),p(` Operations with response examples: ${i}/${c} (${X(i,c)})`),p(` Operations with description: ${a}/${c} (${X(a,c)})`),p("")}function X(e,r){return r>0?`${Math.round(e/r*100)}%`:"N/A"}function at(e){p(b(A(" Per-Operation Metrics"))),p("");let r=" "+"Operation".padEnd(50)+"Props".padStart(7)+"Poly".padStart(7)+"Depth".padStart(7)+"Params".padStart(8)+"Constr".padStart(8);p(U(r)),p(U(" "+"\u2500".repeat(r.length-2)));let t=[...e.rawMetrics.operations.entries()].sort(([,o],[,n])=>n.totalSchemaProperties-o.totalSchemaProperties);for(let[,o]of t){let n=(o.operationId??`${o.method.toUpperCase()} ${o.path}`).slice(0,48),s=Math.max(o.maxRequestSchemaDepth,o.maxResponseSchemaDepth),i=" "+n.padEnd(50)+String(o.totalSchemaProperties).padStart(7)+String(o.polymorphismCount).padStart(7)+String(s).padStart(7)+String(o.parameterCount).padStart(8)+String(o.constraintCount).padStart(8);p(i)}p("")}function Ge(e,r){if(p(""),p(b(A(` Debug: ${e} schema breakdown`))),p(""),r.length===0){p(j(` No schemas found for operation "${e}".`)),p(j(' Make sure the value matches an operationId or "METHOD /path" exactly.')),p("");return}for(let t of r){p(b(U(` ${t.context}`))),p(U(" "+"\u2500".repeat(70)));let o=new Map;for(let s of t.entries){let i=s.ref??`(inline depth ${s.depth})`,a=o.get(i);if(a){a.count++,a.totalProps+=s.propertyNames.length;for(let c of s.propertyNames)a.propNames.includes(c)||a.propNames.push(c)}else o.set(i,{count:1,totalProps:s.propertyNames.length,propNames:[...s.propertyNames]})}for(let s of t.entries){let i=s.ref??"(inline)",a=" ".repeat(Math.min(s.depth,6)),c=s.propertyNames.length,h=` ${a}${i}`;c>0&&(h+=` (${c} properties)`);let u=[];if(s.polymorphism.oneOf&&u.push(`oneOf:${s.polymorphism.oneOf}`),s.polymorphism.anyOf&&u.push(`anyOf:${s.polymorphism.anyOf}`),s.polymorphism.allOf&&u.push(`allOf:${s.polymorphism.allOf}`),u.length>0&&(h+=` [${u.join(", ")}]`),s.constraintCount>0&&(h+=` {${s.constraintCount} constraints}`),p(h),c>0&&c<=20)p(` ${a} properties: ${s.propertyNames.join(", ")}`);else if(c>20){let f=s.propertyNames.slice(0,15).join(", ");p(` ${a} properties: ${f}, ... +${c-15} more`)}}p(""),p(` Totals: ${t.totalProperties} properties, ${t.totalPolymorphism} polymorphism items, ${t.totalConstraints} constraints, max depth ${t.maxDepth}`);let n=[...o.entries()].filter(([,s])=>s.totalProps>0).sort(([,s],[,i])=>i.totalProps-s.totalProps).slice(0,10);if(n.length>0){p(""),p(b(" Top schemas by property count:"));for(let[s,i]of n)p(` ${s}: ${i.totalProps} properties`)}p("")}}function pt(e){if(e.hotspots.length===0){p(b(A(" No hotspot operations found."))),p("");return}p(b(A(` Top ${e.hotspots.length} Hotspot Operations`))),p("");for(let r of e.hotspots){let t=r.operationId?`${r.method.toUpperCase()} ${r.path} (${r.operationId})`:`${r.method.toUpperCase()} ${r.path}`;p(b(` ${t}`)),p(` Agent Readiness: ${Be(r.agentReadinessScore)}`);for(let o of r.reasons)p(j(` - ${o}`));p("")}}function Ve(e,r,t,o=D){let n=[];for(let[s,i]of r){let a=e.operations.get(s);if(!a)continue;let c=ct(a,t.get(s)??0,o);c.length!==0&&n.push({path:a.path,method:a.method,operationId:a.operationId,agentReadinessScore:i.agentReadiness,reasons:c})}return n.sort((s,i)=>s.reasons.length!==i.reasons.length?i.reasons.length-s.reasons.length:s.agentReadinessScore-i.agentReadinessScore),n.slice(0,o.hotspotLimit)}function ct(e,r,t){let{thresholds:o}=t,n=[];e.parameterCount>o.maxParamsGood&&n.push(`High parameter count (${e.parameterCount})`);let s=Math.max(e.maxRequestSchemaDepth,e.maxResponseSchemaDepth);s>o.maxDepthGood&&n.push(`Deep schema nesting (depth ${s})`),e.anyOfCount>0&&!e.hasDiscriminator?n.push(`Polymorphism (anyOf) without discriminator (${e.anyOfCount} anyOf)`):e.polymorphismCount>o.maxPolymorphismGood&&n.push(`High polymorphism count (${e.polymorphismCount})`);let i=e.requestBodyPresent&&!e.requestExamplePresent,a=!e.responseExamplePresent;return i&&a?n.push("Missing request and response examples"):i?n.push("Missing request body examples"):a&&n.push("Missing response examples"),e.totalErrorResponses>0&&e.structuredErrorResponseCount===0&&n.push("No structured error responses (4xx/5xx)"),e.operationDescriptionPresent||n.push("Missing operation description"),e.parameterCount>0&&e.paramsWithDescription===0&&n.push("No parameter descriptions"),r>o.maxDependencyDepthGood&&n.push(`High dependency depth (${r})`),e.ambiguousIdentifierCount>o.maxAmbiguousGood&&n.push(`Ambiguous identifiers (${e.ambiguousIdentifierCount})`),n}async function Vt({argv:e,config:r,collectSpecData:t}){let[{path:o}]=await xe(e.api?[e.api]:[],r),n=new le(r.resolve),{bundle:s}=await be({config:r,ref:o});t?.(s);let i=ge(s.parsed);if(Se(i)!=="oas3")throw new Ce(`The score command currently supports only OpenAPI 3.x. Detected: ${i}`);let a=mt.now(),c=ae(r.extendTypes(ue(i),i),r),h=await he({rootDocument:s,rootType:c.Root,externalRefResolver:n}),u=e["debug-operation-id"],{metrics:f,debugLogs:$}=ke({document:s,types:c,resolvedRefMap:h,ctx:{problems:[],specVersion:i,config:r,visitorsData:{}},debugOperationId:u}),O=Ne(f.operations),y=Re(f,O),g=Me(f.operationCount),{agentReadiness:M}=ve(y,g),T=Ve(f,y,O),I={agentReadiness:M,discoverability:g,subscores:Ee(y),rawMetrics:f,hotspots:T,operationScores:y,dependencyDepths:O};ut(I,o,a,e.format,!!e["operation-details"],u?{operationId:u,logs:$}:void 0)}function ut(e,r,t,o,n,s){k.info(`Document: ${ye(r)} score:
9
- `),o==="json"?Fe(e):je(e,n),s&&Ge(s.operationId,s.logs),Pe("score",t,r)}export{Vt as handleScore};