@redocly/cli 2.47.0 → 2.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chunks/{QRD3XQNU.js → 2U54VUOE.js} +1 -1
- package/lib/chunks/3JJEI7CJ.js +456 -0
- package/lib/chunks/4I2OVMBJ.js +11 -0
- package/lib/chunks/{REBHK2JR.js → 4JDAOKRJ.js} +1 -1
- package/lib/chunks/5JIGUBC3.js +7 -0
- package/lib/chunks/{QVV2EKMT.js → 5SAFIITS.js} +1 -1
- package/lib/chunks/6KCIFTIG.js +57 -0
- package/lib/chunks/{5NR4DJW4.js → 6VSHPQXO.js} +1 -1
- package/lib/chunks/{W2NJCZOS.js → 74WJ7S7J.js} +1 -1
- package/lib/chunks/{QL4V2A4A.js → 7R5PBTLG.js} +1 -1
- package/lib/chunks/BT3ELZVX.js +42 -0
- package/lib/chunks/C5TR4MMN.js +19 -0
- package/lib/chunks/CCR5RYCX.js +20 -0
- package/lib/chunks/DCN3GSUA.js +7 -0
- package/lib/chunks/{TEQA5OM7.js → E5I67ZCZ.js} +1 -1
- package/lib/chunks/FUMCRNTK.js +78 -0
- package/lib/chunks/GNMJA2V2.js +16 -0
- package/lib/chunks/GRJG3TOI.js +14 -0
- package/lib/chunks/HA22GUKQ.js +7 -0
- package/lib/chunks/HJ36YGCI.js +184 -0
- package/lib/chunks/HJYFWIVE.js +9 -0
- package/lib/chunks/HL5FOKC4.js +16 -0
- package/lib/chunks/{SL6AH3N2.js → JBNPGEIJ.js} +1 -1
- package/lib/chunks/KHEMMNFU.js +26 -0
- package/lib/chunks/{SN2EC2ZR.js → KK2STV73.js} +1 -1
- package/lib/chunks/KK77ANZH.js +7 -0
- package/lib/chunks/L3TZNNJJ.js +13 -0
- package/lib/chunks/M6KLAAY4.js +7 -0
- package/lib/chunks/MHITBEGC.js +90 -0
- package/lib/chunks/NB54XRRU.js +10 -0
- package/lib/chunks/NSIQWNYL.js +7 -0
- package/lib/chunks/{YQW463Z7.js → NTPLYWAB.js} +1 -1
- package/lib/chunks/{5PXRDPHV.js → NUNOXB7Z.js} +1 -1
- package/lib/chunks/NWMTC4AN.js +7 -0
- package/lib/chunks/NYLAOZPO.js +22 -0
- package/lib/chunks/O4R6BSAS.js +20 -0
- package/lib/chunks/OKITK6EF.js +30 -0
- package/lib/chunks/OUCZOBEX.js +22 -0
- package/lib/chunks/PFYPTG4G.js +7 -0
- package/lib/chunks/QZH7EL26.js +7 -0
- package/lib/chunks/R4XFBOJU.js +9 -0
- package/lib/chunks/REFX2EKS.js +13 -0
- package/lib/chunks/{S4MX7JPH.js → RXOEH2LN.js} +1 -1
- package/lib/chunks/SGBB4RNM.js +11 -0
- package/lib/chunks/SQVG3CEM.js +8 -0
- package/lib/chunks/{RIFZSMUA.js → T5EPIBMA.js} +1 -1
- package/lib/chunks/TLQZAJQU.js +18 -0
- package/lib/chunks/TSB6PODJ.js +13 -0
- package/lib/chunks/TSRK76GA.js +19 -0
- package/lib/chunks/{34J2ZJDK.js → U2H2LXZE.js} +1 -1
- package/lib/chunks/UKSQ7B5H.js +2268 -0
- package/lib/chunks/UMQN5HTL.js +42 -0
- package/lib/chunks/V2LJ4UGM.js +7 -0
- package/lib/chunks/VBPP2WUF.js +7 -0
- package/lib/chunks/WPGKH5NI.js +177 -0
- package/lib/chunks/WXVC3KOI.js +67 -0
- package/lib/chunks/{KEUH3PST.js → YI34NB7D.js} +1 -1
- package/lib/chunks/YOJGIGE3.js +7 -0
- package/lib/chunks/{TO2KJ36N.js → YP5GHFYE.js} +1 -1
- package/lib/chunks/YXXYE4G2.js +7 -0
- package/lib/chunks/ZBL4IVEW.js +11 -0
- package/lib/chunks/ZMCRMR2V.js +5400 -0
- package/lib/chunks/ZOUQBK53.js +14 -0
- package/lib/chunks/ZXKOHMC6.js +177 -0
- package/lib/eject-assets/AGENTS.md +137 -0
- package/lib/eject-assets/generators/cli/docs.ts +224 -0
- package/lib/eject-assets/generators/cli/engine-source.ts +21 -0
- package/lib/eject-assets/generators/cli/index.ts +90 -0
- package/lib/eject-assets/generators/cli/render.ts +348 -0
- package/lib/eject-assets/generators/go/client.ts +57 -0
- package/lib/eject-assets/generators/go/descriptor.ts +41 -0
- package/lib/eject-assets/generators/go/index.ts +336 -0
- package/lib/eject-assets/generators/go/models.ts +179 -0
- package/lib/eject-assets/generators/go/naming.ts +49 -0
- package/lib/eject-assets/generators/go/operations.ts +296 -0
- package/lib/eject-assets/generators/go/pagination.ts +194 -0
- package/lib/eject-assets/generators/go/types.ts +60 -0
- package/lib/eject-assets/generators/mock/faker.ts +214 -0
- package/lib/eject-assets/generators/mock/index.ts +35 -0
- package/lib/eject-assets/generators/mock/render.ts +282 -0
- package/lib/eject-assets/generators/mock/sample.ts +316 -0
- package/lib/eject-assets/generators/mock/values.ts +63 -0
- package/lib/eject-assets/generators/php/client.ts +63 -0
- package/lib/eject-assets/generators/php/descriptor.ts +58 -0
- package/lib/eject-assets/generators/php/index.ts +237 -0
- package/lib/eject-assets/generators/php/models.ts +275 -0
- package/lib/eject-assets/generators/php/naming.ts +51 -0
- package/lib/eject-assets/generators/php/operations.ts +232 -0
- package/lib/eject-assets/generators/php/pagination.ts +133 -0
- package/lib/eject-assets/generators/php/types.ts +148 -0
- package/lib/eject-assets/generators/python/client.ts +123 -0
- package/lib/eject-assets/generators/python/descriptor.ts +52 -0
- package/lib/eject-assets/generators/python/index.ts +251 -0
- package/lib/eject-assets/generators/python/models.ts +242 -0
- package/lib/eject-assets/generators/python/naming.ts +46 -0
- package/lib/eject-assets/generators/python/operations.ts +147 -0
- package/lib/eject-assets/generators/python/pagination.ts +128 -0
- package/lib/eject-assets/generators/python/types.ts +54 -0
- package/lib/eject-assets/generators/swr/index.ts +37 -0
- package/lib/eject-assets/generators/swr/render.ts +78 -0
- package/lib/eject-assets/generators/tanstack-query/index.ts +48 -0
- package/lib/eject-assets/generators/tanstack-query/render.ts +346 -0
- package/lib/eject-assets/generators/transformers/index.ts +46 -0
- package/lib/eject-assets/generators/transformers/render.ts +506 -0
- package/lib/eject-assets/generators/typescript/banner.ts +35 -0
- package/lib/eject-assets/generators/typescript/client.ts +254 -0
- package/lib/eject-assets/generators/typescript/descriptor.ts +137 -0
- package/lib/eject-assets/generators/typescript/index.ts +101 -0
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +135 -0
- package/lib/eject-assets/generators/typescript/operation-signature.ts +62 -0
- package/lib/eject-assets/generators/typescript/operation-types.ts +17 -0
- package/lib/eject-assets/generators/typescript/operations.ts +524 -0
- package/lib/eject-assets/generators/typescript/response-headers.ts +74 -0
- package/lib/eject-assets/generators/typescript/type-guards.ts +159 -0
- package/lib/eject-assets/generators/typescript/types.ts +172 -0
- package/lib/eject-assets/generators/zod/index.ts +32 -0
- package/lib/eject-assets/generators/zod/schemas.ts +456 -0
- package/lib/eject-assets/skills/cli-generator/SKILL.md +121 -0
- package/lib/eject-assets/skills/client-generators/SKILL.md +142 -0
- package/lib/eject-assets/skills/go-generator/SKILL.md +96 -0
- package/lib/eject-assets/skills/mock-generator/SKILL.md +50 -0
- package/lib/eject-assets/skills/php-generator/SKILL.md +112 -0
- package/lib/eject-assets/skills/python-generator/SKILL.md +110 -0
- package/lib/eject-assets/skills/swr-generator/SKILL.md +50 -0
- package/lib/eject-assets/skills/tanstack-query-generator/SKILL.md +55 -0
- package/lib/eject-assets/skills/transformers-generator/SKILL.md +47 -0
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +95 -0
- package/lib/eject-assets/skills/zod-generator/SKILL.md +54 -0
- package/lib/index.js +271 -193
- package/package.json +1 -1
- package/lib/chunks/B6HS7CVY.js +0 -184
- package/lib/chunks/PIJLRHNN.js +0 -8
- package/lib/chunks/Y5HLCNL5.js +0 -2542
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
var c=class{constructor(n=" "){this.indentUnit=n}indentUnit;lines=[];depth=0;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(`
|
|
8
|
+
`)+`
|
|
9
|
+
`}};function d(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 p=e=>e.charAt(0).toUpperCase()+e.slice(1),l={camel:e=>{let[n,...t]=d(e);return(n??"")+t.map(p).join("")},pascal:e=>d(e).map(p).join(""),snake:e=>d(e).join("_"),screaming:e=>d(e).join("_").toUpperCase()},S={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 h(e,n={}){let t=l[n.style??"camel"](e),r=t===""?"_":/^[0-9]/.test(t)?`_${t}`:t;return n.reserved?.has(r.toLowerCase())?`${r}_`:r}function m(e,n={}){let t=new Set(n.taken??[]),r=n.style==="snake"||n.style==="screaming"?"_":"";return e.map(s=>{let i=h(s,n),o=i;for(let f=2;t.has(o);f++)o=`${i}${r}${f}`;return t.add(o),o})}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 i=n.schemas.find(o=>o.name===s);if(i===void 0)return;r=i.schema}return r}function b(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 i=b(s,n);if(i===void 0)return;for(let o of i.properties)r.set(o.name,o)}return{properties:[...r.values()],description:t.description}}function M(e,n){let t=a(e,n);if(t?.kind!=="union"||t.discriminator===void 0)return;let r=[];for(let{value:s,schemaName:i}of t.discriminator.mapping){let o=a({kind:"ref",name:i},n);if(o===void 0)return;r.push({value:s,schemaName:i,schema:o})}return{property:t.discriminator.propertyName,cases:r}}function y(e){return e.kind==="union"&&e.members.some(n=>n.kind==="null")}function x(e){if(e.kind!=="union"||!y(e))return e;let n=e.members.filter(t=>t.kind!=="null");return n.length===1?n[0]:{...e,members:n}}function A(e){if(e.kind!=="enum")return;let n=m(e.values.map(t=>typeof t=="string"?l.screaming(t):`VALUE_${l.screaming(String(t))}`),{style:"screaming"});return{values:e.values,scalar:e.scalar,memberNames:n}}function $(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 g(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 i=a(s,t);i!==void 0&&(r=g(i,n,t)??r)}return r}}function N(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 i=s.replaceAll("~1","/").replaceAll("~0","~"),o=g(r,i,t);if(o===void 0||(r=a(o,t),r===void 0))return}return r}}function u(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":u(r.schema,n,t)}if(e.kind==="intersection"){let r=e.members.filter(i=>i.kind!=="unknown");if(r.length===1)return u(r[0],n,t);let s=[...new Set(r.map(i=>u(i,n,new Set(t))))];return s.length===1?s[0]:s.every(i=>i==="integer"||i==="number")?"number":"string"}if(e.kind==="union"){let r=e.members.filter(s=>s.kind!=="null");return r.length===1?u(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"}export{c as a,l as b,S as c,h as d,m as e,a as f,b as g,M as h,y as i,x as j,A as k,$ as l,N as m,u as n};
|
|
@@ -0,0 +1,16 @@
|
|
|
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 $,b as i,c,d as a,e as m,f as p}from"./R4XFBOJU.js";import"./OKITK6EF.js";import"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import{k as u}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as M}from"node:path";function d(t,e){let r=$(t,"swr");if(r.length===0)return"";let s=r.some(i),o=r.some(n=>!i(n));return[...s?['import useSWR from "swr";']:[],...o?['import useSWRMutation from "swr/mutation";']:[],p(r,e.sdkModule,s),...r.flatMap(n=>i(n)?y(n):[k(n)])].join(`
|
|
8
|
+
|
|
9
|
+
`)}function f(t,e,r){return`export function use${u(t.name)}(${e}) {
|
|
10
|
+
return ${r};
|
|
11
|
+
}`}function y(t){let e=c(t),r=e?`vars: ${a(t)}`:"",s=e?`[${JSON.stringify(t.name)}, vars]`:`[${JSON.stringify(t.name)}]`,o=`export const ${t.name}Key = (${r}) => ${s} as const;`,n=`useSWR(${`${t.name}Key(${e?"vars":""})`}, () => ${m(t,"vars",!0)})`,g=e?`vars: ${a(t)}, init?: Omit<RequestOptions, "envelope">`:'init?: Omit<RequestOptions, "envelope">';return[o,f(t,g,n)]}function k(t){let e=c(t)?`(_key: string, { arg }: {
|
|
12
|
+
arg: ${a(t)};
|
|
13
|
+
}) => ${m(t,"arg",!1)}`:`() => ${m(t,"arg",!1)}`,r=`useSWRMutation(${JSON.stringify(t.name)}, ${e})`;return f(t,"",r)}var h=({model:t,output:e,banner:r,emit:s})=>{let o=d(t,{sdkModule:`./${e.stem}.${s.importExt??"js"}`});if(o==="")return[];let l=r.map(n=>`// ${n}`).join(`
|
|
14
|
+
`);return[{path:M(e.dir,`${e.stem}.swr.ts`),content:`${l}
|
|
15
|
+
|
|
16
|
+
${o}`}]};export{h as swrGenerator};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as x}from"./
|
|
7
|
+
import{a as x}from"./YP5GHFYE.js";import{a as v,b as y,c as R,d as u}from"./NUNOXB7Z.js";import{c as f,d as w}from"./NTPLYWAB.js";import{a as g,b as m}from"./2U54VUOE.js";import{O as a}from"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as A,writeFile as C}from"node:fs/promises";import S from"node:path";async function F(e){let i=await w(e.trafficPath);if(i.length===0)throw new Error("No traffic files found in the provided traffic path.");let t=y.create({openApiIndex:e.openApiIndex,matchMode:e.matchMode,ignoreCookies:e.ignoreCookies,ignoreHeaders:e.ignoreHeaders,previewFindingsLimit:e.previewFindingsLimit,activeRules:e.activeRules,server:e.server,minSeverity:e.minSeverity}),r=0,o=0;for(let n of i){let s=await x(n,e.format);if(!s){a.warn(`Skipping traffic file with unrecognized format: ${n}
|
|
8
8
|
`);continue}r+=1;for await(let c of s.parse(n))await t.process({...c,index:o}),o+=1}if(r===0)throw new Error("No supported traffic files found. In auto mode, files must match built-in traffic parser signatures.");if(o===0)throw new Error("No HTTP exchanges were parsed from the provided traffic files.");return t.finalize()}var E=!!process.stdout.isTTY&&process.env.NO_COLOR===void 0;function T(e){let i=new Set;for(let t of e.operationsByMethod.values())for(let r of t)for(let o of r.servers)i.add(o.rawUrl);return Array.from(i).sort()}function I(e,i,t){let r=e.totalExchanges-e.skippedExchanges;if(r===0&&e.skippedExchanges>0){a.warn(`All ${e.skippedExchanges} exchange(s) were outside the --server "${t}" and were skipped. Check that the server matches the traffic URLs.
|
|
9
9
|
`);return}if(e.documentedExchanges>0||r===0)return;let o=T(i),n=t?`Check that the --server "${t}" matches the traffic URLs and that the description paths align with the remainder.`:e.hostCompatibleExchanges===r?`The traffic hosts are compatible with the description servers (${o.join(", ")}), so the endpoints are likely undocumented; if they should be documented, check that the description base paths and paths align with the traffic URLs, or use --server to declare the server the traffic was captured against.`:`Check that the traffic host and base path match the description servers (${o.join(", ")}), or use --server to declare the server the traffic was captured against.`;a.warn(`None of the ${r} validated exchange(s) matched a documented operation. ${n}
|
|
10
10
|
`)}async function $(e,i){let t=f(e);await A(S.dirname(t),{recursive:!0}),await C(t,i,"utf8")}async function q({argv:e,config:i}){let t=f(e.traffic),r=e["traffic-format"],o=e.rules?u(e.rules):void 0,n=e["ignore-headers"]?u(e["ignore-headers"]):void 0,s=e.server;if(s&&e["match-mode"])return m("The --server and --match-mode options are mutually exclusive: --match-mode controls how requests are located via the description servers, while --server replaces the description servers with the one the traffic was captured against.");let c=e["match-mode"]??"strict-host",d=f(e.api),p=await R(d,i);if(p.loadedOperations===0)return m(`No OpenAPI operations were loaded from: ${d}`);let{runId:k,summary:h,findings:O}=await F({trafficPath:t,format:r,matchMode:c,ignoreCookies:e["ignore-cookies"],ignoreHeaders:n,previewFindingsLimit:e["max-findings"],activeRules:o,openApiIndex:p,server:s,minSeverity:e["min-severity"]});I(h,p,s);let l=v({runId:k,summary:h,findings:O,meta:{specSource:d,trafficPath:t,format:r,matchMode:c,server:s}},{format:e["report-format"],color:E&&e["report-format"]==="pretty"&&!e.output,maxFindings:e["max-findings"]});if(e.output?(await $(e.output,l),a.info(`Drift report written to: ${f(e.output)}
|
|
@@ -0,0 +1,26 @@
|
|
|
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"./OUCZOBEX.js";import{d as Ke,e as Ue,f as Fe}from"./TSRK76GA.js";import{c as Be,d as He,e as Ge}from"./O4R6BSAS.js";import{a as h}from"./WZXA5XPB.js";import{a as kn,b as Ce,c as Se,d as Ae}from"./FUMCRNTK.js";import{c as Ee,d as Te,e as qe}from"./ZOUQBK53.js";import{a as $}from"./BT3ELZVX.js";import{a as Pe,b as xn,c as On,d as Ie,e as $e,f as je}from"./MHITBEGC.js";import{a as Ne}from"./WPGKH5NI.js";import{a as De}from"./TSB6PODJ.js";import{a as Le}from"./GNMJA2V2.js";import"./SQVG3CEM.js";import"./REFX2EKS.js";import"./NSIQWNYL.js";import"./UKSQ7B5H.js";import"./R4XFBOJU.js";import"./OKITK6EF.js";import"./4I2OVMBJ.js";import{g as Re}from"./ZMCRMR2V.js";import"./PFYPTG4G.js";import{C as we,O as w,R as ve,W as ke,aa as xe,c as O,ca as _,ja as Oe,q as R,s as be}from"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";function M(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./VBPP2WUF.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("./HA22GUKQ.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./KK77ANZH.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("./V2LJ4UGM.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./DCN3GSUA.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./YOJGIGE3.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:z,load:()=>import("./5JIGUBC3.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:z,load:()=>import("./M6KLAAY4.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:z,load:()=>import("./QZH7EL26.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 ke,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:ve(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};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{h as a}from"./
|
|
7
|
+
import{h as a}from"./5SAFIITS.js";import"./P26PQ2RU.js";import"./RS5PUOTT.js";import"./6VSHPQXO.js";import"./BXI4SF2U.js";import"./32XCOMOR.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{a as RedoclyOAuthClient};
|
|
@@ -0,0 +1,7 @@
|
|
|
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}from"./WPGKH5NI.js";import"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{a as zodGenerator};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{e as y,k as A}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as R}from"node:path";var u=" ";function M(t){return`transform${A(t)}`}var I="type __Writable<T> = { -readonly [K in keyof T]: T[K] };",k=!1;function _(t){return{text:t,path:[t]}}function G(t,r){return{text:`${t.text}[${JSON.stringify(r)}]`,path:[...t.path,r]}}function d(t,r,n){if(x(t))return!0;switch(t.kind){case"array":return d(t.items,r,n);case"union":return t.members.some(e=>d(e,r,n));case"ref":{if(n.has(t.name))return!1;let e=r.get(t.name);return e!==void 0&&d(e,r,new Set(n).add(t.name))}default:return!1}}function x(t){return t.kind==="scalar"&&t.scalar==="string"&&(t.metadata?.format==="date-time"||t.metadata?.format==="date")}function l(t,r,n){if(x(t))return!0;switch(t.kind){case"array":return l(t.items,r,n);case"record":return l(t.value,r,n);case"object":return t.properties.some(e=>l(e.schema,r,n));case"union":case"intersection":return t.members.some(e=>l(e,r,n));case"ref":{let e=r.get(t.name);return e!==void 0&&!n.has(t.name)?l(e,r,new Set(n).add(t.name)):!1}default:return!1}}function $(t,r,n,e=!1){return e?[`${n}if (${t}) {`,...r(n+u),`${n}}`]:[`${n}if (${t})`,...r(n+u)]}function m(t,r,n=!1){let e=n?J(t):t.text;return s=>[`${s}${e} = ${r};`]}function T(t){return r=>[`${r}${t};`]}function J(t){if(t.path.length<2)return t.text;k=!0;let r={text:t.text.slice(0,t.text.lastIndexOf("[")),path:t.path.slice(0,-1)},n=t.path[t.path.length-1];return`(${r.text} as __Writable<${C(r)}>)[${JSON.stringify(n)}]`}function C(t){let r=`typeof ${t.path[0]}`;for(let n of t.path.slice(1))r=`NonNullable<${r}>[${JSON.stringify(n)}]`;return`NonNullable<${r}>`}function W(t){return t==="data"?"item":`item${Number(t.slice(4))+1}`}function g(t,r,n,e,s,o,a=!1){if(x(r))return $(`typeof ${t.text} === "string"`,m(t,`new Date(${t.text})`,a),o);switch(r.kind){case"ref":return w(t,r.name,n,e,o,a);case"object":{let i=[];for(let f of r.properties)i.push(...K(G(t,f.name),f.schema,n,e,s,o,f.readOnly===!0));return i}case"array":return U(t,r.items,n,e,s,o,a);case"record":return b(t,r.value,n,e,s,o,!0);case"intersection":{let i=[];for(let f of r.members)i.push(...g(t,f,n,e,s,o,a));return i}case"union":return B(t,r.members,n,e,s,o,a);default:return[]}}function B(t,r,n,e,s,o,a=!1){let i=[],f=o+u,p=[];for(let c of r)if(x(c))i.push(...g(t,c,n,e,s,o,a));else if(c.kind==="ref"){if(!l(c,n,e))continue;let S=`${M(c.name)}(${t.text} as ${c.name})`,h=d(c,n,e)?m(t,S,a):T(S);p.push(...h(f))}else p.push(...g(t,c,n,e,s,f,a));return p.length>0&&i.push(...$(`${t.text} && typeof ${t.text} === "object"`,()=>p,o,!0)),i}function w(t,r,n,e,s,o=!1){let a={kind:"ref",name:r};if(!l(a,n,e))return[];let i=`${M(r)}(${t.text})`;return $(t.text,d(a,n,e)?m(t,i,o):T(i),s)}function K(t,r,n,e,s,o,a=!1){if(r.kind==="ref")return w(t,r.name,n,e,o,a);if(r.kind==="object"){let i=g(t,r,n,e,s,o+u);return i.length===0?[]:$(t.text,()=>i,o,!0)}return g(t,r,n,e,s,o,a)}function j(t,r,n,e,s=0){if(x(r))return`new Date(${t})`;if(r.kind==="ref"&&d(r,n,e))return`${M(r.name)}(${t})`;if(r.kind==="array"){let o=r.items.kind==="array"?O(s+1):"v",a=j(o,r.items,n,e,s+1);return a===null?null:`${t}.map(${o} => ${a})`}return null}function O(t){return t<=1?"row":`row${t}`}function U(t,r,n,e,s,o,a=!1){let i=r.kind==="array"?O(1):"v",f=j(i,r,n,e,1);return f!==null?$(`Array.isArray(${t.text})`,m(t,`${t.text}.map(${i} => ${f})`,a),o):r.kind==="ref"?l(r,n,e)?$(`Array.isArray(${t.text})`,T(`${t.text}.forEach(${M(r.name)})`),o):[]:b(t,r,n,e,s,o,!1)}function b(t,r,n,e,s,o,a){if(a){let c={text:`${t.text}[__k]`,path:[...t.path,"__k"]},S=j(c.text,r,n,e);if(S!==null){let h=x(r)?`typeof ${c.text} === "string"`:`Array.isArray(${c.text})`;return $(t.text,v=>[`${v}for (const __k of Object.keys(${t.text}))`,...$(h,E=>[`${E}${c.text} = ${S};`],v+u)],o)}}let i=W(s),f=g(_(i),r,n,e,i,o+u+u);if(f.length===0)return[];let p=a?`Object.values(${t.text})`:t.text;return $(a?t.text:`Array.isArray(${t.text})`,c=>[`${c}${p}.forEach(${i} => {`,...f,`${c}});`],o)}function P(t,r){let n=t.name,e=_("data"),s=t.schema.kind==="ref"?w(e,t.schema.name,r,new Set,u):g(e,t.schema,r,new Set,"data",u);return[`export const ${M(t.name)} = (data: ${n}): ${n} => {`,...s,`${u}return data;`,"};"].join(`
|
|
8
|
+
`)}function D(t,r){let n=new Map(t.schemas.map(i=>[i.name,i.schema])),e=t.schemas.filter(i=>l(i.schema,n,new Set));if(e.length===0)return"";let s=e.map(i=>y(i.name)).join(", ");k=!1;let o=e.map(i=>P(i,n));return[`import type { ${s} } from ${JSON.stringify(r.sdkModule)};`,...k?[I]:[],...o].join(`
|
|
9
|
+
|
|
10
|
+
`)}var Q=({model:t,output:r,banner:n,emit:e})=>{let s=D(t,{sdkModule:`./${r.stem}.${e.importExt??"js"}`});if(s==="")return[];let o=n.map(a=>`// ${a}`).join(`
|
|
11
|
+
`);return[{path:R(r.dir,`${r.stem}.transformers.ts`),content:`${o}
|
|
12
|
+
|
|
13
|
+
${s}`}]};export{Q as transformersGenerator};
|
|
@@ -0,0 +1,7 @@
|
|
|
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}from"./ZOUQBK53.js";import"./REFX2EKS.js";import"./UKSQ7B5H.js";import"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{b as D,g as L}from"./4I2OVMBJ.js";import{a as h,c as F,d as J,e as U}from"./ZMCRMR2V.js";import{a as _,d as G,e as x,f as R,h as K,i as O,j as Q,k as b,l as V,m as z}from"./NB54XRRU.js";import{n as H}from"./HJYFWIVE.js";import{join as Se}from"node:path";var q="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function N(e){return e.filter(t=>t.length>0).join(`
|
|
8
|
+
|
|
9
|
+
`)+`
|
|
10
|
+
`}function v(e){let t=["/**",` * ${O(`${e.title} (v${e.version})`)}`];if(e.description)for(let n of z(O(e.description)))t.push(` * ${n}`.replace(/ +$/,""));return t.push(" */"),t.join(`
|
|
11
|
+
`)}function P(e){return e.contentType==="multipart/form-data"&&e.schema.kind==="object"}function k(e){let t=new Map(e.pathParams.map(r=>[r.name,r])),n=[];for(let r of e.path.matchAll(/\{([^{}]+)\}/g)){let s=t.get(r[1]);s!==void 0&&n.push(s)}return n}function W(e){let t=k(e),n=e.queryParams.length>0,r=!!e.requestBody,s=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:n,hasBody:r,hasHeaders:s,hasCookies:o,hasInputs:t.length>0||n||r||s||o,varsRequired:t.length>0||e.queryParams.some(i=>i.required)||(e.requestBody?.required??!1)||e.headerParams.some(i=>i.required)||e.cookieParams.some(i=>i.required),variablesTypeName:`${b(e.name)}Variables`}}var Te=" ";function Pe(e,t=[]){let n=H(e,{schemas:t});return n==="integer"?"number":n}function X(e,t=[]){let n=Y(e,t);if(n.length!==0)return n.map(r=>({name:r.name,key:r.key,type:r.type}))}function C(e,t=[],n=""){let r=n+Te,s=Y(e,t).map(o=>`${r}${o.key}${o.required===!0?"":"?"}: ${o.type};`);return s.length===0?"{}":`{
|
|
12
|
+
${s.join(`
|
|
13
|
+
`)}
|
|
14
|
+
${n}}`}function Y(e,t){let n=new Set;return(e??[]).map(r=>({...r,key:R(V(r.name),n),type:Pe(r.schema,t)}))}var ee=" ";function g(e,t,n){let r=Q(e,t);return r===void 0?[]:[`${n}/**`,...O(r).split(`
|
|
15
|
+
`).map(s=>`${n} * ${s}`.replace(/ +$/,"")),`${n} */`]}function Z(e){return typeof e=="string"?JSON.stringify(e):String(e)}function ke(e,t,n){switch(e){case"string":return t?.format==="binary"?"Blob":n==="Date"&&(t?.format==="date-time"||t?.format==="date")?"Date":"string";case"number":case"integer":return"number";case"boolean":return"boolean"}}function E(e){return e.kind==="union"||e.kind==="intersection"||e.kind==="enum"&&e.values.length>1}function l(e,t="string",n=""){switch(e.kind){case"scalar":return ke(e.scalar,e.metadata,t);case"ref":return e.name;case"literal":return Z(e.value);case"enum":return e.values.map(Z).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let r=l(e.items,t,n);return E(e.items)?`(${r})[]`:`${r}[]`}case"record":return`Record<string, ${l(e.value,t,n)}>`;case"object":{if(e.properties.length===0)return"{}";let r=n+ee;return`{
|
|
16
|
+
${e.properties.flatMap(o=>je(o,t,r)).join(`
|
|
17
|
+
`)}
|
|
18
|
+
${n}}`}case"union":return e.members.map(r=>{let s=l(r,t,n);return E(r)?`(${s})`:s}).join(" | ");case"intersection":return e.members.map(r=>{let s=l(r,t,n);return E(r)?`(${s})`:s}).join(" & ");case"omit":return`Omit<${e.base}, ${e.keys.map(r=>JSON.stringify(r)).join(" | ")}>`}}function je(e,t,n){let r=x(e.name),s=e.readOnly?"readonly ":"",o=e.required?"":"?",i=l(e.schema,t,n);return[...g(e.description,e.schema.metadata,n),`${n}${s}${r}${o}: ${i};`]}function xe(e){let t=e.schema;return t.kind!=="enum"||t.scalar!=="string"?[]:t.values.every(n=>typeof n=="string"&&_(n))?[`export const ${e.name} = {`,...t.values.map((n,r)=>`${ee}${n}: ${JSON.stringify(n)}${r===t.values.length-1?"":","}`),"} as const;"]:[]}function te(e,t="string"){let n=[];for(let r of e){let s=[...g(r.schema.description??r.description,r.schema.metadata,""),`export type ${r.name} = ${l(r.schema,t)};`];n.push(s.join(`
|
|
19
|
+
`));let o=xe(r);o.length>0&&n.push(o.join(`
|
|
20
|
+
`))}return n.join(`
|
|
21
|
+
|
|
22
|
+
`)}var S=" ";function w(e,t,n=""){if(P(e))return l(e.schema,t,n);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 l(e.schema,t,n)}}function $(e,t,n=""){let r=n+S,s=e.flatMap(o=>[...g(o.description,o.schema.metadata,r),`${r}${x(o.name)}${o.required?"":"?"}: ${l(o.schema,t,r)};`]);return s.length===0?"{}":`{
|
|
23
|
+
${s.join(`
|
|
24
|
+
`)}
|
|
25
|
+
${n}}`}function B(e,t,n=""){if(e.length===0)return{type:"void",kind:"void"};let r=e.find(a=>a.contentType.toLowerCase().includes("json"));if(r)return{type:l(r.schema,t,n),kind:"json"};let s=[],o=new Set,i=!1,c=!1;for(let a of e){let u;a.contentType.startsWith("image/")||a.contentType==="application/octet-stream"?(u="Blob",i=!0):a.contentType.startsWith("text/")?(u="string",c=!0):u=l(a.schema,t,n),!o.has(u)&&(o.add(u),s.push(u))}return{type:s.join(" | "),kind:i?"blob":c?"text":"json"}}function ne(e,t,n=""){let r=new Set,s=[];for(let o of e){let i=l(o.schema,t,n);r.has(i)||(r.add(i),s.push(i))}return s}function Oe(e,t,n=""){let r=e.sse?.eventSchema;return r?l(r,t,n):"string"}function j(e,t,n,r,s,o){let i=s.has(t)?n():t;return`${o}${e}${r?"":"?"}: ${i};`}function qe(e,t){let n=new Set,r=e;for(;r.kind==="ref";){let{name:s}=r;if(n.has(s))return;n.add(s);let o=t?.find(i=>i.name===s);if(o===void 0)return;r=o.schema}return r}function re(e,t){let n=qe(e,t);if(n?.kind==="object")return n.properties.map(s=>s.name);if(n?.kind!=="intersection")return;let r=new Set;for(let s of n.members){let o=re(s,t);if(o===void 0)return;for(let i of o)r.add(i)}return[...r]}function A(e,t){let n=[...k(e),...e.queryParams,...e.headerParams,...e.cookieParams],r=(e.requestBody?.required??!1)&&e.requestBody!==void 0?re(e.requestBody.schema,t):void 0,s=r!==void 0,o=new Map;for(let c of n)o.set(c.name,(o.get(c.name)??0)+1);e.requestBody&&!s&&o.set("body",(o.get("body")??0)+1);for(let c of r??[])o.set(c,(o.get(c)??0)+1);let i=[...o].filter(([,c])=>c>1).map(([c])=>c);return i.length>0?{collisions:i}:{mergeBody:s}}function Re(e,t,n){return e.flatMap(r=>[...g(r.description,r.schema.metadata,n),`${n}${x(r.name)}${r.required?"":"?"}: ${l(r.schema,t.dateType,n)};`])}function se(e,t,n,r=""){let{dateType:s,schemaNames:o}=n,i=r+S,c=n.argsStyle==="flat"?A(e,n.schemas):void 0;if(c!==void 0&&"mergeBody"in c)return Ne(e,t,n,c.mergeBody,r);let a=[],u=k(e);return u.length>0&&a.push(j("path",`${t}Path`,()=>$(u,s,i),!0,o,i)),e.queryParams.length>0&&a.push(j("query",`${t}Query`,()=>$(e.queryParams,s,i),e.queryParams.some(m=>m.required),o,i)),e.requestBody&&a.push(j("body",`${t}Body`,()=>w(e.requestBody,s,i),e.requestBody.required,o,i)),e.headerParams.length>0&&a.push(j("headers",`${t}Headers`,()=>$(e.headerParams,s,i),e.headerParams.some(m=>m.required),o,i)),e.cookieParams.length>0&&a.push(j("cookies",`${t}Cookies`,()=>$(e.cookieParams,s,i),e.cookieParams.some(m=>m.required),o,i)),a.length===0?"{}":`{
|
|
26
|
+
${a.join(`
|
|
27
|
+
`)}
|
|
28
|
+
${r}}`}function Ne(e,t,n,r,s){let o=s+S,i=Re([...k(e),...e.queryParams,...e.headerParams,...e.cookieParams],n,o);e.requestBody&&!r&&i.push(j("body",`${t}Body`,()=>w(e.requestBody,n.dateType,o),e.requestBody.required,n.schemaNames,o));let c=n.schemaNames.has(`${t}Body`)?w(e.requestBody,n.dateType,s):`${t}Body`,a=i.length===0?"{}":`{
|
|
29
|
+
${i.join(`
|
|
30
|
+
`)}
|
|
31
|
+
${s}}`;return r?i.length===0?c:`${a} & ${c}`:a}function M(e,t,n){let r=`${b(e.name)}Result`;return t.schemaNames.has(r)?B(e.successResponses,t.dateType,n).type:r}function ve(e,t,n){let r=ne(e.errorResponses,t.dateType,n);if(r.length===0)return"unknown";let s=`${b(e.name)}Error`;return t.schemaNames.has(s)?r.join(" | "):s}function oe(e,t,n){let r=h(e.services);if(r.length===0)return"";let s=r.flatMap(o=>{let i=t.get(o.name),c=b(o.name),a=S+S,u=se(o,c,n,a),m=o.sse!==void 0,p=m?Oe(o,n.dateType,a):n.errorMode==="result"?`Result<${M(o,n,a)}, ${ve(o,n,a)}>`:M(o,n,a),f=[`${a}args: ${u};`,`${a}result: ${p};`];n.errorMode==="result"&&!m&&f.push(`${a}mode: "result";`);let y=o.successResponseHeaders;y&&y.length>0&&f.push(`${a}headers: ${C(y,n.schemas,a)};`);let d=n.pagination?.get(o.name);return d&&(f.push(`${a}item: ${l(d.itemSchema,n.dateType,a)};`),n.errorMode==="result"&&f.push(`${a}page: ${M(o,n,a)};`)),m&&f.push(`${a}kind: "sse";`),[`${S}${i}: {`,...f,`${S}};`]});return[...g("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 = {",...s,"};"].join(`
|
|
32
|
+
`)}function ie(e,t){let{dateType:n,schemaNames:r}=t,s=b(e.name),o=e.sse!==void 0,{hasInputs:i}=W(e),c=[];if(!o){let m=`${s}Result`;if(r.has(m)||c.push(`export type ${m} = ${B(e.successResponses,n).type};`),t.errorMode==="result"){let p=ne(e.errorResponses,n),f=`${s}Error`;p.length>0&&!r.has(f)&&c.push(`export type ${f} = ${p.join(" | ")};`)}}let a=k(e);a.length>0&&!r.has(`${s}Path`)&&c.push(`export type ${s}Path = ${$(a,n)};`),e.queryParams.length>0&&!r.has(`${s}Query`)&&c.push(`export type ${s}Query = ${$(e.queryParams,n)};`),e.requestBody&&!r.has(`${s}Body`)&&c.push(`export type ${s}Body = ${w(e.requestBody,n)};`),e.headerParams.length>0&&!r.has(`${s}Headers`)&&c.push(`export type ${s}Headers = ${$(e.headerParams,n)};`);let u=e.successResponseHeaders;return u&&u.length>0&&!r.has(`${s}ResponseHeaders`)&&c.push(`export type ${s}ResponseHeaders = ${C(u,t.schemas)};`),e.cookieParams.length>0&&!r.has(`${s}Cookies`)&&c.push(`export type ${s}Cookies = ${$(e.cookieParams,n)};`),i&&!r.has(`${s}Variables`)&&c.push(`export type ${s}Variables = ${se(e,s,t)};`),c.join(`
|
|
33
|
+
|
|
34
|
+
`)}function ae(e,t){let n=new Set,r=s=>{switch(s.kind){case"ref":n.add(s.name);return;case"omit":n.add(s.base);return;case"array":r(s.items);return;case"record":r(s.value);return;case"object":for(let o of s.properties)r(o.schema);return;case"union":case"intersection":for(let o of s.members)r(o);return;default:return}};for(let s of h(e.services)){for(let i of[...s.pathParams,...s.queryParams,...s.headerParams,...s.cookieParams])r(i.schema);s.requestBody&&r(s.requestBody.schema);for(let i of s.successResponses)r(i.schema),i.itemSchema&&r(i.itemSchema);if(t.errorMode==="result")for(let i of s.errorResponses)r(i.schema);let o=t.pagination?.get(s.name);o&&r(o.itemSchema)}return[...n].filter(s=>t.schemaNames.has(s)).sort()}function I(e){let t=new Set(U),n=new Map;for(let r of h(e.services))n.set(r.name,R(r.name,t));return n}function we(e,t,n,r,s=[],o="grouped"){let i=[...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=L(e,{securitySchemes:t}),u=e.sse!==void 0?"sse":B(e.successResponses,n).kind,m=X(e.successResponseHeaders,s);return{id:e.specName??e.name,method:e.method.toUpperCase(),path:e.path,...e.tags.length>0?{tags:e.tags}:{},...i.length>0?{params:i}:{},...e.requestBody?{body:{contentType:e.requestBody.contentType,...P(e.requestBody)?{multipart:!0}:{}}}:{},...u!=="json"?{responseKind:u}:{},...e.sse===void 0?{}:{sseDataKind:e.sse.dataKind},...c.length>0?{security:c}:{},...m===void 0?{}:{responseHeaders:m},...r?.has(e.name)?{pagination:r.get(e.name).spec}:{},...o==="flat"&&"collisions"in A(e,s)?{argsStyle:"grouped"}:{}}}function ce(e,t,n,r,s="grouped"){let o=h(e.services);if(o.length===0)return"";let i=o.map((a,u)=>{let m=K(we(a,e.securitySchemes,n,r,e.schemas,s));return` ${t.get(a.name)}: ${m}${u===o.length-1?"":","}`}),c=[[...g(`The wire-shape descriptor for every operation, keyed by operationId \u2014 the data the
|
|
35
|
+
runtime routes requests by. Also minification-safe static metadata (method, path,
|
|
36
|
+
tags) for cache keys, tracing span names, and request logging.`,void 0,""),"export const OPERATIONS = {",...i,"} as const satisfies Record<string, OperationDescriptor>;"].join(`
|
|
37
|
+
`),'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], {
|
|
38
|
+
tags: readonly string[];
|
|
39
|
+
}>["tags"][number];`),c.join(`
|
|
40
|
+
|
|
41
|
+
`)}var Be="// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator, assembled per this API's needs) \u2500\u2500\u2500";function ue(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 me(e){return[Be,...ue(e).map(t=>J[t]),fe(e)].join(`
|
|
42
|
+
|
|
43
|
+
`)}function pe(e,t="js"){let n=[...ue(e).map(r=>({name:r,content:F[r]})),{name:"factory.ts",content:Ie(e)}];return t==="js"?n:n.map(({name:r,content:s})=>({name:r,content:s.replace(/(from '\.\/[a-z-]+)\.js'/g,"$1.ts'")}))}function Ie(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 {
|
|
44
|
+
Client,
|
|
45
|
+
ClientConfig,
|
|
46
|
+
OperationContext,
|
|
47
|
+
OperationDescriptor,
|
|
48
|
+
OpsShape,
|
|
49
|
+
} 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(`
|
|
50
|
+
`),fe(e),n.join(`
|
|
51
|
+
`)].join(`
|
|
52
|
+
|
|
53
|
+
`)}function fe(e){let t=[...e.multipart?["serializeMultipart: toFormData"]:[],...e.auth?["resolveAuth"]:[],...e.sse?["sse"]:[],...e.paginate?["paginate: { pages, items, pagesByLink, itemsByLink }"]:[]];return`/**
|
|
54
|
+
* The client factory: \`createClientCore\` wired with the capabilities this API needs.
|
|
55
|
+
* Exported so apps can build additional instances (per-tenant, per-environment) over
|
|
56
|
+
* the same \`OPERATIONS\`/\`Ops\`. The trailing string params carry the wiring's literal
|
|
57
|
+
* unions (\`OperationId\`/\`OperationPath\`/\`OperationTag\`) into \`ctx.operation\`.
|
|
58
|
+
*/
|
|
59
|
+
export function createClient<
|
|
60
|
+
Ops extends OpsShape,
|
|
61
|
+
Id extends string = string,
|
|
62
|
+
Path extends string = string,
|
|
63
|
+
Tag extends string = string,
|
|
64
|
+
>(
|
|
65
|
+
operations: Record<string, OperationDescriptor>,
|
|
66
|
+
config?: ClientConfig<OperationContext<Id, Path, Tag>>
|
|
67
|
+
): Client<Ops, OperationContext<Id, Path, Tag>> {
|
|
68
|
+
return createClientCore<Ops, Id, Path, Tag>(operations, config, ${t.length>0?`{ ${t.join(", ")} }`:"{}"});
|
|
69
|
+
}`}function le(e){let t=new Map(e.map(s=>[s.name,s.schema])),n=[],r=new Set;for(let s of e)for(let o of Ce(s)){let i=o.union.discriminator??Ee(o.union,t);if(!i)continue;let c=new Map;for(let a of i.mapping){if(!t.has(a.schemaName))continue;let u=c.get(a.schemaName);u?u.push(a.value):c.set(a.schemaName,[a.value])}for(let[a,u]of c){let m=`is${a}`;if(r.has(m))continue;r.add(m);let p=`(value as Record<string, unknown>)[${JSON.stringify(i.propertyName)}]`,f=u.length===1?`${p} === ${JSON.stringify(u[0])}`:`([${u.map(y=>JSON.stringify(y)).join(", ")}] as readonly unknown[]).includes(${p})`;n.push(["/**",` * Narrow a \`${o.label}\` to \`${a}\` via its \`${i.propertyName}\` discriminant.`," */",`export function ${m}(value: ${o.label}): value is ${a} {`,` return ${f};`,"}"].join(`
|
|
70
|
+
`))}}return n.join(`
|
|
71
|
+
|
|
72
|
+
`)}function Ce(e){let t=[],n=e.schema;if(n.kind==="union"){t.push({union:n,label:e.name});for(let r of n.members)T(r,t)}else T(n,t);return t}function T(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)T(r,t);break}case"array":T(e.items,t);break;case"record":T(e.value,t);break;case"object":for(let n of e.properties)T(n.schema,t);break;case"intersection":for(let n of e.members)T(n,t);break}}function Ee(e,t){let n=[];for(let s of e.members){if(s.kind!=="ref"||!t.get(s.name))return;n.push(s.name)}if(n.length<2)return;let r=n.map(s=>Me(t.get(s)));for(let s of Object.keys(r[0])){if(!r.every(i=>s in i))continue;let o=r.map(i=>i[s]);if(o.every(i=>typeof i=="string")&&new Set(o).size===o.length)return{propertyName:s,mapping:n.map((i,c)=>({value:o[c],schemaName:i}))}}}function Me(e){let t={},n=r=>{if(r.kind==="object")for(let s of r.properties)s.schema.kind==="literal"&&(t[s.name]=s.schema.value);else if(r.kind==="intersection")for(let s of r.members)n(s)};return n(e),t}function he(e,t={}){return be(e,t).entry}function ye(e,t){let n=h(e.services);return{multipart:n.some(r=>r.requestBody&&P(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 ge(e,t){return t.runtime!=="module"?[]:pe(ye(e,t),t.importExt??"js").map(({name:n,content:r})=>({name:n,content:`${q}
|
|
73
|
+
|
|
74
|
+
${r.trim()}
|
|
75
|
+
`}))}function Ae(e,t,n){let r=e.importExt??"js",s=["OperationDescriptor",...e.setup?["ClientConfig","Middleware"]:[],...t.errorMode==="result"&&n?["Result"]:[]].sort();return[`import { createClient${e.setup?", mergeSetup":""} } from './runtime/factory.${r}';`,`import type { ${s.join(", ")} } from './runtime/types.${r}';`,`export * from './runtime/factory.${r}';`].join(`
|
|
76
|
+
`)}function $e(e,t,n){return be(e,t,n)}function be(e,t,n){let r=h(e.services),s=I(e),o=t.pagination??new Map,i={argsStyle:t.argsStyle??"grouped",errorMode:t.errorMode??"throw",dateType:t.dateType??"string",schemaNames:new Set(e.schemas.map(d=>d.name)),schemas:e.schemas,pagination:o},c=r.length>0?[oe(e,s,i),ce(e,s,i.dateType,o,i.argsStyle)]:["export type Ops = Record<string, never>;","export const OPERATIONS = {} as const satisfies Record<string, OperationDescriptor>;"],a=t.runtime==="module"?Ae(t,i,r.length>0):me(ye(e,t)),u=[te(e.schemas,i.dateType),le(e.schemas)].filter(d=>d.length>0).join(`
|
|
77
|
+
|
|
78
|
+
`),m=[...r.map(d=>ie(d,i)),...c].filter(d=>d.length>0).join(`
|
|
79
|
+
|
|
80
|
+
`),p=He(r,s),f=t.runtime==="module";if(n===void 0)return{entry:N([q,v(e),...f?[a]:[],[u,m].filter(d=>d.length>0).join(`
|
|
81
|
+
|
|
82
|
+
`),...f?[]:[a],de(t,i,e),p])};let y=u.length>0;return{entry:N([q,v(e),...f?[a]:[],y?De(e,i,`./${n}.schemas.${t.importExt??"js"}`):"",m,...f?[]:[a],de(t,i,e),p]),schemas:y?N([q,v(e),u]):void 0}}function De(e,t,n){let r=ae(e,t);return`${r.length>0?`import type { ${r.join(", ")} } from '${n}';
|
|
83
|
+
`:""}export * from '${n}';`}function de(e,t,n){let r=e.serverUrl??n.serverUrl,s=[...r!==void 0?[`serverUrl: ${G(r)}`]:[],...t.errorMode==="result"?['errorMode: "result"']:[],...t.argsStyle==="flat"?['argsStyle: "flat"']:[],'clientHeader: "redocly-client-generator"'],o=s.length>0?`{ ${s.join(", ")} }`:"{}",i=e.setup?`mergeSetup({ config: ${o} }, mergeSetup(__redoclySetup, {}))`:o,c=h(n.services),a=c.some(p=>p.tags.length>0),m=`export const client = createClient${c.length>0?`<Ops, OperationId, OperationPath, ${a?"OperationTag":"string"}>`:"<Ops>"}(OPERATIONS, ${i});`;return e.setup?`// \u2500\u2500\u2500 Baked-in setup (--setup) \u2500\u2500\u2500
|
|
84
|
+
const __redoclySetup: { config?: ClientConfig; middleware?: Middleware[] } = ${e.setup};
|
|
85
|
+
`+m:m}function He(e,t){let n=["export const { configure, use } = client;"];if(e.length===0)return n.join(`
|
|
86
|
+
`);let r=e.map(s=>t.get(s.name)).join(", ");return n.push(`export const { ${r} } = client;`),n.join(`
|
|
87
|
+
`)}var Rt=({model:e,output:t,outputMode:n,emit:r})=>{let s=ge(e,r).map(({name:o,content:i})=>({path:Se(t.dir,"runtime",o),content:i}));if(n==="split"){let{dir:o,stem:i}=t,{entry:c,schemas:a}=$e(e,r,i);return[...a===void 0?[]:[{path:Se(o,`${i}.schemas.ts`),content:a}],{path:t.path,content:c},...s]}return[{path:t.path,content:he(e,r)},...s]},Nt=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".typescript.md"),content:D(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:s=>Le(s,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];function Le(e,t){let n=I(t.model).get(e.name)??e.name,s=`./${t.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,"")}.${t.emit.importExt??"js"}`,o=e.queryParams.filter(p=>p.required),i=t.emit.argsStyle==="flat",c=e.pathParams.map(p=>`${p.name}: '<${p.name}>'`),a=o.map(p=>`${p.name}: /* \u2026 */`),u=i?[...c,...a,...e.requestBody?["/* body properties */"]:[]]:[...c.length>0?[`path: { ${c.join(", ")} }`]:[],...a.length>0?[`query: { ${a.join(", ")} }`]:[],...e.requestBody?["body: { /* \u2026 */ }"]:[]],m=u.length>0?[`{ ${u.join(", ")} }`]:[];return{lang:"typescript",label:"TypeScript SDK",source:`import { ${n} } from '${s}';
|
|
88
|
+
|
|
89
|
+
const result = await ${n}(${m.join(", ")});
|
|
90
|
+
`}}export{W as a,g as b,l as c,Rt as d,Nt as e,Le as f};
|
|
@@ -0,0 +1,10 @@
|
|
|
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{c as f}from"./HJYFWIVE.js";var o=/^[A-Za-z_$][A-Za-z0-9_$]*$/,u=f.typescript;function m(n){return o.test(n)}function I(n){return o.test(n)&&!u.has(n)}function c(n){let e=n.replace(/[^A-Za-z0-9_$]/g,"_");return(e===""||/^[0-9]/.test(e)||u.has(e))&&(e=`_${e}`),e}var p={"<":"\\u003C",">":"\\u003E","\u2028":"\\u2028","\u2029":"\\u2029"};function s(n){return JSON.stringify(n).replace(/[<>\u2028\u2029]/g,e=>p[e])}function E(n){return o.test(n)&&!u.has(n)?n:s(n)}function b(n,e){let i=c(n),t=i,r=2;for(;e.has(t);)t=`${i}_${r++}`;return e.add(t),t}var L=s;function g(n){if(typeof n=="string")return s(n);if(typeof n=="boolean"||n===null||typeof n=="number")return String(n);if(Array.isArray(n))return`[${n.map(g).join(", ")}]`;let e=Object.entries(n).map(([i,t])=>`${m(i)?i:s(i)}: ${g(t)}`);return e.length===0?"{}":`{ ${e.join(", ")} }`}function d(n){return n.replace(/\*\//g,"*\\/")}function M(n,e){let i=l(n,e);return i.length===0?void 0:i.join(`
|
|
8
|
+
`)}function l(n,e){let i=[];return n&&n.trim()&&i.push(...x(S(n))),e&&i.push(...h(e)),i}function h(n){let e=[],i=(t,r)=>{r===void 0?e.push(`@${t}`):e.push(`@${t} ${r}`)};return n.minimum!==void 0&&i("minimum",n.minimum),n.maximum!==void 0&&i("maximum",n.maximum),n.exclusiveMinimum!==void 0&&i("exclusiveMinimum",n.exclusiveMinimum),n.exclusiveMaximum!==void 0&&i("exclusiveMaximum",n.exclusiveMaximum),n.minLength!==void 0&&i("minLength",n.minLength),n.maxLength!==void 0&&i("maxLength",n.maxLength),n.pattern!==void 0&&i("pattern",d(n.pattern)),n.minItems!==void 0&&i("minItems",n.minItems),n.maxItems!==void 0&&i("maxItems",n.maxItems),n.uniqueItems===!0&&i("uniqueItems"),n.format!==void 0&&i("format",n.format),n.deprecated===!0&&i("deprecated"),e}function x(n){let e=0,i=n.length;for(;e<i&&n[e]==="";)e++;for(;i>e&&n[i-1]==="";)i--;return n.slice(e,i)}function _(n){return n[0].toUpperCase()+n.slice(1)}function y(n){let e=n.split(/[-_]/).filter(i=>i.length>0).map((i,t)=>{let r=i.toLowerCase();return t===0?r:r.charAt(0).toUpperCase()+r.slice(1)}).join("");return c(e)}function S(n){return n.replace(/\r\n/g,`
|
|
9
|
+
`).split(`
|
|
10
|
+
`).map(e=>e.trimEnd())}export{m as a,I as b,c,s as d,E as e,b as f,L as g,g as h,d as i,M as j,_ as k,y as l,S as m};
|
|
@@ -0,0 +1,7 @@
|
|
|
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 g,c as f,d as i,e as c,l as o}from"./HJYFWIVE.js";var s=f.php,h=class extends g{constructor(){super(" ")}typeName(r){return i(r,{style:"pascal",reserved:s})}memberName(r){return i(r,{style:"camel",reserved:s})}identifier(r){return i(r,{style:"camel",reserved:s})}identifiers(r,t){return c(r,{style:"camel",reserved:s,taken:t})}string(r){return`'${r.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}literal(r){return r==null?"null":typeof r=="boolean"||typeof r=="number"?String(r):typeof r=="string"?this.string(r):Array.isArray(r)?`[${r.map(e=>this.literal(e)).join(", ")}]`:`[${Object.entries(r).map(([e,n])=>`${this.string(e)} => ${this.literal(n)}`).join(", ")}]`}comment(r){for(let t of o(r))this.line(t===""?"//":`// ${t}`);return this}doc(r,t,e=[]){let n=o(t);if(n.length===0&&e.length===0)return this;let l=n.length===0?r:`${r} \u2014 ${n.join(" ")}`;if(e.length===0)return this.line(`/** ${l} */`);this.line("/**"),this.line(` * ${l}`),this.line(" *");for(let m of e)this.line(` * ${m}`);return this.line(" */")}};export{h as a};
|
|
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c}from"./
|
|
7
|
+
import{c}from"./HJ36YGCI.js";import{open as C,readdir as N,stat as P}from"node:fs/promises";import d from"node:path";var $=new Set([".yaml",".yml",".json"]);async function D(e){let n=[];async function t(r){let o=await N(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=d.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&$.has(d.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function _(e,n=4096){let t=await C(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function M(e){return d.resolve(process.cwd(),e)}async function K(e){let n=await P(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await N(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=d.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var k="drift.local",O=`http://${k}`;function u(e){return e===k}var U=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),J=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],R=`
|
|
8
8
|
`;function Y(e){return e.split(R)}function g(e,n,t){let r=n.toLowerCase(),o=e[r];if(o===void 0){e[r]=t;return}e[r]=r==="set-cookie"?`${o}${R}${t}`:`${o},${t}`}function p(e){if(!c(e)&&!Array.isArray(e))return{};let n={};if(Array.isArray(e)){for(let t of e){if(!c(t))continue;let{name:r,value:o}=t;typeof r=="string"&&o!==void 0&&g(n,r,String(o))}return n}for(let[t,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){for(let o of r)g(n,t,String(o));continue}g(n,t,String(r))}return n}function f(e){try{return new URL(e)}catch{return new URL(e,O)}}function m(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function L(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(e){let n=[],t=0,r=e.startsWith("/")?e:`/${e}`,s=m(r).split("/").map(i=>{if(!i)return"";let a=i.match(/^\{([^}]+)\}$/);return a?(n.push(a[1]),"([^/]+)"):(t+=2,L(i))}).join("/");return{regex:new RegExp(`^${s||"/"}$`),params:n,score:t}}function l(e,n){if(n&&A(e))try{return JSON.parse(n)}catch{return}}function E(e){return e?e.split(";")[0]?.trim().toLowerCase()??"":""}function A(e){let n=E(e);return n==="application/json"||n.endsWith("+json")}function Q(e,n){let t=E(n);if(!t)return e["application/json"]??e["*/*"];if(e[t]!==void 0)return e[t];let[r,o]=t.split("/");if(r&&o){let s=`${r}/*`;if(e[s]!==void 0)return e[s]}return e["*/*"]}function Z(e){let n=new Set,t=[];for(let r of e){let o=r.trim().toLowerCase();o.length!==0&&(o.endsWith("*")?t.push(o.slice(0,-1)):n.add(o))}return{names:n,prefixes:t}}function v(e,n){let t=e.toLowerCase();return t.startsWith(":")||U.has(t)||J.some(r=>t.startsWith(r))?!0:n?n.names.has(t)||n.prefixes.some(r=>t.startsWith(r)):!1}import{createReadStream as q}from"node:fs";import{readFile as B}from"node:fs/promises";import{createInterface as F}from"node:readline";function I(e){if(e!=null){if(typeof e=="string")return e;if(Buffer.isBuffer(e))return e.toString("utf8");if(c(e)||Array.isArray(e))try{return JSON.stringify(e)}catch{return String(e)}return String(e)}}function se(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);if(Number.isFinite(n))return n}}function H(e,n){if(e!=null){if(n==="base64"&&typeof e=="string")try{return Buffer.from(e,"base64").toString("utf8")}catch{return e}return I(e)}}function ae(e,n,t){let r=e.method?.toUpperCase(),o=e.url;if(!r||!o)return null;let s=p(e.requestHeaders),i=f(o);if(u(i.host)&&s.host)try{i=new URL(`${i.protocol}//${s.host}${i.pathname}${i.search}`)}catch{i=f(o)}let a=e.requestContentType??s["content-type"],y=H(e.requestBody),T={method:r,url:i.toString(),path:i.pathname,query:i.searchParams,protocol:i.protocol,protocolKnown:e.schemeKnown??/^https?:\/\//i.test(o),host:u(i.host)?void 0:i.host||void 0,headers:s,contentType:a,bodyText:y,bodyJson:l(a,y)},h,x=e.responseStatus;if(x!==void 0){let w=p(e.responseHeaders),S=e.responseContentType??w["content-type"],b=H(e.responseBody);h={status:x,statusText:e.responseStatusText,headers:w,contentType:S,bodyText:b,bodyJson:l(S,b)}}return{index:n,source:t,startedAt:e.startedAt,request:T,response:h,raw:e.raw}}async function*ce(e){let n=q(e,{encoding:"utf8"}),t=F({input:n,crlfDelay:1/0});for await(let r of t){let o=r.trim();if(o)try{let s=JSON.parse(o);c(s)&&(yield s)}catch{}}}async function*ue(e,n){let t=await B(e,"utf8"),r=JSON.parse(t);if(n)for(let o of n.split("."))r=c(r)?r[o]:void 0;if(Array.isArray(r))for(let o of r)c(o)&&(yield o)}function fe(e){return p(e)["content-type"]}function ge(e){return e?.replace(/\/+$/,"")||void 0}function z(e,n){if(!n||n==="/")return e||"/";if(e===n)return"/";if(e.startsWith(`${n}/`))return e.slice(n.length)||"/"}function me(e,n){if(n.startsWith("/"))return z(e.path,n);let t=f(n.includes("://")?n:`http://${n}`);if(!(u(t.host)||e.host!==void 0&&e.host.toLowerCase()!==t.host))return z(e.path,m(t.pathname))}export{D as a,_ as b,M as c,K as d,u as e,Y as f,f as g,m as h,V as i,E as j,A as k,Q as l,Z as m,v as n,I as o,se as p,H as q,ae as r,ce as s,ue as t,fe as u,ge as v,me as w};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./
|
|
7
|
+
import{a as oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./NTPLYWAB.js";import{D as X,E as g,F as O,G as Z,H as $,I as C,K as S,M as y,O as w,Q as ee,R as te,S as Je,W as ne,Y as re,_ as se,aa as ie,c as l,p as Y,u as Q,x as We}from"./HJ36YGCI.js";import{e as J}from"./RFWIIJFG.js";import fe from"node:path";function R(t){return t?t.trim():""}function T(t){let e=R(t.operationId)||R(t.path);return[R(t.ruleId),R(t.severity),R(t.message),e,R(t.target),R(t.schemaPath)].join("")}var F=t=>X(S(t));function Ye(t){return t==="error"?"error":t==="warning"?"warning":"note"}function Qe(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
|
|
8
8
|
`)?e:`"${e.replace(/"/g,'""')}"`}function Xe(t){return fe.isAbsolute(t)?fe.relative(process.cwd(),t)||".":t}function Ze(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function et(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function tt(t){let e=[],r=new Map;for(let n of t){let s=T({ruleId:n.ruleId,severity:n.severity,message:n.message,operationId:n.operationId,path:n.path,target:n.target,schemaPath:n.schemaPath}),i=r.get(s);if(i!==void 0){e[i].occurrences+=1;continue}r.set(s,e.length),e.push({finding:n,occurrences:1})}return e}function nt(t){let e=tt(t.findings).map(n=>({occurrences:n.occurrences,exchangeIndex:n.finding.exchangeIndex,ruleId:n.finding.ruleId,severity:n.finding.severity,category:n.finding.category,message:n.finding.message,operationId:n.finding.operationId,specSource:n.finding.specSource,target:n.finding.target,schemaPath:n.finding.schemaPath,dataPath:n.finding.dataPath,details:n.finding.details,method:n.finding.method,url:n.finding.url,path:n.finding.path,status:n.finding.status})),r={run:{id:t.runId,specSource:t.meta.specSource,trafficPath:t.meta.trafficPath,format:t.meta.format,matchMode:t.meta.matchMode,server:t.meta.server,totalExchanges:t.summary.totalExchanges,documentedExchanges:t.summary.documentedExchanges,undocumentedExchanges:t.summary.undocumentedExchanges,skippedExchanges:t.summary.skippedExchanges,findingsBySeverity:t.summary.findingsBySeverity,findingsByRule:t.summary.findingsByRule,totalProblems:t.summary.totalProblemGroups,durationMs:t.summary.durationMs},problems:e};return`${JSON.stringify(r,null,2)}
|
|
9
9
|
`}function rt(t){let e=["run_id","finding_id","exchange_index","severity","category","rule_id","message","method","path","url","status","operation_id","spec_source","target","schema_path","data_path"],r=t.findings.map(s=>[t.runId,s.id,s.exchangeIndex,s.severity,s.category,s.ruleId,s.message,s.method,s.path,s.url,s.status,s.operationId,s.specSource,s.target,s.schemaPath,s.dataPath]);return`${[e,...r].map(s=>s.map(Qe).join(",")).join(`
|
|
10
10
|
`)}
|
|
@@ -0,0 +1,7 @@
|
|
|
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}from"./TSB6PODJ.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{a as transformersGenerator};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import"./4I2OVMBJ.js";import{a as I}from"./ZMCRMR2V.js";import"./PFYPTG4G.js";import{c as $}from"./HJ36YGCI.js";import"./NEWT5A6S.js";import{a as T,e as C,g as q,h as b,k as O}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as se}from"node:path";var S=class{constructor(n){this.code=n}code};function H(e,n,r={}){let t=new Map(n.map(a=>[a.name,a.schema])),o=k(e,t,new Set,r.dateType??"string");return o===g?null:o}var g=Symbol("cycle");function P(e,n){if(e.kind==="union"){for(let t of e.members){let o=P(t,n);if(o)return o}return}if(e.kind!=="scalar")return;let r=e.metadata?.format;if(r==="binary")return new S("new Blob([])");if(n==="Date"){if(r==="date-time")return new S('new Date("2024-01-01T00:00:00Z")');if(r==="date")return new S('new Date("2024-01-01")')}}function D(e,n){let r=new Map,t=[],o=!1;for(let a of e){if(a.kind==="unknown")continue;let c=Y(a,n);if(c?.kind!=="object"){t.push(a);continue}o=!0;for(let s of c.properties){let i=V(s.schema,n,new Set),u=r.get(s.name);(u===void 0||i>=u.rank)&&r.set(s.name,{schema:s.schema,required:s.required||(u?.required??!1),rank:i})}}return o?{merged:{kind:"object",properties:[...r.entries()].map(([a,c])=>({name:a,schema:c.schema,required:c.required}))},rest:t}:{merged:void 0,rest:t}}function Y(e,n){let r=new Set,t=e;for(;t?.kind==="ref";){if(r.has(t.name))return;r.add(t.name),t=n.get(t.name)}return t}function V(e,n,r){switch(e.kind){case"literal":return 40;case"enum":return e.values.length===1?40:30;case"union":return Math.max(0,...e.members.map(t=>V(t,n,r)))-1;case"ref":{if(r.has(e.name))return 20;let t=n.get(e.name);return t===void 0?20:V(t,n,new Set(r).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,n,r,t){let o=P(e,t);if(o)return o;let a=e.metadata,c=s=>s===null?e.kind==="null"||e.kind==="union"&&e.members.some(i=>i.kind==="null"):e.kind==="enum"?e.values.includes(s):e.kind==="literal"?s===e.value:!0;if(a?.example!==void 0&&c(a.example))return a.example;if(a?.default!==void 0&&c(a.default))return a.default;switch(e.kind){case"scalar":return v(e.scalar,a);case"array":{let s=k(e.items,n,r,t);return s===g?[]:[s]}case"object":return Object.fromEntries(e.properties.flatMap(s=>{let i=k(s.schema,n,r,t);return i===g?s.required?[[s.name,null]]:[]:[[s.name,i]]}));case"record":{let s=k(e.value,n,r,t);return s===g?{}:{key:s}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let s of e.members){let i=k(s,n,r,t);if(i!==g)return i}return e.members.length>0?g:null}case"intersection":{let{merged:s,rest:i}=D(e.members,n),u=i.map(f=>k(f,n,r,t)).filter(f=>f!==g);if(s){let f=k(s,n,r,t),j=$(f)?f:{};for(let A of u)$(A)&&Object.assign(j,A);return j}let h=u.filter($);return h.length>0?h.reduce((f,j)=>Object.assign(f,j),{}):u.length>0?u[0]:{}}case"omit":{let s=n.get(e.base);if(!s)return null;let i=k(s,n,r,t);if($(i)){let u={...i};for(let h of e.keys)delete u[h];return u}return i}case"ref":{if(r.has(e.name))return g;let s=n.get(e.name);if(!s)return null;r.add(e.name);let i=k(s,n,r,t);return r.delete(e.name),i}case"null":case"unknown":return null}}function v(e,n){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(n?.format){case"email":return"user@example.com";case"uuid":return"00000000-0000-4000-8000-000000000000";case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"uri":case"url":return"https://example.com";default:return"string"}}var l=e=>({kind:"expr",text:e}),m=e=>({kind:"object",entries:e});function d(e){return e.kind==="object"}function E(e,n){return d(e)?m([...e.entries,{spread:n}]):e}var B=" ";function y(e,n){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${y(e.value,n)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let r=n+B;return`[
|
|
8
|
+
${e.items.map((o,a)=>`${r}${y(o,r)}${a===e.items.length-1?"":","}`).join(`
|
|
9
|
+
`)}
|
|
10
|
+
${n}]`}case"object":{if(e.entries.length===0)return"{}";let r=n+B;return`{
|
|
11
|
+
${e.entries.map((o,a)=>{let c=a===e.entries.length-1?"":",";if("spread"in o)return`${r}...${o.spread}${c}`;let s=C(o.key)===o.key?o.key:q(o.key);return`${r}${s}: ${y(o.value,r)}${c}`}).join(`
|
|
12
|
+
`)}
|
|
13
|
+
${n}}`}}}function K(e,n,r={}){let t=new Map(n.map(a=>[a.name,a.schema])),o=M(e,t,new Set,r.dateType??"string");return o===p?l("null"):o}var p=Symbol("cycle");function M(e,n,r,t){switch(e.kind){case"scalar":return l(U(e.scalar,e.metadata,t));case"array":{let o=M(e.items,n,r,t);return o===p?l("[]"):Z(o)}case"object":return m(e.properties.flatMap(o=>{let a=M(o.schema,n,r,t);return a===p?o.required?[{key:o.name,value:l("null")}]:[]:[{key:o.name,value:a}]}));case"record":{let o=M(e.value,n,r,t);return o===p?l("{}"):m([{key:"key",value:o}])}case"enum":return l(`faker.helpers.arrayElement([${e.values.map(o=>b(o)).join(", ")}] as const)`);case"literal":return l(b(e.value));case"union":{for(let o of e.members){let a=M(o,n,r,t);if(a!==p)return a}return e.members.length>0?p:l("null")}case"intersection":{let{merged:o,rest:a}=D(e.members,n),c=a.map(i=>M(i,n,r,t)).filter(i=>i!==p);if(o){let i=M(o,n,r,t),u=i!==p&&d(i)?i.entries:[],h=c.filter(d).flatMap(f=>f.entries);return m([...u,...h])}let s=c.filter(d);return s.length>0?m(s.flatMap(i=>i.entries)):c[0]??m([])}case"omit":return z(e.base,e.keys,n,r,t);case"ref":{if(r.has(e.name))return p;let o=n.get(e.name);if(!o)return l("null");r.add(e.name);let a=M(o,n,r,t);return r.delete(e.name),a}case"null":case"unknown":return l("null")}}function U(e,n,r){if(n?.format==="binary")return"new Blob([])";if(e==="boolean")return"faker.datatype.boolean()";if(e==="integer")return`faker.number.int(${J(n)})`;if(e==="number")return`faker.number.float(${J(n)})`;switch(n?.format){case"email":return"faker.internet.email()";case"uuid":return"faker.string.uuid()";case"uri":case"url":return"faker.internet.url()";case"hostname":return"faker.internet.domainName()";case"ipv4":return"faker.internet.ipv4()";case"date-time":return L(r,!1);case"date":return L(r,!0);default:return"faker.lorem.word()"}}function L(e,n){if(e==="Date")return"faker.date.recent()";let r="faker.date.recent().toISOString()";return n?`${r}.slice(0, 10)`:r}function J(e){let n=[...e?.minimum!==void 0?[`min: ${e.minimum}`]:[],...e?.maximum!==void 0?[`max: ${e.maximum}`]:[]];return n.length>0?`{ ${n.join(", ")} }`:""}function Z(e){let n=d(e);return{kind:"wrap",before:`faker.helpers.multiple(() => ${n?"(":""}`,value:e,after:`${n?")":""}, { count: 1 })`}}function z(e,n,r,t,o){let a=r.get(e);if(!a)return l("null");let c=M(a,r,t,o);if(c===p||!d(c))return c;let s=new Set(n);return m(c.entries.filter(i=>"spread"in i||!s.has(i.key)))}var F=" ";function w(e,n,r){return r.mockData==="faker"?K(e,n.schemas,{dateType:r.dateType}):R(H(e,n.schemas,{dateType:r.dateType}))}function G(e,n){let r=I(e.services);if(r.length===0)return"";let t=[...Q(e,n),...n.mockData==="faker"&&n.mockSeed!==void 0?[`faker.seed(${n.mockSeed});`]:[],...e.schemas.map(a=>X(a,e,n)),...r.flatMap(a=>[_(a,e,n),...a.errorResponses.length>0?[N(a,e,n)]:[]]),ae(r)];return`import { http, HttpResponse } from 'msw';
|
|
14
|
+
${n.mockData==="faker"?`import { faker } from '@faker-js/faker';
|
|
15
|
+
`:""}
|
|
16
|
+
${t.join(`
|
|
17
|
+
|
|
18
|
+
`)}`}function Q(e,n){return e.schemas.length===0?[]:[`import type { ${e.schemas.map(t=>t.name).sort().join(", ")} } from ${JSON.stringify(n.sdkModule)};`]}function X(e,n,r){let t=O(e.name),o=w(e.schema,n,r),a=e.name,c=d(o),s=y(c?E(o,"overrides"):o,F),i=c?e.schema.kind==="union"?`${s} as ${a}`:s:`overrides ?? ${s}`,u=c?`Partial<${a}>`:a;return[`export function create${t}(overrides?: ${u}): ${a} {`,`${F}return ${i};`,"}"].join(`
|
|
19
|
+
`)}function x(e){if(!T(e))throw new Error(`Unsafe identifier in mock emission: ${JSON.stringify(e)}`);return e}function _(e,n,r){let o=re(e,n,r)??"",a=`http.${x(e.method)}(${JSON.stringify(W(e.path))}, () => ${te(e,n,r)})`;return`export const ${x(e.name)}Handler = (${o}) => ${a};`}function N(e,n,r){let t=e.errorResponses[0],a=`() => HttpResponse.json(body ?? ${y(w(t.schema,n,r),"")}, { status })`,c=`http.${x(e.method)}(${JSON.stringify(W(e.path))}, ${a})`;return`export const ${x(e.name)}ErrorHandler = (status: ${ee(e)}, body?: ${ne(e)}) => ${c};`}function ee(e){let r=[...new Set(e.errorResponses.filter(t=>typeof t.status=="number").map(t=>t.status))].map(String);return e.errorResponses.some(t=>typeof t.status!="number")&&r.push("number"),r.join(" | ")}function ne(e){let n=new Set,r=!1;for(let o of e.errorResponses)o.schema.kind==="ref"?n.add(o.schema.name):r=!0;let t=[...n];return(r||t.length===0)&&t.push("unknown"),t.join(" | ")}function re(e,n,r){let t=e.successResponses[0];if(!(!t||t.schema.kind==="unknown")){if(t.schema.kind==="ref"){let o=t.schema.name;return`override?: ${d(w(t.schema,n,r))?`Partial<${o}>`:o}`}if(d(w(t.schema,n,r)))return"override?: Record<string, unknown>"}}function te(e,n,r){let t=e.successResponses[0],o=oe(t?.status);if(!t||t.schema.kind==="unknown")return`new HttpResponse(null, { status: ${o} })`;let a=t.schema.kind==="ref"?`create${O(t.schema.name)}(override)`:y(E(w(t.schema,n,r),"override"),"");return`HttpResponse.json(${o===200?a:`${a}, { status: ${o} }`})`}function oe(e){return typeof e=="number"?e:200}function ae(e){return`export const handlers = [${e.map(r=>`${x(r.name)}Handler()`).join(", ")}];`}function W(e){return`*${e.replace(/\{([^{}]+)\}/g,":$1")}`}function R(e){return e instanceof S?l(e.code):Array.isArray(e)?{kind:"array",items:e.map(R)}:$(e)?m(Object.entries(e).map(([n,r])=>({key:n,value:R(r)}))):l(b(e))}var xe=({model:e,output:n,banner:r,emit:t})=>{let o=r.map(c=>`// ${c}`).join(`
|
|
20
|
+
`),a=G(e,{sdkModule:`./${n.stem}.${t.importExt??"js"}`,dateType:t.dateType,mockData:t.mockData,mockSeed:t.mockSeed});return a===""?[]:[{path:se(n.dir,`${n.stem}.mocks.ts`),content:`${o}
|
|
21
|
+
|
|
22
|
+
${a}`}]};export{xe as mockGenerator};
|