@redocly/cli 2.62.2 → 2.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chunks/{HYE4U6V5.js → 24AVTWC7.js} +1 -1
- package/lib/chunks/{TKLMYBPI.js → 2G2Q42ND.js} +1 -1
- package/lib/chunks/{KRCCY64H.js → 3LGZAJES.js} +1 -1
- package/lib/chunks/3SFDVGEQ.js +7 -0
- package/lib/chunks/{4AM55DEH.js → 4C44BO5N.js} +1 -1
- package/lib/chunks/{DS4SCWID.js → 4JKMQCWY.js} +1 -1
- package/lib/chunks/{3JYQOGV3.js → 5IIJHGNO.js} +1 -1
- package/lib/chunks/{6MH5ZWLD.js → 5VDBZVBF.js} +1 -1
- package/lib/chunks/6AB3BDX4.js +20 -0
- package/lib/chunks/{LRLGVYCG.js → 6LEQ46KS.js} +1 -1
- package/lib/chunks/{2OQM5ARW.js → 6QRNEF7K.js} +1 -1
- package/lib/chunks/{PTNNX4IU.js → 6WESXERF.js} +1 -1
- package/lib/chunks/{5X35UU2C.js → 7AWM5GPD.js} +1 -1
- package/lib/chunks/{CQKQB4PJ.js → 7LNKXEIU.js} +1 -1
- package/lib/chunks/{FDGP3ZYZ.js → 7RQW6KPZ.js} +156 -58
- package/lib/chunks/{SLQPKXO2.js → A22GELRX.js} +1 -1
- package/lib/chunks/{HUWKDZPP.js → AAPHKNGA.js} +1 -1
- package/lib/chunks/{22EANOP2.js → ACMV5RZA.js} +1 -1
- package/lib/chunks/AU7VOB4V.js +20 -0
- package/lib/chunks/{2OBVZIAW.js → B4ONRSDG.js} +3 -3
- package/lib/chunks/BC3XCWQE.js +11 -0
- package/lib/chunks/{VXONEXYX.js → BFIZTFWS.js} +1 -1
- package/lib/chunks/{HWTYAU4Y.js → BS3AUVYD.js} +1 -1
- package/lib/chunks/{ZCVUIIPU.js → C2OCU4E3.js} +1 -1
- package/lib/chunks/{US7X4XPD.js → CQMZF72H.js} +1 -1
- package/lib/chunks/{3C6UUCEW.js → CTPVBOG5.js} +1 -1
- package/lib/chunks/{3JYY42DL.js → CVUPOCX4.js} +1 -1
- package/lib/chunks/{FDMXHRDK.js → DEXQ6S3P.js} +1 -1
- package/lib/chunks/{RPHIT72T.js → DQFNUDOT.js} +1 -1
- package/lib/chunks/{7WM6VLB3.js → E2D25T4G.js} +1 -1
- package/lib/chunks/{4OEXH5EV.js → FCZH3476.js} +1 -1
- package/lib/chunks/{7WTV5KH3.js → FRM6TZ42.js} +1 -1
- package/lib/chunks/{3WHXM4DJ.js → HTG3RKCV.js} +1 -1
- package/lib/chunks/{M3XPS7UF.js → HW7ZCN7J.js} +1 -1
- package/lib/chunks/{I5CGSLGR.js → I3M476SQ.js} +1 -1
- package/lib/chunks/{KOR5TUJG.js → IODGA6FG.js} +1 -1
- package/lib/chunks/{WX24BERR.js → ITUUIAOZ.js} +1 -1
- package/lib/chunks/{CIDSJFJO.js → IYKYAJDC.js} +1 -1
- package/lib/chunks/{XFBJHVYU.js → J373CXCH.js} +1 -1
- package/lib/chunks/{JLVGRO3I.js → J7J4PH3V.js} +7 -7
- package/lib/chunks/{IUSSBOYO.js → JGBWIR5U.js} +1 -1
- package/lib/chunks/{S6NFOZ34.js → JHK6XIMG.js} +1 -1
- package/lib/chunks/{YDVWNFMS.js → KMP5ZE2D.js} +1 -1
- package/lib/chunks/{6EGJEFXO.js → L2EBKZQZ.js} +1 -1
- package/lib/chunks/{SHZZKTDE.js → LLWU7A5G.js} +1 -1
- package/lib/chunks/{LVGVWPDB.js → LXSCIQFU.js} +1 -1
- package/lib/chunks/{5PG3ST2N.js → NCBLLIQ3.js} +2 -2
- package/lib/chunks/{73RBZL53.js → NERCHMVY.js} +1 -1
- package/lib/chunks/{XJE2OFDN.js → NR3R4HFM.js} +45 -18
- package/lib/chunks/{ENSYM7KY.js → OFJ2KV5N.js} +1 -1
- package/lib/chunks/{6WZUCZGV.js → OYUXHAGQ.js} +1 -1
- package/lib/chunks/{37WWN4MA.js → PHWKGYUT.js} +1 -1
- package/lib/chunks/{6NB3FKVN.js → Q4UGLPO2.js} +1 -1
- package/lib/chunks/{36IHQANV.js → QNCKZURN.js} +1 -1
- package/lib/chunks/{GWXT3QO6.js → RFGNVCAR.js} +2 -2
- package/lib/chunks/{HBENVUR4.js → SXIFTBZB.js} +1 -1
- package/lib/chunks/{XJTGJYVS.js → TCALQAX5.js} +1 -1
- package/lib/chunks/{TBZEEKTV.js → U52CY34I.js} +1 -1
- package/lib/chunks/VB4PNWOR.js +7 -0
- package/lib/chunks/{SYWAPWW7.js → VSBSD3XZ.js} +1 -1
- package/lib/chunks/{V3ILUN2S.js → WV2NAII3.js} +1 -1
- package/lib/chunks/{3FXYWWTJ.js → X2V5QOZP.js} +1 -1
- package/lib/chunks/{SXBAAS4M.js → XNNK5G6V.js} +1 -1
- package/lib/chunks/Y4UTXOI2.js +59 -0
- package/lib/chunks/{6DO6IN4A.js → YKST56C6.js} +1 -1
- package/lib/chunks/{2XK7ML3U.js → YXH72HCU.js} +1 -1
- package/lib/chunks/{MNH2K4WM.js → Z52TEGV5.js} +1 -1
- package/lib/chunks/{3DEJQSYG.js → Z5QYTPVY.js} +1 -1
- package/lib/chunks/{OP7NIAI7.js → Z7J6WWCO.js} +1 -1
- package/lib/chunks/{2OVI7BIW.js → ZK27F53P.js} +1 -1
- package/lib/chunks/{V2YF33JL.js → ZP54RCIQ.js} +1 -1
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +2 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +1 -1
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +2 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +1 -1
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +2 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +1 -1
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +56 -9
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +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/tanstack-query-generator/SKILL.md +5 -2
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +5 -0
- package/lib/index.js +5 -5
- package/package.json +1 -1
- package/lib/chunks/5SIJI5LC.js +0 -42
- package/lib/chunks/EDQ6QRIB.js +0 -20
- package/lib/chunks/LCFG5N4V.js +0 -7
- package/lib/chunks/PWGFZ5ZK.js +0 -7
- package/lib/chunks/RU7T4CKG.js +0 -11
- package/lib/chunks/Z6GHMX6Z.js +0 -20
|
@@ -4,7 +4,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 c}from"./
|
|
7
|
+
import{a as c}from"./YKST56C6.js";import{h as s,l as a}from"./4JKMQCWY.js";import"./GKXY6U4S.js";import{aa as t,ia as e,oa as i}from"./ACMV5RZA.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function y({argv:r,config:l,version:d}){let o=s(l,r.residency);try{let n=new a(d);r.verbose&&(e.info(`OAuth client initialized.
|
|
8
8
|
`),e.info(`Local credentials file path: ${n.credentialsFilePath}
|
|
9
9
|
`)),await n.login(o,c),e.output(t(`\u2705 Logged in
|
|
10
10
|
|
|
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{h as l}from"./
|
|
7
|
+
import{h as l}from"./4JKMQCWY.js";import"./GKXY6U4S.js";import{ia as p,oa as i}from"./ACMV5RZA.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as C}from"node:child_process";import{existsSync as x}from"node:fs";import*as s from"node:path";var P=/[\\/](_npx|dlx)[\\/]/;function a(r,t,e){return`${r}/api/orgs/${encodeURIComponent(t)}/projects/${encodeURIComponent(e)}/git`}function m(r,t){let e=`credential.${r}/.helper`,o=!P.test(process.argv[1]??"")&&j("redocly")?"redocly":`npx --yes @redocly/cli@${t}`;return[`${e}=`,`${e}=!REDOCLY_SUPPRESS_UPDATE_NOTICE=true ${o} project git-credentials`]}async function d(r){return new Promise((t,e)=>{let n=C("git",r,{stdio:"inherit",env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});n.on("error",o=>e(E(o))),n.on("close",o=>t(o??1))})}function j(r){let t=process.platform==="win32"?[".cmd",".exe"]:[""];return(process.env.PATH??"").split(s.delimiter).some(e=>e&&t.some(n=>x(s.join(e,r+n))))}function E(r){return r.code==="ENOENT"?new i("git is not installed or not on PATH."):r}async function U({argv:r,config:t,version:e}){let[n,o,...g]=r.project.split("/");if(!n||!o||g.length>0)throw new i(`Specify the project as \`<organization>/<project>\`, for example \`acme/developer-portal\`. Got: \`${r.project}\`.`);let c=l(t,r.residency),f=a(c,n,o),u=m(c,e);if(p.info(`Cloning ${n}/${o} from ${c}
|
|
8
8
|
`),await d(["clone",...u.flatMap(y=>["--config",y]),f,r.directory??o])!==0)throw new i("git clone failed.")}export{U as handleProjectClone};
|
|
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c}from"./
|
|
7
|
+
import{c}from"./ACMV5RZA.js";import{open as U,readdir as H,stat as J}from"node:fs/promises";import x from"node:path";var L=new Set([".yaml",".yml",".json"]);async function K(e){let n=[];async function t(r){let o=await H(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=x.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&L.has(x.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function G(e,n=4096){let t=await U(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function X(e){return x.resolve(process.cwd(),e)}async function Y(e){let n=await J(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await H(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=x.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var z="drift.local",B=`http://${z}`;function l(e){return e===z}var I=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),q=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],T=`
|
|
8
8
|
`;function Z(e){return e.split(T)}function S(e,n,t){let r=n.toLowerCase(),o=e[r];if(o===void 0){e[r]=t;return}e[r]=r==="set-cookie"?`${o}${T}${t}`:`${o},${t}`}function w(e){if(!c(e)&&!Array.isArray(e))return{};let n={};if(Array.isArray(e)){for(let t of e){if(!c(t))continue;let{name:r,value:o}=t;typeof r=="string"&&o!==void 0&&S(n,r,String(o))}return n}for(let[t,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){for(let o of r)S(n,t,String(o));continue}S(n,t,String(r))}return n}function m(e){try{return new URL(e)}catch{return new URL(e,B)}}function N(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function v(e){let n=[],t=0,r=e.startsWith("/")?e:`/${e}`,s=N(r).split("/").map(i=>{if(!i)return"";let a=[...i.matchAll(/\{([^}]+)\}/g)],h=n.length,u="",p=0,f=0;for(let[y,d]of a.entries()){let R=i.slice(f,d.index);u+=b(R),p+=R.length,n.push(d[1]),f=d.index+d[0].length;let E=a[y+1];if(!E){u+="([^/]+)";continue}let A=i.slice(f,E.index);u+=A?`((?:(?!${b(A)})[^/])+)`:"([^/])"}let g=i.slice(f);return u+=b(g),p+=g.length,n.length===h?t+=2:p>0&&(t+=1),u}).join("/");return{regex:new RegExp(`^${s||"/"}$`),params:n,score:t}}function k(e,n){if(n&&P(e))try{return JSON.parse(n)}catch{return}}function C(e){return e?e.split(";")[0]?.trim().toLowerCase()??"":""}function P(e){let n=C(e);return n==="application/json"||n.endsWith("+json")}function ee(e,n){let t=C(n);if(!t)return e["application/json"]??e["*/*"];if(e[t]!==void 0)return e[t];let[r,o]=t.split("/");if(r&&o){let s=`${r}/*`;if(e[s]!==void 0)return e[s]}return e["*/*"]}function ne(e){let n=new Set,t=[];for(let r of e){let o=r.trim().toLowerCase();o.length!==0&&(o.endsWith("*")?t.push(o.slice(0,-1)):n.add(o))}return{names:n,prefixes:t}}function te(e,n){let t=e.toLowerCase();return t.startsWith(":")||I.has(t)||q.some(r=>t.startsWith(r))?!0:n?n.names.has(t)||n.prefixes.some(r=>t.startsWith(r)):!1}import{createReadStream as F}from"node:fs";import{readFile as j}from"node:fs/promises";import{createInterface as W}from"node:readline";function D(e){if(e!=null){if(typeof e=="string")return e;if(Buffer.isBuffer(e))return e.toString("utf8");if(c(e)||Array.isArray(e))try{return JSON.stringify(e)}catch{return String(e)}return String(e)}}function ue(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);if(Number.isFinite(n))return n}}function $(e,n){if(e!=null){if(n==="base64"&&typeof e=="string")try{return Buffer.from(e,"base64").toString("utf8")}catch{return e}return D(e)}}function fe(e,n,t){let r=e.method?.toUpperCase(),o=e.url;if(!r||!o)return null;let s=w(e.requestHeaders),i=m(o);if(l(i.host)&&s.host)try{i=new URL(`${i.protocol}//${s.host}${i.pathname}${i.search}`)}catch{i=m(o)}let a=e.requestContentType??s["content-type"],h=$(e.requestBody),u={method:r,url:i.toString(),path:i.pathname,query:i.searchParams,protocol:i.protocol,protocolKnown:e.schemeKnown??/^https?:\/\//i.test(o),host:l(i.host)?void 0:i.host||void 0,headers:s,contentType:a,bodyText:h,bodyJson:k(a,h)},p,f=e.responseStatus;if(f!==void 0){let g=w(e.responseHeaders),y=e.responseContentType??g["content-type"],d=$(e.responseBody);p={status:f,statusText:e.responseStatusText,headers:g,contentType:y,bodyText:d,bodyJson:k(y,d)}}return{index:n,source:t,startedAt:e.startedAt,request:u,response:p,raw:e.raw}}async function*de(e){let n=F(e,{encoding:"utf8"}),t=W({input:n,crlfDelay:1/0});for await(let r of t){let o=r.trim();if(o)try{let s=JSON.parse(o);c(s)&&(yield s)}catch{}}}async function*pe(e,n){let t=await j(e,"utf8"),r=JSON.parse(t);if(n)for(let o of n.split("."))r=c(r)?r[o]:void 0;if(Array.isArray(r))for(let o of r)c(o)&&(yield o)}function ge(e){return w(e)["content-type"]}function he(e){return e?.replace(/\/+$/,"")||void 0}function O(e,n){if(!n||n==="/")return e||"/";if(e===n)return"/";if(e.startsWith(`${n}/`))return e.slice(n.length)||"/"}function ye(e,n){if(n.startsWith("/"))return O(e.path,n);let t=m(n.includes("://")?n:`http://${n}`);if(!(l(t.host)||e.host!==void 0&&e.host.toLowerCase()!==t.host))return O(e.path,N(t.pathname))}export{K as a,G as b,X as c,Y as d,l as e,Z as f,m as g,N as h,v as i,C as j,P as k,ee as l,ne as m,te as n,D as o,ue as p,$ as q,fe as r,de as s,pe as t,ge as u,he as v,ye as w};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{a as p,b as q,c as r,d as s,e as t,f as u,g as v,h as w,i as x,j as y,k as z,l as A,m as D,n as E,o as F,p as H,q as I}from"./BC3XCWQE.js";import{a as B,e as C,g as G}from"./7RQW6KPZ.js";import{a}from"./WZXA5XPB.js";import"./ACMV5RZA.js";import"./NEWT5A6S.js";import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o}from"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{z as AUTHORING_HELPER_NAMES,G as GENERATOR_VERSION,a as NotSupportedError,b as Printer,d as RESERVED_WORDS,C as WIRING_NAMES,B as allOperations,c as casing,E as constantCase,A as defineClientSetup,H as defineGenerator,g as deref,i as discriminatorCases,m as docText,l as enumValues,h as flattenAllOf,I as generateClient,D as groupSlug,o as headerCoerceType,e as identifierFor,u as isBinaryContentType,s as isMultipartBody,j as isNullable,t as isUntypedMultipartBody,q as jsonSuccessSchema,F as mergeConfig,x as paginationItemSchema,p as paginationRuleFor,y as renderReferencePage,n as resolveSchemaPointer,n as schemaAtPointer,w as securityRequirements,v as serverUrlParts,r as sseResponse,f as uniqueIdentifiers,k as unwrapNullable};
|
|
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./
|
|
7
|
+
import{a,b,c,d,e}from"./I3M476SQ.js";import"./CQMZF72H.js";import"./4JKMQCWY.js";import"./Q4UGLPO2.js";import"./GKXY6U4S.js";import"./ACMV5RZA.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";export{a as DeploymentError,b as handlePushStatus,c as handleReuniteError,d as printSlugDeprecation,e as printSunsetWarning};
|
|
@@ -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 K}from"./GKXY6U4S.js";import{Aa as V,j as z,l as I,o as H,oa as m,p as q,ta as Y}from"./22EANOP2.js";import{e as b}from"./RFWIIJFG.js";var Q=b(K(),1);var T=b(K(),1);function G(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function X(n){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(n).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var Z=async(n,{timeout:t,...e}={})=>{let r=G(),s=r&&!X(n),o;s?o=new T.ProxyAgent({uri:r}):t&&(o=new T.Agent({connect:{timeout:t}}));try{return await(0,T.fetch)(n,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:o})}catch(i){throw await o?.destroy(),i}};var de=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function J(){let n=process.env.REDOCLY_ENVIRONMENT?.trim();return n&&de.test(n)?n:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},x=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=J(),s={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let o=await Z(t,{...e,headers:s});return this.collectSunsetWarning(o),o}catch(o){let i=o.cause??o,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)}},U=class{client;domain;apiKey;constructor(t,e,r){this.client=t,this.domain=e,this.apiKey=r}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},N=class extends U{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",Authorization:`Bearer ${this.apiKey}`}});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)}}},j=class extends U{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/source`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return(await this.getParsedResponse(r)).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",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let o=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}async push(t,e,r,s){let o=new Q.FormData;o.append("remoteId",r.remoteId),o.append("commit[message]",r.commit.message),o.append("commit[author][name]",r.commit.author.name),o.append("commit[author][email]",r.commit.author.email),o.append("commit[branchName]",r.commit.branchName),r.commit.url&&o.append("commit[url]",r.commit.url),r.commit.namespace&&o.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&o.append("commit[sha]",r.commit.sha),r.commit.repository&&o.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&o.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await he(i.stream)]);o.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&o.append("isMainBranch","true"),r.replace&&o.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:o});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",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let o=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}},g=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new x(r,s),this.projects=new N(this.apiClient,t,e),this.remotes=new j(this.apiClient,t,e)}getSunsetWarning(){return ee(this.apiClient.sunsetWarnings)}};function ee(n){let[t]=[...n].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function he(n){let t=[];for await(let e of n)t.push(e);return Buffer.concat(t)}function fe(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var pe=/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/,R={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function me(){return process.env.REDOCLY_DOMAIN||R.us}var te=ge((n,t)=>{try{let e=t||n?.resolvedConfig.residency;return we(e)?R[e]:e?new URL(e).origin:n?.resolvedConfig.scorecard?.fromProjectUrl?new URL(n.resolvedConfig.scorecard.fromProjectUrl).origin:R.us}catch{throw new E}});function D(n){try{te(void 0,n)}catch{return!1}return!0}function ge(n){return(...t)=>{let e=n(...t);if(!e.startsWith("https://")&&!pe.test(e))throw new E;return e}}var E=class extends Error{constructor(){super("Invalid Reunite URL")}};function we(n){return typeof n=="string"&&n in R}import{Buffer as O}from"node:buffer";import F from"node:crypto";import{mkdirSync as ye,existsSync as ne,writeFileSync as ve,readFileSync as Te,rmSync as xe}from"node:fs";import{homedir as Ce}from"node:os";import se from"node:path";import*as re from"node:child_process";var w=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new x("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]];re.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,o)=>{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),o(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),o("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:o=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:o,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let o=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(o,{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 Pe="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",oe="aes-256-cbc",k=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Ce();this.credentialsFolderPath=se.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=se.join(this.credentialsFolderPath,this.credentialsFileName),this.key=F.createHash("sha256").update(`${this.credentialsFolderPath}${Pe}`).digest(),this.iv=F.createHash("md5").update(this.credentialsFolderPath).digest(),ye(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new w(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 w(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new w(t,this.version),r=await this.readCredentials();if(!r||!D(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let o=await e.refreshToken(r.refresh_token);return await this.saveCredentials(o),o.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);ve(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!ne(this.credentialsFilePath))return null;try{let t=Te(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){ne(this.credentialsFilePath)&&xe(this.credentialsFilePath)}encryptCredentials(t){let e=F.createCipheriv(oe,this.key,this.iv);return O.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=F.createDecipheriv(oe,this.key,this.iv),r=O.concat([e.update(O.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as y from"node:fs";import*as h from"node:path";var Re=/\/orgs\/([^/]+)\/projects\//,Ee=[401,403];async function C(n,{organization:t,project:e,onSlugDeprecated:r}){let s=await $e(n,t,e);if(!s)return{organizationId:t,projectId:e};let o={organizationId:_e(s.uri),projectId:s.id};return(o.organizationId!==t||o.projectId!==e)&&r?.(o),o}async function $e(n,t,e){try{let r=await n.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&&Ee.includes(r.status))return;throw r}}function _e(n){let t=n.match(Re)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${n}".`);return t}async function Se({domain:n,apiKey:t,organization:e,project:r,mountPath:s,files:o,defaultBranch:i,commit:a,version:c,replace:$,onUploadStart:_,onSunsetWarning:v,onSlugDeprecated:A}){let f=new g({domain:n,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await C(f,{organization:e,project:r,onSlugDeprecated:A}),M=await f.remotes.getDefaultBranch(d,l),p=await f.remotes.upsert(d,l,{mountBranchName:M,mountPath:s});_?.(p);let{id:P}=await f.remotes.push(d,l,{remoteId:p.id,commit:a,isMainBranch:i===a.branchName,replace:$},o.map(W=>({path:H(W.name),stream:y.createReadStream(W.path)})));return{pushId:P,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&v?.(d)}}function Ue(n,t){let e={};for(let s of n)if(y.statSync(s).isDirectory()){let o=s;ie(o,[]).forEach(a=>r(a,o))}else r(s,h.dirname(s));function r(s,o){let i=h.relative(o,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,o])=>({name:s,path:h.resolve(o)}))}function ie(n,t){let e=y.readdirSync(n);for(let r of e){let s=h.join(n,r);y.statSync(s).isDirectory()?t=ie(s,t):t.push(s)}return t}async function ae({operation:n,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:o=5e3}){async function i(){let a=await n();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await z(o),i()}return i()}var Fe=1200,Ae=5e3,Ie=["pending","running"];async function Ne(n){let t=ce(n);try{let e=await C(t,n);return await le(t,e,n.pushId)}finally{ue(t,n)}}async function je({buildType:n,maxExecutionTime:t=Fe,retryIntervalMs:e=Ae,startTime:r=Date.now(),onRetry:s,...o}){let i=ce(o);try{let a=await C(i,o);return await ae({operation:()=>le(i,a,o.pushId),condition:c=>!Ie.includes(c.status[n].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ue(i,o)}}function ce({domain:n,apiKey:t,version:e}){return new g({domain:n,apiKey:t,command:"push-status",version:e})}function ue(n,{onSunsetWarning:t}){let e=n.getSunsetWarning();e&&t?.(e)}function le(n,{organizationId:t,projectId:e},r){return n.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function De({projectUrl:n,auth:t,isApiKey:e=!1,onDebug:r}){let s=Oe(n);if(!s)throw new m(`Invalid project URL format: ${n}`);try{let o=await ke({...s,auth:t,isApiKey:e,onDebug:r}),i=o.config.scorecardClassic||o.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=o.config.pluginsUrl,c=a?await Le(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(o){throw new m(o instanceof Error?o.message:String(o))}}function Oe(n){let t=new URL(n),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 ke({residency:n,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:o}){let i=new URL(`${n}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:Be(r,s)});if(o?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw o?.(`Authentication failed with status ${a.status}.`),o?.("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 o?.("Successfully received project configuration."),a.json()}async function Le(n,t){t?.(`Fetching plugins from: ${n}`);try{let e=await fetch(n);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 Be(n,t){return t?{Authorization:`Bearer ${n}`}:{Cookie:`accessToken=${n}`}}async function L(n,t,e=[],r=[],s){let o={};for(let i of e){let a={[i.name]:{root:n,rules:t}},c=await Y({apis:a,...i,plugins:r},{configPath:s});o[i.name]=c.forAlias(i.name)}return o}function B(n,t){if(n){for(let e of n)if(Object.entries(e.where?.metadata||{}).every(([s,o])=>Me(s,o,t)))return e}}function Me(n,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[n])return!1;let[r,s]=t.split("/"),o=new Date(e[n]);return!(o<new Date(r)||s&&o>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[n])return!1;try{return q(t).test(e[n])}catch{throw new m(`Invalid regex in scorecard target "${n}": ${t}`)}}return e[n]===t}import{pathToFileURL as We}from"node:url";async function be(n,t){if(!n)return[];let e=We(t??process.cwd()).href+"/",r=n.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var ze=".redocly.com";function He(n){try{return new URL(n).hostname.toLowerCase().endsWith(ze)}catch{return!1}}async function qe({apiPath:n,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:o=[],targetLevel:i,metadata:a={},onDebug:c}){let $=[],_=new Map,v=r.levels||[];if(i&&!v.some(l=>l.name===i))throw new m(`Target level "${i}" not found in the scorecard configuration levels.
|
|
7
|
+
import{a as K}from"./GKXY6U4S.js";import{Aa as V,j as z,l as I,o as H,oa as m,p as q,ta as Y}from"./ACMV5RZA.js";import{e as b}from"./RFWIIJFG.js";var Q=b(K(),1);var T=b(K(),1);function G(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function X(n){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(n).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var Z=async(n,{timeout:t,...e}={})=>{let r=G(),s=r&&!X(n),o;s?o=new T.ProxyAgent({uri:r}):t&&(o=new T.Agent({connect:{timeout:t}}));try{return await(0,T.fetch)(n,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:o})}catch(i){throw await o?.destroy(),i}};var de=/^[\x21-\x7e]+( [\x21-\x7e]+)*$/;function J(){let n=process.env.REDOCLY_ENVIRONMENT?.trim();return n&&de.test(n)?n:void 0}var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},x=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r=J(),s={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}${r?` ${r}`:""}`};try{let o=await Z(t,{...e,headers:s});return this.collectSunsetWarning(o),o}catch(o){let i=o.cause??o,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)}},U=class{client;domain;apiKey;constructor(t,e,r){this.client=t,this.domain=e,this.apiKey=r}async getParsedResponse(t){let e=await t.json();if(t.ok)return e;throw new u(`${e.title||t.statusText||"Unknown error"}.`,t.status)}},N=class extends U{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",Authorization:`Bearer ${this.apiKey}`}});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)}}},j=class extends U{async getDefaultBranch(t,e){try{let r=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/source`,{timeout:6e3,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return(await this.getParsedResponse(r)).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",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({mountPath:r.mountPath,mountBranchName:r.mountBranchName,type:"CICD",autoMerge:!0})});return await this.getParsedResponse(s)}catch(s){let o=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}async push(t,e,r,s){let o=new Q.FormData;o.append("remoteId",r.remoteId),o.append("commit[message]",r.commit.message),o.append("commit[author][name]",r.commit.author.name),o.append("commit[author][email]",r.commit.author.email),o.append("commit[branchName]",r.commit.branchName),r.commit.url&&o.append("commit[url]",r.commit.url),r.commit.namespace&&o.append("commit[namespaceId]",r.commit.namespace),r.commit.sha&&o.append("commit[sha]",r.commit.sha),r.commit.repository&&o.append("commit[repositoryId]",r.commit.repository),r.commit.createdAt&&o.append("commit[createdAt]",r.commit.createdAt);for(let i of s){let a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await he(i.stream)]);o.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&o.append("isMainBranch","true"),r.replace&&o.append("replace","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:o});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",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let o=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(o,s.status):new Error(o)}}},g=class{apiClient;projects;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new x(r,s),this.projects=new N(this.apiClient,t,e),this.remotes=new j(this.apiClient,t,e)}getSunsetWarning(){return ee(this.apiClient.sunsetWarnings)}};function ee(n){let[t]=[...n].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function he(n){let t=[];for await(let e of n)t.push(e);return Buffer.concat(t)}function fe(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var pe=/^http:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/,R={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function me(){return process.env.REDOCLY_DOMAIN||R.us}var te=ge((n,t)=>{try{let e=t||n?.resolvedConfig.residency;return we(e)?R[e]:e?new URL(e).origin:n?.resolvedConfig.scorecard?.fromProjectUrl?new URL(n.resolvedConfig.scorecard.fromProjectUrl).origin:R.us}catch{throw new E}});function D(n){try{te(void 0,n)}catch{return!1}return!0}function ge(n){return(...t)=>{let e=n(...t);if(!e.startsWith("https://")&&!pe.test(e))throw new E;return e}}var E=class extends Error{constructor(){super("Invalid Reunite URL")}};function we(n){return typeof n=="string"&&n in R}import{Buffer as O}from"node:buffer";import F from"node:crypto";import{mkdirSync as ye,existsSync as ne,writeFileSync as ve,readFileSync as Te,rmSync as xe}from"node:fs";import{homedir as Ce}from"node:os";import se from"node:path";import*as re from"node:child_process";var w=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new x("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]];re.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,o)=>{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),o(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),o("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:o=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:o,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let o=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(o,{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 Pe="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",oe="aes-256-cbc",k=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=Ce();this.credentialsFolderPath=se.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=se.join(this.credentialsFolderPath,this.credentialsFileName),this.key=F.createHash("sha256").update(`${this.credentialsFolderPath}${Pe}`).digest(),this.iv=F.createHash("md5").update(this.credentialsFolderPath).digest(),ye(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new w(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 w(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new w(t,this.version),r=await this.readCredentials();if(!r||!D(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let o=await e.refreshToken(r.refresh_token);return await this.saveCredentials(o),o.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);ve(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!ne(this.credentialsFilePath))return null;try{let t=Te(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){ne(this.credentialsFilePath)&&xe(this.credentialsFilePath)}encryptCredentials(t){let e=F.createCipheriv(oe,this.key,this.iv);return O.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=F.createDecipheriv(oe,this.key,this.iv),r=O.concat([e.update(O.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as y from"node:fs";import*as h from"node:path";var Re=/\/orgs\/([^/]+)\/projects\//,Ee=[401,403];async function C(n,{organization:t,project:e,onSlugDeprecated:r}){let s=await $e(n,t,e);if(!s)return{organizationId:t,projectId:e};let o={organizationId:_e(s.uri),projectId:s.id};return(o.organizationId!==t||o.projectId!==e)&&r?.(o),o}async function $e(n,t,e){try{let r=await n.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&&Ee.includes(r.status))return;throw r}}function _e(n){let t=n.match(Re)?.[1];if(!t)throw new Error(`Could not read the organization ID from the project URI "${n}".`);return t}async function Se({domain:n,apiKey:t,organization:e,project:r,mountPath:s,files:o,defaultBranch:i,commit:a,version:c,replace:$,onUploadStart:_,onSunsetWarning:v,onSlugDeprecated:A}){let f=new g({domain:n,apiKey:t,command:"push",version:c});try{let{organizationId:d,projectId:l}=await C(f,{organization:e,project:r,onSlugDeprecated:A}),M=await f.remotes.getDefaultBranch(d,l),p=await f.remotes.upsert(d,l,{mountBranchName:M,mountPath:s});_?.(p);let{id:P}=await f.remotes.push(d,l,{remoteId:p.id,commit:a,isMainBranch:i===a.branchName,replace:$},o.map(W=>({path:H(W.name),stream:y.createReadStream(W.path)})));return{pushId:P,organizationId:d,projectId:l}}finally{let d=f.getSunsetWarning();d&&v?.(d)}}function Ue(n,t){let e={};for(let s of n)if(y.statSync(s).isDirectory()){let o=s;ie(o,[]).forEach(a=>r(a,o))}else r(s,h.dirname(s));function r(s,o){let i=h.relative(o,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,o])=>({name:s,path:h.resolve(o)}))}function ie(n,t){let e=y.readdirSync(n);for(let r of e){let s=h.join(n,r);y.statSync(s).isDirectory()?t=ie(s,t):t.push(s)}return t}async function ae({operation:n,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:o=5e3}){async function i(){let a=await n();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await z(o),i()}return i()}var Fe=1200,Ae=5e3,Ie=["pending","running"];async function Ne(n){let t=ce(n);try{let e=await C(t,n);return await le(t,e,n.pushId)}finally{ue(t,n)}}async function je({buildType:n,maxExecutionTime:t=Fe,retryIntervalMs:e=Ae,startTime:r=Date.now(),onRetry:s,...o}){let i=ce(o);try{let a=await C(i,o);return await ae({operation:()=>le(i,a,o.pushId),condition:c=>!Ie.includes(c.status[n].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ue(i,o)}}function ce({domain:n,apiKey:t,version:e}){return new g({domain:n,apiKey:t,command:"push-status",version:e})}function ue(n,{onSunsetWarning:t}){let e=n.getSunsetWarning();e&&t?.(e)}function le(n,{organizationId:t,projectId:e},r){return n.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function De({projectUrl:n,auth:t,isApiKey:e=!1,onDebug:r}){let s=Oe(n);if(!s)throw new m(`Invalid project URL format: ${n}`);try{let o=await ke({...s,auth:t,isApiKey:e,onDebug:r}),i=o.config.scorecardClassic||o.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=o.config.pluginsUrl,c=a?await Le(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(o){throw new m(o instanceof Error?o.message:String(o))}}function Oe(n){let t=new URL(n),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 ke({residency:n,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:o}){let i=new URL(`${n}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:Be(r,s)});if(o?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw o?.(`Authentication failed with status ${a.status}.`),o?.("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 o?.("Successfully received project configuration."),a.json()}async function Le(n,t){t?.(`Fetching plugins from: ${n}`);try{let e=await fetch(n);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 Be(n,t){return t?{Authorization:`Bearer ${n}`}:{Cookie:`accessToken=${n}`}}async function L(n,t,e=[],r=[],s){let o={};for(let i of e){let a={[i.name]:{root:n,rules:t}},c=await Y({apis:a,...i,plugins:r},{configPath:s});o[i.name]=c.forAlias(i.name)}return o}function B(n,t){if(n){for(let e of n)if(Object.entries(e.where?.metadata||{}).every(([s,o])=>Me(s,o,t)))return e}}function Me(n,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[n])return!1;let[r,s]=t.split("/"),o=new Date(e[n]);return!(o<new Date(r)||s&&o>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[n])return!1;try{return q(t).test(e[n])}catch{throw new m(`Invalid regex in scorecard target "${n}": ${t}`)}}return e[n]===t}import{pathToFileURL as We}from"node:url";async function be(n,t){if(!n)return[];let e=We(t??process.cwd()).href+"/",r=n.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var ze=".redocly.com";function He(n){try{return new URL(n).hostname.toLowerCase().endsWith(ze)}catch{return!1}}async function qe({apiPath:n,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:o=[],targetLevel:i,metadata:a={},onDebug:c}){let $=[],_=new Map,v=r.levels||[];if(i&&!v.some(l=>l.name===i))throw new m(`Target level "${i}" not found in the scorecard configuration levels.
|
|
8
8
|
`);let A=B(r.targets,a)?.rules,f=await L(n,A,v,o,s||"");for(let l of v){c?.(`
|
|
9
9
|
Validating level: "${l.name}"`),o.length>0&&c?.(`Using ${o.length} ${I("plugin",o.length)} for this level.`),c?.("Linting document against level rules...");let p=(await V({document:t,externalRefResolver:e,config:f[l.name]})).filter(({ignored:P})=>!P).map(P=>({...P,scorecardLevel:l.name}));c?.(`Found ${p.length} ${I("problem",p.length)} for level "${l.name}".`),_.set(l.name,p),$.push(...p)}let d=Ye(_,v,i);return{problems:$,achievedLevel:d,targetLevelAchieved:i?d===i:!0}}function Ye(n,t,e){let r=null;for(let s of t){if((n.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,x as b,g as c,ee as d,fe as e,R as f,me as g,te as h,D as i,E as j,w as k,k as l,C as m,Se as n,Ue as o,Ne as p,je as q,De as r,L as s,B as t,be as u,He as v,qe as w};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{f as k}from"./
|
|
7
|
+
import{f as k}from"./BC3XCWQE.js";import{a as B}from"./7RQW6KPZ.js";import{a as x,e as P,f as v,i as H,j as C,k as p,l as M}from"./LD5MEXEL.js";import{n as N}from"./UW4UC7ZI.js";function y(e){let t=new Map(e.pathParams.map(r=>[r.name,r])),n=[];for(let r of e.path.matchAll(/\{([^{}]+)\}/g)){let s=t.get(r[1]);s!==void 0&&n.push(s)}return n}function I(e){let t=y(e),n=e.queryParams.length>0,r=!!e.requestBody,s=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:n,hasBody:r,hasHeaders:s,hasCookies:o,hasInputs:t.length>0||n||r||s||o,varsRequired:t.length>0||e.queryParams.some(a=>a.required)||(e.requestBody?.required??!1)||e.headerParams.some(a=>a.required)||e.cookieParams.some(a=>a.required),variablesTypeName:`${p(e.name)}Variables`}}var E=" ";function $(e,t,n){let r=C(e,t);return r===void 0?[]:[`${n}/**`,...H(r).split(`
|
|
8
8
|
`).map(s=>`${n} * ${s}`.replace(/ +$/,"")),`${n} */`]}function O(e){return typeof e=="string"?JSON.stringify(e):String(e)}function F(e,t,n){switch(e){case"string":return t?.format==="binary"?"Blob":n==="Date"&&(t?.format==="date-time"||t?.format==="date")?"Date":"string";case"number":case"integer":return"number";case"boolean":return"boolean"}}function j(e){return e.kind==="union"||e.kind==="intersection"||e.kind==="enum"&&e.values.length>1}function c(e,t="string",n=""){switch(e.kind){case"scalar":return F(e.scalar,e.metadata,t);case"ref":return e.name;case"literal":return O(e.value);case"enum":return e.values.map(O).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let r=c(e.items,t,n);return j(e.items)?`(${r})[]`:`${r}[]`}case"record":return`Record<string, ${c(e.value,t,n)}>`;case"object":{if(e.properties.length===0)return"{}";let r=n+E;return`{
|
|
9
9
|
${e.properties.flatMap(o=>K(o,t,r)).join(`
|
|
10
10
|
`)}
|
|
@@ -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"./QNCKZURN.js";import"./OYUXHAGQ.js";import"./5IIJHGNO.js";import"./BC3XCWQE.js";import"./7RQW6KPZ.js";import"./WZXA5XPB.js";import"./ACMV5RZA.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{a as swrGenerator};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{c as U}from"./NR3R4HFM.js";import{b as R,c as F,d as G,e as L,f as V,g as ae,h as z,i as ie,j as ce}from"./BC3XCWQE.js";import{a as ne,c as T,d as N,e as D,g as Y,h as B,i as te,j as se,k as oe,l as K,n as re}from"./UW4UC7ZI.js";var M=T.python,j=class extends ne{constructor(){super(" ")}typeName(n){return N(n,{style:"pascal",reserved:M})}memberName(n){let t=N(n,{style:"snake",reserved:M});return{identifier:t,renamed:t!==n}}identifier(n){return N(n,{style:"snake",reserved:M})}identifiers(n,t){return D(n,{style:"snake",reserved:M,taken:t})}constName(n){return N(n,{style:"screaming",reserved:M})}string(n){let t='"';for(let s of n){let r=s.codePointAt(0);s==="\\"?t+="\\\\":s==='"'?t+='\\"':s===`
|
|
8
|
+
`?t+="\\n":s==="\r"?t+="\\r":s===" "?t+="\\t":r<32||r===127?t+=`\\x${r.toString(16).padStart(2,"0")}`:r>=55296&&r<=57343?t+=`\\u${r.toString(16).padStart(4,"0")}`:t+=s}return t+'"'}literal(n){return n==null?"None":n===!0?"True":n===!1?"False":typeof n=="number"?String(n):typeof n=="string"?this.string(n):Array.isArray(n)?`[${n.map(s=>this.literal(s)).join(", ")}]`:`{${Object.entries(n).map(([s,r])=>`${this.string(s)}: ${this.literal(r)}`).join(", ")}}`}comment(n){for(let t of K(n))this.line(t===""?"#":`# ${t}`);return this}doc(n){let t=K(n);if(t.length===0)return this;if(t.length===1)return this.line(`"""${t[0]}"""`);this.line(`"""${t[0]}`);for(let s of t.slice(1))this.line(s);return this.line('"""')}};var x=T.python,f=new j;function O(e){return f.typeName(e)}function q(e){let{identifier:n,renamed:t}=f.memberName(e);return{python:n,renamed:t}}function I(e){let n=e.services.flatMap(s=>s.operations),t=D(n.map(s=>s.name),{style:"snake",reserved:x});return n.map((s,r)=>({op:s,ident:t[r]}))}var W=["self","body","headers","timeout","retry","idempotency_key"];function le(e){return f.literal(e)}function de(e){if(e!==void 0)return{style:e.style,...e.param!==void 0?{param:e.param}:{},...e.nextCursor!==void 0?{next_cursor:e.nextCursor}:{},...e.hasMore!==void 0?{has_more:e.hasMore}:{},...e.nextLink!==void 0?{next_link:e.nextLink}:{},...e.limitParam!==void 0?{limit_param:e.limitParam}:{},...e.items!==void 0?{items:e.items}:{}}}function pe(e,n){let t=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let a=N(r.name,{style:"snake",reserved:x}),c=a,i=2;for(;t.has(c);)c=`${a}_${i++}`;t.add(c);let m=re(r.schema,n);return`(${f.string(r.name)}, ${f.string(c)}, ${f.string(m)})`}).join(", ")}]`}function h(e,n="string"){if(te(e))return`Optional[${h(se(e),n)}]`;switch(e.kind){case"scalar":if(n==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"datetime";if(e.metadata?.format==="date")return"date"}return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":return`List[${h(e.items,n)}]`;case"record":return`Dict[str, ${h(e.value,n)}]`;case"ref":return O(e.name);case"literal":return`Literal[${f.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(t=>h(t,n)).join(", ")}]`;case"null":return"None";case"omit":return O(e.base);case"object":case"intersection":case"unknown":return"Any"}}function J(e,n,t,s,r,a,c,i=!1){let m=D([...n.pathParams,...n.queryParams].map(S=>S.name),{style:"snake",reserved:x,taken:W}),l=n.pathParams.map((S,v)=>({param:S,python:m[v]})),o=n.queryParams.map((S,v)=>({param:S,python:m[n.pathParams.length+v]})),d=l.map(({param:S,python:v})=>`${v}: ${h(S.schema,a)}`),u=L(n)||n.requestBody!==void 0&&V(n.requestBody.contentType),y=n.requestBody?[`body: ${u?"Any":h(n.requestBody.schema,a)}`]:[],b=[...o.map(({param:S,python:v})=>{let A=h(S.schema,a),E=A.startsWith("Optional[")?A:`Optional[${A}]`;return`${v}: ${E} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],$=R(n),k=F(n),P=i?`Envelope[${$===void 0?"None":h($,a)}]`:k!==void 0?`${r?"AsyncIterator":"Iterator"}[ServerSentEvent]`:s==="result"?"Result":$===void 0?"None":h($,a),p=r&&k===void 0?"async def":"def",_=r?"await ":"",g=r?"send_async":"send",w=["self",...d,...y,"*",...b].join(", "),H=i?`${t}_with_headers`:t;e.block(`${p} ${H}(${w}) -> ${P}:`,()=>{e.doc(i?`Like ${t}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${t}"]`),e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)'),e.line("params: Dict[str, Any] = dict(auth_query)");for(let{param:E,python:C}of o)e.block(`if ${C} is not None:`,()=>{e.line(`params[${f.string(E.name)}] = encode(${C})`)});let S=l.map(({param:E,python:C})=>`${f.string(E.name)}: ${C}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${S}})`),k!==void 0){let E=k.schema!==void 0&&k.schema.kind!=="unknown"?"json":"text";e.block("def _open(extra_headers: Dict[str, str]):",()=>{e.line('return self._http.stream(op["method"], url, headers={**auth_headers, **(headers or {}), **extra_headers}, params=params, timeout=timeout)')}),e.line(`return ${r?"aiter_sse":"iter_sse"}(_open, data_kind="${E}")`);return}G(n)&&!L(n)&&e.line("form_data, form_files = to_multipart(body)");let v=n.requestBody?L(n)?", **multipart_arguments(body)":G(n)?", data=form_data, files=form_files":V(n.requestBody.contentType)?`, content=body, content_type=${f.string(n.requestBody.contentType)}`:", json_body=encode(body)":"";e.line(`response = ${_}${g}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params=params${v}, timeout=timeout, retry=retry, idempotency_key=idempotency_key)`);let A=$===void 0?"None":`decode(${h($,a)}, _safe_json(response))`;i?(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(`return Envelope(data=${A}, headers=read_envelope_headers(response, ${pe(n,c)}), response=response)`)):s==="result"?(e.block("if not response.is_success:",()=>{e.line("return Result(data=None, error=_safe_json(response), response=response)")}),e.line(`return Result(data=${A}, error=None, response=response)`)):(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line($===void 0?"return None":`return ${A}`))}),e.blank()}function me(e,n,t,s,r,a){let c=R(n),i=c===void 0?"Any":h(c,a),m=D([...n.pathParams,...n.queryParams].map(p=>p.name),{style:"snake",reserved:x,taken:W}),l=n.pathParams.map((p,_)=>({param:p,python:m[_]})),o=n.queryParams.map((p,_)=>({param:p,python:m[n.pathParams.length+_]})),d=l.map(({param:p,python:_})=>`${_}: ${h(p.schema,a)}`),u=[...o.map(({param:p,python:_})=>{let g=h(p.schema,a),w=g.startsWith("Optional[")?g:`Optional[${g}]`;return`${_}: ${w} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],y=["self",...d,"*",...u].join(", "),b=s?"AsyncIterator":"Iterator",$=s?"aiter_pages":"iter_pages",k=s?"aiter_items":"iter_items",P=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:g,python:w}of o)e.block(`if ${w} is not None:`,()=>{e.line(`base[${f.string(g.name)}] = encode(${w})`)});let p=s?"async def":"def",_=s?"await ":"";e.block(`${p} _page(page_params: Dict[str, Any]) -> Tuple[Any, Any]:`,()=>{e.line('auth_headers, auth_query = resolve_auth(op.get("security") or [], self._auth)');let g=l.map(({param:w,python:H})=>`${f.string(w.name)}: ${H}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${g}})`),e.line(`response = ${_}${s?"send_async":"send"}(self._http, self._config, op, url, method=op["method"], headers={**auth_headers, **(headers or {})}, params={**page_params, **auth_query}, timeout=timeout, retry=retry)`),e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line("return _safe_json(response), response")})};s?(e.block(`async def ${t}_pages(${y}) -> ${b}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for page in ${$}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${t}_items(${y}) -> ${b}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for item in ${k}(_page, op["pagination"], base):`,()=>{e.line(r==="Any"?"yield item":`yield decode(${r}, item)`)})})):(e.block(`def ${t}_pages(${y}) -> ${b}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(i==="Any"?`return ${$}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${$}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${t}_items(${y}) -> ${b}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(r==="Any"?`return ${k}(_page, op["pagination"], base)`:`return (decode(${r}, item) for item in ${k}(_page, op["pagination"], base))`)})),e.blank()}function he(e){return ae(e).map(t=>t.kind==="literal"?f.string(t.value):q(t.name).python).join(" + ")}function fe(e,n){let t=n.servers??[];if(t.length===0)return;let s=new Set;e.block("class Servers:",()=>{e.line('"""The declared servers; variables default to the values from the description."""'),e.blank(),t.forEach((r,a)=>{let c=N(r.description??`server${a+1}`,{style:"snake",reserved:x});s.has(c)&&(c=`${c}_${a+1}`),s.add(c);let i=r.variables.map(m=>`${q(m.name).python}: str = ${f.string(m.default)}`);a>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${c}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${he(r)}`)})})}),e.blank()}function Q(e,n,t,s,r,a,c){let i=s?"AsyncClient":"Client",m=s?"httpx.AsyncClient":"httpx.Client";e.block(`class ${i}:`,()=>{e.doc(`${s?"Async ":""}client for ${n.title} (${n.version}).`),e.block(`def __init__(self, server_url: str = ${f.string(a)}, *, auth: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, timeout: Optional[float] = None, retry: Optional[Dict[str, Any]] = None, middleware: Optional[List[Any]] = None, idempotency_key: Any = None, http_client: Optional[${m}] = None) -> None:`,()=>{e.line("self._server_url = server_url"),e.line("self._auth = auth or {}"),e.line("self._config: Dict[str, Any] = {"),e.indent(()=>{e.line('"headers": headers or {},'),e.line('"timeout": timeout,'),e.line('"retry": retry or {},'),e.line('"middleware": middleware or [],'),e.line('"idempotency_key": idempotency_key,')}),e.line("}"),e.line(`self._http = http_client or ${m}()`)}),e.blank();for(let{op:l,ident:o}of I(n)){J(e,l,o,t,s,c),F(l)===void 0&&(l.successResponseHeaders?.length??0)>0&&J(e,l,o,t,s,c,n,!0);let d=r.get(o);if(d!==void 0){let u=R(l),y=ie(u,typeof d.items=="string"?d.items:void 0,n);me(e,l,o,s,y===void 0?"Any":h(y,c),c)}}}),e.blank()}function X(e){let n=new Map,t=new Set,s=[];for(let{name:a,schema:c}of e.schemas){let i=B(c,e);if(!(i===void 0||!i.cases.every(l=>Y(l.schema,e)?.properties.some(o=>o.name===i.property)===!0))){for(let l of i.cases){let o=n.get(l.schemaName);if(o!==void 0&&o.value!==l.value){t.add(l.schemaName);continue}n.set(l.schemaName,{property:i.property,value:l.value})}s.push({name:a,property:i.property,members:i.cases.map(l=>l.schemaName)})}}let r=new Map;for(let a of s)a.members.some(c=>t.has(c))||r.set(a.name,q(a.property).python);for(let a of t)n.delete(a);return{pins:n,unions:r}}function ye(e,n,t,s,r,a,c){let i=r==="pydantic";i||e.line("@dataclass");let m=i?`class ${O(n)}(BaseModel):`:`class ${O(n)}:`;e.block(m,()=>{e.doc(a),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let l=[...t.filter(d=>d.required),...t.filter(d=>!d.required)],o=[];l.length===0&&e.line("pass");for(let d of l){let{python:u,renamed:y}=q(d.name);y&&!i&&o.push([u,d.name]);let b=y&&i?`alias=${f.string(d.name)}`:void 0,$=c?.property===d.name?`Literal[${f.literal(c.value)}]`:h(d.schema,s);if(d.required){let k=b===void 0?"":` = Field(${b})`;e.line(`${u}: ${$}${k}`)}else{let k=$.startsWith("Optional[")?$:`Optional[${$}]`,P=b===void 0?"None":`Field(default=None, ${b})`;e.line(`${u}: ${k} = ${P}`)}}if(o.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let d=o.map(([u,y])=>`"${u}": ${f.string(y)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${d}}`)}}),e.blank(),e.blank()}function Z(e,n="string",t="dataclass"){let s=new j,{pins:r,unions:a}=t==="pydantic"?X(e):{pins:new Map,unions:new Map};s.line("from __future__ import annotations"),s.blank(),t==="dataclass"&&s.line("from dataclasses import dataclass"),s.line("from enum import Enum");let c=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];t==="dataclass"&&c.splice(2,0,"ClassVar"),a.size>0&&c.unshift("Annotated"),s.line(`from typing import ${c.join(", ")}`),t==="pydantic"&&s.line("from pydantic import BaseModel, ConfigDict, Field"),n==="Date"&&s.line("from datetime import date, datetime"),s.blank(),s.blank();let i=[];for(let{name:m,schema:l}of e.schemas){let o=oe(l);if(o!==void 0){let d=o.scalar==="string"?"str, Enum":"int, Enum";s.block(`class ${O(m)}(${d}):`,()=>{s.doc(l.description),o.values.forEach((u,y)=>{s.line(`${o.memberNames[y]} = ${f.literal(u)}`)})}),s.blank(),s.blank();continue}if(l.kind==="object"||l.kind==="intersection"){let d=Y(l,e);if(d!==void 0){ye(s,m,d.properties,n,t,d.description??l.description,r.get(m));continue}}i.push(()=>{let d=B(l,e);if(d!==void 0){let b=d.cases.map($=>`${$.value} -> ${O($.schemaName)}`).join(", ");s.line(`# Discriminated by "${d.property}": ${b}`)}let u=a.get(m),y=u===void 0?h(l,n):`Annotated[${h(l,n)}, Field(discriminator=${f.string(u)})]`;s.line(`${O(m)} = ${y}`),s.blank()})}for(let m of i)m();return s.toString()}function ue(e,n){let t=[];for(let{name:s,schema:r}of e.schemas){if(n.has(s))continue;let a=B(r,e);if(a===void 0)continue;let c=a.cases.map(i=>`${f.string(i.value)}: ${O(i.schemaName)}`).join(", ");t.push(`DISCRIMINATORS[${O(s)}] = (${f.string(a.property)}, {${c}})`)}return t}var on={type:"object",properties:{models:{enum:["dataclass","pydantic"],default:"dataclass",description:"Model style: standard-library dataclasses (default, httpx is the only dependency), or pydantic BaseModel classes (adds pydantic)."}},additionalProperties:!1};function ee(e){let n=e.lastIndexOf("/")>=0?"/":"\\",t=e.lastIndexOf(n),s=t>=0?e.slice(0,t+1):"",r=(t>=0?e.slice(t+1):e).replace(/\.[^.]+$/,"");return`${s}${N(r,{style:"snake",reserved:x})}.py`}var rn=({model:e,output:n,banner:t,emit:s,options:r,pagination:a})=>{let c=s.errorMode??"throw",i=s.dateType??"string",m=r?.models??"dataclass",l=m==="pydantic"?X(e):void 0,o=new j;if(o.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),o.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),o.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),o.blank(),o.line(Z(e,i,m).trimEnd()),o.blank(),o.blank(),fe(o,e),s.runtime==="module"){o.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let p of Object.keys(U))o.line(`from ${p.replace(/\.py$/,"")} import *`);o.blank(),o.blank()}else{o.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let p of Object.values(U)){let _=p.split(`
|
|
9
|
+
`).filter(g=>!g.startsWith("from __future__")&&!g.startsWith("from ._")).join(`
|
|
10
|
+
`).trim();o.line(_),o.blank()}o.blank()}let d=ue(e,new Set(l?.unions.keys()));if(d.length>0){o.line("# Discriminated unions dispatch by their property inside decode().");for(let p of d)o.line(p);o.blank()}o.block("def _safe_json(response: httpx.Response) -> Any:",()=>{o.block("try:",()=>{o.line("return response.json()")}),o.block("except Exception:",()=>{o.line("return None")})}),o.blank();let u=new Map;for(let{op:p,ident:_}of I(e))u.set(_,de(a?.get(p.name)?.spec));o.line("_OPERATIONS = {"),o.indent(()=>{for(let{op:p,ident:_}of I(e)){let g={id:p.specName??p.name,method:p.method.toUpperCase(),path:p.path,...z(p,e).length>0?{security:z(p,e)}:{},...u.get(_)!==void 0?{pagination:u.get(_)}:{}};o.line(`"${_}": ${le(g)},`)}}),o.line("}"),o.blank(),o.blank();let y=s.serverUrl??e.serverUrl??"";Q(o,e,c,!1,u,y,i),Q(o,e,c,!0,u,y,i);let b={path:ee(n.path),content:o.toString()};if(s.runtime!=="module")return[b];let $=t.map(p=>`# ${p}`).join(`
|
|
11
|
+
`),k=ee(n.path).replace(/[^\\/]+$/,""),P=Object.entries(U).map(([p,_])=>({path:`${k}${p}`,content:`${$}
|
|
12
|
+
|
|
13
|
+
${_.split(`
|
|
14
|
+
`).map(g=>g.startsWith("from ._")?g.replace("from ._","from _"):g).join(`
|
|
15
|
+
`).trim()}
|
|
16
|
+
`}));return[b,...P]};function $e(e,n){let t=ee(n.outputPath).replace(/^.*[\\/]/,"").replace(/\.py$/,""),s=I(n.model).find(a=>a.op.name===e.name)?.ident??N(e.name,{style:"snake",reserved:x}),r=[...e.pathParams.map(a=>{let c=N(a.name,{style:"snake",reserved:x});return`${c}="<${c}>"`}),...e.queryParams.filter(a=>a.required).map(a=>`${N(a.name,{style:"snake",reserved:x})}=...`),...e.requestBody?["body=..."]:[]];return{lang:"python",label:"Python SDK",source:`from ${t} import Client
|
|
17
|
+
|
|
18
|
+
client = Client()
|
|
19
|
+
result = client.${s}(${r.join(", ")})
|
|
20
|
+
`}}var an=({model:e,output:n,emit:t,pagination:s})=>[{path:n.path.replace(/\.[^.\\/]+$/,".python.md"),content:ce(e,{title:`${e.title} Python SDK reference`,frontmatter:t.docsFrontmatter===!0,language:{name:"python",label:"Python",fence:"python",requires:"The SDK needs `httpx`."},sample:r=>$e(r,{model:e,emit:t,outputPath:n.path}),paginated:new Set(s?.keys()??[])})}];export{h as a,Z as b,on as c,rn as d,$e as e,an as f};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{ia as r}from"./
|
|
7
|
+
import{a as o,b as t,c as e}from"./HBUZKWXC.js";import{ia as r}from"./ACMV5RZA.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{spawn as p}from"node:child_process";var u=async({argv:n})=>{r.info(`
|
|
8
8
|
Launching translate using NPX.
|
|
9
9
|
|
|
10
10
|
`);let{npxExecutableName:s,sanitize:a,shell:i}=e(),l=a(n["project-dir"],o),c=a(n.locale,t);p(s,["-y","@redocly/realm","translate",c,`-d=${l}`],{stdio:"inherit",shell:i}).on("error",m=>{throw r.info(`Translate launch failed: ${m.message}`),new Error("Translate launch failed.")})};export{u as handleTranslations};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as T,b as O,c as A,d as E}from"./
|
|
7
|
+
import{a as T,b as O,c as A,d as E}from"./KMP5ZE2D.js";import{c as m,k as C,r as $}from"./3LGZAJES.js";import{a as q}from"./GKXY6U4S.js";import{c as H,ia as u,oa as y,pa as R}from"./ACMV5RZA.js";import"./NEWT5A6S.js";import{e as z}from"./RFWIIJFG.js";import{createReadStream as F,createWriteStream as k,existsSync as N}from"node:fs";import{appendFile as V,mkdir as _,rm as j,writeFile as W}from"node:fs/promises";import B from"node:path";import{createInterface as G}from"node:readline";var w=class{outputPath;entriesPath;creatorVersion;writeChain=Promise.resolve();directoryEnsured=!1;started=!1;count=0;constructor(t,r){this.outputPath=B.resolve(process.cwd(),t),this.entriesPath=`${this.outputPath}.entries.tmp`,this.creatorVersion=r}get entryCount(){return this.count}add(t){let r=`${JSON.stringify(t)}
|
|
8
8
|
`,n=this.writeChain.catch(()=>{}).then(()=>this.append(r)).then(()=>{this.count+=1});return this.writeChain=n.catch(()=>{}),n}async finalize(){await this.writeChain.catch(()=>{}),await this.ensureDirectory(),await this.writeDocument(),await j(this.entriesPath,{force:!0})}async append(t){if(await this.ensureDirectory(),!this.started){await W(this.entriesPath,t,"utf8"),this.started=!0;return}await V(this.entriesPath,t,"utf8")}async ensureDirectory(){this.directoryEnsured||(await _(B.dirname(this.outputPath),{recursive:!0}),this.directoryEnsured=!0)}async writeDocument(){let t=k(this.outputPath,{encoding:"utf8"}),r=n=>new Promise((o,s)=>{t.write(n,i=>i?s(i):o())});try{let n=JSON.stringify({name:"redocly-cli proxy",version:this.creatorVersion});await r(`{
|
|
9
9
|
"log": {
|
|
10
10
|
"version": "1.2",
|
|
@@ -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{b as m,j as C,o as a,p,q as T,r as l,s as h,t as f,u as d}from"./
|
|
7
|
+
import{b as m,j as C,o as a,p,q as T,r as l,s as h,t as f,u as d}from"./3LGZAJES.js";import{c as g}from"./ACMV5RZA.js";import A from"node:path";function L(e,n){if(C(e)!=="application/x-www-form-urlencoded"||!Array.isArray(n))return;let o=new URLSearchParams;for(let s of n){if(!g(s))continue;let t=a(s.name);t!==void 0&&o.append(t,a(s.value)??"")}return o.size>0?o.toString():void 0}function K(e,n,o){let s=e?.request,t=e?.response;if(!s)return null;let r=s?.postData,i=a(r?.mimeType),u=r?.text??L(i,r?.params),c=a(r?.encoding),y=t?.content?.text,S=a(t?.content?.encoding),q=p(t?.status);return l({method:a(s?.method),url:a(s?.url),requestHeaders:s?.headers,requestBody:T(u,c),requestContentType:i,responseStatus:q===0?void 0:q,responseStatusText:a(t?.statusText),responseHeaders:t?.headers,responseBody:T(y,S),responseContentType:a(t?.content?.mimeType),startedAt:a(e?.startedDateTime),raw:e},n,o)}var b=class{id="har";canParse(n,o){if(A.extname(n).toLowerCase()===".har")return!0;let t=o.toLowerCase();return t.includes('"log"')&&t.includes('"entries"')}async*parse(n){let o=0;for await(let s of f(n,"log.entries")){let t=K(s,o,n);t&&(yield t),o+=1}}};import $ from"node:path";function H(e){let n=a(e.url??e.uri);if(n)return{url:n};let o=a(e.host??e.headers?.host),s=a(e.path??e.request_uri),t=a(e.scheme??e.forwarded_proto);return o&&s?{url:`${t??"http"}://${o}${s}`,schemeKnown:!!t}:{url:s,schemeKnown:!!t}}function z(e,n,o){let s=e?.request??e?.req??e?.http?.request;if(!s)return null;let t=e?.response??e?.res??e?.http?.response,r=t?.body??t?.raw_body??t?.payload??t?.data,i=s?.body??s?.raw_body??s?.payload??s?.data,{url:u,schemeKnown:c}=H(s);return l({method:a(s?.method??s?.http_method),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:i,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode),responseHeaders:t?.headers,responseBody:r,responseContentType:d(t?.headers),startedAt:a(e?.started_at??e?.startedAt??e?.timestamp),raw:e},n,o)}var x=class{id="kong";canParse(n,o){if($.extname(n).toLowerCase()===".kong")return!0;let t=o.toLowerCase();return t.includes('"latencies"')||t.includes('"request"')&&t.includes('"response"')&&t.includes('"route"')}async*parse(n){let o=(await m(n,16)).trim().slice(0,1),s=0;if(o==="["){for await(let t of f(n)){let r=z(t,s,n);r&&(yield r),s+=1}return}for await(let t of h(n)){let r=z(t,s,n);r&&(yield r),s+=1}}};import R from"node:path";function U(e){return e?.request??e?.req??e?.httpRequest??e?.http?.request??e}function I(e){return e?.response??e?.res??e?.httpResponse??e?.http?.response}function O(e,n){let o=a(n?.url??n?.uri??n?.requestUrl??e?.url);if(o)return{url:o};let s=a(n?.host??n?.headers?.host??e?.host),t=a(n?.path??e?.path??n?.pathname),r=a(n?.scheme??e?.scheme);return s&&t?{url:`${r??"http"}://${s}${t}`,schemeKnown:!!r}:{url:t,schemeKnown:!!r}}function k(e,n,o){let s=U(e),t=I(e),r=s?.body??s?.bodyText??s?.payload??s?.data??s?.rawBody,i=t?.body??t?.bodyText??t?.payload??t?.data??t?.rawBody,{url:u,schemeKnown:c}=O(e,s);return l({method:a(s?.method??s?.httpMethod??e?.method??e?.httpMethod),url:u,schemeKnown:c,requestHeaders:s?.headers,requestBody:r,requestContentType:d(s?.headers),responseStatus:p(t?.status??t?.statusCode??e?.status??e?.statusCode),responseHeaders:t?.headers,responseBody:i,responseContentType:d(t?.headers),startedAt:a(e?.startedAt??e?.timestamp??e?.time),raw:e},n,o)}var w=class{id="ndjson";canParse(n,o){let s=R.extname(n).toLowerCase();if(s===".ndjson"||s===".jsonl"||s===".jsonlines")return!0;let t=o.lastIndexOf(`
|
|
8
8
|
`),i=(t===-1?o:o.slice(0,t)).split(`
|
|
9
9
|
`).map(u=>u.trim()).find(Boolean);if(!i?.startsWith("{")||!i.endsWith("}"))return!1;try{return JSON.parse(i),!0}catch{return!1}}async*parse(n){let o=0;for await(let s of h(n)){let t=k(s,o,n);t&&(yield t),o+=1}}};import J from"node:path";function P(e){if(!e)return{};let n=e.trim().split(/\s+/);return n.length<2?{}:{method:n[0],path:n[1],protocol:n[2]}}function W(e,n){let o=a(n?.url??n?.request_uri??n?.uri??e?.url??e?.request_url??e?.absolute_uri),s=P(a(e?.request??n?.request_line)),t=a(n?.request_uri??n?.uri??n?.path??e?.request_uri??e?.uri)??s.path;if(o?.startsWith("http://")||o?.startsWith("https://"))return{url:o};let r=a(n?.host??n?.headers?.host??e?.host??e?.http_host??e?.server_name??e?.vhost),i=a(e?.scheme??n?.scheme??e?.request_scheme),u=!!i;if(r&&(o||t)){let c=i??"http",y=o??t;return y?.startsWith("/")?{url:`${c}://${r}${y}`,schemeKnown:u}:{url:`${c}://${r}/${y}`,schemeKnown:u}}return{url:o??t,schemeKnown:u}}function E(e,n,o){let s=g(e?.request)?e.request:e,t=g(e?.response)?e.response:void 0,r=P(a(e?.request)),i=a(s?.method??s?.request_method??e?.request_method??e?.method)??r.method,{url:u,schemeKnown:c}=W(e,s);return l({method:i,url:u,schemeKnown:c,requestHeaders:s?.headers??s?.request_headers??e?.request_headers??e?.headers,requestBody:s?.body??s?.request_body??e?.request_body??e?.body,requestContentType:d(s?.headers??s?.request_headers??e?.request_headers),responseStatus:p(t?.status??t?.status_code??e?.status??e?.status_code??e?.response_status),responseHeaders:t?.headers??t?.response_headers??e?.response_headers??e?.headers_out,responseBody:t?.body??t?.response_body??e?.response_body,responseContentType:d(t?.headers??t?.response_headers??e?.response_headers),startedAt:a(e?.time_iso8601??e?.timestamp??e?.time??e?.time_local??e?.["@timestamp"]),raw:e},n,o)}async function*j(e){if((await m(e,16)).trim().slice(0,1)==="["){yield*f(e);return}for await(let o of h(e))yield o}var N=class{id="nginx-json";canParse(n,o){let s=J.extname(n).toLowerCase(),t=n.toLowerCase();if(s===".ndjson"&&t.includes("nginx"))return!0;let r=o.toLowerCase();return r.includes('"request_uri"')||r.includes('"time_iso8601"')||r.includes('"upstream_response_time"')||r.includes('"remote_addr"')}async*parse(n){let o=0;for await(let s of j(n)){let t=E(s,o,n);t&&(yield t),o+=1}}},_=class{id="apache-json";canParse(n,o){let s=J.extname(n).toLowerCase(),t=n.toLowerCase();if(s===".ndjson"&&t.includes("apache"))return!0;let r=o.toLowerCase();return r.includes('"request_method"')||r.includes('"request_uri"')||r.includes('"vhost"')||r.includes('"response_status"')}async*parse(n){let o=0;for await(let s of j(n)){let t=E(s,o,n);t&&(yield t),o+=1}}};var B=[new b,new x,new N,new _,new w];async function le(e,n){if(n!=="auto"){let s=B.find(t=>t.id===n);if(!s)throw new Error(`Unsupported parser format: ${n}`);return s}let o=await m(e);return B.find(s=>s.canParse(e,o))}export{le 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{c as a,d as b}from"./
|
|
7
|
+
import{c as a,d as b}from"./E2D25T4G.js";import"./7RQW6KPZ.js";import"./WZXA5XPB.js";import"./ACMV5RZA.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as generateClient,a as runGenerators};
|
|
@@ -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 h}from"./
|
|
7
|
+
import{a as h}from"./7RQW6KPZ.js";import{e as g,h as p,k as $}from"./LD5MEXEL.js";import{join as R}from"node:path";var a=" ";function m(e){return`${$(e)}Schema`}var y=new Map;function u(e,r=y,t=""){return j(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return z(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${m(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return q(e.values);case"union":return k(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return E(e.base,e.keys,r,t)}}function z(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
|
|
8
8
|
${e.map((s,i)=>{let d=u(s.schema,r,n),l=s.required?d:`${d}.optional()`,x=i===e.length-1?"":",";return`${n}${c(s.name)}: ${l}${x}`}).join(`
|
|
9
9
|
`)}
|
|
10
10
|
${t}})`}function q(e){return e.every(r=>typeof r=="string")?`z.enum([${e.map(r=>JSON.stringify(r)).join(", ")}])`:`z.union([${e.map(r=>`z.literal(${p(r)})`).join(", ")}])`}function k(e,r,t){let n=e.map(o=>u(o,r,t));return n.length===1?n[0]:`z.union([${n.join(", ")}])`}function E(e,r,t,n){let o=t.get(e);if(o&&o.kind!=="object")return u(f(o,r,t,new Set([e])),t,n);let s=r.map(i=>`${c(i)}: true`).join(", ");return`${m(e)}.omit({ ${s} })`}function f(e,r,t,n){switch(e.kind){case"object":return{...e,properties:e.properties.filter(o=>!r.includes(o.name))};case"union":case"intersection":return{...e,members:e.members.map(o=>f(o,r,t,n))};case"ref":{if(n.has(e.name))return e;let o=t.get(e.name);if(!o)return e;if(o.kind==="object"){let s=r.filter(i=>o.properties.some(d=>d.name===i));return s.length>0?{kind:"omit",base:e.name,keys:s}:e}return f(o,r,t,new Set([...n,e.name]))}default:return e}}function j(e,r){let t=r.metadata;if(!t)return e;let n=e;return r.kind==="scalar"&&r.scalar==="string"&&(t.minLength!==void 0&&(n=`${n}.min(${t.minLength})`),t.maxLength!==void 0&&(n=`${n}.max(${t.maxLength})`),t.pattern!==void 0&&(n=`${n}.regex(new RegExp(${JSON.stringify(t.pattern)}))`)),r.kind==="scalar"&&(r.scalar==="number"||r.scalar==="integer")&&(t.minimum!==void 0&&(n=`${n}.min(${t.minimum})`),t.maximum!==void 0&&(n=`${n}.max(${t.maximum})`),t.exclusiveMinimum!==void 0&&(n=`${n}.gt(${t.exclusiveMinimum})`),t.exclusiveMaximum!==void 0&&(n=`${n}.lt(${t.exclusiveMaximum})`)),r.kind==="array"&&(t.minItems!==void 0&&(n=`${n}.min(${t.minItems})`),t.maxItems!==void 0&&(n=`${n}.max(${t.maxItems})`)),n}function Z(e,r){let t=[];for(let n of h(e.services)){if(n.sse!==void 0)continue;let o=n.requestBody,s=o&&o.contentType.toLowerCase().includes("json")?u(o.schema,r,a):void 0,i=n.successResponses.find(l=>l.contentType.toLowerCase().includes("json")),d=i?u(i.schema,r,a):void 0;!s&&!d||t.push({name:n.specName??n.name,request:s,response:d})}return t}function I(e){let r=e.flatMap(n=>[`${a}${c(n.name)}: {`,...n.request?[`${a}${a}request: z.ZodType;`]:[],...n.response?[`${a}${a}response: z.ZodType;`]:[],`${a}};`]),t=e.map((n,o)=>{let s=[...n.request?[`request: ${n.request}`]:[],...n.response?[`response: ${n.response}`]:[]].join(", "),i=o===e.length-1?"":",";return`${a}${c(n.name)}: { ${s} }${i}`});return["/**"," * Request/response validators by operationId \u2014 powers `zodValidation`, or import one directly."," */","export const operationSchemas: {",...r,"} = {",...t,"};"].join(`
|