@redocly/cli 2.49.1 → 2.51.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 (108) hide show
  1. package/lib/chunks/{WG3HZCUF.js → 2L3Z5JZA.js} +1 -1
  2. package/lib/chunks/{ULOXDWJT.js → 2OHNINBQ.js} +1 -1
  3. package/lib/chunks/{TNYG2WWT.js → 2WUJ57QA.js} +1 -1
  4. package/lib/chunks/{KW2DYFTU.js → 3XSOTIDJ.js} +1 -1
  5. package/lib/chunks/{3BZL5B4H.js → 45LW7ZJ2.js} +1 -1
  6. package/lib/chunks/{GG676VHI.js → 46OWJR6X.js} +1 -1
  7. package/lib/chunks/{VGBSMXRM.js → 4PT55VGO.js} +2 -2
  8. package/lib/chunks/{C7PTGUVO.js → 62X4OKFV.js} +1 -1
  9. package/lib/chunks/{JVOPWBET.js → 65LLBIQA.js} +1 -1
  10. package/lib/chunks/{M3HF5ZRI.js → 73NWWLM3.js} +1 -1
  11. package/lib/chunks/{7RCYOS5C.js → 77VEOG4O.js} +1 -1
  12. package/lib/chunks/{GZI26L3N.js → 7ZC3TNBP.js} +1 -1
  13. package/lib/chunks/{4PPXJI4C.js → AQT2EJZS.js} +1 -1
  14. package/lib/chunks/{KD4AOMY6.js → B3QINORT.js} +4 -4
  15. package/lib/chunks/{ENKAF6J7.js → BFGFT7E3.js} +1 -1
  16. package/lib/chunks/{5HNCFY3B.js → CA4BPC77.js} +1 -1
  17. package/lib/chunks/{HKNDR3ZE.js → EOS3ZB2L.js} +1 -1
  18. package/lib/chunks/ESNPHQEK.js +93 -0
  19. package/lib/chunks/{A5ASAZNF.js → FJAJ4RIU.js} +1 -1
  20. package/lib/chunks/{QKGUXGJO.js → FVKTV62N.js} +1 -1
  21. package/lib/chunks/{7K66NKDE.js → HMPJ7TN6.js} +1 -1
  22. package/lib/chunks/{KW4NHNFI.js → IPFRJMV6.js} +1 -1
  23. package/lib/chunks/{WZ7U5J57.js → KBGRTZ3S.js} +1 -1
  24. package/lib/chunks/{AEYKQB3Y.js → KF7NA4HQ.js} +1 -1
  25. package/lib/chunks/{VN7LZQGN.js → KNLINRO4.js} +1 -1
  26. package/lib/chunks/{VEQESANY.js → L4GUU6OS.js} +1 -1
  27. package/lib/chunks/{WAUR32EX.js → MONT6PMR.js} +1 -1
  28. package/lib/chunks/{N4AFJIJZ.js → MSRZMIR7.js} +1 -1
  29. package/lib/chunks/{7EFXGPDR.js → MXZKXUIJ.js} +1 -1
  30. package/lib/chunks/N5SXQI4I.js +14 -0
  31. package/lib/chunks/{4OMVSQVK.js → NAGDQV7J.js} +1 -1
  32. package/lib/chunks/{3O6RY2OI.js → NGC5R7OH.js} +1 -1
  33. package/lib/chunks/{YAMJYOV5.js → NIH6ZKB3.js} +1 -1
  34. package/lib/chunks/{T5DNFYA3.js → NSKVRJLY.js} +5 -5
  35. package/lib/chunks/{YOFC4HMY.js → OKMAGS7N.js} +1 -1
  36. package/lib/chunks/{H2G5AV35.js → OOLLHPWT.js} +3 -3
  37. package/lib/chunks/{M3XP3LQ3.js → OZMIIHFH.js} +92 -92
  38. package/lib/chunks/{3UDONSS2.js → P37B4DI4.js} +1 -1
  39. package/lib/chunks/{RQPDQIKC.js → QKWUIMTP.js} +1 -1
  40. package/lib/chunks/{GTD7QSP5.js → QPW3IML7.js} +3 -3
  41. package/lib/chunks/{G4MWXFHH.js → SQYP47H6.js} +1 -1
  42. package/lib/chunks/{TFNO2II2.js → TKFA7G4G.js} +1 -1
  43. package/lib/chunks/TMULAWFD.js +53 -0
  44. package/lib/chunks/{FRTUU2MY.js → U6E22USS.js} +1 -1
  45. package/lib/chunks/{D7CUMUET.js → ULV3D265.js} +1 -1
  46. package/lib/chunks/{SSHEKZ4L.js → V4SBON7Y.js} +1 -1
  47. package/lib/chunks/{J7XZNTM3.js → WPSBZRFR.js} +1 -1
  48. package/lib/chunks/{CWHIZM5P.js → X3MZMREJ.js} +1 -1
  49. package/lib/chunks/{UHWZYG4E.js → XOZ4UMDG.js} +1 -1
  50. package/lib/chunks/{MOKGEIKX.js → XWZNQKXF.js} +1 -1
  51. package/lib/chunks/{GULPNFGZ.js → YEK532UO.js} +1 -1
  52. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  53. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  54. package/lib/eject-assets/generators/cli/index.ts +2 -2
  55. package/lib/eject-assets/generators/cli/render.ts +1 -1
  56. package/lib/eject-assets/generators/go/client.ts +1 -1
  57. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  58. package/lib/eject-assets/generators/go/index.ts +2 -2
  59. package/lib/eject-assets/generators/go/models.ts +1 -1
  60. package/lib/eject-assets/generators/go/naming.ts +1 -1
  61. package/lib/eject-assets/generators/go/operations.ts +1 -1
  62. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  63. package/lib/eject-assets/generators/go/types.ts +1 -1
  64. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  65. package/lib/eject-assets/generators/mock/index.ts +2 -2
  66. package/lib/eject-assets/generators/mock/render.ts +1 -1
  67. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  68. package/lib/eject-assets/generators/mock/values.ts +1 -1
  69. package/lib/eject-assets/generators/php/client.ts +1 -1
  70. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  71. package/lib/eject-assets/generators/php/index.ts +2 -2
  72. package/lib/eject-assets/generators/php/models.ts +1 -1
  73. package/lib/eject-assets/generators/php/naming.ts +1 -1
  74. package/lib/eject-assets/generators/php/operations.ts +1 -1
  75. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  76. package/lib/eject-assets/generators/php/types.ts +1 -1
  77. package/lib/eject-assets/generators/python/client.ts +1 -1
  78. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  79. package/lib/eject-assets/generators/python/index.ts +2 -2
  80. package/lib/eject-assets/generators/python/models.ts +1 -1
  81. package/lib/eject-assets/generators/python/naming.ts +1 -1
  82. package/lib/eject-assets/generators/python/operations.ts +1 -1
  83. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  84. package/lib/eject-assets/generators/python/types.ts +1 -1
  85. package/lib/eject-assets/generators/swr/index.ts +2 -2
  86. package/lib/eject-assets/generators/swr/render.ts +1 -1
  87. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  88. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  89. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  90. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  91. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  92. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  93. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  94. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  95. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  96. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  97. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  98. package/lib/eject-assets/generators/typescript/operations.ts +1 -1
  99. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  100. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  101. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  102. package/lib/eject-assets/generators/zod/index.ts +2 -2
  103. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  104. package/lib/index.js +285 -178
  105. package/package.json +1 -1
  106. package/lib/chunks/PQ2JPZXM.js +0 -59
  107. package/lib/chunks/TXGTKM76.js +0 -8
  108. package/lib/chunks/W5DUUIKF.js +0 -93
@@ -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 $,b as i,c,d as a,e as m,f as p}from"./TNYG2WWT.js";import"./MOKGEIKX.js";import"./4OMVSQVK.js";import"./VGBSMXRM.js";import"./PFYPTG4G.js";import"./M3XP3LQ3.js";import"./NEWT5A6S.js";import{k as u}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as M}from"node:path";function d(t,e){let r=$(t,"swr");if(r.length===0)return"";let s=r.some(i),o=r.some(n=>!i(n));return[...s?['import useSWR from "swr";']:[],...o?['import useSWRMutation from "swr/mutation";']:[],p(r,e.sdkModule,s),...r.flatMap(n=>i(n)?y(n):[k(n)])].join(`
7
+ import{a as $,b as i,c,d as a,e as m,f as p}from"./2WUJ57QA.js";import"./XWZNQKXF.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{k as u}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as M}from"node:path";function d(t,e){let r=$(t,"swr");if(r.length===0)return"";let s=r.some(i),o=r.some(n=>!i(n));return[...s?['import useSWR from "swr";']:[],...o?['import useSWRMutation from "swr/mutation";']:[],p(r,e.sdkModule,s),...r.flatMap(n=>i(n)?y(n):[k(n)])].join(`
8
8
 
9
9
  `)}function f(t,e,r){return`export function use${u(t.name)}(${e}) {
10
10
  return ${r};
@@ -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 x}from"./TFNO2II2.js";import{a as v,b as y,c as R,d as u}from"./KD4AOMY6.js";import{c as f,d as w}from"./HKNDR3ZE.js";import{a as g,b as m}from"./5HNCFY3B.js";import{O as a}from"./M3XP3LQ3.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as A,writeFile as C}from"node:fs/promises";import S from"node:path";async function F(e){let i=await w(e.trafficPath);if(i.length===0)throw new Error("No traffic files found in the provided traffic path.");let t=y.create({openApiIndex:e.openApiIndex,matchMode:e.matchMode,ignoreCookies:e.ignoreCookies,ignoreHeaders:e.ignoreHeaders,previewFindingsLimit:e.previewFindingsLimit,activeRules:e.activeRules,server:e.server,minSeverity:e.minSeverity}),r=0,o=0;for(let n of i){let s=await x(n,e.format);if(!s){a.warn(`Skipping traffic file with unrecognized format: ${n}
7
+ import{a as x}from"./TKFA7G4G.js";import{a as v,b as y,c as R,d as u}from"./B3QINORT.js";import{c as f,d as w}from"./EOS3ZB2L.js";import{a as g,b as m}from"./CA4BPC77.js";import{V as a}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as A,writeFile as C}from"node:fs/promises";import S from"node:path";async function F(e){let i=await w(e.trafficPath);if(i.length===0)throw new Error("No traffic files found in the provided traffic path.");let t=y.create({openApiIndex:e.openApiIndex,matchMode:e.matchMode,ignoreCookies:e.ignoreCookies,ignoreHeaders:e.ignoreHeaders,previewFindingsLimit:e.previewFindingsLimit,activeRules:e.activeRules,server:e.server,minSeverity:e.minSeverity}),r=0,o=0;for(let n of i){let s=await x(n,e.format);if(!s){a.warn(`Skipping traffic file with unrecognized format: ${n}
8
8
  `);continue}r+=1;for await(let c of s.parse(n))await t.process({...c,index:o}),o+=1}if(r===0)throw new Error("No supported traffic files found. In auto mode, files must match built-in traffic parser signatures.");if(o===0)throw new Error("No HTTP exchanges were parsed from the provided traffic files.");return t.finalize()}var E=!!process.stdout.isTTY&&process.env.NO_COLOR===void 0;function T(e){let i=new Set;for(let t of e.operationsByMethod.values())for(let r of t)for(let o of r.servers)i.add(o.rawUrl);return Array.from(i).sort()}function I(e,i,t){let r=e.totalExchanges-e.skippedExchanges;if(r===0&&e.skippedExchanges>0){a.warn(`All ${e.skippedExchanges} exchange(s) were outside the --server "${t}" and were skipped. Check that the server matches the traffic URLs.
9
9
  `);return}if(e.documentedExchanges>0||r===0)return;let o=T(i),n=t?`Check that the --server "${t}" matches the traffic URLs and that the description paths align with the remainder.`:e.hostCompatibleExchanges===r?`The traffic hosts are compatible with the description servers (${o.join(", ")}), so the endpoints are likely undocumented; if they should be documented, check that the description base paths and paths align with the traffic URLs, or use --server to declare the server the traffic was captured against.`:`Check that the traffic host and base path match the description servers (${o.join(", ")}), or use --server to declare the server the traffic was captured against.`;a.warn(`None of the ${r} validated exchange(s) matched a documented operation. ${n}
10
10
  `)}async function $(e,i){let t=f(e);await A(S.dirname(t),{recursive:!0}),await C(t,i,"utf8")}async function q({argv:e,config:i}){let t=f(e.traffic),r=e["traffic-format"],o=e.rules?u(e.rules):void 0,n=e["ignore-headers"]?u(e["ignore-headers"]):void 0,s=e.server;if(s&&e["match-mode"])return m("The --server and --match-mode options are mutually exclusive: --match-mode controls how requests are located via the description servers, while --server replaces the description servers with the one the traffic was captured against.");let c=e["match-mode"]??"strict-host",d=f(e.api),p=await R(d,i);if(p.loadedOperations===0)return m(`No OpenAPI operations were loaded from: ${d}`);let{runId:k,summary:h,findings:O}=await F({trafficPath:t,format:r,matchMode:c,ignoreCookies:e["ignore-cookies"],ignoreHeaders:n,previewFindingsLimit:e["max-findings"],activeRules:o,openApiIndex:p,server:s,minSeverity:e["min-severity"]});I(h,p,s);let l=v({runId:k,summary:h,findings:O,meta:{specSource:d,trafficPath:t,format:r,matchMode:c,server:s}},{format:e["report-format"],color:E&&e["report-format"]==="pretty"&&!e.output,maxFindings:e["max-findings"]});if(e.output?(await $(e.output,l),a.info(`Drift report written to: ${f(e.output)}
@@ -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 as i}from"./MOKGEIKX.js";import{O as p}from"./M3XP3LQ3.js";function h(t,o){let n=t.services.flatMap(e=>e.operations),r=n.filter(e=>e.sse!==void 0);r.length>0&&p.warn(`generate-client: ${o} skipped ${r.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${r.map(e=>e.name).join(", ")}.
7
+ import{a as i}from"./XWZNQKXF.js";import{V as p}from"./OZMIIHFH.js";function h(t,o){let n=t.services.flatMap(e=>e.operations),r=n.filter(e=>e.sse!==void 0);r.length>0&&p.warn(`generate-client: ${o} skipped ${r.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${r.map(e=>e.name).join(", ")}.
8
8
  `);let s=new Set(t.schemas.map(e=>e.name)),a=n.filter(e=>e.sse===void 0&&l(e,s));return a.length>0&&p.warn(`generate-client: ${o} skipped ${a.length} operation(s) whose variables type name collides with a schema \u2014 rename the schema or the operation: ${a.map(e=>e.name).join(", ")}.
9
9
  `),n.filter(e=>e.sse===void 0&&!l(e,s))}function l(t,o){let n=i(t);return n.hasInputs&&o.has(n.variablesTypeName)}function g(t){return t.method==="get"||t.method==="head"}function m(t){return i(t).hasInputs}function u(t){return i(t).variablesTypeName}function O(t,o,n){let r=[];return i(t).hasInputs?r.push(o):n&&r.push("{}"),n&&r.push("{ ...init, envelope: undefined }"),`${t.name}(${r.join(", ")})`}function x(t,o,n){let r=t.map(e=>e.name).sort(),s=t.filter(m).map(u).sort();return n&&s.push("RequestOptions"),`import { ${[...r,...s.map(e=>`type ${e}`)].join(", ")} } from ${JSON.stringify(o)};`}export{h as a,g as b,m as c,u as d,O as e,x as f};
@@ -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{a}from"./WAUR32EX.js";import"./TNYG2WWT.js";import"./MOKGEIKX.js";import"./4OMVSQVK.js";import"./VGBSMXRM.js";import"./PFYPTG4G.js";import"./M3XP3LQ3.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{a as tanstackQueryGenerator};
7
+ import{a}from"./MONT6PMR.js";import"./2WUJ57QA.js";import"./XWZNQKXF.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{a as tanstackQueryGenerator};
@@ -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{a,b,c,d,e}from"./QKGUXGJO.js";import"./NSIQWNYL.js";import"./UKSQ7B5H.js";import"./4OMVSQVK.js";import"./VGBSMXRM.js";import"./PFYPTG4G.js";import"./M3XP3LQ3.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as phpDocs,c as phpGenerator,d as phpSample,a as phpType,b as renderPhpModels};
7
+ import{a,b,c,d,e}from"./FVKTV62N.js";import"./NSIQWNYL.js";import"./UKSQ7B5H.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as phpDocs,c as phpGenerator,d as phpSample,a as phpType,b as renderPhpModels};
@@ -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 h}from"./VGBSMXRM.js";import{e as g,h as p,k as $}from"./NB54XRRU.js";import{join as R}from"node:path";var a=" ";function m(e){return`${$(e)}Schema`}var y=new Map;function u(e,r=y,t=""){return j(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return z(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${m(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return q(e.values);case"union":return k(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return E(e.base,e.keys,r,t)}}function z(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
7
+ import{a as h}from"./4PT55VGO.js";import{e as g,h as p,k as $}from"./NB54XRRU.js";import{join as R}from"node:path";var a=" ";function m(e){return`${$(e)}Schema`}var y=new Map;function u(e,r=y,t=""){return j(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return z(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${m(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return q(e.values);case"union":return k(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return E(e.base,e.keys,r,t)}}function z(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
8
8
  ${e.map((s,i)=>{let d=u(s.schema,r,n),l=s.required?d:`${d}.optional()`,x=i===e.length-1?"":",";return`${n}${c(s.name)}: ${l}${x}`}).join(`
9
9
  `)}
10
10
  ${t}})`}function q(e){return e.every(r=>typeof r=="string")?`z.enum([${e.map(r=>JSON.stringify(r)).join(", ")}])`:`z.union([${e.map(r=>`z.literal(${p(r)})`).join(", ")}])`}function k(e,r,t){let n=e.map(o=>u(o,r,t));return n.length===1?n[0]:`z.union([${n.join(", ")}])`}function E(e,r,t,n){let o=t.get(e);if(o&&o.kind!=="object")return u(f(o,r,t,new Set([e])),t,n);let s=r.map(i=>`${c(i)}: true`).join(", ");return`${m(e)}.omit({ ${s} })`}function f(e,r,t,n){switch(e.kind){case"object":return{...e,properties:e.properties.filter(o=>!r.includes(o.name))};case"union":case"intersection":return{...e,members:e.members.map(o=>f(o,r,t,n))};case"ref":{if(n.has(e.name))return e;let o=t.get(e.name);if(!o)return e;if(o.kind==="object"){let s=r.filter(i=>o.properties.some(d=>d.name===i));return s.length>0?{kind:"omit",base:e.name,keys:s}:e}return f(o,r,t,new Set([...n,e.name]))}default:return e}}function j(e,r){let t=r.metadata;if(!t)return e;let n=e;return r.kind==="scalar"&&r.scalar==="string"&&(t.minLength!==void 0&&(n=`${n}.min(${t.minLength})`),t.maxLength!==void 0&&(n=`${n}.max(${t.maxLength})`),t.pattern!==void 0&&(n=`${n}.regex(new RegExp(${JSON.stringify(t.pattern)}))`)),r.kind==="scalar"&&(r.scalar==="number"||r.scalar==="integer")&&(t.minimum!==void 0&&(n=`${n}.min(${t.minimum})`),t.maximum!==void 0&&(n=`${n}.max(${t.maximum})`),t.exclusiveMinimum!==void 0&&(n=`${n}.gt(${t.exclusiveMinimum})`),t.exclusiveMaximum!==void 0&&(n=`${n}.lt(${t.exclusiveMaximum})`)),r.kind==="array"&&(t.minItems!==void 0&&(n=`${n}.min(${t.minItems})`),t.maxItems!==void 0&&(n=`${n}.max(${t.maxItems})`)),n}function Z(e,r){let t=[];for(let n of h(e.services)){if(n.sse!==void 0)continue;let o=n.requestBody,s=o&&o.contentType.toLowerCase().includes("json")?u(o.schema,r,a):void 0,i=n.successResponses.find(l=>l.contentType.toLowerCase().includes("json")),d=i?u(i.schema,r,a):void 0;!s&&!d||t.push({name:n.specName??n.name,request:s,response:d})}return t}function I(e){let r=e.flatMap(n=>[`${a}${c(n.name)}: {`,...n.request?[`${a}${a}request: z.ZodType;`]:[],...n.response?[`${a}${a}response: z.ZodType;`]:[],`${a}};`]),t=e.map((n,o)=>{let s=[...n.request?[`request: ${n.request}`]:[],...n.response?[`response: ${n.response}`]:[]].join(", "),i=o===e.length-1?"":",";return`${a}${c(n.name)}: { ${s} }${i}`});return["/**"," * Request/response validators by operationId \u2014 powers `zodValidation`, or import one directly."," */","export const operationSchemas: {",...r,"} = {",...t,"};"].join(`
@@ -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{O as R,c as x}from"./M3XP3LQ3.js";import{m}from"./HJYFWIVE.js";function O(e){return e.flatMap(n=>n.operations)}function P(e,n,s){let r=e.specName??e.name;if(s?.exclude?.includes(r))return{};let a=s?.operations?.[r];if(a!==void 0)return y(e,n,a,`pagination.operations["${r}"]`,!0);if(e.paginationExtension!==void 0)return y(e,n,e.paginationExtension,"x-redoclyPagination",!0);if(s?.style!==void 0){let{exclude:o,operations:c,...t}=s;return y(e,n,t,"pagination convention",!1)}return{}}function H(e,n){let s=new Map,r=[];for(let a of O(e.services)){let o=P(a,e,n);o.error!==void 0?r.push(o.error):o.spec!==void 0&&s.set(a.name,{spec:o.spec,itemSchema:o.itemSchema})}if(r.length>0)throw new Error(["Invalid pagination configuration:",...r].join(`
7
+ import{V as R,c as x}from"./OZMIIHFH.js";import{m}from"./HJYFWIVE.js";function O(e){return e.flatMap(n=>n.operations)}function P(e,n,s){let r=e.specName??e.name;if(s?.exclude?.includes(r))return{};let a=s?.operations?.[r];if(a!==void 0)return y(e,n,a,`pagination.operations["${r}"]`,!0);if(e.paginationExtension!==void 0)return y(e,n,e.paginationExtension,"x-redoclyPagination",!0);if(s?.style!==void 0){let{exclude:o,operations:c,...t}=s;return y(e,n,t,"pagination convention",!1)}return{}}function H(e,n){let s=new Map,r=[];for(let a of O(e.services)){let o=P(a,e,n);o.error!==void 0?r.push(o.error):o.spec!==void 0&&s.set(a.name,{spec:o.spec,itemSchema:o.itemSchema})}if(r.length>0)throw new Error(["Invalid pagination configuration:",...r].join(`
8
8
  - `));return s}function y(e,n,s,r,a){let o=`Pagination for operation "${e.name}" (${r})`,c=q(s);if(c!==void 0)return{error:`${o}: ${c}`};let t=s,d=i=>a?{error:`${o}: ${i}`}:{};if(e.sse!==void 0)return d("the operation is a Server-Sent Events stream");if(t.style!=="link"){let i=t.style==="cursor"?"cursorParam":"offsetParam",l=t.style==="cursor"?t.cursorParam:t.offsetParam,k=e.queryParams.find(u=>u.name===l);if(!k){let u=e.queryParams.map(E=>E.name).join(", ");return d(`query parameter "${l}" is not declared on the operation`+(u===""?"":` (declared: ${u})`))}let p=C(k.schema,n);if(!(p!==void 0&&(t.style==="cursor"?b(p,n):p.kind==="scalar"&&(p.scalar==="number"||p.scalar==="integer")))){let u=t.style==="cursor"?"a string":"a number";return d(`the "${i}" query parameter "${l}" must accept ${u} (got ${I(p)})`)}}let g=e.successResponses.find(i=>i.contentType.toLowerCase().includes("json"));if(!g)return d("the operation has no JSON success response");if(t.style==="link"){let i=e.successResponseHeaders?.some(l=>l.name==="link")===!0;if(!i&&!a)return{};i||R.warn(`generate-client: ${o.toLowerCase()} follows the Link header, but the success response does not document one.
9
9
  `)}let h=m(g.schema,t.items,n);if(h===void 0)return d(`the "items" pointer "${t.items}" does not resolve in the success response schema`);if(h.kind!=="array")return d(`the "items" pointer "${t.items}" must point at an array (got ${h.kind})`);if(t.style==="cursor"){let i=m(g.schema,t.nextCursor,n);if(i===void 0)return d(`the "nextCursor" pointer "${t.nextCursor}" does not resolve in the success response schema`);if(!b(i,n))return d(`the "nextCursor" pointer "${t.nextCursor}" must point at a string (got ${i.kind})`);if(t.hasMore!==void 0){let l=m(g.schema,t.hasMore,n);if(l===void 0)return d(`the "hasMore" pointer "${t.hasMore}" does not resolve in the success response schema`);if(l.kind!=="scalar"||l.scalar!=="boolean")return d(`the "hasMore" pointer "${t.hasMore}" must point at a boolean (got ${l.kind})`)}}let f=t.limitParam!==void 0?{limitParam:t.limitParam}:{};return{spec:t.style==="cursor"?{style:"cursor",param:t.cursorParam,...f,nextCursor:t.nextCursor,...t.hasMore!==void 0?{hasMore:t.hasMore}:{},items:t.items}:t.style==="link"?{style:"link",...f,items:t.items}:{style:t.style,param:t.offsetParam,...f,items:t.items},itemSchema:h.items}}function q(e){if(!x(e))return"the rule must be an object";let{style:n,cursorParam:s,nextCursor:r,hasMore:a,offsetParam:o,limitParam:c,items:t}=e;if(n!=="cursor"&&n!=="offset"&&n!=="page"&&n!=="link")return`"style" must be one of "cursor" | "offset" | "page" | "link" (got ${JSON.stringify(n)})`;if(typeof t!="string"||t!==""&&!t.startsWith("/"))return'"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';if(n==="cursor"){if(typeof s!="string"||s==="")return'cursor style requires a "cursorParam" query parameter name';if(typeof r!="string"||!r.startsWith("/"))return'cursor style requires a "nextCursor" JSON pointer starting with "/"';if(a!==void 0&&(typeof a!="string"||!a.startsWith("/")))return'"hasMore" must be a JSON pointer starting with "/"'}else if((n==="offset"||n==="page")&&(typeof o!="string"||o===""))return`${n} style requires an "offsetParam" query parameter name`;if(c!==void 0&&typeof c!="string")return'"limitParam" must be a query parameter name'}function I(e){return e===void 0?"an unresolvable ref":e.kind==="scalar"||e.kind==="enum"?e.scalar:e.kind}function C(e,n){let s=new Set,r=e;for(;r.kind==="ref";){let{name:a}=r;if(s.has(a))return;s.add(a);let o=n.schemas.find(c=>c.name===a);if(o===void 0)return;r=o.schema}return r}function b(e,n){return e.kind==="scalar"||e.kind==="enum"?e.scalar==="string":e.kind==="literal"?typeof e.value=="string":e.kind==="union"?e.members.every(s=>{let r=C(s,n);return r!==void 0&&(r.kind==="null"||r.kind!=="union"&&b(r,n))}):!1}var G={"types.ts":`/**
10
10
  * The public type surface of the client runtime \u2014 \`@redocly/client-generator\`'s
@@ -5397,4 +5397,4 @@ async function runSingle(
5397
5397
  }
5398
5398
  return fail(1, detail);
5399
5399
  }
5400
- }`},S=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var j=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],$=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],N=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],v;function Q(){return v===void 0&&(v=new Set([...j,...$,...N,...S])),v}var A={name:"@redocly/client-generator",version:"0.4.2",description:"Generate typed, zero-dependency TypeScript clients (fetch, auth, retries, middleware, SSE) from OpenAPI descriptions.",type:"module",types:"lib/index.d.ts",sideEffects:!1,exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./generate":{types:"./lib/generate.d.ts",import:"./lib/generate.js",default:"./lib/generate.js"},"./printers/python":{types:"./lib/printers/python.d.ts",import:"./lib/printers/python.js",default:"./lib/printers/python.js"},"./printers/go":{types:"./lib/printers/go.d.ts",import:"./lib/printers/go.js",default:"./lib/printers/go.js"},"./printers/php":{types:"./lib/printers/php.d.ts",import:"./lib/printers/php.js",default:"./lib/printers/php.js"},"./printers/typescript":{types:"./lib/printers/typescript.d.ts",import:"./lib/printers/typescript.js",default:"./lib/printers/typescript.js"},"./printers":{types:"./lib/printers/index.d.ts",import:"./lib/printers/index.js",default:"./lib/printers/index.js"},"./contracts/typescript":{types:"./lib/contracts/typescript.d.ts",import:"./lib/contracts/typescript.js",default:"./lib/contracts/typescript.js"},"./runtime-sources":{types:"./lib/runtime-sources.d.ts",import:"./lib/runtime-sources.js",default:"./lib/runtime-sources.js"},"./package.json":"./package.json"},engines:{node:">=22.12.0 || >=20.19.0 <21.0.0",npm:">=10"},engineStrict:!0,publishConfig:{access:"public"},scripts:{"examples:regen":"node scripts/regenerate-examples.mjs",prepare:"node scripts/generate-runtime-sources.mjs && node scripts/generate-eject-assets.mjs","typecheck:examples":"node scripts/typecheck-examples.mjs"},license:"MIT",repository:{type:"git",url:"git+https://github.com/Redocly/redocly-cli.git"},homepage:"https://github.com/Redocly/redocly-cli",keywords:["OpenAPI","Swagger","TypeScript","client","generator","codegen","fetch"],contributors:["Roman Marshevskyi <roman.marshevskyy@redocly.com> (https://redocly.com/)"],dependencies:{"@redocly/openapi-core":"2.49.1"},peerDependencies:{typescript:">=5.5.0"},peerDependenciesMeta:{typescript:{optional:!0}},devDependencies:{typescript:"6.0.2"},files:["lib","eject-assets"]};var ee=A.version;function T(e){let n=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());return n===null?void 0:[Number(n[1]),Number(n[2]),Number(n[3])]}function w(e,n){return e[0]-n[0]||e[1]-n[1]||e[2]-n[2]}function ne(e,n){let s=/^[\^~]|^>=/.exec(n.trim())?.[0]??"",r=T(n.trim().slice(s.length)),a=T(e);if(!(r===void 0||a===void 0))return w(a,r)<0?!1:s===">="?!0:s===""?w(a,r)===0:s==="~"?a[0]===r[0]&&a[1]===r[1]:r[0]!==0?a[0]===r[0]:r[1]!==0?a[0]===0&&a[1]===r[1]:w(a,r)===0}export{O as a,H as b,G as c,W as d,j as e,Q as f,A as g,ee as h,ne as i};
5400
+ }`},S=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var j=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],$=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],N=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],v;function Q(){return v===void 0&&(v=new Set([...j,...$,...N,...S])),v}var A={name:"@redocly/client-generator",version:"0.4.4",description:"Generate typed, zero-dependency TypeScript clients (fetch, auth, retries, middleware, SSE) from OpenAPI descriptions.",type:"module",types:"lib/index.d.ts",sideEffects:!1,exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./generate":{types:"./lib/generate.d.ts",import:"./lib/generate.js",default:"./lib/generate.js"},"./printers/python":{types:"./lib/printers/python.d.ts",import:"./lib/printers/python.js",default:"./lib/printers/python.js"},"./printers/go":{types:"./lib/printers/go.d.ts",import:"./lib/printers/go.js",default:"./lib/printers/go.js"},"./printers/php":{types:"./lib/printers/php.d.ts",import:"./lib/printers/php.js",default:"./lib/printers/php.js"},"./printers/typescript":{types:"./lib/printers/typescript.d.ts",import:"./lib/printers/typescript.js",default:"./lib/printers/typescript.js"},"./printers":{types:"./lib/printers/index.d.ts",import:"./lib/printers/index.js",default:"./lib/printers/index.js"},"./contracts/typescript":{types:"./lib/contracts/typescript.d.ts",import:"./lib/contracts/typescript.js",default:"./lib/contracts/typescript.js"},"./runtime-sources":{types:"./lib/runtime-sources.d.ts",import:"./lib/runtime-sources.js",default:"./lib/runtime-sources.js"},"./package.json":"./package.json"},engines:{node:">=22.12.0 || >=20.19.0 <21.0.0",npm:">=10"},engineStrict:!0,publishConfig:{access:"public"},scripts:{"examples:regen":"node scripts/regenerate-examples.mjs",prepare:"node scripts/generate-runtime-sources.mjs && node scripts/generate-eject-assets.mjs","typecheck:examples":"node scripts/typecheck-examples.mjs"},license:"MIT",repository:{type:"git",url:"git+https://github.com/Redocly/redocly-cli.git"},homepage:"https://github.com/Redocly/redocly-cli",keywords:["OpenAPI","Swagger","TypeScript","client","generator","codegen","fetch"],contributors:["Roman Marshevskyi <roman.marshevskyy@redocly.com> (https://redocly.com/)"],dependencies:{"@redocly/openapi-core":"2.51.0"},peerDependencies:{typescript:">=5.5.0"},peerDependenciesMeta:{typescript:{optional:!0}},devDependencies:{typescript:"6.0.2"},files:["lib","eject-assets"]};var ee=A.version;function T(e){let n=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());return n===null?void 0:[Number(n[1]),Number(n[2]),Number(n[3])]}function w(e,n){return e[0]-n[0]||e[1]-n[1]||e[2]-n[2]}function ne(e,n){let s=/^[\^~]|^>=/.exec(n.trim())?.[0]??"",r=T(n.trim().slice(s.length)),a=T(e);if(!(r===void 0||a===void 0))return w(a,r)<0?!1:s===">="?!0:s===""?w(a,r)===0:s==="~"?a[0]===r[0]&&a[1]===r[1]:r[0]!==0?a[0]===r[0]:r[1]!==0?a[0]===0&&a[1]===r[1]:w(a,r)===0}export{O as a,H as b,G as c,W as d,j as e,Q as f,A as g,ee as h,ne as i};
@@ -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"./WZ7U5J57.js";import"./UKSQ7B5H.js";import"./TNYG2WWT.js";import"./MOKGEIKX.js";import"./4OMVSQVK.js";import"./VGBSMXRM.js";import"./PFYPTG4G.js";import"./M3XP3LQ3.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.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"./KBGRTZ3S.js";import"./UKSQ7B5H.js";import"./2WUJ57QA.js";import"./XWZNQKXF.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{b as cliDocs,a as cliGenerator,c as cliSample};
@@ -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
- var e={name:"@redocly/cli",version:"2.49.1",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:"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:{"@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.5","@redocly/client-generator":"0.4.2","@redocly/openapi-core":"2.49.1","@redocly/respect-core":"2.49.1","@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.9","https-proxy-agent":"^7.0.5",react:"^17.0.0 || ^18.2.0 || ^19.2.7","react-dom":"^17.0.0 || ^18.2.0 || ^19.2.7",redoc:"2.5.3",semver:"^7.5.2","set-cookie-parser":"^2.3.5","styled-components":"6.4.2",typescript:"6.0.2",ulid:"^3.0.1",undici:"^6.28.0",yargs:"17.0.1"}};var{version:s,name:i,engines:c}=e,n=e.devDependencies.redoc,p="sha384-xiEssMQFSpSfLbzRZCGfxxIM5QDb2DTrU6vyoZdp2sV1L6pmOMy6MpTtUoLbpC96";export{s as a,i as b,c,n as d,p as e};
7
+ var e={name:"@redocly/cli",version:"2.51.0",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:"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:{"@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.5","@redocly/client-generator":"0.4.4","@redocly/openapi-core":"2.51.0","@redocly/respect-core":"2.51.0","@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.9","https-proxy-agent":"^7.0.5",react:"^17.0.0 || ^18.2.0 || ^19.2.7","react-dom":"^17.0.0 || ^18.2.0 || ^19.2.7",redoc:"2.5.3",semver:"^7.5.2","set-cookie-parser":"^2.3.5","styled-components":"6.4.2",typescript:"6.0.2",ulid:"^3.0.1",undici:"^6.28.0",yargs:"17.0.1"}};var{version:s,name:i,engines:c}=e,n=e.devDependencies.redoc,p="sha384-xiEssMQFSpSfLbzRZCGfxxIM5QDb2DTrU6vyoZdp2sV1L6pmOMy6MpTtUoLbpC96";export{s as a,i as b,c,n as d,p as e};
@@ -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"./VGBSMXRM.js";import{c as w}from"./M3XP3LQ3.js";import{a as H,e as q,g as P,h as g,k as E}from"./NB54XRRU.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"./4PT55VGO.js";import{c as w}from"./OZMIIHFH.js";import{a as H,e as q,g as P,h as g,k as E}from"./NB54XRRU.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,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"./UKSQ7B5H.js";import"./TNYG2WWT.js";import{g as m}from"./MOKGEIKX.js";import{k as l,l as c}from"./4OMVSQVK.js";import{c as b,d as $}from"./VGBSMXRM.js";import"./PFYPTG4G.js";import{O as h}from"./M3XP3LQ3.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import{a as C,b as S}from"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as y}from"node:path";function g(t){return(t??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function k(t){return[t.group===void 0?void 0:l(t.group),t.name].filter(Boolean).join(" ")}function R(t,e){return[t,k(e),...e.positionals.map(i=>`<${i.name}>`),...e.flags.filter(i=>i.required).map(i=>`--${i.name} <${i.type}>`),...e.body?[e.body.required?"--json '<json>'":"[--json '<json>']"]:[]].filter(i=>i!=="").join(" ")}function P(t,e){t.line("| Flag | Type | Required | Description |"),t.line("| ---- | ---- | -------- | ----------- |");for(let n of e){let i=[g(n.description),n.enum===void 0?"":`One of ${n.enum.map(r=>`\`${r}\``).join(", ")}.`,n.type==="array"?"Repeat the flag for multiple values.":""].filter(r=>r!=="").join(" ");t.line(`| \`--${n.name}\` | ${n.type} | ${n.required?"yes":"no"} | ${i} |`)}t.blank()}function A(t,e,n){if(t.line(`### \`${k(e)}\``),t.blank(),e.summary!==void 0&&(t.line(g(e.summary)),t.blank()),t.line(`\`${e.method} ${e.path}\``),t.blank(),t.line("```sh"),t.line(R(n.name,e)),t.line("```"),t.blank(),e.positionals.length>0){t.line("| Argument | Description |"),t.line("| -------- | ----------- |");for(let r of e.positionals)t.line(`| \`<${r.name}>\` | ${g(r.description)} |`);t.blank()}e.flags.length>0&&P(t,e.flags);let i=[e.body===void 0?"":`Takes a JSON body${e.body.required?" (required)":""}: \`--json '<json>'\`, \`--json @file.json\`, or \`--json @-\` for stdin.`,e.unsupportedBody===void 0?"":`Takes a \`${e.unsupportedBody}\` body, which the CLI cannot build \u2014 call this operation through the generated client instead.`,e.paginated===!0?"Paginated: `--page-all` follows every page, printing one JSON page per line.":"",e.sse===!0?"Streams server-sent events as one JSON object per line.":"",e.blob===!0?"Returns binary content, so `--output <path>` is required.":""].filter(r=>r!=="");for(let r of i)t.line(r);i.length>0&&t.blank()}function v(t,e){let n=new C;e.frontmatter&&(n.line("---"),n.line(`title: ${e.title}`),n.line("---"),n.blank()),n.line(`# ${e.title}`),n.blank(),n.line(`Generated command-line reference for \`${e.name}\`, produced from the API description by \`redocly generate-client\`.`),n.line("Re-run generation to update it \u2014 this file is not hand-edited."),n.blank(),n.line("## Usage"),n.blank(),n.line("```sh"),n.line(`${e.name} <command> [flags]`),n.line(`${e.name} --help`),n.line(`${e.name} schema <command> # request/response schemas`),n.line("```"),n.blank(),n.line("Install the file under any `bin` name: the command takes that name, and the credential variables below do not change."),n.blank(),n.line("## Global flags"),n.blank(),n.line("| Flag | Description |"),n.line("| ---- | ----------- |");let i=e.schemes.some(o=>o.kind==="bearer");for(let[o,s]of[["--server-url <url>","Override the server URL included in the client."],["--format <json\\|ndjson>","Output format."],["--dry-run","Print the prepared request, credentials redacted, without sending it."],["--page-all","Follow pagination, printing one JSON page per line."],["--output <path>","Write the response body to a file. Required for binary responses."],...i?[["--token <token>","Bearer token, overriding the environment."]]:[],["--json <json\\|@file\\|@->","Request body, inline or from a file or stdin."]])n.line(`| \`${o}\` | ${s} |`);n.blank();let r=c(e.name);if(n.line("## Credentials"),n.blank(),e.schemes.length===0)n.line("The description declares no security schemes, so no credentials are read.");else{n.line("Credentials come from the environment:"),n.blank(),n.line("| Scheme | Variable |"),n.line("| ------ | -------- |");for(let o of e.schemes){let s=o.kind==="bearer"?`\`${r}_TOKEN\` (or \`--token\`)`:o.kind==="basic"?`\`${r}_USERNAME\` and \`${r}_PASSWORD\``:`\`${r}_API_KEY_${c(o.key)}\``;n.line(`| ${o.kind} (\`${o.key}\`) | ${s} |`)}}n.blank(),n.line("## Exit codes"),n.blank(),n.line("| Code | Meaning |"),n.line("| ---- | ------- |");for(let[o,s]of[[0,"success"],[1,"API error (status other than 401 or 403)"],[2,"auth error (401 or 403)"],[3,"validation error"],[4,"usage error (unknown command or flag, bad `--json`)"]])n.line(`| ${o} | ${s} |`);n.blank(),n.line("Errors print one JSON object to stderr, so stdout stays clean for piping."),n.blank();let a=[...new Set(t.map(o=>o.group))];for(let o of a){let s=t.filter(d=>d.group===o);o===void 0?(n.line("## Commands"),n.blank()):(n.line(`## ${o}`),n.blank(),n.line(`Addressed as \`${e.name} ${l(o)} <command>\`.`),n.blank());for(let d of s)A(n,d,e)}return n.toString().replace(/\n{3,}/g,`
7
+ import"./UKSQ7B5H.js";import"./2WUJ57QA.js";import{g as m}from"./XWZNQKXF.js";import{k as l,l as c}from"./NAGDQV7J.js";import{c as b,d as $}from"./4PT55VGO.js";import"./PFYPTG4G.js";import{V as h}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import{a as C,b as S}from"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as y}from"node:path";function g(t){return(t??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function k(t){return[t.group===void 0?void 0:l(t.group),t.name].filter(Boolean).join(" ")}function R(t,e){return[t,k(e),...e.positionals.map(i=>`<${i.name}>`),...e.flags.filter(i=>i.required).map(i=>`--${i.name} <${i.type}>`),...e.body?[e.body.required?"--json '<json>'":"[--json '<json>']"]:[]].filter(i=>i!=="").join(" ")}function P(t,e){t.line("| Flag | Type | Required | Description |"),t.line("| ---- | ---- | -------- | ----------- |");for(let n of e){let i=[g(n.description),n.enum===void 0?"":`One of ${n.enum.map(r=>`\`${r}\``).join(", ")}.`,n.type==="array"?"Repeat the flag for multiple values.":""].filter(r=>r!=="").join(" ");t.line(`| \`--${n.name}\` | ${n.type} | ${n.required?"yes":"no"} | ${i} |`)}t.blank()}function A(t,e,n){if(t.line(`### \`${k(e)}\``),t.blank(),e.summary!==void 0&&(t.line(g(e.summary)),t.blank()),t.line(`\`${e.method} ${e.path}\``),t.blank(),t.line("```sh"),t.line(R(n.name,e)),t.line("```"),t.blank(),e.positionals.length>0){t.line("| Argument | Description |"),t.line("| -------- | ----------- |");for(let r of e.positionals)t.line(`| \`<${r.name}>\` | ${g(r.description)} |`);t.blank()}e.flags.length>0&&P(t,e.flags);let i=[e.body===void 0?"":`Takes a JSON body${e.body.required?" (required)":""}: \`--json '<json>'\`, \`--json @file.json\`, or \`--json @-\` for stdin.`,e.unsupportedBody===void 0?"":`Takes a \`${e.unsupportedBody}\` body, which the CLI cannot build \u2014 call this operation through the generated client instead.`,e.paginated===!0?"Paginated: `--page-all` follows every page, printing one JSON page per line.":"",e.sse===!0?"Streams server-sent events as one JSON object per line.":"",e.blob===!0?"Returns binary content, so `--output <path>` is required.":""].filter(r=>r!=="");for(let r of i)t.line(r);i.length>0&&t.blank()}function v(t,e){let n=new C;e.frontmatter&&(n.line("---"),n.line(`title: ${e.title}`),n.line("---"),n.blank()),n.line(`# ${e.title}`),n.blank(),n.line(`Generated command-line reference for \`${e.name}\`, produced from the API description by \`redocly generate-client\`.`),n.line("Re-run generation to update it \u2014 this file is not hand-edited."),n.blank(),n.line("## Usage"),n.blank(),n.line("```sh"),n.line(`${e.name} <command> [flags]`),n.line(`${e.name} --help`),n.line(`${e.name} schema <command> # request/response schemas`),n.line("```"),n.blank(),n.line("Install the file under any `bin` name: the command takes that name, and the credential variables below do not change."),n.blank(),n.line("## Global flags"),n.blank(),n.line("| Flag | Description |"),n.line("| ---- | ----------- |");let i=e.schemes.some(o=>o.kind==="bearer");for(let[o,s]of[["--server-url <url>","Override the server URL included in the client."],["--format <json\\|ndjson>","Output format."],["--dry-run","Print the prepared request, credentials redacted, without sending it."],["--page-all","Follow pagination, printing one JSON page per line."],["--output <path>","Write the response body to a file. Required for binary responses."],...i?[["--token <token>","Bearer token, overriding the environment."]]:[],["--json <json\\|@file\\|@->","Request body, inline or from a file or stdin."]])n.line(`| \`${o}\` | ${s} |`);n.blank();let r=c(e.name);if(n.line("## Credentials"),n.blank(),e.schemes.length===0)n.line("The description declares no security schemes, so no credentials are read.");else{n.line("Credentials come from the environment:"),n.blank(),n.line("| Scheme | Variable |"),n.line("| ------ | -------- |");for(let o of e.schemes){let s=o.kind==="bearer"?`\`${r}_TOKEN\` (or \`--token\`)`:o.kind==="basic"?`\`${r}_USERNAME\` and \`${r}_PASSWORD\``:`\`${r}_API_KEY_${c(o.key)}\``;n.line(`| ${o.kind} (\`${o.key}\`) | ${s} |`)}}n.blank(),n.line("## Exit codes"),n.blank(),n.line("| Code | Meaning |"),n.line("| ---- | ------- |");for(let[o,s]of[[0,"success"],[1,"API error (status other than 401 or 403)"],[2,"auth error (401 or 403)"],[3,"validation error"],[4,"usage error (unknown command or flag, bad `--json`)"]])n.line(`| ${o} | ${s} |`);n.blank(),n.line("Errors print one JSON object to stderr, so stdout stays clean for piping."),n.blank();let a=[...new Set(t.map(o=>o.group))];for(let o of a){let s=t.filter(d=>d.group===o);o===void 0?(n.line("## Commands"),n.blank()):(n.line(`## ${o}`),n.blank(),n.line(`Addressed as \`${e.name} ${l(o)} <command>\`.`),n.blank());for(let d of s)A(n,d,e)}return n.toString().replace(/\n{3,}/g,`
8
8
 
9
9
  `).trimEnd()+`
10
10
  `}function w(){return $["cli.ts"]}function x(){return b["cli.ts"]}var E="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function q(t){return S.snake(t).replace(/_/g,"-")}function j(t){let e=t.schema,n=e.kind==="array"?"array":e.kind==="scalar"&&(e.scalar==="integer"||e.scalar==="number")?"number":e.kind==="scalar"&&e.scalar==="boolean"?"boolean":"string";return{name:q(t.name),param:t.name,type:n,required:t.required,...e.kind==="enum"?{enum:e.values.map(String)}:{},...t.description!==void 0?{description:t.description}:{}}}function F(t){let e=t.successResponses;return e.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function N(t){return t.successResponses.find(e=>e.contentType.toLowerCase().includes("json"))?.schema}function T(t,e,n){if(n!=="flat")return{};let i=m(t,e.schemas);return"mergeBody"in i&&i.mergeBody?{merged:!0}:{}}function D(t,e,n){return n!=="flat"?{}:"collisions"in m(t,e.schemas)?{argsStyle:"grouped"}:{}}function p(t,e){let n=[];for(let i of t.services)for(let r of i.operations){let a=r.requestBody?.contentType.toLowerCase().includes("json")?r.requestBody:void 0,o=N(r);n.push({...r.tags.length>0?{group:r.tags[0]}:{},name:r.name,...r.summary!==void 0?{summary:r.summary}:{},method:r.method.toUpperCase(),path:r.path,positionals:r.pathParams.map(s=>({name:s.name,type:j(s).type,...s.description!==void 0?{description:s.description}:{}})),flags:r.queryParams.map(j),...a?{body:{required:a.required,...T(r,t,e.argsStyle)}}:{},...a===void 0&&r.requestBody!==void 0?{unsupportedBody:r.requestBody.contentType}:{},...e.pagination?.has(r.name)===!0?{paginated:!0}:{},...D(r,t,e.argsStyle),...r.sse!==void 0?{sse:!0}:{},...F(r)?{blob:!0}:{},...a!==void 0||o!==void 0?{schemas:{...a?{request:a.schema}:{},...o!==void 0?{response:o}:{}}}:{}})}return n}var U=`function isProcessEntry(): boolean {
@@ -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 S,b as d}from"./REFX2EKS.js";import{a as C}from"./UKSQ7B5H.js";import{b as H,c as D,d as G,e as K,f as J,g as z,h as Q}from"./4OMVSQVK.js";import"./VGBSMXRM.js";import{a as j}from"./PFYPTG4G.js";import"./M3XP3LQ3.js";import"./NEWT5A6S.js";import{b as A,c as I,d as v,e as L,g as E,h as x,i as B,j as F,k as W,n as _}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var c=new S,b=I.go;function V(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||b.has(e))throw new j(`goPackage "${e}" is not a valid Go package name: use lowercase letters, digits, and underscores, don't start with a digit, and avoid Go keywords.`);return e}function w(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let a=d(o.name),i=2;for(;t.has(a);)a=`${d(o.name)}${i++}`;t.add(a),n.push({op:o,ident:a})}return n}function oe(e){return J(e).map(n=>n.kind==="literal"?c.string(n.value):v(n.name,{style:"camel",reserved:b})).join(" + ")}function X(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,a)=>{let i=`${d(o.description??`server${a+1}`)}URL`;r.has(i)&&(i=`${i}${a+1}`),r.add(i);let s=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} string`),u=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} default: ${c.string(l.default)}`).join(", ");e.line(`// ${i} returns the ${c.string(o.description??o.url)} base URL${u===""?".":` (${u}).`}`),e.block(`func ${i}(${s.join(", ")}) string {`,()=>{e.line(`return ${oe(o)}`)},"}"),e.blank()})}function Y(e,t){let n=z(e,t).map(r=>r.map(o=>o.kind==="apiKey"?`{Scheme: ${c.string(o.scheme)}, Kind: "apiKey", Name: ${c.string(o.name)}, In: ${c.string(o.in)}}`:`{Scheme: ${c.string(o.scheme)}, Kind: ${c.string(o.kind)}}`));if(n.length!==0)return`[][]SecuritySpec{${n.map(r=>`{${r.join(", ")}}`).join(", ")}}`}function Z(e){return`&PaginationSpec{${[`Style: ${c.string(e.style)}`,...e.param!==void 0?[`Param: ${c.string(e.param)}`]:[],...e.nextCursor!==void 0?[`NextCursor: ${c.string(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`HasMore: ${c.string(e.hasMore)}`]:[],...e.limitParam!==void 0?[`LimitParam: ${c.string(e.limitParam)}`]:[],...e.items!==void 0?[`Items: ${c.string(e.items)}`]:[]].join(", ")}}`}function g(e,t="string"){if(B(e)){let n=g(F(e),t);return n.startsWith("*")||n==="any"?n:`*${n}`}switch(e.kind){case"scalar":if(t==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"time.Time";if(e.metadata?.format==="date")return"Date"}return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"array":return`[]${g(e.items,t)}`;case"record":return`map[string]${g(e.value,t)}`;case"ref":return d(e.name);case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float64";case"enum":return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"omit":return d(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ae(e,t,n,r,o){e.doc(d(t),o),e.block(`type ${d(t)} struct {`,()=>{for(let a of n){let i=d(a.name),s=g(a.schema,r),u=`\`json:"${a.name}"\``;a.required||(!s.startsWith("*")&&!s.startsWith("[]")&&!s.startsWith("map[")&&s!=="any"&&(s=`*${s}`),u=`\`json:"${a.name},omitempty"\``),e.line(`${i} ${s} ${u}`)}},"}"),e.blank()}function N(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:a})=>x(a,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=ie(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function ie(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let a=W(o);if(a!==void 0){let s=a.scalar==="string"?"string":"int64";n.doc(d(r),o.description),n.line(`type ${d(r)} ${s}`),n.blank(),n.block("const (",()=>{let u=new Set;a.values.forEach(l=>{let f=A.pascal(String(l))||"Value",m="";for(let k=2;u.has(f+m);k++)m=String(k);u.add(f+m);let h=d(r)+f+m;n.line(`${h} ${d(r)} = ${c.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let s=E(o,e);if(s!==void 0){ae(n,r,s.properties,t,s.description??o.description);continue}}let i=x(o,e);if(i!==void 0){let s=d(r),u=i.cases.map(l=>`${l.value} -> ${d(l.schemaName)}`).join(", ");n.line(`// ${s} is a discriminated union ("${i.property}"): ${u}.`),n.line(`type ${s} = any`),n.blank(),n.line(`// Unmarshal${s} decodes into the member selected by "${i.property}".`),n.block(`func Unmarshal${s}(data []byte) (${s}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${i.property}"\``)},"}"),n.block("if err := json.Unmarshal(data, &probe); err != nil {",()=>{n.line("return nil, err")},"}"),n.line("switch probe.Discriminant {");for(let l of i.cases)n.block(`case ${c.string(l.value)}:`,()=>{n.line(`var value ${d(l.schemaName)}`),n.line("err := json.Unmarshal(data, &value)"),n.line("return value, err")});n.line("}"),n.line("var fallback any"),n.line("err := json.Unmarshal(data, &fallback)"),n.line("return fallback, err")},"}"),n.blank();continue}n.doc(d(r),o.description),n.line(`type ${d(r)} = ${g(o,t)}`),n.blank()}return n.toString()}function R(e,t){if(t==="string")return e;let n=e.startsWith("*")?`(${e})`:e;return t==="time.Time"?`${n}.Format(time.RFC3339)`:t==="Date"?`${n}.Format("2006-01-02")`:t==="int64"?`strconv.FormatInt(${e}, 10)`:t==="float64"?`strconv.FormatFloat(${e}, 'f', -1, 64)`:t==="bool"?`strconv.FormatBool(${e})`:`fmt.Sprint(${e})`}var se=["c","ctx","body","params","out","op"];function T(e,t){let n=L(e.pathParams.map(r=>r.name),{style:"camel",reserved:b,taken:se});return e.pathParams.map((r,o)=>({param:r,go:n[o],type:g(r.schema,t)}))}function le(e,t){let n=new Set;return(e.successResponseHeaders??[]).map(r=>{let o=d(r.name),a=o,i=2;for(;n.has(a);)a=`${o}${i++}`;n.add(a);let s=_(r.schema,t),u={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[s];return{field:a,name:r.name,...u}})}function U(e,t,n,r,o,a=!1){let i=T(t,r),s=t.queryParams.length>0,u=D(t),l=u===void 0?void 0:g(u,r),f=a?le(t,o):[];a&&(e.line(`// ${n}Headers carries the declared response headers of ${n}WithHeaders (nil when absent or unparsable).`),e.block(`type ${n}Headers struct {`,()=>{for(let p of f)e.line(`${p.field} ${p.goType}`)},"}"),e.blank());let m=["ctx context.Context",...i.map(({go:p,type:P})=>`${p} ${P}`),...t.requestBody?[`body ${g(t.requestBody.schema,r)}`]:[],...s?[`params *${n}Params`]:[]],h=G(t),k=a?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:h!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,$=p=>a?l===void 0?`return headers, ${p}`:`return out, headers, ${p}`:l===void 0?`return ${p}`:`return out, ${p}`,M=a?`${n}WithHeaders`:n;e.doc(M,a?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${M}(${m.join(", ")}) ${k} {`,()=>{h===void 0&&l!==void 0&&e.line(`var out ${l}`),a&&e.line(`var headers ${n}Headers`),e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),s&&e.block("if params != nil {",()=>{for(let y of t.queryParams){let O=d(y.name);e.block(`if params.${O} != nil {`,()=>{if(y.schema.kind==="array"){let q=g(y.schema.items,r);e.block(`for _, item := range *params.${O} {`,()=>{e.line(`query.Add(${c.string(y.name)}, ${R("item",q)})`)},"}")}else e.line(`query.Set(${c.string(y.name)}, ${R(`*params.${O}`,g(y.schema,r))})`)},"}")}},"}");let p=i.map(({param:y,go:O,type:q})=>`${c.string(y.name)}: ${R(O,q)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${p}})`),h!==void 0){e.block("open := func(extraHeaders map[string]string) (*http.Response, error) {",()=>{e.line("merged := map[string]string{}"),e.block("for key, value := range authHeaders {",()=>{e.line("merged[key] = value")},"}"),e.block("for key, value := range extraHeaders {",()=>{e.line("merged[key] = value")},"}"),e.line("return send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: merged, Query: query})")},"}"),e.line(`return iterSSE(open, ${h.schema!==void 0&&h.schema.kind!=="unknown"})`);return}let P=["OperationID: op.ID","Method: op.Method","URL: requestURL","Headers: authHeaders","Query: query"];if(t.requestBody&&K(t)?(e.line("contentType, reader, err := toMultipart(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: reader"),P.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: bytes.NewReader(payload)"),P.push(`ContentType: ${c.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${P.join(", ")}})`),e.block("if err != nil {",()=>{e.line($("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line($("apiErrorFrom(resp, requestURL)"))},"}"),a){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line($("err"))},"}");for(let y of f)e.line(`headers.${y.field} = ${y.helper}(resp.Header, ${c.string(y.name)})`);e.line(l===void 0?"return headers, nil":"return out, headers, nil")}else l===void 0?e.line("return decodeJSON(resp, nil)"):(e.block("if err := decodeJSON(resp, &out); err != nil {",()=>{e.line("return out, err")},"}"),e.line("return out, nil"))},"}"),e.blank()}function ee(e,t,n,r,o,a){let i=T(t,r),s=t.queryParams.length>0,u=["ctx context.Context",...i.map(({go:f,type:m})=>`${f} ${m}`),...s?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),s&&e.block("if params != nil {",()=>{for(let f of t.queryParams){let m=d(f.name);e.block(`if params.${m} != nil {`,()=>{e.line(`base.Set(${c.string(f.name)}, ${R(`*params.${m}`,g(f.schema,r))})`)},"}")}},"}"),e.block("call := func(pageParams url.Values) (any, *http.Response, error) {",()=>{e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),e.block("for key, values := range pageParams {",()=>{e.block("for _, value := range values {",()=>{e.line("query.Set(key, value)")},"}")},"}");let f=i.map(({param:m,go:h,type:k})=>`${c.string(m.name)}: ${R(h,k)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${f}})`),e.line("resp, err := send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: authHeaders, Query: query})"),e.block("if err != nil {",()=>{e.line("return nil, nil, err")},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line("return nil, resp, apiErrorFrom(resp, requestURL)")},"}"),e.line("var raw any"),e.block("if err := decodeJSON(resp, &raw); err != nil {",()=>{e.line("return nil, resp, err")},"}"),e.line("return raw, resp, nil")},"}"),e.line("pages := iterPages(call, *op.Pagination, base)")};e.line(`// ${n}Pages iterates ${n} response pages; use with \`for page, err := range\`.`),e.block(`func (c *Client) ${n}Pages(${u}) func(yield func(${o}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${o}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.line(`var page ${o}`),e.block("if err == nil {",()=>{e.line("err = reencode(raw, &page)")},"}"),e.line("return yield(page, err)")},"})")},"}")},"}"),e.blank(),e.line(`// ${n}Items iterates the items of every ${n} page.`),e.block(`func (c *Client) ${n}Items(${u}) func(yield func(${a}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${a}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.block("if err != nil {",()=>{e.line(`var zero ${a}`),e.line("return yield(zero, err)")},"}"),e.line("pageItems, _ := resolvePointer(raw, op.Pagination.Items).([]any)"),e.block("for _, item := range pageItems {",()=>{e.line(`var typed ${a}`),e.block("if err := reencode(item, &typed); err != nil {",()=>{e.line("return yield(typed, err)")},"}"),e.block("if !yield(typed, nil) {",()=>{e.line("return false")},"}")},"}"),e.line("return true")},"})")},"}")},"}"),e.blank()}function ne(e){let t=e.split(`
7
+ import{a as S,b as d}from"./REFX2EKS.js";import{a as C}from"./UKSQ7B5H.js";import{b as H,c as D,d as G,e as K,f as J,g as z,h as Q}from"./NAGDQV7J.js";import"./4PT55VGO.js";import{a as j}from"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{b as A,c as I,d as v,e as L,g as E,h as x,i as B,j as F,k as W,n as _}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var c=new S,b=I.go;function V(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||b.has(e))throw new j(`goPackage "${e}" is not a valid Go package name: use lowercase letters, digits, and underscores, don't start with a digit, and avoid Go keywords.`);return e}function w(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let a=d(o.name),i=2;for(;t.has(a);)a=`${d(o.name)}${i++}`;t.add(a),n.push({op:o,ident:a})}return n}function oe(e){return J(e).map(n=>n.kind==="literal"?c.string(n.value):v(n.name,{style:"camel",reserved:b})).join(" + ")}function X(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,a)=>{let i=`${d(o.description??`server${a+1}`)}URL`;r.has(i)&&(i=`${i}${a+1}`),r.add(i);let s=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} string`),u=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} default: ${c.string(l.default)}`).join(", ");e.line(`// ${i} returns the ${c.string(o.description??o.url)} base URL${u===""?".":` (${u}).`}`),e.block(`func ${i}(${s.join(", ")}) string {`,()=>{e.line(`return ${oe(o)}`)},"}"),e.blank()})}function Y(e,t){let n=z(e,t).map(r=>r.map(o=>o.kind==="apiKey"?`{Scheme: ${c.string(o.scheme)}, Kind: "apiKey", Name: ${c.string(o.name)}, In: ${c.string(o.in)}}`:`{Scheme: ${c.string(o.scheme)}, Kind: ${c.string(o.kind)}}`));if(n.length!==0)return`[][]SecuritySpec{${n.map(r=>`{${r.join(", ")}}`).join(", ")}}`}function Z(e){return`&PaginationSpec{${[`Style: ${c.string(e.style)}`,...e.param!==void 0?[`Param: ${c.string(e.param)}`]:[],...e.nextCursor!==void 0?[`NextCursor: ${c.string(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`HasMore: ${c.string(e.hasMore)}`]:[],...e.limitParam!==void 0?[`LimitParam: ${c.string(e.limitParam)}`]:[],...e.items!==void 0?[`Items: ${c.string(e.items)}`]:[]].join(", ")}}`}function g(e,t="string"){if(B(e)){let n=g(F(e),t);return n.startsWith("*")||n==="any"?n:`*${n}`}switch(e.kind){case"scalar":if(t==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"time.Time";if(e.metadata?.format==="date")return"Date"}return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"array":return`[]${g(e.items,t)}`;case"record":return`map[string]${g(e.value,t)}`;case"ref":return d(e.name);case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float64";case"enum":return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"omit":return d(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ae(e,t,n,r,o){e.doc(d(t),o),e.block(`type ${d(t)} struct {`,()=>{for(let a of n){let i=d(a.name),s=g(a.schema,r),u=`\`json:"${a.name}"\``;a.required||(!s.startsWith("*")&&!s.startsWith("[]")&&!s.startsWith("map[")&&s!=="any"&&(s=`*${s}`),u=`\`json:"${a.name},omitempty"\``),e.line(`${i} ${s} ${u}`)}},"}"),e.blank()}function N(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:a})=>x(a,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=ie(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function ie(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let a=W(o);if(a!==void 0){let s=a.scalar==="string"?"string":"int64";n.doc(d(r),o.description),n.line(`type ${d(r)} ${s}`),n.blank(),n.block("const (",()=>{let u=new Set;a.values.forEach(l=>{let f=A.pascal(String(l))||"Value",m="";for(let k=2;u.has(f+m);k++)m=String(k);u.add(f+m);let h=d(r)+f+m;n.line(`${h} ${d(r)} = ${c.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let s=E(o,e);if(s!==void 0){ae(n,r,s.properties,t,s.description??o.description);continue}}let i=x(o,e);if(i!==void 0){let s=d(r),u=i.cases.map(l=>`${l.value} -> ${d(l.schemaName)}`).join(", ");n.line(`// ${s} is a discriminated union ("${i.property}"): ${u}.`),n.line(`type ${s} = any`),n.blank(),n.line(`// Unmarshal${s} decodes into the member selected by "${i.property}".`),n.block(`func Unmarshal${s}(data []byte) (${s}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${i.property}"\``)},"}"),n.block("if err := json.Unmarshal(data, &probe); err != nil {",()=>{n.line("return nil, err")},"}"),n.line("switch probe.Discriminant {");for(let l of i.cases)n.block(`case ${c.string(l.value)}:`,()=>{n.line(`var value ${d(l.schemaName)}`),n.line("err := json.Unmarshal(data, &value)"),n.line("return value, err")});n.line("}"),n.line("var fallback any"),n.line("err := json.Unmarshal(data, &fallback)"),n.line("return fallback, err")},"}"),n.blank();continue}n.doc(d(r),o.description),n.line(`type ${d(r)} = ${g(o,t)}`),n.blank()}return n.toString()}function R(e,t){if(t==="string")return e;let n=e.startsWith("*")?`(${e})`:e;return t==="time.Time"?`${n}.Format(time.RFC3339)`:t==="Date"?`${n}.Format("2006-01-02")`:t==="int64"?`strconv.FormatInt(${e}, 10)`:t==="float64"?`strconv.FormatFloat(${e}, 'f', -1, 64)`:t==="bool"?`strconv.FormatBool(${e})`:`fmt.Sprint(${e})`}var se=["c","ctx","body","params","out","op"];function T(e,t){let n=L(e.pathParams.map(r=>r.name),{style:"camel",reserved:b,taken:se});return e.pathParams.map((r,o)=>({param:r,go:n[o],type:g(r.schema,t)}))}function le(e,t){let n=new Set;return(e.successResponseHeaders??[]).map(r=>{let o=d(r.name),a=o,i=2;for(;n.has(a);)a=`${o}${i++}`;n.add(a);let s=_(r.schema,t),u={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[s];return{field:a,name:r.name,...u}})}function U(e,t,n,r,o,a=!1){let i=T(t,r),s=t.queryParams.length>0,u=D(t),l=u===void 0?void 0:g(u,r),f=a?le(t,o):[];a&&(e.line(`// ${n}Headers carries the declared response headers of ${n}WithHeaders (nil when absent or unparsable).`),e.block(`type ${n}Headers struct {`,()=>{for(let p of f)e.line(`${p.field} ${p.goType}`)},"}"),e.blank());let m=["ctx context.Context",...i.map(({go:p,type:P})=>`${p} ${P}`),...t.requestBody?[`body ${g(t.requestBody.schema,r)}`]:[],...s?[`params *${n}Params`]:[]],h=G(t),k=a?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:h!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,$=p=>a?l===void 0?`return headers, ${p}`:`return out, headers, ${p}`:l===void 0?`return ${p}`:`return out, ${p}`,M=a?`${n}WithHeaders`:n;e.doc(M,a?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${M}(${m.join(", ")}) ${k} {`,()=>{h===void 0&&l!==void 0&&e.line(`var out ${l}`),a&&e.line(`var headers ${n}Headers`),e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),s&&e.block("if params != nil {",()=>{for(let y of t.queryParams){let O=d(y.name);e.block(`if params.${O} != nil {`,()=>{if(y.schema.kind==="array"){let q=g(y.schema.items,r);e.block(`for _, item := range *params.${O} {`,()=>{e.line(`query.Add(${c.string(y.name)}, ${R("item",q)})`)},"}")}else e.line(`query.Set(${c.string(y.name)}, ${R(`*params.${O}`,g(y.schema,r))})`)},"}")}},"}");let p=i.map(({param:y,go:O,type:q})=>`${c.string(y.name)}: ${R(O,q)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${p}})`),h!==void 0){e.block("open := func(extraHeaders map[string]string) (*http.Response, error) {",()=>{e.line("merged := map[string]string{}"),e.block("for key, value := range authHeaders {",()=>{e.line("merged[key] = value")},"}"),e.block("for key, value := range extraHeaders {",()=>{e.line("merged[key] = value")},"}"),e.line("return send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: merged, Query: query})")},"}"),e.line(`return iterSSE(open, ${h.schema!==void 0&&h.schema.kind!=="unknown"})`);return}let P=["OperationID: op.ID","Method: op.Method","URL: requestURL","Headers: authHeaders","Query: query"];if(t.requestBody&&K(t)?(e.line("contentType, reader, err := toMultipart(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: reader"),P.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: bytes.NewReader(payload)"),P.push(`ContentType: ${c.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${P.join(", ")}})`),e.block("if err != nil {",()=>{e.line($("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line($("apiErrorFrom(resp, requestURL)"))},"}"),a){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line($("err"))},"}");for(let y of f)e.line(`headers.${y.field} = ${y.helper}(resp.Header, ${c.string(y.name)})`);e.line(l===void 0?"return headers, nil":"return out, headers, nil")}else l===void 0?e.line("return decodeJSON(resp, nil)"):(e.block("if err := decodeJSON(resp, &out); err != nil {",()=>{e.line("return out, err")},"}"),e.line("return out, nil"))},"}"),e.blank()}function ee(e,t,n,r,o,a){let i=T(t,r),s=t.queryParams.length>0,u=["ctx context.Context",...i.map(({go:f,type:m})=>`${f} ${m}`),...s?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),s&&e.block("if params != nil {",()=>{for(let f of t.queryParams){let m=d(f.name);e.block(`if params.${m} != nil {`,()=>{e.line(`base.Set(${c.string(f.name)}, ${R(`*params.${m}`,g(f.schema,r))})`)},"}")}},"}"),e.block("call := func(pageParams url.Values) (any, *http.Response, error) {",()=>{e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),e.block("for key, values := range pageParams {",()=>{e.block("for _, value := range values {",()=>{e.line("query.Set(key, value)")},"}")},"}");let f=i.map(({param:m,go:h,type:k})=>`${c.string(m.name)}: ${R(h,k)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${f}})`),e.line("resp, err := send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: authHeaders, Query: query})"),e.block("if err != nil {",()=>{e.line("return nil, nil, err")},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line("return nil, resp, apiErrorFrom(resp, requestURL)")},"}"),e.line("var raw any"),e.block("if err := decodeJSON(resp, &raw); err != nil {",()=>{e.line("return nil, resp, err")},"}"),e.line("return raw, resp, nil")},"}"),e.line("pages := iterPages(call, *op.Pagination, base)")};e.line(`// ${n}Pages iterates ${n} response pages; use with \`for page, err := range\`.`),e.block(`func (c *Client) ${n}Pages(${u}) func(yield func(${o}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${o}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.line(`var page ${o}`),e.block("if err == nil {",()=>{e.line("err = reencode(raw, &page)")},"}"),e.line("return yield(page, err)")},"})")},"}")},"}"),e.blank(),e.line(`// ${n}Items iterates the items of every ${n} page.`),e.block(`func (c *Client) ${n}Items(${u}) func(yield func(${a}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${a}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.block("if err != nil {",()=>{e.line(`var zero ${a}`),e.line("return yield(zero, err)")},"}"),e.line("pageItems, _ := resolvePointer(raw, op.Pagination.Items).([]any)"),e.block("for _, item := range pageItems {",()=>{e.line(`var typed ${a}`),e.block("if err := reencode(item, &typed); err != nil {",()=>{e.line("return yield(typed, err)")},"}"),e.block("if !yield(typed, nil) {",()=>{e.line("return false")},"}")},"}"),e.line("return true")},"})")},"}")},"}"),e.blank()}function ne(e){let t=e.split(`
8
8
  `),n=[],r=!1;for(let o of t)if(!o.startsWith("package ")){if(o.startsWith("import (")){r=!0;continue}if(r){o.startsWith(")")&&(r=!1);continue}o.startsWith("import ")||n.push(o)}return n.join(`
9
9
  `).trim()}var te=["bytes","context","encoding/base64","encoding/json","errors","fmt","io","math/rand","mime/multipart","net/http","net/url","strconv","strings","time"];function re(e,t,n,r,o,a){e.line(ne(N(t,r))),e.blank(),X(e,t),a&&(e.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator go runtime) \u2500\u2500\u2500"),e.line(ne(C)),e.blank()),e.block("type operationMeta struct {",()=>{e.line("ID string"),e.line("Method string"),e.line("Path string"),e.line("Security [][]SecuritySpec"),e.line("Pagination *PaginationSpec")},"}"),e.blank(),e.block("var operations = map[string]operationMeta{",()=>{for(let{op:i,ident:s}of w(t)){let u=i.specName??i.name,l=Y(i,t),f=o.get(s),m=[`ID: ${c.string(u)}`,`Method: ${c.string(i.method.toUpperCase())}`,`Path: ${c.string(i.path)}`,...l!==void 0?[`Security: ${l}`]:[],...f!==void 0?[`Pagination: ${Z(f)}`]:[]];e.line(`${c.string(u)}: {${m.join(", ")}},`)}},"}"),e.blank();for(let{op:i,ident:s}of w(t))i.queryParams.length!==0&&(e.block(`type ${s}Params struct {`,()=>{for(let u of i.queryParams){let l=g(u.schema,r);e.line(`${d(u.name)} ${l.startsWith("*")?l:`*${l}`}`)}},"}"),e.blank());e.doc("Client",`Client for ${t.title} (${t.version}).`),e.block("type Client struct {",()=>{e.line("config Config")},"}"),e.blank(),e.block("func New(config Config) *Client {",()=>{e.block('if config.ServerURL == "" {',()=>{e.line(`config.ServerURL = ${c.string(n.serverUrl??t.serverUrl??"")}`)},"}"),e.line("return &Client{config: config}")},"}"),e.blank();for(let{op:i,ident:s}of w(t)){U(e,i,s,r),G(i)===void 0&&(i.successResponseHeaders?.length??0)>0&&U(e,i,s,r,t,!0);let u=o.get(s);if(u===void 0)continue;let l=D(i),f=l===void 0?"any":g(l,r),m=Q(l,u.items,t);ee(e,i,s,r,f,m===void 0?"any":g(m,r))}}var ze=({model:e,output:t,banner:n,emit:r,pagination:o})=>{let a=new S,i=r.dateType??"string",s=V(r.goPackage),u=new Map;for(let{op:$,ident:M}of w(e)){let p=o?.get($.name)?.spec;p!==void 0&&u.set(M,p)}a.line(`// Code generated by @redocly/client-generator (go) from "${e.title}" ${e.version}. DO NOT EDIT.`),a.line("// Regenerate with `redocly generate-client`. Standard library only \u2014 zero dependencies."),a.line(`package ${s}`),a.blank();let l=r.runtime!=="module",f=l?te:(()=>{let $=new S;re($,e,r,i,u,!1);let M=$.toString();return te.filter(p=>new RegExp(`\\b${p.split("/").pop()}\\.`).test(M))})();a.block("import (",()=>{for(let $ of f)a.line(c.string($))},")"),a.blank(),re(a,e,r,i,u,l);let m={path:t.path.replace(/\.[^.\\/]+$/,".go"),content:a.toString()};if(l)return[m];let h=n.map($=>`// ${$}`).join(`
10
10
  `),k=C.replace(/^package .*$/m,`package ${s}`);return[m,{path:m.path.replace(/[^\\/]+$/,"runtime.go"),content:`${h}
@@ -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"./4OMVSQVK.js";import{a as h}from"./VGBSMXRM.js";import"./PFYPTG4G.js";import"./M3XP3LQ3.js";import"./NEWT5A6S.js";import{e as g,h as p,k as y}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as M}from"node:path";var a=" ";function f(e){return`${y(e)}Schema`}var x=new Map;function u(e,r=x,t=""){return k(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return S(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${f(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return z(e.values);case"union":return E(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return q(e.base,e.keys,r,t)}}function S(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
7
+ import"./NAGDQV7J.js";import{a as h}from"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{e as g,h as p,k as y}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as M}from"node:path";var a=" ";function f(e){return`${y(e)}Schema`}var x=new Map;function u(e,r=x,t=""){return k(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return S(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${f(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return z(e.values);case"union":return E(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return q(e.base,e.keys,r,t)}}function S(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
8
8
  ${e.map((s,i)=>{let d=u(s.schema,r,n),l=s.required?d:`${d}.optional()`,v=i===e.length-1?"":",";return`${n}${c(s.name)}: ${l}${v}`}).join(`
9
9
  `)}
10
10
  ${t}})`}function z(e){return e.every(r=>typeof r=="string")?`z.enum([${e.map(r=>JSON.stringify(r)).join(", ")}])`:`z.union([${e.map(r=>`z.literal(${p(r)})`).join(", ")}])`}function E(e,r,t){let n=e.map(o=>u(o,r,t));return n.length===1?n[0]:`z.union([${n.join(", ")}])`}function q(e,r,t,n){let o=t.get(e);if(o&&o.kind!=="object")return u(m(o,r,t,new Set([e])),t,n);let s=r.map(i=>`${c(i)}: true`).join(", ");return`${f(e)}.omit({ ${s} })`}function m(e,r,t,n){switch(e.kind){case"object":return{...e,properties:e.properties.filter(o=>!r.includes(o.name))};case"union":case"intersection":return{...e,members:e.members.map(o=>m(o,r,t,n))};case"ref":{if(n.has(e.name))return e;let o=t.get(e.name);if(!o)return e;if(o.kind==="object"){let s=r.filter(i=>o.properties.some(d=>d.name===i));return s.length>0?{kind:"omit",base:e.name,keys:s}:e}return m(o,r,t,new Set([...n,e.name]))}default:return e}}function k(e,r){let t=r.metadata;if(!t)return e;let n=e;return r.kind==="scalar"&&r.scalar==="string"&&(t.minLength!==void 0&&(n=`${n}.min(${t.minLength})`),t.maxLength!==void 0&&(n=`${n}.max(${t.maxLength})`),t.pattern!==void 0&&(n=`${n}.regex(new RegExp(${JSON.stringify(t.pattern)}))`)),r.kind==="scalar"&&(r.scalar==="number"||r.scalar==="integer")&&(t.minimum!==void 0&&(n=`${n}.min(${t.minimum})`),t.maximum!==void 0&&(n=`${n}.max(${t.maximum})`),t.exclusiveMinimum!==void 0&&(n=`${n}.gt(${t.exclusiveMinimum})`),t.exclusiveMaximum!==void 0&&(n=`${n}.lt(${t.exclusiveMaximum})`)),r.kind==="array"&&(t.minItems!==void 0&&(n=`${n}.min(${t.minItems})`),t.maxItems!==void 0&&(n=`${n}.max(${t.maxItems})`)),n}function j(e,r){let t=[];for(let n of h(e.services)){if(n.sse!==void 0)continue;let o=n.requestBody,s=o&&o.contentType.toLowerCase().includes("json")?u(o.schema,r,a):void 0,i=n.successResponses.find(l=>l.contentType.toLowerCase().includes("json")),d=i?u(i.schema,r,a):void 0;!s&&!d||t.push({name:n.specName??n.name,request:s,response:d})}return t}function Z(e){let r=e.flatMap(n=>[`${a}${c(n.name)}: {`,...n.request?[`${a}${a}request: z.ZodType;`]:[],...n.response?[`${a}${a}response: z.ZodType;`]:[],`${a}};`]),t=e.map((n,o)=>{let s=[...n.request?[`request: ${n.request}`]:[],...n.response?[`response: ${n.response}`]:[]].join(", "),i=o===e.length-1?"":",";return`${a}${c(n.name)}: { ${s} }${i}`});return["/**"," * Request/response validators by operationId \u2014 powers `zodValidation`, or import one directly."," */","export const operationSchemas: {",...r,"} = {",...t,"};"].join(`
@@ -4,19 +4,19 @@ 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 oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./HKNDR3ZE.js";import{D as X,E as g,F as O,G as Z,H as $,I as C,K as S,M as y,O as w,Q as ee,R as te,S as Je,W as ne,Y as re,_ as se,aa as ie,c as l,p as Y,u as Q,x as We}from"./M3XP3LQ3.js";import{e as J}from"./RFWIIJFG.js";import fe from"node:path";function R(t){return t?t.trim():""}function T(t){let e=R(t.operationId)||R(t.path);return[R(t.ruleId),R(t.severity),R(t.message),e,R(t.target),R(t.schemaPath)].join("")}var F=t=>X(S(t));function Ye(t){return t==="error"?"error":t==="warning"?"warning":"note"}function Qe(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
7
+ import{a as oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./EOS3ZB2L.js";import{H as X,J as Je,K as Z,L as g,M as O,N as ee,O as $,P as C,R as S,T as y,V as w,W as te,X as ne,Y as re,_ as se,aa as ie,c as l,p as Y,u as Q,x as We}from"./OZMIIHFH.js";import{e as J}from"./RFWIIJFG.js";import fe from"node:path";function R(t){return t?t.trim():""}function T(t){let e=R(t.operationId)||R(t.path);return[R(t.ruleId),R(t.severity),R(t.message),e,R(t.target),R(t.schemaPath)].join("")}var F=t=>Z(S(t));function Ye(t){return t==="error"?"error":t==="warning"?"warning":"note"}function Qe(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
8
8
  `)?e:`"${e.replace(/"/g,'""')}"`}function Xe(t){return fe.isAbsolute(t)?fe.relative(process.cwd(),t)||".":t}function Ze(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function et(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function tt(t){let e=[],r=new Map;for(let n of t){let s=T({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 nt(t){let e=tt(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
9
  `}function rt(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(Qe).join(",")).join(`
10
10
  `)}
11
11
  `}function st(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:Ye(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 it(t){return t.findingsBySeverity.error+t.findingsBySeverity.warning+t.findingsBySeverity.info}function ot(t){return t>=500?O:t>=400?$:t>=300?C:t>=200?Z:y}function at(t,e,r){let n=(h,f)=>e?f(h):h,s=h=>h==="error"?n("\u2716",O):h==="warning"?n("\u25B2",$):n("\u25CF",C),i=h=>h==="error"?n("ERROR",O):h==="warning"?n("WARN",$):n("INFO",C),{summary:o,meta:a}=t,c=it(o),p=o.previewFindings.slice(0,r),u=[];if(u.push(n("\u250F\u2501 Drift Report",F)),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}`,O)} ${n(`warning=${o.findingsBySeverity.warning}`,$)} ${n(`info=${o.findingsBySeverity.info}`,C)}`),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(`
12
+ `}function it(t){return t.findingsBySeverity.error+t.findingsBySeverity.warning+t.findingsBySeverity.info}function ot(t){return t>=500?O:t>=400?$:t>=300?C:t>=200?ee:y}function at(t,e,r){let n=(h,f)=>e?f(h):h,s=h=>h==="error"?n("\u2716",O):h==="warning"?n("\u25B2",$):n("\u25CF",C),i=h=>h==="error"?n("ERROR",O):h==="warning"?n("WARN",$):n("INFO",C),{summary:o,meta:a}=t,c=it(o),p=o.previewFindings.slice(0,r),u=[];if(u.push(n("\u250F\u2501 Drift Report",F)),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}`,O)} ${n(`warning=${o.findingsBySeverity.warning}`,$)} ${n(`info=${o.findingsBySeverity.info}`,C)}`),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
13
  `)}
14
14
  `;u.push(""),u.push(n(`Types (${Object.keys(o.problemGroupsByRule).length})`,F));for(let[h,f]of et(o.problemGroupsByRule)){let v=o.findingsByRule[h]??f;u.push(` ${n("\u2022",y)} ${h}: ${f} problems / ${v} findings`)}let m=new Map;for(let h of p)m.has(h.ruleId)||m.set(h.ruleId,[]),m.get(h.ruleId).push(h);let x=Array.from(m.keys()).sort((h,f)=>{let v=(o.problemGroupsByRule[f]??0)-(o.problemGroupsByRule[h]??0);return v!==0?v:h.localeCompare(f)});u.push(""),u.push(n(`Problems by type (showing first ${p.length} of ${o.totalProblemGroups})`,F));let q=0;for(let h of x){let f=m.get(h);if(!f||f.length===0)continue;let v=o.problemGroupsByRule[h]??f.length,ze=o.findingsByRule[h]??v;u.push(""),u.push(`${n("\u25C9",S)} ${n(h,F)} ${n(`(${f.length} problems shown / ${v} total, ${ze} findings)`,y)}`);for(let d of f){q+=1;let U=d.occurrences,De=d.status!==void 0?n(String(d.status),ot(d.status)):n("-",y),Ke=Ze(d.details)??d.path,Ue=d.operationId?` ${n(d.operationId,g)}`:"";if(u.push(`${s(d.severity)} ${i(d.severity)} #${q}${U>1?` ${n(`\xD7${U}`,y)}`:""} ${n("\u2192",y)} ${d.message}`),u.push(` \u21B3 sample exchange=${d.exchangeIndex} ${n(d.method,S)} ${Ke} (${De})${Ue}`),u.push(""),u.push(` ${n(d.url,y)}`),(d.specSource||d.schemaPath||d.dataPath)&&(u.push(""),d.specSource&&u.push(` ${n("spec:",g)} ${n(Xe(d.specSource),S)}`),d.schemaPath&&u.push(` ${n("schemaPath=",g)} ${n(d.schemaPath,g)}`),d.dataPath&&u.push(` ${n("dataPath=",g)} ${n(d.dataPath,S)}`)),d.details)if(u.push(""),d.ruleId==="security-baseline"&&typeof d.details.summary=="string")u.push(` ${n("security:",g)} ${d.details.summary}`);else if(d.ruleId==="owasp-api-top10"&&typeof d.details.summary=="string"){let k=typeof d.details.issueId=="string"?d.details.issueId:null,A=typeof d.details.issueTitle=="string"?d.details.issueTitle:null;u.push(` ${n("owasp:",g)} ${d.details.summary}`),(k||A)&&u.push(` ${n("issue:",g)} ${[k,A].filter(Boolean).join(" - ")}`)}else if(d.ruleId==="schema-consistency"&&typeof d.details.summary=="string"){let k=typeof d.details.path=="string"?d.details.path:null,A=typeof d.details.expected=="string"?d.details.expected:null,G=typeof d.details.actual=="string"?d.details.actual:null,W=typeof d.details.suggestion=="string"?d.details.suggestion:null;if(u.push(` ${n("schema:",g)} ${d.details.summary}`),k&&u.push(` ${n("path:",g)} ${n(k,S)}`),A&&u.push(` ${n("expected:",g)} ${A}`),G&&u.push(` ${n("actual:",g)} ${G}`),W){u.push(` ${n("hint:",g)}`);for(let Ge of W.split(`
15
15
  `))u.push(` ${Ge}`)}}else u.push(` ${n("details:",g)} ${JSON.stringify(d.details)}`);u.push("")}}let P=o.totalProblemGroups-p.length;return P>0?(u[u.length-1]!==""&&u.push(""),u.push(n(`\u2026 ${P} problems omitted from terminal output. Use --format json/csv/sarif for the complete export.`,y))):u[u.length-1]===""&&u.pop(),`${u.join(`
16
16
  `)}
17
17
  `}function Hn(t,e){let r=e.maxFindings??10;switch(e.format){case"json":return nt(t);case"csv":return rt(t);case"sarif":return st(t);case"pretty":return at(t,e.color??!1,r);default:throw new Error(`Unsupported report format: ${e.format}`)}}import{randomUUID as Be}from"node:crypto";function ut(t,e){let r=b(t||"/")||"/",n=b(e.basePath||"/")||"/";return n==="/"?r:r===n?"/":r.startsWith(`${n}/`)?r.slice(n.length)||"/":null}function ct(t,e){return!t.host||!e?!0:t.host===e.toLowerCase()}function dt(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 ge(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]=dt(i))}return r}function lt(t,e){let r=b(e)||"/";for(let n of t){let s=n.pathRegex.exec(r);if(s)return{operation:n,pathParams:ge(n,s)}}return null}function ye(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 lt(i,n);let o=null;for(let a of i)for(let c of a.servers){if(r==="strict-host"&&!ct(c,e.request.host))continue;let p=ut(e.request.path,c);if(!p)continue;let u=a.pathRegex.exec(p);if(!u)continue;let m={score:pt(a,c,r),matched:{operation:a,pathParams:ge(a,u)}};(!o||m.score>o.score)&&(o=m)}return o?.matched??null}var Se=6,ht=2e3,mt=50,ft=5,gt=1e6,yt=/(?:token|api[_-]?key|apikey|password|passwd|secret|authorization|jwt)/i,St=/(?:password|passwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|private[_-]?key|ssn|credit[_-]?card|card[_-]?number|cvv)/i,vt=new Set(["page","limit","offset","cursor","per_page","perpage","size","start","after","before"]),ve=4,wt=ve*2;function Rt(t){return t.length<=wt?"***":`${t.slice(0,ve)}\u2026`}function It(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Pt(t){return typeof t=="string"||typeof t=="number"}function bt(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 xt(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 kt(t){if(!l(t)&&!Array.isArray(t))return[];let e=[],r=[{value:t,path:""}],n=0;for(;r.length>0&&n<ht&&e.length<Se;){let s=r.pop();if(!s)break;if(n+=1,Array.isArray(s.value)){let i=Math.min(s.value.length,mt);for(let o=0;o<i;o+=1){let a=s.value[o];(l(a)||Array.isArray(a))&&r.push({value:a,path:`${s.path}/${o}`})}continue}if(l(s.value))for(let[i,o]of Object.entries(s.value)){let a=`${s.path}/${It(i)}`;if(St.test(i)&&Pt(o)){let c=String(o);if(bt(i)&&xt(o))continue;if(c.length>0&&(e.push(a||"/"),e.length>=Se))break}(l(o)||Array.isArray(o))&&r.push({value:o,path:a})}}return e}function At(t){for(let e of t.keys())if(vt.has(e.toLowerCase()))return!0;return!1}function I(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 Ot(t){let e=[];for(let[r,n]of t.exchange.request.query.entries())if(yt.test(r)&&(e.push({key:r,valuePreview:Rt(n)}),e.length>=ft))break;return e.length===0?[]:[I(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 $t(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"?[]:[I(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 Ct(t){let e=t.exchange.response;if(!e)return[];let r=e.headers["set-cookie"];if(!r)return[];let n=[];for(let s of ue(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(I(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(I(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(I(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 Et(t){let e=t.exchange.response;if(!e||e.bodyJson===void 0)return[];let r=kt(e.bodyJson);return r.length===0?[]:[I(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 qt(t){let e=t.exchange.response;return!e||e.status>=400||t.exchange.request.method!=="GET"?[]:!e.bodyText||e.bodyText.length<gt?[]:At(t.exchange.request.query)?[]:[I(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 M=class{id="owasp-api-top10";analyze(e){return e.matchedOperation?[...Ot(e),...$t(e),...Ct(e),...Et(e),...qt(e)]:[]}};var we=200;function Re(t){return t!==void 0&&t!==""}function Tt(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}function Ft(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}function Mt(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function jt(t){return!t||t==="#"?"":t.startsWith("#")?t.slice(1):t}function N(t){let e=jt(t);return!e||e==="/"?[]:e.split("/").slice(1).map(r=>Ft(r))}function Ie(t,e){return`/${[...N(t),Mt(e)].join("/")}`}function Bt(t,e){let r=N(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(!l(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"?Ie(e,r.missingProperty):t.keyword==="additionalProperties"&&typeof r.additionalProperty=="string"?Ie(e,r.additionalProperty):e}function Lt(t){let e=N(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 _t(t){if(t===void 0)return"[missing]";let e=JSON.stringify(t);return e?e.length>we?`${e.slice(0,we)}\u2026`:e:String(t)}function Ht(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 Vt(t,e,r){let n=t==="request"?"Request":"Response",s=e.params??{},i=Lt(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=Bt(t,n);return{summary:Vt(r,e,n),keyword:e.keyword??null,path:n||"/",expected:Ht(e)??null,actual:_t(s),suggestion:null,params:e.params??{},ajvMessage:e.message??"validation error"}}function Nt(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}}})}}var zt=/^([^[\]]+)\[([^[\]]+)\]$/;function xe(t){let e=t.match(zt);return e?{parameterName:e[1],property:e[2]}:void 0}function Dt(t,e){let r;for(let[n,s]of e){let i=xe(n);i?.parameterName===t&&(r??={},r[i.property]=s)}return r}function Kt(t,e,r){switch(t.in){case"path":return e.matchedOperation?.pathParams[t.name];case"query":{if(t.style==="deepObject")return Dt(t.name,e.exchange.request.query);let n=e.exchange.request.query.getAll(t.name);return n.length===0?void 0:(l(t.schema)?t.schema.type:void 0)==="array"||n.length>1?n:n[0]}case"header":return e.exchange.request.headers[t.name.toLowerCase()];case"cookie":return r[t.name];default:return}}function Ut(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=xe(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))le(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 Gt(t){let e=t.exchange.response;return e!==void 0&&e.status>=400&&e.status<500}function Wt(t,e){let r=t.exchange.response;if(!r)return;let n=String(r.status),s=`${Math.floor(r.status/100)}XX`,i=e.operation.responseBodyContent[n]??e.operation.responseBodyContent[s]??e.operation.responseBodyContent[s.toLowerCase()]??e.operation.responseBodyContent.default;if(i)return V(i,r.contentType)}function Pe(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 j=class{id="schema-consistency";analyze(e){let r=e.matchedOperation;if(!r)return[];let n=[],s=Tt(e.exchange.request.headers.cookie);if(n.push(...Ut(e,r)),!Gt(e)){for(let p of r.operation.requestParameters){if(e.ignoreCookies&&p.in==="cookie")continue;let u=Kt(p,e,s);if(p.required&&u==null){n.push({ruleId:this.id,severity:"error",category:"documentation",message:`Missing required ${p.in} parameter: "${p.name}"`,exchangeIndex:e.exchange.index,operationId:r.operation.operationId,specSource:r.operation.specSource,target:"request"});continue}Nt(p,u,e,n)}let o=e.exchange.request.contentType,a=V(r.operation.requestBodyContent,o),c=Re(e.exchange.request.bodyText);r.operation.requestBodyRequired&&!c&&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"}),a&&c&&H(o)&&(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(...Pe(a,e.exchange.request.bodyJson,e,"request")))}let i=Wt(e,r);if(i&&e.exchange.response&&Re(e.exchange.response.bodyText)){let o=e.exchange.response.contentType;H(o)&&(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(...Pe(i,e.exchange.response.bodyJson,e,"response")))}return n}};function D(t){if(!t)return null;let[e]=t.trim().split(/\s+/,1);return e?e.toLowerCase():null}function Ae(t){return!!t.exchange.request.headers.authorization}function Jt(t,e){return t?t.split(";").map(r=>r.trim()).some(r=>r.startsWith(`${e}=`)):!1}function Yt(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=Jt(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=D(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=D(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 Qt(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=>Yt(t,a));return{requirementIndex:s,satisfied:o.every(a=>a.satisfied),schemeResults:o}});return{satisfied:r.some(n=>n.satisfied),requirements:r}}function Xt(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 ke(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 Zt(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 en(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 tn=/^(?:(?:.+\.)?localhost|127(?:\.\d{1,3}){3}|::1)$/i;function nn(t){let e;try{e=new URL(t.url).hostname}catch{e=t.host?.replace(/:\d+$/,"")}return e?tn.test(e.replace(/^\[|\]$/g,"")):!1}function rn(t){if(t.exchange.request.protocol!=="http:"||!t.exchange.request.protocolKnown||nn(t.exchange.request))return{flag:!1,hasAuthHeader:!1,sensitiveQueryKeys:[]};let e=Ae(t),r=en(t);return{flag:e||r.length>0,hasAuthHeader:e,sensitiveQueryKeys:r}}var B=class{id="security-baseline";analyze(e){if(!e.matchedOperation)return[];let r=[],n=Qt(e);if(n.satisfied){let i=ke(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=Xt(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:Zt(i),failedChecks:i,skippedChecks:ke(n),authorizationScheme:D(e.exchange.request.headers.authorization),hasAuthorizationHeader:Ae(e)}})}let s=rn(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 L=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 K={"undocumented-endpoint":()=>new L,"schema-consistency":()=>new j,"security-baseline":()=>new B,"owasp-api-top10":()=>new M},sn=Object.keys(K),on=["undocumented-endpoint","schema-consistency","security-baseline"];function Oe(t){return!t||t.length===0?on.map(e=>K[e]()):[...new Set(t)].map(e=>{let r=K[e];if(!r)throw new Error(`Unknown rule id: "${e}". Available rules: ${sn.join(", ")}`);return r()})}var Ee=J(We(),1);var qe=J(Je(),1),$e=Ee.default,Ce=qe.default;function an(t,e){return l(t)?e==="request"?t.readOnly===!0:t.writeOnly===!0:!1}function Te(t,e,r,n=new WeakSet){if(!l(t)||n.has(t))return!1;n.add(t);let s=t.properties;return l(s)&&an(s[e],r)?!0:[t.allOf,t.oneOf,t.anyOf].some(i=>Array.isArray(i)&&i.some(o=>Te(o,e,r,n)))}var un=new Set(["items","additionalItems","additionalProperties","unevaluatedItems","unevaluatedProperties","contains","propertyNames","not","if","then","else"]),cn=new Set(["allOf","anyOf","oneOf","prefixItems"]),dn=new Set(["properties","patternProperties","dependentSchemas","$defs","definitions"]);function Fe(t,e,r=new WeakSet){if(!l(t))return t;if(r.has(t))return!0;r.add(t);let n=i=>Fe(i,e,r),s={};for(let[i,o]of Object.entries(t))un.has(i)?s[i]=Array.isArray(o)?o.map(n):n(o):cn.has(i)&&Array.isArray(o)?s[i]=o.map(n):dn.has(i)&&l(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"||!Te(t,i,e))),r.delete(t),s}var E=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 $e(r),this.fallbackAjv=new $e({...r,discriminator:!1}),Ce(this.ajv),Ce(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(l(e)){let o=this.objectSchemaCaches[r??"none"],a=o.get(e);if(a)return a;let c=r?Fe(e,r):e,p=this.compileSchema(c);return o.set(e,p),p}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)}}};var pn=10,Me={info:0,warning:1,error:2};function ln(){return{totalExchanges:0,documentedExchanges:0,undocumentedExchanges:0,skippedExchanges:0,hostCompatibleExchanges:0,findingsBySeverity:{info:0,warning:0,error:0},findingsByRule:{}}}function hn(t,e){t.findingsBySeverity[e.severity]+=1,t.findingsByRule[e.ruleId]=(t.findingsByRule[e.ruleId]??0)+1}function mn(t,e){return{...t,id:Be(),method:e.request.method,url:e.request.url,path:e.request.path,status:e.response?.status}}function fn(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 gn(t,e){if(!e)return;t.operationId||(t.operationId=e.operation.operationId),t.specSource||(t.specSource=e.operation.specSource);let r=t.details??{};if(!l(r)){t.details={operationPathTemplate:e.operation.pathTemplate};return}typeof r.operationPathTemplate!="string"&&(r.operationPathTemplate=e.operation.pathTemplate),t.details=r}function yn(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 Sn(t,e){let r=[];for(let n of t)try{let s=await n.analyze(e);s.length>0&&r.push(...s)}catch(s){w.warn(`Rule "${n.id}" failed to execute: ${s.message}
18
- `)}return r}var je=class t{startedAt=Date.now();runId=Be();previewLimit;rules;schemaValidator=new E;coercingSchemaValidator=new E({coerceTypes:!0});options;counters=ln();findings=[];previewFindings=[];problemGroupsByRule={};problemKeyStats=new Map;totalProblemGroups=0;server;ignoreHeaders;minSeverityRank;specServerHosts;hasHostlessSpecServer;constructor(e,r){this.options=e,this.rules=r,this.server=he(e.server),this.ignoreHeaders=e.ignoreHeaders?pe(e.ignoreHeaders):void 0;let{specServerHosts:n,hasHostlessSpecServer:s}=yn(e.openApiIndex);this.specServerHosts=n,this.hasHostlessSpecServer=s,this.minSeverityRank=Me[e.minSeverity??"info"],this.previewLimit=e.previewFindingsLimit&&e.previewFindingsLimit>0?e.previewFindingsLimit:pn}static create(e){if(e.openApiIndex.loadedOperations===0)throw new Error("No OpenAPI operations available to validate traffic against.");return new t(e,Oe(e.activeRules))}async process(e){this.counters.totalExchanges+=1;let r;if(this.server!==void 0&&(r=me(e.request,this.server),r===void 0))return this.counters.skippedExchanges+=1,[];let n=this.isHostCompatible(e.request.host);n&&(this.counters.hostCompatibleExchanges+=1);let s=ye(this.options.openApiIndex,e,this.options.matchMode,r);s?this.counters.documentedExchanges+=1:this.counters.undocumentedExchanges+=1;let i=await Sn(this.rules,{exchange:e,matchedOperation:s,matchMode:this.options.matchMode,hostCompatibleWithSpecServers:r!==void 0||n,ignoreCookies:this.options.ignoreCookies??!1,ignoreHeaders:this.ignoreHeaders,validateSchema:(a,c,p)=>p?.coerce?this.coercingSchemaValidator.validate(a,c,p?.target):this.schemaValidator.validate(a,c,p?.target)}),o=[];for(let a of i){if(Me[a.severity]<this.minSeverityRank)continue;gn(a,s);let c=mn(a,e);this.findings.push(c),o.push(c),hn(this.counters,a);let p=T({ruleId:a.ruleId,severity:a.severity,message:a.message,operationId:a.operationId,path:e.request.path,target:a.target,schemaPath:a.schemaPath}),u=this.problemKeyStats.get(p);if(u){u.occurrences+=1,u.previewIndex!==null&&(this.previewFindings[u.previewIndex].occurrences=u.occurrences);continue}if(this.totalProblemGroups+=1,this.problemGroupsByRule[a.ruleId]=(this.problemGroupsByRule[a.ruleId]??0)+1,this.previewFindings.length<this.previewLimit){let m=this.previewFindings.length;this.previewFindings.push(fn(a,e)),this.problemKeyStats.set(p,{occurrences:1,previewIndex:m});continue}this.problemKeyStats.set(p,{occurrences:1,previewIndex:null})}return o}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}}};import{stat as vn}from"node:fs/promises";function _(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=ce(r),s=!!(n.host&&!ae(n.host));return{rawUrl:t,protocol:s?n.protocol:void 0,host:s?n.host.toLowerCase():void 0,basePath:b(n.pathname||"/")}}function Le(t){return t?t.startsWith("/")?t:`/${t}`:"/"}var wn=["get","put","post","delete","patch","head","options","trace"],Rn=new Set(["query","header","path","cookie"]);function In(t){return wn.includes(t)}function Pn(t){return Rn.has(t)}function _e(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!l(r))continue;let n=r.in;typeof n!="string"||!Pn(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 He(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(He(n),n);for(let n of e)r.set(He(n),n);return Array.from(r.values())}function Ne(t){let e={};if(!l(t))return e;for(let[r,n]of Object.entries(t))l(n)&&"schema"in n&&(e[r.toLowerCase()]=n.schema);return e}function xn(t){return l(t)?Ne(t.content):{}}function kn(t){if(!l(t))return{};let e={};for(let[r,n]of Object.entries(t))!l(n)||!("content"in n)||(e[r]=Ne(n.content));return e}function An(t,e,r){let n=t??e??r;return!Array.isArray(n)||n.length===0?[_("/")]:n.map(s=>{if(!l(s))return _("/");let i=typeof s.url=="string"?s.url:"/",o=l(s.variables)?s.variables:void 0;return _(i,o)})}function On(t,e,r){return r||`${t.toUpperCase()} ${e}`}function $n(t){try{let e=te(t.parsed);return ee(e)==="oas3"?e:null}catch{return null}}function Ve(t){return Array.isArray(t)?t:void 0}function Cn(t,e){let r,n,s={},i="/",o=[],a;return{Root:{enter(c){r=c.servers,n=c.security;let p=l(c.components)?c.components.securitySchemes:void 0;s=l(p)?p:{}}},Paths:{PathItem:{enter(c,p){i=Le(String(p.key)),o=_e(c.parameters),a=c.servers},Operation:{enter(c,p){let u=String(p.key);if(!In(u))return;let m=bn(o,_e(c.parameters)),x=de(i),q=An(c.servers,a,r),P=c.requestBody,h={operationId:On(u,i,typeof c.operationId=="string"?c.operationId:void 0),method:u,pathTemplate:i,pathRegex:x.regex,pathParams:x.params,pathScore:x.score,servers:q,requestParameters:m,requestBodyContent:xn(P),requestBodyRequired:l(P)&&!!P.required,responseBodyContent:kn(c.responses),security:Ve(c.security)??Ve(n),securitySchemes:s,specSource:t},f=e.get(u)??[];f.push(h),e.set(u,f)}}}}}}function En(t,e,r,n,s){let i=Y(r.extendTypes(Q(e),e),r),o=new Map,a={problems:[],specVersion:e,config:r,visitorsData:{}},c=re([{severity:"warn",ruleId:"drift-index",visitor:Cn(n,s)}],i);se({document:t,rootType:i.Root,normalizedVisitors:c,resolvedRefMap:o,ctx:a})}function qn(t){return`${t.host??""}|${t.basePath}`}function Tn(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=qn(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;w.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 Fn(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 Mn(t){return(await vn(t)).isDirectory()?{specFiles:await oe(t),fromDirectory:!0}:{specFiles:[t],fromDirectory:!1}}async function Rr(t,e){let{specFiles:r,fromDirectory:n}=await Mn(t),s=new Map,i=new ne(e.resolve),o=0;for(let a of r){let c=await i.resolveDocument(null,a,!0);if(c instanceof Error){w.warn(`Failed to load OpenAPI description ${a}: ${c.message}
18
+ `)}return r}var je=class t{startedAt=Date.now();runId=Be();previewLimit;rules;schemaValidator=new E;coercingSchemaValidator=new E({coerceTypes:!0});options;counters=ln();findings=[];previewFindings=[];problemGroupsByRule={};problemKeyStats=new Map;totalProblemGroups=0;server;ignoreHeaders;minSeverityRank;specServerHosts;hasHostlessSpecServer;constructor(e,r){this.options=e,this.rules=r,this.server=he(e.server),this.ignoreHeaders=e.ignoreHeaders?pe(e.ignoreHeaders):void 0;let{specServerHosts:n,hasHostlessSpecServer:s}=yn(e.openApiIndex);this.specServerHosts=n,this.hasHostlessSpecServer=s,this.minSeverityRank=Me[e.minSeverity??"info"],this.previewLimit=e.previewFindingsLimit&&e.previewFindingsLimit>0?e.previewFindingsLimit:pn}static create(e){if(e.openApiIndex.loadedOperations===0)throw new Error("No OpenAPI operations available to validate traffic against.");return new t(e,Oe(e.activeRules))}async process(e){this.counters.totalExchanges+=1;let r;if(this.server!==void 0&&(r=me(e.request,this.server),r===void 0))return this.counters.skippedExchanges+=1,[];let n=this.isHostCompatible(e.request.host);n&&(this.counters.hostCompatibleExchanges+=1);let s=ye(this.options.openApiIndex,e,this.options.matchMode,r);s?this.counters.documentedExchanges+=1:this.counters.undocumentedExchanges+=1;let i=await Sn(this.rules,{exchange:e,matchedOperation:s,matchMode:this.options.matchMode,hostCompatibleWithSpecServers:r!==void 0||n,ignoreCookies:this.options.ignoreCookies??!1,ignoreHeaders:this.ignoreHeaders,validateSchema:(a,c,p)=>p?.coerce?this.coercingSchemaValidator.validate(a,c,p?.target):this.schemaValidator.validate(a,c,p?.target)}),o=[];for(let a of i){if(Me[a.severity]<this.minSeverityRank)continue;gn(a,s);let c=mn(a,e);this.findings.push(c),o.push(c),hn(this.counters,a);let p=T({ruleId:a.ruleId,severity:a.severity,message:a.message,operationId:a.operationId,path:e.request.path,target:a.target,schemaPath:a.schemaPath}),u=this.problemKeyStats.get(p);if(u){u.occurrences+=1,u.previewIndex!==null&&(this.previewFindings[u.previewIndex].occurrences=u.occurrences);continue}if(this.totalProblemGroups+=1,this.problemGroupsByRule[a.ruleId]=(this.problemGroupsByRule[a.ruleId]??0)+1,this.previewFindings.length<this.previewLimit){let m=this.previewFindings.length;this.previewFindings.push(fn(a,e)),this.problemKeyStats.set(p,{occurrences:1,previewIndex:m});continue}this.problemKeyStats.set(p,{occurrences:1,previewIndex:null})}return o}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}}};import{stat as vn}from"node:fs/promises";function _(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=ce(r),s=!!(n.host&&!ae(n.host));return{rawUrl:t,protocol:s?n.protocol:void 0,host:s?n.host.toLowerCase():void 0,basePath:b(n.pathname||"/")}}function Le(t){return t?t.startsWith("/")?t:`/${t}`:"/"}var wn=["get","put","post","delete","patch","head","options","trace"],Rn=new Set(["query","header","path","cookie"]);function In(t){return wn.includes(t)}function Pn(t){return Rn.has(t)}function _e(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!l(r))continue;let n=r.in;typeof n!="string"||!Pn(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 He(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(He(n),n);for(let n of e)r.set(He(n),n);return Array.from(r.values())}function Ne(t){let e={};if(!l(t))return e;for(let[r,n]of Object.entries(t))l(n)&&"schema"in n&&(e[r.toLowerCase()]=n.schema);return e}function xn(t){return l(t)?Ne(t.content):{}}function kn(t){if(!l(t))return{};let e={};for(let[r,n]of Object.entries(t))!l(n)||!("content"in n)||(e[r]=Ne(n.content));return e}function An(t,e,r){let n=t??e??r;return!Array.isArray(n)||n.length===0?[_("/")]:n.map(s=>{if(!l(s))return _("/");let i=typeof s.url=="string"?s.url:"/",o=l(s.variables)?s.variables:void 0;return _(i,o)})}function On(t,e,r){return r||`${t.toUpperCase()} ${e}`}function $n(t){try{let e=ne(t.parsed);return te(e)==="oas3"?e:null}catch{return null}}function Ve(t){return Array.isArray(t)?t:void 0}function Cn(t,e){let r,n,s={},i="/",o=[],a;return{Root:{enter(c){r=c.servers,n=c.security;let p=l(c.components)?c.components.securitySchemes:void 0;s=l(p)?p:{}}},Paths:{PathItem:{enter(c,p){i=Le(String(p.key)),o=_e(c.parameters),a=c.servers},Operation:{enter(c,p){let u=String(p.key);if(!In(u))return;let m=bn(o,_e(c.parameters)),x=de(i),q=An(c.servers,a,r),P=c.requestBody,h={operationId:On(u,i,typeof c.operationId=="string"?c.operationId:void 0),method:u,pathTemplate:i,pathRegex:x.regex,pathParams:x.params,pathScore:x.score,servers:q,requestParameters:m,requestBodyContent:xn(P),requestBodyRequired:l(P)&&!!P.required,responseBodyContent:kn(c.responses),security:Ve(c.security)??Ve(n),securitySchemes:s,specSource:t},f=e.get(u)??[];f.push(h),e.set(u,f)}}}}}}function En(t,e,r,n,s){let i=Y(r.extendTypes(Q(e),e),r),o=new Map,a={problems:[],specVersion:e,config:r,visitorsData:{}},c=re([{severity:"warn",ruleId:"drift-index",visitor:Cn(n,s)}],i);se({document:t,rootType:i.Root,normalizedVisitors:c,resolvedRefMap:o,ctx:a})}function qn(t){return`${t.host??""}|${t.basePath}`}function Tn(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=qn(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;w.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 Fn(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 Mn(t){return(await vn(t)).isDirectory()?{specFiles:await oe(t),fromDirectory:!0}:{specFiles:[t],fromDirectory:!1}}async function Rr(t,e){let{specFiles:r,fromDirectory:n}=await Mn(t),s=new Map,i=new X(e.resolve),o=0;for(let a of r){let c=await i.resolveDocument(null,a,!0);if(c instanceof Error){w.warn(`Failed to load OpenAPI description ${a}: ${c.message}
20
20
  `);continue}let p=$n(c);if(!p){n||w.warn(`Skipping ${a}: not an OpenAPI 3.x description.
21
21
  `);continue}let u;try{let{bundle:m}=await ie({config:e,doc:c,externalRefResolver:i,dereference:!0});u=m}catch(m){w.warn(`Failed to bundle OpenAPI description ${a}: ${m.message}
22
22
  `);continue}o+=1,En(u,p,e,a,s)}return o>1&&Tn(s),Fn(s,o)}function Pr(t){return t.split(",").map(e=>e.trim()).filter(Boolean)}export{Hn as a,je as b,Rr as c,Pr 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{b as D,g as L}from"./4OMVSQVK.js";import{a as h,c as F,d as J,e as U}from"./VGBSMXRM.js";import{a as _,d as G,e as x,f as R,h as K,i as O,j as Q,k as b,l as V,m as z}from"./NB54XRRU.js";import{n as H}from"./HJYFWIVE.js";import{join as Se}from"node:path";var q="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function N(e){return e.filter(t=>t.length>0).join(`
7
+ import{b as D,g as L}from"./NAGDQV7J.js";import{a as h,c as F,d as J,e as U}from"./4PT55VGO.js";import{a as _,d as G,e as x,f as R,h as K,i as O,j as Q,k as b,l as V,m as z}from"./NB54XRRU.js";import{n as H}from"./HJYFWIVE.js";import{join as Se}from"node:path";var q="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function N(e){return e.filter(t=>t.length>0).join(`
8
8
 
9
9
  `)+`
10
10
  `}function v(e){let t=["/**",` * ${O(`${e.title} (v${e.version})`)}`];if(e.description)for(let n of z(O(e.description)))t.push(` * ${n}`.replace(/ +$/,""));return t.push(" */"),t.join(`
@@ -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{la as e}from"./M3XP3LQ3.js";var t=class extends Error{};function o(r){throw new e(r)}export{t as a,o as b};
7
+ import{la as e}from"./OZMIIHFH.js";var t=class extends Error{};function o(r){throw new e(r)}export{t as a,o as b};
@@ -4,5 +4,5 @@ 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{c}from"./M3XP3LQ3.js";import{open as C,readdir as N,stat as P}from"node:fs/promises";import d from"node:path";var $=new Set([".yaml",".yml",".json"]);async function D(e){let n=[];async function t(r){let o=await N(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=d.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&$.has(d.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function _(e,n=4096){let t=await C(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function M(e){return d.resolve(process.cwd(),e)}async function K(e){let n=await P(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await N(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=d.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var k="drift.local",O=`http://${k}`;function u(e){return e===k}var U=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),J=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],R=`
7
+ import{c}from"./OZMIIHFH.js";import{open as C,readdir as N,stat as P}from"node:fs/promises";import d from"node:path";var $=new Set([".yaml",".yml",".json"]);async function D(e){let n=[];async function t(r){let o=await N(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=d.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&$.has(d.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function _(e,n=4096){let t=await C(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function M(e){return d.resolve(process.cwd(),e)}async function K(e){let n=await P(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await N(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=d.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var k="drift.local",O=`http://${k}`;function u(e){return e===k}var U=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),J=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],R=`
8
8
  `;function Y(e){return e.split(R)}function g(e,n,t){let r=n.toLowerCase(),o=e[r];if(o===void 0){e[r]=t;return}e[r]=r==="set-cookie"?`${o}${R}${t}`:`${o},${t}`}function p(e){if(!c(e)&&!Array.isArray(e))return{};let n={};if(Array.isArray(e)){for(let t of e){if(!c(t))continue;let{name:r,value:o}=t;typeof r=="string"&&o!==void 0&&g(n,r,String(o))}return n}for(let[t,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){for(let o of r)g(n,t,String(o));continue}g(n,t,String(r))}return n}function f(e){try{return new URL(e)}catch{return new URL(e,O)}}function m(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function L(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(e){let n=[],t=0,r=e.startsWith("/")?e:`/${e}`,s=m(r).split("/").map(i=>{if(!i)return"";let a=i.match(/^\{([^}]+)\}$/);return a?(n.push(a[1]),"([^/]+)"):(t+=2,L(i))}).join("/");return{regex:new RegExp(`^${s||"/"}$`),params:n,score:t}}function l(e,n){if(n&&A(e))try{return JSON.parse(n)}catch{return}}function E(e){return e?e.split(";")[0]?.trim().toLowerCase()??"":""}function A(e){let n=E(e);return n==="application/json"||n.endsWith("+json")}function Q(e,n){let t=E(n);if(!t)return e["application/json"]??e["*/*"];if(e[t]!==void 0)return e[t];let[r,o]=t.split("/");if(r&&o){let s=`${r}/*`;if(e[s]!==void 0)return e[s]}return e["*/*"]}function Z(e){let n=new Set,t=[];for(let r of e){let o=r.trim().toLowerCase();o.length!==0&&(o.endsWith("*")?t.push(o.slice(0,-1)):n.add(o))}return{names:n,prefixes:t}}function v(e,n){let t=e.toLowerCase();return t.startsWith(":")||U.has(t)||J.some(r=>t.startsWith(r))?!0:n?n.names.has(t)||n.prefixes.some(r=>t.startsWith(r)):!1}import{createReadStream as q}from"node:fs";import{readFile as B}from"node:fs/promises";import{createInterface as F}from"node:readline";function I(e){if(e!=null){if(typeof e=="string")return e;if(Buffer.isBuffer(e))return e.toString("utf8");if(c(e)||Array.isArray(e))try{return JSON.stringify(e)}catch{return String(e)}return String(e)}}function se(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);if(Number.isFinite(n))return n}}function H(e,n){if(e!=null){if(n==="base64"&&typeof e=="string")try{return Buffer.from(e,"base64").toString("utf8")}catch{return e}return I(e)}}function ae(e,n,t){let r=e.method?.toUpperCase(),o=e.url;if(!r||!o)return null;let s=p(e.requestHeaders),i=f(o);if(u(i.host)&&s.host)try{i=new URL(`${i.protocol}//${s.host}${i.pathname}${i.search}`)}catch{i=f(o)}let a=e.requestContentType??s["content-type"],y=H(e.requestBody),T={method:r,url:i.toString(),path:i.pathname,query:i.searchParams,protocol:i.protocol,protocolKnown:e.schemeKnown??/^https?:\/\//i.test(o),host:u(i.host)?void 0:i.host||void 0,headers:s,contentType:a,bodyText:y,bodyJson:l(a,y)},h,x=e.responseStatus;if(x!==void 0){let w=p(e.responseHeaders),S=e.responseContentType??w["content-type"],b=H(e.responseBody);h={status:x,statusText:e.responseStatusText,headers:w,contentType:S,bodyText:b,bodyJson:l(S,b)}}return{index:n,source:t,startedAt:e.startedAt,request:T,response:h,raw:e.raw}}async function*ce(e){let n=q(e,{encoding:"utf8"}),t=F({input:n,crlfDelay:1/0});for await(let r of t){let o=r.trim();if(o)try{let s=JSON.parse(o);c(s)&&(yield s)}catch{}}}async function*ue(e,n){let t=await B(e,"utf8"),r=JSON.parse(t);if(n)for(let o of n.split("."))r=c(r)?r[o]:void 0;if(Array.isArray(r))for(let o of r)c(o)&&(yield o)}function fe(e){return p(e)["content-type"]}function ge(e){return e?.replace(/\/+$/,"")||void 0}function z(e,n){if(!n||n==="/")return e||"/";if(e===n)return"/";if(e.startsWith(`${n}/`))return e.slice(n.length)||"/"}function me(e,n){if(n.startsWith("/"))return z(e.path,n);let t=f(n.includes("://")?n:`http://${n}`);if(!(u(t.host)||e.host!==void 0&&e.host.toLowerCase()!==t.host))return z(e.path,m(t.pathname))}export{D as a,_ as b,M as c,K as d,u as e,Y as f,f as g,m as h,V as i,E as j,A as k,Q as l,Z as m,v as n,I as o,se as p,H as q,ae as r,ce as s,ue as t,fe as u,ge as v,me as w};