@redocly/cli 2.71.0 → 2.71.1
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 +3 -3
- package/lib/chunks/{SXIMN47K.js → 25RSTUQA.js} +1 -1
- package/lib/chunks/{N37OGNC4.js → 2IUGP2IH.js} +3 -3
- package/lib/chunks/{STAMDB3P.js → 2NYYNBAC.js} +1 -1
- package/lib/chunks/{YDGFDJ2K.js → 3N7LKSDD.js} +1 -1
- package/lib/chunks/4DUOPCYP.js +7 -0
- package/lib/chunks/{QAPQYNI3.js → 54EKLNNI.js} +1 -1
- package/lib/chunks/5BQNATJZ.js +20 -0
- package/lib/chunks/{PF43QQZA.js → 5DW3QRJB.js} +2 -2
- package/lib/chunks/{E4MPGN3Z.js → 5SSWNONM.js} +1 -1
- package/lib/chunks/{B5KSRXXW.js → 6TCEQRVX.js} +1 -1
- package/lib/chunks/{G2M6SQCS.js → 6ZNJ7RDX.js} +2 -2
- package/lib/chunks/{YLRH4RVF.js → 7HFLPQAB.js} +2 -2
- package/lib/chunks/{JCP37EY3.js → ACAPGKSR.js} +59 -25
- package/lib/chunks/ACECCMWJ.js +14 -0
- package/lib/chunks/{O37B7ABT.js → AH6ANNYP.js} +1 -1
- package/lib/chunks/{EHQY7ZOF.js → B5SUTVG4.js} +1 -1
- package/lib/chunks/{HAOBCQWB.js → BE4Z5FOC.js} +10 -8
- package/lib/chunks/{TXSBWL3Y.js → BOWZV5S6.js} +1 -1
- package/lib/chunks/{IULINGO6.js → BPSWCUZE.js} +1 -1
- package/lib/chunks/{V6VNRABV.js → BXXX3ZCV.js} +1 -1
- package/lib/chunks/{QMS4UKIK.js → CHX7O5AM.js} +5 -5
- package/lib/chunks/{2NVGTELR.js → CJWIDJTB.js} +1 -1
- package/lib/chunks/{L4F2ERUL.js → CX76LEFC.js} +1 -1
- package/lib/chunks/{WBWCX3LS.js → DORXGE7Z.js} +93 -93
- package/lib/chunks/{LD5MEXEL.js → DP3T6VZX.js} +1 -1
- package/lib/chunks/{FKKC7G6X.js → DURXFJ7H.js} +1 -1
- package/lib/chunks/DVLD4FET.js +20 -0
- package/lib/chunks/{MV3ZJ5HR.js → EAFZ6DNQ.js} +1 -1
- package/lib/chunks/{LS3G7CUH.js → EBHQXW6Z.js} +1 -1
- package/lib/chunks/{RIGQPR2I.js → EO65RJ4Z.js} +1 -1
- package/lib/chunks/{T55LQK2H.js → EQOFXQKD.js} +1 -1
- package/lib/chunks/FBEEMKTB.js +7 -0
- package/lib/chunks/{BU4AMVHN.js → FGJDZKD2.js} +1 -1
- package/lib/chunks/G6SB4ZP5.js +7 -0
- package/lib/chunks/{LRMOPAZ4.js → GAKWND4S.js} +1 -1
- package/lib/chunks/HAGYQ4BK.js +20 -0
- package/lib/chunks/{LNEXTJNF.js → HBWCMTP3.js} +1 -1
- package/lib/chunks/{2R2CXBRH.js → HWOL3HHR.js} +1 -1
- package/lib/chunks/{2UAA6O26.js → ILYXMZRT.js} +1 -1
- package/lib/chunks/{NBMSBQEL.js → INGAWMLB.js} +1 -1
- package/lib/chunks/{3DMXMP4K.js → IYV7EO2J.js} +1 -1
- package/lib/chunks/IZMDARCL.js +22 -0
- package/lib/chunks/JOWPA3MJ.js +7 -0
- package/lib/chunks/KFQC57GK.js +145 -0
- package/lib/chunks/{CZS2ZXJ7.js → KJIUDCYZ.js} +1 -1
- package/lib/chunks/{QB6CQ2CV.js → L2O63VRM.js} +1 -1
- package/lib/chunks/{MYSYBBIO.js → MH5X2EVH.js} +1 -1
- package/lib/chunks/{RLJVKAOL.js → NLAPR7D4.js} +1 -1
- package/lib/chunks/O53IFFP3.js +98 -0
- package/lib/chunks/{MQUZ5IJ2.js → PBQOGZ5C.js} +1 -1
- package/lib/chunks/{BCRM4BTA.js → Q3IJURM3.js} +1 -1
- package/lib/chunks/{HHCU6T2V.js → QXBSAWH3.js} +1 -1
- package/lib/chunks/QXHFS5G6.js +7 -0
- package/lib/chunks/{E3FBSKNS.js → QZJAXPYF.js} +1 -1
- package/lib/chunks/{QTGTCBFK.js → RBJCAITC.js} +1 -1
- package/lib/chunks/{CN2ZOHYL.js → RBNQC5ZB.js} +1 -1
- package/lib/chunks/{2CMKIFTE.js → RNA6JDRC.js} +1 -1
- package/lib/chunks/{DHP4BBTH.js → RNL7TC2W.js} +1 -1
- package/lib/chunks/{WKDC6LN3.js → RUPTJCF5.js} +1 -1
- package/lib/chunks/{YDQCJP4F.js → S6W63XAS.js} +1 -1
- package/lib/chunks/{B3GE7EIX.js → TN3JQHMS.js} +1 -1
- package/lib/chunks/TNRIBQHV.js +7 -0
- package/lib/chunks/TZROZMVE.js +20 -0
- package/lib/chunks/{TR67FYLT.js → U7KIB7CD.js} +1 -1
- package/lib/chunks/{EFB2YVY2.js → UMN7TKTH.js} +2 -2
- package/lib/chunks/{VXD5O25A.js → V34D5CUU.js} +1 -1
- package/lib/chunks/{SBHCUK5I.js → W2CABGMW.js} +1 -1
- package/lib/chunks/{MYOQDPQZ.js → WCJ2HAN3.js} +1 -1
- package/lib/chunks/{5ECOOGVW.js → WJ3YDHQA.js} +1 -1
- package/lib/chunks/{6TE6AFQ3.js → WLI2XLEP.js} +1 -1
- package/lib/chunks/{NCDX4IGX.js → X7C43UBI.js} +1 -1
- package/lib/chunks/{EH6VW7JO.js → XGPGFZMH.js} +1 -1
- package/lib/chunks/{YUEIHUPX.js → XZIK3H6V.js} +1 -1
- package/lib/chunks/{P7LM57HK.js → Y3LDWYZD.js} +1 -1
- package/lib/chunks/{VJHJJBVN.js → Y5DDX2MU.js} +1 -1
- package/lib/chunks/{MT4W54PL.js → YL3LVBZF.js} +1 -1
- package/lib/chunks/{O6NMXFEP.js → ZBB6PS6I.js} +1 -1
- package/lib/chunks/{NZE22F7Q.js → ZQTHHPK3.js} +2 -2
- 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 +7 -2
- 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 +17 -9
- package/lib/eject-assets/generators/mock/index.ts +4 -3
- package/lib/eject-assets/generators/mock/render.ts +128 -9
- package/lib/eject-assets/generators/mock/sample.ts +87 -4
- 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 +10 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +8 -3
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +11 -6
- package/lib/eject-assets/generators/php/pagination.ts +3 -2
- package/lib/eject-assets/generators/php/types.ts +12 -2
- 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 +3 -3
- package/lib/eject-assets/generators/python/models.ts +9 -3
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +6 -5
- 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 +6 -5
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +34 -7
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +1 -1
- package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/lib/eject-assets/generators/typescript/types.ts +1 -1
- package/lib/eject-assets/generators/zod/index.ts +2 -2
- package/lib/eject-assets/generators/zod/schemas.ts +1 -1
- package/lib/eject-assets/skills/go-generator/SKILL.md +3 -0
- package/lib/eject-assets/skills/mock-generator/SKILL.md +22 -0
- package/lib/eject-assets/skills/php-generator/SKILL.md +9 -2
- package/lib/eject-assets/skills/python-generator/SKILL.md +6 -0
- package/lib/eject-assets/skills/tanstack-query-generator/SKILL.md +2 -1
- package/lib/eject-assets/skills/transformers-generator/SKILL.md +4 -0
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +5 -0
- package/lib/index.js +5 -5
- package/lib/skills/redocly-cli/SKILL.md +20 -1
- package/package.json +1 -1
- package/lib/chunks/2Y7MGFQS.js +0 -105
- package/lib/chunks/BPDHBW3N.js +0 -7
- package/lib/chunks/EWU57NBY.js +0 -20
- package/lib/chunks/GKXY6U4S.js +0 -145
- package/lib/chunks/GMGZQR6Q.js +0 -7
- package/lib/chunks/JM7BMZLD.js +0 -13
- package/lib/chunks/K6VR5YNF.js +0 -22
- package/lib/chunks/M6UVHV6D.js +0 -7
- package/lib/chunks/O72R3AD4.js +0 -20
- package/lib/chunks/RZ3FGCBT.js +0 -20
- package/lib/chunks/SBT63VHF.js +0 -7
- package/lib/chunks/UW4UC7ZI.js +0 -9
- package/lib/chunks/VQRJE4I2.js +0 -7
- package/lib/chunks/WACZWFKN.js +0 -19
- package/lib/chunks/WJXIZZA6.js +0 -7
|
@@ -4,9 +4,11 @@ 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
|
|
8
|
-
|
|
9
|
-
`
|
|
7
|
+
import{c as S,fa as A}from"./DORXGE7Z.js";var E=class{indentUnit;lines=[];depth=0;constructor(n=" "){this.indentUnit=n}line(n=""){return this.lines.push(n===""?"":this.indentUnit.repeat(this.depth)+n),this}blank(){return this.line()}indent(n){return this.depth++,n(),this.depth--,this}block(n,t,r){return this.line(n),this.indent(t),r===void 0?this:this.line(r)}toString(){return this.lines.join(`
|
|
8
|
+
`)+`
|
|
9
|
+
`}};function b(e){return e.replace(/^\+(?=\d)/,"plus ").replace(/^-(?=\d)/,"minus ").replace(/([A-Z]{2,})s(?![a-z])/g,"$1S").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[^A-Za-z0-9]+/).filter(n=>n!=="").map(n=>n.toLowerCase())}var T=e=>e.charAt(0).toUpperCase()+e.slice(1),w={camel:e=>{let[n,...t]=b(e);return(n??"")+t.map(T).join("")},pascal:e=>b(e).map(T).join(""),snake:e=>b(e).join("_"),screaming:e=>b(e).join("_").toUpperCase()},Y={typescript:new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","implements","interface","let","package","private","protected","public","static","yield","await"]),python:new Set(["false","none","true","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield","match","case","type"]),go:new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"]),php:new Set(["abstract","and","array","as","break","callable","case","catch","class","clone","const","continue","declare","default","die","do","echo","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","exit","extends","final","finally","fn","for","foreach","function","global","goto","if","implements","include","instanceof","insteadof","interface","isset","list","match","namespace","new","or","print","private","protected","public","readonly","require","return","static","switch","throw","trait","try","unset","use","var","while","xor","yield","true","false","null","int","float","bool","string","void","iterable","object","mixed","never","self","parent"])};function U(e,n={}){let t=w[n.style??"camel"](e),r=t===""?"_":/^[0-9]/.test(t)?`_${t}`:t;return n.reserved?.has(r.toLowerCase())?`${r}_`:r}function P(e,n={}){let t=new Set(n.taken??[]),r=n.style==="snake"||n.style==="screaming"?"_":"";return e.map(a=>{let s=U(a,n),i=s;for(let o=2;t.has(i);o++)i=`${s}${r}${o}`;return t.add(i),i})}function m(e,n){let t=new Set,r=e;for(;r.kind==="ref";){let{name:a}=r;if(t.has(a))return;t.add(a);let s=n.schemas.find(i=>i.name===a);if(s===void 0)return;r=s.schema}return r}function F(e,n){let t=m(e,n);if(t===void 0)return;if(t.kind==="object")return{properties:t.properties,description:t.description};if(t.kind!=="intersection")return;let r=new Map;for(let a of t.members){let s=F(a,n);if(s===void 0)return;for(let i of s.properties)r.set(i.name,i)}return{properties:[...r.values()],description:t.description}}function ee(e,n){let t=m(e,n);if(t?.kind!=="union"||t.discriminator===void 0)return;let r=[];for(let{value:a,schemaName:s}of t.discriminator.mapping){let i=m({kind:"ref",name:s},n);if(i===void 0)return;r.push({value:a,schemaName:s,schema:i})}return{property:t.discriminator.propertyName,cases:r}}function K(e){return e.kind==="union"&&e.members.some(n=>n.kind==="null")}function ne(e){if(e.kind!=="union"||!K(e))return e;let n=e.members.filter(t=>t.kind!=="null");return n.length===1?n[0]:{...e,members:n}}function te(e){if(e.kind!=="enum")return;let n=P(e.values.map(t=>typeof t=="string"?w.screaming(t):`VALUE_${w.screaming(String(t))}`),{style:"screaming"});return{values:e.values,scalar:e.scalar,memberNames:n}}function re(e){if(!e)return[];let n=e.split(/\r\n|\n|\r/).map(t=>t.trim());for(;n.length>0&&n[0]==="";)n.shift();for(;n.length>0&&n[n.length-1]==="";)n.pop();return n}function q(e,n,t){if(e.kind==="object")return e.properties.find(r=>r.name===n)?.schema;if(e.kind==="record")return e.value;if(e.kind==="array"&&/^(0|[1-9]\d*)$/.test(n))return e.items;if(e.kind==="intersection"){let r;for(let a of e.members){let s=m(a,t);s!==void 0&&(r=q(s,n,t)??r)}return r}}function g(e,n,t){let r=e.kind==="omit"?{kind:"ref",name:e.base}:e,a=m(r,t);if(!(a===void 0||n!==""&&!n.startsWith("/"))){if(n==="")return a;for(let s of n.slice(1).split("/")){let i=s.replaceAll("~1","/").replaceAll("~0","~"),o=q(a,i,t);if(o===void 0||(a=m(o,t),a===void 0))return}return a}}function v(e,n,t=new Set){if(e.kind==="ref"){if(t.has(e.name))return"string";t.add(e.name);let r=n.schemas.find(a=>a.name===e.name);return r===void 0?"string":v(r.schema,n,t)}if(e.kind==="intersection"){let r=e.members.filter(s=>s.kind!=="unknown");if(r.length===1)return v(r[0],n,t);let a=[...new Set(r.map(s=>v(s,n,new Set(t))))];return a.length===1?a[0]:a.every(s=>s==="integer"||s==="number")?"number":"string"}if(e.kind==="union"){let r=e.members.filter(a=>a.kind!=="null");return r.length===1?v(r[0],n,t):"string"}if(e.kind==="scalar"||e.kind==="enum"){if(e.scalar==="integer")return"integer";if(e.scalar==="number")return"number";if(e.scalar==="boolean")return"boolean"}if(e.kind==="literal"){if(typeof e.value=="number")return Number.isInteger(e.value)?"integer":"number";if(typeof e.value=="boolean")return"boolean"}return"string"}function I(e){return e.flatMap(n=>n.operations)}function M(e,n,t){let r=e.specName??e.name;if(t?.exclude?.includes(r))return{};let a=t?.operations?.[r];if(a!==void 0)return x(e,n,a,`pagination.operations["${r}"]`,!0);if(e.paginationExtension!==void 0)return x(e,n,e.paginationExtension,"x-redoclyPagination",!0);if(t?.style!==void 0){let{exclude:s,operations:i,...o}=t;return x(e,n,o,"pagination convention",!1)}return{}}function le(e,n){let t=new Map,r=[];for(let a of I(e.services)){let s=M(a,e,n);s.error!==void 0?r.push(s.error):s.spec!==void 0&&t.set(a.name,{spec:s.spec,itemSchema:s.itemSchema})}if(r.length>0)throw new Error(["Invalid pagination configuration:",...r].join(`
|
|
10
|
+
- `));return t}function x(e,n,t,r,a){let s=`Pagination for operation "${e.name}" (${r})`,i=B(t);if(i!==void 0)return{error:`${s}: ${i}`};let o=t,d=l=>a?{error:`${s}: ${l}`}:{};if(e.sse!==void 0)return d("the operation is a Server-Sent Events stream");if(o.style!=="link"&&o.style!=="body-link"){let l=o.style==="cursor"?"cursorParam":"offsetParam",c=o.style==="cursor"?o.cursorParam:o.offsetParam,O=e.queryParams.find(u=>u.name===c);if(!O){let u=e.queryParams.map(D=>D.name).join(", ");return d(`query parameter "${c}" is not declared on the operation`+(u===""?"":` (declared: ${u})`))}let p=j(O.schema,n);if(!(p!==void 0&&(o.style==="cursor"?k(p,n):p.kind==="scalar"&&(p.scalar==="number"||p.scalar==="integer")))){let u=o.style==="cursor"?"a string":"a number";return d(`the "${l}" query parameter "${c}" must accept ${u} (got ${H(p)})`)}}let h=e.successResponses.find(l=>l.contentType.toLowerCase().includes("json"));if(!h)return d("the operation has no JSON success response");if(o.style==="link"){let l=e.successResponseHeaders?.some(c=>c.name==="link")===!0;if(!l&&!a)return{};l||A.warn(`generate-client: ${s.toLowerCase()} follows the Link header, but the success response does not document one.
|
|
11
|
+
`)}let f=g(h.schema,o.items,n);if(f===void 0)return d(`the "items" pointer "${o.items}" does not resolve in the success response schema`);if(f.kind!=="array")return d(`the "items" pointer "${o.items}" must point at an array (got ${f.kind})`);if(o.style==="body-link"){let l=g(h.schema,o.nextLink,n);if(l===void 0)return d(`the "nextLink" pointer "${o.nextLink}" does not resolve in the success response schema`);if(!k(l,n))return d(`the "nextLink" pointer "${o.nextLink}" must point at a string (got ${l.kind})`)}if(o.style==="cursor"){let l=g(h.schema,o.nextCursor,n);if(l===void 0)return d(`the "nextCursor" pointer "${o.nextCursor}" does not resolve in the success response schema`);if(!k(l,n))return d(`the "nextCursor" pointer "${o.nextCursor}" must point at a string (got ${l.kind})`);if(o.hasMore!==void 0){let c=g(h.schema,o.hasMore,n);if(c===void 0)return d(`the "hasMore" pointer "${o.hasMore}" does not resolve in the success response schema`);if(c.kind!=="scalar"||c.scalar!=="boolean")return d(`the "hasMore" pointer "${o.hasMore}" must point at a boolean (got ${c.kind})`)}}let y=o.limitParam!==void 0?{limitParam:o.limitParam}:{};return{spec:o.style==="cursor"?{style:"cursor",param:o.cursorParam,...y,nextCursor:o.nextCursor,...o.hasMore!==void 0?{hasMore:o.hasMore}:{},items:o.items}:o.style==="link"?{style:"link",...y,items:o.items}:o.style==="body-link"?{style:"body-link",...y,nextLink:o.nextLink,items:o.items}:{style:o.style,param:o.offsetParam,...y,items:o.items},itemSchema:f.items}}function B(e){if(!S(e))return"the rule must be an object";let{style:n,cursorParam:t,nextCursor:r,hasMore:a,offsetParam:s,nextLink:i,limitParam:o,items:d}=e;if(n!=="cursor"&&n!=="offset"&&n!=="page"&&n!=="link"&&n!=="body-link")return`"style" must be one of "cursor" | "offset" | "page" | "link" | "body-link" (got ${JSON.stringify(n)})`;if(typeof d!="string"||d!==""&&!d.startsWith("/"))return'"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';if(n==="cursor"){if(typeof t!="string"||t==="")return'cursor style requires a "cursorParam" query parameter name';if(typeof r!="string"||!r.startsWith("/"))return'cursor style requires a "nextCursor" JSON pointer starting with "/"';if(a!==void 0&&(typeof a!="string"||!a.startsWith("/")))return'"hasMore" must be a JSON pointer starting with "/"'}else if(n==="offset"||n==="page"){if(typeof s!="string"||s==="")return`${n} style requires an "offsetParam" query parameter name`}else if(n==="body-link"&&(typeof i!="string"||!i.startsWith("/")))return'body-link style requires a "nextLink" JSON pointer starting with "/"';if(o!==void 0&&typeof o!="string")return'"limitParam" must be a query parameter name'}function H(e){return e===void 0?"an unresolvable ref":e.kind==="scalar"||e.kind==="enum"?e.scalar:e.kind}function j(e,n){let t=new Set,r=e;for(;r.kind==="ref";){let{name:a}=r;if(t.has(a))return;t.add(a);let s=n.schemas.find(i=>i.name===a);if(s===void 0)return;r=s.schema}return r}function k(e,n){return e.kind==="scalar"||e.kind==="enum"?e.scalar==="string":e.kind==="literal"?typeof e.value=="string":e.kind==="union"?e.members.every(t=>{let r=j(t,n);return r!==void 0&&(r.kind==="null"||r.kind!=="union"&&k(r,n))}):!1}var ue={"types.ts":`/**
|
|
10
12
|
* The public type surface of the client runtime \u2014 \`@redocly/client-generator\`'s
|
|
11
13
|
* app-facing runtime module. Pure types, no runtime code (excluded from coverage).
|
|
12
14
|
* The generator emits \`OPERATIONS\` literals typed
|
|
@@ -185,7 +187,8 @@ export type ApiErrorLike = globalThis.Error & {
|
|
|
185
187
|
};
|
|
186
188
|
|
|
187
189
|
export type SettledCall = {
|
|
188
|
-
response
|
|
190
|
+
// \`| undefined\`, so the runtime can pass an unset response under \`exactOptionalPropertyTypes\`.
|
|
191
|
+
response?: Response | undefined;
|
|
189
192
|
error?: unknown;
|
|
190
193
|
attempts: number;
|
|
191
194
|
durationMs: number;
|
|
@@ -827,7 +830,13 @@ export function toHeaderRecord(headers: HeadersInit | undefined): Record<string,
|
|
|
827
830
|
export function middlewareChain(config: ClientConfig): Middleware[] {
|
|
828
831
|
const single =
|
|
829
832
|
config.onRequest || config.onResponse || config.onError
|
|
830
|
-
? [
|
|
833
|
+
? [
|
|
834
|
+
{
|
|
835
|
+
...(config.onRequest ? { onRequest: config.onRequest } : {}),
|
|
836
|
+
...(config.onResponse ? { onResponse: config.onResponse } : {}),
|
|
837
|
+
...(config.onError ? { onError: config.onError } : {}),
|
|
838
|
+
},
|
|
839
|
+
]
|
|
831
840
|
: [];
|
|
832
841
|
return [...single, ...(config.middleware ?? [])];
|
|
833
842
|
}
|
|
@@ -1001,10 +1010,10 @@ export async function send(
|
|
|
1001
1010
|
...fetchInit,
|
|
1002
1011
|
// \`fetch\` requires it for a stream body.
|
|
1003
1012
|
...(isStream ? { duplex: 'half' } : {}),
|
|
1004
|
-
signal: attemptSignal,
|
|
1013
|
+
signal: attemptSignal ?? null,
|
|
1005
1014
|
method: context.method,
|
|
1006
1015
|
headers: context.headers,
|
|
1007
|
-
body: payload,
|
|
1016
|
+
body: payload ?? null,
|
|
1008
1017
|
});
|
|
1009
1018
|
} catch (error) {
|
|
1010
1019
|
// Decided before any await, when no timer can have fired since \`fetch\` rejected: an
|
|
@@ -1027,7 +1036,7 @@ export async function send(
|
|
|
1027
1036
|
lastResponse = response;
|
|
1028
1037
|
// Reverse order: the last-registered middleware wraps closest to the network (onion).
|
|
1029
1038
|
for (let i = middleware.length - 1; i >= 0; i--) {
|
|
1030
|
-
const onResponse = middleware[i]
|
|
1039
|
+
const onResponse = middleware[i]?.onResponse;
|
|
1031
1040
|
if (onResponse) {
|
|
1032
1041
|
const replaced = await onResponse(response, context);
|
|
1033
1042
|
if (replaced && replaced !== response) {
|
|
@@ -1260,7 +1269,12 @@ export function parseSseFrame(
|
|
|
1260
1269
|
);
|
|
1261
1270
|
}
|
|
1262
1271
|
}
|
|
1263
|
-
return {
|
|
1272
|
+
return {
|
|
1273
|
+
...(event === undefined ? {} : { event }),
|
|
1274
|
+
data,
|
|
1275
|
+
...(id === undefined ? {} : { id }),
|
|
1276
|
+
...(retry === undefined ? {} : { retry }),
|
|
1277
|
+
};
|
|
1264
1278
|
}
|
|
1265
1279
|
`,"create-client.ts":`import { ApiError } from './errors.js';
|
|
1266
1280
|
import { parse, readError } from './parse.js';
|
|
@@ -1475,7 +1489,7 @@ function queryStyles(op: OperationDescriptor): Record<string, QueryStyle> | unde
|
|
|
1475
1489
|
styles[param.name] = {
|
|
1476
1490
|
style: param.style ?? 'form',
|
|
1477
1491
|
explode: param.explode ?? true,
|
|
1478
|
-
allowReserved: param.allowReserved,
|
|
1492
|
+
...(param.allowReserved === undefined ? {} : { allowReserved: param.allowReserved }),
|
|
1479
1493
|
};
|
|
1480
1494
|
}
|
|
1481
1495
|
return styles;
|
|
@@ -1986,9 +2000,10 @@ export function linkNext(header: string | null): string | undefined {
|
|
|
1986
2000
|
for (const entry of header.split(/,\\s*(?=<)/)) {
|
|
1987
2001
|
const target = /^\\s*<([^>]*)>(.*)$/.exec(entry);
|
|
1988
2002
|
if (!target) continue;
|
|
1989
|
-
const
|
|
2003
|
+
const [, url = '', params = ''] = target;
|
|
2004
|
+
const rel = /;\\s*rel\\s*=\\s*"?([^";]+)"?/i.exec(params);
|
|
1990
2005
|
// \`rel\` may carry several space-separated relation types (RFC 8288 \xA73.3).
|
|
1991
|
-
if (rel
|
|
2006
|
+
if (rel?.[1]?.split(/\\s+/).includes('next')) return url;
|
|
1992
2007
|
}
|
|
1993
2008
|
return undefined;
|
|
1994
2009
|
}
|
|
@@ -2013,7 +2028,10 @@ export async function* pagesByLink<TPage>(
|
|
|
2013
2028
|
let query = args.query;
|
|
2014
2029
|
let previous: string | undefined;
|
|
2015
2030
|
while (true) {
|
|
2016
|
-
const { page, linkHeader, url } = await call(
|
|
2031
|
+
const { page, linkHeader, url } = await call(
|
|
2032
|
+
{ ...args, ...(query === undefined ? {} : { query }) },
|
|
2033
|
+
init
|
|
2034
|
+
);
|
|
2017
2035
|
yield page as TPage;
|
|
2018
2036
|
const target = pointer === undefined ? linkNext(linkHeader) : resolvePointer(page, pointer);
|
|
2019
2037
|
if (target === undefined || target === null || target === '') return;
|
|
@@ -2862,7 +2880,7 @@ async function runSingle(
|
|
|
2862
2880
|
return fail(1, detail);
|
|
2863
2881
|
}
|
|
2864
2882
|
}
|
|
2865
|
-
`},
|
|
2883
|
+
`},me={"types.ts":`/**
|
|
2866
2884
|
* The public type surface of the client runtime \u2014 \`@redocly/client-generator\`'s
|
|
2867
2885
|
* app-facing runtime module. Pure types, no runtime code (excluded from coverage).
|
|
2868
2886
|
* The generator emits \`OPERATIONS\` literals typed
|
|
@@ -3041,7 +3059,8 @@ export type ApiErrorLike = globalThis.Error & {
|
|
|
3041
3059
|
};
|
|
3042
3060
|
|
|
3043
3061
|
export type SettledCall = {
|
|
3044
|
-
response
|
|
3062
|
+
// \`| undefined\`, so the runtime can pass an unset response under \`exactOptionalPropertyTypes\`.
|
|
3063
|
+
response?: Response | undefined;
|
|
3045
3064
|
error?: unknown;
|
|
3046
3065
|
attempts: number;
|
|
3047
3066
|
durationMs: number;
|
|
@@ -3652,7 +3671,13 @@ function toHeaderRecord(headers: HeadersInit | undefined): Record<string, string
|
|
|
3652
3671
|
function middlewareChain(config: ClientConfig): Middleware[] {
|
|
3653
3672
|
const single =
|
|
3654
3673
|
config.onRequest || config.onResponse || config.onError
|
|
3655
|
-
? [
|
|
3674
|
+
? [
|
|
3675
|
+
{
|
|
3676
|
+
...(config.onRequest ? { onRequest: config.onRequest } : {}),
|
|
3677
|
+
...(config.onResponse ? { onResponse: config.onResponse } : {}),
|
|
3678
|
+
...(config.onError ? { onError: config.onError } : {}),
|
|
3679
|
+
},
|
|
3680
|
+
]
|
|
3656
3681
|
: [];
|
|
3657
3682
|
return [...single, ...(config.middleware ?? [])];
|
|
3658
3683
|
}
|
|
@@ -3826,10 +3851,10 @@ async function send(
|
|
|
3826
3851
|
...fetchInit,
|
|
3827
3852
|
// \`fetch\` requires it for a stream body.
|
|
3828
3853
|
...(isStream ? { duplex: 'half' } : {}),
|
|
3829
|
-
signal: attemptSignal,
|
|
3854
|
+
signal: attemptSignal ?? null,
|
|
3830
3855
|
method: context.method,
|
|
3831
3856
|
headers: context.headers,
|
|
3832
|
-
body: payload,
|
|
3857
|
+
body: payload ?? null,
|
|
3833
3858
|
});
|
|
3834
3859
|
} catch (error) {
|
|
3835
3860
|
// Decided before any await, when no timer can have fired since \`fetch\` rejected: an
|
|
@@ -3852,7 +3877,7 @@ async function send(
|
|
|
3852
3877
|
lastResponse = response;
|
|
3853
3878
|
// Reverse order: the last-registered middleware wraps closest to the network (onion).
|
|
3854
3879
|
for (let i = middleware.length - 1; i >= 0; i--) {
|
|
3855
|
-
const onResponse = middleware[i]
|
|
3880
|
+
const onResponse = middleware[i]?.onResponse;
|
|
3856
3881
|
if (onResponse) {
|
|
3857
3882
|
const replaced = await onResponse(response, context);
|
|
3858
3883
|
if (replaced && replaced !== response) {
|
|
@@ -4078,7 +4103,12 @@ function parseSseFrame(
|
|
|
4078
4103
|
);
|
|
4079
4104
|
}
|
|
4080
4105
|
}
|
|
4081
|
-
return {
|
|
4106
|
+
return {
|
|
4107
|
+
...(event === undefined ? {} : { event }),
|
|
4108
|
+
data,
|
|
4109
|
+
...(id === undefined ? {} : { id }),
|
|
4110
|
+
...(retry === undefined ? {} : { retry }),
|
|
4111
|
+
};
|
|
4082
4112
|
}`,"create-client.ts":`/**
|
|
4083
4113
|
* The optional behaviors \`createClientCore\` can dispatch to but never statically
|
|
4084
4114
|
* imports. The package's public \`createClient\` wires the full set; the future
|
|
@@ -4269,7 +4299,7 @@ function queryStyles(op: OperationDescriptor): Record<string, QueryStyle> | unde
|
|
|
4269
4299
|
styles[param.name] = {
|
|
4270
4300
|
style: param.style ?? 'form',
|
|
4271
4301
|
explode: param.explode ?? true,
|
|
4272
|
-
allowReserved: param.allowReserved,
|
|
4302
|
+
...(param.allowReserved === undefined ? {} : { allowReserved: param.allowReserved }),
|
|
4273
4303
|
};
|
|
4274
4304
|
}
|
|
4275
4305
|
return styles;
|
|
@@ -4776,9 +4806,10 @@ function linkNext(header: string | null): string | undefined {
|
|
|
4776
4806
|
for (const entry of header.split(/,\\s*(?=<)/)) {
|
|
4777
4807
|
const target = /^\\s*<([^>]*)>(.*)$/.exec(entry);
|
|
4778
4808
|
if (!target) continue;
|
|
4779
|
-
const
|
|
4809
|
+
const [, url = '', params = ''] = target;
|
|
4810
|
+
const rel = /;\\s*rel\\s*=\\s*"?([^";]+)"?/i.exec(params);
|
|
4780
4811
|
// \`rel\` may carry several space-separated relation types (RFC 8288 \xA73.3).
|
|
4781
|
-
if (rel
|
|
4812
|
+
if (rel?.[1]?.split(/\\s+/).includes('next')) return url;
|
|
4782
4813
|
}
|
|
4783
4814
|
return undefined;
|
|
4784
4815
|
}
|
|
@@ -4803,7 +4834,10 @@ async function* pagesByLink<TPage>(
|
|
|
4803
4834
|
let query = args.query;
|
|
4804
4835
|
let previous: string | undefined;
|
|
4805
4836
|
while (true) {
|
|
4806
|
-
const { page, linkHeader, url } = await call(
|
|
4837
|
+
const { page, linkHeader, url } = await call(
|
|
4838
|
+
{ ...args, ...(query === undefined ? {} : { query }) },
|
|
4839
|
+
init
|
|
4840
|
+
);
|
|
4807
4841
|
yield page as TPage;
|
|
4808
4842
|
const target = pointer === undefined ? linkNext(linkHeader) : resolvePointer(page, pointer);
|
|
4809
4843
|
if (target === undefined || target === null || target === '') return;
|
|
@@ -5650,4 +5684,4 @@ async function runSingle(
|
|
|
5650
5684
|
}
|
|
5651
5685
|
return fail(1, detail);
|
|
5652
5686
|
}
|
|
5653
|
-
}`}
|
|
5687
|
+
}`},$=["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","SettledCall","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","anySignal","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","timeoutSignal","toFormData","toHeaderRecord"];var z=["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"],G=["AbortController","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"],R;function fe(){return R===void 0&&(R=new Set([...z,..._,...G,...$])),R}var L={name:"@redocly/client-generator",version:"0.7.12",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.71.1"},peerDependencies:{typescript:">=5.5.0"},peerDependenciesMeta:{typescript:{optional:!0}},devDependencies:{typescript:"6.0.2"},files:["lib","eject-assets"]};var ve=L.version;function N(e){let n=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());return n===null?void 0:[Number(n[1]),Number(n[2]),Number(n[3])]}function C(e,n){return e[0]-n[0]||e[1]-n[1]||e[2]-n[2]}function ke(e,n){let t=/^[\^~]|^>=/.exec(n.trim())?.[0]??"",r=N(n.trim().slice(t.length)),a=N(e);if(!(r===void 0||a===void 0))return C(a,r)<0?!1:t===">="?!0:t===""?C(a,r)===0:t==="~"?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]:C(a,r)===0}export{E as a,w as b,Y as c,U as d,P as e,m as f,F as g,ee as h,K as i,ne as j,te as k,re as l,g as m,v as n,I as o,le as p,ue as q,me as r,z as s,fe as t,ve as u,ke as v};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{e as y,k as D}from"./DP3T6VZX.js";import{g as _}from"./ACAPGKSR.js";import{join as z}from"node:path";var a=" ";function k(t){return`transform${D(t)}`}var W="type __Writable<T> = { -readonly [K in keyof T]: T[K] };",v=!1;function E(t){return{text:t,path:[t]}}function B(t,r){return{text:`${t.text}[${JSON.stringify(r)}]`,path:[...t.path,r]}}function d(t,r,n){if(w(t))return!0;switch(t.kind){case"array":return d(t.items,r,n);case"union":return t.members.some(o=>d(o,r,n));case"ref":{if(n.has(t.name))return!1;let o=r.get(t.name);return o!==void 0&&d(o,r,new Set(n).add(t.name))}default:return!1}}function w(t){return t.kind==="scalar"&&t.scalar==="string"&&(t.metadata?.format==="date-time"||t.metadata?.format==="date")}function $(t,r,n){if(w(t))return!0;switch(t.kind){case"array":return $(t.items,r,n);case"record":return $(t.value,r,n);case"object":return t.properties.some(o=>$(o.schema,r,n));case"union":case"intersection":return t.members.some(o=>$(o,r,n));case"ref":{let o=r.get(t.name);return o!==void 0&&!n.has(t.name)?$(o,r,new Set(n).add(t.name)):!1}default:return!1}}function l(t,r,n,o=!1){return o?[`${n}if (${t}) {`,...r(n+a),`${n}}`]:[`${n}if (${t})`,...r(n+a)]}function O(t,r,n=!1){let o=n?G(t):t.text;return i=>[`${i}${o} = ${r};`]}function T(t){return r=>[`${r}${t};`]}function G(t){if(t.path.length<2)return t.text;v=!0;let r={text:t.text.slice(0,t.text.lastIndexOf("[")),path:t.path.slice(0,-1)},n=t.path[t.path.length-1];return`(${r.text} as __Writable<${K(r)}>)[${JSON.stringify(n)}]`}function K(t){let r=`typeof ${t.path[0]}`;for(let n of t.path.slice(1))r=`NonNullable<${r}>[${JSON.stringify(n)}]`;return`NonNullable<${r}>`}function U(t){return t==="data"?"item":`item${Number(t.slice(4))+1}`}function p(t,r,n,o,i,e,u=!1){if(w(r))return l(`typeof ${t.text} === "string"`,O(t,`new Date(${t.text})`,u),e);switch(r.kind){case"ref":return h(t,r.name,n,o,e,u);case"object":{let f=[];for(let s of r.properties)f.push(...P(B(t,s.name),s.schema,n,o,i,e,s.readOnly===!0));return f}case"array":return R(t,r.items,n,o,i,e,u);case"record":return J(t,r.value,n,o,i,e,!0);case"intersection":{let f=[];for(let s of r.members)f.push(...p(t,s,n,o,i,e,u));return f}case"union":return b(t,r.members,n,o,i,e,u);default:return[]}}function b(t,r,n,o,i,e,u=!1){let f=[],s=e+a,x=[];for(let c of r)if(w(c))f.push(...p(t,c,n,o,i,e,u));else if(c.kind==="ref"){if(!$(c,n,o))continue;let j=`${k(c.name)}(${t.text} as ${c.name})`,m=d(c,n,o)?O(t,j,u):T(j);x.push(...m(s))}else x.push(...p(t,c,n,o,i,s,u));return x.length>0&&f.push(...l(`${t.text} && typeof ${t.text} === "object"`,()=>x,e,!0)),f}function h(t,r,n,o,i,e=!1){let u={kind:"ref",name:r};if(!$(u,n,o))return[];let f=`${k(r)}(${t.text})`;return l(t.text,d(u,n,o)?O(t,f,e):T(f),i)}function P(t,r,n,o,i,e,u=!1){if(r.kind==="ref")return h(t,r.name,n,o,e,u);if(r.kind==="object"){let f=p(t,r,n,o,i,e+a);return f.length===0?[]:l(t.text,()=>f,e,!0)}return p(t,r,n,o,i,e,u)}function A(t,r,n,o,i=0){if(w(r))return`new Date(${t})`;if(r.kind==="ref"&&d(r,n,o))return`${k(r.name)}(${t})`;if(r.kind==="array"){let e=r.items.kind==="array"?I(i+1):"v",u=A(e,r.items,n,o,i+1);return u===null?null:`${t}.map(${e} => ${u})`}return null}function I(t){return t<=1?"row":`row${t}`}function R(t,r,n,o,i,e,u=!1){let f=r.kind==="array"?I(1):"v",s=A(f,r,n,o,1);return s!==null?l(`Array.isArray(${t.text})`,O(t,`${t.text}.map(${f} => ${s})`,u),e):r.kind==="ref"?$(r,n,o)?l(`Array.isArray(${t.text})`,T(`${t.text}.forEach(${k(r.name)})`),e):[]:J(t,r,n,o,i,e,!1)}function J(t,r,n,o,i,e,u){if(u){let c={text:`${t.text}[__k]`,path:[...t.path,"__k"]},j=A(c.text,r,n,o);if(j!==null){let m=w(r)?`typeof ${c.text} === "string"`:`Array.isArray(${c.text})`;return l(t.text,S=>[`${S}for (const __k of Object.keys(${t.text}))`,...l(m,C=>[`${C}${c.text} = ${j};`],S+a)],e)}}let f=U(i),s=p(E(f),r,n,o,f,e+a+a);if(s.length===0)return[];let x=u?`Object.values(${t.text})`:t.text;return l(u?t.text:`Array.isArray(${t.text})`,c=>[`${c}${x}.forEach(${f} => {`,...s,`${c}});`],e)}function q(t,r,n){let o=t.name,i=E("data"),e=t.schema.kind==="ref"?h(i,t.schema.name,n,new Set,a):p(i,t.schema,n,new Set,"data",a),u=(_(t.schema,r)?.properties??[]).filter(s=>s.writeOnly).map(s=>JSON.stringify(s.name));if(u.length===0)return[`export const ${k(t.name)} = (data: ${o}): ${o} => {`,...e,`${a}return data;`,"};"].join(`
|
|
8
|
+
`);let f=`Omit<${o}, ${u.join(" | ")}>`;return[`export const ${k(t.name)} = <T extends ${f}>(input: T): T => {`,`${a}const data: ${f} = input;`,...e,`${a}return input;`,"};"].join(`
|
|
9
|
+
`)}function M(t,r){let n=new Map(t.schemas.map(f=>[f.name,f.schema])),o=t.schemas.filter(f=>$(f.schema,n,new Set));if(o.length===0)return"";let i=o.map(f=>y(f.name)).join(", ");v=!1;let e=o.map(f=>q(f,t,n));return[`import type { ${i} } from ${JSON.stringify(r.sdkModule)};`,...v?[W]:[],...e].join(`
|
|
10
|
+
|
|
11
|
+
`)}var Z=({model:t,output:r,banner:n,emit:o})=>{let i=M(t,{sdkModule:`./${r.stem}.${o.importExt??"js"}`});if(i==="")return[];let e=n.map(u=>`// ${u}`).join(`
|
|
12
|
+
`);return[{path:z(r.dir,`${r.stem}.transformers.ts`),content:`${e}
|
|
13
|
+
|
|
14
|
+
${i}`}]};export{Z as a};
|
|
@@ -4,6 +4,6 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as X}from"./GKXY6U4S.js";import{j as z,k as O,la as g,n as G,o as V,qa as Y,xa as J}from"./WBWCX3LS.js";import{e as W}from"./RFWIIJFG.js";var te=W(X(),1);var C=W(X(),1);function Z(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function K(o){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var Q=async(o,{timeout:t,...e}={})=>{let r=Z(),s=r&&!K(o),n;s?n=new C.ProxyAgent({uri:r}):t&&(n=new C.Agent({connect:{timeout:t}}));try{return await(0,C.fetch)(o,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:n})}catch(i){throw await n?.destroy(),i}};var fe=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function ee(){let o=process.env.REDOCLY_ENVIRONMENT?.trim();return o&&fe.test(o)?o:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},h=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=ee(),s={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let n=await Q(t,{...e,headers:s});return this.collectSunsetWarning(n),n}catch(n){let i=n.cause??n,a=`Failed to fetch. Caused by ${i.message||i.name}.`;throw typeof i.code=="string"&&(a+=` Code: ${i.code}`),new Error(a)}}collectSunsetWarning(t){let e=this.getSunsetDate(t);if(!e)return;let r=new Date(e);e>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(t){let{headers:e}=t;if(!e)return;let r=e.get("sunset")||e.get("Sunset");if(r)return Date.parse(r)}},P=class{client;domain;authHeaders;constructor(t,e,r){this.client=t,this.domain=e,this.authHeaders=r}projectUrl(t,e){return`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`}async fetchJson(t,e,r){try{let s=await this.client.request(t,{...e,headers:{"Content-Type":"application/json",...this.authHeaders}});return await this.getParsedResponse(s)}catch(s){let n=`${r}. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},k=class extends P{async find(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",...this.authHeaders}});return r.status===404?void 0:await this.getParsedResponse(r)}catch(r){let s=`Failed to fetch project. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}},D=class extends P{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/sources`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",...this.authHeaders}}),s=await this.getParsedResponse(r),[n]=s.data;if(!n)throw new Error("Project source not found.");return n.branchName}catch(r){let s=`Failed to fetch default branch. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}async upsert(t,e,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes`,{timeout:6e3,method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let n=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}async push(t,e,r,s){let n=new te.FormData;n.append("remoteId",r.remoteId),n.append("commit[message]",r.commit.message),n.append("commit[author][name]",r.commit.author.name),n.append("commit[author][email]",r.commit.author.email),n.append("commit[branchName]",r.commit.branchName),r.commit.url&&n.append("commit[url]",r.commit.url),r.commit.namespace&&n.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&n.append("commit[sha]",r.commit.sha),r.commit.repository&&n.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&n.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await me(i.stream)]);n.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&n.append("isMainBranch","true"),r.replace&&n.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{...this.authHeaders},body:n});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getPush({organizationId:t,projectId:e,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes/${r}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",...this.authHeaders}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}},F=class extends P{create(t,e,r){return this.fetchJson(`${this.projectUrl(t,e)}/pull-requests`,{method:"POST",body:JSON.stringify(r)},"Failed to open a pull request")}async findLatest(t,e,r){let s=new URLSearchParams({branchName:r,limit:"1"}),{data:n}=await this.fetchJson(`${this.projectUrl(t,e)}/pull-requests?${s}`,{method:"GET",timeout:6e3},"Failed to get the pull request");return n[0]}listChecks(t,e,r){return this.fetchJson(`${this.projectUrl(t,e)}/pull-requests/${encodeURIComponent(r)}/checks`,{method:"GET",timeout:6e3},"Failed to get the checks")}},j=class extends P{async findLatestByCommit(t,e,r){let s=new URLSearchParams({limit:"1",filter:`commitHash:${r}`}),{data:n}=await this.fetchJson(`${this.projectUrl(t,e)}/builds?${s}`,{method:"GET",timeout:6e3},"Failed to get the build");return n[0]}},y=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new h(r,s);let n={Authorization:`Bearer ${e}`};this.projects=new k(this.apiClient,t,n),this.remotes=new D(this.apiClient,t,n)}getSunsetWarning(){return re(this.apiClient.sunsetWarnings)}};function re(o){let[t]=[...o].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function me(o){let t=[];for await(let e of o)t.push(e);return Buffer.concat(t)}function ge(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var we=/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/,E={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function ye(){return process.env.REDOCLY_DOMAIN||E.us}var ne=ve((o,t)=>{try{let e=t||o?.resolvedConfig.residency;return Te(e)?E[e]:e?new URL(e).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:E.us}catch{throw new $}});function S(o){try{ne(void 0,o)}catch{return!1}return!0}function ve(o){return(...t)=>{let e=o(...t);if(!e.startsWith("https://")&&!we.test(e))throw new $;return e}}var $=class extends Error{constructor(){super("Invalid Reunite URL")}};function Te(o){return typeof o=="string"&&o in E}import{Buffer as L}from"node:buffer";import A from"node:crypto";import{mkdirSync as Re,existsSync as oe,writeFileSync as Ce,readFileSync as Pe,rmSync as xe}from"node:fs";import{homedir as Ue}from"node:os";import ie from"node:path";import*as se from"node:child_process";var v=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new h("login",e)}async run(t){let e=await this.getDeviceCode();t?.({verificationUri:e.verificationUri,verificationUriComplete:e.verificationUriComplete,userCode:e.userCode}),this.openBrowser(e.verificationUriComplete);let r=await this.pollingAccessToken(e.deviceCode,e.interval,e.expiresIn);return this.withResidency(r)}openBrowser(t){if(!/^https?:\/\//.test(t))return;let[e,r]=process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:process.platform==="darwin"?["open",[t]]:["xdg-open",[t]];se.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((s,n)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),s(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),n(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),n("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:s,interval:n=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:s,interval:n,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let n=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(n,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...s},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var Ee="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",ae="aes-256-cbc",H=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Ue();this.credentialsFolderPath=ie.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=ie.join(this.credentialsFolderPath,this.credentialsFileName),this.key=A.createHash("sha256").update(`${this.credentialsFolderPath}${Ee}`).digest(),this.iv=A.createHash("md5").update(this.credentialsFolderPath).digest(),Re(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new v(t,this.version).run(e);if(!s)throw new Error("Failed to login. No credentials received.");await this.saveCredentials(s)}async logout(){try{this.removeCredentials()}catch{}}async isAuthorized(t,e){return e?new v(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new v(t,this.version),r=await this.readCredentials();if(!r||!S(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let n=await e.refreshToken(r.refresh_token);return await this.saveCredentials(n),n.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);Ce(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!oe(this.credentialsFilePath))return null;try{let t=Pe(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){oe(this.credentialsFilePath)&&xe(this.credentialsFilePath)}encryptCredentials(t){let e=A.createCipheriv(ae,this.key,this.iv);return L.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=A.createDecipheriv(ae,this.key,this.iv),r=L.concat([e.update(L.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};var $e=/^(https?:\/\/[^/]+)\/api\/orgs\/([^/]+)\/projects\/([^/]+)\/git\/?$/;function Se(o,t,e){return`${o}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}/git`}function _e(o){let[,t,e,r]=o.match($e)??[];if(!(!t||!e||!r||!S(t)))return{reuniteUrl:t,organization:decodeURIComponent(e),project:decodeURIComponent(r)}}async function Ie({branch:o,title:t,description:e,base:r,draft:s,...n}){let{pullRequests:i}=ce(n,"project pr create");return i.create(n.organization,n.project,{branchName:o,title:t,description:e,targetBranchName:r,isDraft:s})}async function Fe({branch:o,...t}){let{pullRequests:e,builds:r}=ce(t,"project pr status"),{organization:s,project:n}=t,i=await e.findLatest(s,n,o);if(!i)return;let[a,c]=await Promise.all([e.listChecks(s,n,i.id),i.headCommitHash?r.findLatestByCommit(s,n,i.headCommitHash):void 0]);return{pullRequest:i,checks:a,previewUrl:c?.deploymentStatus==="SUCCESS"?c.url:void 0}}function ce({reuniteUrl:o,accessToken:t,version:e},r){let s=new h(r,e),n={Cookie:`accessToken=${t}`};return{pullRequests:new F(s,o,n),builds:new j(s,o,n)}}import*as T from"node:fs";import*as p from"node:path";var je=/\/orgs\/([^/]+)\/projects\//,Ae=[401,403];async function x(o,{organization:t,project:e,onSlugDeprecated:r}){let s=await Ne(o,t,e);if(!s)return{organizationId:t,projectId:e};let n={organizationId:Oe(s.uri),projectId:s.id};return(n.organizationId!==t||n.projectId!==e)&&r?.(n),n}async function Ne(o,t,e){try{let r=await o.projects.find(t,e);if(!r)throw new u(`Project "${e}" was not found in organization "${t}". Use the IDs from the organization and project settings in Reunite.`,404);return r}catch(r){if(r instanceof u&&Ae.includes(r.status))return;throw r}}function Oe(o){let t=o.match(je)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${o}".`);return t}async function ke({domain:o,apiKey:t,organization:e,project:r,mountPath:s,files:n,defaultBranch:i,commit:a,version:c,replace:_,onUploadStart:I,onSunsetWarning:R,onSlugDeprecated:N}){let f=new y({domain:o,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await x(f,{organization:e,project:r,onSlugDeprecated:N}),b=await f.remotes.getDefaultBranch(d,l),m=await f.remotes.upsert(d,l,{mountBranchName:b,mountPath:s});I?.(m);let{id:U}=await f.remotes.push(d,l,{remoteId:m.id,commit:a,isMainBranch:i===a.branchName,replace:_},n.map(M=>({path:G(M.name),stream:T.createReadStream(M.path)})));return{pushId:U,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&R?.(d)}}function De(o,t){let e={};for(let s of o)if(T.statSync(s).isDirectory()){let n=s;ue(n,[]).forEach(a=>r(a,n))}else r(s,p.dirname(s));function r(s,n){let i=p.relative(n,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,n])=>({name:s,path:p.resolve(n)}))}function ue(o,t){let e=T.readdirSync(o);for(let r of e){let s=p.join(o,r);T.statSync(s).isDirectory()?t=ue(s,t):t.push(s)}return t}async function le({operation:o,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:n=5e3}){async function i(){let a=await o();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await z(n),i()}return i()}var Le=1200,He=5e3,qe=["pending","running"];async function Be(o){let t=de(o);try{let e=await x(t,o);return await pe(t,e,o.pushId)}finally{he(t,o)}}async function be({buildType:o,maxExecutionTime:t=Le,retryIntervalMs:e=He,startTime:r=Date.now(),onRetry:s,...n}){let i=de(n);try{let a=await x(i,n);return await le({operation:()=>pe(i,a,n.pushId),condition:c=>!qe.includes(c.status[o].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{he(i,n)}}function de({domain:o,apiKey:t,version:e}){return new y({domain:o,apiKey:t,command:"push-status",version:e})}function he(o,{onSunsetWarning:t}){let e=o.getSunsetWarning();e&&t?.(e)}function pe(o,{organizationId:t,projectId:e},r){return o.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function Me({projectUrl:o,auth:t,isApiKey:e=!1,onDebug:r}){let s=We(o);if(!s)throw new g(`Invalid project URL format: ${o}`);try{let n=await ze({...s,auth:t,isApiKey:e,onDebug:r}),i=n.config.scorecardClassic||n.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=n.config.pluginsUrl,c=a?await Ge(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(n){throw new g(n instanceof Error?n.message:String(n))}}function We(o){let t=new URL(o),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:s}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:s}}async function ze({residency:o,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:n}){let i=new URL(`${o}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:Ve(r,s)});if(n?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw n?.(`Authentication failed with status ${a.status}.`),n?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return n?.("Successfully received project configuration."),a.json()}async function Ge(o,t){t?.(`Fetching plugins from: ${o}`);try{let e=await fetch(o);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function Ve(o,t){return t?{Authorization:`Bearer ${o}`}:{Cookie:`accessToken=${o}`}}async function q(o,t,e=[],r=[],s){let n={};for(let i of e){let a={[i.name]:{root:o,rules:t}},c=await Y({apis:a,...i,plugins:r},{configPath:s});n[i.name]=c.forAlias(i.name)}return n}function B(o,t){if(o){for(let e of o)if(Object.entries(e.where?.metadata||{}).every(([s,n])=>Ye(s,n,t)))return e}}function Ye(o,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[o])return!1;let[r,s]=t.split("/"),n=new Date(e[o]);return!(n<new Date(r)||s&&n>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[o])return!1;try{return V(t).test(e[o])}catch{throw new g(`Invalid regex in scorecard target "${o}": ${t}`)}}return e[o]===t}import{pathToFileURL as Je}from"node:url";async function Xe(o,t){if(!o)return[];let e=Je(t??process.cwd()).href+"/",r=o.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var Ze=".redocly.com";function Ke(o){try{return new URL(o).hostname.toLowerCase().endsWith(Ze)}catch{return!1}}async function Qe({apiPath:o,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:n=[],targetLevel:i,metadata:a={},onDebug:c}){let _=[],I=new Map,R=r.levels||[];if(i&&!R.some(l=>l.name===i))throw new g(`Target level "${i}" not found in the scorecard configuration levels.
|
|
7
|
+
import{a as X}from"./KFQC57GK.js";import{j as z,k as O,la as g,n as G,o as V,qa as Y,xa as J}from"./DORXGE7Z.js";import{e as W}from"./RFWIIJFG.js";var te=W(X(),1);var C=W(X(),1);function Z(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function K(o){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var Q=async(o,{timeout:t,...e}={})=>{let r=Z(),s=r&&!K(o),n;s?n=new C.ProxyAgent({uri:r}):t&&(n=new C.Agent({connect:{timeout:t}}));try{return await(0,C.fetch)(o,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:n})}catch(i){throw await n?.destroy(),i}};var fe=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function ee(){let o=process.env.REDOCLY_ENVIRONMENT?.trim();return o&&fe.test(o)?o:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},h=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=ee(),s={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let n=await Q(t,{...e,headers:s});return this.collectSunsetWarning(n),n}catch(n){let i=n.cause??n,a=`Failed to fetch. Caused by ${i.message||i.name}.`;throw typeof i.code=="string"&&(a+=` Code: ${i.code}`),new Error(a)}}collectSunsetWarning(t){let e=this.getSunsetDate(t);if(!e)return;let r=new Date(e);e>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(t){let{headers:e}=t;if(!e)return;let r=e.get("sunset")||e.get("Sunset");if(r)return Date.parse(r)}},P=class{client;domain;authHeaders;constructor(t,e,r){this.client=t,this.domain=e,this.authHeaders=r}projectUrl(t,e){return`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`}async fetchJson(t,e,r){try{let s=await this.client.request(t,{...e,headers:{"Content-Type":"application/json",...this.authHeaders}});return await this.getParsedResponse(s)}catch(s){let n=`${r}. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},k=class extends P{async find(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",...this.authHeaders}});return r.status===404?void 0:await this.getParsedResponse(r)}catch(r){let s=`Failed to fetch project. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}},D=class extends P{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/sources`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",...this.authHeaders}}),s=await this.getParsedResponse(r),[n]=s.data;if(!n)throw new Error("Project source not found.");return n.branchName}catch(r){let s=`Failed to fetch default branch. ${r.message}`;throw r instanceof u?new u(s,r.status):new Error(s)}}async upsert(t,e,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes`,{timeout:6e3,method:"POST",headers:{"Content-Type":"application/json",...this.authHeaders},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let n=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}async push(t,e,r,s){let n=new te.FormData;n.append("remoteId",r.remoteId),n.append("commit[message]",r.commit.message),n.append("commit[author][name]",r.commit.author.name),n.append("commit[author][email]",r.commit.author.email),n.append("commit[branchName]",r.commit.branchName),r.commit.url&&n.append("commit[url]",r.commit.url),r.commit.namespace&&n.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&n.append("commit[sha]",r.commit.sha),r.commit.repository&&n.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&n.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await me(i.stream)]);n.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&n.append("isMainBranch","true"),r.replace&&n.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{...this.authHeaders},body:n});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getPush({organizationId:t,projectId:e,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes/${r}`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",...this.authHeaders}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}},F=class extends P{create(t,e,r){return this.fetchJson(`${this.projectUrl(t,e)}/pull-requests`,{method:"POST",body:JSON.stringify(r)},"Failed to open a pull request")}async findLatest(t,e,r){let s=new URLSearchParams({branchName:r,limit:"1"}),{data:n}=await this.fetchJson(`${this.projectUrl(t,e)}/pull-requests?${s}`,{method:"GET",timeout:6e3},"Failed to get the pull request");return n[0]}listChecks(t,e,r){return this.fetchJson(`${this.projectUrl(t,e)}/pull-requests/${encodeURIComponent(r)}/checks`,{method:"GET",timeout:6e3},"Failed to get the checks")}},j=class extends P{async findLatestByCommit(t,e,r){let s=new URLSearchParams({limit:"1",filter:`commitHash:${r}`}),{data:n}=await this.fetchJson(`${this.projectUrl(t,e)}/builds?${s}`,{method:"GET",timeout:6e3},"Failed to get the build");return n[0]}},y=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new h(r,s);let n={Authorization:`Bearer ${e}`};this.projects=new k(this.apiClient,t,n),this.remotes=new D(this.apiClient,t,n)}getSunsetWarning(){return re(this.apiClient.sunsetWarnings)}};function re(o){let[t]=[...o].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function me(o){let t=[];for await(let e of o)t.push(e);return Buffer.concat(t)}function ge(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var we=/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/,E={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function ye(){return process.env.REDOCLY_DOMAIN||E.us}var ne=ve((o,t)=>{try{let e=t||o?.resolvedConfig.residency;return Te(e)?E[e]:e?new URL(e).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:E.us}catch{throw new $}});function S(o){try{ne(void 0,o)}catch{return!1}return!0}function ve(o){return(...t)=>{let e=o(...t);if(!e.startsWith("https://")&&!we.test(e))throw new $;return e}}var $=class extends Error{constructor(){super("Invalid Reunite URL")}};function Te(o){return typeof o=="string"&&o in E}import{Buffer as L}from"node:buffer";import A from"node:crypto";import{mkdirSync as Re,existsSync as oe,writeFileSync as Ce,readFileSync as Pe,rmSync as xe}from"node:fs";import{homedir as Ue}from"node:os";import ie from"node:path";import*as se from"node:child_process";var v=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new h("login",e)}async run(t){let e=await this.getDeviceCode();t?.({verificationUri:e.verificationUri,verificationUriComplete:e.verificationUriComplete,userCode:e.userCode}),this.openBrowser(e.verificationUriComplete);let r=await this.pollingAccessToken(e.deviceCode,e.interval,e.expiresIn);return this.withResidency(r)}openBrowser(t){if(!/^https?:\/\//.test(t))return;let[e,r]=process.platform==="win32"?["rundll32",["url.dll,FileProtocolHandler",t]]:process.platform==="darwin"?["open",[t]]:["xdg-open",[t]];se.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((s,n)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),s(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),n(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),n("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:s,interval:n=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:s,interval:n,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let n=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(n,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...s},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var Ee="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",ae="aes-256-cbc",H=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Ue();this.credentialsFolderPath=ie.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=ie.join(this.credentialsFolderPath,this.credentialsFileName),this.key=A.createHash("sha256").update(`${this.credentialsFolderPath}${Ee}`).digest(),this.iv=A.createHash("md5").update(this.credentialsFolderPath).digest(),Re(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new v(t,this.version).run(e);if(!s)throw new Error("Failed to login. No credentials received.");await this.saveCredentials(s)}async logout(){try{this.removeCredentials()}catch{}}async isAuthorized(t,e){return e?new v(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new v(t,this.version),r=await this.readCredentials();if(!r||!S(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let n=await e.refreshToken(r.refresh_token);return await this.saveCredentials(n),n.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);Ce(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!oe(this.credentialsFilePath))return null;try{let t=Pe(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){oe(this.credentialsFilePath)&&xe(this.credentialsFilePath)}encryptCredentials(t){let e=A.createCipheriv(ae,this.key,this.iv);return L.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=A.createDecipheriv(ae,this.key,this.iv),r=L.concat([e.update(L.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};var $e=/^(https?:\/\/[^/]+)\/api\/orgs\/([^/]+)\/projects\/([^/]+)\/git\/?$/;function Se(o,t,e){return`${o}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}/git`}function _e(o){let[,t,e,r]=o.match($e)??[];if(!(!t||!e||!r||!S(t)))return{reuniteUrl:t,organization:decodeURIComponent(e),project:decodeURIComponent(r)}}async function Ie({branch:o,title:t,description:e,base:r,draft:s,...n}){let{pullRequests:i}=ce(n,"project pr create");return i.create(n.organization,n.project,{branchName:o,title:t,description:e,targetBranchName:r,isDraft:s})}async function Fe({branch:o,...t}){let{pullRequests:e,builds:r}=ce(t,"project pr status"),{organization:s,project:n}=t,i=await e.findLatest(s,n,o);if(!i)return;let[a,c]=await Promise.all([e.listChecks(s,n,i.id),i.headCommitHash?r.findLatestByCommit(s,n,i.headCommitHash):void 0]);return{pullRequest:i,checks:a,previewUrl:c?.deploymentStatus==="SUCCESS"?c.url:void 0}}function ce({reuniteUrl:o,accessToken:t,version:e},r){let s=new h(r,e),n={Cookie:`accessToken=${t}`};return{pullRequests:new F(s,o,n),builds:new j(s,o,n)}}import*as T from"node:fs";import*as p from"node:path";var je=/\/orgs\/([^/]+)\/projects\//,Ae=[401,403];async function x(o,{organization:t,project:e,onSlugDeprecated:r}){let s=await Ne(o,t,e);if(!s)return{organizationId:t,projectId:e};let n={organizationId:Oe(s.uri),projectId:s.id};return(n.organizationId!==t||n.projectId!==e)&&r?.(n),n}async function Ne(o,t,e){try{let r=await o.projects.find(t,e);if(!r)throw new u(`Project "${e}" was not found in organization "${t}". Use the IDs from the organization and project settings in Reunite.`,404);return r}catch(r){if(r instanceof u&&Ae.includes(r.status))return;throw r}}function Oe(o){let t=o.match(je)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${o}".`);return t}async function ke({domain:o,apiKey:t,organization:e,project:r,mountPath:s,files:n,defaultBranch:i,commit:a,version:c,replace:_,onUploadStart:I,onSunsetWarning:R,onSlugDeprecated:N}){let f=new y({domain:o,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await x(f,{organization:e,project:r,onSlugDeprecated:N}),b=await f.remotes.getDefaultBranch(d,l),m=await f.remotes.upsert(d,l,{mountBranchName:b,mountPath:s});I?.(m);let{id:U}=await f.remotes.push(d,l,{remoteId:m.id,commit:a,isMainBranch:i===a.branchName,replace:_},n.map(M=>({path:G(M.name),stream:T.createReadStream(M.path)})));return{pushId:U,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&R?.(d)}}function De(o,t){let e={};for(let s of o)if(T.statSync(s).isDirectory()){let n=s;ue(n,[]).forEach(a=>r(a,n))}else r(s,p.dirname(s));function r(s,n){let i=p.relative(n,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,n])=>({name:s,path:p.resolve(n)}))}function ue(o,t){let e=T.readdirSync(o);for(let r of e){let s=p.join(o,r);T.statSync(s).isDirectory()?t=ue(s,t):t.push(s)}return t}async function le({operation:o,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:n=5e3}){async function i(){let a=await o();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await z(n),i()}return i()}var Le=1200,He=5e3,qe=["pending","running"];async function Be(o){let t=de(o);try{let e=await x(t,o);return await pe(t,e,o.pushId)}finally{he(t,o)}}async function be({buildType:o,maxExecutionTime:t=Le,retryIntervalMs:e=He,startTime:r=Date.now(),onRetry:s,...n}){let i=de(n);try{let a=await x(i,n);return await le({operation:()=>pe(i,a,n.pushId),condition:c=>!qe.includes(c.status[o].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{he(i,n)}}function de({domain:o,apiKey:t,version:e}){return new y({domain:o,apiKey:t,command:"push-status",version:e})}function he(o,{onSunsetWarning:t}){let e=o.getSunsetWarning();e&&t?.(e)}function pe(o,{organizationId:t,projectId:e},r){return o.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function Me({projectUrl:o,auth:t,isApiKey:e=!1,onDebug:r}){let s=We(o);if(!s)throw new g(`Invalid project URL format: ${o}`);try{let n=await ze({...s,auth:t,isApiKey:e,onDebug:r}),i=n.config.scorecardClassic||n.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=n.config.pluginsUrl,c=a?await Ge(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(n){throw new g(n instanceof Error?n.message:String(n))}}function We(o){let t=new URL(o),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:s}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:s}}async function ze({residency:o,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:n}){let i=new URL(`${o}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:Ve(r,s)});if(n?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw n?.(`Authentication failed with status ${a.status}.`),n?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return n?.("Successfully received project configuration."),a.json()}async function Ge(o,t){t?.(`Fetching plugins from: ${o}`);try{let e=await fetch(o);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function Ve(o,t){return t?{Authorization:`Bearer ${o}`}:{Cookie:`accessToken=${o}`}}async function q(o,t,e=[],r=[],s){let n={};for(let i of e){let a={[i.name]:{root:o,rules:t}},c=await Y({apis:a,...i,plugins:r},{configPath:s});n[i.name]=c.forAlias(i.name)}return n}function B(o,t){if(o){for(let e of o)if(Object.entries(e.where?.metadata||{}).every(([s,n])=>Ye(s,n,t)))return e}}function Ye(o,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[o])return!1;let[r,s]=t.split("/"),n=new Date(e[o]);return!(n<new Date(r)||s&&n>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[o])return!1;try{return V(t).test(e[o])}catch{throw new g(`Invalid regex in scorecard target "${o}": ${t}`)}}return e[o]===t}import{pathToFileURL as Je}from"node:url";async function Xe(o,t){if(!o)return[];let e=Je(t??process.cwd()).href+"/",r=o.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var Ze=".redocly.com";function Ke(o){try{return new URL(o).hostname.toLowerCase().endsWith(Ze)}catch{return!1}}async function Qe({apiPath:o,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:n=[],targetLevel:i,metadata:a={},onDebug:c}){let _=[],I=new Map,R=r.levels||[];if(i&&!R.some(l=>l.name===i))throw new g(`Target level "${i}" not found in the scorecard configuration levels.
|
|
8
8
|
`);let N=B(r.targets,a)?.rules,f=await q(o,N,R,n,s||"");for(let l of R){c?.(`
|
|
9
9
|
Validating level: "${l.name}"`),n.length>0&&c?.(`Using ${n.length} ${O("plugin",n.length)} for this level.`),c?.("Linting document against level rules...");let m=(await J({document:t,externalRefResolver:e,config:f[l.name]})).filter(({ignored:U})=>!U).map(U=>({...U,scorecardLevel:l.name}));c?.(`Found ${m.length} ${O("problem",m.length)} for level "${l.name}".`),I.set(l.name,m),_.push(...m)}let d=et(I,R,i);return{problems:_,achievedLevel:d,targetLevelAchieved:i?d===i:!0}}function et(o,t,e){let r=null;for(let s of t){if((o.get(s.name)||[]).some(a=>a.severity==="error"))return r||"Non Conformant";if(r=s.name,e&&s.name===e)return s.name}return r||"Non Conformant"}export{u as a,h as b,y as c,re as d,ge as e,E as f,ye as g,ne as h,S as i,$ as j,v as k,H as l,Se as m,_e as n,Ie as o,Fe as p,x as q,ke as r,De as s,Be as t,be as u,Me as v,q as w,B as x,Xe as y,Ke as z,Qe as A};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b,c
|
|
7
|
+
import{a,b,c}from"./XZIK3H6V.js";import"./BE4Z5FOC.js";import"./IYV7EO2J.js";import"./DP3T6VZX.js";import"./UMN7TKTH.js";import"./ACAPGKSR.js";import"./WZXA5XPB.js";import"./DORXGE7Z.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{b as typescriptDocs,a as typescriptGenerator,c as typescriptSample};
|
|
@@ -1606,7 +1606,7 @@ from typing import Any, Dict, Tuple, get_args, get_origin, get_type_hints
|
|
|
1606
1606
|
DISCRIMINATORS: Dict[Any, Tuple[str, Dict[str, Any]]] = {}
|
|
1607
1607
|
|
|
1608
1608
|
|
|
1609
|
-
def decode(type_: Any, data: Any):
|
|
1609
|
+
def decode(type_: Any, data: Any) -> Any:
|
|
1610
1610
|
"""Best-effort hydration: wire data -> the annotated Python shape. Unknown or
|
|
1611
1611
|
mismatched shapes pass through unchanged (the server is the source of truth)."""
|
|
1612
1612
|
if data is None or type_ is Any or type_ is None:
|
|
@@ -1620,7 +1620,8 @@ def decode(type_: Any, data: Any):
|
|
|
1620
1620
|
discriminator = DISCRIMINATORS.get(type_)
|
|
1621
1621
|
if discriminator is not None and isinstance(data, dict):
|
|
1622
1622
|
wire_property, mapping = discriminator
|
|
1623
|
-
|
|
1623
|
+
value = data.get(wire_property)
|
|
1624
|
+
target = mapping.get(value) if isinstance(value, str) else None
|
|
1624
1625
|
if target is not None:
|
|
1625
1626
|
try:
|
|
1626
1627
|
return decode(target, data)
|
|
@@ -1663,10 +1664,10 @@ def decode(type_: Any, data: Any):
|
|
|
1663
1664
|
# subclasses \`ValueError\`, so union member probing above still works.
|
|
1664
1665
|
if isinstance(type_, type) and hasattr(type_, "model_validate"):
|
|
1665
1666
|
return type_.model_validate(data)
|
|
1666
|
-
if dataclasses.is_dataclass(type_):
|
|
1667
|
+
if dataclasses.is_dataclass(type_) and isinstance(type_, type):
|
|
1667
1668
|
hints = get_type_hints(type_)
|
|
1668
1669
|
field_map = getattr(type_, "_field_map", {})
|
|
1669
|
-
kwargs = {}
|
|
1670
|
+
kwargs: Dict[str, Any] = {}
|
|
1670
1671
|
for field in dataclasses.fields(type_):
|
|
1671
1672
|
wire = field_map.get(field.name, field.name)
|
|
1672
1673
|
if isinstance(data, dict) and wire in data:
|
|
@@ -1675,7 +1676,7 @@ def decode(type_: Any, data: Any):
|
|
|
1675
1676
|
return data
|
|
1676
1677
|
|
|
1677
1678
|
|
|
1678
|
-
def encode(value: Any):
|
|
1679
|
+
def encode(value: Any) -> Any:
|
|
1679
1680
|
"""Python shape -> wire (JSON) shape; inverse of decode for request bodies."""
|
|
1680
1681
|
# \`mode="json"\` resolves datetimes and enums the same way the branches below do,
|
|
1681
1682
|
# and \`exclude_none\` matches the dataclass path: an unset optional is not sent.
|
|
@@ -1721,14 +1722,15 @@ import httpx
|
|
|
1721
1722
|
|
|
1722
1723
|
from ._errors import ApiTimeoutError
|
|
1723
1724
|
|
|
1724
|
-
T
|
|
1725
|
+
# Not \`T\`: the runtime modules share one generated file, where \`_errors.py\` defines \`T\`.
|
|
1726
|
+
TData = TypeVar("TData")
|
|
1725
1727
|
|
|
1726
1728
|
|
|
1727
1729
|
@dataclass
|
|
1728
|
-
class Envelope(Generic[
|
|
1730
|
+
class Envelope(Generic[TData]):
|
|
1729
1731
|
"""A *_with_headers() result: decoded body + coerced declared headers + raw response."""
|
|
1730
1732
|
|
|
1731
|
-
data:
|
|
1733
|
+
data: TData
|
|
1732
1734
|
headers: Dict[str, Any]
|
|
1733
1735
|
response: httpx.Response
|
|
1734
1736
|
|
|
@@ -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}from"./
|
|
7
|
+
import{a}from"./IZMDARCL.js";import"./DP3T6VZX.js";import"./UMN7TKTH.js";import"./ACAPGKSR.js";import"./WZXA5XPB.js";import"./DORXGE7Z.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{a as mockGenerator};
|
|
@@ -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}from"./
|
|
7
|
+
import{a}from"./2NYYNBAC.js";import"./DP3T6VZX.js";import"./UMN7TKTH.js";import"./ACAPGKSR.js";import"./WZXA5XPB.js";import"./DORXGE7Z.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{a as zodGenerator};
|
|
@@ -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 as xt,h as et}from"./
|
|
7
|
+
import{a as $,g as xt,h as et}from"./RUPTJCF5.js";import{a as wt}from"./64G5RPLP.js";import{b as lt,f as ut,m as gt,n as ht,s as yt}from"./CHX7O5AM.js";import{$ as v,S as Z,Y as D,Z as G,_ as k,b as N,c as M,d as it,fa as T,g as at,ha as tt,i as U,la as w,na as ft,q as E,sa as ct,ta as mt,v as pt}from"./DORXGE7Z.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import*as Nt from"node:path";import{performance as jt}from"node:perf_hooks";import*as Ot from"node:path";function dt(t,e){xt(t,o=>{if(E(o)&&et(o.$ref)){let r=Ot.basename(o.$ref);o.$ref=o.$ref.replace(r,e+"_"+r)}else if(M(o.discriminator)&&M(o.discriminator.mapping)){let{mapping:r}=o.discriminator;for(let i of Object.keys(r)){let c=r[i];typeof c=="string"&&et(c)&&(r[i]=c.split("/").map((O,s,p)=>p.length-1===s&&!O.startsWith(e+"_")?e+"_"+O:O).join("/"))}}})}function j(t,e,o){if(!e)return"";if(!t)throw new w("Info section is not found in specification.");if(!t[e])throw new w(`${k(`prefix-${o}-with-info-prop`)} argument value is not found in info section.`);if(!at(t[e]))throw new w(`${k(`prefix-${o}-with-info-prop`)} argument value should be string.`);if(t[e].length>50)throw new w(`${k(`prefix-${o}-with-info-prop`)} argument value length should not exceed 50 characters.`);return t[e].replaceAll(/\s/g,"_")}function ot(t,e){return e?t?.map(o=>{let r={};for(let[i,c]of Object.entries(o))Object.assign(r,{[e+"_"+i]:c});return r}):t}function C(t,e){return e?e+"_"+t:t}import*as Pt from"node:path";function H(t,e){return t.replace(/"(#\/components\/.*?)"/g,o=>{let r=Pt.basename(o);return o.replace(r,C(r,e))})}function B(t){return t.map(e=>({name:e}))}import*as q from"node:path";function bt(t){return q.basename(t,q.extname(t))}function vt(t){return Object.entries(t).filter(([e,o])=>o.length>1)}function rt(t,e){for(let[o,r]of e)T.warn(`Conflict on ${t} : ${D(o)} in files: ${v(r)}
|
|
8
8
|
`)}function Tt(t){T.info(G(`
|
|
9
9
|
${t} conflict(s) on tags.
|
|
10
10
|
Suggestion: please use ${v("prefix-tags-with-filename")}, ${v("prefix-tags-with-info-prop")} or ${v("without-x-tag-groups")} to prevent naming conflicts.
|
|
@@ -4,13 +4,13 @@ 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{$ as f,L as D,M as h,N as O,R as C,Y as P,Z as j,_ as S,d as E,da as b,e as x,f as $,fa as o,k as l,la as a,t as u}from"./
|
|
7
|
+
import{$ as f,L as D,M as h,N as O,R as C,Y as P,Z as j,_ as S,d as E,da as b,e as x,f as $,fa as o,k as l,la as a,t as u}from"./DORXGE7Z.js";var y=["json","yaml","yml"];import*as i from"node:fs";import{basename as k,dirname as d,extname as g,join as T,resolve as m,relative as R}from"node:path";import*as p from"node:process";import{performance as F}from"perf_hooks";async function te(e,n){let r=!x(e)&&$(n.resolvedConfig.apis)?G(n):await W(e,n),c=r.filter(({path:s})=>!z(s));if(x(c)){for(let{path:s}of c)o.warn(`
|
|
8
8
|
${q(s)} ${P(`does not exist or is invalid.
|
|
9
9
|
|
|
10
|
-
`)}`);throw new a("Please provide a valid path.")}if(r.length===0)throw new a("No APIs were provided. Specify an API via the command argument or define one in your config.");return r}function w(e){return e.configPath?d(e.configPath):
|
|
10
|
+
`)}`);throw new a("Please provide a valid path.")}if(r.length===0)throw new a("No APIs were provided. Specify an API via the command argument or define one in your config.");return r}function w(e){return e.configPath?d(e.configPath):p.cwd()}function z(e){if(!e.trim())throw new a("Path cannot be empty.");return i.existsSync(e)||u(e)?e:void 0}function G(e){return Object.entries(e.resolvedConfig.apis||{}).map(([n,{root:t,output:r}])=>({path:u(t)?t:m(w(e),t),alias:n,output:r&&m(w(e),r)}))}function N(e,n){let t=w(e),r=e.resolvedConfig.apis?.[n];return r?{path:u(r.root)?r.root:m(t,r.root),alias:n,output:r.output&&m(t,r.output)}:{path:n,alias:Object.entries(e.resolvedConfig.apis||{}).find(([c,s])=>m(t,s.root)===m(n))?.[0]??void 0}}async function W(e,n){let{hasMagic:t,glob:r}=await import("./SJHPKWSD.js");return(await Promise.all(e.map(async c=>t(c)&&!u(c)?(await r(c,{cwd:w(n)})).map(I=>N(n,I)):N(n,c)))).flat()}function L(e){return p.env.NODE_ENV==="test"?"<test>ms":`${Math.ceil(F.now()-e)}ms`}function oe(e,n,t){let r=L(n);o.info(b(`
|
|
11
11
|
${t}: ${e} processed in ${r}
|
|
12
12
|
|
|
13
|
-
`))}function se(e,n){return e==="/"?n:e.replaceAll("~1","/").replaceAll("~0","~").replace(/^\//,"").replaceAll("/",n)}function ie(e){return e.replace(/#/g,"_sharp").replace(/\//,"_").replace(/\s/g,"")}function ae(e){return{php:".php","c#":".cs",shell:".sh",curl:".sh",bash:".sh",javascript:".js",js:".js",python:".py",c:".c","c++":".cpp",coffeescript:".litcoffee",dart:".dart",elixir:".ex",go:".go",groovy:".groovy",java:".java",kotlin:".kt","objective-c":".m",perl:".pl",powershell:".ps1",ruby:".rb",rust:".rs",scala:".sc",swift:".swift",typescript:".ts",tsx:".tsx","visual basic":".vb","c/al":".al"}[e.toLowerCase()]??""}var A=class e extends Error{constructor(t){super(t.message);this.originalError=t;Object.setPrototypeOf(this,e.prototype)}originalError};function
|
|
13
|
+
`))}function se(e,n){return e==="/"?n:e.replaceAll("~1","/").replaceAll("~0","~").replace(/^\//,"").replaceAll("/",n)}function ie(e){return e.replace(/#/g,"_sharp").replace(/\//,"_").replace(/\s/g,"")}function ae(e){return{php:".php","c#":".cs",shell:".sh",curl:".sh",bash:".sh",javascript:".js",js:".js",python:".py",c:".c","c++":".cpp",coffeescript:".litcoffee",dart:".dart",elixir:".ex",go:".go",groovy:".groovy",java:".java",kotlin:".kt","objective-c":".m",perl:".pl",powershell:".ps1",ruby:".rb",rust:".rs",scala:".sc",swift:".swift",typescript:".ts",tsx:".tsx","visual basic":".vb","c/al":".al"}[e.toLowerCase()]??""}var A=class e extends Error{constructor(t){super(t.message);this.originalError=t;Object.setPrototypeOf(this,e.prototype)}originalError};function ce(e,n,t){if(n==="json")try{return JSON.stringify(e,null,2)}catch(r){throw r.message.indexOf("circular")>-1?new A(r):r}else return h(e,{noRefs:!t,lineWidth:-1})}function pe(e,n){i.mkdirSync(d(e),{recursive:!0}),i.writeFileSync(e,n)}function le(e){return D(i.readFileSync(e,"utf-8"),{filename:e})}function ue(e,n,t){if(_(n)==="json"){Y(e,n);return}V(e,n,t)}function V(e,n,t=!1){let r=h(e,{noRefs:t});if(p.env.NODE_ENV==="test"){o.info(r);return}i.mkdirSync(d(n),{recursive:!0}),i.writeFileSync(n,r)}function Y(e,n){let t=JSON.stringify(e,null,2);if(p.env.NODE_ENV==="test"){o.info(t);return}i.mkdirSync(d(n),{recursive:!0}),i.writeFileSync(n,t)}function _(e){let n=e.split(".").pop();return y.includes(n)?n:(o.warn(`Unsupported file extension: ${n}. Using yaml.
|
|
14
14
|
`),"yaml")}function fe(e,n){switch(e.constructor){case a:throw e;case C:throw new a(`Failed to resolve API description at ${n}:
|
|
15
15
|
|
|
16
16
|
- ${e.message}`);case O:throw new a(`Failed to parse API description at ${n}:
|
|
@@ -27,8 +27,8 @@ ${t}`):e.warnings>0?(o.info(j(`Woohoo! Your API ${l("description is",n)} valid.
|
|
|
27
27
|
`)),o.warn(`You have ${e.warnings} ${l("warning",e.warnings)}.
|
|
28
28
|
${t}`)):o.info(j(`Woohoo! Your API ${l("description is",n)} valid. \u{1F389}
|
|
29
29
|
${t}`)),e.errors>0&&o.info(b("run `redocly lint --generate-ignore-file` to add all problems to the ignore file.\n")),o.info(`
|
|
30
|
-
`)}function ge({entrypoint:e,output:n,argvOutput:t,ext:r,entries:
|
|
30
|
+
`)}function ge({entrypoint:e,output:n,argvOutput:t,ext:r,entries:c}){let s=n||t;if(!s)return{ext:r||"yaml"};if(c>1&&t){if(r=r||g(e).substring(1),!y.includes(r))throw new Error(`Invalid file extension: ${r}.`);s=T(t,k(e,g(e)))+"."+r}else{if(r=r||g(s).substring(1)||g(e).substring(1),!y.includes(r))throw new Error(`Invalid file extension: ${r}.`);s=T(d(s),k(s,g(s)))+"."+r}return{outputFile:s,ext:r}}function de(e){let{preprocessors:n,rules:t,decorators:r}=e.getUnusedRules();t.length&&o.warn(`[WARNING] Unused rules found in ${f(e.configPath||"")}: ${t.join(", ")}.
|
|
31
31
|
`),n.length&&o.warn(`[WARNING] Unused preprocessors found in ${f(e.configPath||"")}: ${n.join(", ")}.
|
|
32
32
|
`),r.length&&o.warn(`[WARNING] Unused decorators found in ${f(e.configPath||"")}: ${r.join(", ")}.
|
|
33
33
|
`),(t.length||n.length)&&o.warn(`Check the spelling and verify the added plugin prefix.
|
|
34
|
-
`)}function B(e){return e.asyncapi?.startsWith("2")}var U=["swagger","info","host","basePath","schemes","consumes","produces","security","tags","externalDocs","paths","definitions","parameters","responses","securityDefinitions"],K=["openapi","info","jsonSchemaDialect","servers","security","tags","externalDocs","paths","webhooks","x-webhooks","components"],J=["asyncapi","id","info","externalDocs","tags","defaultContentType","servers","channels","components"],M=["asyncapi","info","defaultContentType","servers","channels","operations","components"];function ye(e){return"asyncapi"in e?B(e)?v(e,J):v(e,M):"swagger"in e?v(e,U):v(e,K)}function v(e,n){let t={};for(let r of n)e.hasOwnProperty(r)&&(t[r]=e[r]);return Object.assign(t,e)}function ve(e){let n={...e.oas2,...e.oas3_0,...e.oas3_1,...e.oas3_2,...e.async2,...e.async3,...e.arazzo1,...e.overlay1,...e.openrpc1,...e.graphql};if(E(n))throw new a("\u26A0\uFE0F No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/")}function we(e){return e.replace(/\x1b\[\d+m/g,"")}function q(e){return u(e)?e:R(
|
|
34
|
+
`)}function B(e){return e.asyncapi?.startsWith("2")}var U=["swagger","info","host","basePath","schemes","consumes","produces","security","tags","externalDocs","paths","definitions","parameters","responses","securityDefinitions"],K=["openapi","info","jsonSchemaDialect","servers","security","tags","externalDocs","paths","webhooks","x-webhooks","components"],J=["asyncapi","id","info","externalDocs","tags","defaultContentType","servers","channels","components"],M=["asyncapi","info","defaultContentType","servers","channels","operations","components"];function ye(e){return"asyncapi"in e?B(e)?v(e,J):v(e,M):"swagger"in e?v(e,U):v(e,K)}function v(e,n){let t={};for(let r of n)e.hasOwnProperty(r)&&(t[r]=e[r]);return Object.assign(t,e)}function ve(e){let n={...e.oas2,...e.oas3_0,...e.oas3_1,...e.oas3_2,...e.async2,...e.async3,...e.arazzo1,...e.overlay1,...e.openrpc1,...e.graphql};if(E(n))throw new a("\u26A0\uFE0F No rules were configured. Learn how to configure rules: https://redocly.com/docs/cli/rules/")}function we(e){return e.replace(/\x1b\[\d+m/g,"")}function q(e){return u(e)?e:R(p.cwd(),e)}export{y as a,te as b,w as c,N as d,L as e,oe as f,se as g,ie as h,ae as i,ce as j,pe as k,le as l,ue as m,_ as n,fe as o,me as p,ge as q,de as r,ye as s,ve as t,we as u,q as v};
|