@redocly/cli 2.66.1 → 2.67.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 (125) hide show
  1. package/lib/chunks/{PYSE2LAG.js → 2AJDP47K.js} +1 -1
  2. package/lib/chunks/{7NPQH3V7.js → 3HSHTOK2.js} +1 -1
  3. package/lib/chunks/{F7K3O6UM.js → 3SPC2VZI.js} +1 -1
  4. package/lib/chunks/{K4IZRPJV.js → 4JI4GT6B.js} +35 -35
  5. package/lib/chunks/{CK2FG2DD.js → 6BJRKKAU.js} +1 -1
  6. package/lib/chunks/{JZV7OYQZ.js → 7WOMNRDU.js} +1 -1
  7. package/lib/chunks/{ULKOLYWY.js → 7YY5ECWE.js} +1 -1
  8. package/lib/chunks/{SDGM5YBT.js → A3NSKGWO.js} +1 -1
  9. package/lib/chunks/{4ABWBH3W.js → AENSGZDZ.js} +1 -1
  10. package/lib/chunks/{TPBJSMIK.js → AL7PXK7F.js} +1 -1
  11. package/lib/chunks/{B4Z2Z4FS.js → BUQQJCMF.js} +1 -1
  12. package/lib/chunks/{TLDUEX6A.js → BYO4KBZG.js} +1 -1
  13. package/lib/chunks/{LR6VKQFM.js → CCZY5XJV.js} +2 -2
  14. package/lib/chunks/{VAPT4FUS.js → D4U2LEEI.js} +1 -1
  15. package/lib/chunks/{GLUPJCQU.js → D5A4WCOD.js} +1 -1
  16. package/lib/chunks/{LJTGHAPA.js → DQZXJA6Q.js} +1 -1
  17. package/lib/chunks/{FXCLUZIF.js → DTPYQUHR.js} +13 -13
  18. package/lib/chunks/{U7SJFXVW.js → EDKRUI6D.js} +1 -1
  19. package/lib/chunks/{WFZEGGBA.js → EOCKJNES.js} +1 -1
  20. package/lib/chunks/{LSFJCPZH.js → EPVPJTXN.js} +1 -1
  21. package/lib/chunks/{TOBKCE6P.js → F77DQGVI.js} +1 -1
  22. package/lib/chunks/{T23ZPTN4.js → F7DLPPNU.js} +1 -1
  23. package/lib/chunks/{ROLEKKAB.js → G67BALR7.js} +1 -1
  24. package/lib/chunks/{RALPAYEE.js → GP5VOB7R.js} +1 -1
  25. package/lib/chunks/{POIQ4MUQ.js → GU34RIUR.js} +1 -1
  26. package/lib/chunks/{L3SH4LDY.js → H3CWVIT3.js} +1 -1
  27. package/lib/chunks/{ON2YZD5C.js → HET452FN.js} +1 -1
  28. package/lib/chunks/{HXPCC4OG.js → HG5B2AKP.js} +1 -1
  29. package/lib/chunks/{NUBOB7QM.js → HPYQF7FO.js} +2 -2
  30. package/lib/chunks/{KOEA2NZG.js → HQTUYG5X.js} +2 -2
  31. package/lib/chunks/{M37DUXGN.js → HU6QTMHN.js} +1 -1
  32. package/lib/chunks/{IAAYM25M.js → IHFKHD4E.js} +1 -1
  33. package/lib/chunks/{NT6J6VMM.js → IRF3OXDB.js} +1 -1
  34. package/lib/chunks/{OYDBXGWA.js → IZVG6IUS.js} +1 -1
  35. package/lib/chunks/{UJN4HIWM.js → J32G7NQF.js} +1 -1
  36. package/lib/chunks/{AONBK2JI.js → JH6AK2RM.js} +1 -1
  37. package/lib/chunks/{RO4A6LSK.js → JMYCFXFO.js} +1 -1
  38. package/lib/chunks/{6KF4UNVM.js → KA43H34P.js} +1 -1
  39. package/lib/chunks/{R5MSEDNK.js → KHQEQ7SW.js} +1 -1
  40. package/lib/chunks/{ZSK75GT2.js → KIFTQ6KG.js} +1 -1
  41. package/lib/chunks/{JGSM4NRA.js → KMGFC2JR.js} +1 -1
  42. package/lib/chunks/{5EHUKG3I.js → LEPQDSTM.js} +1 -1
  43. package/lib/chunks/{UYF7BOSD.js → LZUYKJND.js} +1 -1
  44. package/lib/chunks/{PGX27JIK.js → M5FZMXND.js} +1 -1
  45. package/lib/chunks/{NHOPECWM.js → MLLRCWW6.js} +1 -1
  46. package/lib/chunks/{FOXOWXSK.js → OKWRNBEY.js} +1 -1
  47. package/lib/chunks/{JFWECYV5.js → OLVAP7AA.js} +1 -1
  48. package/lib/chunks/{CVCE3TMJ.js → OUNJECS6.js} +1 -1
  49. package/lib/chunks/{6JHVGOS4.js → PNADRNVV.js} +1 -1
  50. package/lib/chunks/{NFCO7FU3.js → QPNNEO3Y.js} +1 -1
  51. package/lib/chunks/{FP63LRP5.js → QT45SNBU.js} +1 -1
  52. package/lib/chunks/{46YO7ZAG.js → RIJ5NQKJ.js} +1 -1
  53. package/lib/chunks/{IVWO724G.js → RV4QSDBS.js} +1 -1
  54. package/lib/chunks/{ARBQ5CUR.js → SR776DY3.js} +1 -1
  55. package/lib/chunks/{QMIJ4HMG.js → TO7JCTX3.js} +1 -1
  56. package/lib/chunks/{DRSH6QBU.js → UNWO4KGQ.js} +1 -1
  57. package/lib/chunks/{YY44N7JX.js → VEVZJC25.js} +1 -1
  58. package/lib/chunks/{AZPQQ3GI.js → VJQCED3T.js} +1 -1
  59. package/lib/chunks/{FHDBQIEB.js → WFKHK77N.js} +1 -1
  60. package/lib/chunks/{36DQZK3T.js → WH5ELPJC.js} +1 -1
  61. package/lib/chunks/{STYLK3WI.js → WHI5PM5X.js} +1 -1
  62. package/lib/chunks/{YCJL4ZHF.js → WJLUIDSE.js} +1 -1
  63. package/lib/chunks/{M3VAMERP.js → XZIAEGVZ.js} +1 -1
  64. package/lib/chunks/{JZPKVDJA.js → XZNJU67S.js} +1 -1
  65. package/lib/chunks/{LIDTATJI.js → Y5OFK6NL.js} +1 -1
  66. package/lib/chunks/{GG6HRP6Y.js → YIXIZB5W.js} +1 -1
  67. package/lib/chunks/{OMDMN4SS.js → YQYR6TIT.js} +1 -1
  68. package/lib/chunks/YUHXZXUL.js +34 -0
  69. package/lib/chunks/{KTZA5BVG.js → ZLAHBPRQ.js} +1 -1
  70. package/lib/chunks/{USAJ5FBD.js → ZMV5LF7Y.js} +1 -1
  71. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  72. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  73. package/lib/eject-assets/generators/cli/index.ts +2 -2
  74. package/lib/eject-assets/generators/cli/render.ts +1 -1
  75. package/lib/eject-assets/generators/go/client.ts +1 -1
  76. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  77. package/lib/eject-assets/generators/go/index.ts +2 -2
  78. package/lib/eject-assets/generators/go/models.ts +1 -1
  79. package/lib/eject-assets/generators/go/naming.ts +1 -1
  80. package/lib/eject-assets/generators/go/operations.ts +1 -1
  81. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  82. package/lib/eject-assets/generators/go/types.ts +1 -1
  83. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  84. package/lib/eject-assets/generators/mock/index.ts +2 -2
  85. package/lib/eject-assets/generators/mock/render.ts +1 -1
  86. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  87. package/lib/eject-assets/generators/mock/values.ts +1 -1
  88. package/lib/eject-assets/generators/php/client.ts +1 -1
  89. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  90. package/lib/eject-assets/generators/php/index.ts +2 -2
  91. package/lib/eject-assets/generators/php/models.ts +1 -1
  92. package/lib/eject-assets/generators/php/naming.ts +1 -1
  93. package/lib/eject-assets/generators/php/operations.ts +1 -1
  94. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  95. package/lib/eject-assets/generators/php/types.ts +1 -1
  96. package/lib/eject-assets/generators/python/client.ts +1 -1
  97. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  98. package/lib/eject-assets/generators/python/index.ts +2 -2
  99. package/lib/eject-assets/generators/python/models.ts +1 -1
  100. package/lib/eject-assets/generators/python/naming.ts +1 -1
  101. package/lib/eject-assets/generators/python/operations.ts +1 -1
  102. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  103. package/lib/eject-assets/generators/python/types.ts +1 -1
  104. package/lib/eject-assets/generators/swr/index.ts +2 -2
  105. package/lib/eject-assets/generators/swr/render.ts +1 -1
  106. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  107. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  108. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  109. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  110. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  111. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  112. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  113. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  114. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  115. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  116. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  117. package/lib/eject-assets/generators/typescript/operations.ts +1 -1
  118. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  119. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  120. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  121. package/lib/eject-assets/generators/zod/index.ts +2 -2
  122. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  123. package/lib/index.js +5 -5
  124. package/package.json +1 -1
  125. package/lib/chunks/MSJZTIMR.js +0 -34
@@ -4,16 +4,16 @@ 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 ee,b as te,f as ne,g as E,h as re}from"./LR6VKQFM.js";import{a as y}from"./WZXA5XPB.js";import{Aa as Z,P as W,V,c as x,ia as b,ka as Q,r as v,ra as Y,s as H,ta as T,u as J}from"./K4IZRPJV.js";import{b as A,c as G,k as D}from"./LD5MEXEL.js";import{mkdir as ct,readFile as ut,writeFile as dt}from"node:fs/promises";import{dirname as ke,parse as ft,resolve as R,sep as pt}from"node:path";function M(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./SDGM5YBT.js").then(t=>({run:t.tanstackQueryGenerator(e)}))}}var U={outputMode:"it always emits one self-contained file",runtime:"the runtime is always embedded in the generated file",argsStyle:"inputs follow the target language's own idiom",importExt:"the generated file has no relative imports"},I={typescript:{load:()=>import("./T23ZPTN4.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./ARBQ5CUR.js").then(e=>({run:e.zodGenerator}))},transformers:{requires:["typescript"],dateTypes:["Date"],load:()=>import("./IULINGO6.js").then(e=>({run:e.transformersGenerator}))},"tanstack-query":M("react"),"tanstack-query-vue":M("vue"),"tanstack-query-svelte":M("svelte"),"tanstack-query-solid":M("solid"),swr:{requires:["typescript"],errorModes:["throw"],load:()=>import("./LIDTATJI.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./NT6J6VMM.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./CVCE3TMJ.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:U,load:()=>import("./R5MSEDNK.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:U,load:()=>import("./WFZEGGBA.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:U,load:()=>import("./TPBJSMIK.js").then(e=>({run:e.phpGenerator,sample:e.phpSample,docs:e.phpDocs}))}};function oe(e,t,n,r){let s=new Set(e);t.goPackage!==void 0&&!s.has("go")&&b.warn(`generate-client: goPackage is ignored \u2014 it declares the Go package clause, and no selected generator uses it (add --generator go).
8
- `),t.telemetry==="on"&&!s.has("typescript")&&b.warn(`generate-client: telemetry is ignored \u2014 the typescript generator writes the telemetry module, and it is not selected (add --generator typescript).
9
- `);let o=t.errorMode??"throw",i=t.dateType??"string";for(let a of e){let c=n.get(a);if(!c)throw new y(`Unknown generator: ${a}`);for(let d of c.requires??[])if(!s.has(d)){let f=[...new Set([d,...e])].map(m=>`--generator ${m}`).join(" ");throw new y(`The "${a}" generator requires the "${d}" generator. Add it, e.g. ${f}.`)}if(c.errorModes&&!c.errorModes.includes(o))throw new y(`The "${a}" generator does not support --error-mode "${o}" (supported: ${c.errorModes.join(", ")}).`);if(c.dateTypes&&!c.dateTypes.includes(i))throw new y(`The "${a}" generator requires --date-type ${c.dateTypes.join(" or ")} (got "${i}") so the runtime values match the generated types.`);let u={...t,outputMode:r};for(let[d,f]of Object.entries(c.notApplicable??{}))u[d]!==void 0&&b.warn(`generate-client: the "${a}" generator ignores ${d} \u2014 ${f}.
10
- `)}}function se(e,t,n){let r=new Map;for(let s of e){let o=t.get(s)?.options,i=n?.[s];if(o===void 0){i!==void 0&&b.warn(`generate-client: the "${s}" generator declares no options, so client.options.${s} is ignored.
11
- `),r.set(s,{});continue}r.set(s,ve(s,o,i))}return r}function ve(e,t,n){if(n!==void 0&&!x(n))throw new y(`The "${e}" generator's options must be a map of option names to values.`);let r=n??{},s=Object.keys(t.properties);if(t.additionalProperties!==!0){for(let i of Object.keys(r))if(!s.includes(i))throw new y(`The "${e}" generator got an unknown option "${i}". Declared options: ${s.join(", ")||"(none)"}.`)}for(let i of t.required??[])if(r[i]===void 0)throw new y(`The "${e}" generator requires the "${i}" option.`);let o={...r};for(let[i,a]of Object.entries(t.properties)){if(o[i]===void 0){a.default!==void 0&&(o[i]=a.default);continue}let c=Se(a,o[i]);if(c!==void 0)throw new y(`The "${e}" generator's "${i}" ${c}.`)}return o}function Se(e,t){if("enum"in e)return e.enum.includes(t)?void 0:`must be one of: ${e.enum.join(", ")}`;if(e.type==="array"){let n=e.items.type;return Array.isArray(t)&&t.every(r=>typeof r===n)?void 0:`must be an array of ${n}`}return typeof t===e.type?void 0:`must be a ${e.type}`}import{isAbsolute as xe,resolve as qe}from"node:path";import{pathToFileURL as Pe}from"node:url";var Oe=function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,s,o,i){return r?t?".jsx":".js":s&&(!o||!i)?n:s+o+"."+i.toLowerCase()+"js"}):e};async function ae(e,t={}){let n=new Map;for(let a of t.customGenerators??[])ce(n,a);let r=[];for(let a of e)r.push(await ie(a,n,t.configDir));let s=[],o=new Set,i=async a=>{if(!(s.includes(a)||o.has(a))){o.add(a);for(let c of n.get(a).requires??[])(n.has(c)||c in I)&&await i(await ie(c,n,t.configDir));o.delete(a),s.push(a)}};for(let a of r)await i(a);return{selected:s,registry:n}}async function ie(e,t,n){if(t.has(e))return e;let r=I[e];if(r!==void 0){let{load:o,...i}=r;return t.set(e,{...i,...await o()}),e}if(e==="sdk")throw new y('The "sdk" generator is now named "typescript". Update the `generators` list or the --generator flag.');let s=await je(e,n??process.cwd());return ce(t,s),s.name}function ce(e,t){if(!x(t)||typeof t.name!="string"||t.name===""||typeof t.run!="function")throw new y("Invalid custom generator: expected an object with a non-empty string `name` and a `run` function (build one with `defineGenerator`).");if(e.has(t.name))throw new y(`Generator name "${t.name}" collides with an existing generator. Rename the custom generator.`);if(t.requiresGenerator!==void 0){let n=re(E,t.requiresGenerator);if(n===void 0)throw new y(`Generator "${t.name}" declares requiresGenerator "${t.requiresGenerator}", which is not a range we read. Use ^1.2.0, ~1.2.0, >=1.2.0, or an exact version.`);if(!n)throw new y(`Generator "${t.name}" needs @redocly/client-generator ${t.requiresGenerator}; this CLI ships ${E}. Upgrade @redocly/cli if the generator is newer, or update the generator \u2014 \`redocly eject-generator <name> --update\` for an ejected file, or upgrade its package.`)}t.name in I&&b.warn(`generate-client: custom generator "${t.name}" takes over the built-in generator of the same name.
12
- `),e.set(t.name,{run:t.run,sample:t.sample,docs:t.docs,notApplicable:t.notApplicable,options:t.options,requires:t.requires,errorModes:t.errorModes,dateTypes:t.dateTypes})}async function je(e,t){if(J(e))throw new y(`Remote generator modules are not supported \u2014 use a local path or a package name. Got: ${e}`);let n=e.startsWith(".")||xe(e),r=n?Pe(qe(t,e)).href:e;if(n&&e.endsWith(".ts")&&!process.features.typescript)throw new y(`Generator "${e}" is TypeScript, which this Node cannot run directly \u2014 use Node 22.18, 23.6, or newer.`);let s;try{s=await import(Oe(r))}catch(i){throw new y(`Could not load generator "${e}": ${i.message}`)}let o=s.default??s.generator;if(o===void 0)throw new y(`Generator module "${e}" must export a generator (a default export or a \`generator\` export built with \`defineGenerator\`).`);return o}function fe(e){let t=new Set,n=new Set,r=new Map;for(let l of e.securitySchemes){let h=C(l.key,t,n);h!==l.key&&(r.set(l.key,h),L("security scheme",l.key,h,de(l.key,t)),l.key=h)}let s=new Set(ne()),o=new Set(s),i=new Set,a=new Map;for(let l of e.schemas){let h=C(l.name,o,i);h!==l.name&&(a.set(l.name,h),L("schema",l.name,h,de(l.name,s)),l.name=h)}let c=l=>a.get(l)??ue(l),u=l=>r.get(l)??ue(l);for(let l of e.schemas)$(l.schema,c);let d=new Set(o),f=new Set,m=new Set;for(let l of e.services)for(let h of l.operations){let p=m.has(h.name);m.add(h.name);let g=h.name,P=C(h.name,d,f);if(P!==h.name){let j=p?{kind:"duplicate-operation-id"}:s.has(g)?{kind:"reserved"}:o.has(g)?{kind:"schema-collision"}:{kind:"unusable"};L("operation",g,P,j),h.specName=h.name,h.name=P}Ne(h,c),h.security=h.security.map(j=>j.map(u))}}function C(e,t,n){let r=G(e),s=r,o=2;for(;t.has(s)||n.has(D(s));)s=`${r}_${o++}`;return t.add(s),n.add(D(s)),s}function pe(e){for(let t of e.schemas)if(!A(t.name))throw B("schema",t.name);for(let t of e.securitySchemes)if(!A(t.key))throw B("security scheme",t.key);for(let t of e.services)for(let n of t.operations)if(!A(n.name))throw B("operation",n.name)}function B(e,t){return new Error(`Internal error: ${e} name ${JSON.stringify(t)} is not a safe identifier after sanitization.`)}function ue(e){return G(e)}function L(e,t,n,r){let s=JSON.stringify(t),o=JSON.stringify(n),i=r.kind==="duplicate-operation-id"?`two operations share the operationId ${s}; the second is emitted as ${o} \u2014 give each operation a unique operationId to control its method name`:r.kind==="schema-collision"?`${e} ${s} collides with the schema of the same name, so it is emitted as ${o} \u2014 rename the operation or the schema in the description to control its name`:r.kind==="reserved"?`${e} ${s} is a name a generated client already declares, so it is emitted as ${o} \u2014 the reserved set spans every target language, so one schema keeps one name across the SDKs you generate`:`${e} ${s} is not a usable identifier, so it is emitted as ${o}`;b.warn(`generate-client: ${i}.
13
- `)}function de(e,t){return t.has(e)?{kind:"reserved"}:{kind:"unusable"}}function $(e,t){switch(e.kind){case"ref":e.name=t(e.name);break;case"omit":e.base=t(e.base);break;case"array":$(e.items,t);break;case"record":$(e.value,t);break;case"object":for(let n of e.properties)$(n.schema,t);break;case"union":for(let n of e.members)$(n,t);if(e.discriminator)for(let n of e.discriminator.mapping)n.schemaName=t(n.schemaName);break;case"intersection":for(let n of e.members)$(n,t);break}}function Ne(e,t){for(let n of e.pathParams)$(n.schema,t);for(let n of e.queryParams)$(n.schema,t);for(let n of e.headerParams)$(n.schema,t);for(let n of e.cookieParams)$(n.schema,t);e.requestBody&&$(e.requestBody.schema,t);for(let n of[...e.successResponses,...e.errorResponses])$(n.schema,t),n.itemSchema&&$(n.itemSchema,t)}var Ae=["get","post","put","delete","patch","head","options"];function me(e,t){if(!t.startsWith("#/"))throw new y(`External $ref not supported: ${t}`);let n=t.slice(2).split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~")),r=e;for(let s of n){if(!x(r)&&!Array.isArray(r))throw new y(`Cannot resolve $ref: ${t}`);r=r[s]}if(r===void 0)throw new y(`Cannot resolve $ref: ${t}`);return r}function S(e,t){return v(t)?me(e,t.$ref):t}function N(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Me(e){let t=e,n={};return typeof t.minimum=="number"&&(n.minimum=t.minimum),typeof t.maximum=="number"&&(n.maximum=t.maximum),typeof t.exclusiveMinimum=="number"?n.exclusiveMinimum=t.exclusiveMinimum:t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(n.exclusiveMinimum=t.minimum,delete n.minimum),typeof t.exclusiveMaximum=="number"?n.exclusiveMaximum=t.exclusiveMaximum:t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(n.exclusiveMaximum=t.maximum,delete n.maximum),typeof t.minLength=="number"&&(n.minLength=t.minLength),typeof t.maxLength=="number"&&(n.maxLength=t.maxLength),typeof t.pattern=="string"&&(n.pattern=t.pattern),typeof t.minItems=="number"&&(n.minItems=t.minItems),typeof t.maxItems=="number"&&(n.maxItems=t.maxItems),t.uniqueItems===!0&&(n.uniqueItems=!0),typeof t.format=="string"&&(n.format=t.format),t.deprecated===!0&&(n.deprecated=!0),t.example!==void 0?n.example=t.example:Array.isArray(t.examples)&&t.examples.length>0&&(n.example=t.examples[0]),t.default!==void 0&&(n.default=t.default),Object.keys(n).length>0?n:void 0}function Ie(e,t){let n=e.discriminator;if(!n||typeof n.propertyName!="string")return;let r=[];if(n.mapping)for(let[s,o]of Object.entries(n.mapping))r.push({value:s,schemaName:N(o)});else for(let s of t)if(v(s)){let o=N(s.$ref);r.push({value:o,schemaName:o})}if(r.length!==0)return{propertyName:n.propertyName,mapping:r}}function k(e,t){return t?{...e,metadata:t}:e}function z(e,t){return e?t?{...e,...t}:e:t}function Re(e){return e?e.url.replace(/\{([^{}]+)\}/g,(t,n)=>e.variables?.[n]?.default??t):""}function he(e){let t=e.info?.title??"Api",n=e.info?.version??"0.0.0",r=e.info?.description,s=Re(e.servers?.[0]),o=(e.servers??[]).map(d=>({url:d.url,description:d.description,variables:Object.entries(d.variables??{}).map(([f,m])=>({name:f,default:m.default,description:m.description}))})),i=Be(e),a=Ue(e),c=Le(e,a),u={title:t,version:n,description:r,serverUrl:s,servers:o,services:c,schemas:i,securitySchemes:a};return fe(u),Te(c,i),pe(u),u}function Te(e,t){let n=new Map(t.map(r=>[r.name,r.schema]));for(let r of e)for(let s of r.operations)s.requestBody&&(s.requestBody.schema=Ge(s.requestBody.schema,n))}function Ee(e){let t=e.filter(n=>n.kind!=="unknown");return t.length>0?t:[{kind:"unknown"}]}function Ge(e,t){if(e.kind==="ref"){let n=De(e,t,new Set);return n.length>0?{kind:"omit",base:e.name,keys:n}:e}if(e.kind==="object"){let n=e.properties.filter(r=>!r.readOnly);return n.length===e.properties.length?e:{...e,properties:n}}return e}function De(e,t,n){let r=[],s=o=>{if(o.kind==="ref"){if(n.has(o.name))return;n.add(o.name);let i=t.get(o.name);i&&s(i)}else if(o.kind==="object")for(let i of o.properties)i.readOnly&&!r.includes(i.name)&&r.push(i.name);else if(o.kind==="intersection")for(let i of o.members)s(i)};return s(e),r}function Ue(e){let t=e.components?.securitySchemes;if(!t)return[];let n=[];for(let[r,s]of Object.entries(t)){let o=S(e,s),i=o.type;i==="oauth2"||i==="openIdConnect"?n.push({kind:"bearer",key:r}):i==="http"&&(o.scheme??"").toLowerCase()==="bearer"?n.push({kind:"bearer",key:r}):i==="http"&&(o.scheme??"").toLowerCase()==="basic"?n.push({kind:"basic",key:r}):i==="apiKey"&&o.in==="header"&&typeof o.name=="string"?n.push({kind:"apiKeyHeader",key:r,headerName:o.name}):i==="apiKey"&&o.in==="query"&&typeof o.name=="string"?n.push({kind:"apiKeyQuery",key:r,paramName:o.name}):i==="apiKey"&&o.in==="cookie"&&typeof o.name=="string"&&(b.warn(`generate-client: security scheme "${r}" sends its credential in the Cookie header, which browsers ignore \u2014 cookie auth works only in server-side clients.
14
- `),n.push({kind:"apiKeyCookie",key:r,cookieName:o.name}))}return n}function Ce(e,t,n){let r=e.security??t.security;if(!r)return[];let s=[];for(let o of r){let i=Object.keys(o);i.length!==0&&i.every(a=>n.has(a))&&s.push([...new Set(i)])}return s}function Be(e){let t=e.components?.schemas;return t?Object.entries(t).map(([n,r])=>{if(v(r)){let o=me(e,r.$ref);return{name:n,schema:q(o,`components.schemas.${n}`,e),description:o.description}}let s=q(r,`components.schemas.${n}`,e);return{name:n,schema:s,description:r.description}}):[]}function Le(e,t){let n=new Set(t.map(i=>i.key)),r=[],s=new Set;for(let[i,a]of Object.entries(e.paths??{})){if(!a)continue;let c=S(e,a),u=(c.parameters??[]).map(d=>ye(S(e,d),`paths.${i}.parameters`,e));for(let d of Ae){let f=c[d];f&&(r.push({method:d,path:i,operation:f,pathLevelParams:u}),f.operationId&&s.add(f.operationId))}}return[{name:"Default",operations:r.map(i=>{let a=i.operation.operationId??_e(ze(i.method,i.path),s);return Fe(i.method,i.path,i.operation,a,i.pathLevelParams,e,n)})}]}function ze(e,t){let n=t.split("/").filter(Boolean).map(r=>Ke(r.replace(/[{}]/g,"")));return`${e}${n.join("")}`}function Ke(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function _e(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}${r++}`;return t.add(n),n}function Fe(e,t,n,r,s,o,i){let a=(n.parameters??[]).map(w=>ye(S(o,w),`paths.${t}.${e}.parameters`,o)),c=new Set,u=[];for(let w of a)c.add(`${w.in}:${w.name}`),u.push(w);for(let w of s)c.has(`${w.in}:${w.name}`)||u.push(w);let d=u.filter(w=>w.in==="path"),f=u.filter(w=>w.in==="query"),m=u.filter(w=>w.in==="header"),l=u.filter(w=>w.in==="cookie"),h=n.requestBody?He(S(o,n.requestBody),`${e} ${t}`,o):void 0,{successResponses:p,successResponseHeaders:g}=Je(n,t,o),P=Ve(n,t,o),j=Ce(n,o,i),F=n["x-redoclyPagination"],X=Xe(p);return{name:r,method:e,path:t,summary:n.summary,description:n.description,pathParams:d,queryParams:f,headerParams:m,cookieParams:l,requestBody:h,successResponses:p,...g===void 0?{}:{successResponseHeaders:g},errorResponses:P,security:j,tags:Array.isArray(n.tags)?n.tags.filter(w=>typeof w=="string"):[],...F!==void 0?{paginationExtension:F}:{},...X===void 0?{}:{sse:X}}}function Xe(e){let t=e.find(s=>s.contentType.split(";")[0].trim().toLowerCase()==="text/event-stream");if(t===void 0)return;let n=t.itemSchema&&t.itemSchema.kind!=="unknown"?t.itemSchema:t.schema.kind!=="unknown"?t.schema:void 0;if(n===void 0)return{dataKind:"text"};let r=n.kind==="object"||n.kind==="ref"||n.kind==="array"||n.kind==="record"||n.kind==="union"||n.kind==="intersection";return{eventSchema:n,dataKind:r?"json":"text"}}function ye(e,t,n){if(!e.in)throw new y(`Parameter ${e.name} at ${t} is missing "in"`);if(!["path","query","header","cookie"].includes(e.in))throw new y(`Unsupported parameter location "${e.in}" for ${e.name} at ${t}`);let r=O(e.schema,`${t}.${e.name}`,n);e.deprecated===!0&&(r={...r,metadata:z(r.metadata,{deprecated:!0})});let s={name:e.name,in:e.in,schema:r,required:!!e.required,description:e.description};if(s.in==="query"){let o=e;(o.style==="form"||o.style==="spaceDelimited"||o.style==="pipeDelimited"||o.style==="deepObject")&&(s.style=o.style),typeof o.explode=="boolean"&&(s.explode=o.explode),typeof o.allowReserved=="boolean"&&(s.allowReserved=o.allowReserved)}return s}function He(e,t,n){let r=e.content??{},s=r["application/json"]??r["application/merge-patch+json"]??r["application/x-www-form-urlencoded"]??r["multipart/form-data"]??Object.values(r)[0];if(!s)return;let o=Object.keys(r).find(a=>r[a]===s),i=O(s.schema,`${t}.requestBody`,n);return{contentType:o,schema:i,required:!!e.required,description:e.description}}function Je(e,t,n){let r=e.responses??{},s=Object.keys(r).filter(m=>/^2\d\d$/.test(m));s.length===0&&(r["2XX"]?s.push("2XX"):r.default&&s.push("default"));let o=s[0];if(!o)return{successResponses:[]};let i=r[o];if(!i)return{successResponses:[]};let a=S(n,i),c=We(a.headers,`paths.${t}.response.${o}`,n),u=a.content;if(!u)return{successResponses:[],...c===void 0?{}:{successResponseHeaders:c}};let d=o==="default"||o==="2XX"?o:Number(o),f=[];for(let[m,l]of Object.entries(u)){let h=O(l.schema,`paths.${t}.response.${o}.${m}`,n),p=l.itemSchema,g=p!==void 0?O(p,`paths.${t}.response.${o}.${m}.itemSchema`,n):void 0;f.push({contentType:m,schema:h,status:d,...g===void 0?{}:{itemSchema:g}})}return{successResponses:f,...c===void 0?{}:{successResponseHeaders:c}}}function We(e,t,n){if(!e)return;let r=[];for(let[s,o]of Object.entries(e)){let i=S(n,o),a={name:s.toLowerCase(),schema:O(i.schema===void 0?void 0:S(n,i.schema),`${t}.headers.${s}`,n)};i.required===!0&&(a.required=!0),r.push(a)}return r.length>0?r:void 0}function Ve(e,t,n){let r=e.responses??{},s=Object.keys(r).filter(a=>/^([45]\d\d|4XX|5XX)$/.test(a));Object.keys(r).some(a=>/^(2\d\d|2XX)$/.test(a))&&r.default&&s.push("default");let i=[];for(let a of s){let c=r[a];if(!c)continue;let d=S(n,c).content;if(!d)continue;let f=a==="default"||a==="4XX"||a==="5XX"?a:Number(a);for(let[m,l]of Object.entries(d)){let h=O(l.schema,`paths.${t}.response.${a}.${m}`,n);i.push({contentType:m,schema:h,status:f})}}return i}function O(e,t,n){return e===void 0||typeof e=="boolean"?{kind:"unknown"}:v(e)?{kind:"ref",name:N(e.$ref)}:q(e,t,n)}function q(e,t,n){let r=Me(e),s=e.oneOf??e.anyOf;if(s){let a=s.map((d,f)=>v(d)?{kind:"ref",name:N(d.$ref)}:q(d,`${t}.[${f}]`,n)),c=Ee(a);if(c.length===1&&c.length<a.length){let d=c[0];return{...d,description:d.description??e.description,metadata:z(r,d.metadata)}}let u=Ie(e,s);return k({kind:"union",members:c,discriminator:u,description:e.description},r)}if(e.allOf){let a=e.allOf.map((u,d)=>v(u)?{kind:"ref",name:N(u.$ref)}:q(u,`${t}.allOf[${d}]`,n)),c=le(e,t,n);if(c.length>0&&a.unshift({kind:"object",properties:c}),a.length===1){let u=a[0];return{...u,description:u.description??e.description,metadata:z(r,u.metadata)}}return k({kind:"intersection",members:a,description:e.description},r)}let o=e.type;if(Array.isArray(o)){let a=o.filter(d=>d!=="null"),c=o.includes("null"),u=a.map(d=>{let f={...e,type:d};if(Array.isArray(f.enum)){let m=f.enum.filter(l=>l!==null);f.enum=m.length>0?m:void 0}return q(f,t,n)});return c&&u.push({kind:"null"}),u.length===1?u[0]:k({kind:"union",members:u,description:e.description},r)}if(e.nullable)return{kind:"union",members:[q({...e,nullable:void 0},t,n),{kind:"null"}],description:e.description};if(e.const!==void 0){let a=e.const;if(typeof a!="string"&&typeof a!="number"&&typeof a!="boolean")throw new y(`Unsupported const value at ${t}: ${JSON.stringify(a)}`);return k({kind:"literal",value:a,description:e.description},r)}if(e.enum){let a=e.enum,c=a.filter(m=>m!==null),u=c.length!==a.length;if(c.length===0)return k({kind:"null",description:e.description},r);let d=Qe(c,t),f=d==="boolean"?{kind:"scalar",scalar:"boolean",description:e.description}:{kind:"enum",values:c,scalar:d,description:e.description};return k(u?{kind:"union",members:[f,{kind:"null"}],description:e.description}:f,r)}let i=o;if(i==="null")return k({kind:"null",description:e.description},r);if(i==="array"){let a=e.items,c=O(a,`${t}.items`,n);return k({kind:"array",items:c,description:e.description},r)}if(i==="object"||e.properties||e.additionalProperties){let a=le(e,t,n),c=e.additionalProperties;if(a.length===0&&c!==!1){let u=O(c,`${t}.additionalProperties`,n);return k({kind:"record",value:u,description:e.description},r)}return k({kind:"object",properties:a,description:e.description},r)}return k(i==="string"||i==="number"||i==="integer"||i==="boolean"?{kind:"scalar",scalar:i,description:e.description}:{kind:"unknown",description:e.description},r)}function Qe(e,t){let n=!1,r=!1,s=!1;for(let o of e)if(typeof o=="string")n=!0;else if(typeof o=="number")r=!0;else if(typeof o=="boolean")s=!0;else throw new y(`Unsupported enum value type at ${t}: ${JSON.stringify(o)}`);return n&&!r&&!s?"string":r&&!n&&!s?"number":s&&!n&&!r?"boolean":"string"}function Ye(e){return!(e.openapi??"").startsWith("3.0")}function le(e,t,n){let r=e.properties??{},s=new Set(e.required??[]),o=Ye(n);return Object.entries(r).map(([i,a])=>{let c=a.readOnly===!0;c&&v(a)&&!o&&b.warn(`generate-client: "${i}" declares readOnly beside a $ref, which OpenAPI ${n.openapi} ignores \u2014 the property stays in request bodies. Inline the schema, wrap the $ref in allOf, or move the description to OpenAPI 3.1.
15
- `);let u=c&&(o||!v(a));return{name:i,schema:O(a,`${t}.${i}`,n),required:s.has(i),description:a.description,...u?{readOnly:!0}:{}}})}function ge(e){let t=K(e),n={...t};delete n.swagger,delete n.host,delete n.basePath,delete n.schemes,delete n.definitions,delete n.securityDefinitions,delete n.consumes,delete n.produces,delete n.parameters,delete n.responses,n.openapi="3.0.3";let r=Ze(t);return r&&(n.servers=r),n.components=et(t),n.paths=ot(t.paths??{},t.consumes??void 0,t.produces??void 0),n}function Ze(e){let t=e.host,n=e.basePath??"",r=(e.schemes??["https"])[0]??"https";if(t)return[{url:`${r}://${t}${n}`}]}function et(e){let t={};e.definitions&&(t.schemas=e.definitions),e.parameters&&(t.parameters=Object.fromEntries(Object.entries(e.parameters).map(([r,s])=>[r,_(s)]))),e.responses&&(t.responses=be(e.responses,void 0));let n=e.securityDefinitions;if(n){let r={};for(let[s,o]of Object.entries(n))r[s]=tt(o);t.securitySchemes=r}return t}function tt(e){switch(e.type){case"basic":return{type:"http",scheme:"basic"};case"apiKey":return{type:"apiKey",name:e.name,in:e.in};case"oauth2":{let t=e.flow==="accessCode"?"authorizationCode":e.flow==="application"?"clientCredentials":e.flow,n={scopes:e.scopes??{}};return e.authorizationUrl&&(n.authorizationUrl=e.authorizationUrl),e.tokenUrl&&(n.tokenUrl=e.tokenUrl),{type:"oauth2",flows:{[t]:n}}}default:return e}}function K(e){if(Array.isArray(e))return e.map(K);if(x(e)){let t={};for(let[n,r]of Object.entries(e))n==="$ref"&&typeof r=="string"?t.$ref=r.replace("#/definitions/","#/components/schemas/").replace("#/parameters/","#/components/parameters/").replace("#/responses/","#/components/responses/"):t[n]=K(r);return t}return e}var nt="application/json",rt="application/json",we=new Set(["name","in","required","description","deprecated","allowEmptyValue","collectionFormat"]);function ot(e,t,n){let r={};for(let[s,o]of Object.entries(e)){let i=o,a={};for(let[c,u]of Object.entries(i)){if(c==="parameters"&&Array.isArray(u)){a.parameters=u.map(_);continue}if(!st(c)){a[c]=u;continue}a[c]=it(u,t,n)}r[s]=a}return r}function st(e){return["get","put","post","delete","options","head","patch"].includes(e.toLowerCase())}function it(e,t,n){let r=e.consumes??t,s=e.produces??n,o=e.parameters??[],i=o.find(f=>f.in==="body"),a=o.filter(f=>f.in==="formData"),c=o.filter(f=>f.in!=="body"&&f.in!=="formData").map(_),u={...e,parameters:c};delete u.consumes,delete u.produces;let d=r?.[0]??nt;if(i)u.requestBody={required:!!i.required,content:{[d]:{schema:i.schema}}};else if(a.length>0){let f={},m=[];for(let p of a)f[p.name]=at(p),p.required&&m.push(p.name);let l={type:"object",properties:f};m.length>0&&(l.required=m);let h=r?.find(p=>p==="multipart/form-data")??r?.[0]??"application/x-www-form-urlencoded";u.requestBody={required:m.length>0,content:{[h]:{schema:l}}}}return e.responses&&(u.responses=be(e.responses,s)),u}function _(e){if(e.$ref!==void 0||e.in==="body"||e.in==="formData")return e;let t={},n={};for(let[r,s]of Object.entries(e))we.has(r)?t[r]=s:n[r]=s;if(t.schema=n,delete t.collectionFormat,e.in==="query"&&n.type==="array"){let r=e.collectionFormat??"csv";r!=="multi"&&(t.style=r==="ssv"?"spaceDelimited":r==="pipes"?"pipeDelimited":"form",t.explode=!1)}return t}function at(e){let t={};for(let[n,r]of Object.entries(e))we.has(n)||(t[n]=r);return t}function be(e,t){let n=t?.[0]??rt,r={};for(let[s,o]of Object.entries(e)){let i=o;if(i.schema===void 0){r[s]=i;continue}let{schema:a,...c}=i;r[s]={...c,content:{[n]:{schema:a}}}}return r}async function $e(e,t){let n=t??await T({}),r=await Y({ref:e,config:n}),s=await T({rules:{struct:"error"}}),o=await Z({externalRefResolver:new V,document:r.bundle,config:s}),i=[...r.problems,...o].filter(c=>c.severity==="error");if(i.length>0){let c=i.map(u=>`- ${u.message} (at ${u.location?.[0]?.pointer??e})`).join(`
16
- `);throw new Error(`The API description has ${i.length} error(s):
17
- ${c}`)}let a=r.bundle.parsed;return{document:a,version:Q(a)}}var lt=["Generated by @redocly/client-generator \u2014 do not edit by hand.","Source: OpenAPI description. Re-run `redocly generate-client` to update."];function mt(e,t){let n=[],r=new Set,s=R(ke(t.outputPath)),{dir:o,name:i,ext:a}=ft(t.outputPath),c={path:t.outputPath,dir:o,stem:i,ext:a},u=lt,d=!1;for(let f of t.generators){let m=t.registry.get(f),l={model:e,output:c,banner:u,outputMode:t.outputMode,emit:t.emit,pagination:t.pagination,selected:t.generators,options:t.generatorOptions?.get(f)??{}},h;try{t.emit.docs===!0&&m.docs!==void 0?(h=[...m.run(l),...m.docs(l)],d=!0):h=m.run(l)}catch(p){let g=p instanceof Error?p.message:String(p);throw new Error(`Generator "${f}" failed: ${g}`)}if(!Array.isArray(h)||h.some(p=>typeof p?.path!="string"||p.path===""||typeof p.content!="string"))throw new Error(`Generator "${f}" failed: run() must return an array of { path, content } files.`);for(let p of h){let g=R(s,p.path);if(g!==s&&!g.startsWith(s+pt))throw new Error(`Generator "${f}" failed: file path escapes the output directory: ${p.path}`);if(r.has(g))throw new Error(`Generator conflict: ${p.path} already emitted by an earlier generator`);r.add(g),n.push({path:g,content:p.content})}}return t.emit.docs===!0&&!d&&b.warn(`generate-client: docs is on, but no selected generator writes documentation (${t.generators.join(", ")}).
18
- `),n}function ht(e){for(let t of e.services)for(let n of t.operations){let r=new Set,s=new Set;for(let o of[...n.pathParams,...n.queryParams,...n.headerParams,...n.cookieParams])r.has(o.name)&&s.add(o.name),r.add(o.name);s.size!==0&&b.warn(`generate-client: operation "${n.specName??n.name}" uses ${[...s].map(o=>`"${o}"`).join(", ")} in more than one parameter location. Every SDK sends both, and the SDKs whose methods take one argument per parameter give the later one a suffixed name \u2014 rename it in the description to choose the name yourself.
19
- `)}}function yt(e,t,n,r,s,o,i){let a=[],c=new Set;for(let u of ee(t.services)){let d=gt(e,u.path,u.method);if(c.has(d))continue;c.add(d);let f=r.map(m=>s.get(m)?.sample?.(u,{model:t,emit:n,outputPath:o,pagination:i})).filter(m=>m!==void 0);f.length>0&&a.push({target:d,update:{"x-codeSamples":f}})}if(a.length!==0)return W({overlay:"1.0.0",info:{title:`Code samples for ${t.title}`,version:t.version},actions:a})}function gt(e,t,n){let r=i=>`['${i.replaceAll("\\","\\\\").replaceAll("'","\\'")}']`,s=e.paths?.[t];return`${v(s)&&s.$ref.startsWith("#/")?"$"+s.$ref.slice(2).split("/").map(H).map(r).join(""):`$.paths${r(t)}`}.${n}`}async function nn(e){if(e.output.split(/[\\/]/).some(p=>p==="undefined"||p==="null"))throw new Error(`output path "${e.output}" contains a literal "undefined" or "null" segment \u2014 this looks like an interpolation bug in the caller`);if(e.setup&&/^[a-z][a-z0-9+.-]+:/i.test(e.setup))throw new y(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let t=R(e.output),{document:n,version:r}=await $e(e.api,e.config),s=r==="oas2"?ge(n):n,o=he(s);ht(o);let i;if(e.setup){let{bakeSetup:p}=await import("./CQMMUWIJ.js"),g=R(e.configDir??process.cwd(),e.setup);i=p(await ut(g,"utf-8"))}let a=e.generators?.length?e.generators:["typescript"],{selected:c,registry:u}=await ae(a,{customGenerators:e.customGenerators,configDir:e.configDir}),d=te(o,e.pagination),f={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,telemetry:e.telemetry,setup:i,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:d,docs:e.docs,docsFrontmatter:e.docsFrontmatter};oe(c,f,u,e.outputMode);let m=se(c,u,e.options),l=mt(o,{outputPath:t,outputMode:e.outputMode??"single",emit:f,pagination:d,generators:c,generatorOptions:m,registry:u});if(e.codeSamples===!0){let p=yt(n,o,f,c,u,t,d);p!==void 0&&l.push({path:t.replace(/\.[^.]+$/,".code-samples.yaml"),content:p})}let h=[];for(let p of l)await ct(ke(p.path),{recursive:!0}),await dt(p.path,p.content,"utf-8"),h.push({path:p.path,bytes:Buffer.byteLength(p.content,"utf-8")});return{outputPath:t,bytes:h.reduce((p,g)=>p+g.bytes,0),files:h}}export{I as a,oe as b,mt as c,nn as d};
7
+ import{a as ee,b as te,f as ne,g as E,h as re}from"./CCZY5XJV.js";import{a as y}from"./WZXA5XPB.js";import{Aa as Z,P as W,V,c as x,ia as b,ka as Q,r as S,ra as Y,s as H,ta as T,u as J}from"./4JI4GT6B.js";import{b as A,c as G,k as D}from"./LD5MEXEL.js";import{mkdir as ct,readFile as ut,writeFile as dt}from"node:fs/promises";import{dirname as ke,parse as ft,resolve as R,sep as pt}from"node:path";function M(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./A3NSKGWO.js").then(t=>({run:t.tanstackQueryGenerator(e)}))}}var U={outputMode:"it always emits one self-contained file",runtime:"the runtime is always embedded in the generated file",argsStyle:"inputs follow the target language's own idiom",importExt:"the generated file has no relative imports"},I={typescript:{load:()=>import("./F7DLPPNU.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./SR776DY3.js").then(e=>({run:e.zodGenerator}))},transformers:{requires:["typescript"],dateTypes:["Date"],load:()=>import("./IULINGO6.js").then(e=>({run:e.transformersGenerator}))},"tanstack-query":M("react"),"tanstack-query-vue":M("vue"),"tanstack-query-svelte":M("svelte"),"tanstack-query-solid":M("solid"),swr:{requires:["typescript"],errorModes:["throw"],load:()=>import("./Y5OFK6NL.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./IRF3OXDB.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./OUNJECS6.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:U,load:()=>import("./KHQEQ7SW.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:U,load:()=>import("./EOCKJNES.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:U,load:()=>import("./AL7PXK7F.js").then(e=>({run:e.phpGenerator,sample:e.phpSample,docs:e.phpDocs}))}};function oe(e,t,n,r){let o=new Set(e);t.goPackage!==void 0&&!o.has("go")&&b.warn(`generate-client: goPackage is ignored \u2014 it declares the Go package clause, and no selected generator uses it (add --generator go).
8
+ `),t.telemetry==="on"&&!o.has("typescript")&&b.warn(`generate-client: telemetry is ignored \u2014 the typescript generator writes the telemetry module, and it is not selected (add --generator typescript).
9
+ `);let s=t.errorMode??"throw",i=t.dateType??"string";for(let a of e){let c=n.get(a);if(!c)throw new y(`Unknown generator: ${a}`);for(let d of c.requires??[])if(!o.has(d)){let f=[...new Set([d,...e])].map(m=>`--generator ${m}`).join(" ");throw new y(`The "${a}" generator requires the "${d}" generator. Add it, e.g. ${f}.`)}if(c.errorModes&&!c.errorModes.includes(s))throw new y(`The "${a}" generator does not support --error-mode "${s}" (supported: ${c.errorModes.join(", ")}).`);if(c.dateTypes&&!c.dateTypes.includes(i))throw new y(`The "${a}" generator requires --date-type ${c.dateTypes.join(" or ")} (got "${i}") so the runtime values match the generated types.`);let u={...t,outputMode:r};for(let[d,f]of Object.entries(c.notApplicable??{}))u[d]!==void 0&&b.warn(`generate-client: the "${a}" generator ignores ${d} \u2014 ${f}.
10
+ `)}}function se(e,t,n){let r=new Map;for(let o of e){let s=t.get(o)?.options,i=n?.[o];if(s===void 0){i!==void 0&&b.warn(`generate-client: the "${o}" generator declares no options, so client.options.${o} is ignored.
11
+ `),r.set(o,{});continue}r.set(o,Se(o,s,i))}return r}function Se(e,t,n){if(n!==void 0&&!x(n))throw new y(`The "${e}" generator's options must be a map of option names to values.`);let r=n??{},o=Object.keys(t.properties);if(t.additionalProperties!==!0){for(let i of Object.keys(r))if(!o.includes(i))throw new y(`The "${e}" generator got an unknown option "${i}". Declared options: ${o.join(", ")||"(none)"}.`)}for(let i of t.required??[])if(r[i]===void 0)throw new y(`The "${e}" generator requires the "${i}" option.`);let s={...r};for(let[i,a]of Object.entries(t.properties)){if(s[i]===void 0){a.default!==void 0&&(s[i]=a.default);continue}let c=ve(a,s[i]);if(c!==void 0)throw new y(`The "${e}" generator's "${i}" ${c}.`)}return s}function ve(e,t){if("enum"in e)return e.enum.includes(t)?void 0:`must be one of: ${e.enum.join(", ")}`;if(e.type==="array"){let n=e.items.type;return Array.isArray(t)&&t.every(r=>typeof r===n)?void 0:`must be an array of ${n}`}return typeof t===e.type?void 0:`must be a ${e.type}`}import{isAbsolute as xe,resolve as qe}from"node:path";import{pathToFileURL as Pe}from"node:url";var Oe=function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,o,s,i){return r?t?".jsx":".js":o&&(!s||!i)?n:o+s+"."+i.toLowerCase()+"js"}):e};async function ae(e,t={}){let n=new Map;for(let a of t.customGenerators??[])ce(n,a);let r=[];for(let a of e)r.push(await ie(a,n,t.configDir));let o=[],s=new Set,i=async a=>{if(!(o.includes(a)||s.has(a))){s.add(a);for(let c of n.get(a).requires??[])(n.has(c)||c in I)&&await i(await ie(c,n,t.configDir));s.delete(a),o.push(a)}};for(let a of r)await i(a);return{selected:o,registry:n}}async function ie(e,t,n){if(t.has(e))return e;let r=I[e];if(r!==void 0){let{load:s,...i}=r;return t.set(e,{...i,...await s()}),e}if(e==="sdk")throw new y('The "sdk" generator is now named "typescript". Update the `generators` list or the --generator flag.');let o=await je(e,n??process.cwd());return ce(t,o),o.name}function ce(e,t){if(!x(t)||typeof t.name!="string"||t.name===""||typeof t.run!="function")throw new y("Invalid custom generator: expected an object with a non-empty string `name` and a `run` function (build one with `defineGenerator`).");if(e.has(t.name))throw new y(`Generator name "${t.name}" collides with an existing generator. Rename the custom generator.`);if(t.requiresGenerator!==void 0){let n=re(E,t.requiresGenerator);if(n===void 0)throw new y(`Generator "${t.name}" declares requiresGenerator "${t.requiresGenerator}", which is not a range we read. Use ^1.2.0, ~1.2.0, >=1.2.0, or an exact version.`);if(!n)throw new y(`Generator "${t.name}" needs @redocly/client-generator ${t.requiresGenerator}; this CLI ships ${E}. Upgrade @redocly/cli if the generator is newer, or update the generator \u2014 \`redocly eject-generator <name> --update\` for an ejected file, or upgrade its package.`)}t.name in I&&b.warn(`generate-client: custom generator "${t.name}" takes over the built-in generator of the same name.
12
+ `),e.set(t.name,{run:t.run,sample:t.sample,docs:t.docs,notApplicable:t.notApplicable,options:t.options,requires:t.requires,errorModes:t.errorModes,dateTypes:t.dateTypes})}async function je(e,t){if(J(e))throw new y(`Remote generator modules are not supported \u2014 use a local path or a package name. Got: ${e}`);let n=e.startsWith(".")||xe(e),r=n?Pe(qe(t,e)).href:e;if(n&&e.endsWith(".ts")&&!process.features.typescript)throw new y(`Generator "${e}" is TypeScript, which this Node cannot run directly \u2014 use Node 22.18, 23.6, or newer.`);let o;try{o=await import(Oe(r))}catch(i){throw new y(`Could not load generator "${e}": ${i.message}`)}let s=o.default??o.generator;if(s===void 0)throw new y(`Generator module "${e}" must export a generator (a default export or a \`generator\` export built with \`defineGenerator\`).`);return s}function fe(e){let t=new Set,n=new Set,r=new Map;for(let l of e.securitySchemes){let h=C(l.key,t,n);h!==l.key&&(r.set(l.key,h),L("security scheme",l.key,h,de(l.key,t)),l.key=h)}let o=new Set(ne()),s=new Set(o),i=new Set,a=new Map;for(let l of e.schemas){let h=C(l.name,s,i);h!==l.name&&(a.set(l.name,h),L("schema",l.name,h,de(l.name,o)),l.name=h)}let c=l=>a.get(l)??ue(l),u=l=>r.get(l)??ue(l);for(let l of e.schemas)$(l.schema,c);let d=new Set(s),f=new Set,m=new Set;for(let l of e.services)for(let h of l.operations){let p=m.has(h.name);m.add(h.name);let g=h.name,P=C(h.name,d,f);if(P!==h.name){let j=p?{kind:"duplicate-operation-id"}:o.has(g)?{kind:"reserved"}:s.has(g)?{kind:"schema-collision"}:{kind:"unusable"};L("operation",g,P,j),h.specName=h.name,h.name=P}Ne(h,c),h.security=h.security.map(j=>j.map(u))}}function C(e,t,n){let r=G(e),o=r,s=2;for(;t.has(o)||n.has(D(o));)o=`${r}_${s++}`;return t.add(o),n.add(D(o)),o}function pe(e){for(let t of e.schemas)if(!A(t.name))throw B("schema",t.name);for(let t of e.securitySchemes)if(!A(t.key))throw B("security scheme",t.key);for(let t of e.services)for(let n of t.operations)if(!A(n.name))throw B("operation",n.name)}function B(e,t){return new Error(`Internal error: ${e} name ${JSON.stringify(t)} is not a safe identifier after sanitization.`)}function ue(e){return G(e)}function L(e,t,n,r){let o=JSON.stringify(t),s=JSON.stringify(n),i=r.kind==="duplicate-operation-id"?`two operations share the operationId ${o}; the second is emitted as ${s} \u2014 give each operation a unique operationId to control its method name`:r.kind==="schema-collision"?`${e} ${o} collides with the schema of the same name, so it is emitted as ${s} \u2014 rename the operation or the schema in the description to control its name`:r.kind==="reserved"?`${e} ${o} is a name a generated client already declares, so it is emitted as ${s} \u2014 the reserved set spans every target language, so one schema keeps one name across the SDKs you generate`:`${e} ${o} is not a usable identifier, so it is emitted as ${s}`;b.warn(`generate-client: ${i}.
13
+ `)}function de(e,t){return t.has(e)?{kind:"reserved"}:{kind:"unusable"}}function $(e,t){switch(e.kind){case"ref":e.name=t(e.name);break;case"omit":e.base=t(e.base);break;case"array":$(e.items,t);break;case"record":$(e.value,t);break;case"object":for(let n of e.properties)$(n.schema,t);break;case"union":for(let n of e.members)$(n,t);if(e.discriminator)for(let n of e.discriminator.mapping)n.schemaName=t(n.schemaName);break;case"intersection":for(let n of e.members)$(n,t);break}}function Ne(e,t){for(let n of e.pathParams)$(n.schema,t);for(let n of e.queryParams)$(n.schema,t);for(let n of e.headerParams)$(n.schema,t);for(let n of e.cookieParams)$(n.schema,t);e.requestBody&&$(e.requestBody.schema,t);for(let n of[...e.successResponses,...e.errorResponses])$(n.schema,t),n.itemSchema&&$(n.itemSchema,t)}var Ae=["get","post","put","delete","patch","head","options"];function me(e,t){if(!t.startsWith("#/"))throw new y(`External $ref not supported: ${t}`);let n=t.slice(2).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~")),r=e;for(let o of n){if(!x(r)&&!Array.isArray(r))throw new y(`Cannot resolve $ref: ${t}`);r=r[o]}if(r===void 0)throw new y(`Cannot resolve $ref: ${t}`);return r}function v(e,t){return S(t)?me(e,t.$ref):t}function N(e){let t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Me(e){let t=e,n={};return typeof t.minimum=="number"&&(n.minimum=t.minimum),typeof t.maximum=="number"&&(n.maximum=t.maximum),typeof t.exclusiveMinimum=="number"?n.exclusiveMinimum=t.exclusiveMinimum:t.exclusiveMinimum===!0&&typeof t.minimum=="number"&&(n.exclusiveMinimum=t.minimum,delete n.minimum),typeof t.exclusiveMaximum=="number"?n.exclusiveMaximum=t.exclusiveMaximum:t.exclusiveMaximum===!0&&typeof t.maximum=="number"&&(n.exclusiveMaximum=t.maximum,delete n.maximum),typeof t.minLength=="number"&&(n.minLength=t.minLength),typeof t.maxLength=="number"&&(n.maxLength=t.maxLength),typeof t.pattern=="string"&&(n.pattern=t.pattern),typeof t.minItems=="number"&&(n.minItems=t.minItems),typeof t.maxItems=="number"&&(n.maxItems=t.maxItems),t.uniqueItems===!0&&(n.uniqueItems=!0),typeof t.format=="string"&&(n.format=t.format),t.deprecated===!0&&(n.deprecated=!0),t.example!==void 0?n.example=t.example:Array.isArray(t.examples)&&t.examples.length>0&&(n.example=t.examples[0]),t.default!==void 0&&(n.default=t.default),Object.keys(n).length>0?n:void 0}function Ie(e,t){let n=e.discriminator;if(!n||typeof n.propertyName!="string")return;let r=[];if(n.mapping)for(let[o,s]of Object.entries(n.mapping))r.push({value:o,schemaName:N(s)});else for(let o of t)if(S(o)){let s=N(o.$ref);r.push({value:s,schemaName:s})}if(r.length!==0)return{propertyName:n.propertyName,mapping:r}}function k(e,t){return t?{...e,metadata:t}:e}function z(e,t){return e?t?{...e,...t}:e:t}function Re(e){return e?e.url.replace(/\{([^{}]+)\}/g,(t,n)=>e.variables?.[n]?.default??t):""}function he(e){let t=e.info?.title??"Api",n=e.info?.version??"0.0.0",r=e.info?.description,o=Re(e.servers?.[0]),s=(e.servers??[]).map(d=>({url:d.url,description:d.description,variables:Object.entries(d.variables??{}).map(([f,m])=>({name:f,default:m.default,description:m.description}))})),i=Be(e),a=Ue(e),c=Le(e,a),u={title:t,version:n,description:r,serverUrl:o,servers:s,services:c,schemas:i,securitySchemes:a};return fe(u),Te(c,i),pe(u),u}function Te(e,t){let n=new Map(t.map(r=>[r.name,r.schema]));for(let r of e)for(let o of r.operations)o.requestBody&&(o.requestBody.schema=Ge(o.requestBody.schema,n))}function Ee(e){let t=e.filter(n=>n.kind!=="unknown");return t.length>0?t:[{kind:"unknown"}]}function Ge(e,t){if(e.kind==="ref"){let n=De(e,t,new Set);return n.length>0?{kind:"omit",base:e.name,keys:n}:e}if(e.kind==="object"){let n=e.properties.filter(r=>!r.readOnly);return n.length===e.properties.length?e:{...e,properties:n}}return e}function De(e,t,n){let r=[],o=s=>{if(s.kind==="ref"){if(n.has(s.name))return;n.add(s.name);let i=t.get(s.name);i&&o(i)}else if(s.kind==="object")for(let i of s.properties)i.readOnly&&!r.includes(i.name)&&r.push(i.name);else if(s.kind==="intersection")for(let i of s.members)o(i)};return o(e),r}function Ue(e){let t=e.components?.securitySchemes;if(!t)return[];let n=[];for(let[r,o]of Object.entries(t)){let s=v(e,o),i=s.type;i==="oauth2"||i==="openIdConnect"?n.push({kind:"bearer",key:r}):i==="http"&&(s.scheme??"").toLowerCase()==="bearer"?n.push({kind:"bearer",key:r}):i==="http"&&(s.scheme??"").toLowerCase()==="basic"?n.push({kind:"basic",key:r}):i==="apiKey"&&s.in==="header"&&typeof s.name=="string"?n.push({kind:"apiKeyHeader",key:r,headerName:s.name}):i==="apiKey"&&s.in==="query"&&typeof s.name=="string"?n.push({kind:"apiKeyQuery",key:r,paramName:s.name}):i==="apiKey"&&s.in==="cookie"&&typeof s.name=="string"&&(b.warn(`generate-client: security scheme "${r}" sends its credential in the Cookie header, which browsers ignore \u2014 cookie auth works only in server-side clients.
14
+ `),n.push({kind:"apiKeyCookie",key:r,cookieName:s.name}))}return n}function Ce(e,t,n){let r=e.security??t.security;if(!r)return[];let o=[];for(let s of r){let i=Object.keys(s);i.length!==0&&i.every(a=>n.has(a))&&o.push([...new Set(i)])}return o}function Be(e){let t=e.components?.schemas;return t?Object.entries(t).map(([n,r])=>{if(S(r)){let s=me(e,r.$ref);return{name:n,schema:q(s,`components.schemas.${n}`,e),description:s.description}}let o=q(r,`components.schemas.${n}`,e);return{name:n,schema:o,description:r.description}}):[]}function Le(e,t){let n=new Set(t.map(i=>i.key)),r=[],o=new Set;for(let[i,a]of Object.entries(e.paths??{})){if(!a)continue;let c=v(e,a),u=(c.parameters??[]).map(d=>ye(v(e,d),`paths.${i}.parameters`,e));for(let d of Ae){let f=c[d];f&&(r.push({method:d,path:i,operation:f,pathLevelParams:u}),f.operationId&&o.add(f.operationId))}}return[{name:"Default",operations:r.map(i=>{let a=i.operation.operationId??_e(ze(i.method,i.path),o);return Fe(i.method,i.path,i.operation,a,i.pathLevelParams,e,n)})}]}function ze(e,t){let n=t.split("/").filter(Boolean).map(r=>Ke(r.replace(/[{}]/g,"")));return`${e}${n.join("")}`}function Ke(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function _e(e,t){let n=e,r=2;for(;t.has(n);)n=`${e}${r++}`;return t.add(n),n}function Fe(e,t,n,r,o,s,i){let a=(n.parameters??[]).map(w=>ye(v(s,w),`paths.${t}.${e}.parameters`,s)),c=new Set,u=[];for(let w of a)c.add(`${w.in}:${w.name}`),u.push(w);for(let w of o)c.has(`${w.in}:${w.name}`)||u.push(w);let d=u.filter(w=>w.in==="path"),f=u.filter(w=>w.in==="query"),m=u.filter(w=>w.in==="header"),l=u.filter(w=>w.in==="cookie"),h=n.requestBody?He(v(s,n.requestBody),`${e} ${t}`,s):void 0,{successResponses:p,successResponseHeaders:g}=Je(n,t,s),P=Ve(n,t,s),j=Ce(n,s,i),F=n["x-redoclyPagination"],X=Xe(p);return{name:r,method:e,path:t,summary:n.summary,description:n.description,pathParams:d,queryParams:f,headerParams:m,cookieParams:l,requestBody:h,successResponses:p,...g===void 0?{}:{successResponseHeaders:g},errorResponses:P,security:j,tags:Array.isArray(n.tags)?n.tags.filter(w=>typeof w=="string"):[],...F!==void 0?{paginationExtension:F}:{},...X===void 0?{}:{sse:X}}}function Xe(e){let t=e.find(o=>o.contentType.split(";")[0].trim().toLowerCase()==="text/event-stream");if(t===void 0)return;let n=t.itemSchema&&t.itemSchema.kind!=="unknown"?t.itemSchema:t.schema.kind!=="unknown"?t.schema:void 0;if(n===void 0)return{dataKind:"text"};let r=n.kind==="object"||n.kind==="ref"||n.kind==="array"||n.kind==="record"||n.kind==="union"||n.kind==="intersection";return{eventSchema:n,dataKind:r?"json":"text"}}function ye(e,t,n){if(!e.in)throw new y(`Parameter ${e.name} at ${t} is missing "in"`);if(!["path","query","header","cookie"].includes(e.in))throw new y(`Unsupported parameter location "${e.in}" for ${e.name} at ${t}`);let r=O(e.schema,`${t}.${e.name}`,n);e.deprecated===!0&&(r={...r,metadata:z(r.metadata,{deprecated:!0})});let o={name:e.name,in:e.in,schema:r,required:!!e.required,description:e.description};if(o.in==="query"){let s=e;(s.style==="form"||s.style==="spaceDelimited"||s.style==="pipeDelimited"||s.style==="deepObject")&&(o.style=s.style),typeof s.explode=="boolean"&&(o.explode=s.explode),typeof s.allowReserved=="boolean"&&(o.allowReserved=s.allowReserved)}return o}function He(e,t,n){let r=e.content??{},o=r["application/json"]??r["application/merge-patch+json"]??r["application/x-www-form-urlencoded"]??r["multipart/form-data"]??Object.values(r)[0];if(!o)return;let s=Object.keys(r).find(a=>r[a]===o),i=O(o.schema,`${t}.requestBody`,n);return{contentType:s,schema:i,required:!!e.required,description:e.description}}function Je(e,t,n){let r=e.responses??{},o=Object.keys(r).filter(m=>/^2\d\d$/.test(m));o.length===0&&(r["2XX"]?o.push("2XX"):r.default&&o.push("default"));let s=o[0];if(!s)return{successResponses:[]};let i=r[s];if(!i)return{successResponses:[]};let a=v(n,i),c=We(a.headers,`paths.${t}.response.${s}`,n),u=a.content;if(!u)return{successResponses:[],...c===void 0?{}:{successResponseHeaders:c}};let d=s==="default"||s==="2XX"?s:Number(s),f=[];for(let[m,l]of Object.entries(u)){let h=O(l.schema,`paths.${t}.response.${s}.${m}`,n),p=l.itemSchema,g=p!==void 0?O(p,`paths.${t}.response.${s}.${m}.itemSchema`,n):void 0;f.push({contentType:m,schema:h,status:d,...g===void 0?{}:{itemSchema:g}})}return{successResponses:f,...c===void 0?{}:{successResponseHeaders:c}}}function We(e,t,n){if(!e)return;let r=[];for(let[o,s]of Object.entries(e)){let i=v(n,s),a={name:o.toLowerCase(),schema:O(i.schema===void 0?void 0:v(n,i.schema),`${t}.headers.${o}`,n)};i.required===!0&&(a.required=!0),r.push(a)}return r.length>0?r:void 0}function Ve(e,t,n){let r=e.responses??{},o=Object.keys(r).filter(a=>/^([45]\d\d|4XX|5XX)$/.test(a));Object.keys(r).some(a=>/^(2\d\d|2XX)$/.test(a))&&r.default&&o.push("default");let i=[];for(let a of o){let c=r[a];if(!c)continue;let d=v(n,c).content;if(!d)continue;let f=a==="default"||a==="4XX"||a==="5XX"?a:Number(a);for(let[m,l]of Object.entries(d)){let h=O(l.schema,`paths.${t}.response.${a}.${m}`,n);i.push({contentType:m,schema:h,status:f})}}return i}function O(e,t,n){return e===void 0||typeof e=="boolean"?{kind:"unknown"}:S(e)?{kind:"ref",name:N(e.$ref)}:q(e,t,n)}function q(e,t,n){let r=Me(e),o=e.oneOf??e.anyOf;if(o){let a=o.map((d,f)=>S(d)?{kind:"ref",name:N(d.$ref)}:q(d,`${t}.[${f}]`,n)),c=Ee(a);if(c.length===1&&c.length<a.length){let d=c[0];return{...d,description:d.description??e.description,metadata:z(r,d.metadata)}}let u=Ie(e,o);return k({kind:"union",members:c,discriminator:u,description:e.description},r)}if(e.allOf){let a=e.allOf.map((u,d)=>S(u)?{kind:"ref",name:N(u.$ref)}:q(u,`${t}.allOf[${d}]`,n)),c=le(e,t,n);if(c.length>0&&a.unshift({kind:"object",properties:c}),a.length===1){let u=a[0];return{...u,description:u.description??e.description,metadata:z(r,u.metadata)}}return k({kind:"intersection",members:a,description:e.description},r)}let s=e.type;if(Array.isArray(s)){let a=s.filter(d=>d!=="null"),c=s.includes("null"),u=a.map(d=>{let f={...e,type:d};if(Array.isArray(f.enum)){let m=f.enum.filter(l=>l!==null);f.enum=m.length>0?m:void 0}return q(f,t,n)});return c&&u.push({kind:"null"}),u.length===1?u[0]:k({kind:"union",members:u,description:e.description},r)}if(e.nullable)return{kind:"union",members:[q({...e,nullable:void 0},t,n),{kind:"null"}],description:e.description};if(e.const!==void 0){let a=e.const;if(typeof a!="string"&&typeof a!="number"&&typeof a!="boolean")throw new y(`Unsupported const value at ${t}: ${JSON.stringify(a)}`);return k({kind:"literal",value:a,description:e.description},r)}if(e.enum){let a=e.enum,c=a.filter(m=>m!==null),u=c.length!==a.length;if(c.length===0)return k({kind:"null",description:e.description},r);let d=Qe(c,t),f=d==="boolean"?{kind:"scalar",scalar:"boolean",description:e.description}:{kind:"enum",values:c,scalar:d,description:e.description};return k(u?{kind:"union",members:[f,{kind:"null"}],description:e.description}:f,r)}let i=s;if(i==="null")return k({kind:"null",description:e.description},r);if(i==="array"){let a=e.items,c=O(a,`${t}.items`,n);return k({kind:"array",items:c,description:e.description},r)}if(i==="object"||e.properties||e.additionalProperties){let a=le(e,t,n),c=e.additionalProperties;if(a.length===0&&c!==!1){let u=O(c,`${t}.additionalProperties`,n);return k({kind:"record",value:u,description:e.description},r)}return k({kind:"object",properties:a,description:e.description},r)}return k(i==="string"||i==="number"||i==="integer"||i==="boolean"?{kind:"scalar",scalar:i,description:e.description}:{kind:"unknown",description:e.description},r)}function Qe(e,t){let n=!1,r=!1,o=!1;for(let s of e)if(typeof s=="string")n=!0;else if(typeof s=="number")r=!0;else if(typeof s=="boolean")o=!0;else throw new y(`Unsupported enum value type at ${t}: ${JSON.stringify(s)}`);return n&&!r&&!o?"string":r&&!n&&!o?"number":o&&!n&&!r?"boolean":"string"}function Ye(e){return!(e.openapi??"").startsWith("3.0")}function le(e,t,n){let r=e.properties??{},o=new Set(e.required??[]),s=Ye(n);return Object.entries(r).map(([i,a])=>{let c=a.readOnly===!0;c&&S(a)&&!s&&b.warn(`generate-client: "${i}" declares readOnly beside a $ref, which OpenAPI ${n.openapi} ignores \u2014 the property stays in request bodies. Inline the schema, wrap the $ref in allOf, or move the description to OpenAPI 3.1.
15
+ `);let u=c&&(s||!S(a));return{name:i,schema:O(a,`${t}.${i}`,n),required:o.has(i),description:a.description,...u?{readOnly:!0}:{}}})}function ge(e){let t=K(e),n={...t};delete n.swagger,delete n.host,delete n.basePath,delete n.schemes,delete n.definitions,delete n.securityDefinitions,delete n.consumes,delete n.produces,delete n.parameters,delete n.responses,n.openapi="3.0.3";let r=Ze(t);return r&&(n.servers=r),n.components=et(t),n.paths=ot(t.paths??{},t.consumes??void 0,t.produces??void 0),n}function Ze(e){let t=e.host,n=e.basePath??"",r=(e.schemes??["https"])[0]??"https";if(t)return[{url:`${r}://${t}${n}`}]}function et(e){let t={};e.definitions&&(t.schemas=e.definitions),e.parameters&&(t.parameters=Object.fromEntries(Object.entries(e.parameters).map(([r,o])=>[r,_(o)]))),e.responses&&(t.responses=be(e.responses,void 0));let n=e.securityDefinitions;if(n){let r={};for(let[o,s]of Object.entries(n))r[o]=tt(s);t.securitySchemes=r}return t}function tt(e){switch(e.type){case"basic":return{type:"http",scheme:"basic"};case"apiKey":return{type:"apiKey",name:e.name,in:e.in};case"oauth2":{let t=e.flow==="accessCode"?"authorizationCode":e.flow==="application"?"clientCredentials":e.flow,n={scopes:e.scopes??{}};return e.authorizationUrl&&(n.authorizationUrl=e.authorizationUrl),e.tokenUrl&&(n.tokenUrl=e.tokenUrl),{type:"oauth2",flows:{[t]:n}}}default:return e}}function K(e){if(Array.isArray(e))return e.map(K);if(x(e)){let t={};for(let[n,r]of Object.entries(e))n==="$ref"&&typeof r=="string"?t.$ref=r.replace("#/definitions/","#/components/schemas/").replace("#/parameters/","#/components/parameters/").replace("#/responses/","#/components/responses/"):t[n]=K(r);return t}return e}var nt="application/json",rt="application/json",we=new Set(["name","in","required","description","deprecated","allowEmptyValue","collectionFormat"]);function ot(e,t,n){let r={};for(let[o,s]of Object.entries(e)){let i=s,a={};for(let[c,u]of Object.entries(i)){if(c==="parameters"&&Array.isArray(u)){a.parameters=u.map(_);continue}if(!st(c)){a[c]=u;continue}a[c]=it(u,t,n)}r[o]=a}return r}function st(e){return["get","put","post","delete","options","head","patch"].includes(e.toLowerCase())}function it(e,t,n){let r=e.consumes??t,o=e.produces??n,s=e.parameters??[],i=s.find(f=>f.in==="body"),a=s.filter(f=>f.in==="formData"),c=s.filter(f=>f.in!=="body"&&f.in!=="formData").map(_),u={...e,parameters:c};delete u.consumes,delete u.produces;let d=r?.[0]??nt;if(i)u.requestBody={required:!!i.required,content:{[d]:{schema:i.schema}}};else if(a.length>0){let f={},m=[];for(let p of a)f[p.name]=at(p),p.required&&m.push(p.name);let l={type:"object",properties:f};m.length>0&&(l.required=m);let h=r?.find(p=>p==="multipart/form-data")??r?.[0]??"application/x-www-form-urlencoded";u.requestBody={required:m.length>0,content:{[h]:{schema:l}}}}return e.responses&&(u.responses=be(e.responses,o)),u}function _(e){if(e.$ref!==void 0||e.in==="body"||e.in==="formData")return e;let t={},n={};for(let[r,o]of Object.entries(e))we.has(r)?t[r]=o:n[r]=o;if(t.schema=n,delete t.collectionFormat,e.in==="query"&&n.type==="array"){let r=e.collectionFormat??"csv";r!=="multi"&&(t.style=r==="ssv"?"spaceDelimited":r==="pipes"?"pipeDelimited":"form",t.explode=!1)}return t}function at(e){let t={};for(let[n,r]of Object.entries(e))we.has(n)||(t[n]=r);return t}function be(e,t){let n=t?.[0]??rt,r={};for(let[o,s]of Object.entries(e)){let i=s;if(i.schema===void 0){r[o]=i;continue}let{schema:a,...c}=i;r[o]={...c,content:{[n]:{schema:a}}}}return r}async function $e(e,t,n){let r=t??await T({}),o=await Y({ref:e,config:r,collectSpecData:n}),s=await T({rules:{struct:"error"}}),i=await Z({externalRefResolver:new V,document:o.bundle,config:s}),a=[...o.problems,...i].filter(u=>u.severity==="error");if(a.length>0){let u=a.map(d=>`- ${d.message} (at ${d.location?.[0]?.pointer??e})`).join(`
16
+ `);throw new Error(`The API description has ${a.length} error(s):
17
+ ${u}`)}let c=o.bundle.parsed;return{document:c,version:Q(c)}}var lt=["Generated by @redocly/client-generator \u2014 do not edit by hand.","Source: OpenAPI description. Re-run `redocly generate-client` to update."];function mt(e,t){let n=[],r=new Set,o=R(ke(t.outputPath)),{dir:s,name:i,ext:a}=ft(t.outputPath),c={path:t.outputPath,dir:s,stem:i,ext:a},u=lt,d=!1;for(let f of t.generators){let m=t.registry.get(f),l={model:e,output:c,banner:u,outputMode:t.outputMode,emit:t.emit,pagination:t.pagination,selected:t.generators,options:t.generatorOptions?.get(f)??{}},h;try{t.emit.docs===!0&&m.docs!==void 0?(h=[...m.run(l),...m.docs(l)],d=!0):h=m.run(l)}catch(p){let g=p instanceof Error?p.message:String(p);throw new Error(`Generator "${f}" failed: ${g}`)}if(!Array.isArray(h)||h.some(p=>typeof p?.path!="string"||p.path===""||typeof p.content!="string"))throw new Error(`Generator "${f}" failed: run() must return an array of { path, content } files.`);for(let p of h){let g=R(o,p.path);if(g!==o&&!g.startsWith(o+pt))throw new Error(`Generator "${f}" failed: file path escapes the output directory: ${p.path}`);if(r.has(g))throw new Error(`Generator conflict: ${p.path} already emitted by an earlier generator`);r.add(g),n.push({path:g,content:p.content})}}return t.emit.docs===!0&&!d&&b.warn(`generate-client: docs is on, but no selected generator writes documentation (${t.generators.join(", ")}).
18
+ `),n}function ht(e){for(let t of e.services)for(let n of t.operations){let r=new Set,o=new Set;for(let s of[...n.pathParams,...n.queryParams,...n.headerParams,...n.cookieParams])r.has(s.name)&&o.add(s.name),r.add(s.name);o.size!==0&&b.warn(`generate-client: operation "${n.specName??n.name}" uses ${[...o].map(s=>`"${s}"`).join(", ")} in more than one parameter location. Every SDK sends both, and the SDKs whose methods take one argument per parameter give the later one a suffixed name \u2014 rename it in the description to choose the name yourself.
19
+ `)}}function yt(e,t,n,r,o,s,i){let a=[],c=new Set;for(let u of ee(t.services)){let d=gt(e,u.path,u.method);if(c.has(d))continue;c.add(d);let f=r.map(m=>o.get(m)?.sample?.(u,{model:t,emit:n,outputPath:s,pagination:i})).filter(m=>m!==void 0);f.length>0&&a.push({target:d,update:{"x-codeSamples":f}})}if(a.length!==0)return W({overlay:"1.0.0",info:{title:`Code samples for ${t.title}`,version:t.version},actions:a})}function gt(e,t,n){let r=i=>`['${i.replaceAll("\\","\\\\").replaceAll("'","\\'")}']`,o=e.paths?.[t];return`${S(o)&&o.$ref.startsWith("#/")?"$"+o.$ref.slice(2).split("/").map(H).map(r).join(""):`$.paths${r(t)}`}.${n}`}async function nn(e){if(e.output.split(/[\\/]/).some(p=>p==="undefined"||p==="null"))throw new Error(`output path "${e.output}" contains a literal "undefined" or "null" segment \u2014 this looks like an interpolation bug in the caller`);if(e.setup&&/^[a-z][a-z0-9+.-]+:/i.test(e.setup))throw new y(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let t=R(e.output),{document:n,version:r}=await $e(e.api,e.config,e.collectSpecData),o=r==="oas2"?ge(n):n,s=he(o);ht(s);let i;if(e.setup){let{bakeSetup:p}=await import("./CQMMUWIJ.js"),g=R(e.configDir??process.cwd(),e.setup);i=p(await ut(g,"utf-8"))}let a=e.generators?.length?e.generators:["typescript"],{selected:c,registry:u}=await ae(a,{customGenerators:e.customGenerators,configDir:e.configDir}),d=te(s,e.pagination),f={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,telemetry:e.telemetry,setup:i,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:d,docs:e.docs,docsFrontmatter:e.docsFrontmatter};oe(c,f,u,e.outputMode);let m=se(c,u,e.options),l=mt(s,{outputPath:t,outputMode:e.outputMode??"single",emit:f,pagination:d,generators:c,generatorOptions:m,registry:u});if(e.codeSamples===!0){let p=yt(n,s,f,c,u,t,d);p!==void 0&&l.push({path:t.replace(/\.[^.]+$/,".code-samples.yaml"),content:p})}let h=[];for(let p of l)await ct(ke(p.path),{recursive:!0}),await dt(p.path,p.content,"utf-8"),h.push({path:p.path,bytes:Buffer.byteLength(p.content,"utf-8")});return{outputPath:t,bytes:h.reduce((p,g)=>p+g.bytes,0),files:h}}export{I as a,oe as b,mt as c,nn as d};
@@ -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{c as a,d as b}from"./FXCLUZIF.js";import"./LR6VKQFM.js";import"./WZXA5XPB.js";import"./K4IZRPJV.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as generateClient,a as runGenerators};
7
+ import{c as a,d as b}from"./DTPYQUHR.js";import"./CCZY5XJV.js";import"./WZXA5XPB.js";import"./4JI4GT6B.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as generateClient,a as runGenerators};
@@ -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"./KTZA5BVG.js";import"./HAOBCQWB.js";import"./PYSE2LAG.js";import"./LR6VKQFM.js";import"./WZXA5XPB.js";import"./K4IZRPJV.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
7
+ import{a,b,c,d,e}from"./ZLAHBPRQ.js";import"./HAOBCQWB.js";import"./2AJDP47K.js";import"./CCZY5XJV.js";import"./WZXA5XPB.js";import"./4JI4GT6B.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
@@ -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 q}from"./YCJL4ZHF.js";import{h as H,l as B,r as z,t as K,u as V,v as Z,w as _}from"./RALPAYEE.js";import"./GKXY6U4S.js";import{b as J,d as M,e as Y,v as L}from"./46YO7ZAG.js";import{$ as O,V as N,Z as v,aa as A,ba as j,ca as b,ea as y,fa as C,ga as R,ia as e,l as h,oa as w,pa as D,ua as S,xa as g}from"./K4IZRPJV.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{dirname as le}from"node:path";function W(r,t,o,n){n&&e.info(C(v(`
7
+ import{a as q}from"./WJLUIDSE.js";import{h as H,l as B,r as z,t as K,u as V,v as Z,w as _}from"./GP5VOB7R.js";import"./GKXY6U4S.js";import{b as J,d as M,e as Y,v as L}from"./RIJ5NQKJ.js";import{$ as O,V as N,Z as v,aa as A,ba as j,ca as b,ea as y,fa as C,ga as R,ia as e,l as h,oa as w,pa as D,ua as S,xa as g}from"./4JI4GT6B.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{dirname as le}from"node:path";function W(r,t,o,n){n&&e.info(C(v(`
8
8
  \u2611\uFE0F Achieved Level: ${y(o)}
9
9
 
10
10
  `))),e.output(`<?xml version="1.0" encoding="UTF-8"?>
@@ -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 we,e as Re,f as be,g as k,h as A,i as Oe,j as Ie,k as S,l as x,m as Pe,n as ke,v as Ae,w as xe}from"./PGX27JIK.js";import{$ as E,K as lt,V as le,Y as ft,Z as fe,_ as g,aa as me,ba as q,c as p,ca as T,ea as b,ga as w,ia as R,ja as he,ka as ge,la as ye,ma as Se,q as de,ra as ve,w as pe}from"./K4IZRPJV.js";import{e as ce}from"./RFWIIJFG.js";import Ce from"node:path";function O(t){return t?t.trim():""}function L(t){let e=O(t.operationId)||O(t.path);return[O(t.ruleId),O(t.severity),O(t.message),e,O(t.target),O(t.schemaPath)].join("")}var N=t=>fe(b(t));function mt(t){return t==="error"?"error":t==="warning"?"warning":"note"}function ht(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
7
+ import{a as we,e as Re,f as be,g as k,h as A,i as Oe,j as Ie,k as S,l as x,m as Pe,n as ke,v as Ae,w as xe}from"./M5FZMXND.js";import{$ as E,K as lt,V as le,Y as ft,Z as fe,_ as g,aa as me,ba as q,c as p,ca as T,ea as b,ga as w,ia as R,ja as he,ka as ge,la as ye,ma as Se,q as de,ra as ve,w as pe}from"./4JI4GT6B.js";import{e as ce}from"./RFWIIJFG.js";import Ce from"node:path";function O(t){return t?t.trim():""}function L(t){let e=O(t.operationId)||O(t.path);return[O(t.ruleId),O(t.severity),O(t.message),e,O(t.target),O(t.schemaPath)].join("")}var N=t=>fe(b(t));function mt(t){return t==="error"?"error":t==="warning"?"warning":"note"}function ht(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
8
8
  `)?e:`"${e.replace(/"/g,'""')}"`}function gt(t){return Ce.isAbsolute(t)?Ce.relative(process.cwd(),t)||".":t}function yt(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function St(t){return Object.entries(t).sort((e,n)=>{let r=n[1]-e[1];return r!==0?r:e[0].localeCompare(n[0])})}function vt(t){let e=[],n=new Map;for(let r of t){let s=L({ruleId:r.ruleId,severity:r.severity,message:r.message,operationId:r.operationId,path:r.path,target:r.target,schemaPath:r.schemaPath}),i=n.get(s);if(i!==void 0){e[i].occurrences+=1;continue}n.set(s,e.length),e.push({finding:r,occurrences:1})}return e}function wt(t){let e=vt(t.findings).map(r=>({occurrences:r.occurrences,exchangeIndex:r.finding.exchangeIndex,ruleId:r.finding.ruleId,severity:r.finding.severity,category:r.finding.category,message:r.finding.message,operationId:r.finding.operationId,specSource:r.finding.specSource,target:r.finding.target,schemaPath:r.finding.schemaPath,dataPath:r.finding.dataPath,details:r.finding.details,method:r.finding.method,url:r.finding.url,path:r.finding.path,status:r.finding.status})),n={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(n,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"],n=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,...n].map(s=>s.map(ht).join(",")).join(`
10
10
  `)}
@@ -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}from"./AONBK2JI.js";import"./HAOBCQWB.js";import"./M37DUXGN.js";import"./PYSE2LAG.js";import"./LR6VKQFM.js";import"./WZXA5XPB.js";import"./K4IZRPJV.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as typescriptDocs,a as typescriptGenerator,c as typescriptSample};
7
+ import{a,b,c}from"./JH6AK2RM.js";import"./HAOBCQWB.js";import"./HU6QTMHN.js";import"./2AJDP47K.js";import"./CCZY5XJV.js";import"./WZXA5XPB.js";import"./4JI4GT6B.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as typescriptDocs,a as typescriptGenerator,c as typescriptSample};
@@ -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,f,g}from"./GLUPJCQU.js";import"./UF2ZCH7W.js";import"./K4IZRPJV.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{d as RESET_ESCAPE_CODE,c as calculateTotals,f as conditionallyMaskSecrets,b as generate,e as maskSecrets,a as parseRuntimeExpression,g as run};
7
+ import{a,b,c,d,e,f,g}from"./D5A4WCOD.js";import"./UF2ZCH7W.js";import"./4JI4GT6B.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{d as RESET_ESCAPE_CODE,c as calculateTotals,f as conditionallyMaskSecrets,b as generate,e as maskSecrets,a as parseRuntimeExpression,g as run};
@@ -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 K}from"./GKXY6U4S.js";import{Aa as V,j as z,l as I,o as H,oa as m,p as q,ta as Y}from"./K4IZRPJV.js";import{e as b}from"./RFWIIJFG.js";var Q=b(K(),1);var T=b(K(),1);function G(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function X(n){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(n).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var Z=async(n,{timeout:t,...e}={})=>{let r=G(),s=r&&!X(n),o;s?o=new T.ProxyAgent({uri:r}):t&&(o=new T.Agent({connect:{timeout:t}}));try{return await(0,T.fetch)(n,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:o})}catch(i){throw await o?.destroy(),i}};var de=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function J(){let n=process.env.REDOCLY_ENVIRONMENT?.trim();return n&&de.test(n)?n:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},x=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=J(),s={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let o=await Z(t,{...e,headers:s});return this.collectSunsetWarning(o),o}catch(o){let i=o.cause??o,a=`Failed to fetch. Caused by ${i.message||i.name}.`;throw typeof i.code=="string"&&(a+=` Code: ${i.code}`),new Error(a)}}collectSunsetWarning(t){let e=this.getSunsetDate(t);if(!e)return;let r=new Date(e);e>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(t){let{headers:e}=t;if(!e)return;let r=e.get("sunset")||e.get("Sunset");if(r)return Date.parse(r)}},U=class{client;domain;apiKey;constructor(t,e,r){this.client=t,this.domain=e,this.apiKey=r}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},N=class extends U{async find(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return r.status===404?void 0:await this.getParsedResponse(r)}catch(r){let s=`Failed to fetch project. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}},j=class extends U{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/sources`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}}),s=await this.getParsedResponse(r),[o]=s.data;if(!o)throw new Error("Project source not found.");return o.branchName}catch(r){let s=`Failed to fetch default branch. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}async upsert(t,e,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes`,{timeout:6e3,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let o=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}async push(t,e,r,s){let o=new Q.FormData;o.append("remoteId",r.remoteId),o.append("commit[message]",r.commit.message),o.append("commit[author][name]",r.commit.author.name),o.append("commit[author][email]",r.commit.author.email),o.append("commit[branchName]",r.commit.branchName),r.commit.url&&o.append("commit[url]",r.commit.url),r.commit.namespace&&o.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&o.append("commit[sha]",r.commit.sha),r.commit.repository&&o.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&o.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await he(i.stream)]);o.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&o.append("isMainBranch","true"),r.replace&&o.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:o});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getPush({organizationId:t,projectId:e,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes/${r}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let o=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}},g=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new x(r,s),this.projects=new N(this.apiClient,t,e),this.remotes=new j(this.apiClient,t,e)}getSunsetWarning(){return ee(this.apiClient.sunsetWarnings)}};function ee(n){let[t]=[...n].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function he(n){let t=[];for await(let e of n)t.push(e);return Buffer.concat(t)}function fe(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var pe=/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/,E={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function me(){return process.env.REDOCLY_DOMAIN||E.us}var te=ge((n,t)=>{try{let e=t||n?.resolvedConfig.residency;return we(e)?E[e]:e?new URL(e).origin:n?.resolvedConfig.scorecard?.fromProjectUrl?new URL(n.resolvedConfig.scorecard.fromProjectUrl).origin:E.us}catch{throw new R}});function D(n){try{te(void 0,n)}catch{return!1}return!0}function ge(n){return(...t)=>{let e=n(...t);if(!e.startsWith("https://")&&!pe.test(e))throw new R;return e}}var R=class extends Error{constructor(){super("Invalid Reunite URL")}};function we(n){return typeof n=="string"&&n in E}import{Buffer as O}from"node:buffer";import F from"node:crypto";import{mkdirSync as ye,existsSync as ne,writeFileSync as ve,readFileSync as Te,rmSync as xe}from"node:fs";import{homedir as Ce}from"node:os";import se from"node:path";import*as re from"node:child_process";var w=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new x("login",e)}async run(t){let e=await this.getDeviceCode();t?.({verificationUri:e.verificationUri,verificationUriComplete:e.verificationUriComplete,userCode:e.userCode}),this.openBrowser(e.verificationUriComplete);let r=await this.pollingAccessToken(e.deviceCode,e.interval,e.expiresIn);return this.withResidency(r)}openBrowser(t){if(!/^https?:\/\//.test(t))return;let[e,r]=process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:process.platform==="darwin"?["open",[t]]:["xdg-open",[t]];re.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((s,o)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),s(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),o(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),o("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:s,interval:o=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:s,interval:o,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let o=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(o,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...s},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var Pe="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",oe="aes-256-cbc",k=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Ce();this.credentialsFolderPath=se.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=se.join(this.credentialsFolderPath,this.credentialsFileName),this.key=F.createHash("sha256").update(`${this.credentialsFolderPath}${Pe}`).digest(),this.iv=F.createHash("md5").update(this.credentialsFolderPath).digest(),ye(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new w(t,this.version).run(e);if(!s)throw new Error("Failed to login. No credentials received.");await this.saveCredentials(s)}async logout(){try{this.removeCredentials()}catch{}}async isAuthorized(t,e){return e?new w(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new w(t,this.version),r=await this.readCredentials();if(!r||!D(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let o=await e.refreshToken(r.refresh_token);return await this.saveCredentials(o),o.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);ve(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!ne(this.credentialsFilePath))return null;try{let t=Te(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){ne(this.credentialsFilePath)&&xe(this.credentialsFilePath)}encryptCredentials(t){let e=F.createCipheriv(oe,this.key,this.iv);return O.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=F.createDecipheriv(oe,this.key,this.iv),r=O.concat([e.update(O.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as y from"node:fs";import*as h from"node:path";var Ee=/\/orgs\/([^/]+)\/projects\//,Re=[401,403];async function C(n,{organization:t,project:e,onSlugDeprecated:r}){let s=await $e(n,t,e);if(!s)return{organizationId:t,projectId:e};let o={organizationId:_e(s.uri),projectId:s.id};return(o.organizationId!==t||o.projectId!==e)&&r?.(o),o}async function $e(n,t,e){try{let r=await n.projects.find(t,e);if(!r)throw new u(`Project "${e}" was not found in organization "${t}". Use the IDs from the organization and project settings in Reunite.`,404);return r}catch(r){if(r instanceof u&&Re.includes(r.status))return;throw r}}function _e(n){let t=n.match(Ee)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${n}".`);return t}async function Se({domain:n,apiKey:t,organization:e,project:r,mountPath:s,files:o,defaultBranch:i,commit:a,version:c,replace:$,onUploadStart:_,onSunsetWarning:v,onSlugDeprecated:A}){let f=new g({domain:n,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await C(f,{organization:e,project:r,onSlugDeprecated:A}),M=await f.remotes.getDefaultBranch(d,l),p=await f.remotes.upsert(d,l,{mountBranchName:M,mountPath:s});_?.(p);let{id:P}=await f.remotes.push(d,l,{remoteId:p.id,commit:a,isMainBranch:i===a.branchName,replace:$},o.map(W=>({path:H(W.name),stream:y.createReadStream(W.path)})));return{pushId:P,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&v?.(d)}}function Ue(n,t){let e={};for(let s of n)if(y.statSync(s).isDirectory()){let o=s;ie(o,[]).forEach(a=>r(a,o))}else r(s,h.dirname(s));function r(s,o){let i=h.relative(o,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,o])=>({name:s,path:h.resolve(o)}))}function ie(n,t){let e=y.readdirSync(n);for(let r of e){let s=h.join(n,r);y.statSync(s).isDirectory()?t=ie(s,t):t.push(s)}return t}async function ae({operation:n,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:o=5e3}){async function i(){let a=await n();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await z(o),i()}return i()}var Fe=1200,Ae=5e3,Ie=["pending","running"];async function Ne(n){let t=ce(n);try{let e=await C(t,n);return await le(t,e,n.pushId)}finally{ue(t,n)}}async function je({buildType:n,maxExecutionTime:t=Fe,retryIntervalMs:e=Ae,startTime:r=Date.now(),onRetry:s,...o}){let i=ce(o);try{let a=await C(i,o);return await ae({operation:()=>le(i,a,o.pushId),condition:c=>!Ie.includes(c.status[n].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ue(i,o)}}function ce({domain:n,apiKey:t,version:e}){return new g({domain:n,apiKey:t,command:"push-status",version:e})}function ue(n,{onSunsetWarning:t}){let e=n.getSunsetWarning();e&&t?.(e)}function le(n,{organizationId:t,projectId:e},r){return n.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function De({projectUrl:n,auth:t,isApiKey:e=!1,onDebug:r}){let s=Oe(n);if(!s)throw new m(`Invalid project URL format: ${n}`);try{let o=await ke({...s,auth:t,isApiKey:e,onDebug:r}),i=o.config.scorecardClassic||o.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=o.config.pluginsUrl,c=a?await Le(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(o){throw new m(o instanceof Error?o.message:String(o))}}function Oe(n){let t=new URL(n),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:s}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:s}}async function ke({residency:n,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:o}){let i=new URL(`${n}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:Be(r,s)});if(o?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw o?.(`Authentication failed with status ${a.status}.`),o?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return o?.("Successfully received project configuration."),a.json()}async function Le(n,t){t?.(`Fetching plugins from: ${n}`);try{let e=await fetch(n);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function Be(n,t){return t?{Authorization:`Bearer ${n}`}:{Cookie:`accessToken=${n}`}}async function L(n,t,e=[],r=[],s){let o={};for(let i of e){let a={[i.name]:{root:n,rules:t}},c=await Y({apis:a,...i,plugins:r},{configPath:s});o[i.name]=c.forAlias(i.name)}return o}function B(n,t){if(n){for(let e of n)if(Object.entries(e.where?.metadata||{}).every(([s,o])=>Me(s,o,t)))return e}}function Me(n,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[n])return!1;let[r,s]=t.split("/"),o=new Date(e[n]);return!(o<new Date(r)||s&&o>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[n])return!1;try{return q(t).test(e[n])}catch{throw new m(`Invalid regex in scorecard target "${n}": ${t}`)}}return e[n]===t}import{pathToFileURL as We}from"node:url";async function be(n,t){if(!n)return[];let e=We(t??process.cwd()).href+"/",r=n.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var ze=".redocly.com";function He(n){try{return new URL(n).hostname.toLowerCase().endsWith(ze)}catch{return!1}}async function qe({apiPath:n,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:o=[],targetLevel:i,metadata:a={},onDebug:c}){let $=[],_=new Map,v=r.levels||[];if(i&&!v.some(l=>l.name===i))throw new m(`Target level "${i}" not found in the scorecard configuration levels.
7
+ import{a as K}from"./GKXY6U4S.js";import{Aa as V,j as z,l as I,o as H,oa as m,p as q,ta as Y}from"./4JI4GT6B.js";import{e as b}from"./RFWIIJFG.js";var Q=b(K(),1);var T=b(K(),1);function G(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function X(n){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(n).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var Z=async(n,{timeout:t,...e}={})=>{let r=G(),s=r&&!X(n),o;s?o=new T.ProxyAgent({uri:r}):t&&(o=new T.Agent({connect:{timeout:t}}));try{return await(0,T.fetch)(n,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:o})}catch(i){throw await o?.destroy(),i}};var de=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function J(){let n=process.env.REDOCLY_ENVIRONMENT?.trim();return n&&de.test(n)?n:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},x=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=J(),s={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let o=await Z(t,{...e,headers:s});return this.collectSunsetWarning(o),o}catch(o){let i=o.cause??o,a=`Failed to fetch. Caused by ${i.message||i.name}.`;throw typeof i.code=="string"&&(a+=` Code: ${i.code}`),new Error(a)}}collectSunsetWarning(t){let e=this.getSunsetDate(t);if(!e)return;let r=new Date(e);e>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(t){let{headers:e}=t;if(!e)return;let r=e.get("sunset")||e.get("Sunset");if(r)return Date.parse(r)}},U=class{client;domain;apiKey;constructor(t,e,r){this.client=t,this.domain=e,this.apiKey=r}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},N=class extends U{async find(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return r.status===404?void 0:await this.getParsedResponse(r)}catch(r){let s=`Failed to fetch project. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}},j=class extends U{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/sources`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}}),s=await this.getParsedResponse(r),[o]=s.data;if(!o)throw new Error("Project source not found.");return o.branchName}catch(r){let s=`Failed to fetch default branch. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}async upsert(t,e,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes`,{timeout:6e3,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let o=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}async push(t,e,r,s){let o=new Q.FormData;o.append("remoteId",r.remoteId),o.append("commit[message]",r.commit.message),o.append("commit[author][name]",r.commit.author.name),o.append("commit[author][email]",r.commit.author.email),o.append("commit[branchName]",r.commit.branchName),r.commit.url&&o.append("commit[url]",r.commit.url),r.commit.namespace&&o.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&o.append("commit[sha]",r.commit.sha),r.commit.repository&&o.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&o.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await he(i.stream)]);o.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&o.append("isMainBranch","true"),r.replace&&o.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:o});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getPush({organizationId:t,projectId:e,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes/${r}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let o=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}},g=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new x(r,s),this.projects=new N(this.apiClient,t,e),this.remotes=new j(this.apiClient,t,e)}getSunsetWarning(){return ee(this.apiClient.sunsetWarnings)}};function ee(n){let[t]=[...n].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function he(n){let t=[];for await(let e of n)t.push(e);return Buffer.concat(t)}function fe(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var pe=/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/,E={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function me(){return process.env.REDOCLY_DOMAIN||E.us}var te=ge((n,t)=>{try{let e=t||n?.resolvedConfig.residency;return we(e)?E[e]:e?new URL(e).origin:n?.resolvedConfig.scorecard?.fromProjectUrl?new URL(n.resolvedConfig.scorecard.fromProjectUrl).origin:E.us}catch{throw new R}});function D(n){try{te(void 0,n)}catch{return!1}return!0}function ge(n){return(...t)=>{let e=n(...t);if(!e.startsWith("https://")&&!pe.test(e))throw new R;return e}}var R=class extends Error{constructor(){super("Invalid Reunite URL")}};function we(n){return typeof n=="string"&&n in E}import{Buffer as O}from"node:buffer";import F from"node:crypto";import{mkdirSync as ye,existsSync as ne,writeFileSync as ve,readFileSync as Te,rmSync as xe}from"node:fs";import{homedir as Ce}from"node:os";import se from"node:path";import*as re from"node:child_process";var w=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new x("login",e)}async run(t){let e=await this.getDeviceCode();t?.({verificationUri:e.verificationUri,verificationUriComplete:e.verificationUriComplete,userCode:e.userCode}),this.openBrowser(e.verificationUriComplete);let r=await this.pollingAccessToken(e.deviceCode,e.interval,e.expiresIn);return this.withResidency(r)}openBrowser(t){if(!/^https?:\/\//.test(t))return;let[e,r]=process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:process.platform==="darwin"?["open",[t]]:["xdg-open",[t]];re.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((s,o)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),s(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),o(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),o("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:s,interval:o=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:s,interval:o,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let o=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(o,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...s},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var Pe="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",oe="aes-256-cbc",k=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Ce();this.credentialsFolderPath=se.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=se.join(this.credentialsFolderPath,this.credentialsFileName),this.key=F.createHash("sha256").update(`${this.credentialsFolderPath}${Pe}`).digest(),this.iv=F.createHash("md5").update(this.credentialsFolderPath).digest(),ye(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new w(t,this.version).run(e);if(!s)throw new Error("Failed to login. No credentials received.");await this.saveCredentials(s)}async logout(){try{this.removeCredentials()}catch{}}async isAuthorized(t,e){return e?new w(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new w(t,this.version),r=await this.readCredentials();if(!r||!D(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let o=await e.refreshToken(r.refresh_token);return await this.saveCredentials(o),o.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);ve(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!ne(this.credentialsFilePath))return null;try{let t=Te(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){ne(this.credentialsFilePath)&&xe(this.credentialsFilePath)}encryptCredentials(t){let e=F.createCipheriv(oe,this.key,this.iv);return O.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=F.createDecipheriv(oe,this.key,this.iv),r=O.concat([e.update(O.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as y from"node:fs";import*as h from"node:path";var Ee=/\/orgs\/([^/]+)\/projects\//,Re=[401,403];async function C(n,{organization:t,project:e,onSlugDeprecated:r}){let s=await $e(n,t,e);if(!s)return{organizationId:t,projectId:e};let o={organizationId:_e(s.uri),projectId:s.id};return(o.organizationId!==t||o.projectId!==e)&&r?.(o),o}async function $e(n,t,e){try{let r=await n.projects.find(t,e);if(!r)throw new u(`Project "${e}" was not found in organization "${t}". Use the IDs from the organization and project settings in Reunite.`,404);return r}catch(r){if(r instanceof u&&Re.includes(r.status))return;throw r}}function _e(n){let t=n.match(Ee)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${n}".`);return t}async function Se({domain:n,apiKey:t,organization:e,project:r,mountPath:s,files:o,defaultBranch:i,commit:a,version:c,replace:$,onUploadStart:_,onSunsetWarning:v,onSlugDeprecated:A}){let f=new g({domain:n,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await C(f,{organization:e,project:r,onSlugDeprecated:A}),M=await f.remotes.getDefaultBranch(d,l),p=await f.remotes.upsert(d,l,{mountBranchName:M,mountPath:s});_?.(p);let{id:P}=await f.remotes.push(d,l,{remoteId:p.id,commit:a,isMainBranch:i===a.branchName,replace:$},o.map(W=>({path:H(W.name),stream:y.createReadStream(W.path)})));return{pushId:P,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&v?.(d)}}function Ue(n,t){let e={};for(let s of n)if(y.statSync(s).isDirectory()){let o=s;ie(o,[]).forEach(a=>r(a,o))}else r(s,h.dirname(s));function r(s,o){let i=h.relative(o,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,o])=>({name:s,path:h.resolve(o)}))}function ie(n,t){let e=y.readdirSync(n);for(let r of e){let s=h.join(n,r);y.statSync(s).isDirectory()?t=ie(s,t):t.push(s)}return t}async function ae({operation:n,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:o=5e3}){async function i(){let a=await n();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await z(o),i()}return i()}var Fe=1200,Ae=5e3,Ie=["pending","running"];async function Ne(n){let t=ce(n);try{let e=await C(t,n);return await le(t,e,n.pushId)}finally{ue(t,n)}}async function je({buildType:n,maxExecutionTime:t=Fe,retryIntervalMs:e=Ae,startTime:r=Date.now(),onRetry:s,...o}){let i=ce(o);try{let a=await C(i,o);return await ae({operation:()=>le(i,a,o.pushId),condition:c=>!Ie.includes(c.status[n].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ue(i,o)}}function ce({domain:n,apiKey:t,version:e}){return new g({domain:n,apiKey:t,command:"push-status",version:e})}function ue(n,{onSunsetWarning:t}){let e=n.getSunsetWarning();e&&t?.(e)}function le(n,{organizationId:t,projectId:e},r){return n.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function De({projectUrl:n,auth:t,isApiKey:e=!1,onDebug:r}){let s=Oe(n);if(!s)throw new m(`Invalid project URL format: ${n}`);try{let o=await ke({...s,auth:t,isApiKey:e,onDebug:r}),i=o.config.scorecardClassic||o.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=o.config.pluginsUrl,c=a?await Le(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(o){throw new m(o instanceof Error?o.message:String(o))}}function Oe(n){let t=new URL(n),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:s}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:s}}async function ke({residency:n,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:o}){let i=new URL(`${n}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:Be(r,s)});if(o?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw o?.(`Authentication failed with status ${a.status}.`),o?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return o?.("Successfully received project configuration."),a.json()}async function Le(n,t){t?.(`Fetching plugins from: ${n}`);try{let e=await fetch(n);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function Be(n,t){return t?{Authorization:`Bearer ${n}`}:{Cookie:`accessToken=${n}`}}async function L(n,t,e=[],r=[],s){let o={};for(let i of e){let a={[i.name]:{root:n,rules:t}},c=await Y({apis:a,...i,plugins:r},{configPath:s});o[i.name]=c.forAlias(i.name)}return o}function B(n,t){if(n){for(let e of n)if(Object.entries(e.where?.metadata||{}).every(([s,o])=>Me(s,o,t)))return e}}function Me(n,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[n])return!1;let[r,s]=t.split("/"),o=new Date(e[n]);return!(o<new Date(r)||s&&o>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[n])return!1;try{return q(t).test(e[n])}catch{throw new m(`Invalid regex in scorecard target "${n}": ${t}`)}}return e[n]===t}import{pathToFileURL as We}from"node:url";async function be(n,t){if(!n)return[];let e=We(t??process.cwd()).href+"/",r=n.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var ze=".redocly.com";function He(n){try{return new URL(n).hostname.toLowerCase().endsWith(ze)}catch{return!1}}async function qe({apiPath:n,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:o=[],targetLevel:i,metadata:a={},onDebug:c}){let $=[],_=new Map,v=r.levels||[];if(i&&!v.some(l=>l.name===i))throw new m(`Target level "${i}" not found in the scorecard configuration levels.
8
8
  `);let A=B(r.targets,a)?.rules,f=await L(n,A,v,o,s||"");for(let l of v){c?.(`
9
9
  Validating level: "${l.name}"`),o.length>0&&c?.(`Using ${o.length} ${I("plugin",o.length)} for this level.`),c?.("Linting document against level rules...");let p=(await V({document:t,externalRefResolver:e,config:f[l.name]})).filter(({ignored:P})=>!P).map(P=>({...P,scorecardLevel:l.name}));c?.(`Found ${p.length} ${I("problem",p.length)} for level "${l.name}".`),_.set(l.name,p),$.push(...p)}let d=Ye(_,v,i);return{problems:$,achievedLevel:d,targetLevelAchieved:i?d===i:!0}}function Ye(n,t,e){let r=null;for(let s of t){if((n.get(s.name)||[]).some(a=>a.severity==="error"))return r||"Non Conformant";if(r=s.name,e&&s.name===e)return s.name}return r||"Non Conformant"}export{u as a,x as b,g as c,ee as d,fe as e,E as f,me as g,te as h,D as i,R as j,w as k,k as l,C as m,Se as n,Ue as o,Ne as p,je as q,De as r,L as s,B as t,be as u,He as v,qe as w};