@redocly/cli 2.44.0 → 2.44.2
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 +4 -4
- package/lib/chunks/{J46HWXZ6.js → 53K3ZVCM.js} +86 -86
- package/lib/chunks/{WWPXYCJE.js → AFAIVO72.js} +1 -1
- package/lib/chunks/{UUKR7FEE.js → BBQVVF2F.js} +1 -1
- package/lib/chunks/{PKEPRIA3.js → BCPSMPMX.js} +1 -1
- package/lib/chunks/BXI4SF2U.js +59 -0
- package/lib/chunks/{IXOJYSW4.js → CF4MVP77.js} +1 -1
- package/lib/chunks/{ASFBZUY5.js → CHVKBAVV.js} +7 -7
- package/lib/chunks/{JTFBO6YU.js → D5ZEYUAL.js} +1 -1
- package/lib/chunks/{2Q5SN6X4.js → HBXV5HMH.js} +1 -1
- package/lib/chunks/{RZY3J6PM.js → HLDA4F5Q.js} +122 -122
- package/lib/chunks/{6K7ZCWZR.js → IFK6ZEAO.js} +1 -1
- package/lib/chunks/{LCC3O74U.js → JK66AU25.js} +1 -1
- package/lib/chunks/{EFU2RD5U.js → KIILLIDR.js} +1 -1
- package/lib/chunks/{JMYL7BXB.js → SCYQIGUP.js} +1 -1
- package/lib/chunks/{JF4SD24U.js → SMB572YO.js} +1 -1
- package/lib/chunks/{76KU55V5.js → U2QTS6KO.js} +1 -1
- package/lib/chunks/{MMOQBN5Y.js → UHQJTZST.js} +1 -1
- package/lib/chunks/{QLQQS5L4.js → X37JXMEY.js} +1 -1
- package/lib/chunks/{SIC26ONQ.js → Y2L4DX4K.js} +1 -1
- package/lib/chunks/{6H3RG723.js → YULFUHLK.js} +1 -1
- package/lib/index.js +86 -86
- package/package.json +1 -1
- package/lib/chunks/O6MCQRCP.js +0 -59
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c as p}from"./P26PQ2RU.js";import{a as O}from"./RS5PUOTT.js";import{a as R}from"./
|
|
7
|
+
import{c as p}from"./P26PQ2RU.js";import{a as O}from"./RS5PUOTT.js";import{a as R}from"./X37JXMEY.js";import{a as I}from"./BXI4SF2U.js";import{G as T,I as w,O as a}from"./53K3ZVCM.js";import{e as C}from"./RFWIIJFG.js";import{Buffer as P}from"node:buffer";import y from"node:crypto";import{mkdirSync as j,existsSync as F,writeFileSync as q,readFileSync as z,rmSync as M}from"node:fs";import{homedir as H}from"node:os";import B from"node:path";var l={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function G(){return process.env.REDOCLY_DOMAIN||l.us}var U=D((o,e)=>{try{let t=e||o?.resolvedConfig.residency;return W(t)?l[t]:t?new URL(t).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:l.us}catch{throw new f}});function x(o){try{U(void 0,o)}catch{return!1}return!0}function D(o){return(...e)=>{let t=o(...e);if(!t.startsWith("https://"))throw new f;return t}}var f=class extends Error{constructor(){super("Invalid Reunite URL")}};function W(o){return typeof o=="string"&&o in l}import*as k from"node:child_process";var g=C(I(),1);var N=C(O(),1);function b(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function S(o){let e=process.env.NO_PROXY||process.env.no_proxy;if(!e)return!1;let t=e.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(t.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return t.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var _=async(o,{timeout:e,...t}={})=>{let r=b(),s=r&&!S(o),n,i=e?{connect:{timeout:e}}:{};return s?n=new g.ProxyAgent({uri:r,...i}):e&&(n=new g.Agent(i)),await fetch(o,{signal:e?AbortSignal.timeout(e):void 0,...t,dispatcher:n})};var c=class extends Error{constructor(t,r){super(t);this.status=r}status},h=class{constructor(e){this.command=e}command;sunsetWarnings=[];async request(e,t){let r={...t.headers,"user-agent":`redocly-cli/${R} ${this.command}`};try{let s=await _(e,{...t,headers:r});return this.collectSunsetWarning(s),s}catch(s){let n="Failed to fetch.";throw s.cause&&(n+=` Caused by ${s.cause.message||s.cause.name}.`),(s.code||s.cause?.code)&&(n+=` Code: ${s.code||s.cause?.code}`),new Error(n)}}collectSunsetWarning(e){let t=this.getSunsetDate(e);if(!t)return;let r=new Date(t);t>Date.now()?this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!1}):this.sunsetWarnings.push({sunsetDate:r,isSunsetExpired:!0})}getSunsetDate(e){let{headers:t}=e;if(!t)return;let r=t.get("sunset")||t.get("Sunset");if(r)return Date.parse(r)}},v=class{constructor(e,t,r){this.client=e;this.domain=t;this.apiKey=r}client;domain;apiKey;async getParsedResponse(e){let t=await e.json();if(e.ok)return t;throw new c(`${t.title||e.statusText||"Unknown error"}.`,e.status)}async getDefaultBranch(e,t){try{let r=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/source`,{timeout:p,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 c?new c(s,r.status):new Error(s)}}async upsert(e,t,r){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/remotes`,{timeout:p,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 n=`Failed to upsert remote. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}async push(e,t,r,s){let n=new globalThis.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 u=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await L(i.stream)]);n.append(`files[${i.path}]`,u,i.path)}r.isMainBranch&&n.append("isMainBranch","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:n});return await this.getParsedResponse(i)}catch(i){let u=`Failed to push. ${i.message}`;throw i instanceof c?new c(u,i.status):new Error(u)}}async getRemotesList({organizationId:e,projectId:t,mountPath:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/remotes?filter=mountPath:/${r}/`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get remote list. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}async getPush({organizationId:e,projectId:t,pushId:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${e}/projects/${t}/pushes/${r}`,{timeout:p,method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}});return await this.getParsedResponse(s)}catch(s){let n=`Failed to get push status. ${s.message}`;throw s instanceof c?new c(n,s.status):new Error(n)}}},$=class{apiClient;command;remotes;constructor({domain:e,apiKey:t,command:r}){this.command=r,this.apiClient=new h(this.command),this.remotes=new v(this.apiClient,e,t)}reportSunsetWarnings(){let e=this.apiClient.sunsetWarnings;if(e.length){let[{isSunsetExpired:t,sunsetDate:r}]=e.sort((n,i)=>n.isSunsetExpired!==i.isSunsetExpired?n.isSunsetExpired?-1:1:n.sunsetDate>i.sunsetDate?1:-1),s='Update to the latest version by running "npm install @redocly/cli@latest".';t?a.error(`The "${this.command}" command is not compatible with your version of Redocly CLI. ${s}
|
|
8
8
|
|
|
9
9
|
`):a.warn(`The "${this.command}" command will be incompatible with your version of Redocly CLI after ${r.toLocaleString()}. ${s}
|
|
10
10
|
|
|
@@ -5,4 +5,4 @@ const require = __createRequire(import.meta.url);
|
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
7
|
import{a as fe}from"./WZXA5XPB.js";import"./RFWIIJFG.js";function ce(e){return e}async function V(e){return typeof e=="function"?await e():e}function le(e){let t="";for(let n of new TextEncoder().encode(e))t+=String.fromCharCode(n);return btoa(t)}function pe(e,t){return e.kind==="apiKey"?t.auth?.apiKey?.[e.scheme]!==void 0:e.kind==="bearer"?t.auth?.bearer!==void 0:t.auth?.basic!==void 0}async function Q(e,t){let n=e.find(d=>d.every(a=>pe(a,t)))??e[0]??[],o={},r={},s=[];for(let d of n)if(d.kind==="apiKey"){let a=t.auth?.apiKey?.[d.scheme];if(a===void 0)continue;let c=await V(a);d.in==="header"?o[d.name]=c:d.in==="query"?r[d.name]=c:s.push(`${d.name}=${encodeURIComponent(c)}`)}else if(d.kind==="bearer"){let a=t.auth?.bearer;a!==void 0&&(o.Authorization=`Bearer ${await V(a)}`)}else{let a=t.auth?.basic;a!==void 0&&(o.Authorization=`Basic ${le(`${a.username}:${a.password}`)}`)}return s.length>0&&(o.Cookie=s.join("; ")),{headers:o,query:r}}var S=class extends Error{url;status;statusText;body;constructor(t,n,o,r){super(`Request failed with status ${n}`),this.name="ApiError",this.url=t,this.status=n,this.statusText=o,this.body=r}},O=class extends Error{operationId;timeout;attempt;constructor(t,n,o){super(`Request "${t}" timed out after ${n} ms (attempt ${o})`),this.name="TimeoutError",this.operationId=t,this.timeout=n,this.attempt=o}};function j(e){let t=e.reason;return t instanceof Error?t:new DOMException("The operation was aborted.","AbortError")}async function P(e,t){if(t==="void"){if(e.status===204||e.status===205||e.status===304||!(e.headers.get("content-type")??"").toLowerCase().includes("json"))return;let s=await e.text().catch(()=>"");if(s==="")return;try{return JSON.parse(s)}catch{return}}if(e.status===204)return;if(t==="stream")return e.body;if(t==="blob")return e.blob();if(t==="arrayBuffer")return e.arrayBuffer();if(t==="formData")return e.formData();if(t==="text")return e.text();if(t==="json")return e.json();let n=(e.headers.get("content-type")??"").toLowerCase();if(n.includes("json"))return e.json();if(n.startsWith("text/"))return e.text();let o=await e.blob();return o.size>0?o:void 0}async function k(e){return(e.headers.get("content-type")??"").toLowerCase().includes("json")?e.json().catch(()=>{}):e.text().catch(()=>{})}var me=new Set(["GET","HEAD","PUT","DELETE","OPTIONS"]),ye=new Set([408,429,500,502,503,504]);function U(e){return me.has(e.request.method.toUpperCase())||"Idempotency-Key"in e.request.headers||"idempotency-key"in e.request.headers?e.response===void 0||ye.has(e.response.status):!1}function z(e,t,n){if(n){let s=Number(n);if(!Number.isNaN(s))return s*1e3;let d=Date.parse(n);if(!Number.isNaN(d))return Math.max(0,d-Date.now())}let o=e.retryDelay??1e3,r=e.retryStrategy==="fixed"?o:o*Math.pow(2,t-1);return e.jitter===!1?r:Math.random()*r}function $(e,t){return new Promise((n,o)=>{if(t?.aborted){o(j(t));return}let r=()=>{clearTimeout(s),o(j(t))},s=setTimeout(()=>{t&&t.removeEventListener("abort",r),n()},e);t&&t.addEventListener("abort",r,{once:!0})})}function D(e){if(e===void 0)return{};if(e instanceof Headers){let t={};return e.forEach((n,o)=>{t[o]=n}),t}return Array.isArray(e)?Object.fromEntries(e):e}function _(e){return[...e.onRequest||e.onResponse||e.onError?[{onRequest:e.onRequest,onResponse:e.onResponse,onError:e.onError}]:[],...e.middleware??[]]}async function I(e,t,n,o,r,s,d,a="application/json"){let{retry:c,timeout:f,idempotencyKey:u,...i}=o,l={...e.retry,...c},p=f??e.timeout,m=u??e.idempotencyKey,E=typeof e.headers=="function"?await e.headers():e.headers,A={Accept:a,...E,...D(i.headers)},B=(i.method??"GET").toUpperCase();m!==void 0&&m!==!1&&(B==="POST"||B==="PATCH")&&!("Idempotency-Key"in A)&&!("idempotency-key"in A)&&(A["Idempotency-Key"]=typeof m=="string"?m:typeof m=="function"?m():crypto.randomUUID()),typeof e.clientHeader=="string"&&typeof document>"u"&&!("X-Redocly-Client"in A)&&!("x-redocly-client"in A)&&(A["X-Redocly-Client"]=e.clientHeader);let y={url:n,method:i.method??"GET",headers:A,body:r,operation:t},T=_(e);for(let h of T)h.onRequest&&await h.onRequest(y);let R;if(y.body!==void 0){let h=y.body,w=h instanceof Blob||h instanceof ArrayBuffer||ArrayBuffer.isView(h),g=typeof FormData<"u"&&h instanceof FormData,L=h instanceof URLSearchParams;if(g||L||w||typeof h=="string")R=h;else if(s?.multipart===!0){if(!d.serializeMultipart)throw new Error("Multipart capability not wired: cannot serialize the request body");R=d.serializeMultipart(h)}else R=JSON.stringify(h),!("Content-Type"in y.headers)&&!("content-type"in y.headers)&&(y.headers["Content-Type"]=s?.contentType??"application/json")}let q=e.fetch??fetch,v=1+(l.retries??0),C=l.retryOn??U,x=i.signal??void 0,b=0;for(;;){if(b++,x?.aborted)throw j(x);let h=p?x?AbortSignal.any([x,AbortSignal.timeout(p)]):AbortSignal.timeout(p):x,w;try{w=await q(y.url,{...i,signal:h,method:y.method,headers:y.headers,body:R})}catch(g){if(b<v&&!x?.aborted&&await C({attempt:b,request:y,error:g})){await $(z(l,b,null),x);continue}throw p&&!x?.aborted&&g instanceof DOMException&&g.name==="TimeoutError"?new O(t.id,p,b):g}for(let g=T.length-1;g>=0;g--){let L=T[g].onResponse;if(L){let H=await L(w,y);H&&H!==w&&(await w.body?.cancel().catch(()=>{}),w=H)}}if(!w.ok&&b<v&&!x?.aborted&&await C({attempt:b,request:y,response:w})){let g=w.headers.get("retry-after");await w.body?.cancel().catch(()=>{}),await $(z(l,b,g),x);continue}return{response:w,context:y}}}function M(e){return encodeURIComponent(e).replace(/%(3A|2F|3F|23|5B|5D|40|21|24|26|27|28|29|2A|2B|2C|3B|3D)/g,t=>decodeURIComponent(t))}function X(e,t){return e.replace(/\{([^{}]+)\}/g,(n,o)=>{let r=t[o];if(r===void 0)throw new Error(`Missing path parameter "${o}"`);return encodeURIComponent(String(r))})}function Y(e,t,n,o){let r=e.length;for(;r>0&&e.charCodeAt(r-1)===47;)r--;let s=e.slice(0,r)+t;if(!n)return s;let d=new URLSearchParams,a=[];for(let[f,u]of Object.entries(n)){if(u==null)continue;let i=o?.[f];if(!i){if(Array.isArray(u))for(let l of u)l!=null&&d.append(f,String(l));else if(Object(u)===u)for(let[l,p]of Object.entries(u))p!=null&&d.append(`${f}[${l}]`,String(p));else d.append(f,String(u));continue}if(Array.isArray(u)){let l=u.filter(p=>p!=null).map(String);if(i.style==="form"&&i.explode)for(let p of l)i.allowReserved?a.push(`${f}=${M(p)}`):d.append(f,p);else{let p=i.style==="pipeDelimited"?"|":i.style==="spaceDelimited"?"%20":",",m=i.allowReserved?M:encodeURIComponent;a.push(`${encodeURIComponent(f)}=${l.map(m).join(p)}`)}}else if(Object(u)===u)for(let[l,p]of Object.entries(u))p!=null&&(i.allowReserved?a.push(`${f}[${l}]=${M(String(p))}`):d.append(`${f}[${l}]`,String(p)));else i.allowReserved?a.push(`${f}=${M(String(u))}`):d.append(f,String(u))}let c=[d.toString(),...a].filter(Boolean).join("&");return c?`${s}?${c}`:s}function te(e){return e==="text"?"text/*":e==="blob"||e==="arrayBuffer"||e==="stream"||e==="formData"?"*/*":"application/json"}function re(e){return e.responseKind==="void"||e.responseKind==="blob"||e.responseKind==="text"?e.responseKind:"auto"}function he(e,t){let n={},o=new Set;for(let r of e.params??[])r.in==="path"&&(o.add(r.name),n[r.name]=t[r.name]);for(let r of Object.keys(t))if(!(r==="params"||r==="body"||r==="headers"||r==="cookies")&&!o.has(r))throw new TypeError(`Unknown argument "${r}" for operation "${e.id}". Query parameters go under params: { \u2026 } and the request body under body; valid keys are params, body, headers, cookies`+(o.size>0?`, and the path parameters (${[...o].join(", ")}).`:"."));return{path:n,query:t.params,body:t.body,headers:t.headers,cookies:t.cookies}}function we(e){let t;for(let n of e.params??[])n.in!=="query"||!(n.style!==void 0&&n.style!=="form"||n.explode===!1||n.allowReserved===!0)||(t??={},t[n.name]={style:n.style??"form",explode:n.explode??!0,allowReserved:n.allowReserved});return t}function be(e){let t={};for(let[n,o]of Object.entries(e??{}))o!=null&&(t[n]=String(o));return t}async function J(e,t,n,o,r){let{path:s,query:d,body:a,headers:c,cookies:f}=he(t,n),u=t.security?.length&&r.resolveAuth?await r.resolveAuth(t.security,e):{headers:{},query:{}},i=Object.entries(f??{}).filter(([,E])=>E!=null).map(([E,A])=>`${E}=${encodeURIComponent(String(A))}`);i.length>0&&(u.headers.Cookie=[u.headers.Cookie,...i].filter(Boolean).join("; "));let l={...d,...u.query},p=Y(e.serverUrl??"",X(t.path,s),Object.keys(l).length>0?l:void 0,we(t)),m={...o,method:t.method.toUpperCase(),headers:{...u.headers,...be(c),...D(o.headers)}};return{url:p,init:m,body:a}}function xe(e,t){if(e!==null){if(t==="number"){if(e.trim()==="")return;let n=Number(e);return Number.isFinite(n)?n:void 0}if(t==="boolean"){let n=e.trim().toLowerCase();return n==="true"?!0:n==="false"?!1:void 0}return e}}function ge(e,t){let n={};for(let o of t??[]){let r=xe(e.headers.get(o.name),o.type);r!==void 0&&(n[o.key]=r)}return n}async function Ee(e,t,n,o,r){let s=await J(e,t,n,o,r),d={id:t.id,path:t.path,tags:[...t.tags??[]]},{parseAs:a,envelope:c,...f}=s.init,u=a??re(t),{response:i,context:l}=await I(e,d,s.url,f,s.body,t.body,r,te(u));if(e.errorMode==="result")return i.ok?{data:await P(i,u),error:void 0,response:i}:{data:void 0,error:await k(i),response:i};if(!i.ok){let m=new S(l.url,i.status,i.statusText,await k(i));for(let E of _(e))E.onError&&(m=await E.onError(m,l));throw m}let p=await P(i,u);return c===!0?{data:p,headers:ge(i,t.responseHeaders),response:i}:p}function F(e,t){if(!e.paginate)throw new Error(`Pagination capability not wired: cannot iterate operation "${t.id}"`);return e.paginate}function Z(e,t){let n=(o,r)=>{if(!r||r.envelope===void 0)return e(o,r);let{envelope:s,...d}=r;return e(o,d)};return t.errorMode!=="result"?n:async(o,r)=>{let s=await n(o,r);if(!s.response.ok){let{response:d}=s;throw new S(d.url,d.status,d.statusText,s.error)}return s.data}}function ee(e,t,n){return async(o={},r={})=>{let s=await J(e,t,o,r,n),{parseAs:d,envelope:a,...c}=s.init,f=d??re(t),u={id:t.id,path:t.path,tags:[...t.tags??[]]},{response:i}=await I(e,u,s.url,c,s.body,t.body,n,te(f));if(!i.ok)throw new S(s.url,i.status,i.statusText,await k(i));return{page:await P(i,f),linkHeader:i.headers.get("link"),url:i.url===""?s.url:i.url}}}function ne(e,t={},n={}){let o=t,r={...o,middleware:[...o.middleware??[]]},s={};for(let[d,a]of Object.entries(e))if(a.responseKind==="sse"){let c=(f={},u={})=>{if(!n.sse)throw new Error(`SSE capability not wired: cannot stream operation "${a.id}"`);let i=n.sse;return(async function*(){let l={id:a.id,path:a.path,tags:[...a.tags??[]]};yield*i(r,l,async()=>{let m=await J(r,a,f,u,n);return{url:m.url,init:m.init,body:m.body}},a.sseDataKind??"text")})()};Object.defineProperty(c,"name",{value:d}),Object.defineProperty(c,"operationId",{value:a.id}),s[d]=c}else{let c=(u={},i={})=>Ee(r,a,u,i,n);Object.defineProperty(c,"name",{value:d}),Object.defineProperty(c,"operationId",{value:a.id});let f=a.pagination;s[d]=f===void 0?c:f.style==="link"?Object.assign(c,{pages:(u,i)=>F(n,a).pagesByLink(ee(r,a,n),u,i),items:(u,i)=>F(n,a).itemsByLink(ee(r,a,n),f,u,i)}):Object.assign(c,{pages:(u,i)=>F(n,a).pages(Z(c,r),f,u,i),items:(u,i)=>F(n,a).items(Z(c,r),f,u,i)})}return s.configure=d=>{let{errorMode:a,auth:c,...f}=d;Object.assign(r,f),c&&(r.auth={...r.auth,...c,...c.apiKey?{apiKey:{...r.auth?.apiKey,...c.apiKey}}:{}})},s.use=(...d)=>{r.middleware=[...r.middleware??[],...d]},s.auth={bearer(d){r.auth={...r.auth,bearer:d}},basic(d,a){r.auth={...r.auth,basic:{username:d,password:a}}},apiKey(d,a){r.auth={...r.auth,apiKey:{...r.auth?.apiKey,[d]:a}}}},s}function oe(e){let t=new FormData,n=(o,r)=>{r!=null&&(r instanceof Blob||typeof r=="string"?t.append(o,r):r instanceof Date?t.append(o,r.toISOString()):Object(r)===r?t.append(o,JSON.stringify(r)):t.append(o,String(r)))};for(let[o,r]of Object.entries(e))if(Array.isArray(r))for(let s of r)n(o,s);else n(o,r);return t}function N(e,t){if(t==="")return e;if(!t.startsWith("/"))return;let n=e;for(let o of t.slice(1).split("/")){let r=o.replaceAll("~1","/").replaceAll("~0","~");if(Array.isArray(n)){if(!/^(0|[1-9]\d*)$/.test(r))return;n=n[Number(r)]}else if(Object(n)===n&&r in n)n=n[r];else return}return n}async function*G(e,t,n={},o){if(t.style==="cursor"){let r=n.params?.[t.param];for(;;){let s={...n.params};r!==void 0&&(s[t.param]=r);let d=await e({...n,params:s},o);if(yield d,t.hasMore!==void 0&&N(d,t.hasMore)===!1)return;let a=N(d,t.nextCursor);if(a==null||a==="")return;if(typeof a!="string"&&typeof a!="number")throw new Error(`Pagination cursor at ${t.nextCursor} is not a string or number`);if(a===r)throw new Error("Pagination did not advance: operation returned the same cursor twice");r=a}}else{if(t.style==="link")throw new Error("link-style pagination iterates via pagesByLink");{let r=n.params?.[t.param],s=t.style==="page"?1:0,a=r==null||r===""||Number.isNaN(Number(r))?s:Number(r),c;for(;;){let f=await e({...n,params:{...n.params,[t.param]:a}},o),u=N(f,t.items),i=Array.isArray(u)?JSON.stringify(u):void 0;if(i!==void 0&&i===c)throw new Error("Pagination did not advance: the operation returned the same page twice");if(yield f,!Array.isArray(u)||u.length===0)return;c=i,a+=t.style==="page"?1:u.length}}}}async function*ie(e,t,n,o){for await(let r of G(e,t,n,o)){let s=N(r,t.items);Array.isArray(s)&&(yield*s)}}function ve(e){if(e!==null)for(let t of e.split(/,\s*(?=<)/)){let n=/^\s*<([^>]*)>(.*)$/.exec(t);if(!n)continue;let o=/;\s*rel\s*=\s*"?([^";]+)"?/i.exec(n[2]);if(o&&o[1].split(/\s+/).includes("next"))return n[1]}}async function*W(e,t={},n){let o=t.params,r;for(;;){let{page:s,linkHeader:d,url:a}=await e({...t,params:o},n);yield s;let c=ve(d);if(c===void 0)return;let f=new URL(a,"http://relative.invalid"),u=new URL(c,f).toString();if(u===r||u===f.toString())throw new Error('Pagination did not advance: the Link rel="next" target repeats');r=u;let i={};for(let[l,p]of new URL(u).searchParams){let m=i[l];m===void 0?i[l]=p:Array.isArray(m)?m.push(p):i[l]=[m,p]}o={...t.params,...i}}}async function*ae(e,t,n,o){for await(let r of W(e,n,o)){let s=N(r,t.items);Array.isArray(s)&&(yield*s)}}var Se=/(?:\r\n|\r|\n){2}/,K=class extends Error{};async function*de(e,t,n,o="text"){let r,s,d=0;for(;;){let{url:a,init:c,body:f}=await n(),{reconnect:u=!0,reconnectDelay:i,...l}=c,p=l.signal??void 0;if(p?.aborted)return;let m={Accept:"text/event-stream",...D(l.headers)},E=r===void 0?m:{...m,"Last-Event-ID":r};try{let{response:y}=await I(e,t,a,{...l,method:l.method??"GET",headers:E,timeout:0},f,void 0,{});if(!y.ok){let C=await k(y);throw new S(a,y.status,y.statusText,C)}d=0;let T=y.body;if(!T)return;let R=T.getReader(),q=new TextDecoder,v="";try{for(;;){let{done:C,value:x}=await R.read();v+=C?q.decode():q.decode(x,{stream:!0});let b;for(;(b=Se.exec(v))!==null;){let h=v.slice(0,b.index);v=v.slice(b.index+b[0].length);let w=se(h,o);w&&(w.id!==void 0&&(r=w.id),w.retry!==void 0&&(s=w.retry),yield w)}if(C){let h=v.length>0?se(v,o):void 0;h&&(h.id!==void 0&&(r=h.id),h.retry!==void 0&&(s=h.retry),yield h);return}if(v.length>1048576)throw new K("SSE frame exceeded 1048576 characters without a delimiter")}}finally{await R.cancel().catch(()=>{})}}catch(y){if(p?.aborted)return;if(y instanceof S||y instanceof K||!u)throw y}d++;let B=Math.min((s??i??1e3)*Math.pow(2,d-1),3e4);try{await $(Math.random()*B,p)}catch{return}}}function se(e,t){let n,o=[],r,s,d=!1;for(let f of e.split(/\r\n|\n|\r/)){if(f===""||f.startsWith(":"))continue;let u=f.indexOf(":"),i=u===-1?f:f.slice(0,u),l=u===-1?"":f.slice(u+1);l.startsWith(" ")&&(l=l.slice(1)),d=!0,i==="event"?n=l:i==="data"?o.push(l):i==="id"?r=l:i==="retry"&&/^\d+$/.test(l)&&(s=Number(l))}if(!d)return;let a=o.join(`
|
|
8
|
-
`),c=a;if(t==="json"&&a!=="")try{c=JSON.parse(a)}catch(f){throw new K(`Failed to parse SSE event data as JSON: ${f instanceof Error?f.message:String(f)}`)}return{event:n,data:c,id:r,retry:s}}function ue(e,t={}){return{...e?.config,...t,middleware:[...e?.middleware??[],...t.middleware??[]]}}function Ae(e,t){return ne(e,t,{serializeMultipart:oe,resolveAuth:Q,sse:de,paginate:{pages:G,items:ie,pagesByLink:W,itemsByLink:ae}})}function Re(e,t){let n={...e};for(let[o,r]of Object.entries(t))r!==void 0&&(n[o]=r);return n}function it(e){return e}async function st(e){return(await import("./
|
|
8
|
+
`),c=a;if(t==="json"&&a!=="")try{c=JSON.parse(a)}catch(f){throw new K(`Failed to parse SSE event data as JSON: ${f instanceof Error?f.message:String(f)}`)}return{event:n,data:c,id:r,retry:s}}function ue(e,t={}){return{...e?.config,...t,middleware:[...e?.middleware??[],...t.middleware??[]]}}function Ae(e,t){return ne(e,t,{serializeMultipart:oe,resolveAuth:Q,sse:de,paginate:{pages:G,items:ie,pagesByLink:W,itemsByLink:ae}})}function Re(e,t){let n={...e};for(let[o,r]of Object.entries(t))r!==void 0&&(n[o]=r);return n}function it(e){return e}async function st(e){return(await import("./CF4MVP77.js")).generateClient(e)}export{S as ApiError,fe as NotSupportedError,O as TimeoutError,Ae as createClient,U as defaultRetryOn,ce as defineClientSetup,it as defineGenerator,st as generateClient,Re as mergeConfig,ue as mergeSetup};
|