@redocly/cli 2.51.0 → 2.51.2
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.
- package/THIRD_PARTY_NOTICES +2 -2
- package/lib/chunks/{3XSOTIDJ.js → 2QB2GQK4.js} +1 -1
- package/lib/chunks/57HELKSP.js +11 -0
- package/lib/chunks/5FCIOXHF.js +7 -0
- package/lib/chunks/75JBXLYL.js +7 -0
- package/lib/chunks/{65LLBIQA.js → ADW6GVRA.js} +1 -1
- package/lib/chunks/{IPFRJMV6.js → AEUD4DDQ.js} +1 -1
- package/lib/chunks/BFHO7GW5.js +97 -0
- package/lib/chunks/C2P2K3EL.js +7 -0
- package/lib/chunks/{TMULAWFD.js → CHYVBQIC.js} +1 -1
- package/lib/chunks/{3JJEI7CJ.js → CQMMUWIJ.js} +99 -95
- package/lib/chunks/{MXZKXUIJ.js → D2LIZR7C.js} +1 -1
- package/lib/chunks/{B3QINORT.js → D3EE6JIC.js} +1 -1
- package/lib/chunks/{QKWUIMTP.js → D6R7VN2E.js} +1 -1
- package/lib/chunks/DV6O45KM.js +20 -0
- package/lib/chunks/F2OX5CFF.js +7 -0
- package/lib/chunks/H7GBQYOQ.js +20 -0
- package/lib/chunks/{NSKVRJLY.js → HJBZSEOJ.js} +1 -1
- package/lib/chunks/{46OWJR6X.js → HTZLTEUF.js} +1 -1
- package/lib/chunks/{CA4BPC77.js → ITXYN4EV.js} +1 -1
- package/lib/chunks/{NWMTC4AN.js → IULINGO6.js} +1 -1
- package/lib/chunks/{TKFA7G4G.js → JGDGNU3W.js} +1 -1
- package/lib/chunks/{TSB6PODJ.js → JM7BMZLD.js} +1 -1
- package/lib/chunks/{NGC5R7OH.js → JW436AQL.js} +1 -1
- package/lib/chunks/LD5MEXEL.js +10 -0
- package/lib/chunks/{73NWWLM3.js → MA3DQUED.js} +1 -1
- package/lib/chunks/{4PT55VGO.js → NEUHMRVX.js} +3 -3
- package/lib/chunks/{MONT6PMR.js → OHIVXMXU.js} +1 -1
- package/lib/chunks/OHW62OX6.js +8 -0
- package/lib/chunks/{2OHNINBQ.js → ONCO376P.js} +1 -1
- package/lib/chunks/P6UQ46OM.js +20 -0
- package/lib/chunks/POEVQHCC.js +30 -0
- package/lib/chunks/QYUMGE2L.js +9 -0
- package/lib/chunks/{XOZ4UMDG.js → RBQSJMUA.js} +1 -1
- package/lib/chunks/SK7RTQX6.js +18 -0
- package/lib/chunks/T22N7JRE.js +7 -0
- package/lib/chunks/{NIH6ZKB3.js → TMUDD3AQ.js} +1 -1
- package/lib/chunks/{WPSBZRFR.js → UJ7OYRJC.js} +1 -1
- package/lib/chunks/{HJYFWIVE.js → UW4UC7ZI.js} +2 -2
- package/lib/chunks/{KF7NA4HQ.js → V3JDIYRX.js} +1 -1
- package/lib/chunks/{PFYPTG4G.js → VZNKVS6Q.js} +1 -1
- package/lib/chunks/W62WTKL6.js +67 -0
- package/lib/chunks/{HMPJ7TN6.js → W7NMFHT5.js} +1 -1
- package/lib/chunks/{KBGRTZ3S.js → WSWUTUN2.js} +1 -1
- package/lib/chunks/{N5SXQI4I.js → XA64NLCK.js} +1 -1
- package/lib/chunks/{62X4OKFV.js → YHUS4LA4.js} +1 -1
- package/lib/chunks/{SQYP47H6.js → YOD7FLHY.js} +1 -1
- package/lib/chunks/{OKMAGS7N.js → YUQGMTD4.js} +1 -1
- package/lib/chunks/{OZMIIHFH.js → ZMAMNQ5K.js} +95 -95
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +1 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +1 -1
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +1 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +1 -1
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +1 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +1 -1
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +1 -1
- package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/lib/eject-assets/generators/typescript/types.ts +1 -1
- package/lib/eject-assets/generators/zod/index.ts +2 -2
- package/lib/eject-assets/generators/zod/schemas.ts +1 -1
- package/lib/index.js +8 -8
- package/package.json +1 -1
- package/lib/chunks/2L3Z5JZA.js +0 -16
- package/lib/chunks/2WUJ57QA.js +0 -9
- package/lib/chunks/45LW7ZJ2.js +0 -7
- package/lib/chunks/77VEOG4O.js +0 -57
- package/lib/chunks/7ZC3TNBP.js +0 -14
- package/lib/chunks/AQT2EJZS.js +0 -177
- package/lib/chunks/BFGFT7E3.js +0 -90
- package/lib/chunks/EOS3ZB2L.js +0 -8
- package/lib/chunks/ESNPHQEK.js +0 -93
- package/lib/chunks/FJAJ4RIU.js +0 -20
- package/lib/chunks/FVKTV62N.js +0 -20
- package/lib/chunks/KNLINRO4.js +0 -19
- package/lib/chunks/L3TZNNJJ.js +0 -13
- package/lib/chunks/L4GUU6OS.js +0 -7
- package/lib/chunks/MSRZMIR7.js +0 -22
- package/lib/chunks/NAGDQV7J.js +0 -11
- package/lib/chunks/NB54XRRU.js +0 -10
- package/lib/chunks/NSIQWNYL.js +0 -7
- package/lib/chunks/OOLLHPWT.js +0 -18
- package/lib/chunks/P37B4DI4.js +0 -42
- package/lib/chunks/QPW3IML7.js +0 -26
- package/lib/chunks/REFX2EKS.js +0 -13
- package/lib/chunks/SGBB4RNM.js +0 -11
- package/lib/chunks/SQVG3CEM.js +0 -8
- package/lib/chunks/U6E22USS.js +0 -14
- package/lib/chunks/ULV3D265.js +0 -19
- package/lib/chunks/V4SBON7Y.js +0 -7
- package/lib/chunks/X3MZMREJ.js +0 -7
- package/lib/chunks/XWZNQKXF.js +0 -30
- package/lib/chunks/YEK532UO.js +0 -67
- package/lib/chunks/ZBL4IVEW.js +0 -11
- /package/lib/chunks/{UKSQ7B5H.js → 2U6O26CV.js} +0 -0
package/lib/chunks/QPW3IML7.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as Me}from"./73NWWLM3.js";import{d as Ke,e as Ue,f as Fe}from"./ULV3D265.js";import{c as Be,d as He,e as Ge}from"./FVKTV62N.js";import{a as h}from"./WZXA5XPB.js";import{a as kn,b as Ce,c as Se,d as Ae}from"./KBGRTZ3S.js";import{c as Ee,d as Te,e as qe}from"./U6E22USS.js";import{a as $}from"./MONT6PMR.js";import{a as Pe,b as xn,c as On,d as Ie,e as $e,f as je}from"./BFGFT7E3.js";import{a as Ne}from"./46OWJR6X.js";import{a as De}from"./TSB6PODJ.js";import{a as Le}from"./NIH6ZKB3.js";import"./SQVG3CEM.js";import"./REFX2EKS.js";import"./NSIQWNYL.js";import"./UKSQ7B5H.js";import"./2WUJ57QA.js";import"./XWZNQKXF.js";import"./NAGDQV7J.js";import{g as Re}from"./4PT55VGO.js";import"./PFYPTG4G.js";import{C as we,H as ve,V as w,X as ke,aa as xe,c as O,ca as _,ja as Oe,q as R,s as be}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";function M(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./3XSOTIDJ.js").then(n=>({run:n.tanstackQueryGenerator(e)}))}}var z={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("./V4SBON7Y.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./NGC5R7OH.js").then(e=>({run:e.zodGenerator}))},transformers:{requires:["typescript"],dateTypes:["Date"],load:()=>import("./NWMTC4AN.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("./XOZ4UMDG.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./SQYP47H6.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./62X4OKFV.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:z,load:()=>import("./X3MZMREJ.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:z,load:()=>import("./L4GUU6OS.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:z,load:()=>import("./45LW7ZJ2.js").then(e=>({run:e.phpGenerator,sample:e.phpSample,docs:e.phpDocs}))}};function K(e,n,t,r){let s=new Set(e);n.goPackage!==void 0&&!s.has("go")&&w.warn(`generate-client: goPackage is ignored \u2014 it declares the Go package clause, and no selected generator uses it (add --generator go).
|
|
8
|
-
`);let o=n.errorMode??"throw",a=n.dateType??"string";for(let i of e){let d=t.get(i);if(!d)throw new h(`Unknown generator: ${i}`);for(let c of d.requires??[])if(!s.has(c)){let u=[...new Set([c,...e])].map(g=>`--generator ${g}`).join(" ");throw new h(`The "${i}" generator requires the "${c}" generator. Add it, e.g. ${u}.`)}if(d.errorModes&&!d.errorModes.includes(o))throw new h(`The "${i}" generator does not support --error-mode "${o}" (supported: ${d.errorModes.join(", ")}).`);if(d.dateTypes&&!d.dateTypes.includes(a))throw new h(`The "${i}" generator requires --date-type ${d.dateTypes.join(" or ")} (got "${a}") so the runtime values match the generated types.`);let l={...n,outputMode:r};for(let[c,u]of Object.entries(d.notApplicable??{}))l[c]!==void 0&&w.warn(`generate-client: the "${i}" generator ignores ${c} \u2014 ${u}.
|
|
9
|
-
`)}}var Rn={typescript:{run:Ie,sample:je,docs:$e},zod:{run:Ne},transformers:{run:De},"tanstack-query":{run:$("react")},"tanstack-query-vue":{run:$("vue")},"tanstack-query-svelte":{run:$("svelte")},"tanstack-query-solid":{run:$("solid")},swr:{run:Le},mock:{run:Me},cli:{run:Ce,sample:Ae,docs:Se},python:{run:Ke,sample:Ue,docs:Fe},go:{run:Ee,sample:Te,docs:qe},php:{run:Be,sample:He,docs:Ge}},Cn=Object.fromEntries(Object.entries(I).map(([e,{load:n,...t}])=>[e,{...t,...Rn[e]}]));function W(){return new Map(Object.entries(Cn))}function _e(e,n,t=W(),r){K(e,n,t,r)}import{mkdir as Ct,readFile as St,writeFile as At}from"node:fs/promises";import{dirname as vn,parse as Et,resolve as G,sep as Tt}from"node:path";function ze(e,n,t){let r=new Map;for(let s of e){let o=n.get(s)?.options,a=t?.[s];if(o===void 0){a!==void 0&&w.warn(`generate-client: the "${s}" generator declares no options, so client.options.${s} is ignored.
|
|
10
|
-
`),r.set(s,{});continue}r.set(s,Sn(s,o,a))}return r}function Sn(e,n,t){if(t!==void 0&&!O(t))throw new h(`The "${e}" generator's options must be a map of option names to values.`);let r=t??{},s=Object.keys(n.properties);if(n.additionalProperties!==!0){for(let a of Object.keys(r))if(!s.includes(a))throw new h(`The "${e}" generator got an unknown option "${a}". Declared options: ${s.join(", ")||"(none)"}.`)}for(let a of n.required??[])if(r[a]===void 0)throw new h(`The "${e}" generator requires the "${a}" option.`);let o={...r};for(let[a,i]of Object.entries(n.properties)){if(o[a]===void 0){i.default!==void 0&&(o[a]=i.default);continue}let d=An(i,o[a]);if(d!==void 0)throw new h(`The "${e}" generator's "${a}" ${d}.`)}return o}function An(e,n){if("enum"in e)return e.enum.includes(n)?void 0:`must be one of: ${e.enum.join(", ")}`;if(e.type==="array"){let t=e.items.type;return Array.isArray(n)&&n.every(r=>typeof r===t)?void 0:`must be an array of ${t}`}return typeof n===e.type?void 0:`must be a ${e.type}`}import{isAbsolute as Tn,resolve as qn}from"node:path";import{pathToFileURL as Pn}from"node:url";var V=Re.version;function We(e){let n=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());return n===null?void 0:[Number(n[1]),Number(n[2]),Number(n[3])]}function J(e,n){return e[0]-n[0]||e[1]-n[1]||e[2]-n[2]}function Je(e,n){let t=/^[\^~]|^>=/.exec(n.trim())?.[0]??"",r=We(n.trim().slice(t.length)),s=We(e);if(!(r===void 0||s===void 0))return J(s,r)<0?!1:t===">="?!0:t===""?J(s,r)===0:t==="~"?s[0]===r[0]&&s[1]===r[1]:r[0]!==0?s[0]===r[0]:r[1]!==0?s[0]===0&&s[1]===r[1]:J(s,r)===0}var En=function(e,n){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(t,r,s,o,a){return r?n?".jsx":".js":s&&(!o||!a)?t:s+o+"."+a.toLowerCase()+"js"}):e};async function Qe(e,n={}){let t=new Map;for(let i of n.customGenerators??[])Xe(t,i);let r=[];for(let i of e)r.push(await Ve(i,t,n.configDir));let s=[],o=new Set,a=async i=>{if(!(s.includes(i)||o.has(i))){o.add(i);for(let d of t.get(i).requires??[])(t.has(d)||d in I)&&await a(await Ve(d,t,n.configDir));o.delete(i),s.push(i)}};for(let i of r)await a(i);return{selected:s,registry:t}}async function Ve(e,n,t){if(n.has(e))return e;let r=I[e];if(r!==void 0){let{load:o,...a}=r;return n.set(e,{...a,...await o()}),e}if(e==="sdk")throw new h('The "sdk" generator is now named "typescript". Update the `generators` list or the --generator flag.');let s=await In(e,t??process.cwd());return Xe(n,s),s.name}function Xe(e,n){if(!O(n)||typeof n.name!="string"||n.name===""||typeof n.run!="function")throw new h("Invalid custom generator: expected an object with a non-empty string `name` and a `run` function (build one with `defineGenerator`).");if(e.has(n.name))throw new h(`Generator name "${n.name}" collides with an existing generator. Rename the custom generator.`);if(n.requiresGenerator!==void 0){let t=Je(V,n.requiresGenerator);if(t===void 0)throw new h(`Generator "${n.name}" declares requiresGenerator "${n.requiresGenerator}", which is not a range we read. Use ^1.2.0, ~1.2.0, >=1.2.0, or an exact version.`);if(!t)throw new h(`Generator "${n.name}" needs @redocly/client-generator ${n.requiresGenerator}; this CLI ships ${V}. 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.`)}n.name in I&&w.warn(`generate-client: custom generator "${n.name}" takes over the built-in generator of the same name.
|
|
11
|
-
`),e.set(n.name,{run:n.run,sample:n.sample,docs:n.docs,notApplicable:n.notApplicable,options:n.options,requires:n.requires,errorModes:n.errorModes,dateTypes:n.dateTypes})}async function In(e,n){if(be(e))throw new h(`Remote generator modules are not supported \u2014 use a local path or a package name. Got: ${e}`);let t=e.startsWith(".")||Tn(e),r=t?Pn(qn(n,e)).href:e;if(t&&e.endsWith(".ts")&&!process.features.typescript)throw new h(`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(En(r))}catch(a){throw new h(`Could not load generator "${e}": ${a.message}`)}let o=s.default??s.generator;if(o===void 0)throw new h(`Generator module "${e}" must export a generator (a default export or a \`generator\` export built with \`defineGenerator\`).`);return o}function U(e){return e.replace(/^\+(?=\d)/,"plus ").replace(/^-(?=\d)/,"minus ").replace(/([A-Z]{2,})s(?![a-z])/g,"$1S").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(n=>n!=="").map(n=>n.toLowerCase())}var Ye=e=>e.charAt(0).toUpperCase()+e.slice(1),j={camel:e=>{let[n,...t]=U(e);return(n??"")+t.map(Ye).join("")},pascal:e=>U(e).map(Ye).join(""),snake:e=>U(e).join("_"),screaming:e=>U(e).join("_").toUpperCase()},Q={typescript:new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","implements","interface","let","package","private","protected","public","static","yield","await"]),python:new Set(["false","none","true","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","match","case","type"]),go:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"]),php:new Set(["abstract","and","array","as","break","callable","case","catch","class","clone","const","continue","declare","default","die","do","echo","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","exit","extends","final","finally","fn","for","foreach","function","global","goto","if","implements","include","instanceof","insteadof","interface","isset","list","match","namespace","new","or","print","private","protected","public","readonly","require","return","static","switch","throw","trait","try","unset","use","var","while","xor","yield","true","false","null","int","float","bool","string","void","iterable","object","mixed","never","self","parent"])};function Ze(e,n={}){let t=j[n.style??"camel"](e),r=t===""?"_":/^[0-9]/.test(t)?`_${t}`:t;return n.reserved?.has(r.toLowerCase())?`${r}_`:r}function X(e,n={}){let t=new Set(n.taken??[]),r=n.style==="snake"||n.style==="screaming"?"_":"";return e.map(s=>{let o=Ze(s,n),a=o;for(let i=2;t.has(a);i++)a=`${o}${r}${i}`;return t.add(a),a})}var N=class{indentUnit;lines=[];depth=0;constructor(n=" "){this.indentUnit=n}line(n=""){return this.lines.push(n===""?"":this.indentUnit.repeat(this.depth)+n),this}blank(){return this.line()}indent(n){return this.depth++,n(),this.depth--,this}block(n,t,r){return this.line(n),this.indent(t),r===void 0?this:this.line(r)}toString(){return this.lines.join(`
|
|
12
|
-
`)+`
|
|
13
|
-
`}};function A(e,n){let t=new Set,r=e;for(;r.kind==="ref";){let{name:s}=r;if(t.has(s))return;t.add(s);let o=n.schemas.find(a=>a.name===s);if(o===void 0)return;r=o.schema}return r}function en(e,n){let t=A(e,n);if(t===void 0)return;if(t.kind==="object")return{properties:t.properties,description:t.description};if(t.kind!=="intersection")return;let r=new Map;for(let s of t.members){let o=en(s,n);if(o===void 0)return;for(let a of o.properties)r.set(a.name,a)}return{properties:[...r.values()],description:t.description}}function $n(e,n){let t=A(e,n);if(t?.kind!=="union"||t.discriminator===void 0)return;let r=[];for(let{value:s,schemaName:o}of t.discriminator.mapping){let a=A({kind:"ref",name:o},n);if(a===void 0)return;r.push({value:s,schemaName:o,schema:a})}return{property:t.discriminator.propertyName,cases:r}}function nn(e){return e.kind==="union"&&e.members.some(n=>n.kind==="null")}function jn(e){if(e.kind!=="union"||!nn(e))return e;let n=e.members.filter(t=>t.kind!=="null");return n.length===1?n[0]:{...e,members:n}}function Nn(e){if(e.kind!=="enum")return;let n=X(e.values.map(t=>typeof t=="string"?j.screaming(t):`VALUE_${j.screaming(String(t))}`),{style:"screaming"});return{values:e.values,scalar:e.scalar,memberNames:n}}function Dn(e){if(!e)return[];let n=e.split(/\r\n|\n|\r/).map(t=>t.trim());for(;n.length>0&&n[0]==="";)n.shift();for(;n.length>0&&n[n.length-1]==="";)n.pop();return n}function tn(e,n,t){if(e.kind==="object")return e.properties.find(r=>r.name===n)?.schema;if(e.kind==="record")return e.value;if(e.kind==="array"&&/^(0|[1-9]\d*)$/.test(n))return e.items;if(e.kind==="intersection"){let r;for(let s of e.members){let o=A(s,t);o!==void 0&&(r=tn(o,n,t)??r)}return r}}function E(e,n,t){let r=A(e,t);if(!(r===void 0||n!==""&&!n.startsWith("/"))){if(n==="")return r;for(let s of n.slice(1).split("/")){let o=s.replaceAll("~1","/").replaceAll("~0","~"),a=tn(r,o,t);if(a===void 0||(r=A(a,t),r===void 0))return}return r}}function D(e,n,t=new Set){if(e.kind==="ref"){if(t.has(e.name))return"string";t.add(e.name);let r=n.schemas.find(s=>s.name===e.name);return r===void 0?"string":D(r.schema,n,t)}if(e.kind==="intersection"){let r=e.members.filter(o=>o.kind!=="unknown");if(r.length===1)return D(r[0],n,t);let s=[...new Set(r.map(o=>D(o,n,new Set(t))))];return s.length===1?s[0]:s.every(o=>o==="integer"||o==="number")?"number":"string"}if(e.kind==="union"){let r=e.members.filter(s=>s.kind!=="null");return r.length===1?D(r[0],n,t):"string"}if(e.kind==="scalar"||e.kind==="enum"){if(e.scalar==="integer")return"integer";if(e.scalar==="number")return"number";if(e.scalar==="boolean")return"boolean"}if(e.kind==="literal"){if(typeof e.value=="number")return Number.isInteger(e.value)?"integer":"number";if(typeof e.value=="boolean")return"boolean"}return"string"}var ee=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ne=Q.typescript;function Ln(e){return ee.test(e)}function F(e){return ee.test(e)&&!ne.has(e)}function te(e){let n=e.replace(/[^A-Za-z0-9_$]/g,"_");return(n===""||/^[0-9]/.test(n)||ne.has(n))&&(n=`_${n}`),n}var Mn={"<":"\\u003C",">":"\\u003E","\u2028":"\\u2028","\u2029":"\\u2029"};function Y(e){return JSON.stringify(e).replace(/[<>\u2028\u2029]/g,n=>Mn[n])}function Kn(e){return ee.test(e)&&!ne.has(e)?e:Y(e)}function Z(e){if(typeof e=="string")return Y(e);if(typeof e=="boolean"||e===null||typeof e=="number")return String(e);if(Array.isArray(e))return`[${e.map(Z).join(", ")}]`;let n=Object.entries(e).map(([t,r])=>`${Ln(t)?t:Y(t)}: ${Z(r)}`);return n.length===0?"{}":`{ ${n.join(", ")} }`}function B(e){return e[0].toUpperCase()+e.slice(1)}var rn=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var Un=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],Fn=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],Bn=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],re;function on(){return re===void 0&&(re=new Set([...Un,...Fn,...Bn,...rn])),re}function dn(e){let n=new Set,t=new Set,r=new Map;for(let p of e.securitySchemes){let m=oe(p.key,n,t);m!==p.key&&(r.set(p.key,m),ae("security scheme",p.key,m,an(p.key,n)),p.key=m)}let s=new Set(on()),o=new Set(s),a=new Set,i=new Map;for(let p of e.schemas){let m=oe(p.name,o,a);m!==p.name&&(i.set(p.name,m),ae("schema",p.name,m,an(p.name,s)),p.name=m)}let d=p=>i.get(p)??sn(p),l=p=>r.get(p)??sn(p);for(let p of e.schemas)v(p.schema,d);let c=new Set(o),u=new Set,g=new Set;for(let p of e.services)for(let m of p.operations){let f=g.has(m.name);g.add(m.name);let y=m.name,P=oe(m.name,c,u);if(P!==m.name){let x=f?{kind:"duplicate-operation-id"}:s.has(y)?{kind:"reserved"}:o.has(y)?{kind:"schema-collision"}:{kind:"unusable"};ae("operation",y,P,x),m.specName=m.name,m.name=P}Hn(m,d),m.security=m.security.map(x=>x.map(l))}}function oe(e,n,t){let r=te(e),s=r,o=2;for(;n.has(s)||t.has(B(s));)s=`${r}_${o++}`;return n.add(s),t.add(B(s)),s}function ln(e){for(let n of e.schemas)if(!F(n.name))throw se("schema",n.name);for(let n of e.securitySchemes)if(!F(n.key))throw se("security scheme",n.key);for(let n of e.services)for(let t of n.operations)if(!F(t.name))throw se("operation",t.name)}function se(e,n){return new Error(`Internal error: ${e} name ${JSON.stringify(n)} is not a safe identifier after sanitization.`)}function sn(e){return te(e)}function ae(e,n,t,r){let s=JSON.stringify(n),o=JSON.stringify(t),a=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}`;w.warn(`generate-client: ${a}.
|
|
14
|
-
`)}function an(e,n){return n.has(e)?{kind:"reserved"}:{kind:"unusable"}}function v(e,n){switch(e.kind){case"ref":e.name=n(e.name);break;case"omit":e.base=n(e.base);break;case"array":v(e.items,n);break;case"record":v(e.value,n);break;case"object":for(let t of e.properties)v(t.schema,n);break;case"union":for(let t of e.members)v(t,n);if(e.discriminator)for(let t of e.discriminator.mapping)t.schemaName=n(t.schemaName);break;case"intersection":for(let t of e.members)v(t,n);break}}function Hn(e,n){for(let t of e.pathParams)v(t.schema,n);for(let t of e.queryParams)v(t.schema,n);for(let t of e.headerParams)v(t.schema,n);for(let t of e.cookieParams)v(t.schema,n);e.requestBody&&v(e.requestBody.schema,n);for(let t of[...e.successResponses,...e.errorResponses])v(t.schema,n),t.itemSchema&&v(t.itemSchema,n)}var Gn=["get","post","put","delete","patch","head","options"];function pn(e,n){if(!n.startsWith("#/"))throw new h(`External $ref not supported: ${n}`);let t=n.slice(2).split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~")),r=e;for(let s of t){if(!O(r)&&!Array.isArray(r))throw new h(`Cannot resolve $ref: ${n}`);r=r[s]}if(r===void 0)throw new h(`Cannot resolve $ref: ${n}`);return r}function C(e,n){return R(n)?pn(e,n.$ref):n}function L(e){let n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e}function _n(e){let n=e,t={};return typeof n.minimum=="number"&&(t.minimum=n.minimum),typeof n.maximum=="number"&&(t.maximum=n.maximum),typeof n.exclusiveMinimum=="number"?t.exclusiveMinimum=n.exclusiveMinimum:n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t.exclusiveMinimum=n.minimum,delete t.minimum),typeof n.exclusiveMaximum=="number"?t.exclusiveMaximum=n.exclusiveMaximum:n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t.exclusiveMaximum=n.maximum,delete t.maximum),typeof n.minLength=="number"&&(t.minLength=n.minLength),typeof n.maxLength=="number"&&(t.maxLength=n.maxLength),typeof n.pattern=="string"&&(t.pattern=n.pattern),typeof n.minItems=="number"&&(t.minItems=n.minItems),typeof n.maxItems=="number"&&(t.maxItems=n.maxItems),n.uniqueItems===!0&&(t.uniqueItems=!0),typeof n.format=="string"&&(t.format=n.format),n.deprecated===!0&&(t.deprecated=!0),n.example!==void 0?t.example=n.example:Array.isArray(n.examples)&&n.examples.length>0&&(t.example=n.examples[0]),n.default!==void 0&&(t.default=n.default),Object.keys(t).length>0?t:void 0}function zn(e,n){let t=e.discriminator;if(!t||typeof t.propertyName!="string")return;let r=[];if(t.mapping)for(let[s,o]of Object.entries(t.mapping))r.push({value:s,schemaName:L(o)});else for(let s of n)if(R(s)){let o=L(s.$ref);r.push({value:o,schemaName:o})}if(r.length!==0)return{propertyName:t.propertyName,mapping:r}}function k(e,n){return n?{...e,metadata:n}:e}function ie(e,n){return e?n?{...e,...n}:e:n}function Wn(e){return e?e.url.replace(/\{([^{}]+)\}/g,(n,t)=>e.variables?.[t]?.default??n):""}function un(e){let n=e.info?.title??"Api",t=e.info?.version??"0.0.0",r=e.info?.description,s=Wn(e.servers?.[0]),o=(e.servers??[]).map(c=>({url:c.url,description:c.description,variables:Object.entries(c.variables??{}).map(([u,g])=>({name:u,default:g.default,description:g.description}))})),a=et(e),i=Yn(e),d=nt(e,i),l={title:n,version:t,description:r,serverUrl:s,servers:o,services:d,schemas:a,securitySchemes:i};return dn(l),Jn(d,a),ln(l),l}function Jn(e,n){let t=new Map(n.map(r=>[r.name,r.schema]));for(let r of e)for(let s of r.operations)s.requestBody&&(s.requestBody.schema=Qn(s.requestBody.schema,t))}function Vn(e){let n=e.filter(t=>t.kind!=="unknown");return n.length>0?n:[{kind:"unknown"}]}function Qn(e,n){if(e.kind==="ref"){let t=Xn(e,n,new Set);return t.length>0?{kind:"omit",base:e.name,keys:t}:e}if(e.kind==="object"){let t=e.properties.filter(r=>!r.readOnly);return t.length===e.properties.length?e:{...e,properties:t}}return e}function Xn(e,n,t){let r=[],s=o=>{if(o.kind==="ref"){if(t.has(o.name))return;t.add(o.name);let a=n.get(o.name);a&&s(a)}else if(o.kind==="object")for(let a of o.properties)a.readOnly&&!r.includes(a.name)&&r.push(a.name);else if(o.kind==="intersection")for(let a of o.members)s(a)};return s(e),r}function Yn(e){let n=e.components?.securitySchemes;if(!n)return[];let t=[];for(let[r,s]of Object.entries(n)){let o=C(e,s),a=o.type;a==="oauth2"||a==="openIdConnect"?t.push({kind:"bearer",key:r}):a==="http"&&(o.scheme??"").toLowerCase()==="bearer"?t.push({kind:"bearer",key:r}):a==="http"&&(o.scheme??"").toLowerCase()==="basic"?t.push({kind:"basic",key:r}):a==="apiKey"&&o.in==="header"&&typeof o.name=="string"?t.push({kind:"apiKeyHeader",key:r,headerName:o.name}):a==="apiKey"&&o.in==="query"&&typeof o.name=="string"?t.push({kind:"apiKeyQuery",key:r,paramName:o.name}):a==="apiKey"&&o.in==="cookie"&&typeof o.name=="string"&&(w.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.
|
|
15
|
-
`),t.push({kind:"apiKeyCookie",key:r,cookieName:o.name}))}return t}function Zn(e,n,t){let r=e.security??n.security;if(!r)return[];let s=[];for(let o of r){let a=Object.keys(o);a.length!==0&&a.every(i=>t.has(i))&&s.push([...new Set(a)])}return s}function et(e){let n=e.components?.schemas;return n?Object.entries(n).map(([t,r])=>{if(R(r)){let o=pn(e,r.$ref);return{name:t,schema:T(o,`components.schemas.${t}`,e),description:o.description}}let s=T(r,`components.schemas.${t}`,e);return{name:t,schema:s,description:r.description}}):[]}function nt(e,n){let t=new Set(n.map(a=>a.key)),r=[],s=new Set;for(let[a,i]of Object.entries(e.paths??{})){if(!i)continue;let d=C(e,i),l=(d.parameters??[]).map(c=>mn(C(e,c),`paths.${a}.parameters`,e));for(let c of Gn){let u=d[c];u&&(r.push({method:c,path:a,operation:u,pathLevelParams:l}),u.operationId&&s.add(u.operationId))}}return[{name:"Default",operations:r.map(a=>{let i=a.operation.operationId??ot(tt(a.method,a.path),s);return st(a.method,a.path,a.operation,i,a.pathLevelParams,e,t)})}]}function tt(e,n){let t=n.split("/").filter(Boolean).map(r=>rt(r.replace(/[{}]/g,"")));return`${e}${t.join("")}`}function rt(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function ot(e,n){let t=e,r=2;for(;n.has(t);)t=`${e}${r++}`;return n.add(t),t}function st(e,n,t,r,s,o,a){let i=(t.parameters??[]).map(b=>mn(C(o,b),`paths.${n}.${e}.parameters`,o)),d=new Set,l=[];for(let b of i)d.add(`${b.in}:${b.name}`),l.push(b);for(let b of s)d.has(`${b.in}:${b.name}`)||l.push(b);let c=l.filter(b=>b.in==="path"),u=l.filter(b=>b.in==="query"),g=l.filter(b=>b.in==="header"),p=l.filter(b=>b.in==="cookie"),m=t.requestBody?it(C(o,t.requestBody),`${e} ${n}`,o):void 0,{successResponses:f,successResponseHeaders:y}=dt(t,n,o),P=ct(t,n,o),x=Zn(t,o,a),he=t["x-redoclyPagination"],ye=at(f);return{name:r,method:e,path:n,summary:t.summary,description:t.description,pathParams:c,queryParams:u,headerParams:g,cookieParams:p,requestBody:m,successResponses:f,...y===void 0?{}:{successResponseHeaders:y},errorResponses:P,security:x,tags:Array.isArray(t.tags)?t.tags.filter(b=>typeof b=="string"):[],...he!==void 0?{paginationExtension:he}:{},...ye===void 0?{}:{sse:ye}}}function at(e){let n=e.find(s=>s.contentType.split(";")[0].trim().toLowerCase()==="text/event-stream");if(n===void 0)return;let t=n.itemSchema&&n.itemSchema.kind!=="unknown"?n.itemSchema:n.schema.kind!=="unknown"?n.schema:void 0;if(t===void 0)return{dataKind:"text"};let r=t.kind==="object"||t.kind==="ref"||t.kind==="array"||t.kind==="record"||t.kind==="union"||t.kind==="intersection";return{eventSchema:t,dataKind:r?"json":"text"}}function mn(e,n,t){if(!e.in)throw new h(`Parameter ${e.name} at ${n} is missing "in"`);if(!["path","query","header","cookie"].includes(e.in))throw new h(`Unsupported parameter location "${e.in}" for ${e.name} at ${n}`);let r=S(e.schema,`${n}.${e.name}`,t);e.deprecated===!0&&(r={...r,metadata:ie(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 it(e,n,t){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(i=>r[i]===s),a=S(s.schema,`${n}.requestBody`,t);return{contentType:o,schema:a,required:!!e.required,description:e.description}}function dt(e,n,t){let r=e.responses??{},s=Object.keys(r).filter(g=>/^2\d\d$/.test(g));s.length===0&&(r["2XX"]?s.push("2XX"):r.default&&s.push("default"));let o=s[0];if(!o)return{successResponses:[]};let a=r[o];if(!a)return{successResponses:[]};let i=C(t,a),d=lt(i.headers,`paths.${n}.response.${o}`,t),l=i.content;if(!l)return{successResponses:[],...d===void 0?{}:{successResponseHeaders:d}};let c=o==="default"||o==="2XX"?o:Number(o),u=[];for(let[g,p]of Object.entries(l)){let m=S(p.schema,`paths.${n}.response.${o}.${g}`,t),f=p.itemSchema,y=f!==void 0?S(f,`paths.${n}.response.${o}.${g}.itemSchema`,t):void 0;u.push({contentType:g,schema:m,status:c,...y===void 0?{}:{itemSchema:y}})}return{successResponses:u,...d===void 0?{}:{successResponseHeaders:d}}}function lt(e,n,t){if(!e)return;let r=[];for(let[s,o]of Object.entries(e)){let a=C(t,o),i={name:s.toLowerCase(),schema:S(a.schema===void 0?void 0:C(t,a.schema),`${n}.headers.${s}`,t)};a.required===!0&&(i.required=!0),r.push(i)}return r.length>0?r:void 0}function ct(e,n,t){let r=e.responses??{},s=Object.keys(r).filter(i=>/^([45]\d\d|4XX|5XX)$/.test(i));Object.keys(r).some(i=>/^(2\d\d|2XX)$/.test(i))&&r.default&&s.push("default");let a=[];for(let i of s){let d=r[i];if(!d)continue;let c=C(t,d).content;if(!c)continue;let u=i==="default"||i==="4XX"||i==="5XX"?i:Number(i);for(let[g,p]of Object.entries(c)){let m=S(p.schema,`paths.${n}.response.${i}.${g}`,t);a.push({contentType:g,schema:m,status:u})}}return a}function S(e,n,t){return e===void 0||typeof e=="boolean"?{kind:"unknown"}:R(e)?{kind:"ref",name:L(e.$ref)}:T(e,n,t)}function T(e,n,t){let r=_n(e),s=e.oneOf??e.anyOf;if(s){let i=s.map((c,u)=>R(c)?{kind:"ref",name:L(c.$ref)}:T(c,`${n}.[${u}]`,t)),d=Vn(i);if(d.length===1&&d.length<i.length){let c=d[0];return{...c,description:c.description??e.description,metadata:ie(r,c.metadata)}}let l=zn(e,s);return k({kind:"union",members:d,discriminator:l,description:e.description},r)}if(e.allOf){let i=e.allOf.map((l,c)=>R(l)?{kind:"ref",name:L(l.$ref)}:T(l,`${n}.allOf[${c}]`,t)),d=cn(e,n,t);if(d.length>0&&i.unshift({kind:"object",properties:d}),i.length===1){let l=i[0];return{...l,description:l.description??e.description,metadata:ie(r,l.metadata)}}return k({kind:"intersection",members:i,description:e.description},r)}let o=e.type;if(Array.isArray(o)){let i=o.filter(c=>c!=="null"),d=o.includes("null"),l=i.map(c=>{let u={...e,type:c};if(Array.isArray(u.enum)){let g=u.enum.filter(p=>p!==null);u.enum=g.length>0?g:void 0}return T(u,n,t)});return d&&l.push({kind:"null"}),l.length===1?l[0]:k({kind:"union",members:l,description:e.description},r)}if(e.nullable)return{kind:"union",members:[T({...e,nullable:void 0},n,t),{kind:"null"}],description:e.description};if(e.const!==void 0){let i=e.const;if(typeof i!="string"&&typeof i!="number"&&typeof i!="boolean")throw new h(`Unsupported const value at ${n}: ${JSON.stringify(i)}`);return k({kind:"literal",value:i,description:e.description},r)}if(e.enum){let i=e.enum,d=i.filter(g=>g!==null),l=d.length!==i.length;if(d.length===0)return k({kind:"null",description:e.description},r);let c=pt(d,n),u=c==="boolean"?{kind:"scalar",scalar:"boolean",description:e.description}:{kind:"enum",values:d,scalar:c,description:e.description};return k(l?{kind:"union",members:[u,{kind:"null"}],description:e.description}:u,r)}let a=o;if(a==="null")return k({kind:"null",description:e.description},r);if(a==="array"){let i=e.items,d=S(i,`${n}.items`,t);return k({kind:"array",items:d,description:e.description},r)}if(a==="object"||e.properties||e.additionalProperties){let i=cn(e,n,t),d=e.additionalProperties;if(i.length===0&&d!==!1){let l=S(d,`${n}.additionalProperties`,t);return k({kind:"record",value:l,description:e.description},r)}return k({kind:"object",properties:i,description:e.description},r)}return k(a==="string"||a==="number"||a==="integer"||a==="boolean"?{kind:"scalar",scalar:a,description:e.description}:{kind:"unknown",description:e.description},r)}function pt(e,n){let t=!1,r=!1,s=!1;for(let o of e)if(typeof o=="string")t=!0;else if(typeof o=="number")r=!0;else if(typeof o=="boolean")s=!0;else throw new h(`Unsupported enum value type at ${n}: ${JSON.stringify(o)}`);return t&&!r&&!s?"string":r&&!t&&!s?"number":s&&!t&&!r?"boolean":"string"}function ut(e){return!(e.openapi??"").startsWith("3.0")}function cn(e,n,t){let r=e.properties??{},s=new Set(e.required??[]),o=ut(t);return Object.entries(r).map(([a,i])=>{let d=i.readOnly===!0;d&&R(i)&&!o&&w.warn(`generate-client: "${a}" declares readOnly beside a $ref, which OpenAPI ${t.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.
|
|
16
|
-
`);let l=d&&(o||!R(i));return{name:a,schema:S(i,`${n}.${a}`,t),required:s.has(a),description:i.description,...l?{readOnly:!0}:{}}})}function H(e){return e.flatMap(n=>n.operations)}function fn(e){let n=de(e),t={...n};delete t.swagger,delete t.host,delete t.basePath,delete t.schemes,delete t.definitions,delete t.securityDefinitions,delete t.consumes,delete t.produces,delete t.parameters,delete t.responses,t.openapi="3.0.3";let r=mt(n);return r&&(t.servers=r),t.components=ft(n),t.paths=bt(n.paths??{},n.consumes??void 0,n.produces??void 0),t}function mt(e){let n=e.host,t=e.basePath??"",r=(e.schemes??["https"])[0]??"https";if(n)return[{url:`${r}://${n}${t}`}]}function ft(e){let n={};e.definitions&&(n.schemas=e.definitions),e.parameters&&(n.parameters=Object.fromEntries(Object.entries(e.parameters).map(([r,s])=>[r,le(s)]))),e.responses&&(n.responses=hn(e.responses,void 0));let t=e.securityDefinitions;if(t){let r={};for(let[s,o]of Object.entries(t))r[s]=gt(o);n.securitySchemes=r}return n}function gt(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 n=e.flow==="accessCode"?"authorizationCode":e.flow==="application"?"clientCredentials":e.flow,t={scopes:e.scopes??{}};return e.authorizationUrl&&(t.authorizationUrl=e.authorizationUrl),e.tokenUrl&&(t.tokenUrl=e.tokenUrl),{type:"oauth2",flows:{[n]:t}}}default:return e}}function de(e){if(Array.isArray(e))return e.map(de);if(O(e)){let n={};for(let[t,r]of Object.entries(e))t==="$ref"&&typeof r=="string"?n.$ref=r.replace("#/definitions/","#/components/schemas/").replace("#/parameters/","#/components/parameters/").replace("#/responses/","#/components/responses/"):n[t]=de(r);return n}return e}var ht="application/json",yt="application/json",gn=new Set(["name","in","required","description","deprecated","allowEmptyValue","collectionFormat"]);function bt(e,n,t){let r={};for(let[s,o]of Object.entries(e)){let a=o,i={};for(let[d,l]of Object.entries(a)){if(d==="parameters"&&Array.isArray(l)){i.parameters=l.map(le);continue}if(!wt(d)){i[d]=l;continue}i[d]=vt(l,n,t)}r[s]=i}return r}function wt(e){return["get","put","post","delete","options","head","patch"].includes(e.toLowerCase())}function vt(e,n,t){let r=e.consumes??n,s=e.produces??t,o=e.parameters??[],a=o.find(u=>u.in==="body"),i=o.filter(u=>u.in==="formData"),d=o.filter(u=>u.in!=="body"&&u.in!=="formData").map(le),l={...e,parameters:d};delete l.consumes,delete l.produces;let c=r?.[0]??ht;if(a)l.requestBody={required:!!a.required,content:{[c]:{schema:a.schema}}};else if(i.length>0){let u={},g=[];for(let f of i)u[f.name]=kt(f),f.required&&g.push(f.name);let p={type:"object",properties:u};g.length>0&&(p.required=g);let m=r?.find(f=>f==="multipart/form-data")??r?.[0]??"application/x-www-form-urlencoded";l.requestBody={required:g.length>0,content:{[m]:{schema:p}}}}return e.responses&&(l.responses=hn(e.responses,s)),l}function le(e){if(e.$ref!==void 0||e.in==="body"||e.in==="formData")return e;let n={},t={};for(let[r,s]of Object.entries(e))gn.has(r)?n[r]=s:t[r]=s;if(n.schema=t,delete n.collectionFormat,e.in==="query"&&t.type==="array"){let r=e.collectionFormat??"csv";r!=="multi"&&(n.style=r==="ssv"?"spaceDelimited":r==="pipes"?"pipeDelimited":"form",n.explode=!1)}return n}function kt(e){let n={};for(let[t,r]of Object.entries(e))gn.has(t)||(n[t]=r);return n}function hn(e,n){let t=n?.[0]??yt,r={};for(let[s,o]of Object.entries(e)){let a=o;if(a.schema===void 0){r[s]=a;continue}let{schema:i,...d}=a;r[s]={...d,content:{[t]:{schema:i}}}}return r}async function yn(e,n){let t=n??await _({}),r=await xe({ref:e,config:t}),s=await _({rules:{struct:"error"}}),o=await Oe({externalRefResolver:new ve,document:r.bundle,config:s}),a=[...r.problems,...o].filter(d=>d.severity==="error");if(a.length>0){let d=a.map(l=>`- ${l.message} (at ${l.location?.[0]?.pointer??e})`).join(`
|
|
17
|
-
`);throw new Error(`The API description has ${a.length} error(s):
|
|
18
|
-
${d}`)}let i=r.bundle.parsed;return{document:i,version:ke(i)}}function xt(e,n,t){let r=e.specName??e.name;if(t?.exclude?.includes(r))return{};let s=t?.operations?.[r];if(s!==void 0)return ce(e,n,s,`pagination.operations["${r}"]`,!0);if(e.paginationExtension!==void 0)return ce(e,n,e.paginationExtension,"x-redoclyPagination",!0);if(t?.style!==void 0){let{exclude:o,operations:a,...i}=t;return ce(e,n,i,"pagination convention",!1)}return{}}function bn(e,n){let t=new Map,r=[];for(let s of H(e.services)){let o=xt(s,e,n);o.error!==void 0?r.push(o.error):o.spec!==void 0&&t.set(s.name,{spec:o.spec,itemSchema:o.itemSchema})}if(r.length>0)throw new Error(["Invalid pagination configuration:",...r].join(`
|
|
19
|
-
- `));return t}function ce(e,n,t,r,s){let o=`Pagination for operation "${e.name}" (${r})`,a=Ot(t);if(a!==void 0)return{error:`${o}: ${a}`};let i=t,d=p=>s?{error:`${o}: ${p}`}:{};if(e.sse!==void 0)return d("the operation is a Server-Sent Events stream");if(i.style!=="link"){let p=i.style==="cursor"?"cursorParam":"offsetParam",m=i.style==="cursor"?i.cursorParam:i.offsetParam,f=e.queryParams.find(x=>x.name===m);if(!f){let x=e.queryParams.map(ge=>ge.name).join(", ");return d(`query parameter "${m}" is not declared on the operation`+(x===""?"":` (declared: ${x})`))}let y=wn(f.schema,n);if(!(y!==void 0&&(i.style==="cursor"?pe(y,n):y.kind==="scalar"&&(y.scalar==="number"||y.scalar==="integer")))){let x=i.style==="cursor"?"a string":"a number";return d(`the "${p}" query parameter "${m}" must accept ${x} (got ${Rt(y)})`)}}let l=e.successResponses.find(p=>p.contentType.toLowerCase().includes("json"));if(!l)return d("the operation has no JSON success response");if(i.style==="link"){let p=e.successResponseHeaders?.some(m=>m.name==="link")===!0;if(!p&&!s)return{};p||w.warn(`generate-client: ${o.toLowerCase()} follows the Link header, but the success response does not document one.
|
|
20
|
-
`)}let c=E(l.schema,i.items,n);if(c===void 0)return d(`the "items" pointer "${i.items}" does not resolve in the success response schema`);if(c.kind!=="array")return d(`the "items" pointer "${i.items}" must point at an array (got ${c.kind})`);if(i.style==="cursor"){let p=E(l.schema,i.nextCursor,n);if(p===void 0)return d(`the "nextCursor" pointer "${i.nextCursor}" does not resolve in the success response schema`);if(!pe(p,n))return d(`the "nextCursor" pointer "${i.nextCursor}" must point at a string (got ${p.kind})`);if(i.hasMore!==void 0){let m=E(l.schema,i.hasMore,n);if(m===void 0)return d(`the "hasMore" pointer "${i.hasMore}" does not resolve in the success response schema`);if(m.kind!=="scalar"||m.scalar!=="boolean")return d(`the "hasMore" pointer "${i.hasMore}" must point at a boolean (got ${m.kind})`)}}let u=i.limitParam!==void 0?{limitParam:i.limitParam}:{};return{spec:i.style==="cursor"?{style:"cursor",param:i.cursorParam,...u,nextCursor:i.nextCursor,...i.hasMore!==void 0?{hasMore:i.hasMore}:{},items:i.items}:i.style==="link"?{style:"link",...u,items:i.items}:{style:i.style,param:i.offsetParam,...u,items:i.items},itemSchema:c.items}}function Ot(e){if(!O(e))return"the rule must be an object";let{style:n,cursorParam:t,nextCursor:r,hasMore:s,offsetParam:o,limitParam:a,items:i}=e;if(n!=="cursor"&&n!=="offset"&&n!=="page"&&n!=="link")return`"style" must be one of "cursor" | "offset" | "page" | "link" (got ${JSON.stringify(n)})`;if(typeof i!="string"||i!==""&&!i.startsWith("/"))return'"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';if(n==="cursor"){if(typeof t!="string"||t==="")return'cursor style requires a "cursorParam" query parameter name';if(typeof r!="string"||!r.startsWith("/"))return'cursor style requires a "nextCursor" JSON pointer starting with "/"';if(s!==void 0&&(typeof s!="string"||!s.startsWith("/")))return'"hasMore" must be a JSON pointer starting with "/"'}else if((n==="offset"||n==="page")&&(typeof o!="string"||o===""))return`${n} style requires an "offsetParam" query parameter name`;if(a!==void 0&&typeof a!="string")return'"limitParam" must be a query parameter name'}function Rt(e){return e===void 0?"an unresolvable ref":e.kind==="scalar"||e.kind==="enum"?e.scalar:e.kind}function wn(e,n){let t=new Set,r=e;for(;r.kind==="ref";){let{name:s}=r;if(t.has(s))return;t.add(s);let o=n.schemas.find(a=>a.name===s);if(o===void 0)return;r=o.schema}return r}function pe(e,n){return e.kind==="scalar"||e.kind==="enum"?e.scalar==="string":e.kind==="literal"?typeof e.value=="string":e.kind==="union"?e.members.every(t=>{let r=wn(t,n);return r!==void 0&&(r.kind==="null"||r.kind!=="union"&&pe(r,n))}):!1}var qt=["Generated by @redocly/client-generator \u2014 do not edit by hand.","Source: OpenAPI description. Re-run `redocly generate-client` to update."];function ue(e,n){let t=[],r=new Set,s=G(vn(n.outputPath)),{dir:o,name:a,ext:i}=Et(n.outputPath),d={path:n.outputPath,dir:o,stem:a,ext:i},l=qt,c=!1;for(let u of n.generators){let g=n.registry.get(u),p={model:e,output:d,banner:l,outputMode:n.outputMode,emit:n.emit,pagination:n.pagination,selected:n.generators,options:n.generatorOptions?.get(u)??{}},m;try{n.emit.docs===!0&&g.docs!==void 0?(m=[...g.run(p),...g.docs(p)],c=!0):m=g.run(p)}catch(f){let y=f instanceof Error?f.message:String(f);throw new Error(`Generator "${u}" failed: ${y}`)}if(!Array.isArray(m)||m.some(f=>typeof f?.path!="string"||f.path===""||typeof f.content!="string"))throw new Error(`Generator "${u}" failed: run() must return an array of { path, content } files.`);for(let f of m){let y=G(s,f.path);if(y!==s&&!y.startsWith(s+Tt))throw new Error(`Generator "${u}" failed: file path escapes the output directory: ${f.path}`);if(r.has(y))throw new Error(`Generator conflict: ${f.path} already emitted by an earlier generator`);r.add(y),t.push({path:y,content:f.content})}}return n.emit.docs===!0&&!c&&w.warn(`generate-client: docs is on, but no selected generator writes documentation (${n.generators.join(", ")}).
|
|
21
|
-
`),t}function Pt(e){for(let n of e.services)for(let t of n.operations){let r=new Set,s=new Set;for(let o of[...t.pathParams,...t.queryParams,...t.headerParams,...t.cookieParams])r.has(o.name)&&s.add(o.name),r.add(o.name);s.size!==0&&w.warn(`generate-client: operation "${t.specName??t.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.
|
|
22
|
-
`)}}function It(e,n,t,r,s,o){let a=[];for(let i of H(e.services)){let d=t.map(l=>r.get(l)?.sample?.(i,{model:e,emit:n,outputPath:s,pagination:o})).filter(l=>l!==void 0);d.length>0&&a.push({target:`$.paths['${i.path.replaceAll("'","''")}'].${i.method}`,update:{"x-codeSamples":d}})}if(a.length!==0)return we({overlay:"1.0.0",info:{title:`Code samples for ${e.title}`,version:e.version},actions:a})}async function $t(e){if(e.output.split(/[\\/]/).some(f=>f==="undefined"||f==="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 h(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let n=G(e.output),{document:t,version:r}=await yn(e.api,e.config),s=r==="oas2"?fn(t):t,o=un(s);Pt(o);let a;if(e.setup){let{bakeSetup:f}=await import("./SGBB4RNM.js"),y=G(e.configDir??process.cwd(),e.setup);a=f(await St(y,"utf-8"))}let i=e.generators?.length?e.generators:["typescript"],{selected:d,registry:l}=await Qe(i,{customGenerators:e.customGenerators,configDir:e.configDir}),c=bn(o,e.pagination),u={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,setup:a,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:c,docs:e.docs,docsFrontmatter:e.docsFrontmatter};K(d,u,l,e.outputMode);let g=ze(d,l,e.options),p=ue(o,{outputPath:n,outputMode:e.outputMode??"single",emit:u,pagination:c,generators:d,generatorOptions:g,registry:l});if(e.codeSamples===!0){let f=It(o,u,d,l,n,c);f!==void 0&&p.push({path:n.replace(/\.[^.]+$/,".code-samples.yaml"),content:f})}let m=[];for(let f of p)await Ct(vn(f.path),{recursive:!0}),await At(f.path,f.content,"utf-8"),m.push({path:f.path,bytes:Buffer.byteLength(f.content,"utf-8")});return{outputPath:n,bytes:m.reduce((f,y)=>f+y.bytes,0),files:m}}function me(e,n){let t=n??{},r=e.specName??e.name;if(Array.isArray(t.exclude)&&t.exclude.includes(r))return;let o=(t.operations??{})[r]??e.paginationExtension;if(o===void 0&&typeof t.style=="string"){let{exclude:i,operations:d,...l}=t,c=l.style==="cursor"?l.cursorParam:l.offsetParam;(l.style==="link"?e.successResponseHeaders?.some(g=>g.name==="link")===!0:typeof c=="string"&&e.queryParams.some(g=>g.name===c))&&(o=l)}if(o===void 0||typeof o.style!="string")return;let a=o.style==="cursor"?o.cursorParam:o.offsetParam;return{style:o.style,...typeof a=="string"?{param:a}:{},...typeof o.nextCursor=="string"?{nextCursor:o.nextCursor}:{},...typeof o.hasMore=="string"?{hasMore:o.hasMore}:{},...typeof o.limitParam=="string"?{limitParam:o.limitParam}:{},...typeof o.items=="string"?{items:o.items}:{}}}function fe(e){return(e??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function q(e){switch(e.kind){case"ref":return e.name;case"omit":return e.base;case"scalar":return e.scalar;case"array":return`array of ${q(e.items)}`;case"record":return`map of ${q(e.value)}`;case"enum":{let n=e.values.map(String),t=n.slice(0,6).join(", ");return n.length>6?`enum: ${t}, and ${n.length-6} more`:`enum: ${t}`}case"literal":return String(e.value);case"union":return e.members.map(q).join(" or ");case"intersection":return e.members.map(q).join(" and ");case"object":return"object";case"null":return"null";case"unknown":return"any"}}function jt(e){return e.successResponses.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.successResponses.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function Nt(e,n){e.line("| Parameter | In | Type | Required | Description |"),e.line("| --------- | -- | ---- | -------- | ----------- |");for(let t of n)e.line(`| \`${t.name}\` | ${t.in} | ${fe(q(t.schema))} | ${t.required?"yes":"no"} | ${fe(t.description)} |`);e.blank()}function Dt(e,n,t){e.line(`### \`${n.specName??n.name}\``),e.blank(),n.summary!==void 0&&(e.line(fe(n.summary)),e.blank()),e.line(`\`${n.method.toUpperCase()} ${n.path}\``),e.blank();let r=t.sample(n);if(r!==void 0){e.line("```"+t.language.fence);for(let i of r.source.replace(/\n+$/,"").split(`
|
|
23
|
-
`))e.line(i);e.line("```"),e.blank()}let s=[...n.pathParams,...n.queryParams,...n.headerParams];s.length>0&&Nt(e,s),n.requestBody!==void 0&&e.line(`Body: \`${n.requestBody.contentType}\`${n.requestBody.required?", required":", optional"}, of type ${q(n.requestBody.schema)}.`);let o=n.successResponses[0];e.line(o===void 0?"Returns no content.":`Returns \`${o.contentType}\`, of type ${q(o.schema)}.`),(t.paginated!==void 0?t.paginated.has(n.name):me(n,t.pagination)!==void 0)&&e.line("This operation is paginated, so the SDK gives it page and item iterators."),n.successResponses.some(i=>i.contentType==="text/event-stream")&&e.line("This operation streams server-sent events, so the SDK iterates the events."),jt(n)&&e.line("This operation returns binary content."),e.blank()}function Lt(e,n){let t=new N;if(n.frontmatter&&(t.line("---"),t.line(`title: ${n.title}`),t.line("---"),t.blank()),t.line(`# ${n.title}`),t.blank(),t.line(`Generated reference for the ${n.language.label} SDK, produced from the API description by \`redocly generate-client\`.`),t.line("Re-run generation to update it \u2014 this file is not hand-edited."),t.blank(),t.line(n.language.requires),t.blank(),t.line("## Authentication"),t.blank(),e.securitySchemes.length===0)t.line("The description declares no security schemes.");else{t.line("The description declares these schemes, which you pass to the client:"),t.blank(),t.line("| Scheme | Kind | Sent as |"),t.line("| ------ | ---- | ------- |");for(let o of e.securitySchemes){let a=o.kind==="bearer"?"`Authorization: Bearer <token>`":o.kind==="basic"?"`Authorization: Basic <base64>`":o.kind==="apiKeyHeader"?`the \`${o.headerName}\` header`:o.kind==="apiKeyQuery"?`the \`${o.paramName}\` query parameter`:`the \`${o.cookieName}\` cookie`;t.line(`| \`${o.key}\` | ${o.kind} | ${a} |`)}}t.blank();let r=e.services.flatMap(o=>o.operations),s=[...new Set(r.map(o=>o.tags[0]))];for(let o of s){t.line(o===void 0?"## Operations":`## ${o}`),t.blank();for(let a of r.filter(i=>i.tags[0]===o))Dt(t,a,n)}return t.toString().replace(/\n{3,}/g,`
|
|
24
|
-
|
|
25
|
-
`).trimEnd()+`
|
|
26
|
-
`}function Mt(e){return e.successResponses.find(n=>n.contentType.toLowerCase().includes("json"))?.schema}function Kt(e){return e.successResponses.find(n=>n.contentType.toLowerCase().includes("text/event-stream"))}function Ut(e){return e.requestBody?.contentType.toLowerCase().includes("multipart")??!1}function Ft(e){let n=new Set(e.variables.map(a=>a.name)),t=[],r="",s=e.url,o=/\{([^{}]+)\}/;for(let a=o.exec(s);a!==null;a=o.exec(s))r+=s.slice(0,a.index),n.has(a[1])?(r!==""&&t.push({kind:"literal",value:r}),r="",t.push({kind:"variable",name:a[1]})):r+=a[0],s=s.slice(a.index+a[0].length);return r+=s,(r!==""||t.length===0)&&t.push({kind:"literal",value:r}),t}function Bt(e,n){return e.security.map(t=>t.flatMap(r=>{let s=n.securitySchemes.find(o=>o.key===r);return s===void 0?[]:s.kind==="bearer"||s.kind==="basic"?[{scheme:r,kind:s.kind}]:s.kind==="apiKeyHeader"?[{scheme:r,kind:"apiKey",name:s.headerName,in:"header"}]:s.kind==="apiKeyQuery"?[{scheme:r,kind:"apiKey",name:s.paramName,in:"query"}]:[{scheme:r,kind:"apiKey",name:s.cookieName,in:"cookie"}]})).filter(t=>t.length>0)}function Ht(e,n,t){if(e===void 0||n===void 0)return;let r=E(e,n,t);return r?.kind==="array"?r.items:void 0}var lo=["Printer","casing","identifierFor","uniqueIdentifiers","RESERVED_WORDS","flattenAllOf","deref","discriminatorCases","jsonSuccessSchema","sseResponse","isMultipartBody","serverUrlParts","securityRequirements","paginationItemSchema","isNullable","unwrapNullable","enumValues","docText","headerCoerceType","schemaAtPointer","paginationRuleFor","renderReferencePage","NotSupportedError"];function Ro(e,n){let t=n.registry??W();return _e(n.generators,n.emit,t,n.outputMode),ue(e,{...n,registry:t})}export{lo as AUTHORING_HELPER_NAMES,h as NotSupportedError,N as Printer,Q as RESERVED_WORDS,j as casing,Z as codeLiteral,Ro as collectGeneratedFiles,A as deref,$n as discriminatorCases,Dn as docText,Nn as enumValues,en as flattenAllOf,$t as generateClient,D as headerCoerceType,Ze as identifierFor,Ut as isMultipartBody,nn as isNullable,Mt as jsonSuccessSchema,Pe as operationSignature,Ht as paginationItemSchema,me as paginationRuleFor,B as pascalCase,kn as renderComposedCliEntry,Lt as renderReferencePage,Kn as safeIdent,E as schemaAtPointer,Bt as securityRequirements,Ft as serverUrlParts,Kt as sseResponse,xn as tsJsdoc,On as tsType,X as uniqueIdentifiers,jn as unwrapNullable};
|
package/lib/chunks/REFX2EKS.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as E,c as b,d as m,l as y}from"./HJYFWIVE.js";var $=b.go,w=class extends E{constructor(){super(" ")}typeName(t){return x(t)}memberName(t){return x(t)}identifier(t){return m(t,{style:"camel",reserved:$})}identifiers(t,n){let r=new Set(n??[]);return t.map(e=>{let a=x(e),c=a;for(let o=2;r.has(c);o++)c=`${a}${o}`;return r.add(c),c})}packageName(t){let n=t.toLowerCase().replace(/[^a-z0-9]/g,"");return n===""||/^[0-9]/.test(n)?"client":n}string(t){let n='"';for(let r of t){let e=r.codePointAt(0);r==="\\"?n+="\\\\":r==='"'?n+='\\"':r===`
|
|
8
|
-
`?n+="\\n":r==="\r"?n+="\\r":r===" "?n+="\\t":e<32||e===127?n+=`\\x${e.toString(16).padStart(2,"0")}`:e>=55296&&e<=57343?n+="\\uFFFD":n+=r}return n+'"'}literal(t){return t==null?"nil":typeof t=="boolean"||typeof t=="number"?String(t):typeof t=="string"?this.string(t):Array.isArray(t)?`[]any{${t.map(r=>this.literal(r)).join(", ")}}`:`map[string]any{${Object.entries(t).map(([r,e])=>`${this.string(r)}: ${this.literal(e)}`).join(", ")}}`}comment(t){for(let n of y(t))this.line(n===""?"//":`// ${n}`);return this}doc(t,n){let r=y(n);if(r.length===0)return this;this.line(`// ${t} \u2014 ${r[0]}`);let e=!1;for(let a of r.slice(1)){if(a===""){e||this.line("//"),e=!0;continue}this.line(`// ${a}`),e=!1}return this}layout(t){return A(N(t))}toString(){return this.layout(super.toString())}};function x(g){let t=m(g,{style:"pascal",reserved:$});return t.startsWith("_")?`N${t.slice(1)}`:t}function A(g){return`${g.replace(/\n{3,}/g,`
|
|
9
|
-
|
|
10
|
-
`).trimEnd()}
|
|
11
|
-
`}function N(g){let t=g.split(`
|
|
12
|
-
`),n=[...t],r=/^(\t+)([A-Za-z_]\w*) (\S+)( `[^`]*`)?$/,e=/^(\t+)([A-Za-z_]\w*) (\S+) = (.+)$/,a=/^(\t+)("(?:[^"\\]|\\.)*":) (.+)$/,c=u=>{if(u.length<2)return;let d=[];for(let{parts:i}of u)i.forEach((s,l)=>{l<i.length-1&&(d[l]=Math.max(d[l]??0,s.length))});for(let{index:i,parts:s,indent:l}of u){let f=s.map((p,h)=>h<s.length-1?p.padEnd(d[h]??0):p);n[i]=l+f.join(" ").trimEnd()}},o=[],S;return t.forEach((u,d)=>{let i=a.exec(u),s=i===null?e.exec(u):null,l=i===null&&s===null?r.exec(u):null,f=l!==null&&!$.has(l[2])?l:null,p=i!==null?"entry":s!==null?"const":f!==null?"field":void 0;if((p===void 0||p!==S)&&(c(o),o=[],S=p),i!==null){o.push({index:d,indent:i[1],parts:[i[2],i[3]]});return}if(s!==null){o.push({index:d,indent:s[1],parts:[s[2],s[3],"=",s[4]]});return}if(f!==null){let h=[f[2],f[3]];f[4]!==void 0&&h.push(f[4].trimStart()),o.push({index:d,indent:f[1],parts:h})}}),c(o),n.join(`
|
|
13
|
-
`)}export{w as a,x as b};
|
package/lib/chunks/SGBB4RNM.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as s}from"./WZXA5XPB.js";import{a as m}from"./3JJEI7CJ.js";import{e as f}from"./RFWIIJFG.js";var e=f(m(),1);if(typeof e.default?.createSourceFile!="function")throw new Error(`Baking a --setup module needs the TypeScript compiler API, but the installed \`typescript\` package${e.default?.version?` (${e.default.version})`:""} does not include it \u2014 TypeScript 7 ships only the native tsc. Install TypeScript 6 for generation (npm i -D typescript@6); your app can still compile the generated client with TypeScript 7.`);var a="@redocly/client-generator";function g(n){let i=e.default.createSourceFile("setup.ts",n,e.default.ScriptTarget.Latest,!0,e.default.ScriptKind.TS),p=[],o,d="defineClientSetup";for(let t of i.statements){if(e.default.isImportDeclaration(t)){let r=t.moduleSpecifier.text;if(r!==a)throw new s(`A --setup file may only import from "${a}"; found "${r}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);let c=t.importClause?.namedBindings;if(c&&e.default.isNamedImports(c))for(let l of c.elements)(l.propertyName?.text??l.name.text)==="defineClientSetup"&&(d=l.name.text);continue}if(e.default.isExportAssignment(t)&&!t.isExportEquals){o=y(t.expression,d).getText(i);continue}if(e.default.isExportDeclaration(t)){if(t.moduleSpecifier!==void 0)throw new s(`A --setup file may only import from "${a}"; found "${t.moduleSpecifier.text}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);continue}let u=e.default.canHaveModifiers(t)?e.default.getModifiers(t)?.find(r=>r.kind===e.default.SyntaxKind.ExportKeyword):void 0;p.push(u===void 0?t.getText(i):n.slice(u.end,t.getEnd()).trimStart())}if(o===void 0)throw new s("A --setup file must `export default defineClientSetup({ config, middleware })` (or a setup object).");return p.length===0?o:`(() => {
|
|
8
|
-
${p.join(`
|
|
9
|
-
`)}
|
|
10
|
-
return ${o};
|
|
11
|
-
})()`}function y(n,i){return e.default.isCallExpression(n)&&e.default.isIdentifier(n.expression)&&n.expression.text===i&&n.arguments.length===1?n.arguments[0]:n}export{g as bakeSetup};
|
package/lib/chunks/SQVG3CEM.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as f,c as l,d as i,e as g,l as o}from"./HJYFWIVE.js";var s=l.python,d=class extends f{constructor(){super(" ")}typeName(r){return i(r,{style:"pascal",reserved:s})}memberName(r){let e=i(r,{style:"snake",reserved:s});return{identifier:e,renamed:e!==r}}identifier(r){return i(r,{style:"snake",reserved:s})}identifiers(r,e){return g(r,{style:"snake",reserved:s,taken:e})}constName(r){return i(r,{style:"screaming",reserved:s})}string(r){let e='"';for(let t of r){let n=t.codePointAt(0);t==="\\"?e+="\\\\":t==='"'?e+='\\"':t===`
|
|
8
|
-
`?e+="\\n":t==="\r"?e+="\\r":t===" "?e+="\\t":n<32||n===127?e+=`\\x${n.toString(16).padStart(2,"0")}`:n>=55296&&n<=57343?e+=`\\u${n.toString(16).padStart(4,"0")}`:e+=t}return e+'"'}literal(r){return r==null?"None":r===!0?"True":r===!1?"False":typeof r=="number"?String(r):typeof r=="string"?this.string(r):Array.isArray(r)?`[${r.map(t=>this.literal(t)).join(", ")}]`:`{${Object.entries(r).map(([t,n])=>`${this.string(t)}: ${this.literal(n)}`).join(", ")}}`}comment(r){for(let e of o(r))this.line(e===""?"#":`# ${e}`);return this}doc(r){let e=o(r);if(e.length===0)return this;if(e.length===1)return this.line(`"""${e[0]}"""`);this.line(`"""${e[0]}`);for(let t of e.slice(1))this.line(t);return this.line('"""')}};export{d as a};
|
package/lib/chunks/U6E22USS.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as S,b as f}from"./REFX2EKS.js";import{a as N}from"./UKSQ7B5H.js";import{b as E,c as U,d as j,e as K,f as J,g as z,h as Q}from"./NAGDQV7J.js";import{a as M}from"./PFYPTG4G.js";import{b as O,c as H,d as w,e as B,g as F,h as G,i as T,j as W,k as _,n as A}from"./HJYFWIVE.js";var c=new S,y=H.go;function V(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||y.has(e))throw new M(`goPackage "${e}" is not a valid Go package name: use lowercase letters, digits, and underscores, don't start with a digit, and avoid Go keywords.`);return e}function R(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let a=f(o.name),s=2;for(;t.has(a);)a=`${f(o.name)}${s++}`;t.add(a),n.push({op:o,ident:a})}return n}function oe(e){return J(e).map(n=>n.kind==="literal"?c.string(n.value):w(n.name,{style:"camel",reserved:y})).join(" + ")}function X(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,a)=>{let s=`${f(o.description??`server${a+1}`)}URL`;r.has(s)&&(s=`${s}${a+1}`),r.add(s);let i=o.variables.map(l=>`${w(l.name,{style:"camel",reserved:y})} string`),u=o.variables.map(l=>`${w(l.name,{style:"camel",reserved:y})} default: ${c.string(l.default)}`).join(", ");e.line(`// ${s} returns the ${c.string(o.description??o.url)} base URL${u===""?".":` (${u}).`}`),e.block(`func ${s}(${i.join(", ")}) string {`,()=>{e.line(`return ${oe(o)}`)},"}"),e.blank()})}function Y(e,t){let n=z(e,t).map(r=>r.map(o=>o.kind==="apiKey"?`{Scheme: ${c.string(o.scheme)}, Kind: "apiKey", Name: ${c.string(o.name)}, In: ${c.string(o.in)}}`:`{Scheme: ${c.string(o.scheme)}, Kind: ${c.string(o.kind)}}`));if(n.length!==0)return`[][]SecuritySpec{${n.map(r=>`{${r.join(", ")}}`).join(", ")}}`}function Z(e){return`&PaginationSpec{${[`Style: ${c.string(e.style)}`,...e.param!==void 0?[`Param: ${c.string(e.param)}`]:[],...e.nextCursor!==void 0?[`NextCursor: ${c.string(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`HasMore: ${c.string(e.hasMore)}`]:[],...e.limitParam!==void 0?[`LimitParam: ${c.string(e.limitParam)}`]:[],...e.items!==void 0?[`Items: ${c.string(e.items)}`]:[]].join(", ")}}`}function g(e,t="string"){if(T(e)){let n=g(W(e),t);return n.startsWith("*")||n==="any"?n:`*${n}`}switch(e.kind){case"scalar":if(t==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"time.Time";if(e.metadata?.format==="date")return"Date"}return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"array":return`[]${g(e.items,t)}`;case"record":return`map[string]${g(e.value,t)}`;case"ref":return f(e.name);case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float64";case"enum":return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"omit":return f(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ae(e,t,n,r,o){e.doc(f(t),o),e.block(`type ${f(t)} struct {`,()=>{for(let a of n){let s=f(a.name),i=g(a.schema,r),u=`\`json:"${a.name}"\``;a.required||(!i.startsWith("*")&&!i.startsWith("[]")&&!i.startsWith("map[")&&i!=="any"&&(i=`*${i}`),u=`\`json:"${a.name},omitempty"\``),e.line(`${s} ${i} ${u}`)}},"}"),e.blank()}function D(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:a})=>G(a,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=se(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function se(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let a=_(o);if(a!==void 0){let i=a.scalar==="string"?"string":"int64";n.doc(f(r),o.description),n.line(`type ${f(r)} ${i}`),n.blank(),n.block("const (",()=>{let u=new Set;a.values.forEach(l=>{let d=O.pascal(String(l))||"Value",m="";for(let k=2;u.has(d+m);k++)m=String(k);u.add(d+m);let p=f(r)+d+m;n.line(`${p} ${f(r)} = ${c.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let i=F(o,e);if(i!==void 0){ae(n,r,i.properties,t,i.description??o.description);continue}}let s=G(o,e);if(s!==void 0){let i=f(r),u=s.cases.map(l=>`${l.value} -> ${f(l.schemaName)}`).join(", ");n.line(`// ${i} is a discriminated union ("${s.property}"): ${u}.`),n.line(`type ${i} = any`),n.blank(),n.line(`// Unmarshal${i} decodes into the member selected by "${s.property}".`),n.block(`func Unmarshal${i}(data []byte) (${i}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${s.property}"\``)},"}"),n.block("if err := json.Unmarshal(data, &probe); err != nil {",()=>{n.line("return nil, err")},"}"),n.line("switch probe.Discriminant {");for(let l of s.cases)n.block(`case ${c.string(l.value)}:`,()=>{n.line(`var value ${f(l.schemaName)}`),n.line("err := json.Unmarshal(data, &value)"),n.line("return value, err")});n.line("}"),n.line("var fallback any"),n.line("err := json.Unmarshal(data, &fallback)"),n.line("return fallback, err")},"}"),n.blank();continue}n.doc(f(r),o.description),n.line(`type ${f(r)} = ${g(o,t)}`),n.blank()}return n.toString()}function q(e,t){if(t==="string")return e;let n=e.startsWith("*")?`(${e})`:e;return t==="time.Time"?`${n}.Format(time.RFC3339)`:t==="Date"?`${n}.Format("2006-01-02")`:t==="int64"?`strconv.FormatInt(${e}, 10)`:t==="float64"?`strconv.FormatFloat(${e}, 'f', -1, 64)`:t==="bool"?`strconv.FormatBool(${e})`:`fmt.Sprint(${e})`}var ie=["c","ctx","body","params","out","op"];function I(e,t){let n=B(e.pathParams.map(r=>r.name),{style:"camel",reserved:y,taken:ie});return e.pathParams.map((r,o)=>({param:r,go:n[o],type:g(r.schema,t)}))}function le(e,t){let n=new Set;return(e.successResponseHeaders??[]).map(r=>{let o=f(r.name),a=o,s=2;for(;n.has(a);)a=`${o}${s++}`;n.add(a);let i=A(r.schema,t),u={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[i];return{field:a,name:r.name,...u}})}function L(e,t,n,r,o,a=!1){let s=I(t,r),i=t.queryParams.length>0,u=U(t),l=u===void 0?void 0:g(u,r),d=a?le(t,o):[];a&&(e.line(`// ${n}Headers carries the declared response headers of ${n}WithHeaders (nil when absent or unparsable).`),e.block(`type ${n}Headers struct {`,()=>{for(let $ of d)e.line(`${$.field} ${$.goType}`)},"}"),e.blank());let m=["ctx context.Context",...s.map(({go:$,type:v})=>`${$} ${v}`),...t.requestBody?[`body ${g(t.requestBody.schema,r)}`]:[],...i?[`params *${n}Params`]:[]],p=j(t),k=a?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:p!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,b=$=>a?l===void 0?`return headers, ${$}`:`return out, headers, ${$}`:l===void 0?`return ${$}`:`return out, ${$}`,P=a?`${n}WithHeaders`:n;e.doc(P,a?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${P}(${m.join(", ")}) ${k} {`,()=>{p===void 0&&l!==void 0&&e.line(`var out ${l}`),a&&e.line(`var headers ${n}Headers`),e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),i&&e.block("if params != nil {",()=>{for(let h of t.queryParams){let x=f(h.name);e.block(`if params.${x} != nil {`,()=>{if(h.schema.kind==="array"){let C=g(h.schema.items,r);e.block(`for _, item := range *params.${x} {`,()=>{e.line(`query.Add(${c.string(h.name)}, ${q("item",C)})`)},"}")}else e.line(`query.Set(${c.string(h.name)}, ${q(`*params.${x}`,g(h.schema,r))})`)},"}")}},"}");let $=s.map(({param:h,go:x,type:C})=>`${c.string(h.name)}: ${q(x,C)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${$}})`),p!==void 0){e.block("open := func(extraHeaders map[string]string) (*http.Response, error) {",()=>{e.line("merged := map[string]string{}"),e.block("for key, value := range authHeaders {",()=>{e.line("merged[key] = value")},"}"),e.block("for key, value := range extraHeaders {",()=>{e.line("merged[key] = value")},"}"),e.line("return send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: merged, Query: query})")},"}"),e.line(`return iterSSE(open, ${p.schema!==void 0&&p.schema.kind!=="unknown"})`);return}let v=["OperationID: op.ID","Method: op.Method","URL: requestURL","Headers: authHeaders","Query: query"];if(t.requestBody&&K(t)?(e.line("contentType, reader, err := toMultipart(body)"),e.block("if err != nil {",()=>{e.line(b("err"))},"}"),v.push("Body: reader"),v.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line(b("err"))},"}"),v.push("Body: bytes.NewReader(payload)"),v.push(`ContentType: ${c.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${v.join(", ")}})`),e.block("if err != nil {",()=>{e.line(b("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line(b("apiErrorFrom(resp, requestURL)"))},"}"),a){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line(b("err"))},"}");for(let h of d)e.line(`headers.${h.field} = ${h.helper}(resp.Header, ${c.string(h.name)})`);e.line(l===void 0?"return headers, nil":"return out, headers, nil")}else l===void 0?e.line("return decodeJSON(resp, nil)"):(e.block("if err := decodeJSON(resp, &out); err != nil {",()=>{e.line("return out, err")},"}"),e.line("return out, nil"))},"}"),e.blank()}function ee(e,t,n,r,o,a){let s=I(t,r),i=t.queryParams.length>0,u=["ctx context.Context",...s.map(({go:d,type:m})=>`${d} ${m}`),...i?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),i&&e.block("if params != nil {",()=>{for(let d of t.queryParams){let m=f(d.name);e.block(`if params.${m} != nil {`,()=>{e.line(`base.Set(${c.string(d.name)}, ${q(`*params.${m}`,g(d.schema,r))})`)},"}")}},"}"),e.block("call := func(pageParams url.Values) (any, *http.Response, error) {",()=>{e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),e.block("for key, values := range pageParams {",()=>{e.block("for _, value := range values {",()=>{e.line("query.Set(key, value)")},"}")},"}");let d=s.map(({param:m,go:p,type:k})=>`${c.string(m.name)}: ${q(p,k)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${d}})`),e.line("resp, err := send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: authHeaders, Query: query})"),e.block("if err != nil {",()=>{e.line("return nil, nil, err")},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line("return nil, resp, apiErrorFrom(resp, requestURL)")},"}"),e.line("var raw any"),e.block("if err := decodeJSON(resp, &raw); err != nil {",()=>{e.line("return nil, resp, err")},"}"),e.line("return raw, resp, nil")},"}"),e.line("pages := iterPages(call, *op.Pagination, base)")};e.line(`// ${n}Pages iterates ${n} response pages; use with \`for page, err := range\`.`),e.block(`func (c *Client) ${n}Pages(${u}) func(yield func(${o}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${o}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.line(`var page ${o}`),e.block("if err == nil {",()=>{e.line("err = reencode(raw, &page)")},"}"),e.line("return yield(page, err)")},"})")},"}")},"}"),e.blank(),e.line(`// ${n}Items iterates the items of every ${n} page.`),e.block(`func (c *Client) ${n}Items(${u}) func(yield func(${a}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${a}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.block("if err != nil {",()=>{e.line(`var zero ${a}`),e.line("return yield(zero, err)")},"}"),e.line("pageItems, _ := resolvePointer(raw, op.Pagination.Items).([]any)"),e.block("for _, item := range pageItems {",()=>{e.line(`var typed ${a}`),e.block("if err := reencode(item, &typed); err != nil {",()=>{e.line("return yield(typed, err)")},"}"),e.block("if !yield(typed, nil) {",()=>{e.line("return false")},"}")},"}"),e.line("return true")},"})")},"}")},"}"),e.blank()}function ne(e){let t=e.split(`
|
|
8
|
-
`),n=[],r=!1;for(let o of t)if(!o.startsWith("package ")){if(o.startsWith("import (")){r=!0;continue}if(r){o.startsWith(")")&&(r=!1);continue}o.startsWith("import ")||n.push(o)}return n.join(`
|
|
9
|
-
`).trim()}var te=["bytes","context","encoding/base64","encoding/json","errors","fmt","io","math/rand","mime/multipart","net/http","net/url","strconv","strings","time"];function re(e,t,n,r,o,a){e.line(ne(D(t,r))),e.blank(),X(e,t),a&&(e.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator go runtime) \u2500\u2500\u2500"),e.line(ne(N)),e.blank()),e.block("type operationMeta struct {",()=>{e.line("ID string"),e.line("Method string"),e.line("Path string"),e.line("Security [][]SecuritySpec"),e.line("Pagination *PaginationSpec")},"}"),e.blank(),e.block("var operations = map[string]operationMeta{",()=>{for(let{op:s,ident:i}of R(t)){let u=s.specName??s.name,l=Y(s,t),d=o.get(i),m=[`ID: ${c.string(u)}`,`Method: ${c.string(s.method.toUpperCase())}`,`Path: ${c.string(s.path)}`,...l!==void 0?[`Security: ${l}`]:[],...d!==void 0?[`Pagination: ${Z(d)}`]:[]];e.line(`${c.string(u)}: {${m.join(", ")}},`)}},"}"),e.blank();for(let{op:s,ident:i}of R(t))s.queryParams.length!==0&&(e.block(`type ${i}Params struct {`,()=>{for(let u of s.queryParams){let l=g(u.schema,r);e.line(`${f(u.name)} ${l.startsWith("*")?l:`*${l}`}`)}},"}"),e.blank());e.doc("Client",`Client for ${t.title} (${t.version}).`),e.block("type Client struct {",()=>{e.line("config Config")},"}"),e.blank(),e.block("func New(config Config) *Client {",()=>{e.block('if config.ServerURL == "" {',()=>{e.line(`config.ServerURL = ${c.string(n.serverUrl??t.serverUrl??"")}`)},"}"),e.line("return &Client{config: config}")},"}"),e.blank();for(let{op:s,ident:i}of R(t)){L(e,s,i,r),j(s)===void 0&&(s.successResponseHeaders?.length??0)>0&&L(e,s,i,r,t,!0);let u=o.get(i);if(u===void 0)continue;let l=U(s),d=l===void 0?"any":g(l,r),m=Q(l,u.items,t);ee(e,s,i,r,d,m===void 0?"any":g(m,r))}}var ze=({model:e,output:t,banner:n,emit:r,pagination:o})=>{let a=new S,s=r.dateType??"string",i=V(r.goPackage),u=new Map;for(let{op:b,ident:P}of R(e)){let $=o?.get(b.name)?.spec;$!==void 0&&u.set(P,$)}a.line(`// Code generated by @redocly/client-generator (go) from "${e.title}" ${e.version}. DO NOT EDIT.`),a.line("// Regenerate with `redocly generate-client`. Standard library only \u2014 zero dependencies."),a.line(`package ${i}`),a.blank();let l=r.runtime!=="module",d=l?te:(()=>{let b=new S;re(b,e,r,s,u,!1);let P=b.toString();return te.filter($=>new RegExp(`\\b${$.split("/").pop()}\\.`).test(P))})();a.block("import (",()=>{for(let b of d)a.line(c.string(b))},")"),a.blank(),re(a,e,r,s,u,l);let m={path:t.path.replace(/\.[^.\\/]+$/,".go"),content:a.toString()};if(l)return[m];let p=n.map(b=>`// ${b}`).join(`
|
|
10
|
-
`),k=N.replace(/^package .*$/m,`package ${i}`);return[m,{path:m.path.replace(/[^\\/]+$/,"runtime.go"),content:`${p}
|
|
11
|
-
${k.trimEnd()}
|
|
12
|
-
`}]};function ce(e,t){let n=t.emit.dateType??"string",r=t.emit.goPackage??"client",o=R(t.model).find(u=>u.op.name===e.name)?.ident??f(e.name),a=["ctx",...e.pathParams.map(u=>`"<${w(u.name,{style:"camel",reserved:y})}>"`),...e.requestBody?[`${g(e.requestBody.schema,n)}{ /* \u2026 */ }`]:[],...e.queryParams.length>0?["nil"]:[]],s=`client.${o}(${a.join(", ")})`,i=j(e)!==void 0?`stream := ${s}`:U(e)===void 0?`err := ${s}`:`result, err := ${s}`;return{lang:"go",label:"Go SDK",source:`client := ${r}.New(${r}.Config{})
|
|
13
|
-
${i}
|
|
14
|
-
`}}var Qe=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".go.md"),content:E(e,{title:`${e.title} Go SDK reference`,frontmatter:n.docsFrontmatter===!0,language:{name:"go",label:"Go",fence:"go",requires:"The SDK needs the standard library only."},sample:o=>ce(o,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];export{g as a,D as b,ze as c,ce as d,Qe as e};
|
package/lib/chunks/ULV3D265.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as R}from"./SQVG3CEM.js";import{c as L}from"./UKSQ7B5H.js";import{b as J,c as E,d as F,e as W,f as ne,g as B,h as te}from"./NAGDQV7J.js";import{c as z,d as w,e as A,g as U,h as C,i as Q,j as X,k as Z,n as ee}from"./HJYFWIVE.js";var k=z.python,f=new R;function O(e){return f.typeName(e)}function q(e){let{identifier:n,renamed:s}=f.memberName(e);return{python:n,renamed:s}}function I(e){let n=e.services.flatMap(t=>t.operations),s=A(n.map(t=>t.name),{style:"snake",reserved:k});return n.map((t,r)=>({op:t,ident:s[r]}))}var T=["self","body","headers","timeout","retry","idempotency_key"];function se(e){return f.literal(e)}function oe(e){if(e!==void 0)return{style:e.style,...e.param!==void 0?{param:e.param}:{},...e.nextCursor!==void 0?{next_cursor:e.nextCursor}:{},...e.hasMore!==void 0?{has_more:e.hasMore}:{},...e.limitParam!==void 0?{limit_param:e.limitParam}:{},...e.items!==void 0?{items:e.items}:{}}}function ae(e,n){let s=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let a=w(r.name,{style:"snake",reserved:k}),c=a,i=2;for(;s.has(c);)c=`${a}_${i++}`;s.add(c);let m=ee(r.schema,n);return`(${f.string(r.name)}, ${f.string(c)}, ${f.string(m)})`}).join(", ")}]`}function y(e,n="string"){if(Q(e))return`Optional[${y(X(e),n)}]`;switch(e.kind){case"scalar":if(n==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"datetime";if(e.metadata?.format==="date")return"date"}return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":return`List[${y(e.items,n)}]`;case"record":return`Dict[str, ${y(e.value,n)}]`;case"ref":return O(e.name);case"literal":return`Literal[${f.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(s=>y(s,n)).join(", ")}]`;case"null":return"None";case"omit":return O(e.base);case"object":case"intersection":case"unknown":return"Any"}}function H(e,n,s,t,r,a,c,i=!1){let m=A([...n.pathParams,...n.queryParams].map(N=>N.name),{style:"snake",reserved:k,taken:T}),l=n.pathParams.map((N,S)=>({param:N,python:m[S]})),o=n.queryParams.map((N,S)=>({param:N,python:m[n.pathParams.length+S]})),p=l.map(({param:N,python:S})=>`${S}: ${y(N.schema,a)}`),u=n.requestBody?[`body: ${y(n.requestBody.schema,a)}`]:[],$=[...o.map(({param:N,python:S})=>{let D=y(N.schema,a),j=D.startsWith("Optional[")?D:`Optional[${D}]`;return`${S}: ${j} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],h=E(n),g=F(n),v=i?`Envelope[${h===void 0?"None":y(h,a)}]`:g!==void 0?`${r?"AsyncIterator":"Iterator"}[ServerSentEvent]`:t==="result"?"Result":h===void 0?"None":y(h,a),P=r&&g===void 0?"async def":"def",d=r?"await ":"",_=r?"send_async":"send",b=["self",...p,...u,"*",...$].join(", "),x=i?`${s}_with_headers`:s;e.block(`${P} ${x}(${b}) -> ${v}:`,()=>{e.doc(i?`Like ${s}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${s}"]`),e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)'),e.line("params: Dict[str, Any] = dict(auth_query)");for(let{param:j,python:M}of o)e.block(`if ${M} is not None:`,()=>{e.line(`params[${f.string(j.name)}] = encode(${M})`)});let N=l.map(({param:j,python:M})=>`${f.string(j.name)}: ${M}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${N}})`),g!==void 0){let j=g.schema!==void 0&&g.schema.kind!=="unknown"?"json":"text";e.block("def _open(extra_headers: Dict[str, str]):",()=>{e.line('return self._http.stream(op["method"], url, headers={**auth_headers, **(headers or {}), **extra_headers}, params=params, timeout=timeout)')}),e.line(`return ${r?"aiter_sse":"iter_sse"}(_open, data_kind="${j}")`);return}W(n)&&e.line("form_data, form_files = to_multipart(body)");let S=n.requestBody?W(n)?", data=form_data, files=form_files":", json_body=encode(body)":"";e.line(`response = ${d}${_}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params=params${S}, timeout=timeout, retry=retry, idempotency_key=idempotency_key)`);let D=h===void 0?"None":`decode(${y(h,a)}, _safe_json(response))`;i?(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(`return Envelope(data=${D}, headers=read_envelope_headers(response, ${ae(n,c)}), response=response)`)):t==="result"?(e.block("if not response.is_success:",()=>{e.line("return Result(data=None, error=_safe_json(response), response=response)")}),e.line(`return Result(data=${D}, error=None, response=response)`)):(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(h===void 0?"return None":`return ${D}`))}),e.blank()}function re(e,n,s,t,r,a){let c=E(n),i=c===void 0?"Any":y(c,a),m=A([...n.pathParams,...n.queryParams].map(d=>d.name),{style:"snake",reserved:k,taken:T}),l=n.pathParams.map((d,_)=>({param:d,python:m[_]})),o=n.queryParams.map((d,_)=>({param:d,python:m[n.pathParams.length+_]})),p=l.map(({param:d,python:_})=>`${_}: ${y(d.schema,a)}`),u=[...o.map(({param:d,python:_})=>{let b=y(d.schema,a),x=b.startsWith("Optional[")?b:`Optional[${b}]`;return`${_}: ${x} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],$=["self",...p,"*",...u].join(", "),h=t?"AsyncIterator":"Iterator",g=t?"aiter_pages":"iter_pages",v=t?"aiter_items":"iter_items",P=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:b,python:x}of o)e.block(`if ${x} is not None:`,()=>{e.line(`base[${f.string(b.name)}] = encode(${x})`)});let d=t?"async def":"def",_=t?"await ":"";e.block(`${d} _page(page_params: Dict[str, Any]) -> Tuple[Any, Any]:`,()=>{e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)');let b=l.map(({param:x,python:N})=>`${f.string(x.name)}: ${N}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${b}})`),e.line(`response = ${_}${t?"send_async":"send"}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params={**page_params, **auth_query}, timeout=timeout, retry=retry)`),e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line("return _safe_json(response), response")})};t?(e.block(`async def ${s}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.block(`async for page in ${g}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${s}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.block(`async for item in ${v}(_page, op["pagination"], base):`,()=>{e.line(r==="Any"?"yield item":`yield decode(${r}, item)`)})})):(e.block(`def ${s}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.line(i==="Any"?`return ${g}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${g}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${s}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.line(r==="Any"?`return ${v}(_page, op["pagination"], base)`:`return (decode(${r}, item) for item in ${v}(_page, op["pagination"], base))`)})),e.blank()}function le(e){return ne(e).map(s=>s.kind==="literal"?f.string(s.value):q(s.name).python).join(" + ")}function ie(e,n){let s=n.servers??[];if(s.length===0)return;let t=new Set;e.block("class Servers:",()=>{e.line('"""The declared servers; variables default to the values from the description."""'),e.blank(),s.forEach((r,a)=>{let c=w(r.description??`server${a+1}`,{style:"snake",reserved:k});t.has(c)&&(c=`${c}_${a+1}`),t.add(c);let i=r.variables.map(m=>`${q(m.name).python}: str = ${f.string(m.default)}`);a>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${c}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${le(r)}`)})})}),e.blank()}function K(e,n,s,t,r,a,c){let i=t?"AsyncClient":"Client",m=t?"httpx.AsyncClient":"httpx.Client";e.block(`class ${i}:`,()=>{e.doc(`${t?"Async ":""}client for ${n.title} (${n.version}).`),e.block(`def __init__(self, server_url: str = ${f.string(a)}, *, auth: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, timeout: Optional[float] = None, retry: Optional[Dict[str, Any]] = None, middleware: Optional[List[Any]] = None, idempotency_key: Any = None, http_client: Optional[${m}] = None) -> None:`,()=>{e.line("self._server_url = server_url"),e.line("self._auth = auth or {}"),e.line("self._config: Dict[str, Any] = {"),e.indent(()=>{e.line('"headers": headers or {},'),e.line('"timeout": timeout,'),e.line('"retry": retry or {},'),e.line('"middleware": middleware or [],'),e.line('"idempotency_key": idempotency_key,')}),e.line("}"),e.line(`self._http = http_client or ${m}()`)}),e.blank();for(let{op:l,ident:o}of I(n)){H(e,l,o,s,t,c),F(l)===void 0&&(l.successResponseHeaders?.length??0)>0&&H(e,l,o,s,t,c,n,!0);let p=r.get(o);if(p!==void 0){let u=E(l),$=te(u,typeof p.items=="string"?p.items:void 0,n);re(e,l,o,t,$===void 0?"Any":y($,c),c)}}}),e.blank()}function Y(e){let n=new Map,s=new Set,t=[];for(let{name:a,schema:c}of e.schemas){let i=C(c,e);if(!(i===void 0||!i.cases.every(l=>U(l.schema,e)?.properties.some(o=>o.name===i.property)===!0))){for(let l of i.cases){let o=n.get(l.schemaName);if(o!==void 0&&o.value!==l.value){s.add(l.schemaName);continue}n.set(l.schemaName,{property:i.property,value:l.value})}t.push({name:a,property:i.property,members:i.cases.map(l=>l.schemaName)})}}let r=new Map;for(let a of t)a.members.some(c=>s.has(c))||r.set(a.name,q(a.property).python);for(let a of s)n.delete(a);return{pins:n,unions:r}}function pe(e,n,s,t,r,a,c){let i=r==="pydantic";i||e.line("@dataclass");let m=i?`class ${O(n)}(BaseModel):`:`class ${O(n)}:`;e.block(m,()=>{e.doc(a),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let l=[...s.filter(p=>p.required),...s.filter(p=>!p.required)],o=[];l.length===0&&e.line("pass");for(let p of l){let{python:u,renamed:$}=q(p.name);$&&!i&&o.push([u,p.name]);let h=$&&i?`alias=${f.string(p.name)}`:void 0,g=c?.property===p.name?`Literal[${f.literal(c.value)}]`:y(p.schema,t);if(p.required){let v=h===void 0?"":` = Field(${h})`;e.line(`${u}: ${g}${v}`)}else{let v=g.startsWith("Optional[")?g:`Optional[${g}]`,P=h===void 0?"None":`Field(default=None, ${h})`;e.line(`${u}: ${v} = ${P}`)}}if(o.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let p=o.map(([u,$])=>`"${u}": ${f.string($)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${p}}`)}}),e.blank(),e.blank()}function G(e,n="string",s="dataclass"){let t=new R,{pins:r,unions:a}=s==="pydantic"?Y(e):{pins:new Map,unions:new Map};t.line("from __future__ import annotations"),t.blank(),s==="dataclass"&&t.line("from dataclasses import dataclass"),t.line("from enum import Enum");let c=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];s==="dataclass"&&c.splice(2,0,"ClassVar"),a.size>0&&c.unshift("Annotated"),t.line(`from typing import ${c.join(", ")}`),s==="pydantic"&&t.line("from pydantic import BaseModel, ConfigDict, Field"),n==="Date"&&t.line("from datetime import date, datetime"),t.blank(),t.blank();let i=[];for(let{name:m,schema:l}of e.schemas){let o=Z(l);if(o!==void 0){let p=o.scalar==="string"?"str, Enum":"int, Enum";t.block(`class ${O(m)}(${p}):`,()=>{t.doc(l.description),o.values.forEach((u,$)=>{t.line(`${o.memberNames[$]} = ${f.literal(u)}`)})}),t.blank(),t.blank();continue}if(l.kind==="object"||l.kind==="intersection"){let p=U(l,e);if(p!==void 0){pe(t,m,p.properties,n,s,p.description??l.description,r.get(m));continue}}i.push(()=>{let p=C(l,e);if(p!==void 0){let h=p.cases.map(g=>`${g.value} -> ${O(g.schemaName)}`).join(", ");t.line(`# Discriminated by "${p.property}": ${h}`)}let u=a.get(m),$=u===void 0?y(l,n):`Annotated[${y(l,n)}, Field(discriminator=${f.string(u)})]`;t.line(`${O(m)} = ${$}`),t.blank()})}for(let m of i)m();return t.toString()}function ce(e,n){let s=[];for(let{name:t,schema:r}of e.schemas){if(n.has(t))continue;let a=C(r,e);if(a===void 0)continue;let c=a.cases.map(i=>`${f.string(i.value)}: ${O(i.schemaName)}`).join(", ");s.push(`DISCRIMINATORS[${O(t)}] = (${f.string(a.property)}, {${c}})`)}return s}var Ve={type:"object",properties:{models:{enum:["dataclass","pydantic"],default:"dataclass",description:"Model style: standard-library dataclasses (default, httpx is the only dependency), or pydantic BaseModel classes (adds pydantic)."}},additionalProperties:!1};function V(e){let n=e.lastIndexOf("/")>=0?"/":"\\",s=e.lastIndexOf(n),t=s>=0?e.slice(0,s+1):"",r=(s>=0?e.slice(s+1):e).replace(/\.[^.]+$/,"");return`${t}${w(r,{style:"snake",reserved:k})}.py`}var ze=({model:e,output:n,banner:s,emit:t,options:r,pagination:a})=>{let c=t.errorMode??"throw",i=t.dateType??"string",m=r?.models??"dataclass",l=m==="pydantic"?Y(e):void 0,o=new R;if(o.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),o.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),o.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),o.blank(),o.line(G(e,i,m).trimEnd()),o.blank(),o.blank(),ie(o,e),t.runtime==="module"){o.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let d of Object.keys(L))o.line(`from ${d.replace(/\.py$/,"")} import *`);o.blank(),o.blank()}else{o.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let d of Object.values(L)){let _=d.split(`
|
|
8
|
-
`).filter(b=>!b.startsWith("from __future__")&&!b.startsWith("from ._")).join(`
|
|
9
|
-
`).trim();o.line(_),o.blank()}o.blank()}let p=ce(e,new Set(l?.unions.keys()));if(p.length>0){o.line("# Discriminated unions dispatch by their property inside decode().");for(let d of p)o.line(d);o.blank()}o.block("def _safe_json(response: httpx.Response) -> Any:",()=>{o.block("try:",()=>{o.line("return response.json()")}),o.block("except Exception:",()=>{o.line("return None")})}),o.blank();let u=new Map;for(let{op:d,ident:_}of I(e))u.set(_,oe(a?.get(d.name)?.spec));o.line("_OPERATIONS = {"),o.indent(()=>{for(let{op:d,ident:_}of I(e)){let b={id:d.specName??d.name,method:d.method.toUpperCase(),path:d.path,...B(d,e).length>0?{security:B(d,e)}:{},...u.get(_)!==void 0?{pagination:u.get(_)}:{}};o.line(`"${_}": ${se(b)},`)}}),o.line("}"),o.blank(),o.blank();let $=t.serverUrl??e.serverUrl??"";K(o,e,c,!1,u,$,i),K(o,e,c,!0,u,$,i);let h={path:V(n.path),content:o.toString()};if(t.runtime!=="module")return[h];let g=s.map(d=>`# ${d}`).join(`
|
|
10
|
-
`),v=V(n.path).replace(/[^\\/]+$/,""),P=Object.entries(L).map(([d,_])=>({path:`${v}${d}`,content:`${g}
|
|
11
|
-
|
|
12
|
-
${_.split(`
|
|
13
|
-
`).map(b=>b.startsWith("from ._")?b.replace("from ._","from _"):b).join(`
|
|
14
|
-
`).trim()}
|
|
15
|
-
`}));return[h,...P]};function de(e,n){let s=V(n.outputPath).replace(/^.*[\\/]/,"").replace(/\.py$/,""),t=I(n.model).find(a=>a.op.name===e.name)?.ident??w(e.name,{style:"snake",reserved:k}),r=[...e.pathParams.map(a=>{let c=w(a.name,{style:"snake",reserved:k});return`${c}="<${c}>"`}),...e.queryParams.filter(a=>a.required).map(a=>`${w(a.name,{style:"snake",reserved:k})}=...`),...e.requestBody?["body=..."]:[]];return{lang:"python",label:"Python SDK",source:`from ${s} import Client
|
|
16
|
-
|
|
17
|
-
client = Client()
|
|
18
|
-
result = client.${t}(${r.join(", ")})
|
|
19
|
-
`}}var Je=({model:e,output:n,emit:s,pagination:t})=>[{path:n.path.replace(/\.[^.\\/]+$/,".python.md"),content:J(e,{title:`${e.title} Python SDK reference`,frontmatter:s.docsFrontmatter===!0,language:{name:"python",label:"Python",fence:"python",requires:"The SDK needs `httpx`."},sample:r=>de(r,{model:e,emit:s,outputPath:n.path}),paginated:new Set(t?.keys()??[])})}];export{y as a,G as b,Ve as c,ze as d,de as e,Je as f};
|
package/lib/chunks/V4SBON7Y.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{d as a,e as b,f as c}from"./BFGFT7E3.js";import"./UKSQ7B5H.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{b as typescriptDocs,a as typescriptGenerator,c as typescriptSample};
|
package/lib/chunks/X3MZMREJ.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e,f}from"./ULV3D265.js";import"./SQVG3CEM.js";import"./UKSQ7B5H.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{f as pythonDocs,d as pythonGenerator,c as pythonOptions,e as pythonSample,a as pythonType,b as renderPythonModels};
|
package/lib/chunks/XWZNQKXF.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as T}from"./4PT55VGO.js";import{a as x,e as M,f as j,i as H,j as O,k as f,l as v}from"./NB54XRRU.js";import{n as N}from"./HJYFWIVE.js";function w(e){return e.contentType==="multipart/form-data"&&e.schema.kind==="object"}var V=" ";function K(e,s=[]){let t=N(e,{schemas:s});return t==="integer"?"number":t}function re(e,s=[]){let t=C(e,s);if(t.length!==0)return t.map(n=>({name:n.name,key:n.key,type:n.type}))}function q(e,s=[],t=""){let n=t+V,r=C(e,s).map(o=>`${n}${o.key}${o.required===!0?"":"?"}: ${o.type};`);return r.length===0?"{}":`{
|
|
8
|
-
${r.join(`
|
|
9
|
-
`)}
|
|
10
|
-
${t}}`}function C(e,s){let t=new Set;return(e??[]).map(n=>({...n,key:j(v(n.name),t),type:K(n.schema,s)}))}var E=" ";function h(e,s,t){let n=O(e,s);return n===void 0?[]:[`${t}/**`,...H(n).split(`
|
|
11
|
-
`).map(r=>`${t} * ${r}`.replace(/ +$/,"")),`${t} */`]}function D(e){return typeof e=="string"?JSON.stringify(e):String(e)}function W(e,s,t){switch(e){case"string":return s?.format==="binary"?"Blob":t==="Date"&&(s?.format==="date-time"||s?.format==="date")?"Date":"string";case"number":case"integer":return"number";case"boolean":return"boolean"}}function k(e){return e.kind==="union"||e.kind==="intersection"||e.kind==="enum"&&e.values.length>1}function u(e,s="string",t=""){switch(e.kind){case"scalar":return W(e.scalar,e.metadata,s);case"ref":return e.name;case"literal":return D(e.value);case"enum":return e.values.map(D).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let n=u(e.items,s,t);return k(e.items)?`(${n})[]`:`${n}[]`}case"record":return`Record<string, ${u(e.value,s,t)}>`;case"object":{if(e.properties.length===0)return"{}";let n=t+E;return`{
|
|
12
|
-
${e.properties.flatMap(o=>F(o,s,n)).join(`
|
|
13
|
-
`)}
|
|
14
|
-
${t}}`}case"union":return e.members.map(n=>{let r=u(n,s,t);return k(n)?`(${r})`:r}).join(" | ");case"intersection":return e.members.map(n=>{let r=u(n,s,t);return k(n)?`(${r})`:r}).join(" & ");case"omit":return`Omit<${e.base}, ${e.keys.map(n=>JSON.stringify(n)).join(" | ")}>`}}function F(e,s,t){let n=M(e.name),r=e.readOnly?"readonly ":"",o=e.required?"":"?",a=u(e.schema,s,t);return[...h(e.description,e.schema.metadata,t),`${t}${r}${n}${o}: ${a};`]}function U(e){let s=e.schema;return s.kind!=="enum"||s.scalar!=="string"?[]:s.values.every(t=>typeof t=="string"&&x(t))?[`export const ${e.name} = {`,...s.values.map((t,n)=>`${E}${t}: ${JSON.stringify(t)}${n===s.values.length-1?"":","}`),"} as const;"]:[]}function ae(e,s="string"){let t=[];for(let n of e){let r=[...h(n.schema.description??n.description,n.schema.metadata,""),`export type ${n.name} = ${u(n.schema,s)};`];t.push(r.join(`
|
|
15
|
-
`));let o=U(n);o.length>0&&t.push(o.join(`
|
|
16
|
-
`))}return t.join(`
|
|
17
|
-
|
|
18
|
-
`)}function g(e){let s=new Map(e.pathParams.map(n=>[n.name,n])),t=[];for(let n of e.path.matchAll(/\{([^{}]+)\}/g)){let r=s.get(n[1]);r!==void 0&&t.push(r)}return t}function A(e){let s=g(e),t=e.queryParams.length>0,n=!!e.requestBody,r=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:t,hasBody:n,hasHeaders:r,hasCookies:o,hasInputs:s.length>0||t||n||r||o,varsRequired:s.length>0||e.queryParams.some(a=>a.required)||(e.requestBody?.required??!1)||e.headerParams.some(a=>a.required)||e.cookieParams.some(a=>a.required),variablesTypeName:`${f(e.name)}Variables`}}var y=" ";function S(e,s,t=""){if(w(e))return u(e.schema,s,t);switch(e.contentType){case"multipart/form-data":return"FormData";case"application/x-www-form-urlencoded":return"URLSearchParams";case"application/octet-stream":return"Blob | ArrayBuffer";default:return u(e.schema,s,t)}}function p(e,s,t=""){let n=t+y,r=e.flatMap(o=>[...h(o.description,o.schema.metadata,n),`${n}${M(o.name)}${o.required?"":"?"}: ${u(o.schema,s,n)};`]);return r.length===0?"{}":`{
|
|
19
|
-
${r.join(`
|
|
20
|
-
`)}
|
|
21
|
-
${t}}`}function I(e,s,t=""){if(e.length===0)return{type:"void",kind:"void"};let n=e.find(i=>i.contentType.toLowerCase().includes("json"));if(n)return{type:u(n.schema,s,t),kind:"json"};let r=[],o=new Set,a=!1,d=!1;for(let i of e){let c;i.contentType.startsWith("image/")||i.contentType==="application/octet-stream"?(c="Blob",a=!0):i.contentType.startsWith("text/")?(c="string",d=!0):c=u(i.schema,s,t),!o.has(c)&&(o.add(c),r.push(c))}return{type:r.join(" | "),kind:a?"blob":d?"text":"json"}}function J(e,s,t=""){let n=new Set,r=[];for(let o of e){let a=u(o.schema,s,t);n.has(a)||(n.add(a),r.push(a))}return r}function z(e,s,t=""){let n=e.sse?.eventSchema;return n?u(n,s,t):"string"}function $(e,s,t,n,r,o){let a=r.has(s)?t():s;return`${o}${e}${n?"":"?"}: ${a};`}function G(e,s){let t=new Set,n=e;for(;n.kind==="ref";){let{name:r}=n;if(t.has(r))return;t.add(r);let o=s?.find(a=>a.name===r);if(o===void 0)return;n=o.schema}return n}function L(e,s){let t=G(e,s);if(t?.kind==="object")return t.properties.map(r=>r.name);if(t?.kind!=="intersection")return;let n=new Set;for(let r of t.members){let o=L(r,s);if(o===void 0)return;for(let a of o)n.add(a)}return[...n]}function X(e,s){let t=[...g(e),...e.queryParams,...e.headerParams,...e.cookieParams],n=(e.requestBody?.required??!1)&&e.requestBody!==void 0?L(e.requestBody.schema,s):void 0,r=n!==void 0,o=new Map;for(let d of t)o.set(d.name,(o.get(d.name)??0)+1);e.requestBody&&!r&&o.set("body",(o.get("body")??0)+1);for(let d of n??[])o.set(d,(o.get(d)??0)+1);let a=[...o].filter(([,d])=>d>1).map(([d])=>d);return a.length>0?{collisions:a}:{mergeBody:r}}function Y(e,s,t){return e.flatMap(n=>[...h(n.description,n.schema.metadata,t),`${t}${M(n.name)}${n.required?"":"?"}: ${u(n.schema,s.dateType,t)};`])}function Q(e,s,t,n=""){let{dateType:r,schemaNames:o}=t,a=n+y,d=t.argsStyle==="flat"?X(e,t.schemas):void 0;if(d!==void 0&&"mergeBody"in d)return Z(e,s,t,d.mergeBody,n);let i=[],c=g(e);return c.length>0&&i.push($("path",`${s}Path`,()=>p(c,r,a),!0,o,a)),e.queryParams.length>0&&i.push($("query",`${s}Query`,()=>p(e.queryParams,r,a),e.queryParams.some(m=>m.required),o,a)),e.requestBody&&i.push($("body",`${s}Body`,()=>S(e.requestBody,r,a),e.requestBody.required,o,a)),e.headerParams.length>0&&i.push($("headers",`${s}Headers`,()=>p(e.headerParams,r,a),e.headerParams.some(m=>m.required),o,a)),e.cookieParams.length>0&&i.push($("cookies",`${s}Cookies`,()=>p(e.cookieParams,r,a),e.cookieParams.some(m=>m.required),o,a)),i.length===0?"{}":`{
|
|
22
|
-
${i.join(`
|
|
23
|
-
`)}
|
|
24
|
-
${n}}`}function Z(e,s,t,n,r){let o=r+y,a=Y([...g(e),...e.queryParams,...e.headerParams,...e.cookieParams],t,o);e.requestBody&&!n&&a.push($("body",`${s}Body`,()=>S(e.requestBody,t.dateType,o),e.requestBody.required,t.schemaNames,o));let d=t.schemaNames.has(`${s}Body`)?S(e.requestBody,t.dateType,r):`${s}Body`,i=a.length===0?"{}":`{
|
|
25
|
-
${a.join(`
|
|
26
|
-
`)}
|
|
27
|
-
${r}}`;return n?a.length===0?d:`${i} & ${d}`:i}function B(e,s,t){let n=`${f(e.name)}Result`;return s.schemaNames.has(n)?I(e.successResponses,s.dateType,t).type:n}function _(e,s,t){let n=J(e.errorResponses,s.dateType,t);if(n.length===0)return"unknown";let r=`${f(e.name)}Error`;return s.schemaNames.has(r)?n.join(" | "):r}function he(e,s,t){let n=T(e.services);if(n.length===0)return"";let r=n.flatMap(o=>{let a=s.get(o.name),d=f(o.name),i=y+y,c=Q(o,d,t,i),m=o.sse!==void 0,P=m?z(o,t.dateType,i):t.errorMode==="result"?`Result<${B(o,t,i)}, ${_(o,t,i)}>`:B(o,t,i),l=[`${i}args: ${c};`,`${i}result: ${P};`];t.errorMode==="result"&&!m&&l.push(`${i}mode: "result";`);let b=o.successResponseHeaders;b&&b.length>0&&l.push(`${i}headers: ${q(b,t.schemas,i)};`);let R=t.pagination?.get(o.name);return R&&(l.push(`${i}item: ${u(R.itemSchema,t.dateType,i)};`),t.errorMode==="result"&&l.push(`${i}page: ${B(o,t,i)};`)),m&&l.push(`${i}kind: "sse";`),[`${y}${a}: {`,...l,`${y}};`]});return[...h("Per-operation `args`/`result` shapes (plus `kind: 'sse'` for event streams) \u2014 the\ntype-level companion of `OPERATIONS` that gives `createClient<Ops>` its typed methods.",void 0,""),"export type Ops = {",...r,"};"].join(`
|
|
28
|
-
`)}function ge(e,s){let{dateType:t,schemaNames:n}=s,r=f(e.name),o=e.sse!==void 0,{hasInputs:a}=A(e),d=[];if(!o){let m=`${r}Result`;if(n.has(m)||d.push(`export type ${m} = ${I(e.successResponses,t).type};`),s.errorMode==="result"){let P=J(e.errorResponses,t),l=`${r}Error`;P.length>0&&!n.has(l)&&d.push(`export type ${l} = ${P.join(" | ")};`)}}let i=g(e);i.length>0&&!n.has(`${r}Path`)&&d.push(`export type ${r}Path = ${p(i,t)};`),e.queryParams.length>0&&!n.has(`${r}Query`)&&d.push(`export type ${r}Query = ${p(e.queryParams,t)};`),e.requestBody&&!n.has(`${r}Body`)&&d.push(`export type ${r}Body = ${S(e.requestBody,t)};`),e.headerParams.length>0&&!n.has(`${r}Headers`)&&d.push(`export type ${r}Headers = ${p(e.headerParams,t)};`);let c=e.successResponseHeaders;return c&&c.length>0&&!n.has(`${r}ResponseHeaders`)&&d.push(`export type ${r}ResponseHeaders = ${q(c,s.schemas)};`),e.cookieParams.length>0&&!n.has(`${r}Cookies`)&&d.push(`export type ${r}Cookies = ${p(e.cookieParams,t)};`),a&&!n.has(`${r}Variables`)&&d.push(`export type ${r}Variables = ${Q(e,r,s)};`),d.join(`
|
|
29
|
-
|
|
30
|
-
`)}function $e(e,s){let t=new Set,n=r=>{switch(r.kind){case"ref":t.add(r.name);return;case"omit":t.add(r.base);return;case"array":n(r.items);return;case"record":n(r.value);return;case"object":for(let o of r.properties)n(o.schema);return;case"union":case"intersection":for(let o of r.members)n(o);return;default:return}};for(let r of T(e.services)){for(let a of[...r.pathParams,...r.queryParams,...r.headerParams,...r.cookieParams])n(a.schema);r.requestBody&&n(r.requestBody.schema);for(let a of r.successResponses)n(a.schema),a.itemSchema&&n(a.itemSchema);if(s.errorMode==="result")for(let a of r.errorResponses)n(a.schema);let o=s.pagination?.get(r.name);o&&n(o.itemSchema)}return[...t].filter(r=>s.schemaNames.has(r)).sort()}export{A as a,w as b,re as c,h as d,ae as e,I as f,X as g,he as h,ge as i,$e as j};
|
package/lib/chunks/YEK532UO.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import"./UKSQ7B5H.js";import{b as S,c as v,d as k,e as P,f as w,g as D,h as q,i as U,j as B}from"./XWZNQKXF.js";import{b,g as R}from"./NAGDQV7J.js";import{a as d,c as j,d as N,e as T}from"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{d as E,f as A,h as I,i as x,m as C}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as Y}from"node:path";var y="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function O(e){return e.filter(t=>t.length>0).join(`
|
|
8
|
-
|
|
9
|
-
`)+`
|
|
10
|
-
`}function M(e){let t=["/**",` * ${x(`${e.title} (v${e.version})`)}`];if(e.description)for(let n of C(x(e.description)))t.push(` * ${n}`.replace(/ +$/,""));return t.push(" */"),t.join(`
|
|
11
|
-
`)}function $(e){let t=new Set(T),n=new Map;for(let r of d(e.services))n.set(r.name,A(r.name,t));return n}function Z(e,t,n,r,i=[],o="grouped"){let s=[...e.pathParams,...e.queryParams,...e.headerParams,...e.cookieParams].map(p=>({name:p.name,in:p.in,...p.style!==void 0?{style:p.style}:{},...p.explode!==void 0?{explode:p.explode}:{},...p.allowReserved!==void 0?{allowReserved:p.allowReserved}:{}})),c=R(e,{securitySchemes:t}),m=e.sse!==void 0?"sse":w(e.successResponses,n).kind,l=v(e.successResponseHeaders,i);return{id:e.specName??e.name,method:e.method.toUpperCase(),path:e.path,...e.tags.length>0?{tags:e.tags}:{},...s.length>0?{params:s}:{},...e.requestBody?{body:{contentType:e.requestBody.contentType,...S(e.requestBody)?{multipart:!0}:{}}}:{},...m!=="json"?{responseKind:m}:{},...e.sse===void 0?{}:{sseDataKind:e.sse.dataKind},...c.length>0?{security:c}:{},...l===void 0?{}:{responseHeaders:l},...r?.has(e.name)?{pagination:r.get(e.name).spec}:{},...o==="flat"&&"collisions"in D(e,i)?{argsStyle:"grouped"}:{}}}function F(e,t,n,r,i="grouped"){let o=d(e.services);if(o.length===0)return"";let s=o.map((a,m)=>{let l=I(Z(a,e.securitySchemes,n,r,e.schemas,i));return` ${t.get(a.name)}: ${l}${m===o.length-1?"":","}`}),c=[[...k(`The wire-shape descriptor for every operation, keyed by operationId \u2014 the data the
|
|
12
|
-
runtime routes requests by. Also minification-safe static metadata (method, path,
|
|
13
|
-
tags) for cache keys, tracing span names, and request logging.`,void 0,""),"export const OPERATIONS = {",...s,"} as const satisfies Record<string, OperationDescriptor>;"].join(`
|
|
14
|
-
`),'export type OperationId = (typeof OPERATIONS)[keyof typeof OPERATIONS]["id"];','export type OperationPath = (typeof OPERATIONS)[keyof typeof OPERATIONS]["path"];'];return o.some(a=>a.tags.length>0)&&c.push(`export type OperationTag = Extract<(typeof OPERATIONS)[keyof typeof OPERATIONS], {
|
|
15
|
-
tags: readonly string[];
|
|
16
|
-
}>["tags"][number];`),c.join(`
|
|
17
|
-
|
|
18
|
-
`)}var ee="// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator, assembled per this API's needs) \u2500\u2500\u2500";function L(e){let t=["types.ts","errors.ts","url.ts","parse.ts","retry.ts"];return e.multipart&&t.push("multipart.ts"),e.auth&&t.push("auth.ts"),e.setup&&t.push("setup.ts"),e.paginate&&t.push("paginate.ts"),t.push("send.ts"),e.sse&&t.push("sse.ts"),t.push("create-client.ts"),t}function G(e){return[ee,...L(e).map(t=>N[t]),H(e)].join(`
|
|
19
|
-
|
|
20
|
-
`)}function _(e,t="js"){let n=[...L(e).map(r=>({name:r,content:j[r]})),{name:"factory.ts",content:te(e)}];return t==="js"?n:n.map(({name:r,content:i})=>({name:r,content:i.replace(/(from '\.\/[a-z-]+)\.js'/g,"$1.ts'")}))}function te(e){let t=["import { createClientCore } from './create-client.js';",...e.multipart?["import { toFormData } from './multipart.js';"]:[],...e.auth?["import { resolveAuth } from './auth.js';"]:[],...e.paginate?["import { items, itemsByLink, pages, pagesByLink } from './paginate.js';"]:[],...e.sse?["import { sse } from './sse.js';"]:[],`import type {
|
|
21
|
-
Client,
|
|
22
|
-
ClientConfig,
|
|
23
|
-
OperationContext,
|
|
24
|
-
OperationDescriptor,
|
|
25
|
-
OpsShape,
|
|
26
|
-
} from './types.js';`],n=["export { ApiError, TimeoutError } from './errors.js';","export { defaultRetryOn } from './retry.js';",...e.setup?["export { mergeSetup } from './setup.js';"]:[],"export type * from './types.js';"];return[t.join(`
|
|
27
|
-
`),H(e),n.join(`
|
|
28
|
-
`)].join(`
|
|
29
|
-
|
|
30
|
-
`)}function H(e){let t=[...e.multipart?["serializeMultipart: toFormData"]:[],...e.auth?["resolveAuth"]:[],...e.sse?["sse"]:[],...e.paginate?["paginate: { pages, items, pagesByLink, itemsByLink }"]:[]];return`/**
|
|
31
|
-
* The client factory: \`createClientCore\` wired with the capabilities this API needs.
|
|
32
|
-
* Exported so apps can build additional instances (per-tenant, per-environment) over
|
|
33
|
-
* the same \`OPERATIONS\`/\`Ops\`. The trailing string params carry the wiring's literal
|
|
34
|
-
* unions (\`OperationId\`/\`OperationPath\`/\`OperationTag\`) into \`ctx.operation\`.
|
|
35
|
-
*/
|
|
36
|
-
export function createClient<
|
|
37
|
-
Ops extends OpsShape,
|
|
38
|
-
Id extends string = string,
|
|
39
|
-
Path extends string = string,
|
|
40
|
-
Tag extends string = string,
|
|
41
|
-
>(
|
|
42
|
-
operations: Record<string, OperationDescriptor>,
|
|
43
|
-
config?: ClientConfig<OperationContext<Id, Path, Tag>>
|
|
44
|
-
): Client<Ops, OperationContext<Id, Path, Tag>> {
|
|
45
|
-
return createClientCore<Ops, Id, Path, Tag>(operations, config, ${t.length>0?`{ ${t.join(", ")} }`:"{}"});
|
|
46
|
-
}`}function J(e){let t=new Map(e.map(i=>[i.name,i.schema])),n=[],r=new Set;for(let i of e)for(let o of ne(i)){let s=o.union.discriminator??re(o.union,t);if(!s)continue;let c=new Map;for(let a of s.mapping){if(!t.has(a.schemaName))continue;let m=c.get(a.schemaName);m?m.push(a.value):c.set(a.schemaName,[a.value])}for(let[a,m]of c){let l=`is${a}`;if(r.has(l))continue;r.add(l);let p=`(value as Record<string, unknown>)[${JSON.stringify(s.propertyName)}]`,f=m.length===1?`${p} === ${JSON.stringify(m[0])}`:`([${m.map(h=>JSON.stringify(h)).join(", ")}] as readonly unknown[]).includes(${p})`;n.push(["/**",` * Narrow a \`${o.label}\` to \`${a}\` via its \`${s.propertyName}\` discriminant.`," */",`export function ${l}(value: ${o.label}): value is ${a} {`,` return ${f};`,"}"].join(`
|
|
47
|
-
`))}}return n.join(`
|
|
48
|
-
|
|
49
|
-
`)}function ne(e){let t=[],n=e.schema;if(n.kind==="union"){t.push({union:n,label:e.name});for(let r of n.members)g(r,t)}else g(n,t);return t}function g(e,t){switch(e.kind){case"union":{let n=e.members.map(r=>r.kind==="ref"?r.name:void 0);n.every(r=>r!==void 0)&&t.push({union:e,label:n.join(" | ")});for(let r of e.members)g(r,t);break}case"array":g(e.items,t);break;case"record":g(e.value,t);break;case"object":for(let n of e.properties)g(n.schema,t);break;case"intersection":for(let n of e.members)g(n,t);break}}function re(e,t){let n=[];for(let i of e.members){if(i.kind!=="ref"||!t.get(i.name))return;n.push(i.name)}if(n.length<2)return;let r=n.map(i=>ie(t.get(i)));for(let i of Object.keys(r[0])){if(!r.every(s=>i in s))continue;let o=r.map(s=>s[i]);if(o.every(s=>typeof s=="string")&&new Set(o).size===o.length)return{propertyName:i,mapping:n.map((s,c)=>({value:o[c],schemaName:s}))}}}function ie(e){let t={},n=r=>{if(r.kind==="object")for(let i of r.properties)i.schema.kind==="literal"&&(t[i.name]=i.schema.value);else if(r.kind==="intersection")for(let i of r.members)n(i)};return n(e),t}function K(e,t={}){return X(e,t).entry}function Q(e,t){let n=d(e.services);return{multipart:n.some(r=>r.requestBody&&S(r.requestBody)),auth:e.securitySchemes.length>0||n.some(r=>r.security.length>0),sse:n.some(r=>r.sse!==void 0),setup:!!t.setup,paginate:(t.pagination??new Map).size>0}}function V(e,t){return t.runtime!=="module"?[]:_(Q(e,t),t.importExt??"js").map(({name:n,content:r})=>({name:n,content:`${y}
|
|
50
|
-
|
|
51
|
-
${r.trim()}
|
|
52
|
-
`}))}function se(e,t,n){let r=e.importExt??"js",i=["OperationDescriptor",...e.setup?["ClientConfig","Middleware"]:[],...t.errorMode==="result"&&n?["Result"]:[]].sort();return[`import { createClient${e.setup?", mergeSetup":""} } from './runtime/factory.${r}';`,`import type { ${i.join(", ")} } from './runtime/types.${r}';`,`export * from './runtime/factory.${r}';`].join(`
|
|
53
|
-
`)}function W(e,t,n){return X(e,t,n)}function X(e,t,n){let r=d(e.services),i=$(e),o=t.pagination??new Map,s={argsStyle:t.argsStyle??"grouped",errorMode:t.errorMode??"throw",dateType:t.dateType??"string",schemaNames:new Set(e.schemas.map(u=>u.name)),schemas:e.schemas,pagination:o},c=r.length>0?[q(e,i,s),F(e,i,s.dateType,o,s.argsStyle)]:["export type Ops = Record<string, never>;","export const OPERATIONS = {} as const satisfies Record<string, OperationDescriptor>;"],a=t.runtime==="module"?se(t,s,r.length>0):G(Q(e,t)),m=[P(e.schemas,s.dateType),J(e.schemas)].filter(u=>u.length>0).join(`
|
|
54
|
-
|
|
55
|
-
`),l=[...r.map(u=>U(u,s)),...c].filter(u=>u.length>0).join(`
|
|
56
|
-
|
|
57
|
-
`),p=ae(r,i),f=t.runtime==="module";if(n===void 0)return{entry:O([y,M(e),...f?[a]:[],[m,l].filter(u=>u.length>0).join(`
|
|
58
|
-
|
|
59
|
-
`),...f?[]:[a],z(t,s,e),p])};let h=m.length>0;return{entry:O([y,M(e),...f?[a]:[],h?oe(e,s,`./${n}.schemas.${t.importExt??"js"}`):"",l,...f?[]:[a],z(t,s,e),p]),schemas:h?O([y,M(e),m]):void 0}}function oe(e,t,n){let r=B(e,t);return`${r.length>0?`import type { ${r.join(", ")} } from '${n}';
|
|
60
|
-
`:""}export * from '${n}';`}function z(e,t,n){let r=e.serverUrl??n.serverUrl,i=[...r!==void 0?[`serverUrl: ${E(r)}`]:[],...t.errorMode==="result"?['errorMode: "result"']:[],...t.argsStyle==="flat"?['argsStyle: "flat"']:[],'clientHeader: "redocly-client-generator"'],o=i.length>0?`{ ${i.join(", ")} }`:"{}",s=e.setup?`mergeSetup({ config: ${o} }, mergeSetup(__redoclySetup, {}))`:o,c=d(n.services),a=c.some(p=>p.tags.length>0),l=`export const client = createClient${c.length>0?`<Ops, OperationId, OperationPath, ${a?"OperationTag":"string"}>`:"<Ops>"}(OPERATIONS, ${s});`;return e.setup?`// \u2500\u2500\u2500 Baked-in setup (--setup) \u2500\u2500\u2500
|
|
61
|
-
const __redoclySetup: { config?: ClientConfig; middleware?: Middleware[] } = ${e.setup};
|
|
62
|
-
`+l:l}function ae(e,t){let n=["export const { configure, use } = client;"];if(e.length===0)return n.join(`
|
|
63
|
-
`);let r=e.map(i=>t.get(i.name)).join(", ");return n.push(`export const { ${r} } = client;`),n.join(`
|
|
64
|
-
`)}var we=({model:e,output:t,outputMode:n,emit:r})=>{let i=V(e,r).map(({name:o,content:s})=>({path:Y(t.dir,"runtime",o),content:s}));if(n==="split"){let{dir:o,stem:s}=t,{entry:c,schemas:a}=W(e,r,s);return[...a===void 0?[]:[{path:Y(o,`${s}.schemas.ts`),content:a}],{path:t.path,content:c},...i]}return[{path:t.path,content:K(e,r)},...i]},De=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".typescript.md"),content:b(e,{title:`${e.title} TypeScript client reference`,frontmatter:n.docsFrontmatter===!0,language:{name:"typescript",label:"TypeScript",fence:"typescript",requires:"The client has no dependencies."},sample:i=>pe(i,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];function pe(e,t){let n=$(t.model).get(e.name)??e.name,i=`./${t.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,"")}.${t.emit.importExt??"js"}`,o=e.queryParams.filter(p=>p.required),s=t.emit.argsStyle==="flat",c=e.pathParams.map(p=>`${p.name}: '<${p.name}>'`),a=o.map(p=>`${p.name}: /* \u2026 */`),m=s?[...c,...a,...e.requestBody?["/* body properties */"]:[]]:[...c.length>0?[`path: { ${c.join(", ")} }`]:[],...a.length>0?[`query: { ${a.join(", ")} }`]:[],...e.requestBody?["body: { /* \u2026 */ }"]:[]],l=m.length>0?[`{ ${m.join(", ")} }`]:[];return{lang:"typescript",label:"TypeScript SDK",source:`import { ${n} } from '${i}';
|
|
65
|
-
|
|
66
|
-
const result = await ${n}(${l.join(", ")});
|
|
67
|
-
`}}export{De as typescriptDocs,we as typescriptGenerator,pe as typescriptSample};
|
package/lib/chunks/ZBL4IVEW.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as m}from"./3JJEI7CJ.js";import{a as s}from"./PFYPTG4G.js";import{e as f}from"./RFWIIJFG.js";var e=f(m(),1);if(typeof e.default?.createSourceFile!="function")throw new Error(`Baking a --setup module needs the TypeScript compiler API, but the installed \`typescript\` package${e.default?.version?` (${e.default.version})`:""} does not include it \u2014 TypeScript 7 ships only the native tsc. Install TypeScript 6 for generation (npm i -D typescript@6); your app can still compile the generated client with TypeScript 7.`);var l="@redocly/client-generator";function y(n){let i=e.default.createSourceFile("setup.ts",n,e.default.ScriptTarget.Latest,!0,e.default.ScriptKind.TS),p=[],r,d="defineClientSetup";for(let t of i.statements){if(e.default.isImportDeclaration(t)){let o=t.moduleSpecifier.text;if(o!==l)throw new s(`A --setup file may only import from "${l}"; found "${o}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);let a=t.importClause?.namedBindings;if(a&&e.default.isNamedImports(a))for(let c of a.elements)(c.propertyName?.text??c.name.text)==="defineClientSetup"&&(d=c.name.text);continue}if(e.default.isExportAssignment(t)&&!t.isExportEquals){r=g(t.expression,d).getText(i);continue}if(e.default.isExportDeclaration(t)){if(t.moduleSpecifier!==void 0)throw new s(`A --setup file may only import from "${l}"; found "${t.moduleSpecifier.text}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);continue}let u=e.default.canHaveModifiers(t)?e.default.getModifiers(t)?.find(o=>o.kind===e.default.SyntaxKind.ExportKeyword):void 0;p.push(u===void 0?t.getText(i):n.slice(u.end,t.getEnd()).trimStart())}if(r===void 0)throw new s("A --setup file must `export default defineClientSetup({ config, middleware })` (or a setup object).");return p.length===0?r:`(() => {
|
|
8
|
-
${p.join(`
|
|
9
|
-
`)}
|
|
10
|
-
return ${r};
|
|
11
|
-
})()`}function g(n,i){return e.default.isCallExpression(n)&&e.default.isIdentifier(n.expression)&&n.expression.text===i&&n.arguments.length===1?n.arguments[0]:n}export{y as bakeSetup};
|
|
File without changes
|