@redocly/cli 2.59.0 → 2.61.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 +2 -2
- package/lib/chunks/{PHV3T4WH.js → 22EANOP2.js} +87 -87
- package/lib/chunks/{AF5IHTRV.js → 2KG4GEMM.js} +1 -1
- package/lib/chunks/2OVI7BIW.js +105 -0
- package/lib/chunks/{NFJLKOC3.js → 2WJSVZYJ.js} +1 -1
- package/lib/chunks/{J3SQBSQT.js → 3QZ3M2JX.js} +1 -1
- package/lib/chunks/{NC5GB4G5.js → 3TBVUHVH.js} +1 -1
- package/lib/chunks/{OFVQSSQQ.js → 3VI3PRNZ.js} +1 -1
- package/lib/chunks/45DZYRBQ.js +7 -0
- package/lib/chunks/{QB6J3FNI.js → 47H7SS4U.js} +1 -1
- package/lib/chunks/{OIISHIPF.js → 5PG3ST2N.js} +2 -2
- package/lib/chunks/{PCJ3RO4V.js → 6DO6IN4A.js} +1 -1
- package/lib/chunks/6ETCN64B.js +20 -0
- package/lib/chunks/{TJGR5OHF.js → 6GH5BRNP.js} +1 -1
- package/lib/chunks/{UESEVDDS.js → 6L6AYZQS.js} +10 -10
- package/lib/chunks/{F2MGZZWG.js → 6NGWHZCB.js} +1 -1
- package/lib/chunks/{WK3QKCKY.js → 6ZVVKLZR.js} +1 -1
- package/lib/chunks/7FLYZDPU.js +11 -0
- package/lib/chunks/{FG62OWSV.js → 7RZON3J3.js} +1 -1
- package/lib/chunks/{42YAZTOS.js → B6HOY6AV.js} +1 -1
- package/lib/chunks/DDAZZC3I.js +20 -0
- package/lib/chunks/{KSTWCX27.js → DNQSGL2N.js} +1 -1
- package/lib/chunks/{NSK5BX5M.js → E5BMYA7V.js} +1 -1
- package/lib/chunks/ERFYZ47T.js +11 -0
- package/lib/chunks/{NSLUCFIM.js → F6IXS3RL.js} +1 -1
- package/lib/chunks/{B7HK2FMY.js → FAIK7Y6U.js} +1 -1
- package/lib/chunks/{PRAHH3RT.js → FAZWASU6.js} +1 -1
- package/lib/chunks/{DAQRGYND.js → FDMXHRDK.js} +1 -1
- package/lib/chunks/{RS64EP6M.js → FUH5ZFZ2.js} +1 -1
- package/lib/chunks/{G5TC4ZEC.js → GGRILIN6.js} +1 -1
- package/lib/chunks/{BYWCQTSQ.js → GJDVFWVH.js} +1 -1
- package/lib/chunks/{BEYYSLHN.js → GLOLLUKD.js} +1 -1
- package/lib/chunks/{7QMY27YR.js → GZ7EDJXV.js} +1 -1
- package/lib/chunks/HBPMIV7U.js +9 -0
- package/lib/chunks/{CUJVZNF3.js → HHJX3B7U.js} +1 -1
- package/lib/chunks/{P6JG7GU7.js → IKDYY4XW.js} +2 -2
- package/lib/chunks/{NBRDOUIR.js → IMYWYFYT.js} +1 -1
- package/lib/chunks/{AVEIZUZG.js → IRHTRVFK.js} +1 -1
- package/lib/chunks/{E2UY7KGT.js → JP2RKFML.js} +1 -1
- package/lib/chunks/{IOYEFQOG.js → KRCCY64H.js} +1 -1
- package/lib/chunks/{OIPFI3RD.js → KVXNE2UB.js} +1 -1
- package/lib/chunks/{UQSXY6X3.js → LR2FZ43E.js} +1 -1
- package/lib/chunks/{YYL4GJWR.js → LRLGVYCG.js} +1 -1
- package/lib/chunks/{MBJ2NZOC.js → LXU55G2P.js} +1 -1
- package/lib/chunks/{CSBPXWYJ.js → MAHMSXK6.js} +1 -1
- package/lib/chunks/{GYVNLXXF.js → MK6X55UC.js} +1 -1
- package/lib/chunks/{NEOAISVJ.js → MNH2K4WM.js} +1 -1
- package/lib/chunks/{TPR5SEOT.js → MUKYSFRK.js} +1 -1
- package/lib/chunks/MXOINKB2.js +7 -0
- package/lib/chunks/{AVVEOYYF.js → OP7NIAI7.js} +1 -1
- package/lib/chunks/{BRJNFWLD.js → OXA7GLZA.js} +1 -1
- package/lib/chunks/{QTOB5ERW.js → PSEWUH36.js} +1 -1
- package/lib/chunks/{IT53FBW3.js → PTNNX4IU.js} +1 -1
- package/lib/chunks/{6367YNHA.js → QFJ6QZPG.js} +1 -1
- package/lib/chunks/{GEYI6VH2.js → RPHIT72T.js} +1 -1
- package/lib/chunks/{RTZAVLXW.js → RPQMBRTA.js} +1 -1
- package/lib/chunks/{MO5BUSRI.js → SFNDGMJM.js} +1 -1
- package/lib/chunks/SLQPKXO2.js +7 -0
- package/lib/chunks/{7YRZIM5N.js → SYWAPWW7.js} +1 -1
- package/lib/chunks/{LHKSVCO3.js → SZVRKEMY.js} +5 -5
- package/lib/chunks/{J2APNZBG.js → TBZEEKTV.js} +1 -1
- package/lib/chunks/{AX7QT4NM.js → US7X4XPD.js} +1 -1
- package/lib/chunks/{J56XVM43.js → V5CIDI6D.js} +58 -12
- package/lib/chunks/WCWEP2X5.js +20 -0
- package/lib/chunks/{V2MDYOAB.js → WEOCCL26.js} +2 -2
- package/lib/chunks/{RSJYGTUN.js → WSOBFTCE.js} +1 -1
- package/lib/chunks/{2U6O26CV.js → XJE2OFDN.js} +116 -16
- package/lib/chunks/{6IOZ5LPA.js → YEOWW3LR.js} +1 -1
- package/lib/chunks/{7W4L5LRS.js → ZH5HJBCG.js} +1 -1
- package/lib/chunks/ZOE6CZ74.js +8 -0
- package/lib/eject-assets/AGENTS.md +24 -23
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +1 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +35 -3
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +1 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +21 -3
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +1 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +19 -6
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +3 -4
- 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/client-generators/SKILL.md +24 -23
- package/lib/eject-assets/skills/go-generator/SKILL.md +11 -0
- package/lib/eject-assets/skills/php-generator/SKILL.md +16 -0
- package/lib/eject-assets/skills/python-generator/SKILL.md +13 -0
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +16 -0
- package/lib/index.js +54 -53
- package/package.json +1 -1
- package/lib/chunks/2ZE577MX.js +0 -11
- package/lib/chunks/6CJDOMNR.js +0 -8
- package/lib/chunks/7FNYMCIP.js +0 -105
- package/lib/chunks/DBWAOHZO.js +0 -11
- package/lib/chunks/ECKYES2X.js +0 -20
- package/lib/chunks/IDDPOAAO.js +0 -20
- package/lib/chunks/O553F5PN.js +0 -20
- package/lib/chunks/QEM3YVSB.js +0 -7
- package/lib/chunks/US7OHDWQ.js +0 -7
- package/lib/chunks/YSCPIS6C.js +0 -9
- package/lib/chunks/ZLNFQUIK.js +0 -7
|
@@ -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{c as p}from"./HBUZKWXC.js";import{a as i,b as s}from"./4PTNG4EI.js";import{
|
|
7
|
+
import{c as p}from"./HBUZKWXC.js";import{a as i,b as s}from"./4PTNG4EI.js";import{ia as t}from"./22EANOP2.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as g}from"node:child_process";import{existsSync as l,readFileSync as P}from"node:fs";import w from"node:path";var S=async({argv:r})=>{let{plan:e,port:a}=r,n=r["project-dir"],o=r.product||h(n);if(!j(o))throw t.info(`Invalid product ${o}.`),new Error("Project preview launch failed.");let c=s[o],d=i[o];t.info(`
|
|
8
8
|
Launching preview of ${c} ${e} using NPX.
|
|
9
9
|
|
|
10
10
|
`);let{npxExecutableName:m,shell:f}=p();g(m,["-y",d,"preview",`--plan=${e}`,`--port=${a||4e3}`],{stdio:"inherit",cwd:n,shell:f}).on("error",u=>{throw t.info(`Project preview launch failed: ${u.message}`),new Error("Project preview launch failed.")})},j=r=>r?!!s[r]:!1,h=r=>{let e=w.join(process.cwd(),r,"package.json");if(l(e))try{let n=JSON.parse(P(e,"utf-8")).dependencies||{};for(let[o,c]of Object.entries(i))if(n[c])return t.info(`
|
|
@@ -4,10 +4,10 @@ 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 l,b as
|
|
7
|
+
import{a as l,b as v,c as U,d as F,e as R}from"./U5DIFWGH.js";import{b as O}from"./F6IXS3RL.js";import{ba as k,c as G,ca as $,ga as S,ia as b,l as P,oa as g}from"./22EANOP2.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{readFileSync as z}from"node:fs";import{mkdir as H,writeFile as B}from"node:fs/promises";import{basename as T,dirname as A,extname as I,isAbsolute as N,relative as j,resolve as f}from"node:path";var V=/^[a-z][a-z0-9+.-]+:/i;function L(e,n){let{setup:o}=e;if(typeof o!="string")return e;if(V.test(o))throw new g(`
|
|
8
8
|
\u274C \`client.setup\` must be a local file path \u2014 remote setup modules are not supported.
|
|
9
9
|
Got: ${o}
|
|
10
|
-
`);return N(o)?e:{...e,setup:f(n,o)}}function q(e){return`${e.replace(/[\\/]/g,"_")}.client.ts`}function D(e){if(e.startsWith("//"))return!1;if(e.startsWith("/"))return!0;try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}async function ie({argv:e,config:n}){let{AUTHORING_HELPER_NAMES:o,generateClient:c,mergeConfig:m}=await import("./
|
|
10
|
+
`);return N(o)?e:{...e,setup:f(n,o)}}function q(e){return`${e.replace(/[\\/]/g,"_")}.client.ts`}function D(e){if(e.startsWith("//"))return!1;if(e.startsWith("/"))return!0;try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"}catch{return!1}}async function ie({argv:e,config:n}){let{AUTHORING_HELPER_NAMES:o,generateClient:c,mergeConfig:m}=await import("./MXOINKB2.js"),t=n.configPath?A(n.configPath):process.cwd(),s={serverUrl:e["server-url"],outputMode:e["output-mode"],runtime:e.runtime,importExt:e["import-ext"],goPackage:e["go-package"],argsStyle:e["args-style"],errorMode:e["error-mode"],dateType:e["date-type"],mockData:e["mock-data"],mockSeed:e["mock-seed"],docs:e.docs,generators:e.generator?.map(a=>a.startsWith(".")?f(a):a),setup:e.setup===void 0?void 0:L({setup:e.setup},process.cwd()).setup},r=n.resolvedConfig.apis??{},i=Object.keys(r).filter(a=>G(r[a].client)||r[a].clientOutput!==void 0);if(e.api===void 0){if(e.output)throw new g("\n\u274C --output can't target multiple APIs. Set `clientOutput` under each api in redocly.yaml, or pass a single <api>.\n");if(i.length===0)throw new g("\n\u274C No API to generate. Add a `client` block or `clientOutput` under an `apis:` entry, or pass <api> (a file/URL or an `apis:` alias).\n")}let u=await O(e.api===void 0?i:[e.api],n),p={config:n,configDir:t,cliFlags:s,outputFlag:e.output,toolkit:{generateClient:c,mergeConfig:m,helperNames:o},seenOutputs:new Set,composable:[]};for(let a of u)await J(a,p);let y=G(n.resolvedConfig.client)?n.resolvedConfig.client:{};y.cliOutput!==void 0&&e.api===void 0&&p.composable.length>0&&await K(y.cliOutput,p)}async function J(e,{config:n,configDir:o,cliFlags:c,outputFlag:m,toolkit:t,seenOutputs:s,composable:r}){let{path:i,alias:u}=e,p=u??T(i,I(i)),y=n.forAlias(u),{client:a,clientOutput:E}=y.resolvedConfig,W=L(G(a)?a:{},o),h=t.mergeConfig(W,c);Q(h.generators??[],t.helperNames,o);let C=m!==void 0?f(m):E!==void 0?f(o,E):f(o,q(p));if(!C.endsWith(".ts"))throw new g(`
|
|
11
11
|
\u274C output must point at a TypeScript file (ending in .ts).
|
|
12
12
|
Got: ${C}
|
|
13
13
|
`);if(s.has(C))throw new g(`
|
|
@@ -20,10 +20,10 @@ import{a as l,b as O,c as v,d as U,e as F}from"./U5DIFWGH.js";import{b as R}from
|
|
|
20
20
|
Generating client for ${p}...
|
|
21
21
|
`));let d=await t.generateClient({...h,api:i,output:C,config:y,configDir:o}),w=d.files.find(_=>_.path.endsWith(".cli.ts"));if(w!==void 0){let _=h.importExt??"js";r.push({alias:p,cliPath:w.path.replace(/\.ts$/,_==="ts"?".ts":".js")})}for(let _ of d.files)s.add(_.path);let M=`Client successfully generated: ${`${d.files.length} ${P("file",d.files.length)}`} (${d.bytes} bytes) at ${k(d.outputPath)}.`;b.info(`
|
|
22
22
|
`+$(M)+`
|
|
23
|
-
`)}catch(d){let w=d instanceof Error?d.message:String(d);throw l.generate_client_error_category=
|
|
23
|
+
`)}catch(d){let w=d instanceof Error?d.message:String(d);throw l.generate_client_error_category=R(w),new g(`
|
|
24
24
|
\u274C Failed to generate client for ${p}.
|
|
25
25
|
${w}
|
|
26
|
-
`)}}async function K(e,{configDir:n,seenOutputs:o,composable:c}){let{renderComposedCliEntry:m}=await import("./
|
|
26
|
+
`)}}async function K(e,{configDir:n,seenOutputs:o,composable:c}){let{renderComposedCliEntry:m}=await import("./45DZYRBQ.js"),t=f(n,e);if(!t.endsWith(".ts"))throw new g(`
|
|
27
27
|
\u274C client.cliOutput must point at a TypeScript file (ending in .ts).
|
|
28
28
|
Got: ${t}
|
|
29
29
|
`);if(o.has(t))throw new g(`
|
|
@@ -31,4 +31,4 @@ import{a as l,b as O,c as v,d as U,e as F}from"./U5DIFWGH.js";import{b as R}from
|
|
|
31
31
|
Give the composed entry its own path.
|
|
32
32
|
`);let s=T(t,I(t)),r=m(c.map(({alias:i,cliPath:u})=>({alias:i,modulePath:`./${j(A(t),u).split("\\").join("/")}`})),s);await H(A(t),{recursive:!0}),await B(t,r,"utf-8"),l.generate_client_composed_apis_count=c.length,b.info(`
|
|
33
33
|
`+$(`Composed CLI written to ${k(j(process.cwd(),t))} \u2014 ${c.map(({alias:i})=>i).join(", ")} behind one \`${s}\` binary.`)+`
|
|
34
|
-
`)}var x=new Set;function Q(e,n,o){let c=new Set(l.generate_client_builtin_generators??[]),m=new Set(l.generate_client_toolkit_imports??[]),t=new Set(l.generate_client_ejected_generators??[]),s=l.generate_client_custom_generators_count??0;for(let r of e){if(
|
|
34
|
+
`)}var x=new Set;function Q(e,n,o){let c=new Set(l.generate_client_builtin_generators??[]),m=new Set(l.generate_client_toolkit_imports??[]),t=new Set(l.generate_client_ejected_generators??[]),s=l.generate_client_custom_generators_count??0;for(let r of e){if(v.has(r)){c.add(r);continue}if(!x.has(r)&&(x.add(r),s++,r.startsWith(".")||N(r)))try{let i=z(f(o,r),"utf-8");for(let p of U(i,n))m.add(p);let u=F(i);u&&t.add(`${u.name}@${u.version}`)}catch{}}l.generate_client_builtin_generators=[...c],l.generate_client_custom_generators_count=s,l.generate_client_toolkit_imports=[...m],l.generate_client_ejected_generators=[...t]}export{Q as collectGeneratorUsage,ie as handleGenerateClient};
|
|
@@ -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,c as n}from"./HBUZKWXC.js";import{
|
|
7
|
+
import{a as o,c as n}from"./HBUZKWXC.js";import{ia as t}from"./22EANOP2.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as m}from"node:child_process";var j=async({argv:e})=>{t.info(`
|
|
8
8
|
Launching eject using NPX.
|
|
9
9
|
|
|
10
10
|
`);let{npxExecutableName:c,sanitize:r,shell:i}=n(),p=r(e.path,o),a=r(e["project-dir"],o);m(c,["-y","@redocly/realm","eject",`${e.type}`,p,`-d=${a}`,e.force?`--force=${e.force}`:""],{stdio:"inherit",shell:i}).on("error",s=>{throw t.info(`Eject launch failed: ${s.message}`),new Error("Eject launch failed.")})};export{j as handleEject};
|
|
@@ -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{
|
|
7
|
+
import{ia as t}from"./22EANOP2.js";import*as e from"node:process";var o=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],n=class{frames;currentFrame;intervalId;message;constructor(){this.frames=o,this.currentFrame=0,this.intervalId=null,this.message=""}showFrame(){t.info("\r"+this.frames[this.currentFrame]+" "+this.message),this.currentFrame=(this.currentFrame+1)%this.frames.length}start(r){if(this.message!==r){if(this.message=r,!e.stderr.isTTY){t.info(`${r}...
|
|
8
8
|
`);return}this.intervalId===null&&(this.intervalId=setInterval(()=>{this.showFrame()},100))}}stop(){this.intervalId!==null&&(clearInterval(this.intervalId),this.intervalId=null,t.info("\r")),this.message=""}};function h(i){i.stop(),e.stderr.isTTY&&t.info("\x1B[2K")}function m(i,r){let[s]=r.inFlight;if(!s)return;let a=r.inFlight.size>1?` (+${r.inFlight.size-1} more)`:"";i.start(`[${r.position}/${r.total}] ${r.action} ${s}${a}`)}export{n as a,h as b,m as c};
|
|
@@ -4,9 +4,9 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c as x,
|
|
8
|
-
- `));return s}function y(e,n,s,r,a){let o=`Pagination for operation "${e.name}" (${r})`,c=q(s);if(c!==void 0)return{error:`${o}: ${c}`};let t=s,d=i=>a?{error:`${o}: ${i}`}:{};if(e.sse!==void 0)return d("the operation is a Server-Sent Events stream");if(t.style!=="link"){let i=t.style==="cursor"?"cursorParam":"offsetParam",l=t.style==="cursor"?t.cursorParam:t.offsetParam,k=e.queryParams.find(u=>u.name===l);if(!k){let u=e.queryParams.map(E=>E.name).join(", ");return d(`query parameter "${l}" is not declared on the operation`+(u===""?"":` (declared: ${u})`))}let p=
|
|
9
|
-
`)}let h=m(g.schema,t.items,n);if(h===void 0)return d(`the "items" pointer "${t.items}" does not resolve in the success response schema`);if(h.kind!=="array")return d(`the "items" pointer "${t.items}" must point at an array (got ${h.kind})`);if(t.style==="cursor"){let i=m(g.schema,t.nextCursor,n);if(i===void 0)return d(`the "nextCursor" pointer "${t.nextCursor}" does not resolve in the success response schema`);if(!b(i,n))return d(`the "nextCursor" pointer "${t.nextCursor}" must point at a string (got ${i.kind})`);if(t.hasMore!==void 0){let l=m(g.schema,t.hasMore,n);if(l===void 0)return d(`the "hasMore" pointer "${t.hasMore}" does not resolve in the success response schema`);if(l.kind!=="scalar"||l.scalar!=="boolean")return d(`the "hasMore" pointer "${t.hasMore}" must point at a boolean (got ${l.kind})`)}}let f=t.limitParam!==void 0?{limitParam:t.limitParam}:{};return{spec:t.style==="cursor"?{style:"cursor",param:t.cursorParam,...f,nextCursor:t.nextCursor,...t.hasMore!==void 0?{hasMore:t.hasMore}:{},items:t.items}:t.style==="link"?{style:"link",...f,items:t.items}:{style:t.style,param:t.offsetParam,...f,items:t.items},itemSchema:h.items}}function q(e){if(!x(e))return"the rule must be an object";let{style:n,cursorParam:s,nextCursor:r,hasMore:a,offsetParam:o,limitParam:c,items:t}=e;if(n!=="cursor"&&n!=="offset"&&n!=="page"&&n!=="link")return`"style" must be one of "cursor" | "offset" | "page" | "link" (got ${JSON.stringify(n)})`;if(typeof t!="string"||t!==""&&!t.startsWith("/"))return'"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';if(n==="cursor"){if(typeof s!="string"||s==="")return'cursor style requires a "cursorParam" query parameter name';if(typeof r!="string"||!r.startsWith("/"))return'cursor style requires a "nextCursor" JSON pointer starting with "/"';if(a!==void 0&&(typeof a!="string"||!a.startsWith("/")))return'"hasMore" must be a JSON pointer starting with "/"'}else if((n==="offset"||n==="page")&&(typeof o!="string"||o===""))return`${n} style requires an "offsetParam" query parameter name`;if(c!==void 0&&typeof c!="string")return'"limitParam" must be a query parameter name'}function I(e){return e===void 0?"an unresolvable ref":e.kind==="scalar"||e.kind==="enum"?e.scalar:e.kind}function
|
|
7
|
+
import{c as x,ia as R}from"./22EANOP2.js";import{m}from"./UW4UC7ZI.js";function C(e){return e.flatMap(n=>n.operations)}function P(e,n,s){let r=e.specName??e.name;if(s?.exclude?.includes(r))return{};let a=s?.operations?.[r];if(a!==void 0)return y(e,n,a,`pagination.operations["${r}"]`,!0);if(e.paginationExtension!==void 0)return y(e,n,e.paginationExtension,"x-redoclyPagination",!0);if(s?.style!==void 0){let{exclude:o,operations:c,...t}=s;return y(e,n,t,"pagination convention",!1)}return{}}function H(e,n){let s=new Map,r=[];for(let a of C(e.services)){let o=P(a,e,n);o.error!==void 0?r.push(o.error):o.spec!==void 0&&s.set(a.name,{spec:o.spec,itemSchema:o.itemSchema})}if(r.length>0)throw new Error(["Invalid pagination configuration:",...r].join(`
|
|
8
|
+
- `));return s}function y(e,n,s,r,a){let o=`Pagination for operation "${e.name}" (${r})`,c=q(s);if(c!==void 0)return{error:`${o}: ${c}`};let t=s,d=i=>a?{error:`${o}: ${i}`}:{};if(e.sse!==void 0)return d("the operation is a Server-Sent Events stream");if(t.style!=="link"){let i=t.style==="cursor"?"cursorParam":"offsetParam",l=t.style==="cursor"?t.cursorParam:t.offsetParam,k=e.queryParams.find(u=>u.name===l);if(!k){let u=e.queryParams.map(E=>E.name).join(", ");return d(`query parameter "${l}" is not declared on the operation`+(u===""?"":` (declared: ${u})`))}let p=O(k.schema,n);if(!(p!==void 0&&(t.style==="cursor"?b(p,n):p.kind==="scalar"&&(p.scalar==="number"||p.scalar==="integer")))){let u=t.style==="cursor"?"a string":"a number";return d(`the "${i}" query parameter "${l}" must accept ${u} (got ${I(p)})`)}}let g=e.successResponses.find(i=>i.contentType.toLowerCase().includes("json"));if(!g)return d("the operation has no JSON success response");if(t.style==="link"){let i=e.successResponseHeaders?.some(l=>l.name==="link")===!0;if(!i&&!a)return{};i||R.warn(`generate-client: ${o.toLowerCase()} follows the Link header, but the success response does not document one.
|
|
9
|
+
`)}let h=m(g.schema,t.items,n);if(h===void 0)return d(`the "items" pointer "${t.items}" does not resolve in the success response schema`);if(h.kind!=="array")return d(`the "items" pointer "${t.items}" must point at an array (got ${h.kind})`);if(t.style==="cursor"){let i=m(g.schema,t.nextCursor,n);if(i===void 0)return d(`the "nextCursor" pointer "${t.nextCursor}" does not resolve in the success response schema`);if(!b(i,n))return d(`the "nextCursor" pointer "${t.nextCursor}" must point at a string (got ${i.kind})`);if(t.hasMore!==void 0){let l=m(g.schema,t.hasMore,n);if(l===void 0)return d(`the "hasMore" pointer "${t.hasMore}" does not resolve in the success response schema`);if(l.kind!=="scalar"||l.scalar!=="boolean")return d(`the "hasMore" pointer "${t.hasMore}" must point at a boolean (got ${l.kind})`)}}let f=t.limitParam!==void 0?{limitParam:t.limitParam}:{};return{spec:t.style==="cursor"?{style:"cursor",param:t.cursorParam,...f,nextCursor:t.nextCursor,...t.hasMore!==void 0?{hasMore:t.hasMore}:{},items:t.items}:t.style==="link"?{style:"link",...f,items:t.items}:{style:t.style,param:t.offsetParam,...f,items:t.items},itemSchema:h.items}}function q(e){if(!x(e))return"the rule must be an object";let{style:n,cursorParam:s,nextCursor:r,hasMore:a,offsetParam:o,limitParam:c,items:t}=e;if(n!=="cursor"&&n!=="offset"&&n!=="page"&&n!=="link")return`"style" must be one of "cursor" | "offset" | "page" | "link" (got ${JSON.stringify(n)})`;if(typeof t!="string"||t!==""&&!t.startsWith("/"))return'"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';if(n==="cursor"){if(typeof s!="string"||s==="")return'cursor style requires a "cursorParam" query parameter name';if(typeof r!="string"||!r.startsWith("/"))return'cursor style requires a "nextCursor" JSON pointer starting with "/"';if(a!==void 0&&(typeof a!="string"||!a.startsWith("/")))return'"hasMore" must be a JSON pointer starting with "/"'}else if((n==="offset"||n==="page")&&(typeof o!="string"||o===""))return`${n} style requires an "offsetParam" query parameter name`;if(c!==void 0&&typeof c!="string")return'"limitParam" must be a query parameter name'}function I(e){return e===void 0?"an unresolvable ref":e.kind==="scalar"||e.kind==="enum"?e.scalar:e.kind}function O(e,n){let s=new Set,r=e;for(;r.kind==="ref";){let{name:a}=r;if(s.has(a))return;s.add(a);let o=n.schemas.find(c=>c.name===a);if(o===void 0)return;r=o.schema}return r}function b(e,n){return e.kind==="scalar"||e.kind==="enum"?e.scalar==="string":e.kind==="literal"?typeof e.value=="string":e.kind==="union"?e.members.every(s=>{let r=O(s,n);return r!==void 0&&(r.kind==="null"||r.kind!=="union"&&b(r,n))}):!1}var G={"types.ts":`/**
|
|
10
10
|
* The public type surface of the client runtime \u2014 \`@redocly/client-generator\`'s
|
|
11
11
|
* app-facing runtime module. Pure types, no runtime code (excluded from coverage).
|
|
12
12
|
* The generator emits \`OPERATIONS\` literals typed
|
|
@@ -816,7 +816,8 @@ export function middlewareChain(config: ClientConfig): Middleware[] {
|
|
|
816
816
|
/**
|
|
817
817
|
* The fetch core shared by every operation: default + config + per-call headers, the
|
|
818
818
|
* \`onRequest\` chain (BEFORE body serialization, so mutations are sent), body
|
|
819
|
-
* serialization (JSON, or FormData via the multipart capability
|
|
819
|
+
* serialization (JSON, or FormData via the multipart capability; a stream passes
|
|
820
|
+
* through in one attempt), the retry loop
|
|
820
821
|
* (idempotent-only defaults, \`Retry-After\`, abandoned-body drain), and the reverse
|
|
821
822
|
* \`onResponse\` onion. Returns the final response plus the request context.
|
|
822
823
|
*/
|
|
@@ -878,6 +879,7 @@ export async function send(
|
|
|
878
879
|
for (const mw of middleware) if (mw.onRequest) await mw.onRequest(context);
|
|
879
880
|
// Serialize AFTER onRequest so body mutations (case conversion, enveloping, signing) take effect.
|
|
880
881
|
let payload: BodyInit | undefined;
|
|
882
|
+
let isStream = false;
|
|
881
883
|
if (context.body !== undefined) {
|
|
882
884
|
const value = context.body;
|
|
883
885
|
const isBinary =
|
|
@@ -886,8 +888,26 @@ export async function send(
|
|
|
886
888
|
ArrayBuffer.isView(value as ArrayBufferView);
|
|
887
889
|
const isFormData = typeof FormData !== 'undefined' && value instanceof FormData;
|
|
888
890
|
const isURLSearchParams = value instanceof URLSearchParams;
|
|
889
|
-
|
|
891
|
+
isStream =
|
|
892
|
+
(typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||
|
|
893
|
+
(value !== null &&
|
|
894
|
+
typeof (value as Partial<AsyncIterable<unknown>>)[Symbol.asyncIterator] === 'function');
|
|
895
|
+
const hasContentType = 'Content-Type' in context.headers || 'content-type' in context.headers;
|
|
896
|
+
if (isFormData || isURLSearchParams || isBinary || isStream || typeof value === 'string') {
|
|
890
897
|
payload = value as BodyInit;
|
|
898
|
+
// \`fetch\` derives the type of FormData and URLSearchParams, boundary included, and a
|
|
899
|
+
// multipart boundary is only the caller's to set. Any other pass-through body gets
|
|
900
|
+
// the declared type when the caller set none.
|
|
901
|
+
const declared = bodySpec?.contentType;
|
|
902
|
+
if (
|
|
903
|
+
!isFormData &&
|
|
904
|
+
!isURLSearchParams &&
|
|
905
|
+
!hasContentType &&
|
|
906
|
+
declared !== undefined &&
|
|
907
|
+
!declared.toLowerCase().includes('multipart')
|
|
908
|
+
) {
|
|
909
|
+
context.headers['Content-Type'] = declared;
|
|
910
|
+
}
|
|
891
911
|
} else if (bodySpec?.multipart === true) {
|
|
892
912
|
if (!caps.serializeMultipart) {
|
|
893
913
|
throw new Error('Multipart capability not wired: cannot serialize the request body');
|
|
@@ -895,14 +915,15 @@ export async function send(
|
|
|
895
915
|
payload = caps.serializeMultipart(value as Record<string, unknown>);
|
|
896
916
|
} else {
|
|
897
917
|
payload = JSON.stringify(value);
|
|
898
|
-
if (!
|
|
918
|
+
if (!hasContentType) {
|
|
899
919
|
// The spec's declared request content type (e.g. application/merge-patch+json).
|
|
900
920
|
context.headers['Content-Type'] = bodySpec?.contentType ?? 'application/json';
|
|
901
921
|
}
|
|
902
922
|
}
|
|
903
923
|
}
|
|
904
924
|
const doFetch = config.fetch ?? fetch;
|
|
905
|
-
|
|
925
|
+
// A stream is consumed by the first attempt and cannot be replayed, so it never retries.
|
|
926
|
+
const maxAttempts = isStream ? 1 : 1 + (retry.retries ?? 0);
|
|
906
927
|
const retryOn = retry.retryOn ?? defaultRetryOn;
|
|
907
928
|
const signal = fetchInit.signal ?? undefined;
|
|
908
929
|
|
|
@@ -921,6 +942,8 @@ export async function send(
|
|
|
921
942
|
try {
|
|
922
943
|
response = await doFetch(context.url, {
|
|
923
944
|
...fetchInit,
|
|
945
|
+
// \`fetch\` requires it for a stream body.
|
|
946
|
+
...(isStream ? { duplex: 'half' } : {}),
|
|
924
947
|
signal: attemptSignal,
|
|
925
948
|
method: context.method,
|
|
926
949
|
headers: context.headers,
|
|
@@ -3515,7 +3538,8 @@ function middlewareChain(config: ClientConfig): Middleware[] {
|
|
|
3515
3538
|
/**
|
|
3516
3539
|
* The fetch core shared by every operation: default + config + per-call headers, the
|
|
3517
3540
|
* \`onRequest\` chain (BEFORE body serialization, so mutations are sent), body
|
|
3518
|
-
* serialization (JSON, or FormData via the multipart capability
|
|
3541
|
+
* serialization (JSON, or FormData via the multipart capability; a stream passes
|
|
3542
|
+
* through in one attempt), the retry loop
|
|
3519
3543
|
* (idempotent-only defaults, \`Retry-After\`, abandoned-body drain), and the reverse
|
|
3520
3544
|
* \`onResponse\` onion. Returns the final response plus the request context.
|
|
3521
3545
|
*/
|
|
@@ -3577,6 +3601,7 @@ async function send(
|
|
|
3577
3601
|
for (const mw of middleware) if (mw.onRequest) await mw.onRequest(context);
|
|
3578
3602
|
// Serialize AFTER onRequest so body mutations (case conversion, enveloping, signing) take effect.
|
|
3579
3603
|
let payload: BodyInit | undefined;
|
|
3604
|
+
let isStream = false;
|
|
3580
3605
|
if (context.body !== undefined) {
|
|
3581
3606
|
const value = context.body;
|
|
3582
3607
|
const isBinary =
|
|
@@ -3585,8 +3610,26 @@ async function send(
|
|
|
3585
3610
|
ArrayBuffer.isView(value as ArrayBufferView);
|
|
3586
3611
|
const isFormData = typeof FormData !== 'undefined' && value instanceof FormData;
|
|
3587
3612
|
const isURLSearchParams = value instanceof URLSearchParams;
|
|
3588
|
-
|
|
3613
|
+
isStream =
|
|
3614
|
+
(typeof ReadableStream !== 'undefined' && value instanceof ReadableStream) ||
|
|
3615
|
+
(value !== null &&
|
|
3616
|
+
typeof (value as Partial<AsyncIterable<unknown>>)[Symbol.asyncIterator] === 'function');
|
|
3617
|
+
const hasContentType = 'Content-Type' in context.headers || 'content-type' in context.headers;
|
|
3618
|
+
if (isFormData || isURLSearchParams || isBinary || isStream || typeof value === 'string') {
|
|
3589
3619
|
payload = value as BodyInit;
|
|
3620
|
+
// \`fetch\` derives the type of FormData and URLSearchParams, boundary included, and a
|
|
3621
|
+
// multipart boundary is only the caller's to set. Any other pass-through body gets
|
|
3622
|
+
// the declared type when the caller set none.
|
|
3623
|
+
const declared = bodySpec?.contentType;
|
|
3624
|
+
if (
|
|
3625
|
+
!isFormData &&
|
|
3626
|
+
!isURLSearchParams &&
|
|
3627
|
+
!hasContentType &&
|
|
3628
|
+
declared !== undefined &&
|
|
3629
|
+
!declared.toLowerCase().includes('multipart')
|
|
3630
|
+
) {
|
|
3631
|
+
context.headers['Content-Type'] = declared;
|
|
3632
|
+
}
|
|
3590
3633
|
} else if (bodySpec?.multipart === true) {
|
|
3591
3634
|
if (!caps.serializeMultipart) {
|
|
3592
3635
|
throw new Error('Multipart capability not wired: cannot serialize the request body');
|
|
@@ -3594,14 +3637,15 @@ async function send(
|
|
|
3594
3637
|
payload = caps.serializeMultipart(value as Record<string, unknown>);
|
|
3595
3638
|
} else {
|
|
3596
3639
|
payload = JSON.stringify(value);
|
|
3597
|
-
if (!
|
|
3640
|
+
if (!hasContentType) {
|
|
3598
3641
|
// The spec's declared request content type (e.g. application/merge-patch+json).
|
|
3599
3642
|
context.headers['Content-Type'] = bodySpec?.contentType ?? 'application/json';
|
|
3600
3643
|
}
|
|
3601
3644
|
}
|
|
3602
3645
|
}
|
|
3603
3646
|
const doFetch = config.fetch ?? fetch;
|
|
3604
|
-
|
|
3647
|
+
// A stream is consumed by the first attempt and cannot be replayed, so it never retries.
|
|
3648
|
+
const maxAttempts = isStream ? 1 : 1 + (retry.retries ?? 0);
|
|
3605
3649
|
const retryOn = retry.retryOn ?? defaultRetryOn;
|
|
3606
3650
|
const signal = fetchInit.signal ?? undefined;
|
|
3607
3651
|
|
|
@@ -3620,6 +3664,8 @@ async function send(
|
|
|
3620
3664
|
try {
|
|
3621
3665
|
response = await doFetch(context.url, {
|
|
3622
3666
|
...fetchInit,
|
|
3667
|
+
// \`fetch\` requires it for a stream body.
|
|
3668
|
+
...(isStream ? { duplex: 'half' } : {}),
|
|
3623
3669
|
signal: attemptSignal,
|
|
3624
3670
|
method: context.method,
|
|
3625
3671
|
headers: context.headers,
|
|
@@ -5397,4 +5443,4 @@ async function runSingle(
|
|
|
5397
5443
|
}
|
|
5398
5444
|
return fail(1, detail);
|
|
5399
5445
|
}
|
|
5400
|
-
}`},S=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var j=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],$=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],N=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],w;function Q(){return w===void 0&&(w=new Set([...j,...$,...N,...S])),w}var A={name:"@redocly/client-generator",version:"0.
|
|
5446
|
+
}`},S=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var j=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],$=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],N=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","Symbol","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],w;function Q(){return w===void 0&&(w=new Set([...j,...$,...N,...S])),w}var A={name:"@redocly/client-generator",version:"0.5.0",description:"Generate typed, zero-dependency TypeScript clients (fetch, auth, retries, middleware, SSE) from OpenAPI descriptions.",type:"module",types:"lib/index.d.ts",sideEffects:!1,exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./generate":{types:"./lib/generate.d.ts",import:"./lib/generate.js",default:"./lib/generate.js"},"./printers/python":{types:"./lib/printers/python.d.ts",import:"./lib/printers/python.js",default:"./lib/printers/python.js"},"./printers/go":{types:"./lib/printers/go.d.ts",import:"./lib/printers/go.js",default:"./lib/printers/go.js"},"./printers/php":{types:"./lib/printers/php.d.ts",import:"./lib/printers/php.js",default:"./lib/printers/php.js"},"./printers/typescript":{types:"./lib/printers/typescript.d.ts",import:"./lib/printers/typescript.js",default:"./lib/printers/typescript.js"},"./printers":{types:"./lib/printers/index.d.ts",import:"./lib/printers/index.js",default:"./lib/printers/index.js"},"./contracts/typescript":{types:"./lib/contracts/typescript.d.ts",import:"./lib/contracts/typescript.js",default:"./lib/contracts/typescript.js"},"./runtime-sources":{types:"./lib/runtime-sources.d.ts",import:"./lib/runtime-sources.js",default:"./lib/runtime-sources.js"},"./package.json":"./package.json"},engines:{node:">=22.12.0 || >=20.19.0 <21.0.0",npm:">=10"},engineStrict:!0,scripts:{"examples:regen":"node scripts/regenerate-examples.mjs",prepare:"node scripts/generate-runtime-sources.mjs && node scripts/generate-eject-assets.mjs","typecheck:examples":"node scripts/typecheck-examples.mjs"},license:"MIT",repository:{type:"git",url:"git+https://github.com/Redocly/redocly-cli.git"},homepage:"https://github.com/Redocly/redocly-cli",keywords:["OpenAPI","Swagger","TypeScript","client","generator","codegen","fetch"],contributors:["Roman Marshevskyi <roman.marshevskyy@redocly.com> (https://redocly.com/)"],dependencies:{"@redocly/openapi-core":"2.61.0"},peerDependencies:{typescript:">=5.5.0"},peerDependenciesMeta:{typescript:{optional:!0}},devDependencies:{typescript:"6.0.2"},files:["lib","eject-assets"]};var ee=A.version;function T(e){let n=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());return n===null?void 0:[Number(n[1]),Number(n[2]),Number(n[3])]}function v(e,n){return e[0]-n[0]||e[1]-n[1]||e[2]-n[2]}function ne(e,n){let s=/^[\^~]|^>=/.exec(n.trim())?.[0]??"",r=T(n.trim().slice(s.length)),a=T(e);if(!(r===void 0||a===void 0))return v(a,r)<0?!1:s===">="?!0:s===""?v(a,r)===0:s==="~"?a[0]===r[0]&&a[1]===r[1]:r[0]!==0?a[0]===r[0]:r[1]!==0?a[0]===0&&a[1]===r[1]:v(a,r)===0}export{C as a,H as b,G as c,W as d,j as e,Q as f,ee as g,ne as h};
|
|
@@ -0,0 +1,20 @@
|
|
|
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 U}from"./XJE2OFDN.js";import{b as R,c as F,d as G,e as L,f as V,g as ae,h as z,i as ie,j as ce}from"./ERFYZ47T.js";import{a as ne,c as T,d as N,e as D,g as Y,h as B,i as te,j as se,k as oe,l as K,n as re}from"./UW4UC7ZI.js";var M=T.python,j=class extends ne{constructor(){super(" ")}typeName(n){return N(n,{style:"pascal",reserved:M})}memberName(n){let t=N(n,{style:"snake",reserved:M});return{identifier:t,renamed:t!==n}}identifier(n){return N(n,{style:"snake",reserved:M})}identifiers(n,t){return D(n,{style:"snake",reserved:M,taken:t})}constName(n){return N(n,{style:"screaming",reserved:M})}string(n){let t='"';for(let s of n){let r=s.codePointAt(0);s==="\\"?t+="\\\\":s==='"'?t+='\\"':s===`
|
|
8
|
+
`?t+="\\n":s==="\r"?t+="\\r":s===" "?t+="\\t":r<32||r===127?t+=`\\x${r.toString(16).padStart(2,"0")}`:r>=55296&&r<=57343?t+=`\\u${r.toString(16).padStart(4,"0")}`:t+=s}return t+'"'}literal(n){return n==null?"None":n===!0?"True":n===!1?"False":typeof n=="number"?String(n):typeof n=="string"?this.string(n):Array.isArray(n)?`[${n.map(s=>this.literal(s)).join(", ")}]`:`{${Object.entries(n).map(([s,r])=>`${this.string(s)}: ${this.literal(r)}`).join(", ")}}`}comment(n){for(let t of K(n))this.line(t===""?"#":`# ${t}`);return this}doc(n){let t=K(n);if(t.length===0)return this;if(t.length===1)return this.line(`"""${t[0]}"""`);this.line(`"""${t[0]}`);for(let s of t.slice(1))this.line(s);return this.line('"""')}};var S=T.python,f=new j;function O(e){return f.typeName(e)}function q(e){let{identifier:n,renamed:t}=f.memberName(e);return{python:n,renamed:t}}function I(e){let n=e.services.flatMap(s=>s.operations),t=D(n.map(s=>s.name),{style:"snake",reserved:S});return n.map((s,r)=>({op:s,ident:t[r]}))}var W=["self","body","headers","timeout","retry","idempotency_key"];function le(e){return f.literal(e)}function de(e){if(e!==void 0)return{style:e.style,...e.param!==void 0?{param:e.param}:{},...e.nextCursor!==void 0?{next_cursor:e.nextCursor}:{},...e.hasMore!==void 0?{has_more:e.hasMore}:{},...e.limitParam!==void 0?{limit_param:e.limitParam}:{},...e.items!==void 0?{items:e.items}:{}}}function pe(e,n){let t=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let a=N(r.name,{style:"snake",reserved:S}),c=a,i=2;for(;t.has(c);)c=`${a}_${i++}`;t.add(c);let m=re(r.schema,n);return`(${f.string(r.name)}, ${f.string(c)}, ${f.string(m)})`}).join(", ")}]`}function h(e,n="string"){if(te(e))return`Optional[${h(se(e),n)}]`;switch(e.kind){case"scalar":if(n==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"datetime";if(e.metadata?.format==="date")return"date"}return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":return`List[${h(e.items,n)}]`;case"record":return`Dict[str, ${h(e.value,n)}]`;case"ref":return O(e.name);case"literal":return`Literal[${f.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(t=>h(t,n)).join(", ")}]`;case"null":return"None";case"omit":return O(e.base);case"object":case"intersection":case"unknown":return"Any"}}function J(e,n,t,s,r,a,c,i=!1){let m=D([...n.pathParams,...n.queryParams].map(x=>x.name),{style:"snake",reserved:S,taken:W}),l=n.pathParams.map((x,v)=>({param:x,python:m[v]})),o=n.queryParams.map((x,v)=>({param:x,python:m[n.pathParams.length+v]})),d=l.map(({param:x,python:v})=>`${v}: ${h(x.schema,a)}`),u=L(n)||n.requestBody!==void 0&&V(n.requestBody.contentType),y=n.requestBody?[`body: ${u?"Any":h(n.requestBody.schema,a)}`]:[],b=[...o.map(({param:x,python:v})=>{let A=h(x.schema,a),E=A.startsWith("Optional[")?A:`Optional[${A}]`;return`${v}: ${E} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],$=R(n),k=F(n),P=i?`Envelope[${$===void 0?"None":h($,a)}]`:k!==void 0?`${r?"AsyncIterator":"Iterator"}[ServerSentEvent]`:s==="result"?"Result":$===void 0?"None":h($,a),p=r&&k===void 0?"async def":"def",_=r?"await ":"",g=r?"send_async":"send",w=["self",...d,...y,"*",...b].join(", "),H=i?`${t}_with_headers`:t;e.block(`${p} ${H}(${w}) -> ${P}:`,()=>{e.doc(i?`Like ${t}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${t}"]`),e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)'),e.line("params: Dict[str, Any] = dict(auth_query)");for(let{param:E,python:C}of o)e.block(`if ${C} is not None:`,()=>{e.line(`params[${f.string(E.name)}] = encode(${C})`)});let x=l.map(({param:E,python:C})=>`${f.string(E.name)}: ${C}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${x}})`),k!==void 0){let E=k.schema!==void 0&&k.schema.kind!=="unknown"?"json":"text";e.block("def _open(extra_headers: Dict[str, str]):",()=>{e.line('return self._http.stream(op["method"], url, headers={**auth_headers, **(headers or {}), **extra_headers}, params=params, timeout=timeout)')}),e.line(`return ${r?"aiter_sse":"iter_sse"}(_open, data_kind="${E}")`);return}G(n)&&!L(n)&&e.line("form_data, form_files = to_multipart(body)");let v=n.requestBody?L(n)?", **multipart_arguments(body)":G(n)?", data=form_data, files=form_files":V(n.requestBody.contentType)?`, content=body, content_type=${f.string(n.requestBody.contentType)}`:", json_body=encode(body)":"";e.line(`response = ${_}${g}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params=params${v}, timeout=timeout, retry=retry, idempotency_key=idempotency_key)`);let A=$===void 0?"None":`decode(${h($,a)}, _safe_json(response))`;i?(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(`return Envelope(data=${A}, headers=read_envelope_headers(response, ${pe(n,c)}), response=response)`)):s==="result"?(e.block("if not response.is_success:",()=>{e.line("return Result(data=None, error=_safe_json(response), response=response)")}),e.line(`return Result(data=${A}, error=None, response=response)`)):(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line($===void 0?"return None":`return ${A}`))}),e.blank()}function me(e,n,t,s,r,a){let c=R(n),i=c===void 0?"Any":h(c,a),m=D([...n.pathParams,...n.queryParams].map(p=>p.name),{style:"snake",reserved:S,taken:W}),l=n.pathParams.map((p,_)=>({param:p,python:m[_]})),o=n.queryParams.map((p,_)=>({param:p,python:m[n.pathParams.length+_]})),d=l.map(({param:p,python:_})=>`${_}: ${h(p.schema,a)}`),u=[...o.map(({param:p,python:_})=>{let g=h(p.schema,a),w=g.startsWith("Optional[")?g:`Optional[${g}]`;return`${_}: ${w} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],y=["self",...d,"*",...u].join(", "),b=s?"AsyncIterator":"Iterator",$=s?"aiter_pages":"iter_pages",k=s?"aiter_items":"iter_items",P=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:g,python:w}of o)e.block(`if ${w} is not None:`,()=>{e.line(`base[${f.string(g.name)}] = encode(${w})`)});let p=s?"async def":"def",_=s?"await ":"";e.block(`${p} _page(page_params: Dict[str, Any]) -> Tuple[Any, Any]:`,()=>{e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)');let g=l.map(({param:w,python:H})=>`${f.string(w.name)}: ${H}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${g}})`),e.line(`response = ${_}${s?"send_async":"send"}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params={**page_params, **auth_query}, timeout=timeout, retry=retry)`),e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line("return _safe_json(response), response")})};s?(e.block(`async def ${t}_pages(${y}) -> ${b}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for page in ${$}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${t}_items(${y}) -> ${b}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for item in ${k}(_page, op["pagination"], base):`,()=>{e.line(r==="Any"?"yield item":`yield decode(${r}, item)`)})})):(e.block(`def ${t}_pages(${y}) -> ${b}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(i==="Any"?`return ${$}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${$}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${t}_items(${y}) -> ${b}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(r==="Any"?`return ${k}(_page, op["pagination"], base)`:`return (decode(${r}, item) for item in ${k}(_page, op["pagination"], base))`)})),e.blank()}function he(e){return ae(e).map(t=>t.kind==="literal"?f.string(t.value):q(t.name).python).join(" + ")}function fe(e,n){let t=n.servers??[];if(t.length===0)return;let s=new Set;e.block("class Servers:",()=>{e.line('"""The declared servers; variables default to the values from the description."""'),e.blank(),t.forEach((r,a)=>{let c=N(r.description??`server${a+1}`,{style:"snake",reserved:S});s.has(c)&&(c=`${c}_${a+1}`),s.add(c);let i=r.variables.map(m=>`${q(m.name).python}: str = ${f.string(m.default)}`);a>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${c}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${he(r)}`)})})}),e.blank()}function Q(e,n,t,s,r,a,c){let i=s?"AsyncClient":"Client",m=s?"httpx.AsyncClient":"httpx.Client";e.block(`class ${i}:`,()=>{e.doc(`${s?"Async ":""}client for ${n.title} (${n.version}).`),e.block(`def __init__(self, server_url: str = ${f.string(a)}, *, auth: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, timeout: Optional[float] = None, retry: Optional[Dict[str, Any]] = None, middleware: Optional[List[Any]] = None, idempotency_key: Any = None, http_client: Optional[${m}] = None) -> None:`,()=>{e.line("self._server_url = server_url"),e.line("self._auth = auth or {}"),e.line("self._config: Dict[str, Any] = {"),e.indent(()=>{e.line('"headers": headers or {},'),e.line('"timeout": timeout,'),e.line('"retry": retry or {},'),e.line('"middleware": middleware or [],'),e.line('"idempotency_key": idempotency_key,')}),e.line("}"),e.line(`self._http = http_client or ${m}()`)}),e.blank();for(let{op:l,ident:o}of I(n)){J(e,l,o,t,s,c),F(l)===void 0&&(l.successResponseHeaders?.length??0)>0&&J(e,l,o,t,s,c,n,!0);let d=r.get(o);if(d!==void 0){let u=R(l),y=ie(u,typeof d.items=="string"?d.items:void 0,n);me(e,l,o,s,y===void 0?"Any":h(y,c),c)}}}),e.blank()}function X(e){let n=new Map,t=new Set,s=[];for(let{name:a,schema:c}of e.schemas){let i=B(c,e);if(!(i===void 0||!i.cases.every(l=>Y(l.schema,e)?.properties.some(o=>o.name===i.property)===!0))){for(let l of i.cases){let o=n.get(l.schemaName);if(o!==void 0&&o.value!==l.value){t.add(l.schemaName);continue}n.set(l.schemaName,{property:i.property,value:l.value})}s.push({name:a,property:i.property,members:i.cases.map(l=>l.schemaName)})}}let r=new Map;for(let a of s)a.members.some(c=>t.has(c))||r.set(a.name,q(a.property).python);for(let a of t)n.delete(a);return{pins:n,unions:r}}function ye(e,n,t,s,r,a,c){let i=r==="pydantic";i||e.line("@dataclass");let m=i?`class ${O(n)}(BaseModel):`:`class ${O(n)}:`;e.block(m,()=>{e.doc(a),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let l=[...t.filter(d=>d.required),...t.filter(d=>!d.required)],o=[];l.length===0&&e.line("pass");for(let d of l){let{python:u,renamed:y}=q(d.name);y&&!i&&o.push([u,d.name]);let b=y&&i?`alias=${f.string(d.name)}`:void 0,$=c?.property===d.name?`Literal[${f.literal(c.value)}]`:h(d.schema,s);if(d.required){let k=b===void 0?"":` = Field(${b})`;e.line(`${u}: ${$}${k}`)}else{let k=$.startsWith("Optional[")?$:`Optional[${$}]`,P=b===void 0?"None":`Field(default=None, ${b})`;e.line(`${u}: ${k} = ${P}`)}}if(o.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let d=o.map(([u,y])=>`"${u}": ${f.string(y)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${d}}`)}}),e.blank(),e.blank()}function Z(e,n="string",t="dataclass"){let s=new j,{pins:r,unions:a}=t==="pydantic"?X(e):{pins:new Map,unions:new Map};s.line("from __future__ import annotations"),s.blank(),t==="dataclass"&&s.line("from dataclasses import dataclass"),s.line("from enum import Enum");let c=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];t==="dataclass"&&c.splice(2,0,"ClassVar"),a.size>0&&c.unshift("Annotated"),s.line(`from typing import ${c.join(", ")}`),t==="pydantic"&&s.line("from pydantic import BaseModel, ConfigDict, Field"),n==="Date"&&s.line("from datetime import date, datetime"),s.blank(),s.blank();let i=[];for(let{name:m,schema:l}of e.schemas){let o=oe(l);if(o!==void 0){let d=o.scalar==="string"?"str, Enum":"int, Enum";s.block(`class ${O(m)}(${d}):`,()=>{s.doc(l.description),o.values.forEach((u,y)=>{s.line(`${o.memberNames[y]} = ${f.literal(u)}`)})}),s.blank(),s.blank();continue}if(l.kind==="object"||l.kind==="intersection"){let d=Y(l,e);if(d!==void 0){ye(s,m,d.properties,n,t,d.description??l.description,r.get(m));continue}}i.push(()=>{let d=B(l,e);if(d!==void 0){let b=d.cases.map($=>`${$.value} -> ${O($.schemaName)}`).join(", ");s.line(`# Discriminated by "${d.property}": ${b}`)}let u=a.get(m),y=u===void 0?h(l,n):`Annotated[${h(l,n)}, Field(discriminator=${f.string(u)})]`;s.line(`${O(m)} = ${y}`),s.blank()})}for(let m of i)m();return s.toString()}function ue(e,n){let t=[];for(let{name:s,schema:r}of e.schemas){if(n.has(s))continue;let a=B(r,e);if(a===void 0)continue;let c=a.cases.map(i=>`${f.string(i.value)}: ${O(i.schemaName)}`).join(", ");t.push(`DISCRIMINATORS[${O(s)}] = (${f.string(a.property)}, {${c}})`)}return t}var on={type:"object",properties:{models:{enum:["dataclass","pydantic"],default:"dataclass",description:"Model style: standard-library dataclasses (default, httpx is the only dependency), or pydantic BaseModel classes (adds pydantic)."}},additionalProperties:!1};function ee(e){let n=e.lastIndexOf("/")>=0?"/":"\\",t=e.lastIndexOf(n),s=t>=0?e.slice(0,t+1):"",r=(t>=0?e.slice(t+1):e).replace(/\.[^.]+$/,"");return`${s}${N(r,{style:"snake",reserved:S})}.py`}var rn=({model:e,output:n,banner:t,emit:s,options:r,pagination:a})=>{let c=s.errorMode??"throw",i=s.dateType??"string",m=r?.models??"dataclass",l=m==="pydantic"?X(e):void 0,o=new j;if(o.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),o.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),o.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),o.blank(),o.line(Z(e,i,m).trimEnd()),o.blank(),o.blank(),fe(o,e),s.runtime==="module"){o.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let p of Object.keys(U))o.line(`from ${p.replace(/\.py$/,"")} import *`);o.blank(),o.blank()}else{o.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let p of Object.values(U)){let _=p.split(`
|
|
9
|
+
`).filter(g=>!g.startsWith("from __future__")&&!g.startsWith("from ._")).join(`
|
|
10
|
+
`).trim();o.line(_),o.blank()}o.blank()}let d=ue(e,new Set(l?.unions.keys()));if(d.length>0){o.line("# Discriminated unions dispatch by their property inside decode().");for(let p of d)o.line(p);o.blank()}o.block("def _safe_json(response: httpx.Response) -> Any:",()=>{o.block("try:",()=>{o.line("return response.json()")}),o.block("except Exception:",()=>{o.line("return None")})}),o.blank();let u=new Map;for(let{op:p,ident:_}of I(e))u.set(_,de(a?.get(p.name)?.spec));o.line("_OPERATIONS = {"),o.indent(()=>{for(let{op:p,ident:_}of I(e)){let g={id:p.specName??p.name,method:p.method.toUpperCase(),path:p.path,...z(p,e).length>0?{security:z(p,e)}:{},...u.get(_)!==void 0?{pagination:u.get(_)}:{}};o.line(`"${_}": ${le(g)},`)}}),o.line("}"),o.blank(),o.blank();let y=s.serverUrl??e.serverUrl??"";Q(o,e,c,!1,u,y,i),Q(o,e,c,!0,u,y,i);let b={path:ee(n.path),content:o.toString()};if(s.runtime!=="module")return[b];let $=t.map(p=>`# ${p}`).join(`
|
|
11
|
+
`),k=ee(n.path).replace(/[^\\/]+$/,""),P=Object.entries(U).map(([p,_])=>({path:`${k}${p}`,content:`${$}
|
|
12
|
+
|
|
13
|
+
${_.split(`
|
|
14
|
+
`).map(g=>g.startsWith("from ._")?g.replace("from ._","from _"):g).join(`
|
|
15
|
+
`).trim()}
|
|
16
|
+
`}));return[b,...P]};function $e(e,n){let t=ee(n.outputPath).replace(/^.*[\\/]/,"").replace(/\.py$/,""),s=I(n.model).find(a=>a.op.name===e.name)?.ident??N(e.name,{style:"snake",reserved:S}),r=[...e.pathParams.map(a=>{let c=N(a.name,{style:"snake",reserved:S});return`${c}="<${c}>"`}),...e.queryParams.filter(a=>a.required).map(a=>`${N(a.name,{style:"snake",reserved:S})}=...`),...e.requestBody?["body=..."]:[]];return{lang:"python",label:"Python SDK",source:`from ${t} import Client
|
|
17
|
+
|
|
18
|
+
client = Client()
|
|
19
|
+
result = client.${s}(${r.join(", ")})
|
|
20
|
+
`}}var an=({model:e,output:n,emit:t,pagination:s})=>[{path:n.path.replace(/\.[^.\\/]+$/,".python.md"),content:ce(e,{title:`${e.title} Python SDK reference`,frontmatter:t.docsFrontmatter===!0,language:{name:"python",label:"Python",fence:"python",requires:"The SDK needs `httpx`."},sample:r=>$e(r,{model:e,emit:t,outputPath:n.path}),paginated:new Set(s?.keys()??[])})}];export{h as a,Z as b,on as c,rn as d,$e as e,an as f};
|
|
@@ -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{c as O,d as se,f as oe}from"./
|
|
7
|
+
import{c as O,d as se,f as oe}from"./FDMXHRDK.js";import"./UF2ZCH7W.js";import{a as Re,b as U,c as ne}from"./GHSNC2OX.js";import{a as re}from"./LRUXN6H5.js";import{$ as F,V as Y,aa as S,ba as ee,c as Q,ca as I,ga as w,ia as k,oa as te}from"./22EANOP2.js";import"./NEWT5A6S.js";import{c as X,e as R}from"./RFWIIJFG.js";var ye=X(V=>{"use strict";V.parse=ze;V.serialize=Fe;var _e=Object.prototype.toString,$e=Object.prototype.hasOwnProperty,Oe=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,We=/^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/,Be=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,De=/^[\u0020-\u003A\u003D-\u007E]*$/;function ze(e,r){if(typeof e!="string")throw new TypeError("argument str must be a string");var t={},s=e.length;if(s<2)return t;var n=r&&r.decode||Ie,o=0,i=0,a=0;do{if(i=e.indexOf("=",o),i===-1)break;if(a=e.indexOf(";",o),a===-1)a=s;else if(i>a){o=e.lastIndexOf(";",i-1)+1;continue}var c=de(e,o,i),f=he(e,i,c),p=e.slice(c,f);if(!$e.call(t,p)){var u=de(e,i+1,a),m=he(e,a,u);e.charCodeAt(u)===34&&e.charCodeAt(m-1)===34&&(u++,m--);var l=e.slice(u,m);t[p]=Ne(l,n)}o=a+1}while(o<s);return t}function de(e,r,t){do{var s=e.charCodeAt(r);if(s!==32&&s!==9)return r}while(++r<t);return t}function he(e,r,t){for(;r>t;){var s=e.charCodeAt(--r);if(s!==32&&s!==9)return r+1}return t}function Fe(e,r,t){var s=t&&t.encode||encodeURIComponent;if(typeof s!="function")throw new TypeError("option encode is invalid");if(!Oe.test(e))throw new TypeError("argument name is invalid");var n=s(r);if(!We.test(n))throw new TypeError("argument val is invalid");var o=e+"="+n;if(!t)return o;if(t.maxAge!=null){var i=Math.floor(t.maxAge);if(!isFinite(i))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+i}if(t.domain){if(!Be.test(t.domain))throw new TypeError("option domain is invalid");o+="; Domain="+t.domain}if(t.path){if(!De.test(t.path))throw new TypeError("option path is invalid");o+="; Path="+t.path}if(t.expires){var a=t.expires;if(!Ue(a)||isNaN(a.valueOf()))throw new TypeError("option expires is invalid");o+="; Expires="+a.toUTCString()}if(t.httpOnly&&(o+="; HttpOnly"),t.secure&&(o+="; Secure"),t.partitioned&&(o+="; Partitioned"),t.priority){var c=typeof t.priority=="string"?t.priority.toLowerCase():t.priority;switch(c){case"low":o+="; Priority=Low";break;case"medium":o+="; Priority=Medium";break;case"high":o+="; Priority=High";break;default:throw new TypeError("option priority is invalid")}}if(t.sameSite){var f=typeof t.sameSite=="string"?t.sameSite.toLowerCase():t.sameSite;switch(f){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}function Ie(e){return e.indexOf("%")!==-1?decodeURIComponent(e):e}function Ue(e){return _e.call(e)==="[object Date]"}function Ne(e,r){try{return r(e)}catch{return e}}});var be=X((gt,P)=>{"use strict";var W={decodeValues:!0,map:!1,silent:!1};function H(e){return typeof e=="string"&&!!e.trim()}function J(e,r){var t=e.split(";").filter(H),s=t.shift(),n=qe(s),o=n.name,i=n.value;r=r?Object.assign({},W,r):W;try{i=r.decodeValues?decodeURIComponent(i):i}catch(c){console.error("set-cookie-parser encountered an error while decoding a cookie with value '"+i+"'. Set options.decodeValues to false to disable this feature.",c)}var a={name:o,value:i};return t.forEach(function(c){var f=c.split("="),p=f.shift().trimLeft().toLowerCase(),u=f.join("=");p==="expires"?a.expires=new Date(u):p==="max-age"?a.maxAge=parseInt(u,10):p==="secure"?a.secure=!0:p==="httponly"?a.httpOnly=!0:p==="samesite"?a.sameSite=u:p==="partitioned"?a.partitioned=!0:a[p]=u}),a}function qe(e){var r="",t="",s=e.split("=");return s.length>1?(r=s.shift(),t=s.join("=")):t=e,{name:r,value:t}}function xe(e,r){if(r=r?Object.assign({},W,r):W,!e)return r.map?{}:[];if(e.headers)if(typeof e.headers.getSetCookie=="function")e=e.headers.getSetCookie();else if(e.headers["set-cookie"])e=e.headers["set-cookie"];else{var t=e.headers[Object.keys(e.headers).find(function(n){return n.toLowerCase()==="set-cookie"})];!t&&e.headers.cookie&&!r.silent&&console.warn("Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."),e=t}if(Array.isArray(e)||(e=[e]),r.map){var s={};return e.filter(H).reduce(function(n,o){var i=J(o,r);return n[i.name]=i,n},s)}else return e.filter(H).map(function(n){return J(n,r)})}function Ve(e){if(Array.isArray(e))return e;if(typeof e!="string")return[];var r=[],t=0,s,n,o,i,a;function c(){for(;t<e.length&&/\s/.test(e.charAt(t));)t+=1;return t<e.length}function f(){return n=e.charAt(t),n!=="="&&n!==";"&&n!==","}for(;t<e.length;){for(s=t,a=!1;c();)if(n=e.charAt(t),n===","){for(o=t,t+=1,c(),i=t;t<e.length&&f();)t+=1;t<e.length&&e.charAt(t)==="="?(a=!0,t=i,r.push(e.substring(s,o)),s=t):t=o+1}else t+=1;(!a||t>=e.length)&&r.push(e.substring(s,e.length))}return r}P.exports=xe;P.exports.parse=xe;P.exports.parseString=J;P.exports.splitCookiesString=Ve});import{existsSync as Qe,readFileSync as Ye,writeFileSync as Ae}from"node:fs";import{dirname as et,basename as tt}from"node:path";function N(e,r){return JSON.stringify(e,(s,n)=>{if(n instanceof ArrayBuffer){if(n.byteLength>1048576)return{__type:"ArrayBuffer",data:`File too large to serialize (${n.byteLength} bytes). Maximum allowed size is 1048576 bytes.`,byteLength:n.byteLength};let o=new Uint8Array(n);return{__type:"ArrayBuffer",data:Buffer.from(o).toString("base64"),byteLength:n.byteLength}}return n instanceof File?{__type:"File",name:n.name||"[File Object]",size:n.size||0,type:n.type||"",lastModified:n.lastModified||0}:n},r)}var ie=R(Re(),1);import*as ae from"node:fs";import*as E from"node:path";function ce(e){if(e){let r=E.dirname(e);for(;r!==E.resolve(r,"..");){let t=E.join(r,".env");if(ae.existsSync(t)){ie.config({path:t});break}r=E.resolve(r,"..")}}return process.env}var C=R(re(),1);function Me(e,r={}){let{clientCert:t,clientKey:s,caCert:n}=r,o=new URL(e).origin,i=U(),a=i&&!ne(e);if(t&&s&&a)return new C.ProxyAgent({uri:i,connect:{key:Buffer.from(s),cert:Buffer.from(t),...n&&{ca:Buffer.from(n)},rejectUnauthorized:!0}});if(t&&s)return new C.Client(o,{connect:{key:Buffer.from(s),cert:Buffer.from(t),...n&&{ca:Buffer.from(n)},rejectUnauthorized:!0}});if(a)return new C.ProxyAgent({uri:i})}function fe(e){if(!U()&&(!e||Object.keys(e).length===0))return C.fetch;let t=new Map;return(s,n)=>{let o=typeof s=="string"?s:s instanceof URL?s.toString():"url"in s?s.url:void 0;if(!o)throw new Error("Invalid input URL");let i=e?Pe(o,e):void 0,a=new URL(o).origin,c=t.get(a);return c||(c=Me(o,i)||n?.dispatcher,c&&t.set(a,c)),(0,C.fetch)(s,{...n,dispatcher:c})}}function Pe(e,r){let t=new URL(e);return r[t.origin]||r[t.hostname]}import*as q from"node:path";function ue(e,r){let s=Math.max(...e.map(({file:i})=>q.basename(i).length+40)),n=[{name:"Filename",width:s},{name:"Workflows",width:10},{name:"Passed",width:7},{name:"Failed",width:7},{name:"Warnings",width:8}],o="";o+=`${w(`\u250C${n.map(i=>"\u2500".repeat(i.width+2)).join("\u252C")}\u2510`)}
|
|
8
8
|
`,o+=`${w(`\u2502${n.map(i=>` ${i.name.padEnd(i.width)} `).join("\u2502")}\u2502`)}
|
|
9
9
|
`,o+=`${w(`\u251C${n.map(i=>"\u2500".repeat(i.width+2)).join("\u253C")}\u2524`)}
|
|
10
10
|
`,e.forEach(({file:i,executedWorkflows:a,argv:c})=>{let f=q.basename(i),p=c?.workflow||[],u=c?.skip||[],m=p&&p.length?a.filter(({workflowId:A})=>p.includes(A)):a;m=u&&u.length?m.filter(({workflowId:A})=>!u.includes(A)):m;let{workflows:l}=O(m),d=w(l.total.toString().padEnd(11)),L=S(l.passed.toString().padEnd(8)),y=l.failed>0?F(l.failed.toString().padEnd(8)):w("-".padEnd(8)),b=l.warnings>0?ee(l.warnings.toString().padEnd(9)):w("-".padEnd(9)),j=`${l.failed>0?"x":"\u2713"} ${f}`.padEnd(s+1),D=l.failed>0?F(j):S(j);o+=w("\u2502")+` ${D}`+w("\u2502")+` ${d}`+w("\u2502")+` ${L}`+w("\u2502")+` ${y}`+w("\u2502")+` ${b}`+w("\u2502")+`
|
|
@@ -16,7 +16,7 @@ import{c as O,d as se,f as oe}from"./DAQRGYND.js";import"./UF2ZCH7W.js";import{a
|
|
|
16
16
|
`);if(h._compressed=/^(gzip|compress|deflate|br)$/.test(d.headers.get("content-encoding")||""),h.response.content||(h.response.content={size:-1}),h._compressed){let x=await y.arrayBuffer();h.response.content.size=x.byteLength}else h.response.content.size=b?Buffer.byteLength(b):-1;let Z=b?Buffer.byteLength(b):-1;h.response={headers:M(d.headers),cookies:Ce(d.headers),status:d.status,statusText:d.statusText||"",httpVersion:d.httpVersion?`HTTP/${d.httpVersion}`:"HTTP/1.1",redirectURL:d.headers.location||"",content:{size:h._compressed&&h.response.content.size!==-1?h.response.content.size:Buffer.byteLength(b),mimeType:d.headers.get("content-type")||"",text:b,compression:h._compressed&&h.response.content.size!==-1?h.response.content.size-Z:0},bodySize:Z,headersSize:A};let{_timestamps:g}=h;h.timings={blocked:Math.max(v(g.start,g.socket),.01),dns:-1,connect:Math.max(v(g.lookup,g.connect),-1),ssl:g.secureConnect?Math.max(v(g.connect,g.secureConnect),-1):-1,send:v(g.secureConnect||g.connect,g.sent),wait:Math.max(v(g.sent,g.firstByte),0),receive:v(g.firstByte,g.received)},h.time=v(g.start,g.received);let _=[],$=h;do{let x=$._parent;delete $._parent,x&&_.unshift(x),$=x}while($);return m.pageref=i||"page_1",_.forEach(x=>{x.pageref=m.pageref}),d.harEntry=m,Array.isArray(o?.log?.entries)&&o.log.entries.push(..._,m),a&&(_.forEach(x=>{a(x)}),a(m)),d}};function Ee(e){let r={};for(let t of e){let{executedWorkflows:s,globalTimeoutError:n,ctx:o,secretValues:i}=t;r[t.file]=oe({value:{totalRequests:t.totalRequests,executedWorkflows:s.map(a=>Se(a)),totalTimeMs:t.totalTimeMs,globalTimeoutError:n,secretValues:i},noSecretsMasking:o.noSecretsMasking,secretsSet:o.secretsSet||new Set})}return r}function Se(e){let{ctx:r,...t}=e,s=e.executedSteps.map(i=>Ke(i,e.workflowId,r)),n=O([e]);return{...t,executedSteps:s,status:n.steps.failed>0?"error":n.steps.warnings>0?"warn":"success",totalRequests:n.totalRequests,totalTimeMs:e.totalTimeMs}}function Ke(e,r,t){if("executedSteps"in e)return Se(e);let s=t.$workflows[r].steps[e.stepId];return{type:"step",stepId:e.stepId,workflowId:r,request:{method:s?.request?.method||"",url:e.response?.requestUrl||"",headers:s?.request?.header||{},body:s?.request?.body},response:{statusCode:e.response?.statusCode||0,body:s?.response?.body,headers:e.response?.header||{},time:e.response?.time||0,size:e.response?.responseSize},checks:e.checks.map(n=>({...n,status:Ge(n)})),totalTimeMs:s?.response?.time||0,retriesLeft:e.retriesLeft,status:Ze(e.checks)}}function Ge(e){return e.passed?"success":e.severity==="error"?"error":"warn"}function Ze(e){let r=!1;for(let t of e){if(!t.passed&&t.severity==="error")return"error";!t.passed&&t.severity==="warn"&&(r=!0)}return r?"warn":"success"}import*as T from"node:fs";import*as Te from"node:path";function Le(e={},r){let t={};for(let[s,n]of Object.entries(e))t[s]={clientCert:G(n.clientCert,r),clientKey:G(n.clientKey,r),caCert:G(n.caCert,r)};return t}function G(e,r){if(e)try{if(!(e.includes("-----BEGIN")&&e.includes("-----END"))){let s=Te.resolve(r,e);return T.accessSync(s,T.constants.R_OK),T.readFileSync(s,"utf-8")}return Xe(e)}catch(t){throw new Error(`Failed to read certificate: ${t.message}`)}}function Xe(e){let r=e.match(/^(-----BEGIN[^-]+-----)\r?\n([A-Za-z0-9+/=\r\n\t ]+)\r?\n(-----END[^-]+-----)/);if(!r)throw new Error("Invalid certificate format");let[,t,s,n]=r,o=s.replace(/\s+/g,"").match(/.{1,64}/g)?.join(`
|
|
17
17
|
`)||"";return`${t}
|
|
18
18
|
${o}
|
|
19
|
-
${n}`}async function Vt({argv:e,config:r,version:t,collectSpecData:s}){let n,o;try{let{run:i,conditionallyMaskSecrets:a}=await import("./
|
|
19
|
+
${n}`}async function Vt({argv:e,config:r,version:t,collectSpecData:s}){let n,o;try{let{run:i,conditionallyMaskSecrets:a}=await import("./MNH2K4WM.js"),c=r.configPath?et(r.configPath):process.cwd();e.mtls&&(n=Le(e.mtls,c));let f=fe(n);e["har-output"]&&(o=le({version:t}),f=K(f,{har:o}));let p=new Y({http:{headers:r.resolve?.http?.headers??[],customFetch:f}}),u={files:e.files,input:e.input,server:e.server,workflow:e.workflow,skip:e.skip,verbose:e.verbose,config:r,version:t,collectSpecData:s,severity:e.severity,maxSteps:e["max-steps"],maxFetchTimeout:e["max-fetch-timeout"],executionTimeout:e["execution-timeout"],requestFileLoader:{getFileBody:async y=>{if(!Qe(y))throw new Error(`File ${y} doesn't exist or isn't readable.`);let b=Ye(y);return new File([b],tt(y))}},envVariables:ce(c)||{},logger:k,fetch:f,externalRefResolver:p,noSecretsMasking:e["no-secrets-masking"]};if(u.skip&&u.workflow)throw new Error("Cannot use both --skip and --workflow flags at the same time.");if(e["har-output"]&&!e["har-output"].endsWith(".har"))throw new Error("File for HAR logs should be in .har format");if(e["json-output"]&&!e["json-output"].endsWith(".json"))throw new Error("File for JSON logs should be in .json format");if(u.files.length>1&&e["har-output"])throw new Error("Currently only a single file can be run with --har-output. Please run a single file at a time.");let m=performance.now(),l=await i(u);k.printNewLine(),ue(l,k),k.printNewLine();let d=l.some(y=>y.hasProblems),L=l.some(y=>y.hasWarnings);if(e["json-output"]){let y={files:Ee(l),status:d?"error":L?"warn":"success",totalTime:performance.now()-m};Ae(e["json-output"],N(y,2),"utf-8"),k.output(I(k.indent(`JSON logs saved in ${S(e["json-output"])}`,2))),k.printNewLine(),k.printNewLine()}if(e["har-output"])for(let y of l){let b=a({value:o,noSecretsMasking:y.ctx.noSecretsMasking,secretsSet:y.ctx.secretsSet||new Set});Ae(e["har-output"],N(b,2),"utf-8"),k.output(I(`Har logs saved in ${S(e["har-output"])}`)),k.printNewLine(),k.printNewLine()}if(d)throw new Error(" Tests exited with error ")}catch(i){throw new te(i?.message??i)}}export{Vt as handleRespect};
|
|
20
20
|
/*! Bundled license information:
|
|
21
21
|
|
|
22
22
|
cookie/index.js:
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b}from"./
|
|
7
|
+
import{a,b}from"./GGRILIN6.js";import"./F6IXS3RL.js";import"./22EANOP2.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{a as bundleTelemetry,b as handleBundle};
|