@redocly/cli 2.62.2 → 2.64.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/THIRD_PARTY_NOTICES +1 -1
- package/lib/chunks/{37WWN4MA.js → 2DKR4Z25.js} +1 -1
- package/lib/chunks/{S6NFOZ34.js → 2MCPXKB6.js} +1 -1
- package/lib/chunks/2ZIICV4T.js +7 -0
- package/lib/chunks/3CSDNX6S.js +20 -0
- package/lib/chunks/{KOR5TUJG.js → 4EAF6XUQ.js} +1 -1
- package/lib/chunks/5PR7FNUB.js +59 -0
- package/lib/chunks/{5X35UU2C.js → 654FMWX6.js} +1 -1
- package/lib/chunks/{4AM55DEH.js → 6FADWAOY.js} +1 -1
- package/lib/chunks/{3FXYWWTJ.js → 6MP4DHWK.js} +1 -1
- package/lib/chunks/{SLQPKXO2.js → 7APJVQSB.js} +1 -1
- package/lib/chunks/{KRCCY64H.js → AC62H63B.js} +1 -1
- package/lib/chunks/{ZCVUIIPU.js → ALBI5SPY.js} +1 -1
- package/lib/chunks/{SXBAAS4M.js → B5ZOH4BB.js} +1 -1
- package/lib/chunks/{V2YF33JL.js → BGGUKU7E.js} +1 -1
- package/lib/chunks/{6EGJEFXO.js → BWXAXULF.js} +1 -1
- package/lib/chunks/{3JYQOGV3.js → CEASD5U3.js} +1 -1
- package/lib/chunks/{TBZEEKTV.js → CVPT656W.js} +1 -1
- package/lib/chunks/{5PG3ST2N.js → DL4VP2Z4.js} +2 -2
- package/lib/chunks/DPNI74SB.js +69 -0
- package/lib/chunks/{GWXT3QO6.js → ENIPOAVJ.js} +2 -2
- package/lib/chunks/{22EANOP2.js → EQTXHL74.js} +101 -101
- package/lib/chunks/{3WHXM4DJ.js → FU7GBMUU.js} +1 -1
- package/lib/chunks/{JLVGRO3I.js → FVGFKJ67.js} +7 -7
- package/lib/chunks/{73RBZL53.js → FXKIC5R3.js} +1 -1
- package/lib/chunks/{2OBVZIAW.js → GKCVQWOQ.js} +3 -3
- package/lib/chunks/{MNH2K4WM.js → GKSUZULD.js} +1 -1
- package/lib/chunks/GOTKYHFM.js +20 -0
- package/lib/chunks/{2XK7ML3U.js → GRTUPOKN.js} +1 -1
- package/lib/chunks/{XJE2OFDN.js → HAOBCQWB.js} +358 -19
- package/lib/chunks/{IUSSBOYO.js → HIII45WJ.js} +1 -1
- package/lib/chunks/{2OVI7BIW.js → HYMULX2S.js} +1 -1
- package/lib/chunks/{FDMXHRDK.js → I6NMWBVI.js} +1 -1
- package/lib/chunks/{SHZZKTDE.js → IH3N62Q4.js} +1 -1
- package/lib/chunks/{V3ILUN2S.js → J665DSDI.js} +1 -1
- package/lib/chunks/JQJ5TDVP.js +11 -0
- package/lib/chunks/{HWTYAU4Y.js → L5X7LBV6.js} +1 -1
- package/lib/chunks/{VXONEXYX.js → LCAJ35J6.js} +1 -1
- package/lib/chunks/{US7X4XPD.js → LG3SUXEW.js} +1 -1
- package/lib/chunks/{YDVWNFMS.js → LMO5V2XF.js} +1 -1
- package/lib/chunks/{XFBJHVYU.js → M4NCSK7Q.js} +1 -1
- package/lib/chunks/{RPHIT72T.js → M74SGAZK.js} +1 -1
- package/lib/chunks/{M3XPS7UF.js → MVCGBDOY.js} +1 -1
- package/lib/chunks/{HYE4U6V5.js → N4R4236N.js} +1 -1
- package/lib/chunks/{6NB3FKVN.js → NRWIPPEV.js} +1 -1
- package/lib/chunks/{3C6UUCEW.js → OGNRVBTI.js} +1 -1
- package/lib/chunks/{6MH5ZWLD.js → ONBORCDJ.js} +1 -1
- package/lib/chunks/{ENSYM7KY.js → OS52EARM.js} +1 -1
- package/lib/chunks/{6DO6IN4A.js → QCOPS234.js} +1 -1
- package/lib/chunks/{CQKQB4PJ.js → QWTSCCNH.js} +1 -1
- package/lib/chunks/{4OEXH5EV.js → RRQJCLNO.js} +1 -1
- package/lib/chunks/{HBENVUR4.js → RWDQI2KD.js} +1 -1
- package/lib/chunks/{I5CGSLGR.js → S3W5GQGC.js} +1 -1
- package/lib/chunks/{HUWKDZPP.js → SRRHJLPL.js} +1 -1
- package/lib/chunks/{7WM6VLB3.js → TTE4EAVV.js} +3 -2
- package/lib/chunks/{LRLGVYCG.js → TWFZE4OF.js} +1 -1
- package/lib/chunks/{OP7NIAI7.js → U4RAHOFK.js} +1 -1
- package/lib/chunks/{36IHQANV.js → UC5EDLXL.js} +1 -1
- package/lib/chunks/{TKLMYBPI.js → ULQK2S4O.js} +1 -1
- package/lib/chunks/{FDGP3ZYZ.js → UNOXQ62I.js} +363 -156
- package/lib/chunks/{6WZUCZGV.js → UQW6CW3M.js} +1 -1
- package/lib/chunks/{DS4SCWID.js → VKTRI5YG.js} +1 -1
- package/lib/chunks/{PTNNX4IU.js → VMIHLA3H.js} +1 -1
- package/lib/chunks/{WX24BERR.js → VWF52WKH.js} +1 -1
- package/lib/chunks/WKQJPOYW.js +7 -0
- package/lib/chunks/{SYWAPWW7.js → WQBSNQXL.js} +1 -1
- package/lib/chunks/{CIDSJFJO.js → X6TQQHRM.js} +1 -1
- package/lib/chunks/{XJTGJYVS.js → XDBFHG7X.js} +1 -1
- package/lib/chunks/{LVGVWPDB.js → XYU2LTWU.js} +1 -1
- package/lib/chunks/{2OQM5ARW.js → Z4X6WES7.js} +1 -1
- package/lib/chunks/{3JYY42DL.js → ZFXOCOU6.js} +1 -1
- package/lib/chunks/{3DEJQSYG.js → ZM3M44Q3.js} +1 -1
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +2 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +1 -1
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +2 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +1 -1
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +2 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +1 -1
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +56 -9
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +29 -3
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +1 -1
- package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/lib/eject-assets/generators/typescript/types.ts +1 -1
- package/lib/eject-assets/generators/zod/index.ts +2 -2
- package/lib/eject-assets/generators/zod/schemas.ts +1 -1
- package/lib/eject-assets/skills/tanstack-query-generator/SKILL.md +5 -2
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +24 -0
- package/lib/index.js +5 -5
- package/package.json +1 -1
- package/lib/chunks/5SIJI5LC.js +0 -42
- package/lib/chunks/7WTV5KH3.js +0 -67
- package/lib/chunks/EDQ6QRIB.js +0 -20
- package/lib/chunks/LCFG5N4V.js +0 -7
- package/lib/chunks/PWGFZ5ZK.js +0 -7
- package/lib/chunks/RU7T4CKG.js +0 -11
- package/lib/chunks/Z6GHMX6Z.js +0 -20
|
@@ -4,7 +4,8 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as ee,b as te,f as ne,g as E,h as re}from"./
|
|
7
|
+
import{a as ee,b as te,f as ne,g as E,h as re}from"./UNOXQ62I.js";import{a as y}from"./WZXA5XPB.js";import{Aa as Z,P as W,V,c as x,ia as b,ka as Q,r as v,ra as Y,s as H,ta as T,u as J}from"./EQTXHL74.js";import{b as A,c as G,k as D}from"./LD5MEXEL.js";import{mkdir as ct,readFile as ut,writeFile as dt}from"node:fs/promises";import{dirname as ke,parse as ft,resolve as R,sep as pt}from"node:path";function M(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./X6TQQHRM.js").then(t=>({run:t.tanstackQueryGenerator(e)}))}}var U={outputMode:"it always emits one self-contained file",runtime:"the runtime is always embedded in the generated file",argsStyle:"inputs follow the target language's own idiom",importExt:"the generated file has no relative imports"},I={typescript:{load:()=>import("./FU7GBMUU.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./MVCGBDOY.js").then(e=>({run:e.zodGenerator}))},transformers:{requires:["typescript"],dateTypes:["Date"],load:()=>import("./IULINGO6.js").then(e=>({run:e.transformersGenerator}))},"tanstack-query":M("react"),"tanstack-query-vue":M("vue"),"tanstack-query-svelte":M("svelte"),"tanstack-query-solid":M("solid"),swr:{requires:["typescript"],errorModes:["throw"],load:()=>import("./ONBORCDJ.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./M4NCSK7Q.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./RRQJCLNO.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:U,load:()=>import("./BGGUKU7E.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:U,load:()=>import("./LCAJ35J6.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:U,load:()=>import("./J665DSDI.js").then(e=>({run:e.phpGenerator,sample:e.phpSample,docs:e.phpDocs}))}};function oe(e,t,n,r){let s=new Set(e);t.goPackage!==void 0&&!s.has("go")&&b.warn(`generate-client: goPackage is ignored \u2014 it declares the Go package clause, and no selected generator uses it (add --generator go).
|
|
8
|
+
`),t.telemetry==="on"&&!s.has("typescript")&&b.warn(`generate-client: telemetry is ignored \u2014 the typescript generator writes the telemetry module, and it is not selected (add --generator typescript).
|
|
8
9
|
`);let o=t.errorMode??"throw",i=t.dateType??"string";for(let a of e){let c=n.get(a);if(!c)throw new y(`Unknown generator: ${a}`);for(let d of c.requires??[])if(!s.has(d)){let f=[...new Set([d,...e])].map(m=>`--generator ${m}`).join(" ");throw new y(`The "${a}" generator requires the "${d}" generator. Add it, e.g. ${f}.`)}if(c.errorModes&&!c.errorModes.includes(o))throw new y(`The "${a}" generator does not support --error-mode "${o}" (supported: ${c.errorModes.join(", ")}).`);if(c.dateTypes&&!c.dateTypes.includes(i))throw new y(`The "${a}" generator requires --date-type ${c.dateTypes.join(" or ")} (got "${i}") so the runtime values match the generated types.`);let u={...t,outputMode:r};for(let[d,f]of Object.entries(c.notApplicable??{}))u[d]!==void 0&&b.warn(`generate-client: the "${a}" generator ignores ${d} \u2014 ${f}.
|
|
9
10
|
`)}}function se(e,t,n){let r=new Map;for(let s of e){let o=t.get(s)?.options,i=n?.[s];if(o===void 0){i!==void 0&&b.warn(`generate-client: the "${s}" generator declares no options, so client.options.${s} is ignored.
|
|
10
11
|
`),r.set(s,{});continue}r.set(s,ve(s,o,i))}return r}function ve(e,t,n){if(n!==void 0&&!x(n))throw new y(`The "${e}" generator's options must be a map of option names to values.`);let r=n??{},s=Object.keys(t.properties);if(t.additionalProperties!==!0){for(let i of Object.keys(r))if(!s.includes(i))throw new y(`The "${e}" generator got an unknown option "${i}". Declared options: ${s.join(", ")||"(none)"}.`)}for(let i of t.required??[])if(r[i]===void 0)throw new y(`The "${e}" generator requires the "${i}" option.`);let o={...r};for(let[i,a]of Object.entries(t.properties)){if(o[i]===void 0){a.default!==void 0&&(o[i]=a.default);continue}let c=Se(a,o[i]);if(c!==void 0)throw new y(`The "${e}" generator's "${i}" ${c}.`)}return o}function Se(e,t){if("enum"in e)return e.enum.includes(t)?void 0:`must be one of: ${e.enum.join(", ")}`;if(e.type==="array"){let n=e.items.type;return Array.isArray(t)&&t.every(r=>typeof r===n)?void 0:`must be an array of ${n}`}return typeof t===e.type?void 0:`must be a ${e.type}`}import{isAbsolute as xe,resolve as qe}from"node:path";import{pathToFileURL as Pe}from"node:url";var Oe=function(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(n,r,s,o,i){return r?t?".jsx":".js":s&&(!o||!i)?n:s+o+"."+i.toLowerCase()+"js"}):e};async function ae(e,t={}){let n=new Map;for(let a of t.customGenerators??[])ce(n,a);let r=[];for(let a of e)r.push(await ie(a,n,t.configDir));let s=[],o=new Set,i=async a=>{if(!(s.includes(a)||o.has(a))){o.add(a);for(let c of n.get(a).requires??[])(n.has(c)||c in I)&&await i(await ie(c,n,t.configDir));o.delete(a),s.push(a)}};for(let a of r)await i(a);return{selected:s,registry:n}}async function ie(e,t,n){if(t.has(e))return e;let r=I[e];if(r!==void 0){let{load:o,...i}=r;return t.set(e,{...i,...await o()}),e}if(e==="sdk")throw new y('The "sdk" generator is now named "typescript". Update the `generators` list or the --generator flag.');let s=await je(e,n??process.cwd());return ce(t,s),s.name}function ce(e,t){if(!x(t)||typeof t.name!="string"||t.name===""||typeof t.run!="function")throw new y("Invalid custom generator: expected an object with a non-empty string `name` and a `run` function (build one with `defineGenerator`).");if(e.has(t.name))throw new y(`Generator name "${t.name}" collides with an existing generator. Rename the custom generator.`);if(t.requiresGenerator!==void 0){let n=re(E,t.requiresGenerator);if(n===void 0)throw new y(`Generator "${t.name}" declares requiresGenerator "${t.requiresGenerator}", which is not a range we read. Use ^1.2.0, ~1.2.0, >=1.2.0, or an exact version.`);if(!n)throw new y(`Generator "${t.name}" needs @redocly/client-generator ${t.requiresGenerator}; this CLI ships ${E}. Upgrade @redocly/cli if the generator is newer, or update the generator \u2014 \`redocly eject-generator <name> --update\` for an ejected file, or upgrade its package.`)}t.name in I&&b.warn(`generate-client: custom generator "${t.name}" takes over the built-in generator of the same name.
|
|
@@ -15,4 +16,4 @@ import{a as ee,b as te,f as ne,g as E,h as re}from"./FDGP3ZYZ.js";import{a as y}
|
|
|
15
16
|
`);throw new Error(`The API description has ${i.length} error(s):
|
|
16
17
|
${c}`)}let a=r.bundle.parsed;return{document:a,version:Q(a)}}var lt=["Generated by @redocly/client-generator \u2014 do not edit by hand.","Source: OpenAPI description. Re-run `redocly generate-client` to update."];function mt(e,t){let n=[],r=new Set,s=R(ke(t.outputPath)),{dir:o,name:i,ext:a}=ft(t.outputPath),c={path:t.outputPath,dir:o,stem:i,ext:a},u=lt,d=!1;for(let f of t.generators){let m=t.registry.get(f),l={model:e,output:c,banner:u,outputMode:t.outputMode,emit:t.emit,pagination:t.pagination,selected:t.generators,options:t.generatorOptions?.get(f)??{}},h;try{t.emit.docs===!0&&m.docs!==void 0?(h=[...m.run(l),...m.docs(l)],d=!0):h=m.run(l)}catch(p){let g=p instanceof Error?p.message:String(p);throw new Error(`Generator "${f}" failed: ${g}`)}if(!Array.isArray(h)||h.some(p=>typeof p?.path!="string"||p.path===""||typeof p.content!="string"))throw new Error(`Generator "${f}" failed: run() must return an array of { path, content } files.`);for(let p of h){let g=R(s,p.path);if(g!==s&&!g.startsWith(s+pt))throw new Error(`Generator "${f}" failed: file path escapes the output directory: ${p.path}`);if(r.has(g))throw new Error(`Generator conflict: ${p.path} already emitted by an earlier generator`);r.add(g),n.push({path:g,content:p.content})}}return t.emit.docs===!0&&!d&&b.warn(`generate-client: docs is on, but no selected generator writes documentation (${t.generators.join(", ")}).
|
|
17
18
|
`),n}function ht(e){for(let t of e.services)for(let n of t.operations){let r=new Set,s=new Set;for(let o of[...n.pathParams,...n.queryParams,...n.headerParams,...n.cookieParams])r.has(o.name)&&s.add(o.name),r.add(o.name);s.size!==0&&b.warn(`generate-client: operation "${n.specName??n.name}" uses ${[...s].map(o=>`"${o}"`).join(", ")} in more than one parameter location. Every SDK sends both, and the SDKs whose methods take one argument per parameter give the later one a suffixed name \u2014 rename it in the description to choose the name yourself.
|
|
18
|
-
`)}}function yt(e,t,n,r,s,o,i){let a=[],c=new Set;for(let u of ee(t.services)){let d=gt(e,u.path,u.method);if(c.has(d))continue;c.add(d);let f=r.map(m=>s.get(m)?.sample?.(u,{model:t,emit:n,outputPath:o,pagination:i})).filter(m=>m!==void 0);f.length>0&&a.push({target:d,update:{"x-codeSamples":f}})}if(a.length!==0)return W({overlay:"1.0.0",info:{title:`Code samples for ${t.title}`,version:t.version},actions:a})}function gt(e,t,n){let r=i=>`['${i.replaceAll("\\","\\\\").replaceAll("'","\\'")}']`,s=e.paths?.[t];return`${v(s)&&s.$ref.startsWith("#/")?"$"+s.$ref.slice(2).split("/").map(H).map(r).join(""):`$.paths${r(t)}`}.${n}`}async function nn(e){if(e.output.split(/[\\/]/).some(p=>p==="undefined"||p==="null"))throw new Error(`output path "${e.output}" contains a literal "undefined" or "null" segment \u2014 this looks like an interpolation bug in the caller`);if(e.setup&&/^[a-z][a-z0-9+.-]+:/i.test(e.setup))throw new y(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let t=R(e.output),{document:n,version:r}=await $e(e.api,e.config),s=r==="oas2"?ge(n):n,o=he(s);ht(o);let i;if(e.setup){let{bakeSetup:p}=await import("./CQMMUWIJ.js"),g=R(e.configDir??process.cwd(),e.setup);i=p(await ut(g,"utf-8"))}let a=e.generators?.length?e.generators:["typescript"],{selected:c,registry:u}=await ae(a,{customGenerators:e.customGenerators,configDir:e.configDir}),d=te(o,e.pagination),f={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,setup:i,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:d,docs:e.docs,docsFrontmatter:e.docsFrontmatter};oe(c,f,u,e.outputMode);let m=se(c,u,e.options),l=mt(o,{outputPath:t,outputMode:e.outputMode??"single",emit:f,pagination:d,generators:c,generatorOptions:m,registry:u});if(e.codeSamples===!0){let p=yt(n,o,f,c,u,t,d);p!==void 0&&l.push({path:t.replace(/\.[^.]+$/,".code-samples.yaml"),content:p})}let h=[];for(let p of l)await ct(ke(p.path),{recursive:!0}),await dt(p.path,p.content,"utf-8"),h.push({path:p.path,bytes:Buffer.byteLength(p.content,"utf-8")});return{outputPath:t,bytes:h.reduce((p,g)=>p+g.bytes,0),files:h}}export{I as a,oe as b,mt as c,nn as d};
|
|
19
|
+
`)}}function yt(e,t,n,r,s,o,i){let a=[],c=new Set;for(let u of ee(t.services)){let d=gt(e,u.path,u.method);if(c.has(d))continue;c.add(d);let f=r.map(m=>s.get(m)?.sample?.(u,{model:t,emit:n,outputPath:o,pagination:i})).filter(m=>m!==void 0);f.length>0&&a.push({target:d,update:{"x-codeSamples":f}})}if(a.length!==0)return W({overlay:"1.0.0",info:{title:`Code samples for ${t.title}`,version:t.version},actions:a})}function gt(e,t,n){let r=i=>`['${i.replaceAll("\\","\\\\").replaceAll("'","\\'")}']`,s=e.paths?.[t];return`${v(s)&&s.$ref.startsWith("#/")?"$"+s.$ref.slice(2).split("/").map(H).map(r).join(""):`$.paths${r(t)}`}.${n}`}async function nn(e){if(e.output.split(/[\\/]/).some(p=>p==="undefined"||p==="null"))throw new Error(`output path "${e.output}" contains a literal "undefined" or "null" segment \u2014 this looks like an interpolation bug in the caller`);if(e.setup&&/^[a-z][a-z0-9+.-]+:/i.test(e.setup))throw new y(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let t=R(e.output),{document:n,version:r}=await $e(e.api,e.config),s=r==="oas2"?ge(n):n,o=he(s);ht(o);let i;if(e.setup){let{bakeSetup:p}=await import("./CQMMUWIJ.js"),g=R(e.configDir??process.cwd(),e.setup);i=p(await ut(g,"utf-8"))}let a=e.generators?.length?e.generators:["typescript"],{selected:c,registry:u}=await ae(a,{customGenerators:e.customGenerators,configDir:e.configDir}),d=te(o,e.pagination),f={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,telemetry:e.telemetry,setup:i,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:d,docs:e.docs,docsFrontmatter:e.docsFrontmatter};oe(c,f,u,e.outputMode);let m=se(c,u,e.options),l=mt(o,{outputPath:t,outputMode:e.outputMode??"single",emit:f,pagination:d,generators:c,generatorOptions:m,registry:u});if(e.codeSamples===!0){let p=yt(n,o,f,c,u,t,d);p!==void 0&&l.push({path:t.replace(/\.[^.]+$/,".code-samples.yaml"),content:p})}let h=[];for(let p of l)await ct(ke(p.path),{recursive:!0}),await dt(p.path,p.content,"utf-8"),h.push({path:p.path,bytes:Buffer.byteLength(p.content,"utf-8")});return{outputPath:t,bytes:h.reduce((p,g)=>p+g.bytes,0),files:h}}export{I as a,oe as b,mt as c,nn as d};
|
|
@@ -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 o,b as t,c as e}from"./HBUZKWXC.js";import{ia as r}from"./
|
|
7
|
+
import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{ia as r}from"./EQTXHL74.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as p}from"node:child_process";var u=async({argv:n})=>{r.info(`
|
|
8
8
|
Launching translate using NPX.
|
|
9
9
|
|
|
10
10
|
`);let{npxExecutableName:s,sanitize:a,shell:i}=e(),l=a(n["project-dir"],o),c=a(n.locale,t);p(s,["-y","@redocly/realm","translate",c,`-d=${l}`],{stdio:"inherit",shell:i}).on("error",m=>{throw r.info(`Translate launch failed: ${m.message}`),new Error("Translate launch failed.")})};export{u as handleTranslations};
|
|
@@ -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 G}from"./
|
|
7
|
+
import{a as G}from"./VMIHLA3H.js";import{c as x,d as C,e as fe,h as N,j as I,k as ue,v as _,w as B}from"./AC62H63B.js";import{a as ae,b as Y,c as ce,d as pe}from"./M74SGAZK.js";import{a as ie}from"./64G5RPLP.js";import"./LG3SUXEW.js";import{O as re,P as v,c as g,ia as S,l as O,oa as oe,ta as se}from"./EQTXHL74.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{mkdir as jt,writeFile as kt}from"node:fs/promises";import At from"node:path";var Be=/^[a-zA-Z][a-zA-Z0-9]*(?:[_\-.][a-zA-Z0-9]+)*$/,De=/^[0-9a-f-]{8,}$/i,ze=[["uuid",/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i],["date-time",/^\d{4}-\d{2}-\d{2}[Tt]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:[Zz]|[+-]\d{2}:\d{2})$/],["date",/^\d{4}-\d{2}-\d{2}$/],["email",/^[^\s@]+@[^\s@]+\.[^\s@]+$/],["uri",/^https?:\/\/\S+$/],["ipv4",/^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$/]],M=new WeakMap;function D(e){return{formats:ze.filter(([,t])=>t.test(e)).map(([t])=>t),values:[e],count:1,overflow:!1}}function q(e,t){if(!e)return t;if(!t)return e;let n={formats:e.formats.filter(r=>t.formats.includes(r)),values:[],count:e.count+t.count,overflow:e.overflow||t.overflow};if(!n.overflow){let r=[...e.values];for(let o of t.values)r.includes(o)||r.push(o);r.length>10?n.overflow=!0:n.values=r}return n}function z(e,t){M.set(e,t)}function H(e){return M.get(e)}function V(e,t){let n=M.get(e);n&&M.set(t,n)}function He(e){return e.length<=30&&!De.test(e)&&Be.test(e)}function K(e,t){return e.formats.length>0?{format:e.formats[0]}:t&&!e.overflow&&e.count>=4&&e.values.length>0&&e.values.length<=5&&e.values.length*2<=e.count&&e.values.every(He)?{enum:[...e.values].sort()}:{}}function $(e){let t=M.get(e);if(t){let n=typeof e.type=="string"?[e.type]:e.type??[];n.includes("string")&&Object.assign(e,K(t,n.length===1))}for(let n of Object.values(e.properties??{}))$(n);e.additionalProperties&&$(e.additionalProperties),e.items&&$(e.items);for(let n of e.oneOf??[])$(n)}function me(e){for(let t of Object.values(e.paths))for(let n of Object.values(t)){for(let r of Object.values(n.requestBody?.content??{}))$(r.schema);for(let r of Object.values(n.responses))for(let o of Object.values(r.content??{}))$(o.schema)}for(let t of Object.values(e.components?.schemas??{}))$(t);return e}var be=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,F=/^\d+$/,Ve=/^[0-9a-hjkmnp-tv-z]{26}$/i,Ue=/^[a-z][a-z0-9]*_(?=[0-9a-z]*\d)[0-9a-z]{10,}$/i,Fe=/^[a-z](?=[a-z0-9]*\d)[a-z0-9]{23,24}$/,X=new Set(ie),Le=new Set(["get","head"]),de="application/x-www-form-urlencoded",le="multipart/form-data";function Ye(e){return e?F.test(e)||be.test(e)||Ve.test(e)||Ue.test(e)||Fe.test(e)?!0:/^[0-9a-f]{16,}$/i.test(e):!1}function Z(e){let t=e.split("/"),n=[],r=new Set;return{template:t.map((s,c)=>{if(!Ye(s))return s;let i=t[c-1],a=i?`${O(i,1)}Id`:"id",p=1;for(;r.has(a);)p+=1,a=i?`${O(i,1)}Id${p}`:`id${p}`;return r.add(a),n.push({name:a,value:s}),`{${a}}`}).join("/")||"/",params:n}}function j(e){if(e===null)return{type:"null"};if(Array.isArray(e)){if(e.length===0)return{type:"array"};let t=e.slice(0,20).map(j);return{type:"array",items:J(t)}}switch(typeof e){case"string":{let t={type:"string"};return z(t,D(e)),t}case"boolean":return{type:"boolean"};case"number":return Number.isInteger(e)?{type:"integer"}:{type:"number"};case"object":{let t=Object.entries(e);if(t.length>0&&(t.every(([c])=>F.test(c))||t.every(([c])=>be.test(c))))return{type:"object",additionalProperties:J(t.map(([,c])=>j(c)))};let n={},r=[];for(let[s,c]of t)n[s]=j(c),r.push(s);let o={type:"object",properties:n};return r.length>0&&(o.required=r),o}default:return{}}}function J(e){if(e.length===0)return{};let[t,...n]=e,r=t;for(let o of n)r=U(r,o);return r}function he(e){return Object.keys(e).length===0}function k(e){return e.additionalProperties?"map":e.type==="object"?"object":e.type==="array"?"array":"scalar"}function W(e){return e.oneOf?e.oneOf.flatMap(W):Array.isArray(e.type)?e.type.map(t=>{if(t==="object"){let r={type:"object"};return e.properties&&(r.properties=e.properties),e.required&&(r.required=e.required),e.additionalProperties&&(r.additionalProperties=e.additionalProperties),r}if(t==="array")return e.items?{type:"array",items:e.items}:{type:"array"};let n={type:t};return t==="string"&&V(e,n),n}):[e]}var Ke=.5,We=3;function Oe(e,t){let n=Object.keys(e.properties??{}),r=Object.keys(t.properties??{});if(n.length===0||r.length===0)return 1;let o=new Set(r),s=n.filter(c=>o.has(c)).length;return s/(n.length+r.length-s)}function Xe(e,t){let n=k(e);if(n!==k(t))return!1;switch(n){case"scalar":return e.type===t.type||e.type==="integer"&&t.type==="number"||e.type==="number"&&t.type==="integer";case"object":return Oe(e,t)>=Ke;default:return!0}}function ve(e,t){switch(k(e)){case"scalar":{if(e.type!==t.type)return{type:"number"};if(e.type==="string"){let n=q(H(e),H(t));if(n){let r={type:"string"};return z(r,n),r}}return e}case"map":return{type:"object",additionalProperties:U(e.additionalProperties??{},t.additionalProperties??{})};case"object":{let n={...e.properties??{}};for(let[c,i]of Object.entries(t.properties??{}))n[c]=n[c]?U(n[c],i):i;let r=new Set(t.required??[]),o=(e.required??[]).filter(c=>r.has(c)),s={type:"object",properties:n};return o.length>0&&(s.required=o),s}case"array":{if(!e.items||!t.items){let n=e.items??t.items;return n?{type:"array",items:n}:{type:"array"}}return{type:"array",items:U(e.items,t.items)}}}}function Ze(e){let t=[...e],n=()=>t.filter(r=>k(r)==="object").length;for(;n()>We;){let r=-1,o=-1,s=-1;for(let c=0;c<t.length;c++)if(k(t[c])==="object")for(let i=c+1;i<t.length;i++){if(k(t[i])!=="object")continue;let a=Oe(t[c],t[i]);a>s&&(s=a,r=c,o=i)}t[r]=ve(t[r],t[o]),t.splice(o,1)}return t}var Qe=["boolean","integer","number","string","null"];function et(e){if(e.length===1)return e[0];let t=[],n=new Set,r;for(let i of e)k(i)==="scalar"&&typeof i.type=="string"?(n.add(i.type),i.type==="string"&&(r=q(r,H(i)))):t.push(i);let o=Qe.filter(i=>n.has(i)),s=i=>{let a={type:i};return(typeof i=="string"?i==="string":i.includes("string"))&&r&&z(a,r),a};if(t.length===0)return o.length===1?s(o[0]):s(o);if(t.length===1&&o.length===1&&o[0]==="null"&&typeof t[0].type=="string")return{...t[0],type:[t[0].type,"null"]};let c=[...t];return o.length===1?c.push(s(o[0])):o.length>1&&c.push(s(o)),{oneOf:c}}function U(e,t){if(he(e)||he(t))return{};let n=W(e);for(let r of W(t)){let o=n.findIndex(s=>Xe(s,r));o===-1?n.push(r):n[o]=ve(n[o],r)}return et(Ze(n))}function tt(e){if(!e)return;let t=e.trim();if(!(!t.startsWith("{")&&!t.startsWith("[")))try{return JSON.parse(t)}catch{return}}function nt(e,t){let n=t?.match(/boundary="?([^";,]+)"?/i)?.[1];if(!n)return;let r={};for(let o of e.split(`--${n}`)){let s=o.match(/^\r?\n([\s\S]*?)\r?\n\r?\n([\s\S]*)\r?\n$/);if(!s)continue;let[,c,i]=s,a=c.match(/\bname="([^"]*)"/i)?.[1];a!==void 0&&(r[a]=/\bfilename="/i.test(c)?{type:"string",format:"binary"}:j(i))}if(Object.keys(r).length!==0)return{type:"object",properties:r,required:Object.keys(r)}}function ge(e){let t=I(e.contentType);if(e.bodyJson!==void 0)return{mime:ue(t)?t:"application/json",schema:j(e.bodyJson)};if(t===de&&e.bodyText){let r={};for(let[o,s]of new URLSearchParams(e.bodyText))r[o]=s;return Object.keys(r).length===0?void 0:{mime:de,schema:j(r)}}if(t===le&&e.bodyText){let r=nt(e.bodyText,e.contentType);return r?{mime:le,schema:r}:void 0}let n=tt(e.bodyText);if(n!==void 0)return{mime:"application/json",schema:j(n)}}function ye(e,t,n){let r=e.get(t);e.set(t,r?J([r,n]):n)}async function we(e){let t=await C(e.trafficPath);if(t.length===0)throw new Error("No traffic files found in the provided traffic path.");let n=_(e.server),r=new Map,o=new Set,s=0,c=a=>{let p=a.request.method.toLowerCase();if(!X.has(p))return;let f=a.request.path||"/";if(n){let u=B(a.request,n);if(u===void 0)return;f=u}else a.request.host&&!fe(a.request.host)&&o.add(`${a.request.protocol}//${a.request.host}`);let{template:m,params:d}=Z(N(f)),P=`${p} ${m}`,h=r.get(P);h||(h={method:p,template:m,pathParams:new Map,queryParams:new Map,requestBodies:new Map,responses:new Map},r.set(P,h));for(let{name:u,value:l}of d){let y=h.pathParams.get(u);h.pathParams.set(u,{numeric:(y?.numeric??!0)&&F.test(l),observations:q(y?.observations,D(l))})}for(let u of new Set(a.request.query.keys())){let l=a.request.query.getAll(u),y=h.queryParams.get(u),T=l.length>0&&l.every(b=>F.test(b)),R=y?.observations;for(let b of l)R=q(R,D(b));h.queryParams.set(u,{numeric:(y?.numeric??!0)&&T,observations:R})}if(!Le.has(p)){let u=ge(a.request);u&&ye(h.requestBodies,u.mime,u.schema)}if(a.response&&a.response.status>=100){let u=String(a.response.status),l=h.responses.get(u);l||(l={bodies:new Map},h.responses.set(u,l)),l.statusText??=a.response.statusText||void 0;let y=ge(a.response);y&&ye(l.bodies,y.mime,y.schema)}};for(let a of t){let p=await G(a,e.format);if(!p){S.warn(`Skipping traffic file with unrecognized format: ${a}
|
|
8
8
|
`);continue}s+=1;for await(let f of p.parse(a))c(f)}if(s===0)throw new Error("No supported traffic files found to generate an OpenAPI description from.");if(r.size===0)throw new Error(n?`No HTTP exchanges in the traffic matched the server "${n}".`:"No HTTP exchanges were observed in the traffic. Cannot generate an OpenAPI description.");let i=n?[n]:Array.from(o).sort();return rt(r,e.title??"Generated API",i)}function Pe(e){return Object.values(e.paths).reduce((t,n)=>t+Object.keys(n).length,0)}function Se(e,t){if(e.numeric)return{type:"integer"};let n={type:"string"};return e.observations&&Object.assign(n,K(e.observations,t)),n}function rt(e,t,n){let r={};for(let o of e.values()){let s=r[o.template]??={},c=[...Array.from(o.pathParams).map(([a,p])=>({name:a,in:"path",required:!0,schema:Se(p,!1)})),...Array.from(o.queryParams).map(([a,p])=>({name:a,in:"query",required:!1,schema:Se(p,!0)}))],i={operationId:ot(o.method,o.template),responses:{}};if(c.length>0&&(i.parameters=c),o.requestBodies.size>0){let a={};for(let[p,f]of o.requestBodies)a[p]={schema:f};i.requestBody={content:a}}if(o.responses.size===0)i.responses.default={description:"Observed response"};else for(let[a,p]of o.responses){let f={description:p.statusText||"Observed response"};if(p.bodies.size>0){let m={};for(let[d,P]of p.bodies)m[d]={schema:P};f.content=m}i.responses[a]=f}s[o.method]=i}return{openapi:"3.2.0",info:{title:t,version:"1.0.0"},...n.length>0?{servers:n.map(o=>({url:o}))}:{},paths:r}}function ot(e,t){let n=t.split("/").filter(Boolean).map(r=>r.replace(/[{}]/g,"")).join("-");return`${e}-${n||"root"}`}function L(e,t){return`${e.toUpperCase()} ${t}`}function Te(e,t){let n;if(e.bodyJson!==void 0)try{n=JSON.stringify(e.bodyJson)}catch{n=void 0}if(n??=e.bodyText,!n)return;let r=n.trim();if(r)return r.length>t?`${r.slice(0,t)}\u2026[truncated]`:r}function $e(e){if(!e)return"";let t=e.bodyJson;return t===void 0?e.bodyText?I(e.contentType)||"text":"":t===null?"null":Array.isArray(t)?`array<${t.length>0?je(t[0]):""}>`:je(t)}function je(e){return g(e)?Object.keys(e).sort().join(","):e===null?"null":typeof e}async function ke(e){let t=e.perGroup??2,n=e.perOperation??4,r=e.maxBodyChars??2e3,o=_(e.server),s=await C(e.trafficPath),c=new Map;for(let a of s){let p=await G(a,e.format);if(p)for await(let f of p.parse(a)){let m=f.request.method.toUpperCase();if(!X.has(m.toLowerCase()))continue;let d=f.request.path||"/";if(o){let ne=B(f.request,o);if(ne===void 0)continue;d=ne}let P=N(d),{template:h}=Z(P),u=f.response&&f.response.status>=100?f.response:void 0,l=u?.status,y=`${$e(f.request)}\u2192${$e(u)}`,T=c.get(L(m,h));T||(T=new Map,c.set(L(m,h),T));let R=`${l??""} ${y}`,b=T.get(R);b||(b=[],T.set(R,b)),!(b.length>=t)&&b.push({method:m,path:P,query:f.request.query.toString(),status:l,requestContentType:f.request.contentType,requestBody:Te(f.request,r),responseContentType:u?.contentType,responseBody:u?Te(u,r):void 0})}}let i=new Map;for(let[a,p]of c){let f=[];for(let m=0;m<t&&f.length<n;m++)for(let d of p.values()){if(f.length>=n)break;d[m]&&f.push(d[m])}i.set(a,f)}return i}var st=`You are an expert API designer. You are given one operation from an OpenAPI 3.2 description that was inferred mechanically from recorded HTTP traffic, the component schemas it references, and a sample of the real recorded HTTP exchanges for that operation. The inferred description is only a hypothesis: types are coarse, every observed property is marked required, and descriptions are missing. Alternative body shapes observed in the traffic appear as "oneOf" variants or type unions. Common string formats (uuid, date-time, date, email, uri, ipv4) and small closed enums are detected conservatively from the observed values.
|
|
9
9
|
|
|
10
10
|
Refine the operation into the most accurate OpenAPI 3.2 definition you can justify from the evidence, while staying conservative:
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as $,b as a,c,d as i,e as m,f}from"./
|
|
7
|
+
import{a as $,b as a,c,d as i,e as m,f}from"./UQW6CW3M.js";import{k as l}from"./LD5MEXEL.js";import{join as p}from"node:path";function k(t,n){let e=$(t,"swr");if(e.length===0)return"";let s=e.some(a),o=e.some(r=>!a(r));return[...s?['import useSWR from "swr";']:[],...o?['import useSWRMutation from "swr/mutation";']:[],f(e,n.sdkModule,s),...e.flatMap(r=>a(r)?g(r):[S(r)])].join(`
|
|
8
8
|
|
|
9
9
|
`)}function y(t,n,e){return`export function use${l(t.name)}(${n}) {
|
|
10
10
|
return ${e};
|
|
@@ -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{h as l}from"./
|
|
7
|
+
import{h as l}from"./VKTRI5YG.js";import"./GKXY6U4S.js";import{ia as p,oa as i}from"./EQTXHL74.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as C}from"node:child_process";import{existsSync as x}from"node:fs";import*as s from"node:path";var P=/[\\/](_npx|dlx)[\\/]/;function a(r,t,e){return`${r}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}/git`}function m(r,t){let e=`credential.${r}/.helper`,o=!P.test(process.argv[1]??"")&&j("redocly")?"redocly":`npx --yes @redocly/cli@${t}`;return[`${e}=`,`${e}=!REDOCLY_SUPPRESS_UPDATE_NOTICE=true ${o} project git-credentials`]}async function d(r){return new Promise((t,e)=>{let n=C("git",r,{stdio:"inherit",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});n.on("error",o=>e(E(o))),n.on("close",o=>t(o??1))})}function j(r){let t=process.platform==="win32"?[".cmd",".exe"]:[""];return(process.env.PATH??"").split(s.delimiter).some(e=>e&&t.some(n=>x(s.join(e,r+n))))}function E(r){return r.code==="ENOENT"?new i("git is not installed or not on PATH."):r}async function U({argv:r,config:t,version:e}){let[n,o,...g]=r.project.split("/");if(!n||!o||g.length>0)throw new i(`Specify the project as \`<organization>/<project>\`, for example \`acme/developer-portal\`. Got: \`${r.project}\`.`);let c=l(t,r.residency),f=a(c,n,o),u=m(c,e);if(p.info(`Cloning ${n}/${o} from ${c}
|
|
8
8
|
`),await d(["clone",...u.flatMap(y=>["--config",y]),f,r.directory??o])!==0)throw new i("git clone failed.")}export{U as handleProjectClone};
|