@redocly/cli 2.54.1 → 2.54.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 +1 -1
- package/lib/chunks/{Q7ARG2G6.js → 26SMEC4W.js} +1 -1
- package/lib/chunks/{23QBFBKB.js → 32ZHA42N.js} +1 -1
- package/lib/chunks/{2MBZI3W3.js → 3UYF5CLP.js} +1 -1
- package/lib/chunks/{4G34OIRT.js → 42DSSM4F.js} +1 -1
- package/lib/chunks/{2NS7AGPD.js → 42HL7XQH.js} +1 -1
- package/lib/chunks/{AM6FT7EB.js → 4UWA75AV.js} +1 -1
- package/lib/chunks/{BYIMEGON.js → 5H5SOEIM.js} +1 -1
- package/lib/chunks/{UWNBPAWG.js → 5KKTVK6L.js} +1 -1
- package/lib/chunks/{J7GIHRZA.js → 73UEREUT.js} +1 -1
- package/lib/chunks/{XFRPQNF6.js → 7GJ7DF3O.js} +1 -1
- package/lib/chunks/{5KMAESVG.js → 7X6ZJPG4.js} +1 -1
- package/lib/chunks/{KZMFETIJ.js → AQQVMAUF.js} +1 -1
- package/lib/chunks/{S4H3MC5R.js → AWIBN2J5.js} +1 -1
- package/lib/chunks/{LLGJ3YMR.js → BR3C2ZRO.js} +1 -1
- package/lib/chunks/{UAEEHSSK.js → BV72RZCF.js} +2 -2
- package/lib/chunks/{IPVLUS43.js → CGBDHCS4.js} +1 -1
- package/lib/chunks/{H4XURXR7.js → CUB5GMHZ.js} +1 -1
- package/lib/chunks/{SAJRBHEI.js → CWYADEAF.js} +1 -1
- package/lib/chunks/{IZ2TZVJD.js → EPBAZUU2.js} +1 -1
- package/lib/chunks/{ZDNSHHXT.js → F645HTKX.js} +1 -1
- package/lib/chunks/{QZBHV7SD.js → FSTHNUTZ.js} +1 -1
- package/lib/chunks/{W6X4HEU3.js → G5RGUPPT.js} +1 -1
- package/lib/chunks/{XRZ5NMQ5.js → G66T7F2A.js} +1 -1
- package/lib/chunks/{Y6E4JAM3.js → HITQPK62.js} +1 -1
- package/lib/chunks/{ALXOGCUM.js → HNVJYHEV.js} +1 -1
- package/lib/chunks/{KEF4233Y.js → HR7ZTPFZ.js} +1 -1
- package/lib/chunks/{SZKF6VFY.js → ICLFVPDF.js} +1 -1
- package/lib/chunks/{CI4NGJ3I.js → ITRAFA2I.js} +1 -1
- package/lib/chunks/{ENDHNS6Y.js → IWS3O2SM.js} +1 -1
- package/lib/chunks/{YDSFHQXH.js → KVPIWPOL.js} +1 -1
- package/lib/chunks/{RW2ESAIF.js → L2EEGRZN.js} +41 -41
- package/lib/chunks/{LT2PEIAT.js → LW5V3SVS.js} +1 -1
- package/lib/chunks/{KW7NKDOX.js → LY6HM2BD.js} +1 -1
- package/lib/chunks/{IW2J6X26.js → LZRNA4HH.js} +1 -1
- package/lib/chunks/{C27G2ZXO.js → M5WLF4GV.js} +1 -1
- package/lib/chunks/{4JE7GYQB.js → NSK6GPZU.js} +1 -1
- package/lib/chunks/{UYHX7364.js → QHPWFCD2.js} +1 -1
- package/lib/chunks/{ZDQDZTQ7.js → RAYH3MG6.js} +1 -1
- package/lib/chunks/{3RDMQ5CQ.js → RBL3UMVK.js} +1 -1
- package/lib/chunks/{JH4AUZLH.js → RSOM77DA.js} +1 -1
- package/lib/chunks/{2TLIBL23.js → SJCEHWE2.js} +1 -1
- package/lib/chunks/{FUCJM4CG.js → SOTTFVAK.js} +1 -1
- package/lib/chunks/{FIIFOPJG.js → SZH6RAZB.js} +1 -1
- package/lib/chunks/{3BJIJBSJ.js → T3U6D4C3.js} +1 -1
- package/lib/chunks/{FTDJMTRX.js → UR72TK6I.js} +1 -1
- package/lib/chunks/{ZBK7SJHM.js → UUIZXPYS.js} +1 -1
- package/lib/chunks/{AHGQ4BNI.js → VQVISWBJ.js} +1 -1
- package/lib/chunks/{CKJYJBJ6.js → VUQEVFSD.js} +1 -1
- package/lib/chunks/{VTKYS75A.js → WCMZCZST.js} +1 -1
- package/lib/chunks/{L24E6ZRY.js → YOV4L7V6.js} +1 -1
- package/lib/chunks/{MZCEUZSS.js → ZIP2B7BB.js} +1 -1
- package/lib/chunks/{RVQFQGGH.js → ZRACBTMS.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 +1 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +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 +1 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +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 +1 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +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 +1 -1
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +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/index.js +9 -9
- package/package.json +1 -1
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -653,7 +653,7 @@ Packages:
|
|
|
653
653
|
@redocly/ajv@8.18.3 — Copyright (c) 2015-2021 Evgeny Poberezkin
|
|
654
654
|
@redocly/cli-otel@0.3.5 — Copyright 2025 Redocly Inc, all rights reserved.
|
|
655
655
|
@redocly/config@0.22.0 — Copyright 2024 Redocly Inc.
|
|
656
|
-
@redocly/config@0.
|
|
656
|
+
@redocly/config@0.57.0 — Copyright 2024 Redocly Inc.
|
|
657
657
|
@redocly/openapi-core@1.34.20
|
|
658
658
|
agent-base@7.1.4 — Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
659
659
|
ajv-formats@3.0.1 — Copyright (c) 2020 Evgeny Poberezkin
|
|
@@ -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"./73UEREUT.js";import"./42HL7XQH.js";import"./CGBDHCS4.js";import"./RSOM77DA.js";import"./BV72RZCF.js";import"./WZXA5XPB.js";import"./L2EEGRZN.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{a as swrGenerator};
|
|
@@ -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 oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./
|
|
7
|
+
import{a as oe,e as ae,f as ue,g as ce,h as b,i as de,k as H,l as V,m as pe,n as le,v as he,w as me}from"./SOTTFVAK.js";import{I as X,L as Je,M as Z,N as g,O,P as ee,Q as $,R as C,T as S,V as y,X as w,Y as te,Z as ne,_ as re,aa as se,c as l,ca as ie,q as Y,v as Q,y as We}from"./L2EEGRZN.js";import{e as J}from"./RFWIIJFG.js";import fe from"node:path";function R(t){return t?t.trim():""}function T(t){let e=R(t.operationId)||R(t.path);return[R(t.ruleId),R(t.severity),R(t.message),e,R(t.target),R(t.schemaPath)].join("")}var F=t=>Z(S(t));function Ye(t){return t==="error"?"error":t==="warning"?"warning":"note"}function Qe(t){if(t==null)return"";let e=String(t);return!e.includes(",")&&!e.includes('"')&&!e.includes(`
|
|
8
8
|
`)?e:`"${e.replace(/"/g,'""')}"`}function Xe(t){return fe.isAbsolute(t)?fe.relative(process.cwd(),t)||".":t}function Ze(t){if(!t)return null;let e=t.operationPathTemplate;return typeof e=="string"&&e.length>0?e:null}function et(t){return Object.entries(t).sort((e,r)=>{let n=r[1]-e[1];return n!==0?n:e[0].localeCompare(r[0])})}function tt(t){let e=[],r=new Map;for(let n of t){let s=T({ruleId:n.ruleId,severity:n.severity,message:n.message,operationId:n.operationId,path:n.path,target:n.target,schemaPath:n.schemaPath}),i=r.get(s);if(i!==void 0){e[i].occurrences+=1;continue}r.set(s,e.length),e.push({finding:n,occurrences:1})}return e}function nt(t){let e=tt(t.findings).map(n=>({occurrences:n.occurrences,exchangeIndex:n.finding.exchangeIndex,ruleId:n.finding.ruleId,severity:n.finding.severity,category:n.finding.category,message:n.finding.message,operationId:n.finding.operationId,specSource:n.finding.specSource,target:n.finding.target,schemaPath:n.finding.schemaPath,dataPath:n.finding.dataPath,details:n.finding.details,method:n.finding.method,url:n.finding.url,path:n.finding.path,status:n.finding.status})),r={run:{id:t.runId,specSource:t.meta.specSource,trafficPath:t.meta.trafficPath,format:t.meta.format,matchMode:t.meta.matchMode,server:t.meta.server,totalExchanges:t.summary.totalExchanges,documentedExchanges:t.summary.documentedExchanges,undocumentedExchanges:t.summary.undocumentedExchanges,skippedExchanges:t.summary.skippedExchanges,findingsBySeverity:t.summary.findingsBySeverity,findingsByRule:t.summary.findingsByRule,totalProblems:t.summary.totalProblemGroups,durationMs:t.summary.durationMs},problems:e};return`${JSON.stringify(r,null,2)}
|
|
9
9
|
`}function rt(t){let e=["run_id","finding_id","exchange_index","severity","category","rule_id","message","method","path","url","status","operation_id","spec_source","target","schema_path","data_path"],r=t.findings.map(s=>[t.runId,s.id,s.exchangeIndex,s.severity,s.category,s.ruleId,s.message,s.method,s.path,s.url,s.status,s.operationId,s.specSource,s.target,s.schemaPath,s.dataPath]);return`${[e,...r].map(s=>s.map(Qe).join(",")).join(`
|
|
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{l as t}from"./
|
|
7
|
+
import{l as t}from"./4UWA75AV.js";import"./BXI4SF2U.js";import{X as o}from"./L2EEGRZN.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function i({version:n}){new t(n).logout(),o.output(`Logged out from the Redocly account. \u270B
|
|
8
8
|
`)}export{i as handleLogout};
|
|
@@ -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"./ZIP2B7BB.js";import"./BV72RZCF.js";import"./WZXA5XPB.js";import"./L2EEGRZN.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as generateClient,a as runGenerators};
|
|
@@ -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}from"./
|
|
7
|
+
import{a}from"./CGBDHCS4.js";import{X as p}from"./L2EEGRZN.js";function g(t,r){let n=t.services.flatMap(e=>e.operations),s=n.filter(e=>e.sse!==void 0);s.length>0&&p.warn(`generate-client: ${r} skipped ${s.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${s.map(e=>e.name).join(", ")}.
|
|
8
8
|
`);let i=new Set(t.schemas.map(e=>e.name)),o=n.filter(e=>e.sse===void 0&&m(e,i));return o.length>0&&p.warn(`generate-client: ${r} skipped ${o.length} operation(s) whose variables type name collides with a schema \u2014 rename the schema or the operation: ${o.map(e=>e.name).join(", ")}.
|
|
9
9
|
`),n.filter(e=>e.sse===void 0&&!m(e,i))}function m(t,r){let n=a(t);return n.hasInputs&&r.has(n.variablesTypeName)}function x(t){return t.method==="get"||t.method==="head"}function u(t){return a(t).hasInputs}function f(t){return a(t).variablesTypeName}function $(t,r,n){let s=[];return a(t).hasInputs?s.push(r):n&&s.push("{}"),n&&s.push("{ ...init, envelope: undefined }"),`${t.name}(${s.join(", ")})`}function v(t,r,n){let s=t.map(e=>e.name).sort(),i=t.filter(u).map(f).sort();return n&&i.push("RequestOptions"),`import { ${[...s,...i.map(e=>`type ${e}`)].join(", ")} } from ${JSON.stringify(r)};`}export{g as a,x as b,u as c,f as d,$ as e,v as f};
|
|
@@ -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 se}from"./BXI4SF2U.js";import{ea as W,j as L,l as U,la as M,na as p,o as j,p as B}from"./RW2ESAIF.js";import{e as re}from"./RFWIIJFG.js";var $=re(se(),1);function b(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function H(o){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var q=async(o,{timeout:t,...e}={})=>{let r=b(),s=r&&!H(o),n,i=t?{connect:{timeout:t}}:{};return s?n=new $.ProxyAgent({uri:r,...i}):t&&(n=new $.Agent(i)),await fetch(o,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:n})};var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},y=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}`};try{let s=await q(t,{...e,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(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)}},A=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)}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 n=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}async push(t,e,r,s){let n=new 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 a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await ne(i.stream)]);n.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&n.append("isMainBranch","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:n});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getRemotesList({organizationId:t,projectId:e,mountPath:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes?filter=mountPath:/${r}/`,{timeout:6e3,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 u?new u(n,s.status):new Error(n)}}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 n=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}},m=class{apiClient;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new y(r,s),this.remotes=new A(this.apiClient,t,e)}getSunsetWarning(){return z(this.apiClient.sunsetWarnings)}};function z(o){let[t]=[...o].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function ne(o){let t=[];for await(let e of o)t.push(e);return Buffer.concat(t)}function oe(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var v={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function ie(){return process.env.REDOCLY_DOMAIN||v.us}var K=ae((o,t)=>{try{let e=t||o?.resolvedConfig.residency;return ce(e)?v[e]:e?new URL(e).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:v.us}catch{throw new T}});function I(o){try{K(void 0,o)}catch{return!1}return!0}function ae(o){return(...t)=>{let e=o(...t);if(!e.startsWith("https://"))throw new T;return e}}var T=class extends Error{constructor(){super("Invalid Reunite URL")}};function ce(o){return typeof o=="string"&&o in v}import{Buffer as k}from"node:buffer";import R from"node:crypto";import{mkdirSync as ue,existsSync as V,writeFileSync as le,readFileSync as he,rmSync as de}from"node:fs";import{homedir as pe}from"node:os";import G from"node:path";import*as Y from"node:child_process";var f=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new y("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]];Y.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((s,n)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),s(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),n(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),n("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:s,interval:n=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:s,interval:n,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let n=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(n,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...s},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var me="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",X="aes-256-cbc",D=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=pe();this.credentialsFolderPath=G.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=G.join(this.credentialsFolderPath,this.credentialsFileName),this.key=R.createHash("sha256").update(`${this.credentialsFolderPath}${me}`).digest(),this.iv=R.createHash("md5").update(this.credentialsFolderPath).digest(),ue(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new f(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 f(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new f(t,this.version),r=await this.readCredentials();if(!r||!I(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let n=await e.refreshToken(r.refresh_token);return await this.saveCredentials(n),n.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);le(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!V(this.credentialsFilePath))return null;try{let t=he(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){V(this.credentialsFilePath)&&de(this.credentialsFilePath)}encryptCredentials(t){let e=R.createCipheriv(X,this.key,this.iv);return k.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=R.createDecipheriv(X,this.key,this.iv),r=k.concat([e.update(k.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as g from"node:fs";import*as d from"node:path";async function fe({domain:o,apiKey:t,organization:e,project:r,mountPath:s,files:n,defaultBranch:i,commit:a,version:c,onUploadStart:C,onSunsetWarning:P}){let h=new m({domain:o,apiKey:t,command:"push",version:c});try{let w=await h.remotes.getDefaultBranch(e,r),x=await h.remotes.upsert(e,r,{mountBranchName:w,mountPath:s});C?.(x);let{id:E}=await h.remotes.push(e,r,{remoteId:x.id,commit:a,isMainBranch:i===a.branchName},n.map(l=>({path:j(l.name),stream:g.createReadStream(l.path)})));return{pushId:E}}finally{let w=h.getSunsetWarning();w&&P?.(w)}}function ge(o,t){let e={};for(let s of o)if(g.statSync(s).isDirectory()){let n=s;J(n,[]).forEach(a=>r(a,n))}else r(s,d.dirname(s));function r(s,n){let i=d.relative(n,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,n])=>({name:s,path:d.resolve(n)}))}function J(o,t){let e=g.readdirSync(o);for(let r of e){let s=d.join(o,r);g.statSync(s).isDirectory()?t=J(s,t):t.push(s)}return t}async function Z({operation:o,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:n=5e3}){async function i(){let a=await o();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await L(n),i()}return i()}var we=1200,ye=5e3,ve=["pending","running"];async function Te(o){let t=Q(o);try{return await te(t,o)}finally{ee(t,o)}}async function Ce({buildType:o,maxExecutionTime:t=we,retryIntervalMs:e=ye,startTime:r=Date.now(),onRetry:s,...n}){let i=Q(n);try{return await Z({operation:()=>te(i,n),condition:a=>!ve.includes(a.status[o].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ee(i,n)}}function Q({domain:o,apiKey:t,version:e}){return new m({domain:o,apiKey:t,command:"push-status",version:e})}function ee(o,{onSunsetWarning:t}){let e=o.getSunsetWarning();e&&t?.(e)}function te(o,{organization:t,project:e,pushId:r}){return o.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function Pe({projectUrl:o,auth:t,isApiKey:e=!1,onDebug:r}){let s=xe(o);if(!s)throw new p(`Invalid project URL format: ${o}`);try{let n=await Ee({...s,auth:t,isApiKey:e,onDebug:r}),i=n.config.scorecardClassic||n.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=n.config.pluginsUrl,c=a?await Se(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(n){throw new p(n instanceof Error?n.message:String(n))}}function xe(o){let t=new URL(o),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:s}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:s}}async function Ee({residency:o,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:n}){let i=new URL(`${o}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:$e(r,s)});if(n?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw n?.(`Authentication failed with status ${a.status}.`),n?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return n?.("Successfully received project configuration."),a.json()}async function Se(o,t){t?.(`Fetching plugins from: ${o}`);try{let e=await fetch(o);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function $e(o,t){return t?{Authorization:`Bearer ${o}`}:{Cookie:`accessToken=${o}`}}async function N(o,t,e=[],r=[],s){let n={};for(let i of e){let a={[i.name]:{root:o,rules:t}},c=await W({apis:a,...i,plugins:r},{configPath:s});n[i.name]=c.forAlias(i.name)}return n}function O(o,t){if(o){for(let e of o)if(Object.entries(e.where?.metadata||{}).every(([s,n])=>Fe(s,n,t)))return e}}function Fe(o,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[o])return!1;let[r,s]=t.split("/"),n=new Date(e[o]);return!(n<new Date(r)||s&&n>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[o])return!1;try{return B(t).test(e[o])}catch{throw new p(`Invalid regex in scorecard target "${o}": ${t}`)}}return e[o]===t}import{pathToFileURL as Re}from"node:url";async function _e(o,t){if(!o)return[];let e=Re(t??process.cwd()).href+"/",r=o.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var Ue=".redocly.com";function Ae(o){try{return new URL(o).hostname.toLowerCase().endsWith(Ue)}catch{return!1}}async function Ie({apiPath:o,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:n=[],targetLevel:i,metadata:a={},onDebug:c}){let C=[],P=new Map,h=r.levels||[];if(i&&!h.some(l=>l.name===i))throw new p(`Target level "${i}" not found in the scorecard configuration levels.
|
|
7
|
+
import{a as se}from"./BXI4SF2U.js";import{ea as W,j as L,l as U,la as M,na as p,o as j,p as B}from"./L2EEGRZN.js";import{e as re}from"./RFWIIJFG.js";var $=re(se(),1);function b(){return process.env.HTTPS_PROXY||process.env.HTTP_PROXY||process.env.http_proxy||process.env.https_proxy}function H(o){let t=process.env.NO_PROXY||process.env.no_proxy;if(!t)return!1;let e=t.split(",").map(s=>s.trim().toLowerCase()).filter(Boolean);if(e.length===0)return!1;let r;try{r=new URL(o).hostname.toLowerCase()}catch{return!1}return e.some(s=>!!(s==="*"||r===s||s.startsWith(".")&&r.endsWith(s)||!s.startsWith(".")&&r.endsWith("."+s)))}var q=async(o,{timeout:t,...e}={})=>{let r=b(),s=r&&!H(o),n,i=t?{connect:{timeout:t}}:{};return s?n=new $.ProxyAgent({uri:r,...i}):t&&(n=new $.Agent(i)),await fetch(o,{signal:t?AbortSignal.timeout(t):void 0,...e,dispatcher:n})};var u=class extends Error{status;constructor(t,e){super(t),this.status=e}},y=class{command;version;sunsetWarnings=[];constructor(t,e="2.0"){this.command=t,this.version=e}async request(t,e){let r={...e.headers,"user-agent":`redocly-cli/${this.version} ${this.command}`};try{let s=await q(t,{...e,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(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)}},A=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)}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 n=`Failed to upsert remote. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}async push(t,e,r,s){let n=new 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 a=Buffer.isBuffer(i.stream)?new Blob([i.stream]):new Blob([await ne(i.stream)]);n.append(`files[${i.path}]`,a,i.path)}r.isMainBranch&&n.append("isMainBranch","true");try{let i=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/pushes`,{method:"POST",headers:{Authorization:`Bearer ${this.apiKey}`},body:n});return await this.getParsedResponse(i)}catch(i){let a=`Failed to push. ${i.message}`;throw i instanceof u?new u(a,i.status):new Error(a)}}async getRemotesList({organizationId:t,projectId:e,mountPath:r}){try{let s=await this.client.request(`${this.domain}/api/orgs/${t}/projects/${e}/remotes?filter=mountPath:/${r}/`,{timeout:6e3,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 u?new u(n,s.status):new Error(n)}}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 n=`Failed to get push status. ${s.message}`;throw s instanceof u?new u(n,s.status):new Error(n)}}},m=class{apiClient;remotes;constructor({domain:t,apiKey:e,command:r,version:s}){this.apiClient=new y(r,s),this.remotes=new A(this.apiClient,t,e)}getSunsetWarning(){return z(this.apiClient.sunsetWarnings)}};function z(o){let[t]=[...o].sort((e,r)=>e.isSunsetExpired!==r.isSunsetExpired?e.isSunsetExpired?-1:1:e.sunsetDate>r.sunsetDate?1:-1);return t}async function ne(o){let t=[];for await(let e of o)t.push(e);return Buffer.concat(t)}function oe(){if(process.env.REDOCLY_AUTHORIZATION)return process.env.REDOCLY_AUTHORIZATION;throw new Error("No api key provided, please use environment variable REDOCLY_AUTHORIZATION.")}var v={us:"https://app.cloud.redocly.com",eu:"https://app.cloud.eu.redocly.com"};function ie(){return process.env.REDOCLY_DOMAIN||v.us}var K=ae((o,t)=>{try{let e=t||o?.resolvedConfig.residency;return ce(e)?v[e]:e?new URL(e).origin:o?.resolvedConfig.scorecard?.fromProjectUrl?new URL(o.resolvedConfig.scorecard.fromProjectUrl).origin:v.us}catch{throw new T}});function I(o){try{K(void 0,o)}catch{return!1}return!0}function ae(o){return(...t)=>{let e=o(...t);if(!e.startsWith("https://"))throw new T;return e}}var T=class extends Error{constructor(){super("Invalid Reunite URL")}};function ce(o){return typeof o=="string"&&o in v}import{Buffer as k}from"node:buffer";import R from"node:crypto";import{mkdirSync as ue,existsSync as V,writeFileSync as le,readFileSync as he,rmSync as de}from"node:fs";import{homedir as pe}from"node:os";import G from"node:path";import*as Y from"node:child_process";var f=class{baseUrl;apiClient;clientName="redocly-cli";constructor(t,e){this.baseUrl=t,this.apiClient=new y("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]];Y.spawn(e,r,{stdio:"ignore",detached:!0}).on("error",()=>{}).unref()}async verifyToken(t){try{return!!(await this.sendRequest("/session","GET",void 0,{Cookie:`accessToken=${t};`})).user}catch{return!1}}async verifyApiKey(t){try{return!!(await this.sendRequest("/api-keys-verify","POST",{apiKey:t})).success}catch{return!1}}async refreshToken(t){let e=await this.sendRequest("/device-rotate-token","POST",{grant_type:"refresh_token",client_name:this.clientName,refresh_token:t});if(!e.access_token)throw new Error("Failed to refresh token");return this.withResidency({access_token:e.access_token,refresh_token:e.refresh_token,expires_in:e.expires_in})}async pollingAccessToken(t,e,r){return new Promise((s,n)=>{let i=setInterval(async()=>{let c=await this.getAccessToken(t);c.access_token&&(clearInterval(i),clearTimeout(a),s(c)),c.error&&c.error!=="authorization_pending"&&(clearInterval(i),clearTimeout(a),n(c.error_description))},e*1e3),a=setTimeout(async()=>{clearInterval(i),clearTimeout(a),n("Authorization has expired. Please try again.")},r*1e3)})}async getAccessToken(t){return await this.sendRequest("/device-token","POST",{client_name:this.clientName,device_code:t,grant_type:"urn:ietf:params:oauth:grant-type:device_code"})}async getDeviceCode(){let{device_code:t,user_code:e,verification_uri:r,verification_uri_complete:s,interval:n=10,expires_in:i=300}=await this.sendRequest("/device-authorize","POST",{client_name:this.clientName});return{deviceCode:t,userCode:e,verificationUri:r,verificationUriComplete:s,interval:n,expiresIn:i}}async sendRequest(t,e="GET",r=void 0,s={}){let n=`${this.baseUrl}/api${t}`,i=await this.apiClient.request(n,{body:r&&JSON.stringify(r),method:e,headers:{"Content-Type":"application/json",...s},timeout:6e3});return i.status===204?{success:!0}:await i.json()}withResidency(t){return{...t,residency:this.baseUrl}}};var me="4618dbc9-8aed-4e27-aaf0-225f4603e5a4",X="aes-256-cbc",D=class{version;credentialsFolderPath;credentialsFilePath;credentialsFileName;key;iv;constructor(t){this.version=t;let e=pe();this.credentialsFolderPath=G.join(e,".redocly"),this.credentialsFileName="credentials",this.credentialsFilePath=G.join(this.credentialsFolderPath,this.credentialsFileName),this.key=R.createHash("sha256").update(`${this.credentialsFolderPath}${me}`).digest(),this.iv=R.createHash("md5").update(this.credentialsFolderPath).digest(),ue(this.credentialsFolderPath,{recursive:!0})}async login(t,e){let s=await new f(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 f(t,this.version).verifyApiKey(e):!!await this.getAccessToken(t)}getAccessToken=async t=>{let e=new f(t,this.version),r=await this.readCredentials();if(!r||!I(t)||r.residency&&r.residency!==t)return null;if(await e.verifyToken(r.access_token))return r.access_token;try{let n=await e.refreshToken(r.refresh_token);return await this.saveCredentials(n),n.access_token}catch{return null}};async saveCredentials(t){try{let e=this.encryptCredentials(t);le(this.credentialsFilePath,e,"utf8")}catch(e){throw new Error(`Failed to save credentials: ${e.message}`)}}async readCredentials(){if(!V(this.credentialsFilePath))return null;try{let t=he(this.credentialsFilePath,"utf8");return this.decryptCredentials(t)}catch{return null}}async removeCredentials(){V(this.credentialsFilePath)&&de(this.credentialsFilePath)}encryptCredentials(t){let e=R.createCipheriv(X,this.key,this.iv);return k.concat([e.update(JSON.stringify(t),"utf8"),e.final()]).toString("hex")}decryptCredentials(t){let e=R.createDecipheriv(X,this.key,this.iv),r=k.concat([e.update(k.from(t,"hex")),e.final()]);return JSON.parse(r.toString("utf8"))}};import*as g from"node:fs";import*as d from"node:path";async function fe({domain:o,apiKey:t,organization:e,project:r,mountPath:s,files:n,defaultBranch:i,commit:a,version:c,onUploadStart:C,onSunsetWarning:P}){let h=new m({domain:o,apiKey:t,command:"push",version:c});try{let w=await h.remotes.getDefaultBranch(e,r),x=await h.remotes.upsert(e,r,{mountBranchName:w,mountPath:s});C?.(x);let{id:E}=await h.remotes.push(e,r,{remoteId:x.id,commit:a,isMainBranch:i===a.branchName},n.map(l=>({path:j(l.name),stream:g.createReadStream(l.path)})));return{pushId:E}}finally{let w=h.getSunsetWarning();w&&P?.(w)}}function ge(o,t){let e={};for(let s of o)if(g.statSync(s).isDirectory()){let n=s;J(n,[]).forEach(a=>r(a,n))}else r(s,d.dirname(s));function r(s,n){let i=d.relative(n,s);e[i]&&t?.(e[i],s),e[i]=s}return Object.entries(e).map(([s,n])=>({name:s,path:d.resolve(n)}))}function J(o,t){let e=g.readdirSync(o);for(let r of e){let s=d.join(o,r);g.statSync(s).isDirectory()?t=J(s,t):t.push(s)}return t}async function Z({operation:o,condition:t,onConditionNotMet:e,startTime:r=Date.now(),retryTimeoutMs:s=6e5,retryIntervalMs:n=5e3}){async function i(){let a=await o();if(t(a))return a;if(Date.now()-r>s)throw new Error("Timeout exceeded.");return await e?.(a),await L(n),i()}return i()}var we=1200,ye=5e3,ve=["pending","running"];async function Te(o){let t=Q(o);try{return await te(t,o)}finally{ee(t,o)}}async function Ce({buildType:o,maxExecutionTime:t=we,retryIntervalMs:e=ye,startTime:r=Date.now(),onRetry:s,...n}){let i=Q(n);try{return await Z({operation:()=>te(i,n),condition:a=>!ve.includes(a.status[o].deploy.status),onConditionNotMet:s,startTime:r,retryTimeoutMs:t*1e3,retryIntervalMs:e})}finally{ee(i,n)}}function Q({domain:o,apiKey:t,version:e}){return new m({domain:o,apiKey:t,command:"push-status",version:e})}function ee(o,{onSunsetWarning:t}){let e=o.getSunsetWarning();e&&t?.(e)}function te(o,{organization:t,project:e,pushId:r}){return o.remotes.getPush({organizationId:t,projectId:e,pushId:r})}async function Pe({projectUrl:o,auth:t,isApiKey:e=!1,onDebug:r}){let s=xe(o);if(!s)throw new p(`Invalid project URL format: ${o}`);try{let n=await Ee({...s,auth:t,isApiKey:e,onDebug:r}),i=n.config.scorecardClassic||n.config.scorecard;if(!i)throw new Error("No scorecard configuration found.");let a=n.config.pluginsUrl,c=a?await Se(a,r):void 0;return{scorecard:i,plugins:c,pluginsUrl:a}}catch(n){throw new p(n instanceof Error?n.message:String(n))}}function xe(o){let t=new URL(o),e=t.pathname.match(/\/org\/(?<orgSlug>[^/]+)\/project\/(?<projectSlug>[^/]+)/);if(!e?.groups)return;let{orgSlug:r,projectSlug:s}=e.groups;return{residency:t.origin,orgSlug:r,projectSlug:s}}async function Ee({residency:o,orgSlug:t,projectSlug:e,auth:r,isApiKey:s,onDebug:n}){let i=new URL(`${o}/api/orgs/${t}/projects/${e}`),a=await fetch(i,{headers:$e(r,s)});if(n?.(`Project fetch response status: ${a.status}`),a.status===401||a.status===403)throw n?.(`Authentication failed with status ${a.status}.`),n?.("Check that your credentials are valid and have the necessary permissions."),new Error(`Unauthorized access to project: ${e}. Please check your credentials.`);if(a.status!==200)throw new Error(`Failed to fetch project: ${e}. Status: ${a.status}`);return n?.("Successfully received project configuration."),a.json()}async function Se(o,t){t?.(`Fetching plugins from: ${o}`);try{let e=await fetch(o);if(t?.(`Plugins fetch response status: ${e.status}`),e.status!==200){t?.("Failed to fetch plugins");return}return e.text()}catch(e){t?.(`Error fetching plugins: ${e instanceof Error?e.message:String(e)}`);return}}function $e(o,t){return t?{Authorization:`Bearer ${o}`}:{Cookie:`accessToken=${o}`}}async function N(o,t,e=[],r=[],s){let n={};for(let i of e){let a={[i.name]:{root:o,rules:t}},c=await W({apis:a,...i,plugins:r},{configPath:s});n[i.name]=c.forAlias(i.name)}return n}function O(o,t){if(o){for(let e of o)if(Object.entries(e.where?.metadata||{}).every(([s,n])=>Fe(s,n,t)))return e}}function Fe(o,t,e){if(t.match(/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}Z)?\/(\d{4}-\d{2}-\d{2})?$/)){if(!e[o])return!1;let[r,s]=t.split("/"),n=new Date(e[o]);return!(n<new Date(r)||s&&n>new Date(s))}else if(t.match(/^\/.*\//)){if(!e[o])return!1;try{return B(t).test(e[o])}catch{throw new p(`Invalid regex in scorecard target "${o}": ${t}`)}}return e[o]===t}import{pathToFileURL as Re}from"node:url";async function _e(o,t){if(!o)return[];let e=Re(t??process.cwd()).href+"/",r=o.replaceAll("__redocly_dirname",`"${e}"`);return(await import(`data:text/javascript;base64,${btoa(r)}`)).default.map(i=>i())}var Ue=".redocly.com";function Ae(o){try{return new URL(o).hostname.toLowerCase().endsWith(Ue)}catch{return!1}}async function Ie({apiPath:o,document:t,externalRefResolver:e,scorecardConfig:r,configPath:s,plugins:n=[],targetLevel:i,metadata:a={},onDebug:c}){let C=[],P=new Map,h=r.levels||[];if(i&&!h.some(l=>l.name===i))throw new p(`Target level "${i}" not found in the scorecard configuration levels.
|
|
8
8
|
`);let w=O(r.targets,a)?.rules,x=await N(o,w,h,n,s||"");for(let l of h){c?.(`
|
|
9
9
|
Validating level: "${l.name}"`),n.length>0&&c?.(`Using ${n.length} ${U("plugin",n.length)} for this level.`),c?.("Linting document against level rules...");let S=(await M({document:t,externalRefResolver:e,config:x[l.name]})).filter(({ignored:_})=>!_).map(_=>({..._,scorecardLevel:l.name}));c?.(`Found ${S.length} ${U("problem",S.length)} for level "${l.name}".`),P.set(l.name,S),C.push(...S)}let E=ke(P,h,i);return{problems:C,achievedLevel:E,targetLevelAchieved:i?E===i:!0}}function ke(o,t,e){let r=null;for(let s of t){if((o.get(s.name)||[]).some(a=>a.severity==="error"))return r||"Non Conformant";if(r=s.name,e&&s.name===e)return s.name}return r||"Non Conformant"}export{u as a,y as b,m as c,z as d,oe as e,v as f,ie as g,K as h,I as i,T as j,f as k,D as l,fe as m,ge as n,Te as o,Ce as p,Pe as q,N as r,O as s,_e as t,Ae as u,Ie as v};
|
|
@@ -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{b as B}from"./2U6O26CV.js";import{b as X,c as E,d as T,e as W,f as ne,g as te,h as re}from"./JH4AUZLH.js";import{a as Y,c as C,d as p,e as w,f as x,g as D,h as O,i as Z,j,k as I,l as F,n as ee}from"./UW4UC7ZI.js";var U=C.php,q=class extends Y{constructor(){super(" ")}typeName(n){return p(n,{style:"pascal",reserved:U})}memberName(n){return p(n,{style:"camel",reserved:U})}identifier(n){return p(n,{style:"camel",reserved:U})}identifiers(n,s){return w(n,{style:"camel",reserved:U,taken:s})}string(n){return`'${n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}literal(n){return n==null?"null":typeof n=="boolean"||typeof n=="number"?String(n):typeof n=="string"?this.string(n):Array.isArray(n)?`[${n.map(i=>this.literal(i)).join(", ")}]`:`[${Object.entries(n).map(([i,r])=>`${this.string(i)} => ${this.literal(r)}`).join(", ")}]`}comment(n){for(let s of F(n))this.line(s===""?"//":`// ${s}`);return this}doc(n,s,i=[]){let r=F(s);if(r.length===0&&i.length===0)return this;let t=r.length===0?n:`${n} \u2014 ${r.join(" ")}`;if(i.length===0)return this.line(`/** ${t} */`);this.line("/**"),this.line(` * ${t}`),this.line(" *");for(let a of i)this.line(` * ${a}`);return this.line(" */")}};var h=C.php,G=new q;function y(e){return G.typeName(e)}function b(e){return G.memberName(e)}function c(e){return G.string(e)}function ie(e){return p(e.name,{style:"camel",reserved:h})}function K(e){let n=e.services.flatMap(i=>i.operations),s=w(n.map(i=>i.name),{style:"camel",reserved:h});return new Map(n.map((i,r)=>[i.name,s[r]]))}function de(e){return ne(e).map(s=>s.kind==="literal"?c(s.value):`$${b(s.name)}`).join(" . ")}function se(e,n){let s=n.servers??[];if(s.length===0)return;let i=new Set;e.line("/** The declared servers; variables default to the values from the description. */"),e.line("final class Servers"),e.block("{",()=>{s.forEach((r,t)=>{let a=p(r.description??`server${t+1}`,{style:"camel",reserved:h});i.has(a)&&(a=`${a}${t+1}`),i.add(a);let o=r.variables.map(l=>`string $${b(l.name)} = ${c(l.default)}`);t>0&&e.blank(),e.line(`public static function ${a}(${o.join(", ")}): string`),e.block("{",()=>{e.line(`return ${de(r)};`)},"}")})},"}"),e.blank()}function ae(e,n){let s=te(e,n).map(i=>`[${i.map(t=>t.kind==="apiKey"?`['kind' => 'apiKey', 'scheme' => ${c(t.scheme)}, 'name' => ${c(t.name)}, 'in' => ${c(t.in)}]`:`['kind' => ${c(t.kind)}, 'scheme' => ${c(t.scheme)}]`).join(", ")}]`);if(s.length!==0)return`[${s.join(", ")}]`}function oe(e){return`[${[`'style' => ${c(e.style)}`,...e.param!==void 0?[`'param' => ${c(e.param)}`]:[],...e.nextCursor!==void 0?[`'nextCursor' => ${c(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`'hasMore' => ${c(e.hasMore)}`]:[],...e.limitParam!==void 0?[`'limitParam' => ${c(e.limitParam)}`]:[],...e.items!==void 0?[`'items' => ${c(e.items)}`]:[]].join(", ")}]`}function ce(e,n){let s=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let t=p(r.name,{style:"camel",reserved:h}),a=2;for(;s.has(t);)t=`${p(r.name,{style:"camel",reserved:h})}_${a++}`;s.add(t);let o=ee(r.schema,n);return`[${c(r.name)}, ${c(t)}, ${c(o)}]`}).join(", ")}]`}function _(e,n){let s=n.schemas.find(t=>t.name===e);if(s===void 0)return"other";let i=s.schema,r=I(i);return r!==void 0&&(r.scalar==="string"||r.scalar==="integer")?"enum":(i.kind==="object"||i.kind==="intersection")&&D(i,n)!==void 0?"class":"other"}function m(e,n,s="string"){if(Z(e)){let i=m(j(e),n,s);return A(i)}switch(e.kind){case"scalar":return s==="Date"&&e.scalar==="string"&&L(e)?"\\DateTimeImmutable":{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":case"record":return"array";case"ref":{let i=_(e.name,n);if(i==="class"||i==="enum")return y(e.name);let r=x(e,n);return r===void 0?"mixed":m(r,n,s)}case"enum":return{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float";case"omit":return y(e.base);case"union":return me(e.members,n,s);case"null":case"object":case"intersection":case"unknown":return"mixed"}}function L(e){let n=e.metadata?.format;return n==="date"||n==="date-time"}function A(e){return e==="mixed"||e.startsWith("?")||e.endsWith("|null")?e:e.includes("|")?`${e}|null`:`?${e}`}function me(e,n,s){let i=[];for(let r of e){if(r.kind==="null")continue;let t=m(r,n,s);if(t==="mixed")return"mixed";let a=t.startsWith("?")?t.slice(1):t;i.includes(a)||i.push(a),t.startsWith("?")&&!i.includes("null")&&i.push("null")}return i.length===0?"mixed":i.join("|")}function J(e,n,s){if(e===void 0)return;let i=j(e);if(i.kind==="ref"){let t=x(i,n);return _(i.name,n)==="other"?J(t,n,s):void 0}if(i.kind!=="array")return;let r=m(i.items,n,s);return r==="mixed"?void 0:r}function le(e,n){let s=n.schemas.find(i=>i.name===e);return s!==void 0&&O(s.schema,n)!==void 0}function v(e,n,s,i){let r=j(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"&&L(r))return`new \\DateTimeImmutable(${n})`;if(r.kind==="omit")return v({kind:"ref",name:r.base},n,s,i);if(r.kind==="ref"){let t=_(r.name,s);if(t==="class")return`${y(r.name)}::fromArray(${n})`;if(t==="enum")return`${y(r.name)}::from(${n})`;if(le(r.name,s))return`unmarshal${y(r.name)}(${n})`;let a=x(r,s);return a===void 0?void 0:v(a,n,s,i)}if(r.kind==="array"){let t=v(r.items,"$item",s,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}if(r.kind==="record"){let t=v(r.value,"$item",s,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}}function N(e,n,s,i="string"){let r=j(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"){if(r.metadata?.format==="date")return`${n}->format('Y-m-d')`;if(r.metadata?.format==="date-time")return`${n}->format(\\DateTimeInterface::ATOM)`}if(r.kind==="omit")return N({kind:"ref",name:r.base},n,s,i);if(r.kind==="ref"){let t=_(r.name,s);if(t==="class")return`${n}->toArray()`;if(t==="enum")return`${n}->value`;if(le(r.name,s))return`is_object(${n}) ? ${n}->toArray() : ${n}`;let a=x(r,s);return a===void 0?void 0:N(a,n,s,i)}if(r.kind==="array"||r.kind==="record"){let t=r.kind==="array"?r.items:r.value,a=N(t,"$item",s,i);return a===void 0?void 0:`array_map(static fn ($item) => ${a}, ${n})`}}function pe(e,n,s,i,r,t){let a=[...s.filter(o=>o.required),...s.filter(o=>!o.required)];e.doc(y(n),t),e.line(`final class ${y(n)}`),e.block("{",()=>{e.block("public function __construct(",()=>{for(let o of a){let l=m(o.schema,i,r);if(o.required)e.line(`public ${l} $${b(o.name)},`);else{let u=A(l);e.line(`public ${u} $${b(o.name)} = null,`)}}},") {"),e.line("}"),e.blank(),e.line("public static function fromArray(array $data): self"),e.block("{",()=>{e.block("return new self(",()=>{for(let o of a){let l=`$data[${c(o.name)}]`,u=v(o.schema,l,i,r),f=b(o.name);o.required?e.line(`${f}: ${u??l},`):u===void 0?e.line(`${f}: ${l} ?? null,`):e.line(`${f}: isset(${l}) ? ${u} : null,`)}},");")},"}"),e.blank(),e.line("public function toArray(): array"),e.block("{",()=>{e.line("$data = [];");for(let o of a){let l=`$this->${b(o.name)}`,u=N(o.schema,l,i,r)??l;o.required?e.line(`$data[${c(o.name)}] = ${u};`):e.block(`if (${l} !== null) {`,()=>{e.line(`$data[${c(o.name)}] = ${u};`)},"}")}e.line("return $data;")},"}")},"}"),e.blank()}function V(e,n="string"){let s=new q;for(let{name:i,schema:r}of e.schemas){let t=I(r);if(t!==void 0&&(t.scalar==="string"||t.scalar==="integer")){let o=t.scalar==="string"?"string":"int";s.doc(y(i),r.description),s.line(`enum ${y(i)}: ${o}`),s.block("{",()=>{let l=w(t.values.map(u=>String(u)),{style:"pascal",reserved:h});t.values.forEach((u,f)=>{let g=typeof u=="string"?c(u):String(u);s.line(`case ${l[f]} = ${g};`)})},"}"),s.blank();continue}if(r.kind==="object"||r.kind==="intersection"){let o=D(r,e);if(o!==void 0){pe(s,i,o.properties,e,n,o.description??r.description);continue}}let a=O(r,e);if(a!==void 0){let o=y(i),l=a.cases.map(u=>`${u.value} -> ${y(u.schemaName)}`).join(", ");s.line(`/** ${o} is a discriminated union (${c(a.property)}): ${l}. */`),s.line(`function unmarshal${o}(array $data): mixed`),s.block("{",()=>{s.block(`return match ($data[${c(a.property)}] ?? null) {`,()=>{for(let u of a.cases)s.line(`${c(u.value)} => ${y(u.schemaName)}::fromArray($data),`);s.line("default => $data,")},"};")},"}"),s.blank();continue}}return s.toString()}var ue=new Set(["post","put","patch"]),he=["body","headers","idempotencyKey"];function z(e,n,s,i){let r=w([...e.pathParams,...e.queryParams].map(l=>l.name),{style:"camel",reserved:h,taken:he}),t=e.pathParams.map((l,u)=>({php:r[u],wire:l.name,type:m(l.schema,n,i)})),a=e.queryParams.map((l,u)=>{let f=r[e.pathParams.length+u];return{php:f,wire:l.name,type:m(l.schema,n,i),value:N(l.schema,`$${f}`,n,i)??`$${f}`}}),o=[...t.map(({php:l,type:u})=>`${u} $${l}`),...s&&e.requestBody?[`${W(e)?"array":m(e.requestBody.schema,n,i)} $body`]:[],...a.map(({php:l,type:u})=>`${A(u)} $${l} = null`),"?array $headers = null",...s&&ue.has(e.method.toLowerCase())?["?string $idempotencyKey = null"]:[]];return{pathArgs:t,queryArgs:a,signature:o}}function ye(e,n,s){e.line(`$op = OPERATIONS[${c(n.specName??n.name)}];`),e.line("[$authHeaders, $query, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);");for(let{php:r,wire:t,value:a}of s.queryArgs)e.block(`if ($${r} !== null) {`,()=>{e.line(`$query[${c(t)}] = ${a};`)},"}");let i=s.pathArgs.map(({php:r,wire:t})=>`${c(t)} => $${r}`).join(", ");e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${i}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}")}function Q(e,n,s,i,r,t=!1){let a=z(n,i,!0,r),o=T(n),l=E(n),u=o===void 0&&l===void 0&&n.successResponses.some(k=>k.contentType!==""),f=t?"Envelope":o!==void 0?"\\Generator":l!==void 0?m(l,i,r):u?"string":"void",g=t?`${s}WithHeaders`:s,H=t?void 0:J(l,i,r);e.doc(g,t?`Like ${s}(), returning an Envelope with the declared response headers.`:n.summary??`${n.method.toUpperCase()} ${n.path}`,H===void 0?[]:[`@return ${H}[]`]),e.line(`public function ${g}(${a.signature.join(", ")}): ${f}`),e.block("{",()=>{if(ye(e,n,a),o!==void 0){let d=o.schema!==void 0&&o.schema.kind!=="unknown";e.line("$url = appendQuery($url, $query);"),e.block("$open = function (array $extraHeaders) use ($url, $requestHeaders): \\CurlHandle {",()=>{e.line("$handle = curl_init($url);"),e.line("$lines = [];"),e.block("foreach (array_merge($requestHeaders, $extraHeaders) as $name => $value) {",()=>{e.line("$lines[] = $name . ': ' . $value;")},"}"),e.line("curl_setopt($handle, CURLOPT_HTTPHEADER, $lines);"),e.line("return $handle;")},"};"),e.line(`yield from iterSse($open, ${d?"true":"false"});`);return}let k=["'operationId' => $op['id']","'method' => $op['method']","'url' => $url","'headers' => $requestHeaders","'query' => $query"];if(n.requestBody&&W(n))e.line("[$contentType, $encoded] = toMultipart($body);"),k.push("'body' => $encoded","'contentType' => $contentType");else if(n.requestBody){let d=N(n.requestBody.schema,"$body",i,r)??"$body";e.line(`$payload = json_encode(${d});`),k.push("'body' => $payload",`'contentType' => ${c(n.requestBody.contentType)}`)}ue.has(n.method.toLowerCase())&&n.requestBody&&k.push("'idempotencyKey' => $idempotencyKey"),e.line(`$response = send($this->config, [${k.join(", ")}]);`),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}");let $=u?"$response['body']":(l===void 0?void 0:v(l,"decodeJson($response)",i,r))??"decodeJson($response)";if(t){e.line(`$data = ${$};`),e.line(`return new Envelope(data: $data, headers: readEnvelopeHeaders($response, ${ce(n,i)}), status: $response['status']);`);return}if(u){e.line("return $response['body'];");return}if(f==="void"){e.line("decodeJson($response);");return}e.line(`return ${$};`)},"}"),e.blank()}function $e(e,n,s,i,r,t,a,o,l){let u=z(n,i,!1,r),f=s,g=()=>{e.line(`$op = OPERATIONS[${c(n.specName??n.name)}];`),e.line("$base = [];");for(let{php:d,wire:P,value:S}of u.queryArgs)e.block(`if ($${d} !== null) {`,()=>{e.line(`$base[${c(P)}] = ${S};`)},"}");let $=u.pathArgs.map(({php:d,wire:P})=>`${c(P)} => $${d}`).join(", ");e.block("$call = function (array $params) use ($op, $headers): array {",()=>{e.line("[$authHeaders, $authQuery, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);"),e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${$}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}"),e.line("$response = send($this->config, ['operationId' => $op['id'], 'method' => $op['method'], 'url' => $url, 'headers' => $requestHeaders, 'query' => array_merge($params, $authQuery)]);"),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}"),e.line("return [decodeJson($response), $response];")},"};")},H=m(E(n)??{kind:"unknown"},i,r),k=H==="mixed"?"mixed":H;e.line("/**"),e.line(` * ${f} response pages, following the pagination rule automatically.`),e.line(" *"),e.line(` * @return \\Generator<int, ${k}>`),e.line(" */"),e.line(`public function ${f}Pages(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`yield ${t??"$page"};`)},"}")},"}"),e.blank(),e.line("/**"),e.line(` * The items of every ${f} page.`),e.line(" *"),e.line(` * @return \\Generator<int, ${l}>`),e.line(" */"),e.line(`public function ${f}Items(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`$items = resolvePointer($page, ${c(o??"")});`),e.block("foreach (is_array($items) ? $items : [] as $item) {",()=>{e.line(`yield ${a??"$item"};`)},"}")},"}")},"}"),e.blank()}function ge(e){let n=e.split(`
|
|
7
|
+
import{b as B}from"./2U6O26CV.js";import{b as X,c as E,d as T,e as W,f as ne,g as te,h as re}from"./RSOM77DA.js";import{a as Y,c as C,d as p,e as w,f as x,g as D,h as O,i as Z,j,k as I,l as F,n as ee}from"./UW4UC7ZI.js";var U=C.php,q=class extends Y{constructor(){super(" ")}typeName(n){return p(n,{style:"pascal",reserved:U})}memberName(n){return p(n,{style:"camel",reserved:U})}identifier(n){return p(n,{style:"camel",reserved:U})}identifiers(n,s){return w(n,{style:"camel",reserved:U,taken:s})}string(n){return`'${n.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}literal(n){return n==null?"null":typeof n=="boolean"||typeof n=="number"?String(n):typeof n=="string"?this.string(n):Array.isArray(n)?`[${n.map(i=>this.literal(i)).join(", ")}]`:`[${Object.entries(n).map(([i,r])=>`${this.string(i)} => ${this.literal(r)}`).join(", ")}]`}comment(n){for(let s of F(n))this.line(s===""?"//":`// ${s}`);return this}doc(n,s,i=[]){let r=F(s);if(r.length===0&&i.length===0)return this;let t=r.length===0?n:`${n} \u2014 ${r.join(" ")}`;if(i.length===0)return this.line(`/** ${t} */`);this.line("/**"),this.line(` * ${t}`),this.line(" *");for(let a of i)this.line(` * ${a}`);return this.line(" */")}};var h=C.php,G=new q;function y(e){return G.typeName(e)}function b(e){return G.memberName(e)}function c(e){return G.string(e)}function ie(e){return p(e.name,{style:"camel",reserved:h})}function K(e){let n=e.services.flatMap(i=>i.operations),s=w(n.map(i=>i.name),{style:"camel",reserved:h});return new Map(n.map((i,r)=>[i.name,s[r]]))}function de(e){return ne(e).map(s=>s.kind==="literal"?c(s.value):`$${b(s.name)}`).join(" . ")}function se(e,n){let s=n.servers??[];if(s.length===0)return;let i=new Set;e.line("/** The declared servers; variables default to the values from the description. */"),e.line("final class Servers"),e.block("{",()=>{s.forEach((r,t)=>{let a=p(r.description??`server${t+1}`,{style:"camel",reserved:h});i.has(a)&&(a=`${a}${t+1}`),i.add(a);let o=r.variables.map(l=>`string $${b(l.name)} = ${c(l.default)}`);t>0&&e.blank(),e.line(`public static function ${a}(${o.join(", ")}): string`),e.block("{",()=>{e.line(`return ${de(r)};`)},"}")})},"}"),e.blank()}function ae(e,n){let s=te(e,n).map(i=>`[${i.map(t=>t.kind==="apiKey"?`['kind' => 'apiKey', 'scheme' => ${c(t.scheme)}, 'name' => ${c(t.name)}, 'in' => ${c(t.in)}]`:`['kind' => ${c(t.kind)}, 'scheme' => ${c(t.scheme)}]`).join(", ")}]`);if(s.length!==0)return`[${s.join(", ")}]`}function oe(e){return`[${[`'style' => ${c(e.style)}`,...e.param!==void 0?[`'param' => ${c(e.param)}`]:[],...e.nextCursor!==void 0?[`'nextCursor' => ${c(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`'hasMore' => ${c(e.hasMore)}`]:[],...e.limitParam!==void 0?[`'limitParam' => ${c(e.limitParam)}`]:[],...e.items!==void 0?[`'items' => ${c(e.items)}`]:[]].join(", ")}]`}function ce(e,n){let s=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let t=p(r.name,{style:"camel",reserved:h}),a=2;for(;s.has(t);)t=`${p(r.name,{style:"camel",reserved:h})}_${a++}`;s.add(t);let o=ee(r.schema,n);return`[${c(r.name)}, ${c(t)}, ${c(o)}]`}).join(", ")}]`}function _(e,n){let s=n.schemas.find(t=>t.name===e);if(s===void 0)return"other";let i=s.schema,r=I(i);return r!==void 0&&(r.scalar==="string"||r.scalar==="integer")?"enum":(i.kind==="object"||i.kind==="intersection")&&D(i,n)!==void 0?"class":"other"}function m(e,n,s="string"){if(Z(e)){let i=m(j(e),n,s);return A(i)}switch(e.kind){case"scalar":return s==="Date"&&e.scalar==="string"&&L(e)?"\\DateTimeImmutable":{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":case"record":return"array";case"ref":{let i=_(e.name,n);if(i==="class"||i==="enum")return y(e.name);let r=x(e,n);return r===void 0?"mixed":m(r,n,s)}case"enum":return{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float";case"omit":return y(e.base);case"union":return me(e.members,n,s);case"null":case"object":case"intersection":case"unknown":return"mixed"}}function L(e){let n=e.metadata?.format;return n==="date"||n==="date-time"}function A(e){return e==="mixed"||e.startsWith("?")||e.endsWith("|null")?e:e.includes("|")?`${e}|null`:`?${e}`}function me(e,n,s){let i=[];for(let r of e){if(r.kind==="null")continue;let t=m(r,n,s);if(t==="mixed")return"mixed";let a=t.startsWith("?")?t.slice(1):t;i.includes(a)||i.push(a),t.startsWith("?")&&!i.includes("null")&&i.push("null")}return i.length===0?"mixed":i.join("|")}function J(e,n,s){if(e===void 0)return;let i=j(e);if(i.kind==="ref"){let t=x(i,n);return _(i.name,n)==="other"?J(t,n,s):void 0}if(i.kind!=="array")return;let r=m(i.items,n,s);return r==="mixed"?void 0:r}function le(e,n){let s=n.schemas.find(i=>i.name===e);return s!==void 0&&O(s.schema,n)!==void 0}function v(e,n,s,i){let r=j(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"&&L(r))return`new \\DateTimeImmutable(${n})`;if(r.kind==="omit")return v({kind:"ref",name:r.base},n,s,i);if(r.kind==="ref"){let t=_(r.name,s);if(t==="class")return`${y(r.name)}::fromArray(${n})`;if(t==="enum")return`${y(r.name)}::from(${n})`;if(le(r.name,s))return`unmarshal${y(r.name)}(${n})`;let a=x(r,s);return a===void 0?void 0:v(a,n,s,i)}if(r.kind==="array"){let t=v(r.items,"$item",s,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}if(r.kind==="record"){let t=v(r.value,"$item",s,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}}function N(e,n,s,i="string"){let r=j(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"){if(r.metadata?.format==="date")return`${n}->format('Y-m-d')`;if(r.metadata?.format==="date-time")return`${n}->format(\\DateTimeInterface::ATOM)`}if(r.kind==="omit")return N({kind:"ref",name:r.base},n,s,i);if(r.kind==="ref"){let t=_(r.name,s);if(t==="class")return`${n}->toArray()`;if(t==="enum")return`${n}->value`;if(le(r.name,s))return`is_object(${n}) ? ${n}->toArray() : ${n}`;let a=x(r,s);return a===void 0?void 0:N(a,n,s,i)}if(r.kind==="array"||r.kind==="record"){let t=r.kind==="array"?r.items:r.value,a=N(t,"$item",s,i);return a===void 0?void 0:`array_map(static fn ($item) => ${a}, ${n})`}}function pe(e,n,s,i,r,t){let a=[...s.filter(o=>o.required),...s.filter(o=>!o.required)];e.doc(y(n),t),e.line(`final class ${y(n)}`),e.block("{",()=>{e.block("public function __construct(",()=>{for(let o of a){let l=m(o.schema,i,r);if(o.required)e.line(`public ${l} $${b(o.name)},`);else{let u=A(l);e.line(`public ${u} $${b(o.name)} = null,`)}}},") {"),e.line("}"),e.blank(),e.line("public static function fromArray(array $data): self"),e.block("{",()=>{e.block("return new self(",()=>{for(let o of a){let l=`$data[${c(o.name)}]`,u=v(o.schema,l,i,r),f=b(o.name);o.required?e.line(`${f}: ${u??l},`):u===void 0?e.line(`${f}: ${l} ?? null,`):e.line(`${f}: isset(${l}) ? ${u} : null,`)}},");")},"}"),e.blank(),e.line("public function toArray(): array"),e.block("{",()=>{e.line("$data = [];");for(let o of a){let l=`$this->${b(o.name)}`,u=N(o.schema,l,i,r)??l;o.required?e.line(`$data[${c(o.name)}] = ${u};`):e.block(`if (${l} !== null) {`,()=>{e.line(`$data[${c(o.name)}] = ${u};`)},"}")}e.line("return $data;")},"}")},"}"),e.blank()}function V(e,n="string"){let s=new q;for(let{name:i,schema:r}of e.schemas){let t=I(r);if(t!==void 0&&(t.scalar==="string"||t.scalar==="integer")){let o=t.scalar==="string"?"string":"int";s.doc(y(i),r.description),s.line(`enum ${y(i)}: ${o}`),s.block("{",()=>{let l=w(t.values.map(u=>String(u)),{style:"pascal",reserved:h});t.values.forEach((u,f)=>{let g=typeof u=="string"?c(u):String(u);s.line(`case ${l[f]} = ${g};`)})},"}"),s.blank();continue}if(r.kind==="object"||r.kind==="intersection"){let o=D(r,e);if(o!==void 0){pe(s,i,o.properties,e,n,o.description??r.description);continue}}let a=O(r,e);if(a!==void 0){let o=y(i),l=a.cases.map(u=>`${u.value} -> ${y(u.schemaName)}`).join(", ");s.line(`/** ${o} is a discriminated union (${c(a.property)}): ${l}. */`),s.line(`function unmarshal${o}(array $data): mixed`),s.block("{",()=>{s.block(`return match ($data[${c(a.property)}] ?? null) {`,()=>{for(let u of a.cases)s.line(`${c(u.value)} => ${y(u.schemaName)}::fromArray($data),`);s.line("default => $data,")},"};")},"}"),s.blank();continue}}return s.toString()}var ue=new Set(["post","put","patch"]),he=["body","headers","idempotencyKey"];function z(e,n,s,i){let r=w([...e.pathParams,...e.queryParams].map(l=>l.name),{style:"camel",reserved:h,taken:he}),t=e.pathParams.map((l,u)=>({php:r[u],wire:l.name,type:m(l.schema,n,i)})),a=e.queryParams.map((l,u)=>{let f=r[e.pathParams.length+u];return{php:f,wire:l.name,type:m(l.schema,n,i),value:N(l.schema,`$${f}`,n,i)??`$${f}`}}),o=[...t.map(({php:l,type:u})=>`${u} $${l}`),...s&&e.requestBody?[`${W(e)?"array":m(e.requestBody.schema,n,i)} $body`]:[],...a.map(({php:l,type:u})=>`${A(u)} $${l} = null`),"?array $headers = null",...s&&ue.has(e.method.toLowerCase())?["?string $idempotencyKey = null"]:[]];return{pathArgs:t,queryArgs:a,signature:o}}function ye(e,n,s){e.line(`$op = OPERATIONS[${c(n.specName??n.name)}];`),e.line("[$authHeaders, $query, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);");for(let{php:r,wire:t,value:a}of s.queryArgs)e.block(`if ($${r} !== null) {`,()=>{e.line(`$query[${c(t)}] = ${a};`)},"}");let i=s.pathArgs.map(({php:r,wire:t})=>`${c(t)} => $${r}`).join(", ");e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${i}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}")}function Q(e,n,s,i,r,t=!1){let a=z(n,i,!0,r),o=T(n),l=E(n),u=o===void 0&&l===void 0&&n.successResponses.some(k=>k.contentType!==""),f=t?"Envelope":o!==void 0?"\\Generator":l!==void 0?m(l,i,r):u?"string":"void",g=t?`${s}WithHeaders`:s,H=t?void 0:J(l,i,r);e.doc(g,t?`Like ${s}(), returning an Envelope with the declared response headers.`:n.summary??`${n.method.toUpperCase()} ${n.path}`,H===void 0?[]:[`@return ${H}[]`]),e.line(`public function ${g}(${a.signature.join(", ")}): ${f}`),e.block("{",()=>{if(ye(e,n,a),o!==void 0){let d=o.schema!==void 0&&o.schema.kind!=="unknown";e.line("$url = appendQuery($url, $query);"),e.block("$open = function (array $extraHeaders) use ($url, $requestHeaders): \\CurlHandle {",()=>{e.line("$handle = curl_init($url);"),e.line("$lines = [];"),e.block("foreach (array_merge($requestHeaders, $extraHeaders) as $name => $value) {",()=>{e.line("$lines[] = $name . ': ' . $value;")},"}"),e.line("curl_setopt($handle, CURLOPT_HTTPHEADER, $lines);"),e.line("return $handle;")},"};"),e.line(`yield from iterSse($open, ${d?"true":"false"});`);return}let k=["'operationId' => $op['id']","'method' => $op['method']","'url' => $url","'headers' => $requestHeaders","'query' => $query"];if(n.requestBody&&W(n))e.line("[$contentType, $encoded] = toMultipart($body);"),k.push("'body' => $encoded","'contentType' => $contentType");else if(n.requestBody){let d=N(n.requestBody.schema,"$body",i,r)??"$body";e.line(`$payload = json_encode(${d});`),k.push("'body' => $payload",`'contentType' => ${c(n.requestBody.contentType)}`)}ue.has(n.method.toLowerCase())&&n.requestBody&&k.push("'idempotencyKey' => $idempotencyKey"),e.line(`$response = send($this->config, [${k.join(", ")}]);`),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}");let $=u?"$response['body']":(l===void 0?void 0:v(l,"decodeJson($response)",i,r))??"decodeJson($response)";if(t){e.line(`$data = ${$};`),e.line(`return new Envelope(data: $data, headers: readEnvelopeHeaders($response, ${ce(n,i)}), status: $response['status']);`);return}if(u){e.line("return $response['body'];");return}if(f==="void"){e.line("decodeJson($response);");return}e.line(`return ${$};`)},"}"),e.blank()}function $e(e,n,s,i,r,t,a,o,l){let u=z(n,i,!1,r),f=s,g=()=>{e.line(`$op = OPERATIONS[${c(n.specName??n.name)}];`),e.line("$base = [];");for(let{php:d,wire:P,value:S}of u.queryArgs)e.block(`if ($${d} !== null) {`,()=>{e.line(`$base[${c(P)}] = ${S};`)},"}");let $=u.pathArgs.map(({php:d,wire:P})=>`${c(P)} => $${d}`).join(", ");e.block("$call = function (array $params) use ($op, $headers): array {",()=>{e.line("[$authHeaders, $authQuery, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);"),e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${$}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}"),e.line("$response = send($this->config, ['operationId' => $op['id'], 'method' => $op['method'], 'url' => $url, 'headers' => $requestHeaders, 'query' => array_merge($params, $authQuery)]);"),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}"),e.line("return [decodeJson($response), $response];")},"};")},H=m(E(n)??{kind:"unknown"},i,r),k=H==="mixed"?"mixed":H;e.line("/**"),e.line(` * ${f} response pages, following the pagination rule automatically.`),e.line(" *"),e.line(` * @return \\Generator<int, ${k}>`),e.line(" */"),e.line(`public function ${f}Pages(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`yield ${t??"$page"};`)},"}")},"}"),e.blank(),e.line("/**"),e.line(` * The items of every ${f} page.`),e.line(" *"),e.line(` * @return \\Generator<int, ${l}>`),e.line(" */"),e.line(`public function ${f}Items(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`$items = resolvePointer($page, ${c(o??"")});`),e.block("foreach (is_array($items) ? $items : [] as $item) {",()=>{e.line(`yield ${a??"$item"};`)},"}")},"}")},"}"),e.blank()}function ge(e){let n=e.split(`
|
|
8
8
|
`),s=0;for(let i=0;i<n.length;i++)if(n[i].trim().startsWith("namespace ")){s=i+1;break}return n.slice(s).join(`
|
|
9
9
|
`).trim()}var ln=({model:e,output:n,banner:s,emit:i,pagination:r})=>{let t=new q,a=i.dateType??"string",o=p(e.title,{style:"pascal",reserved:h});t.line("<?php"),t.blank(),t.line(`// Code generated by @redocly/client-generator (php) from ${c(e.title)} ${e.version}. DO NOT EDIT.`),t.line("// Regenerate with `redocly generate-client`. PHP >= 8.1, curl extension \u2014 zero Composer dependencies."),t.blank(),t.line("declare(strict_types=1);"),t.blank(),t.line(`namespace ${o};`),t.blank(),t.line(V(e,a)),se(t,e),i.runtime==="module"?(t.line("// \u2500\u2500\u2500 Runtime (a real file beside this one, written by the same run) \u2500\u2500\u2500"),t.line("require_once __DIR__ . '/runtime.php';"),t.blank()):(t.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator php runtime) \u2500\u2500\u2500"),t.line(ge(B)),t.blank());let l=e.services.flatMap($=>$.operations),u=K(e),f=new Map;for(let $ of l){let d=r?.get($.name)?.spec;d!==void 0&&f.set($.name,d)}t.block("const OPERATIONS = [",()=>{for(let $ of l){let d=$.specName??$.name,P=ae($,e),S=f.get($.name),M=[`'id' => ${c(d)}`,`'method' => ${c($.method.toUpperCase())}`,`'path' => ${c($.path)}`,...P!==void 0?[`'security' => ${P}`]:[],...S!==void 0?[`'pagination' => ${oe(S)}`]:[]];t.line(`${c(d)} => [${M.join(", ")}],`)}},"];"),t.blank(),t.doc("Client",`Client for ${e.title} (${e.version}).`),t.line("class Client"),t.block("{",()=>{t.line("public function __construct(private Config $config)"),t.block("{",()=>{t.block("if ($this->config->serverUrl === '') {",()=>{t.line(`$this->config->serverUrl = ${c(i.serverUrl??e.serverUrl??"")};`)},"}")},"}"),t.blank();for(let $ of l){let d=u.get($.name);Q(t,$,d,e,a),T($)===void 0&&($.successResponseHeaders?.length??0)>0&&Q(t,$,d,e,a,!0);let P=f.get($.name);if(P===void 0)continue;let S=E($),M=S===void 0?void 0:v(S,"$page",e,a),R=re(S,P.items,e),fe=R===void 0?void 0:v(R,"$item",e,a);$e(t,$,d,e,a,M,fe,P.items,R===void 0?"mixed":m(R,e,a))}},"}");let g={path:n.path.replace(/\.[^.\\/]+$/,".php"),content:t.toString()};if(i.runtime!=="module")return[g];let H=s.map($=>`// ${$}`).join(`
|
|
10
10
|
`),k=B.replace(/^namespace .*$/m,`namespace ${o};`).replace(/^<\?php\n/,`<?php
|
|
@@ -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{b as a,c as b,d as c}from"./
|
|
7
|
+
import{b as a,c as b,d as c}from"./7X6ZJPG4.js";import"./2U6O26CV.js";import"./42HL7XQH.js";import"./CGBDHCS4.js";import"./RSOM77DA.js";import"./BV72RZCF.js";import"./WZXA5XPB.js";import"./L2EEGRZN.js";import"./NEWT5A6S.js";import"./LD5MEXEL.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{b as cliDocs,a as cliGenerator,c as cliSample};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as $,b as a,c,d as i,e as m,f}from"./
|
|
7
|
+
import{a as $,b as a,c,d as i,e as m,f}from"./42HL7XQH.js";import{k as l}from"./LD5MEXEL.js";import{join as p}from"node:path";function k(t,n){let e=$(t,"swr");if(e.length===0)return"";let s=e.some(a),o=e.some(r=>!a(r));return[...s?['import useSWR from "swr";']:[],...o?['import useSWRMutation from "swr/mutation";']:[],f(e,n.sdkModule,s),...e.flatMap(r=>a(r)?g(r):[S(r)])].join(`
|
|
8
8
|
|
|
9
9
|
`)}function y(t,n,e){return`export function use${l(t.name)}(${n}) {
|
|
10
10
|
return ${e};
|
|
@@ -4,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 U}from"./2U6O26CV.js";import{b as Z,c as R,d as L,e as Y,f as oe,g as K,h as re}from"./
|
|
7
|
+
import{c as U}from"./2U6O26CV.js";import{b as Z,c as R,d as L,e as Y,f as oe,g as K,h as re}from"./RSOM77DA.js";import{a as X,c as F,d as k,e as D,g as B,h as T,i as ee,j as ne,k as te,l as H,n as se}from"./UW4UC7ZI.js";var M=F.python,j=class extends X{constructor(){super(" ")}typeName(n){return k(n,{style:"pascal",reserved:M})}memberName(n){let t=k(n,{style:"snake",reserved:M});return{identifier:t,renamed:t!==n}}identifier(n){return k(n,{style:"snake",reserved:M})}identifiers(n,t){return D(n,{style:"snake",reserved:M,taken:t})}constName(n){return k(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
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 H(n))this.line(t===""?"#":`# ${t}`);return this}doc(n){let t=H(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 N=F.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:N});return n.map((s,r)=>({op:s,ident:t[r]}))}var W=["self","body","headers","timeout","retry","idempotency_key"];function ae(e){return f.literal(e)}function ie(e){if(e!==void 0)return{style:e.style,...e.param!==void 0?{param:e.param}:{},...e.nextCursor!==void 0?{next_cursor:e.nextCursor}:{},...e.hasMore!==void 0?{has_more:e.hasMore}:{},...e.limitParam!==void 0?{limit_param:e.limitParam}:{},...e.items!==void 0?{items:e.items}:{}}}function ce(e,n){let t=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let a=k(r.name,{style:"snake",reserved:N}),c=a,i=2;for(;t.has(c);)c=`${a}_${i++}`;t.add(c);let m=se(r.schema,n);return`(${f.string(r.name)}, ${f.string(c)}, ${f.string(m)})`}).join(", ")}]`}function y(e,n="string"){if(ee(e))return`Optional[${y(ne(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[${y(e.items,n)}]`;case"record":return`Dict[str, ${y(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=>y(t,n)).join(", ")}]`;case"null":return"None";case"omit":return O(e.base);case"object":case"intersection":case"unknown":return"Any"}}function G(e,n,t,s,r,a,c,i=!1){let m=D([...n.pathParams,...n.queryParams].map(S=>S.name),{style:"snake",reserved:N,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}: ${y(S.schema,a)}`),u=n.requestBody?[`body: ${y(n.requestBody.schema,a)}`]:[],$=[...o.map(({param:S,python:v})=>{let A=y(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"],h=R(n),g=L(n),x=i?`Envelope[${h===void 0?"None":y(h,a)}]`:g!==void 0?`${r?"AsyncIterator":"Iterator"}[ServerSentEvent]`:s==="result"?"Result":h===void 0?"None":y(h,a),P=r&&g===void 0?"async def":"def",p=r?"await ":"",_=r?"send_async":"send",b=["self",...d,...u,"*",...$].join(", "),w=i?`${t}_with_headers`:t;e.block(`${P} ${w}(${b}) -> ${x}:`,()=>{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}})`),g!==void 0){let E=g.schema!==void 0&&g.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}Y(n)&&e.line("form_data, form_files = to_multipart(body)");let v=n.requestBody?Y(n)?", data=form_data, files=form_files":", json_body=encode(body)":"";e.line(`response = ${p}${_}(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=h===void 0?"None":`decode(${y(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, ${ce(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(h===void 0?"return None":`return ${A}`))}),e.blank()}function le(e,n,t,s,r,a){let c=R(n),i=c===void 0?"Any":y(c,a),m=D([...n.pathParams,...n.queryParams].map(p=>p.name),{style:"snake",reserved:N,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:_})=>`${_}: ${y(p.schema,a)}`),u=[...o.map(({param:p,python:_})=>{let b=y(p.schema,a),w=b.startsWith("Optional[")?b:`Optional[${b}]`;return`${_}: ${w} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],$=["self",...d,"*",...u].join(", "),h=s?"AsyncIterator":"Iterator",g=s?"aiter_pages":"iter_pages",x=s?"aiter_items":"iter_items",P=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:b,python:w}of o)e.block(`if ${w} is not None:`,()=>{e.line(`base[${f.string(b.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 b=l.map(({param:w,python:S})=>`${f.string(w.name)}: ${S}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${b}})`),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(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for page in ${g}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${t}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.block(`async for item in ${x}(_page, op["pagination"], base):`,()=>{e.line(r==="Any"?"yield item":`yield decode(${r}, item)`)})})):(e.block(`def ${t}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(i==="Any"?`return ${g}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${g}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${t}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${t}"]`),P(),e.line(r==="Any"?`return ${x}(_page, op["pagination"], base)`:`return (decode(${r}, item) for item in ${x}(_page, op["pagination"], base))`)})),e.blank()}function me(e){return oe(e).map(t=>t.kind==="literal"?f.string(t.value):q(t.name).python).join(" + ")}function de(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=k(r.description??`server${a+1}`,{style:"snake",reserved:N});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 ${me(r)}`)})})}),e.blank()}function V(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)){G(e,l,o,t,s,c),L(l)===void 0&&(l.successResponseHeaders?.length??0)>0&&G(e,l,o,t,s,c,n,!0);let d=r.get(o);if(d!==void 0){let u=R(l),$=re(u,typeof d.items=="string"?d.items:void 0,n);le(e,l,o,s,$===void 0?"Any":y($,c),c)}}}),e.blank()}function z(e){let n=new Map,t=new Set,s=[];for(let{name:a,schema:c}of e.schemas){let i=T(c,e);if(!(i===void 0||!i.cases.every(l=>B(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 fe(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:$}=q(d.name);$&&!i&&o.push([u,d.name]);let h=$&&i?`alias=${f.string(d.name)}`:void 0,g=c?.property===d.name?`Literal[${f.literal(c.value)}]`:y(d.schema,s);if(d.required){let x=h===void 0?"":` = Field(${h})`;e.line(`${u}: ${g}${x}`)}else{let x=g.startsWith("Optional[")?g:`Optional[${g}]`,P=h===void 0?"None":`Field(default=None, ${h})`;e.line(`${u}: ${x} = ${P}`)}}if(o.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let d=o.map(([u,$])=>`"${u}": ${f.string($)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${d}}`)}}),e.blank(),e.blank()}function J(e,n="string",t="dataclass"){let s=new j,{pins:r,unions:a}=t==="pydantic"?z(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=te(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,$)=>{s.line(`${o.memberNames[$]} = ${f.literal(u)}`)})}),s.blank(),s.blank();continue}if(l.kind==="object"||l.kind==="intersection"){let d=B(l,e);if(d!==void 0){fe(s,m,d.properties,n,t,d.description??l.description,r.get(m));continue}}i.push(()=>{let d=T(l,e);if(d!==void 0){let h=d.cases.map(g=>`${g.value} -> ${O(g.schemaName)}`).join(", ");s.line(`# Discriminated by "${d.property}": ${h}`)}let u=a.get(m),$=u===void 0?y(l,n):`Annotated[${y(l,n)}, Field(discriminator=${f.string(u)})]`;s.line(`${O(m)} = ${$}`),s.blank()})}for(let m of i)m();return s.toString()}function pe(e,n){let t=[];for(let{name:s,schema:r}of e.schemas){if(n.has(s))continue;let a=T(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 nn={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 Q(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}${k(r,{style:"snake",reserved:N})}.py`}var tn=({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"?z(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(J(e,i,m).trimEnd()),o.blank(),o.blank(),de(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
9
|
`).filter(b=>!b.startsWith("from __future__")&&!b.startsWith("from ._")).join(`
|
|
10
10
|
`).trim();o.line(_),o.blank()}o.blank()}let d=pe(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(_,ie(a?.get(p.name)?.spec));o.line("_OPERATIONS = {"),o.indent(()=>{for(let{op:p,ident:_}of I(e)){let b={id:p.specName??p.name,method:p.method.toUpperCase(),path:p.path,...K(p,e).length>0?{security:K(p,e)}:{},...u.get(_)!==void 0?{pagination:u.get(_)}:{}};o.line(`"${_}": ${ae(b)},`)}}),o.line("}"),o.blank(),o.blank();let $=s.serverUrl??e.serverUrl??"";V(o,e,c,!1,u,$,i),V(o,e,c,!0,u,$,i);let h={path:Q(n.path),content:o.toString()};if(s.runtime!=="module")return[h];let g=t.map(p=>`# ${p}`).join(`
|
|
@@ -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{h as g}from"./
|
|
7
|
+
import{h as g}from"./CGBDHCS4.js";import{k as u,l as m}from"./RSOM77DA.js";import{c as C,d as j}from"./BV72RZCF.js";import{X as b}from"./L2EEGRZN.js";import{a as S,b as k}from"./UW4UC7ZI.js";import{join as $}from"node:path";function h(r){return(r??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function v(r){return[r.group===void 0?void 0:u(r.group),r.name].filter(Boolean).join(" ")}function N(r,e){return[r,v(e),...e.positionals.map(o=>`<${o.name}>`),...e.flags.filter(o=>o.required).map(o=>`--${o.name} <${o.type}>`),...e.body?[e.body.required?"--json '<json>'":"[--json '<json>']"]:[]].filter(o=>o!=="").join(" ")}function T(r,e){r.line("| Flag | Type | Required | Description |"),r.line("| ---- | ---- | -------- | ----------- |");for(let n of e){let o=[h(n.description),n.enum===void 0?"":`One of ${n.enum.map(t=>`\`${t}\``).join(", ")}.`,n.type==="array"?"Repeat the flag for multiple values.":""].filter(t=>t!=="").join(" ");r.line(`| \`--${n.name}\` | ${n.type} | ${n.required?"yes":"no"} | ${o} |`)}r.blank()}function D(r,e,n){if(r.line(`### \`${v(e)}\``),r.blank(),e.summary!==void 0&&(r.line(h(e.summary)),r.blank()),r.line(`\`${e.method} ${e.path}\``),r.blank(),r.line("```sh"),r.line(N(n.name,e)),r.line("```"),r.blank(),e.positionals.length>0){r.line("| Argument | Description |"),r.line("| -------- | ----------- |");for(let t of e.positionals)r.line(`| \`<${t.name}>\` | ${h(t.description)} |`);r.blank()}e.flags.length>0&&T(r,e.flags);let o=[e.body===void 0?"":`Takes a JSON body${e.body.required?" (required)":""}: \`--json '<json>'\`, \`--json @file.json\`, or \`--json @-\` for stdin.`,e.unsupportedBody===void 0?"":`Takes a \`${e.unsupportedBody}\` body, which the CLI cannot build \u2014 call this operation through the generated client instead.`,e.paginated===!0?"Paginated: `--page-all` follows every page, printing one JSON page per line.":"",e.sse===!0?"Streams server-sent events as one JSON object per line.":"",e.blob===!0?"Returns binary content, so `--output <path>` is required.":""].filter(t=>t!=="");for(let t of o)r.line(t);o.length>0&&r.blank()}function w(r,e){let n=new S;e.frontmatter&&(n.line("---"),n.line(`title: ${e.title}`),n.line("---"),n.blank()),n.line(`# ${e.title}`),n.blank(),n.line(`Generated command-line reference for \`${e.name}\`, produced from the API description by \`redocly generate-client\`.`),n.line("Re-run generation to update it \u2014 this file is not hand-edited."),n.blank(),n.line("## Usage"),n.blank(),n.line("```sh"),n.line(`${e.name} <command> [flags]`),n.line(`${e.name} --help`),n.line(`${e.name} schema <command> # request/response schemas`),n.line("```"),n.blank(),n.line("Install the file under any `bin` name: the command takes that name, and the credential variables below do not change."),n.blank(),n.line("## Global flags"),n.blank(),n.line("| Flag | Description |"),n.line("| ---- | ----------- |");let o=e.schemes.some(i=>i.kind==="bearer");for(let[i,s]of[["--server-url <url>","Override the server URL included in the client."],["--format <json\\|ndjson>","Output format."],["--dry-run","Print the prepared request, credentials redacted, without sending it."],["--page-all","Follow pagination, printing one JSON page per line."],["--output <path>","Write the response body to a file. Required for binary responses."],...o?[["--token <token>","Bearer token, overriding the environment."]]:[],["--json <json\\|@file\\|@->","Request body, inline or from a file or stdin."]])n.line(`| \`${i}\` | ${s} |`);n.blank();let t=m(e.name);if(n.line("## Credentials"),n.blank(),e.schemes.length===0)n.line("The description declares no security schemes, so no credentials are read.");else{n.line("Credentials come from the environment:"),n.blank(),n.line("| Scheme | Variable |"),n.line("| ------ | -------- |");for(let i of e.schemes){let s=i.kind==="bearer"?`\`${t}_TOKEN\` (or \`--token\`)`:i.kind==="basic"?`\`${t}_USERNAME\` and \`${t}_PASSWORD\``:`\`${t}_API_KEY_${m(i.key)}\``;n.line(`| ${i.kind} (\`${i.key}\`) | ${s} |`)}}n.blank(),n.line("## Exit codes"),n.blank(),n.line("| Code | Meaning |"),n.line("| ---- | ------- |");for(let[i,s]of[[0,"success"],[1,"API error (status other than 401 or 403)"],[2,"auth error (401 or 403)"],[3,"validation error"],[4,"usage error (unknown command or flag, bad `--json`)"]])n.line(`| ${i} | ${s} |`);n.blank(),n.line("Errors print one JSON object to stderr, so stdout stays clean for piping."),n.blank();let a=[...new Set(r.map(i=>i.group))];for(let i of a){let s=r.filter(l=>l.group===i);i===void 0?(n.line("## Commands"),n.blank()):(n.line(`## ${i}`),n.blank(),n.line(`Addressed as \`${e.name} ${u(i)} <command>\`.`),n.blank());for(let l of s)D(n,l,e)}return n.toString().replace(/\n{3,}/g,`
|
|
8
8
|
|
|
9
9
|
`).trimEnd()+`
|
|
10
10
|
`}function R(){return j["cli.ts"]}function x(){return C["cli.ts"]}var O="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function q(r){return k.snake(r).replace(/_/g,"-")}function E(r){let e=r.schema,n=e.kind==="array"?"array":e.kind==="scalar"&&(e.scalar==="integer"||e.scalar==="number")?"number":e.kind==="scalar"&&e.scalar==="boolean"?"boolean":"string";return{name:q(r.name),param:r.name,type:n,required:r.required,...e.kind==="enum"?{enum:e.values.map(String)}:{},...r.description!==void 0?{description:r.description}:{}}}function F(r){let e=r.successResponses;return e.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function M(r){return r.successResponses.find(e=>e.contentType.toLowerCase().includes("json"))?.schema}function U(r,e,n){if(n!=="flat")return{};let o=g(r,e.schemas);return"mergeBody"in o&&o.mergeBody?{merged:!0}:{}}function _(r,e,n){return n!=="flat"?{}:"collisions"in g(r,e.schemas)?{argsStyle:"grouped"}:{}}function f(r,e){let n=[];for(let o of r.services)for(let t of o.operations){let a=t.requestBody?.contentType.toLowerCase().includes("json")?t.requestBody:void 0,i=M(t);n.push({...t.tags.length>0?{group:t.tags[0]}:{},name:t.name,...t.summary!==void 0?{summary:t.summary}:{},method:t.method.toUpperCase(),path:t.path,positionals:t.pathParams.map(s=>({name:s.name,type:E(s).type,...s.description!==void 0?{description:s.description}:{}})),flags:t.queryParams.map(E),...a?{body:{required:a.required,...U(t,r,e.argsStyle)}}:{},...a===void 0&&t.requestBody!==void 0?{unsupportedBody:t.requestBody.contentType}:{},...e.pagination?.has(t.name)===!0?{paginated:!0}:{},..._(t,r,e.argsStyle),...t.sse!==void 0?{sse:!0}:{},...F(t)?{blob:!0}:{},...a!==void 0||i!==void 0?{schemas:{...a?{request:a.schema}:{},...i!==void 0?{response:i}:{}}}:{}})}return n}var P=`function isProcessEntry(): boolean {
|
|
@@ -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,f}from"./
|
|
7
|
+
import{a,b,c,d,e,f}from"./7GJ7DF3O.js";import"./2U6O26CV.js";import"./RSOM77DA.js";import"./BV72RZCF.js";import"./WZXA5XPB.js";import"./L2EEGRZN.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{f as pythonDocs,d as pythonGenerator,c as pythonOptions,e as pythonSample,a as pythonType,b as renderPythonModels};
|
|
@@ -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"./BV72RZCF.js";import{c as w}from"./L2EEGRZN.js";import{a as H,e as q,g as P,h as g,k as E}from"./LD5MEXEL.js";import{join as ae}from"node:path";var j=class{code;constructor(r){this.code=r}};function A(e,r,n={}){let t=new Map(r.map(s=>[s.name,s.schema])),o=k(e,t,new Set,n.dateType??"string");return o===b?null:o}var b=Symbol("cycle");function J(e,r){if(e.kind==="union"){for(let t of e.members){let o=J(t,r);if(o)return o}return}if(e.kind!=="scalar")return;let n=e.metadata?.format;if(n==="binary")return new j("new Blob([])");if(r==="Date"){if(n==="date-time")return new j('new Date("2024-01-01T00:00:00Z")');if(n==="date")return new j('new Date("2024-01-01")')}}function I(e,r){let n=new Map,t=[],o=!1;for(let s of e){if(s.kind==="unknown")continue;let i=G(s,r);if(i?.kind!=="object"){t.push(s);continue}o=!0;for(let a of i.properties){let u=O(a.schema,r,new Set),c=n.get(a.name);(c===void 0||u>=c.rank)&&n.set(a.name,{schema:a.schema,required:a.required||(c?.required??!1),rank:u})}}return o?{merged:{kind:"object",properties:[...n.entries()].map(([s,i])=>({name:s,schema:i.schema,required:i.required}))},rest:t}:{merged:void 0,rest:t}}function G(e,r){let n=new Set,t=e;for(;t?.kind==="ref";){if(n.has(t.name))return;n.add(t.name),t=r.get(t.name)}return t}function O(e,r,n){switch(e.kind){case"literal":return 40;case"enum":return e.values.length===1?40:30;case"union":return Math.max(0,...e.members.map(t=>O(t,r,n)))-1;case"ref":{if(n.has(e.name))return 20;let t=r.get(e.name);return t===void 0?20:O(t,r,new Set(n).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,r,n,t){let o=J(e,t);if(o)return o;let s=e.metadata,i=a=>a===null?e.kind==="null"||e.kind==="union"&&e.members.some(u=>u.kind==="null"):e.kind==="enum"?e.values.includes(a):e.kind==="literal"?a===e.value:!0;if(s?.example!==void 0&&i(s.example))return s.example;if(s?.default!==void 0&&i(s.default))return s.default;switch(e.kind){case"scalar":return K(e.scalar,s);case"array":{let a=k(e.items,r,n,t);return a===b?[]:[a]}case"object":return Object.fromEntries(e.properties.flatMap(a=>{let u=k(a.schema,r,n,t);return u===b?a.required?[[a.name,null]]:[]:[[a.name,u]]}));case"record":{let a=k(e.value,r,n,t);return a===b?{}:{key:a}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let a of e.members){let u=k(a,r,n,t);if(u!==b)return u}return e.members.length>0?b:null}case"intersection":{let{merged:a,rest:u}=I(e.members,r),c=u.map(m=>k(m,r,n,t)).filter(m=>m!==b);if(a){let m=k(a,r,n,t),M=w(m)?m:{};for(let V of c)w(V)&&Object.assign(M,V);return M}let h=c.filter(w);return h.length>0?h.reduce((m,M)=>Object.assign(m,M),{}):c.length>0?c[0]:{}}case"omit":{let a=r.get(e.base);if(!a)return null;let u=k(a,r,n,t);if(w(u)){let c={...u};for(let h of e.keys)delete c[h];return c}return u}case"ref":{if(n.has(e.name))return b;let a=r.get(e.name);if(!a)return null;n.add(e.name);let u=k(a,r,n,t);return n.delete(e.name),u}case"null":case"unknown":return null}}function K(e,r){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(r?.format){case"email":return"user@example.com";case"uuid":return"00000000-0000-4000-8000-000000000000";case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"uri":case"url":return"https://example.com";default:return"string"}}var f=e=>({kind:"expr",text:e}),d=e=>({kind:"object",entries:e});function l(e){return e.kind==="object"}function D(e,r){return l(e)?d([...e.entries,{spread:r}]):e}var L=" ";function x(e,r){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${x(e.value,r)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let n=r+L;return`[
|
|
8
8
|
${e.items.map((o,s)=>`${n}${x(o,n)}${s===e.items.length-1?"":","}`).join(`
|
|
9
9
|
`)}
|
|
10
10
|
${r}]`}case"object":{if(e.entries.length===0)return"{}";let n=r+L;return`{
|
|
@@ -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 q}from"./
|
|
7
|
+
import{a as q}from"./HITQPK62.js";import{h as H,l as B,q as z,s as K,t as V,u as Z,v as _}from"./4UWA75AV.js";import{c as J,d as M,e as Y,u as k}from"./CUB5GMHZ.js";import"./BXI4SF2U.js";import{I as D,M as v,O,P as A,Q as j,R as L,T as y,U as P,V as R,X as e,fa as S,ia as g,l as h,na as C,oa as F}from"./L2EEGRZN.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";import{dirname as le}from"node:path";function W(r,t,o,n){n&&e.info(P(v(`
|
|
8
8
|
\u2611\uFE0F Achieved Level: ${y(o)}
|
|
9
9
|
|
|
10
10
|
`))),e.output(`<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -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{X as O,c as x}from"./
|
|
7
|
+
import{X as O,c as x}from"./L2EEGRZN.js";import{m}from"./UW4UC7ZI.js";function R(e){return e.flatMap(n=>n.operations)}function P(e,n,s){let r=e.specName??e.name;if(s?.exclude?.includes(r))return{};let a=s?.operations?.[r];if(a!==void 0)return y(e,n,a,`pagination.operations["${r}"]`,!0);if(e.paginationExtension!==void 0)return y(e,n,e.paginationExtension,"x-redoclyPagination",!0);if(s?.style!==void 0){let{exclude:o,operations:c,...t}=s;return y(e,n,t,"pagination convention",!1)}return{}}function H(e,n){let s=new Map,r=[];for(let a of R(e.services)){let o=P(a,e,n);o.error!==void 0?r.push(o.error):o.spec!==void 0&&s.set(a.name,{spec:o.spec,itemSchema:o.itemSchema})}if(r.length>0)throw new Error(["Invalid pagination configuration:",...r].join(`
|
|
8
8
|
- `));return s}function y(e,n,s,r,a){let o=`Pagination for operation "${e.name}" (${r})`,c=q(s);if(c!==void 0)return{error:`${o}: ${c}`};let t=s,d=i=>a?{error:`${o}: ${i}`}:{};if(e.sse!==void 0)return d("the operation is a Server-Sent Events stream");if(t.style!=="link"){let i=t.style==="cursor"?"cursorParam":"offsetParam",l=t.style==="cursor"?t.cursorParam:t.offsetParam,k=e.queryParams.find(u=>u.name===l);if(!k){let u=e.queryParams.map(E=>E.name).join(", ");return d(`query parameter "${l}" is not declared on the operation`+(u===""?"":` (declared: ${u})`))}let p=C(k.schema,n);if(!(p!==void 0&&(t.style==="cursor"?b(p,n):p.kind==="scalar"&&(p.scalar==="number"||p.scalar==="integer")))){let u=t.style==="cursor"?"a string":"a number";return d(`the "${i}" query parameter "${l}" must accept ${u} (got ${I(p)})`)}}let g=e.successResponses.find(i=>i.contentType.toLowerCase().includes("json"));if(!g)return d("the operation has no JSON success response");if(t.style==="link"){let i=e.successResponseHeaders?.some(l=>l.name==="link")===!0;if(!i&&!a)return{};i||O.warn(`generate-client: ${o.toLowerCase()} follows the Link header, but the success response does not document one.
|
|
9
9
|
`)}let h=m(g.schema,t.items,n);if(h===void 0)return d(`the "items" pointer "${t.items}" does not resolve in the success response schema`);if(h.kind!=="array")return d(`the "items" pointer "${t.items}" must point at an array (got ${h.kind})`);if(t.style==="cursor"){let i=m(g.schema,t.nextCursor,n);if(i===void 0)return d(`the "nextCursor" pointer "${t.nextCursor}" does not resolve in the success response schema`);if(!b(i,n))return d(`the "nextCursor" pointer "${t.nextCursor}" must point at a string (got ${i.kind})`);if(t.hasMore!==void 0){let l=m(g.schema,t.hasMore,n);if(l===void 0)return d(`the "hasMore" pointer "${t.hasMore}" does not resolve in the success response schema`);if(l.kind!=="scalar"||l.scalar!=="boolean")return d(`the "hasMore" pointer "${t.hasMore}" must point at a boolean (got ${l.kind})`)}}let f=t.limitParam!==void 0?{limitParam:t.limitParam}:{};return{spec:t.style==="cursor"?{style:"cursor",param:t.cursorParam,...f,nextCursor:t.nextCursor,...t.hasMore!==void 0?{hasMore:t.hasMore}:{},items:t.items}:t.style==="link"?{style:"link",...f,items:t.items}:{style:t.style,param:t.offsetParam,...f,items:t.items},itemSchema:h.items}}function q(e){if(!x(e))return"the rule must be an object";let{style:n,cursorParam:s,nextCursor:r,hasMore:a,offsetParam:o,limitParam:c,items:t}=e;if(n!=="cursor"&&n!=="offset"&&n!=="page"&&n!=="link")return`"style" must be one of "cursor" | "offset" | "page" | "link" (got ${JSON.stringify(n)})`;if(typeof t!="string"||t!==""&&!t.startsWith("/"))return'"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';if(n==="cursor"){if(typeof s!="string"||s==="")return'cursor style requires a "cursorParam" query parameter name';if(typeof r!="string"||!r.startsWith("/"))return'cursor style requires a "nextCursor" JSON pointer starting with "/"';if(a!==void 0&&(typeof a!="string"||!a.startsWith("/")))return'"hasMore" must be a JSON pointer starting with "/"'}else if((n==="offset"||n==="page")&&(typeof o!="string"||o===""))return`${n} style requires an "offsetParam" query parameter name`;if(c!==void 0&&typeof c!="string")return'"limitParam" must be a query parameter name'}function I(e){return e===void 0?"an unresolvable ref":e.kind==="scalar"||e.kind==="enum"?e.scalar:e.kind}function C(e,n){let s=new Set,r=e;for(;r.kind==="ref";){let{name:a}=r;if(s.has(a))return;s.add(a);let o=n.schemas.find(c=>c.name===a);if(o===void 0)return;r=o.schema}return r}function b(e,n){return e.kind==="scalar"||e.kind==="enum"?e.scalar==="string":e.kind==="literal"?typeof e.value=="string":e.kind==="union"?e.members.every(s=>{let r=C(s,n);return r!==void 0&&(r.kind==="null"||r.kind!=="union"&&b(r,n))}):!1}var G={"types.ts":`/**
|
|
10
10
|
* The public type surface of the client runtime \u2014 \`@redocly/client-generator\`'s
|
|
@@ -5397,4 +5397,4 @@ async function runSingle(
|
|
|
5397
5397
|
}
|
|
5398
5398
|
return fail(1, detail);
|
|
5399
5399
|
}
|
|
5400
|
-
}`},S=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var j=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],$=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],N=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],w;function Q(){return w===void 0&&(w=new Set([...j,...$,...N,...S])),w}var A={name:"@redocly/client-generator",version:"0.4.
|
|
5400
|
+
}`},S=["ApiError","ApiErrorLike","AuthCredentials","BodyMethod","Capabilities","CliAuthScheme","CliCommand","CliFlag","CliGlobals","CliInvocation","CliWiring","Client","ClientConfig","ClientCore","CommandContext","CommandSource","CustomCommand","Envelope","EnvelopeResult","EnvelopeResultForKnownInit","FRAME_DELIMITER","GLOBAL_FLAGS","HeadersOf","IDEMPOTENT_METHODS","LAYERS","LAYER_OF","LinkPageCall","Middleware","NoRequiredKeys","OperationArgs","OperationContext","OperationDescriptor","OperationMethodIdentity","OpsShape","PageOf","Paginated","PaginationSpec","ParamSpec","ParseAs","QueryStyle","QueryValue","RequestContext","RequestOptions","ResolvedCommand","ResponseHeaderSpec","Result","RetryConfig","RetryContext","RetryStrategy","SecuritySpec","SendCapabilities","ServerSentEvent","SseOptions","SseParseError","TRANSIENT_STATUS","ThrowMethod","TimeoutError","TokenProvider","abortError","acceptFor","buildUrl","callInputs","coerceResponseHeader","commandContract","constantCase","createClientCore","defaultRetryOn","encodeBase64","encodeReserved","execute","groupSlug","inputOf","invokedName","isConfigured","items","itemsByLink","kindFor","linkNext","linkPageCall","loadBody","mergeSetup","middlewareChain","namespaceArgs","normalizeCommands","oneLine","pageCall","pages","pagesByLink","paginateCapability","parse","parseInvocation","parseSseFrame","prepareRequest","queryStyles","readEnvelopeHeaders","readError","redactHeaders","renderComposedHelp","renderHelp","resolveAuth","resolvePointer","resolveToken","retryDelay","runCli","runSingle","runSources","send","shadowedCommandName","sleep","splitArgs","sse","stringHeaders","substitutePath","toFormData","toHeaderRecord"];var j=["client","OPERATIONS","Ops","OperationId","OperationPath","OperationTag","createClient","mergeSetup","ApiError","TimeoutError","configure","use","auth","defaultRetryOn","ClientConfig","RequestOptions","SseOptions","Middleware","OperationDescriptor","ServerSentEvent","Result","Envelope","EnvelopeResult","TokenProvider","__redoclySetup"],$=["z","http","HttpResponse","handlers","faker","queryOptions","useSWR","useSWRMutation","__Writable"],N=["AbortSignal","Array","ArrayBuffer","ArrayBufferView","AsyncGenerator","AsyncIterable","Blob","BodyInit","Boolean","DOMException","Date","Error","Extract","FormData","Headers","HeadersInit","JSON","Map","Math","NonNullable","Number","Object","Omit","Partial","Promise","ReadableStream","Record","RegExp","RegExpExecArray","Request","RequestInit","Response","Set","String","TextDecoder","TextEncoder","TypeError","Uint8Array","URL","URLSearchParams","btoa","clearTimeout","crypto","decodeURIComponent","document","encodeURIComponent","fetch","globalThis","setTimeout","undefined"],w;function Q(){return w===void 0&&(w=new Set([...j,...$,...N,...S])),w}var A={name:"@redocly/client-generator",version:"0.4.15",description:"Generate typed, zero-dependency TypeScript clients (fetch, auth, retries, middleware, SSE) from OpenAPI descriptions.",type:"module",types:"lib/index.d.ts",sideEffects:!1,exports:{".":{types:"./lib/index.d.ts",import:"./lib/index.js",default:"./lib/index.js"},"./generate":{types:"./lib/generate.d.ts",import:"./lib/generate.js",default:"./lib/generate.js"},"./printers/python":{types:"./lib/printers/python.d.ts",import:"./lib/printers/python.js",default:"./lib/printers/python.js"},"./printers/go":{types:"./lib/printers/go.d.ts",import:"./lib/printers/go.js",default:"./lib/printers/go.js"},"./printers/php":{types:"./lib/printers/php.d.ts",import:"./lib/printers/php.js",default:"./lib/printers/php.js"},"./printers/typescript":{types:"./lib/printers/typescript.d.ts",import:"./lib/printers/typescript.js",default:"./lib/printers/typescript.js"},"./printers":{types:"./lib/printers/index.d.ts",import:"./lib/printers/index.js",default:"./lib/printers/index.js"},"./contracts/typescript":{types:"./lib/contracts/typescript.d.ts",import:"./lib/contracts/typescript.js",default:"./lib/contracts/typescript.js"},"./runtime-sources":{types:"./lib/runtime-sources.d.ts",import:"./lib/runtime-sources.js",default:"./lib/runtime-sources.js"},"./package.json":"./package.json"},engines:{node:">=22.12.0 || >=20.19.0 <21.0.0",npm:">=10"},engineStrict:!0,scripts:{"examples:regen":"node scripts/regenerate-examples.mjs",prepare:"node scripts/generate-runtime-sources.mjs && node scripts/generate-eject-assets.mjs","typecheck:examples":"node scripts/typecheck-examples.mjs"},license:"MIT",repository:{type:"git",url:"git+https://github.com/Redocly/redocly-cli.git"},homepage:"https://github.com/Redocly/redocly-cli",keywords:["OpenAPI","Swagger","TypeScript","client","generator","codegen","fetch"],contributors:["Roman Marshevskyi <roman.marshevskyy@redocly.com> (https://redocly.com/)"],dependencies:{"@redocly/openapi-core":"2.54.2"},peerDependencies:{typescript:">=5.5.0"},peerDependenciesMeta:{typescript:{optional:!0}},devDependencies:{typescript:"6.0.2"},files:["lib","eject-assets"]};var ee=A.version;function T(e){let n=/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e.trim());return n===null?void 0:[Number(n[1]),Number(n[2]),Number(n[3])]}function v(e,n){return e[0]-n[0]||e[1]-n[1]||e[2]-n[2]}function ne(e,n){let s=/^[\^~]|^>=/.exec(n.trim())?.[0]??"",r=T(n.trim().slice(s.length)),a=T(e);if(!(r===void 0||a===void 0))return v(a,r)<0?!1:s===">="?!0:s===""?v(a,r)===0:s==="~"?a[0]===r[0]&&a[1]===r[1]:r[0]!==0?a[0]===r[0]:r[1]!==0?a[0]===0&&a[1]===r[1]:v(a,r)===0}export{R as a,H as b,G as c,W as d,j as e,Q as f,ee as g,ne as h};
|
|
@@ -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}from"./
|
|
7
|
+
import{a as T}from"./BV72RZCF.js";import{a as R,e as P,f as x,i as v,j as H,k as l,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 C(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:`${l(e.name)}Variables`}}var O=" ";function $(e,t,n){let r=H(e,t);return r===void 0?[]:[`${n}/**`,...v(r).split(`
|
|
8
8
|
`).map(s=>`${n} * ${s}`.replace(/ +$/,"")),`${n} */`]}function I(e){return typeof e=="string"?JSON.stringify(e):String(e)}function V(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 B(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 V(e.scalar,e.metadata,t);case"ref":return e.name;case"literal":return I(e.value);case"enum":return e.values.map(I).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let r=c(e.items,t,n);return B(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+O;return`{
|
|
9
9
|
${e.properties.flatMap(o=>W(o,t,r)).join(`
|
|
10
10
|
`)}
|