@redocly/cli 2.51.0 → 2.51.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 +2 -2
- package/lib/chunks/{3XSOTIDJ.js → 2QB2GQK4.js} +1 -1
- package/lib/chunks/57HELKSP.js +11 -0
- package/lib/chunks/5FCIOXHF.js +7 -0
- package/lib/chunks/75JBXLYL.js +7 -0
- package/lib/chunks/{65LLBIQA.js → ADW6GVRA.js} +1 -1
- package/lib/chunks/{IPFRJMV6.js → AEUD4DDQ.js} +1 -1
- package/lib/chunks/BFHO7GW5.js +97 -0
- package/lib/chunks/C2P2K3EL.js +7 -0
- package/lib/chunks/{TMULAWFD.js → CHYVBQIC.js} +1 -1
- package/lib/chunks/{3JJEI7CJ.js → CQMMUWIJ.js} +99 -95
- package/lib/chunks/{MXZKXUIJ.js → D2LIZR7C.js} +1 -1
- package/lib/chunks/{B3QINORT.js → D3EE6JIC.js} +1 -1
- package/lib/chunks/{QKWUIMTP.js → D6R7VN2E.js} +1 -1
- package/lib/chunks/DV6O45KM.js +20 -0
- package/lib/chunks/F2OX5CFF.js +7 -0
- package/lib/chunks/H7GBQYOQ.js +20 -0
- package/lib/chunks/{NSKVRJLY.js → HJBZSEOJ.js} +1 -1
- package/lib/chunks/{46OWJR6X.js → HTZLTEUF.js} +1 -1
- package/lib/chunks/{CA4BPC77.js → ITXYN4EV.js} +1 -1
- package/lib/chunks/{NWMTC4AN.js → IULINGO6.js} +1 -1
- package/lib/chunks/{TKFA7G4G.js → JGDGNU3W.js} +1 -1
- package/lib/chunks/{TSB6PODJ.js → JM7BMZLD.js} +1 -1
- package/lib/chunks/{NGC5R7OH.js → JW436AQL.js} +1 -1
- package/lib/chunks/LD5MEXEL.js +10 -0
- package/lib/chunks/{73NWWLM3.js → MA3DQUED.js} +1 -1
- package/lib/chunks/{4PT55VGO.js → NEUHMRVX.js} +3 -3
- package/lib/chunks/{MONT6PMR.js → OHIVXMXU.js} +1 -1
- package/lib/chunks/OHW62OX6.js +8 -0
- package/lib/chunks/{2OHNINBQ.js → ONCO376P.js} +1 -1
- package/lib/chunks/P6UQ46OM.js +20 -0
- package/lib/chunks/POEVQHCC.js +30 -0
- package/lib/chunks/QYUMGE2L.js +9 -0
- package/lib/chunks/{XOZ4UMDG.js → RBQSJMUA.js} +1 -1
- package/lib/chunks/SK7RTQX6.js +18 -0
- package/lib/chunks/T22N7JRE.js +7 -0
- package/lib/chunks/{NIH6ZKB3.js → TMUDD3AQ.js} +1 -1
- package/lib/chunks/{WPSBZRFR.js → UJ7OYRJC.js} +1 -1
- package/lib/chunks/{HJYFWIVE.js → UW4UC7ZI.js} +2 -2
- package/lib/chunks/{KF7NA4HQ.js → V3JDIYRX.js} +1 -1
- package/lib/chunks/{PFYPTG4G.js → VZNKVS6Q.js} +1 -1
- package/lib/chunks/W62WTKL6.js +67 -0
- package/lib/chunks/{HMPJ7TN6.js → W7NMFHT5.js} +1 -1
- package/lib/chunks/{KBGRTZ3S.js → WSWUTUN2.js} +1 -1
- package/lib/chunks/{N5SXQI4I.js → XA64NLCK.js} +1 -1
- package/lib/chunks/{62X4OKFV.js → YHUS4LA4.js} +1 -1
- package/lib/chunks/{SQYP47H6.js → YOD7FLHY.js} +1 -1
- package/lib/chunks/{OKMAGS7N.js → YUQGMTD4.js} +1 -1
- package/lib/chunks/{OZMIIHFH.js → ZMAMNQ5K.js} +95 -95
- 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 +8 -8
- package/package.json +1 -1
- package/lib/chunks/2L3Z5JZA.js +0 -16
- package/lib/chunks/2WUJ57QA.js +0 -9
- package/lib/chunks/45LW7ZJ2.js +0 -7
- package/lib/chunks/77VEOG4O.js +0 -57
- package/lib/chunks/7ZC3TNBP.js +0 -14
- package/lib/chunks/AQT2EJZS.js +0 -177
- package/lib/chunks/BFGFT7E3.js +0 -90
- package/lib/chunks/EOS3ZB2L.js +0 -8
- package/lib/chunks/ESNPHQEK.js +0 -93
- package/lib/chunks/FJAJ4RIU.js +0 -20
- package/lib/chunks/FVKTV62N.js +0 -20
- package/lib/chunks/KNLINRO4.js +0 -19
- package/lib/chunks/L3TZNNJJ.js +0 -13
- package/lib/chunks/L4GUU6OS.js +0 -7
- package/lib/chunks/MSRZMIR7.js +0 -22
- package/lib/chunks/NAGDQV7J.js +0 -11
- package/lib/chunks/NB54XRRU.js +0 -10
- package/lib/chunks/NSIQWNYL.js +0 -7
- package/lib/chunks/OOLLHPWT.js +0 -18
- package/lib/chunks/P37B4DI4.js +0 -42
- package/lib/chunks/QPW3IML7.js +0 -26
- package/lib/chunks/REFX2EKS.js +0 -13
- package/lib/chunks/SGBB4RNM.js +0 -11
- package/lib/chunks/SQVG3CEM.js +0 -8
- package/lib/chunks/U6E22USS.js +0 -14
- package/lib/chunks/ULV3D265.js +0 -19
- package/lib/chunks/V4SBON7Y.js +0 -7
- package/lib/chunks/X3MZMREJ.js +0 -7
- package/lib/chunks/XWZNQKXF.js +0 -30
- package/lib/chunks/YEK532UO.js +0 -67
- package/lib/chunks/ZBL4IVEW.js +0 -11
- /package/lib/chunks/{UKSQ7B5H.js → 2U6O26CV.js} +0 -0
package/lib/chunks/FJAJ4RIU.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as N}from"./NSIQWNYL.js";import{b as U}from"./UKSQ7B5H.js";import{b as Q,c as D,d as R,e as I,f as X,g as Z,h as ee}from"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{c as z,d as P,e as w,f as q,g as _,h as E,i as V,j as H,k as O,n as Y}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var m=z.php,G=new N;function h(e){return G.typeName(e)}function y(e){return G.memberName(e)}function l(e){return G.string(e)}function ne(e){return P(e.name,{style:"camel",reserved:m})}function B(e){let n=e.services.flatMap(i=>i.operations),a=w(n.map(i=>i.name),{style:"camel",reserved:m});return new Map(n.map((i,r)=>[i.name,a[r]]))}function ue(e){return X(e).map(a=>a.kind==="literal"?l(a.value):`$${y(a.name)}`).join(" . ")}function te(e,n){let a=n.servers??[];if(a.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("{",()=>{a.forEach((r,t)=>{let s=P(r.description??`server${t+1}`,{style:"camel",reserved:m});i.has(s)&&(s=`${s}${t+1}`),i.add(s);let o=r.variables.map(c=>`string $${y(c.name)} = ${l(c.default)}`);t>0&&e.blank(),e.line(`public static function ${s}(${o.join(", ")}): string`),e.block("{",()=>{e.line(`return ${ue(r)};`)},"}")})},"}"),e.blank()}function re(e,n){let a=Z(e,n).map(i=>`[${i.map(t=>t.kind==="apiKey"?`['kind' => 'apiKey', 'scheme' => ${l(t.scheme)}, 'name' => ${l(t.name)}, 'in' => ${l(t.in)}]`:`['kind' => ${l(t.kind)}, 'scheme' => ${l(t.scheme)}]`).join(", ")}]`);if(a.length!==0)return`[${a.join(", ")}]`}function ie(e){return`[${[`'style' => ${l(e.style)}`,...e.param!==void 0?[`'param' => ${l(e.param)}`]:[],...e.nextCursor!==void 0?[`'nextCursor' => ${l(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`'hasMore' => ${l(e.hasMore)}`]:[],...e.limitParam!==void 0?[`'limitParam' => ${l(e.limitParam)}`]:[],...e.items!==void 0?[`'items' => ${l(e.items)}`]:[]].join(", ")}]`}function ae(e,n){let a=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let t=P(r.name,{style:"camel",reserved:m}),s=2;for(;a.has(t);)t=`${P(r.name,{style:"camel",reserved:m})}_${s++}`;a.add(t);let o=Y(r.schema,n);return`[${l(r.name)}, ${l(t)}, ${l(o)}]`}).join(", ")}]`}function T(e,n){let a=n.schemas.find(t=>t.name===e);if(a===void 0)return"other";let i=a.schema,r=O(i);return r!==void 0&&(r.scalar==="string"||r.scalar==="integer")?"enum":(i.kind==="object"||i.kind==="intersection")&&_(i,n)!==void 0?"class":"other"}function f(e,n,a="string"){if(V(e)){let i=f(H(e),n,a);return x(i)}switch(e.kind){case"scalar":return a==="Date"&&e.scalar==="string"&&F(e)?"\\DateTimeImmutable":{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":case"record":return"array";case"ref":{let i=T(e.name,n);if(i==="class"||i==="enum")return h(e.name);let r=q(e,n);return r===void 0?"mixed":f(r,n,a)}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 h(e.base);case"union":return de(e.members,n,a);case"null":case"object":case"intersection":case"unknown":return"mixed"}}function F(e){let n=e.metadata?.format;return n==="date"||n==="date-time"}function x(e){return e==="mixed"||e.startsWith("?")||e.endsWith("|null")?e:e.includes("|")?`${e}|null`:`?${e}`}function de(e,n,a){let i=[];for(let r of e){if(r.kind==="null")continue;let t=f(r,n,a);if(t==="mixed")return"mixed";let s=t.startsWith("?")?t.slice(1):t;i.includes(s)||i.push(s),t.startsWith("?")&&!i.includes("null")&&i.push("null")}return i.length===0?"mixed":i.join("|")}function K(e,n,a){if(e===void 0)return;let i=H(e);if(i.kind==="ref"){let t=q(i,n);return T(i.name,n)==="other"?K(t,n,a):void 0}if(i.kind!=="array")return;let r=f(i.items,n,a);return r==="mixed"?void 0:r}function se(e,n){let a=n.schemas.find(i=>i.name===e);return a!==void 0&&E(a.schema,n)!==void 0}function M(e,n,a,i){let r=H(e);if(i==="Date"&&r.kind==="scalar"&&r.scalar==="string"&&F(r))return`new \\DateTimeImmutable(${n})`;if(r.kind==="omit")return M({kind:"ref",name:r.base},n,a,i);if(r.kind==="ref"){let t=T(r.name,a);if(t==="class")return`${h(r.name)}::fromArray(${n})`;if(t==="enum")return`${h(r.name)}::from(${n})`;if(se(r.name,a))return`unmarshal${h(r.name)}(${n})`;let s=q(r,a);return s===void 0?void 0:M(s,n,a,i)}if(r.kind==="array"){let t=M(r.items,"$item",a,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}if(r.kind==="record"){let t=M(r.value,"$item",a,i);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}}function A(e,n,a,i="string"){let r=H(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 A({kind:"ref",name:r.base},n,a,i);if(r.kind==="ref"){let t=T(r.name,a);if(t==="class")return`${n}->toArray()`;if(t==="enum")return`${n}->value`;if(se(r.name,a))return`is_object(${n}) ? ${n}->toArray() : ${n}`;let s=q(r,a);return s===void 0?void 0:A(s,n,a,i)}if(r.kind==="array"||r.kind==="record"){let t=r.kind==="array"?r.items:r.value,s=A(t,"$item",a,i);return s===void 0?void 0:`array_map(static fn ($item) => ${s}, ${n})`}}function pe(e,n,a,i,r,t){let s=[...a.filter(o=>o.required),...a.filter(o=>!o.required)];e.doc(h(n),t),e.line(`final class ${h(n)}`),e.block("{",()=>{e.block("public function __construct(",()=>{for(let o of s){let c=f(o.schema,i,r);if(o.required)e.line(`public ${c} $${y(o.name)},`);else{let u=x(c);e.line(`public ${u} $${y(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 s){let c=`$data[${l(o.name)}]`,u=M(o.schema,c,i,r),p=y(o.name);o.required?e.line(`${p}: ${u??c},`):u===void 0?e.line(`${p}: ${c} ?? null,`):e.line(`${p}: isset(${c}) ? ${u} : null,`)}},");")},"}"),e.blank(),e.line("public function toArray(): array"),e.block("{",()=>{e.line("$data = [];");for(let o of s){let c=`$this->${y(o.name)}`,u=A(o.schema,c,i,r)??c;o.required?e.line(`$data[${l(o.name)}] = ${u};`):e.block(`if (${c} !== null) {`,()=>{e.line(`$data[${l(o.name)}] = ${u};`)},"}")}e.line("return $data;")},"}")},"}"),e.blank()}function L(e,n="string"){let a=new N;for(let{name:i,schema:r}of e.schemas){let t=O(r);if(t!==void 0&&(t.scalar==="string"||t.scalar==="integer")){let o=t.scalar==="string"?"string":"int";a.doc(h(i),r.description),a.line(`enum ${h(i)}: ${o}`),a.block("{",()=>{let c=w(t.values.map(u=>String(u)),{style:"pascal",reserved:m});t.values.forEach((u,p)=>{let g=typeof u=="string"?l(u):String(u);a.line(`case ${c[p]} = ${g};`)})},"}"),a.blank();continue}if(r.kind==="object"||r.kind==="intersection"){let o=_(r,e);if(o!==void 0){pe(a,i,o.properties,e,n,o.description??r.description);continue}}let s=E(r,e);if(s!==void 0){let o=h(i),c=s.cases.map(u=>`${u.value} -> ${h(u.schemaName)}`).join(", ");a.line(`/** ${o} is a discriminated union (${l(s.property)}): ${c}. */`),a.line(`function unmarshal${o}(array $data): mixed`),a.block("{",()=>{a.block(`return match ($data[${l(s.property)}] ?? null) {`,()=>{for(let u of s.cases)a.line(`${l(u.value)} => ${h(u.schemaName)}::fromArray($data),`);a.line("default => $data,")},"};")},"}"),a.blank();continue}}return a.toString()}var oe=new Set(["post","put","patch"]),$e=["body","headers","idempotencyKey"];function W(e,n,a,i){let r=w([...e.pathParams,...e.queryParams].map(c=>c.name),{style:"camel",reserved:m,taken:$e}),t=e.pathParams.map((c,u)=>({php:r[u],wire:c.name,type:f(c.schema,n,i)})),s=e.queryParams.map((c,u)=>{let p=r[e.pathParams.length+u];return{php:p,wire:c.name,type:f(c.schema,n,i),value:A(c.schema,`$${p}`,n,i)??`$${p}`}}),o=[...t.map(({php:c,type:u})=>`${u} $${c}`),...a&&e.requestBody?[`${I(e)?"array":f(e.requestBody.schema,n,i)} $body`]:[],...s.map(({php:c,type:u})=>`${x(u)} $${c} = null`),"?array $headers = null",...a&&oe.has(e.method.toLowerCase())?["?string $idempotencyKey = null"]:[]];return{pathArgs:t,queryArgs:s,signature:o}}function fe(e,n,a){e.line(`$op = OPERATIONS[${l(n.specName??n.name)}];`),e.line("[$authHeaders, $query, $cookies] = resolveAuth($op['security'] ?? [], $this->config->auth);");for(let{php:r,wire:t,value:s}of a.queryArgs)e.block(`if ($${r} !== null) {`,()=>{e.line(`$query[${l(t)}] = ${s};`)},"}");let i=a.pathArgs.map(({php:r,wire:t})=>`${l(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 J(e,n,a,i,r,t=!1){let s=W(n,i,!0,r),o=R(n),c=D(n),u=o===void 0&&c===void 0&&n.successResponses.some(b=>b.contentType!==""),p=t?"Envelope":o!==void 0?"\\Generator":c!==void 0?f(c,i,r):u?"string":"void",g=t?`${a}WithHeaders`:a,S=t?void 0:K(c,i,r);e.doc(g,t?`Like ${a}(), returning an Envelope with the declared response headers.`:n.summary??`${n.method.toUpperCase()} ${n.path}`,S===void 0?[]:[`@return ${S}[]`]),e.line(`public function ${g}(${s.signature.join(", ")}): ${p}`),e.block("{",()=>{if(fe(e,n,s),o!==void 0){let $=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, ${$?"true":"false"});`);return}let b=["'operationId' => $op['id']","'method' => $op['method']","'url' => $url","'headers' => $requestHeaders","'query' => $query"];if(n.requestBody&&I(n))e.line("[$contentType, $encoded] = toMultipart($body);"),b.push("'body' => $encoded","'contentType' => $contentType");else if(n.requestBody){let $=A(n.requestBody.schema,"$body",i,r)??"$body";e.line(`$payload = json_encode(${$});`),b.push("'body' => $payload",`'contentType' => ${l(n.requestBody.contentType)}`)}oe.has(n.method.toLowerCase())&&n.requestBody&&b.push("'idempotencyKey' => $idempotencyKey"),e.line(`$response = send($this->config, [${b.join(", ")}]);`),e.block("if ($response['status'] >= 400) {",()=>{e.line("throw apiErrorFrom($response);")},"}");let d=u?"$response['body']":(c===void 0?void 0:M(c,"decodeJson($response)",i,r))??"decodeJson($response)";if(t){e.line(`$data = ${d};`),e.line(`return new Envelope(data: $data, headers: readEnvelopeHeaders($response, ${ae(n,i)}), status: $response['status']);`);return}if(u){e.line("return $response['body'];");return}if(p==="void"){e.line("decodeJson($response);");return}e.line(`return ${d};`)},"}"),e.blank()}function le(e,n,a,i,r,t,s,o,c){let u=W(n,i,!1,r),p=a,g=()=>{e.line(`$op = OPERATIONS[${l(n.specName??n.name)}];`),e.line("$base = [];");for(let{php:$,wire:k,value:v}of u.queryArgs)e.block(`if ($${$} !== null) {`,()=>{e.line(`$base[${l(k)}] = ${v};`)},"}");let d=u.pathArgs.map(({php:$,wire:k})=>`${l(k)} => $${$}`).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'], [${d}]);`),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];")},"};")},S=f(D(n)??{kind:"unknown"},i,r),b=S==="mixed"?"mixed":S;e.line("/**"),e.line(` * ${p} response pages, following the pagination rule automatically.`),e.line(" *"),e.line(` * @return \\Generator<int, ${b}>`),e.line(" */"),e.line(`public function ${p}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 ${p} page.`),e.line(" *"),e.line(` * @return \\Generator<int, ${c}>`),e.line(" */"),e.line(`public function ${p}Items(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{g(),e.block("foreach (iterPages($call, $op['pagination'], $base) as $page) {",()=>{e.line(`$items = resolvePointer($page, ${l(o??"")});`),e.block("foreach (is_array($items) ? $items : [] as $item) {",()=>{e.line(`yield ${s??"$item"};`)},"}")},"}")},"}"),e.blank()}function me(e){let n=e.split(`
|
|
8
|
-
`),a=0;for(let i=0;i<n.length;i++)if(n[i].trim().startsWith("namespace ")){a=i+1;break}return n.slice(a).join(`
|
|
9
|
-
`).trim()}var nn=({model:e,output:n,banner:a,emit:i,pagination:r})=>{let t=new N,s=i.dateType??"string",o=P(e.title,{style:"pascal",reserved:m});t.line("<?php"),t.blank(),t.line(`// Code generated by @redocly/client-generator (php) from ${l(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(L(e,s)),te(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(me(U)),t.blank());let c=e.services.flatMap(d=>d.operations),u=B(e),p=new Map;for(let d of c){let $=r?.get(d.name)?.spec;$!==void 0&&p.set(d.name,$)}t.block("const OPERATIONS = [",()=>{for(let d of c){let $=d.specName??d.name,k=re(d,e),v=p.get(d.name),j=[`'id' => ${l($)}`,`'method' => ${l(d.method.toUpperCase())}`,`'path' => ${l(d.path)}`,...k!==void 0?[`'security' => ${k}`]:[],...v!==void 0?[`'pagination' => ${ie(v)}`]:[]];t.line(`${l($)} => [${j.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 = ${l(i.serverUrl??e.serverUrl??"")};`)},"}")},"}"),t.blank();for(let d of c){let $=u.get(d.name);J(t,d,$,e,s),R(d)===void 0&&(d.successResponseHeaders?.length??0)>0&&J(t,d,$,e,s,!0);let k=p.get(d.name);if(k===void 0)continue;let v=D(d),j=v===void 0?void 0:M(v,"$page",e,s),C=ee(v,k.items,e),ce=C===void 0?void 0:M(C,"$item",e,s);le(t,d,$,e,s,j,ce,k.items,C===void 0?"mixed":f(C,e,s))}},"}");let g={path:n.path.replace(/\.[^.\\/]+$/,".php"),content:t.toString()};if(i.runtime!=="module")return[g];let S=a.map(d=>`// ${d}`).join(`
|
|
10
|
-
`),b=U.replace(/^namespace .*$/m,`namespace ${o};`).replace(/^<\?php\n/,`<?php
|
|
11
|
-
|
|
12
|
-
${S}
|
|
13
|
-
`).trimEnd();return[g,{path:g.path.replace(/[^\\/]+$/,"runtime.php"),content:`${b}
|
|
14
|
-
`}]};function he(e,n){let a=[...e.pathParams.map(t=>`${l(`<${y(t.name)}>`)}`),...e.requestBody?["$body"]:[],...e.queryParams.length>0?[`${y(e.queryParams[0].name)}: ${l("<value>")}`]:[]],i=P(n.model.title,{style:"pascal",reserved:m});return{lang:"php",label:"PHP SDK",source:`require '${n.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,".php")}';
|
|
15
|
-
|
|
16
|
-
use ${i}\\{Client, Config};
|
|
17
|
-
|
|
18
|
-
$client = new Client(new Config());
|
|
19
|
-
$result = $client->${B(n.model).get(e.name)??ne(e)}(${a.join(", ")});
|
|
20
|
-
`}}var tn=({model:e,output:n,emit:a,pagination:i})=>[{path:n.path.replace(/\.[^.\\/]+$/,".php.md"),content:Q(e,{title:`${e.title} PHP SDK reference`,frontmatter:a.docsFrontmatter===!0,language:{name:"php",label:"PHP",fence:"php",requires:"The SDK needs the curl extension."},sample:r=>he(r,{model:e,emit:a,outputPath:n.path}),paginated:new Set(i?.keys()??[])})}];export{tn as phpDocs,nn as phpGenerator,he as phpSample,f as phpType,L as renderPhpModels};
|
package/lib/chunks/FVKTV62N.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as j}from"./NSIQWNYL.js";import{b as O}from"./UKSQ7B5H.js";import{b as Q,c as _,d as I,e as M,f as X,g as Z,h as ee}from"./NAGDQV7J.js";import{c as z,d as P,e as H,f as N,g as R,h as U,i as V,j as x,k as D,n as Y}from"./HJYFWIVE.js";var p=z.php,B=new j;function h(e){return B.typeName(e)}function g(e){return B.memberName(e)}function c(e){return B.string(e)}function ne(e){return P(e.name,{style:"camel",reserved:p})}function F(e){let n=e.services.flatMap(s=>s.operations),a=H(n.map(s=>s.name),{style:"camel",reserved:p});return new Map(n.map((s,r)=>[s.name,a[r]]))}function ue(e){return X(e).map(a=>a.kind==="literal"?c(a.value):`$${g(a.name)}`).join(" . ")}function te(e,n){let a=n.servers??[];if(a.length===0)return;let s=new Set;e.line("/** The declared servers; variables default to the values from the description. */"),e.line("final class Servers"),e.block("{",()=>{a.forEach((r,t)=>{let i=P(r.description??`server${t+1}`,{style:"camel",reserved:p});s.has(i)&&(i=`${i}${t+1}`),s.add(i);let o=r.variables.map(l=>`string $${g(l.name)} = ${c(l.default)}`);t>0&&e.blank(),e.line(`public static function ${i}(${o.join(", ")}): string`),e.block("{",()=>{e.line(`return ${ue(r)};`)},"}")})},"}"),e.blank()}function re(e,n){let a=Z(e,n).map(s=>`[${s.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(a.length!==0)return`[${a.join(", ")}]`}function se(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 ae(e,n){let a=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let t=P(r.name,{style:"camel",reserved:p}),i=2;for(;a.has(t);)t=`${P(r.name,{style:"camel",reserved:p})}_${i++}`;a.add(t);let o=Y(r.schema,n);return`[${c(r.name)}, ${c(t)}, ${c(o)}]`}).join(", ")}]`}function E(e,n){let a=n.schemas.find(t=>t.name===e);if(a===void 0)return"other";let s=a.schema,r=D(s);return r!==void 0&&(r.scalar==="string"||r.scalar==="integer")?"enum":(s.kind==="object"||s.kind==="intersection")&&R(s,n)!==void 0?"class":"other"}function m(e,n,a="string"){if(V(e)){let s=m(x(e),n,a);return A(s)}switch(e.kind){case"scalar":return a==="Date"&&e.scalar==="string"&&G(e)?"\\DateTimeImmutable":{string:"string",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":case"record":return"array";case"ref":{let s=E(e.name,n);if(s==="class"||s==="enum")return h(e.name);let r=N(e,n);return r===void 0?"mixed":m(r,n,a)}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 h(e.base);case"union":return $e(e.members,n,a);case"null":case"object":case"intersection":case"unknown":return"mixed"}}function G(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 $e(e,n,a){let s=[];for(let r of e){if(r.kind==="null")continue;let t=m(r,n,a);if(t==="mixed")return"mixed";let i=t.startsWith("?")?t.slice(1):t;s.includes(i)||s.push(i),t.startsWith("?")&&!s.includes("null")&&s.push("null")}return s.length===0?"mixed":s.join("|")}function K(e,n,a){if(e===void 0)return;let s=x(e);if(s.kind==="ref"){let t=N(s,n);return E(s.name,n)==="other"?K(t,n,a):void 0}if(s.kind!=="array")return;let r=m(s.items,n,a);return r==="mixed"?void 0:r}function ie(e,n){let a=n.schemas.find(s=>s.name===e);return a!==void 0&&U(a.schema,n)!==void 0}function v(e,n,a,s){let r=x(e);if(s==="Date"&&r.kind==="scalar"&&r.scalar==="string"&&G(r))return`new \\DateTimeImmutable(${n})`;if(r.kind==="omit")return v({kind:"ref",name:r.base},n,a,s);if(r.kind==="ref"){let t=E(r.name,a);if(t==="class")return`${h(r.name)}::fromArray(${n})`;if(t==="enum")return`${h(r.name)}::from(${n})`;if(ie(r.name,a))return`unmarshal${h(r.name)}(${n})`;let i=N(r,a);return i===void 0?void 0:v(i,n,a,s)}if(r.kind==="array"){let t=v(r.items,"$item",a,s);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}if(r.kind==="record"){let t=v(r.value,"$item",a,s);return t===void 0?void 0:`array_map(static fn ($item) => ${t}, ${n})`}}function q(e,n,a,s="string"){let r=x(e);if(s==="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 q({kind:"ref",name:r.base},n,a,s);if(r.kind==="ref"){let t=E(r.name,a);if(t==="class")return`${n}->toArray()`;if(t==="enum")return`${n}->value`;if(ie(r.name,a))return`is_object(${n}) ? ${n}->toArray() : ${n}`;let i=N(r,a);return i===void 0?void 0:q(i,n,a,s)}if(r.kind==="array"||r.kind==="record"){let t=r.kind==="array"?r.items:r.value,i=q(t,"$item",a,s);return i===void 0?void 0:`array_map(static fn ($item) => ${i}, ${n})`}}function fe(e,n,a,s,r,t){let i=[...a.filter(o=>o.required),...a.filter(o=>!o.required)];e.doc(h(n),t),e.line(`final class ${h(n)}`),e.block("{",()=>{e.block("public function __construct(",()=>{for(let o of i){let l=m(o.schema,s,r);if(o.required)e.line(`public ${l} $${g(o.name)},`);else{let u=A(l);e.line(`public ${u} $${g(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 i){let l=`$data[${c(o.name)}]`,u=v(o.schema,l,s,r),f=g(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 i){let l=`$this->${g(o.name)}`,u=q(o.schema,l,s,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 L(e,n="string"){let a=new j;for(let{name:s,schema:r}of e.schemas){let t=D(r);if(t!==void 0&&(t.scalar==="string"||t.scalar==="integer")){let o=t.scalar==="string"?"string":"int";a.doc(h(s),r.description),a.line(`enum ${h(s)}: ${o}`),a.block("{",()=>{let l=H(t.values.map(u=>String(u)),{style:"pascal",reserved:p});t.values.forEach((u,f)=>{let y=typeof u=="string"?c(u):String(u);a.line(`case ${l[f]} = ${y};`)})},"}"),a.blank();continue}if(r.kind==="object"||r.kind==="intersection"){let o=R(r,e);if(o!==void 0){fe(a,s,o.properties,e,n,o.description??r.description);continue}}let i=U(r,e);if(i!==void 0){let o=h(s),l=i.cases.map(u=>`${u.value} -> ${h(u.schemaName)}`).join(", ");a.line(`/** ${o} is a discriminated union (${c(i.property)}): ${l}. */`),a.line(`function unmarshal${o}(array $data): mixed`),a.block("{",()=>{a.block(`return match ($data[${c(i.property)}] ?? null) {`,()=>{for(let u of i.cases)a.line(`${c(u.value)} => ${h(u.schemaName)}::fromArray($data),`);a.line("default => $data,")},"};")},"}"),a.blank();continue}}return a.toString()}var oe=new Set(["post","put","patch"]),de=["body","headers","idempotencyKey"];function W(e,n,a,s){let r=H([...e.pathParams,...e.queryParams].map(l=>l.name),{style:"camel",reserved:p,taken:de}),t=e.pathParams.map((l,u)=>({php:r[u],wire:l.name,type:m(l.schema,n,s)})),i=e.queryParams.map((l,u)=>{let f=r[e.pathParams.length+u];return{php:f,wire:l.name,type:m(l.schema,n,s),value:q(l.schema,`$${f}`,n,s)??`$${f}`}}),o=[...t.map(({php:l,type:u})=>`${u} $${l}`),...a&&e.requestBody?[`${M(e)?"array":m(e.requestBody.schema,n,s)} $body`]:[],...i.map(({php:l,type:u})=>`${A(u)} $${l} = null`),"?array $headers = null",...a&&oe.has(e.method.toLowerCase())?["?string $idempotencyKey = null"]:[]];return{pathArgs:t,queryArgs:i,signature:o}}function me(e,n,a){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:i}of a.queryArgs)e.block(`if ($${r} !== null) {`,()=>{e.line(`$query[${c(t)}] = ${i};`)},"}");let s=a.pathArgs.map(({php:r,wire:t})=>`${c(t)} => $${r}`).join(", ");e.line(`$url = buildUrl($this->config->serverUrl, $op['path'], [${s}]);`),e.line("$requestHeaders = array_merge($authHeaders, $headers ?? []);"),e.block("if ($cookies !== []) {",()=>{e.line("$requestHeaders['Cookie'] = implode('; ', $cookies);")},"}")}function J(e,n,a,s,r,t=!1){let i=W(n,s,!0,r),o=I(n),l=_(n),u=o===void 0&&l===void 0&&n.successResponses.some(b=>b.contentType!==""),f=t?"Envelope":o!==void 0?"\\Generator":l!==void 0?m(l,s,r):u?"string":"void",y=t?`${a}WithHeaders`:a,S=t?void 0:K(l,s,r);e.doc(y,t?`Like ${a}(), returning an Envelope with the declared response headers.`:n.summary??`${n.method.toUpperCase()} ${n.path}`,S===void 0?[]:[`@return ${S}[]`]),e.line(`public function ${y}(${i.signature.join(", ")}): ${f}`),e.block("{",()=>{if(me(e,n,i),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 b=["'operationId' => $op['id']","'method' => $op['method']","'url' => $url","'headers' => $requestHeaders","'query' => $query"];if(n.requestBody&&M(n))e.line("[$contentType, $encoded] = toMultipart($body);"),b.push("'body' => $encoded","'contentType' => $contentType");else if(n.requestBody){let d=q(n.requestBody.schema,"$body",s,r)??"$body";e.line(`$payload = json_encode(${d});`),b.push("'body' => $payload",`'contentType' => ${c(n.requestBody.contentType)}`)}oe.has(n.method.toLowerCase())&&n.requestBody&&b.push("'idempotencyKey' => $idempotencyKey"),e.line(`$response = send($this->config, [${b.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)",s,r))??"decodeJson($response)";if(t){e.line(`$data = ${$};`),e.line(`return new Envelope(data: $data, headers: readEnvelopeHeaders($response, ${ae(n,s)}), 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 ce(e,n,a,s,r,t,i,o,l){let u=W(n,s,!1,r),f=a,y=()=>{e.line(`$op = OPERATIONS[${c(n.specName??n.name)}];`),e.line("$base = [];");for(let{php:d,wire:k,value:w}of u.queryArgs)e.block(`if ($${d} !== null) {`,()=>{e.line(`$base[${c(k)}] = ${w};`)},"}");let $=u.pathArgs.map(({php:d,wire:k})=>`${c(k)} => $${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];")},"};")},S=m(_(n)??{kind:"unknown"},s,r),b=S==="mixed"?"mixed":S;e.line("/**"),e.line(` * ${f} response pages, following the pagination rule automatically.`),e.line(" *"),e.line(` * @return \\Generator<int, ${b}>`),e.line(" */"),e.line(`public function ${f}Pages(${u.signature.join(", ")}): \\Generator`),e.block("{",()=>{y(),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("{",()=>{y(),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 ${i??"$item"};`)},"}")},"}")},"}"),e.blank()}function pe(e){let n=e.split(`
|
|
8
|
-
`),a=0;for(let s=0;s<n.length;s++)if(n[s].trim().startsWith("namespace ")){a=s+1;break}return n.slice(a).join(`
|
|
9
|
-
`).trim()}var nn=({model:e,output:n,banner:a,emit:s,pagination:r})=>{let t=new j,i=s.dateType??"string",o=P(e.title,{style:"pascal",reserved:p});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(L(e,i)),te(t,e),s.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(pe(O)),t.blank());let l=e.services.flatMap($=>$.operations),u=F(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,k=re($,e),w=f.get($.name),T=[`'id' => ${c(d)}`,`'method' => ${c($.method.toUpperCase())}`,`'path' => ${c($.path)}`,...k!==void 0?[`'security' => ${k}`]:[],...w!==void 0?[`'pagination' => ${se(w)}`]:[]];t.line(`${c(d)} => [${T.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(s.serverUrl??e.serverUrl??"")};`)},"}")},"}"),t.blank();for(let $ of l){let d=u.get($.name);J(t,$,d,e,i),I($)===void 0&&($.successResponseHeaders?.length??0)>0&&J(t,$,d,e,i,!0);let k=f.get($.name);if(k===void 0)continue;let w=_($),T=w===void 0?void 0:v(w,"$page",e,i),C=ee(w,k.items,e),le=C===void 0?void 0:v(C,"$item",e,i);ce(t,$,d,e,i,T,le,k.items,C===void 0?"mixed":m(C,e,i))}},"}");let y={path:n.path.replace(/\.[^.\\/]+$/,".php"),content:t.toString()};if(s.runtime!=="module")return[y];let S=a.map($=>`// ${$}`).join(`
|
|
10
|
-
`),b=O.replace(/^namespace .*$/m,`namespace ${o};`).replace(/^<\?php\n/,`<?php
|
|
11
|
-
|
|
12
|
-
${S}
|
|
13
|
-
`).trimEnd();return[y,{path:y.path.replace(/[^\\/]+$/,"runtime.php"),content:`${b}
|
|
14
|
-
`}]};function he(e,n){let a=[...e.pathParams.map(t=>`${c(`<${g(t.name)}>`)}`),...e.requestBody?["$body"]:[],...e.queryParams.length>0?[`${g(e.queryParams[0].name)}: ${c("<value>")}`]:[]],s=P(n.model.title,{style:"pascal",reserved:p});return{lang:"php",label:"PHP SDK",source:`require '${n.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,".php")}';
|
|
15
|
-
|
|
16
|
-
use ${s}\\{Client, Config};
|
|
17
|
-
|
|
18
|
-
$client = new Client(new Config());
|
|
19
|
-
$result = $client->${F(n.model).get(e.name)??ne(e)}(${a.join(", ")});
|
|
20
|
-
`}}var tn=({model:e,output:n,emit:a,pagination:s})=>[{path:n.path.replace(/\.[^.\\/]+$/,".php.md"),content:Q(e,{title:`${e.title} PHP SDK reference`,frontmatter:a.docsFrontmatter===!0,language:{name:"php",label:"PHP",fence:"php",requires:"The SDK needs the curl extension."},sample:r=>he(r,{model:e,emit:a,outputPath:n.path}),paginated:new Set(s?.keys()??[])})}];export{m as a,L as b,nn as c,he as d,tn as e};
|
package/lib/chunks/KNLINRO4.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as j}from"./SQVG3CEM.js";import{c as F}from"./UKSQ7B5H.js";import{b as J,c as R,d as T,e as U,f as ne,g as W,h as te}from"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{c as z,d as S,e as x,g as G,h as I,i as Q,j as X,k as Z,n as ee}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var k=z.python,u=new j;function M(e){return u.typeName(e)}function E(e){let{identifier:n,renamed:o}=u.memberName(e);return{python:n,renamed:o}}function C(e){let n=e.services.flatMap(t=>t.operations),o=x(n.map(t=>t.name),{style:"snake",reserved:k});return n.map((t,a)=>({op:t,ident:o[a]}))}var L=["self","body","headers","timeout","retry","idempotency_key"];function oe(e){return u.literal(e)}function se(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 re(e,n){let o=new Set;return`[${(e.successResponseHeaders??[]).map(a=>{let r=S(a.name,{style:"snake",reserved:k}),l=r,i=2;for(;o.has(l);)l=`${r}_${i++}`;o.add(l);let m=ee(a.schema,n);return`(${u.string(a.name)}, ${u.string(l)}, ${u.string(m)})`}).join(", ")}]`}function h(e,n="string"){if(Q(e))return`Optional[${h(X(e),n)}]`;switch(e.kind){case"scalar":if(n==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"datetime";if(e.metadata?.format==="date")return"date"}return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"array":return`List[${h(e.items,n)}]`;case"record":return`Dict[str, ${h(e.value,n)}]`;case"ref":return M(e.name);case"literal":return`Literal[${u.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(o=>h(o,n)).join(", ")}]`;case"null":return"None";case"omit":return M(e.base);case"object":case"intersection":case"unknown":return"Any"}}function B(e,n,o,t,a,r,l,i=!1){let m=x([...n.pathParams,...n.queryParams].map(P=>P.name),{style:"snake",reserved:k,taken:L}),c=n.pathParams.map((P,v)=>({param:P,python:m[v]})),s=n.queryParams.map((P,v)=>({param:P,python:m[n.pathParams.length+v]})),p=c.map(({param:P,python:v})=>`${v}: ${h(P.schema,r)}`),f=n.requestBody?[`body: ${h(n.requestBody.schema,r)}`]:[],g=[...s.map(({param:P,python:v})=>{let w=h(P.schema,r),A=w.startsWith("Optional[")?w:`Optional[${w}]`;return`${v}: ${A} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],y=R(n),_=T(n),N=i?`Envelope[${y===void 0?"None":h(y,r)}]`:_!==void 0?`${a?"AsyncIterator":"Iterator"}[ServerSentEvent]`:t==="result"?"Result":y===void 0?"None":h(y,r),O=a&&_===void 0?"async def":"def",d=a?"await ":"",$=a?"send_async":"send",b=["self",...p,...f,"*",...g].join(", "),D=i?`${o}_with_headers`:o;e.block(`${O} ${D}(${b}) -> ${N}:`,()=>{e.doc(i?`Like ${o}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${o}"]`),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:A,python:q}of s)e.block(`if ${q} is not None:`,()=>{e.line(`params[${u.string(A.name)}] = encode(${q})`)});let P=c.map(({param:A,python:q})=>`${u.string(A.name)}: ${q}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${P}})`),_!==void 0){let A=_.schema!==void 0&&_.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 ${a?"aiter_sse":"iter_sse"}(_open, data_kind="${A}")`);return}U(n)&&e.line("form_data, form_files = to_multipart(body)");let v=n.requestBody?U(n)?", data=form_data, files=form_files":", json_body=encode(body)":"";e.line(`response = ${d}${$}(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 w=y===void 0?"None":`decode(${h(y,r)}, _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=${w}, headers=read_envelope_headers(response, ${re(n,l)}), response=response)`)):t==="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=${w}, 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(y===void 0?"return None":`return ${w}`))}),e.blank()}function ae(e,n,o,t,a,r){let l=R(n),i=l===void 0?"Any":h(l,r),m=x([...n.pathParams,...n.queryParams].map(d=>d.name),{style:"snake",reserved:k,taken:L}),c=n.pathParams.map((d,$)=>({param:d,python:m[$]})),s=n.queryParams.map((d,$)=>({param:d,python:m[n.pathParams.length+$]})),p=c.map(({param:d,python:$})=>`${$}: ${h(d.schema,r)}`),f=[...s.map(({param:d,python:$})=>{let b=h(d.schema,r),D=b.startsWith("Optional[")?b:`Optional[${b}]`;return`${$}: ${D} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],g=["self",...p,"*",...f].join(", "),y=t?"AsyncIterator":"Iterator",_=t?"aiter_pages":"iter_pages",N=t?"aiter_items":"iter_items",O=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:b,python:D}of s)e.block(`if ${D} is not None:`,()=>{e.line(`base[${u.string(b.name)}] = encode(${D})`)});let d=t?"async def":"def",$=t?"await ":"";e.block(`${d} _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=c.map(({param:D,python:P})=>`${u.string(D.name)}: ${P}`).join(", ");e.line(`url = build_url(self._server_url, op["path"], {${b}})`),e.line(`response = ${$}${t?"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")})};t?(e.block(`async def ${o}_pages(${g}) -> ${y}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.block(`async for page in ${_}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${o}_items(${g}) -> ${y}[${a}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.block(`async for item in ${N}(_page, op["pagination"], base):`,()=>{e.line(a==="Any"?"yield item":`yield decode(${a}, item)`)})})):(e.block(`def ${o}_pages(${g}) -> ${y}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.line(i==="Any"?`return ${_}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${_}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${o}_items(${g}) -> ${y}[${a}]:`,()=>{e.line(`op = _OPERATIONS["${o}"]`),O(),e.line(a==="Any"?`return ${N}(_page, op["pagination"], base)`:`return (decode(${a}, item) for item in ${N}(_page, op["pagination"], base))`)})),e.blank()}function ce(e){return ne(e).map(o=>o.kind==="literal"?u.string(o.value):E(o.name).python).join(" + ")}function ie(e,n){let o=n.servers??[];if(o.length===0)return;let t=new Set;e.block("class Servers:",()=>{e.line('"""The declared servers; variables default to the values from the description."""'),e.blank(),o.forEach((a,r)=>{let l=S(a.description??`server${r+1}`,{style:"snake",reserved:k});t.has(l)&&(l=`${l}_${r+1}`),t.add(l);let i=a.variables.map(m=>`${E(m.name).python}: str = ${u.string(m.default)}`);r>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${l}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${ce(a)}`)})})}),e.blank()}function H(e,n,o,t,a,r,l){let i=t?"AsyncClient":"Client",m=t?"httpx.AsyncClient":"httpx.Client";e.block(`class ${i}:`,()=>{e.doc(`${t?"Async ":""}client for ${n.title} (${n.version}).`),e.block(`def __init__(self, server_url: str = ${u.string(r)}, *, 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:c,ident:s}of C(n)){B(e,c,s,o,t,l),T(c)===void 0&&(c.successResponseHeaders?.length??0)>0&&B(e,c,s,o,t,l,n,!0);let p=a.get(s);if(p!==void 0){let f=R(c),g=te(f,typeof p.items=="string"?p.items:void 0,n);ae(e,c,s,t,g===void 0?"Any":h(g,l),l)}}}),e.blank()}function K(e){let n=new Map,o=new Set,t=[];for(let{name:r,schema:l}of e.schemas){let i=I(l,e);if(!(i===void 0||!i.cases.every(c=>G(c.schema,e)?.properties.some(s=>s.name===i.property)===!0))){for(let c of i.cases){let s=n.get(c.schemaName);if(s!==void 0&&s.value!==c.value){o.add(c.schemaName);continue}n.set(c.schemaName,{property:i.property,value:c.value})}t.push({name:r,property:i.property,members:i.cases.map(c=>c.schemaName)})}}let a=new Map;for(let r of t)r.members.some(l=>o.has(l))||a.set(r.name,E(r.property).python);for(let r of o)n.delete(r);return{pins:n,unions:a}}function pe(e,n,o,t,a,r,l){let i=a==="pydantic";i||e.line("@dataclass");let m=i?`class ${M(n)}(BaseModel):`:`class ${M(n)}:`;e.block(m,()=>{e.doc(r),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let c=[...o.filter(p=>p.required),...o.filter(p=>!p.required)],s=[];c.length===0&&e.line("pass");for(let p of c){let{python:f,renamed:g}=E(p.name);g&&!i&&s.push([f,p.name]);let y=g&&i?`alias=${u.string(p.name)}`:void 0,_=l?.property===p.name?`Literal[${u.literal(l.value)}]`:h(p.schema,t);if(p.required){let N=y===void 0?"":` = Field(${y})`;e.line(`${f}: ${_}${N}`)}else{let N=_.startsWith("Optional[")?_:`Optional[${_}]`,O=y===void 0?"None":`Field(default=None, ${y})`;e.line(`${f}: ${N} = ${O}`)}}if(s.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let p=s.map(([f,g])=>`"${f}": ${u.string(g)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${p}}`)}}),e.blank(),e.blank()}function Y(e,n="string",o="dataclass"){let t=new j,{pins:a,unions:r}=o==="pydantic"?K(e):{pins:new Map,unions:new Map};t.line("from __future__ import annotations"),t.blank(),o==="dataclass"&&t.line("from dataclasses import dataclass"),t.line("from enum import Enum");let l=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];o==="dataclass"&&l.splice(2,0,"ClassVar"),r.size>0&&l.unshift("Annotated"),t.line(`from typing import ${l.join(", ")}`),o==="pydantic"&&t.line("from pydantic import BaseModel, ConfigDict, Field"),n==="Date"&&t.line("from datetime import date, datetime"),t.blank(),t.blank();let i=[];for(let{name:m,schema:c}of e.schemas){let s=Z(c);if(s!==void 0){let p=s.scalar==="string"?"str, Enum":"int, Enum";t.block(`class ${M(m)}(${p}):`,()=>{t.doc(c.description),s.values.forEach((f,g)=>{t.line(`${s.memberNames[g]} = ${u.literal(f)}`)})}),t.blank(),t.blank();continue}if(c.kind==="object"||c.kind==="intersection"){let p=G(c,e);if(p!==void 0){pe(t,m,p.properties,n,o,p.description??c.description,a.get(m));continue}}i.push(()=>{let p=I(c,e);if(p!==void 0){let y=p.cases.map(_=>`${_.value} -> ${M(_.schemaName)}`).join(", ");t.line(`# Discriminated by "${p.property}": ${y}`)}let f=r.get(m),g=f===void 0?h(c,n):`Annotated[${h(c,n)}, Field(discriminator=${u.string(f)})]`;t.line(`${M(m)} = ${g}`),t.blank()})}for(let m of i)m();return t.toString()}function le(e,n){let o=[];for(let{name:t,schema:a}of e.schemas){if(n.has(t))continue;let r=I(a,e);if(r===void 0)continue;let l=r.cases.map(i=>`${u.string(i.value)}: ${M(i.schemaName)}`).join(", ");o.push(`DISCRIMINATORS[${M(t)}] = (${u.string(r.property)}, {${l}})`)}return o}var Ve={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 V(e){let n=e.lastIndexOf("/")>=0?"/":"\\",o=e.lastIndexOf(n),t=o>=0?e.slice(0,o+1):"",a=(o>=0?e.slice(o+1):e).replace(/\.[^.]+$/,"");return`${t}${S(a,{style:"snake",reserved:k})}.py`}var ze=({model:e,output:n,banner:o,emit:t,options:a,pagination:r})=>{let l=t.errorMode??"throw",i=t.dateType??"string",m=a?.models??"dataclass",c=m==="pydantic"?K(e):void 0,s=new j;if(s.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),s.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),s.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),s.blank(),s.line(Y(e,i,m).trimEnd()),s.blank(),s.blank(),ie(s,e),t.runtime==="module"){s.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let d of Object.keys(F))s.line(`from ${d.replace(/\.py$/,"")} import *`);s.blank(),s.blank()}else{s.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let d of Object.values(F)){let $=d.split(`
|
|
8
|
-
`).filter(b=>!b.startsWith("from __future__")&&!b.startsWith("from ._")).join(`
|
|
9
|
-
`).trim();s.line($),s.blank()}s.blank()}let p=le(e,new Set(c?.unions.keys()));if(p.length>0){s.line("# Discriminated unions dispatch by their property inside decode().");for(let d of p)s.line(d);s.blank()}s.block("def _safe_json(response: httpx.Response) -> Any:",()=>{s.block("try:",()=>{s.line("return response.json()")}),s.block("except Exception:",()=>{s.line("return None")})}),s.blank();let f=new Map;for(let{op:d,ident:$}of C(e))f.set($,se(r?.get(d.name)?.spec));s.line("_OPERATIONS = {"),s.indent(()=>{for(let{op:d,ident:$}of C(e)){let b={id:d.specName??d.name,method:d.method.toUpperCase(),path:d.path,...W(d,e).length>0?{security:W(d,e)}:{},...f.get($)!==void 0?{pagination:f.get($)}:{}};s.line(`"${$}": ${oe(b)},`)}}),s.line("}"),s.blank(),s.blank();let g=t.serverUrl??e.serverUrl??"";H(s,e,l,!1,f,g,i),H(s,e,l,!0,f,g,i);let y={path:V(n.path),content:s.toString()};if(t.runtime!=="module")return[y];let _=o.map(d=>`# ${d}`).join(`
|
|
10
|
-
`),N=V(n.path).replace(/[^\\/]+$/,""),O=Object.entries(F).map(([d,$])=>({path:`${N}${d}`,content:`${_}
|
|
11
|
-
|
|
12
|
-
${$.split(`
|
|
13
|
-
`).map(b=>b.startsWith("from ._")?b.replace("from ._","from _"):b).join(`
|
|
14
|
-
`).trim()}
|
|
15
|
-
`}));return[y,...O]};function de(e,n){let o=V(n.outputPath).replace(/^.*[\\/]/,"").replace(/\.py$/,""),t=C(n.model).find(r=>r.op.name===e.name)?.ident??S(e.name,{style:"snake",reserved:k}),a=[...e.pathParams.map(r=>{let l=S(r.name,{style:"snake",reserved:k});return`${l}="<${l}>"`}),...e.queryParams.filter(r=>r.required).map(r=>`${S(r.name,{style:"snake",reserved:k})}=...`),...e.requestBody?["body=..."]:[]];return{lang:"python",label:"Python SDK",source:`from ${o} import Client
|
|
16
|
-
|
|
17
|
-
client = Client()
|
|
18
|
-
result = client.${t}(${a.join(", ")})
|
|
19
|
-
`}}var Je=({model:e,output:n,emit:o,pagination:t})=>[{path:n.path.replace(/\.[^.\\/]+$/,".python.md"),content:J(e,{title:`${e.title} Python SDK reference`,frontmatter:o.docsFrontmatter===!0,language:{name:"python",label:"Python",fence:"python",requires:"The SDK needs `httpx`."},sample:a=>de(a,{model:e,emit:o,outputPath:n.path}),paginated:new Set(t?.keys()??[])})}];export{Je as pythonDocs,ze as pythonGenerator,Ve as pythonOptions,de as pythonSample,h as pythonType,Y as renderPythonModels};
|
package/lib/chunks/L3TZNNJJ.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{e as y,k as A}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as R}from"node:path";var u=" ";function M(t){return`transform${A(t)}`}var I="type __Writable<T> = { -readonly [K in keyof T]: T[K] };",k=!1;function _(t){return{text:t,path:[t]}}function G(t,r){return{text:`${t.text}[${JSON.stringify(r)}]`,path:[...t.path,r]}}function d(t,r,n){if(x(t))return!0;switch(t.kind){case"array":return d(t.items,r,n);case"union":return t.members.some(e=>d(e,r,n));case"ref":{if(n.has(t.name))return!1;let e=r.get(t.name);return e!==void 0&&d(e,r,new Set(n).add(t.name))}default:return!1}}function x(t){return t.kind==="scalar"&&t.scalar==="string"&&(t.metadata?.format==="date-time"||t.metadata?.format==="date")}function l(t,r,n){if(x(t))return!0;switch(t.kind){case"array":return l(t.items,r,n);case"record":return l(t.value,r,n);case"object":return t.properties.some(e=>l(e.schema,r,n));case"union":case"intersection":return t.members.some(e=>l(e,r,n));case"ref":{let e=r.get(t.name);return e!==void 0&&!n.has(t.name)?l(e,r,new Set(n).add(t.name)):!1}default:return!1}}function $(t,r,n,e=!1){return e?[`${n}if (${t}) {`,...r(n+u),`${n}}`]:[`${n}if (${t})`,...r(n+u)]}function m(t,r,n=!1){let e=n?J(t):t.text;return s=>[`${s}${e} = ${r};`]}function T(t){return r=>[`${r}${t};`]}function J(t){if(t.path.length<2)return t.text;k=!0;let r={text:t.text.slice(0,t.text.lastIndexOf("[")),path:t.path.slice(0,-1)},n=t.path[t.path.length-1];return`(${r.text} as __Writable<${C(r)}>)[${JSON.stringify(n)}]`}function C(t){let r=`typeof ${t.path[0]}`;for(let n of t.path.slice(1))r=`NonNullable<${r}>[${JSON.stringify(n)}]`;return`NonNullable<${r}>`}function W(t){return t==="data"?"item":`item${Number(t.slice(4))+1}`}function g(t,r,n,e,s,o,a=!1){if(x(r))return $(`typeof ${t.text} === "string"`,m(t,`new Date(${t.text})`,a),o);switch(r.kind){case"ref":return w(t,r.name,n,e,o,a);case"object":{let i=[];for(let f of r.properties)i.push(...K(G(t,f.name),f.schema,n,e,s,o,f.readOnly===!0));return i}case"array":return U(t,r.items,n,e,s,o,a);case"record":return b(t,r.value,n,e,s,o,!0);case"intersection":{let i=[];for(let f of r.members)i.push(...g(t,f,n,e,s,o,a));return i}case"union":return B(t,r.members,n,e,s,o,a);default:return[]}}function B(t,r,n,e,s,o,a=!1){let i=[],f=o+u,p=[];for(let c of r)if(x(c))i.push(...g(t,c,n,e,s,o,a));else if(c.kind==="ref"){if(!l(c,n,e))continue;let S=`${M(c.name)}(${t.text} as ${c.name})`,h=d(c,n,e)?m(t,S,a):T(S);p.push(...h(f))}else p.push(...g(t,c,n,e,s,f,a));return p.length>0&&i.push(...$(`${t.text} && typeof ${t.text} === "object"`,()=>p,o,!0)),i}function w(t,r,n,e,s,o=!1){let a={kind:"ref",name:r};if(!l(a,n,e))return[];let i=`${M(r)}(${t.text})`;return $(t.text,d(a,n,e)?m(t,i,o):T(i),s)}function K(t,r,n,e,s,o,a=!1){if(r.kind==="ref")return w(t,r.name,n,e,o,a);if(r.kind==="object"){let i=g(t,r,n,e,s,o+u);return i.length===0?[]:$(t.text,()=>i,o,!0)}return g(t,r,n,e,s,o,a)}function j(t,r,n,e,s=0){if(x(r))return`new Date(${t})`;if(r.kind==="ref"&&d(r,n,e))return`${M(r.name)}(${t})`;if(r.kind==="array"){let o=r.items.kind==="array"?O(s+1):"v",a=j(o,r.items,n,e,s+1);return a===null?null:`${t}.map(${o} => ${a})`}return null}function O(t){return t<=1?"row":`row${t}`}function U(t,r,n,e,s,o,a=!1){let i=r.kind==="array"?O(1):"v",f=j(i,r,n,e,1);return f!==null?$(`Array.isArray(${t.text})`,m(t,`${t.text}.map(${i} => ${f})`,a),o):r.kind==="ref"?l(r,n,e)?$(`Array.isArray(${t.text})`,T(`${t.text}.forEach(${M(r.name)})`),o):[]:b(t,r,n,e,s,o,!1)}function b(t,r,n,e,s,o,a){if(a){let c={text:`${t.text}[__k]`,path:[...t.path,"__k"]},S=j(c.text,r,n,e);if(S!==null){let h=x(r)?`typeof ${c.text} === "string"`:`Array.isArray(${c.text})`;return $(t.text,v=>[`${v}for (const __k of Object.keys(${t.text}))`,...$(h,E=>[`${E}${c.text} = ${S};`],v+u)],o)}}let i=W(s),f=g(_(i),r,n,e,i,o+u+u);if(f.length===0)return[];let p=a?`Object.values(${t.text})`:t.text;return $(a?t.text:`Array.isArray(${t.text})`,c=>[`${c}${p}.forEach(${i} => {`,...f,`${c}});`],o)}function P(t,r){let n=t.name,e=_("data"),s=t.schema.kind==="ref"?w(e,t.schema.name,r,new Set,u):g(e,t.schema,r,new Set,"data",u);return[`export const ${M(t.name)} = (data: ${n}): ${n} => {`,...s,`${u}return data;`,"};"].join(`
|
|
8
|
-
`)}function D(t,r){let n=new Map(t.schemas.map(i=>[i.name,i.schema])),e=t.schemas.filter(i=>l(i.schema,n,new Set));if(e.length===0)return"";let s=e.map(i=>y(i.name)).join(", ");k=!1;let o=e.map(i=>P(i,n));return[`import type { ${s} } from ${JSON.stringify(r.sdkModule)};`,...k?[I]:[],...o].join(`
|
|
9
|
-
|
|
10
|
-
`)}var Q=({model:t,output:r,banner:n,emit:e})=>{let s=D(t,{sdkModule:`./${r.stem}.${e.importExt??"js"}`});if(s==="")return[];let o=n.map(a=>`// ${a}`).join(`
|
|
11
|
-
`);return[{path:R(r.dir,`${r.stem}.transformers.ts`),content:`${o}
|
|
12
|
-
|
|
13
|
-
${s}`}]};export{Q as transformersGenerator};
|
package/lib/chunks/L4GUU6OS.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./U6E22USS.js";import"./REFX2EKS.js";import"./UKSQ7B5H.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
|
package/lib/chunks/MSRZMIR7.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import"./NAGDQV7J.js";import{a as I}from"./4PT55VGO.js";import"./PFYPTG4G.js";import{c as $}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import{a as T,e as C,g as q,h as b,k as O}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as se}from"node:path";var S=class{constructor(n){this.code=n}code};function H(e,n,r={}){let t=new Map(n.map(a=>[a.name,a.schema])),o=k(e,t,new Set,r.dateType??"string");return o===g?null:o}var g=Symbol("cycle");function P(e,n){if(e.kind==="union"){for(let t of e.members){let o=P(t,n);if(o)return o}return}if(e.kind!=="scalar")return;let r=e.metadata?.format;if(r==="binary")return new S("new Blob([])");if(n==="Date"){if(r==="date-time")return new S('new Date("2024-01-01T00:00:00Z")');if(r==="date")return new S('new Date("2024-01-01")')}}function D(e,n){let r=new Map,t=[],o=!1;for(let a of e){if(a.kind==="unknown")continue;let c=Y(a,n);if(c?.kind!=="object"){t.push(a);continue}o=!0;for(let s of c.properties){let i=V(s.schema,n,new Set),u=r.get(s.name);(u===void 0||i>=u.rank)&&r.set(s.name,{schema:s.schema,required:s.required||(u?.required??!1),rank:i})}}return o?{merged:{kind:"object",properties:[...r.entries()].map(([a,c])=>({name:a,schema:c.schema,required:c.required}))},rest:t}:{merged:void 0,rest:t}}function Y(e,n){let r=new Set,t=e;for(;t?.kind==="ref";){if(r.has(t.name))return;r.add(t.name),t=n.get(t.name)}return t}function V(e,n,r){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=>V(t,n,r)))-1;case"ref":{if(r.has(e.name))return 20;let t=n.get(e.name);return t===void 0?20:V(t,n,new Set(r).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,n,r,t){let o=P(e,t);if(o)return o;let a=e.metadata,c=s=>s===null?e.kind==="null"||e.kind==="union"&&e.members.some(i=>i.kind==="null"):e.kind==="enum"?e.values.includes(s):e.kind==="literal"?s===e.value:!0;if(a?.example!==void 0&&c(a.example))return a.example;if(a?.default!==void 0&&c(a.default))return a.default;switch(e.kind){case"scalar":return v(e.scalar,a);case"array":{let s=k(e.items,n,r,t);return s===g?[]:[s]}case"object":return Object.fromEntries(e.properties.flatMap(s=>{let i=k(s.schema,n,r,t);return i===g?s.required?[[s.name,null]]:[]:[[s.name,i]]}));case"record":{let s=k(e.value,n,r,t);return s===g?{}:{key:s}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let s of e.members){let i=k(s,n,r,t);if(i!==g)return i}return e.members.length>0?g:null}case"intersection":{let{merged:s,rest:i}=D(e.members,n),u=i.map(f=>k(f,n,r,t)).filter(f=>f!==g);if(s){let f=k(s,n,r,t),j=$(f)?f:{};for(let A of u)$(A)&&Object.assign(j,A);return j}let h=u.filter($);return h.length>0?h.reduce((f,j)=>Object.assign(f,j),{}):u.length>0?u[0]:{}}case"omit":{let s=n.get(e.base);if(!s)return null;let i=k(s,n,r,t);if($(i)){let u={...i};for(let h of e.keys)delete u[h];return u}return i}case"ref":{if(r.has(e.name))return g;let s=n.get(e.name);if(!s)return null;r.add(e.name);let i=k(s,n,r,t);return r.delete(e.name),i}case"null":case"unknown":return null}}function v(e,n){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(n?.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 l=e=>({kind:"expr",text:e}),m=e=>({kind:"object",entries:e});function d(e){return e.kind==="object"}function E(e,n){return d(e)?m([...e.entries,{spread:n}]):e}var B=" ";function y(e,n){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${y(e.value,n)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let r=n+B;return`[
|
|
8
|
-
${e.items.map((o,a)=>`${r}${y(o,r)}${a===e.items.length-1?"":","}`).join(`
|
|
9
|
-
`)}
|
|
10
|
-
${n}]`}case"object":{if(e.entries.length===0)return"{}";let r=n+B;return`{
|
|
11
|
-
${e.entries.map((o,a)=>{let c=a===e.entries.length-1?"":",";if("spread"in o)return`${r}...${o.spread}${c}`;let s=C(o.key)===o.key?o.key:q(o.key);return`${r}${s}: ${y(o.value,r)}${c}`}).join(`
|
|
12
|
-
`)}
|
|
13
|
-
${n}}`}}}function K(e,n,r={}){let t=new Map(n.map(a=>[a.name,a.schema])),o=M(e,t,new Set,r.dateType??"string");return o===p?l("null"):o}var p=Symbol("cycle");function M(e,n,r,t){switch(e.kind){case"scalar":return l(U(e.scalar,e.metadata,t));case"array":{let o=M(e.items,n,r,t);return o===p?l("[]"):Z(o)}case"object":return m(e.properties.flatMap(o=>{let a=M(o.schema,n,r,t);return a===p?o.required?[{key:o.name,value:l("null")}]:[]:[{key:o.name,value:a}]}));case"record":{let o=M(e.value,n,r,t);return o===p?l("{}"):m([{key:"key",value:o}])}case"enum":return l(`faker.helpers.arrayElement([${e.values.map(o=>b(o)).join(", ")}] as const)`);case"literal":return l(b(e.value));case"union":{for(let o of e.members){let a=M(o,n,r,t);if(a!==p)return a}return e.members.length>0?p:l("null")}case"intersection":{let{merged:o,rest:a}=D(e.members,n),c=a.map(i=>M(i,n,r,t)).filter(i=>i!==p);if(o){let i=M(o,n,r,t),u=i!==p&&d(i)?i.entries:[],h=c.filter(d).flatMap(f=>f.entries);return m([...u,...h])}let s=c.filter(d);return s.length>0?m(s.flatMap(i=>i.entries)):c[0]??m([])}case"omit":return z(e.base,e.keys,n,r,t);case"ref":{if(r.has(e.name))return p;let o=n.get(e.name);if(!o)return l("null");r.add(e.name);let a=M(o,n,r,t);return r.delete(e.name),a}case"null":case"unknown":return l("null")}}function U(e,n,r){if(n?.format==="binary")return"new Blob([])";if(e==="boolean")return"faker.datatype.boolean()";if(e==="integer")return`faker.number.int(${J(n)})`;if(e==="number")return`faker.number.float(${J(n)})`;switch(n?.format){case"email":return"faker.internet.email()";case"uuid":return"faker.string.uuid()";case"uri":case"url":return"faker.internet.url()";case"hostname":return"faker.internet.domainName()";case"ipv4":return"faker.internet.ipv4()";case"date-time":return L(r,!1);case"date":return L(r,!0);default:return"faker.lorem.word()"}}function L(e,n){if(e==="Date")return"faker.date.recent()";let r="faker.date.recent().toISOString()";return n?`${r}.slice(0, 10)`:r}function J(e){let n=[...e?.minimum!==void 0?[`min: ${e.minimum}`]:[],...e?.maximum!==void 0?[`max: ${e.maximum}`]:[]];return n.length>0?`{ ${n.join(", ")} }`:""}function Z(e){let n=d(e);return{kind:"wrap",before:`faker.helpers.multiple(() => ${n?"(":""}`,value:e,after:`${n?")":""}, { count: 1 })`}}function z(e,n,r,t,o){let a=r.get(e);if(!a)return l("null");let c=M(a,r,t,o);if(c===p||!d(c))return c;let s=new Set(n);return m(c.entries.filter(i=>"spread"in i||!s.has(i.key)))}var F=" ";function w(e,n,r){return r.mockData==="faker"?K(e,n.schemas,{dateType:r.dateType}):R(H(e,n.schemas,{dateType:r.dateType}))}function G(e,n){let r=I(e.services);if(r.length===0)return"";let t=[...Q(e,n),...n.mockData==="faker"&&n.mockSeed!==void 0?[`faker.seed(${n.mockSeed});`]:[],...e.schemas.map(a=>X(a,e,n)),...r.flatMap(a=>[_(a,e,n),...a.errorResponses.length>0?[N(a,e,n)]:[]]),ae(r)];return`import { http, HttpResponse } from 'msw';
|
|
14
|
-
${n.mockData==="faker"?`import { faker } from '@faker-js/faker';
|
|
15
|
-
`:""}
|
|
16
|
-
${t.join(`
|
|
17
|
-
|
|
18
|
-
`)}`}function Q(e,n){return e.schemas.length===0?[]:[`import type { ${e.schemas.map(t=>t.name).sort().join(", ")} } from ${JSON.stringify(n.sdkModule)};`]}function X(e,n,r){let t=O(e.name),o=w(e.schema,n,r),a=e.name,c=d(o),s=y(c?E(o,"overrides"):o,F),i=c?e.schema.kind==="union"?`${s} as ${a}`:s:`overrides ?? ${s}`,u=c?`Partial<${a}>`:a;return[`export function create${t}(overrides?: ${u}): ${a} {`,`${F}return ${i};`,"}"].join(`
|
|
19
|
-
`)}function x(e){if(!T(e))throw new Error(`Unsafe identifier in mock emission: ${JSON.stringify(e)}`);return e}function _(e,n,r){let o=re(e,n,r)??"",a=`http.${x(e.method)}(${JSON.stringify(W(e.path))}, () => ${te(e,n,r)})`;return`export const ${x(e.name)}Handler = (${o}) => ${a};`}function N(e,n,r){let t=e.errorResponses[0],a=`() => HttpResponse.json(body ?? ${y(w(t.schema,n,r),"")}, { status })`,c=`http.${x(e.method)}(${JSON.stringify(W(e.path))}, ${a})`;return`export const ${x(e.name)}ErrorHandler = (status: ${ee(e)}, body?: ${ne(e)}) => ${c};`}function ee(e){let r=[...new Set(e.errorResponses.filter(t=>typeof t.status=="number").map(t=>t.status))].map(String);return e.errorResponses.some(t=>typeof t.status!="number")&&r.push("number"),r.join(" | ")}function ne(e){let n=new Set,r=!1;for(let o of e.errorResponses)o.schema.kind==="ref"?n.add(o.schema.name):r=!0;let t=[...n];return(r||t.length===0)&&t.push("unknown"),t.join(" | ")}function re(e,n,r){let t=e.successResponses[0];if(!(!t||t.schema.kind==="unknown")){if(t.schema.kind==="ref"){let o=t.schema.name;return`override?: ${d(w(t.schema,n,r))?`Partial<${o}>`:o}`}if(d(w(t.schema,n,r)))return"override?: Record<string, unknown>"}}function te(e,n,r){let t=e.successResponses[0],o=oe(t?.status);if(!t||t.schema.kind==="unknown")return`new HttpResponse(null, { status: ${o} })`;let a=t.schema.kind==="ref"?`create${O(t.schema.name)}(override)`:y(E(w(t.schema,n,r),"override"),"");return`HttpResponse.json(${o===200?a:`${a}, { status: ${o} }`})`}function oe(e){return typeof e=="number"?e:200}function ae(e){return`export const handlers = [${e.map(r=>`${x(r.name)}Handler()`).join(", ")}];`}function W(e){return`*${e.replace(/\{([^{}]+)\}/g,":$1")}`}function R(e){return e instanceof S?l(e.code):Array.isArray(e)?{kind:"array",items:e.map(R)}:$(e)?m(Object.entries(e).map(([n,r])=>({key:n,value:R(r)}))):l(b(e))}var xe=({model:e,output:n,banner:r,emit:t})=>{let o=r.map(c=>`// ${c}`).join(`
|
|
20
|
-
`),a=G(e,{sdkModule:`./${n.stem}.${t.importExt??"js"}`,dateType:t.dateType,mockData:t.mockData,mockSeed:t.mockSeed});return a===""?[]:[{path:se(n.dir,`${n.stem}.mocks.ts`),content:`${o}
|
|
21
|
-
|
|
22
|
-
${a}`}]};export{xe as mockGenerator};
|
package/lib/chunks/NAGDQV7J.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as c,m as u}from"./HJYFWIVE.js";function m(e,n){let t=n??{},o=e.specName??e.name;if(Array.isArray(t.exclude)&&t.exclude.includes(o))return;let r=(t.operations??{})[o]??e.paginationExtension;if(r===void 0&&typeof t.style=="string"){let{exclude:l,operations:A,...p}=t,f=p.style==="cursor"?p.cursorParam:p.offsetParam;(p.style==="link"?e.successResponseHeaders?.some(d=>d.name==="link")===!0:typeof f=="string"&&e.queryParams.some(d=>d.name===f))&&(r=p)}if(r===void 0||typeof r.style!="string")return;let s=r.style==="cursor"?r.cursorParam:r.offsetParam;return{style:r.style,...typeof s=="string"?{param:s}:{},...typeof r.nextCursor=="string"?{nextCursor:r.nextCursor}:{},...typeof r.hasMore=="string"?{hasMore:r.hasMore}:{},...typeof r.limitParam=="string"?{limitParam:r.limitParam}:{},...typeof r.items=="string"?{items:r.items}:{}}}function g(e){return(e??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function a(e){switch(e.kind){case"ref":return e.name;case"omit":return e.base;case"scalar":return e.scalar;case"array":return`array of ${a(e.items)}`;case"record":return`map of ${a(e.value)}`;case"enum":{let n=e.values.map(String),t=n.slice(0,6).join(", ");return n.length>6?`enum: ${t}, and ${n.length-6} more`:`enum: ${t}`}case"literal":return String(e.value);case"union":return e.members.map(a).join(" or ");case"intersection":return e.members.map(a).join(" and ");case"object":return"object";case"null":return"null";case"unknown":return"any"}}function y(e){return e.successResponses.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.successResponses.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function x(e,n){e.line("| Parameter | In | Type | Required | Description |"),e.line("| --------- | -- | ---- | -------- | ----------- |");for(let t of n)e.line(`| \`${t.name}\` | ${t.in} | ${g(a(t.schema))} | ${t.required?"yes":"no"} | ${g(t.description)} |`);e.blank()}function C(e,n,t){e.line(`### \`${n.specName??n.name}\``),e.blank(),n.summary!==void 0&&(e.line(g(n.summary)),e.blank()),e.line(`\`${n.method.toUpperCase()} ${n.path}\``),e.blank();let o=t.sample(n);if(o!==void 0){e.line("```"+t.language.fence);for(let l of o.source.replace(/\n+$/,"").split(`
|
|
8
|
-
`))e.line(l);e.line("```"),e.blank()}let i=[...n.pathParams,...n.queryParams,...n.headerParams];i.length>0&&x(e,i),n.requestBody!==void 0&&e.line(`Body: \`${n.requestBody.contentType}\`${n.requestBody.required?", required":", optional"}, of type ${a(n.requestBody.schema)}.`);let r=n.successResponses[0];e.line(r===void 0?"Returns no content.":`Returns \`${r.contentType}\`, of type ${a(r.schema)}.`),(t.paginated!==void 0?t.paginated.has(n.name):m(n,t.pagination)!==void 0)&&e.line("This operation is paginated, so the SDK gives it page and item iterators."),n.successResponses.some(l=>l.contentType==="text/event-stream")&&e.line("This operation streams server-sent events, so the SDK iterates the events."),y(n)&&e.line("This operation returns binary content."),e.blank()}function R(e,n){let t=new c;if(n.frontmatter&&(t.line("---"),t.line(`title: ${n.title}`),t.line("---"),t.blank()),t.line(`# ${n.title}`),t.blank(),t.line(`Generated reference for the ${n.language.label} SDK, produced from the API description by \`redocly generate-client\`.`),t.line("Re-run generation to update it \u2014 this file is not hand-edited."),t.blank(),t.line(n.language.requires),t.blank(),t.line("## Authentication"),t.blank(),e.securitySchemes.length===0)t.line("The description declares no security schemes.");else{t.line("The description declares these schemes, which you pass to the client:"),t.blank(),t.line("| Scheme | Kind | Sent as |"),t.line("| ------ | ---- | ------- |");for(let r of e.securitySchemes){let s=r.kind==="bearer"?"`Authorization: Bearer <token>`":r.kind==="basic"?"`Authorization: Basic <base64>`":r.kind==="apiKeyHeader"?`the \`${r.headerName}\` header`:r.kind==="apiKeyQuery"?`the \`${r.paramName}\` query parameter`:`the \`${r.cookieName}\` cookie`;t.line(`| \`${r.key}\` | ${r.kind} | ${s} |`)}}t.blank();let o=e.services.flatMap(r=>r.operations),i=[...new Set(o.map(r=>r.tags[0]))];for(let r of i){t.line(r===void 0?"## Operations":`## ${r}`),t.blank();for(let s of o.filter(l=>l.tags[0]===r))C(t,s,n)}return t.toString().replace(/\n{3,}/g,`
|
|
9
|
-
|
|
10
|
-
`).trimEnd()+`
|
|
11
|
-
`}function h(e){return e.successResponses.find(n=>n.contentType.toLowerCase().includes("json"))?.schema}function S(e){return e.successResponses.find(n=>n.contentType.toLowerCase().includes("text/event-stream"))}function b(e){return e.requestBody?.contentType.toLowerCase().includes("multipart")??!1}function k(e){let n=new Set(e.variables.map(s=>s.name)),t=[],o="",i=e.url,r=/\{([^{}]+)\}/;for(let s=r.exec(i);s!==null;s=r.exec(i))o+=i.slice(0,s.index),n.has(s[1])?(o!==""&&t.push({kind:"literal",value:o}),o="",t.push({kind:"variable",name:s[1]})):o+=s[0],i=i.slice(s.index+s[0].length);return o+=i,(o!==""||t.length===0)&&t.push({kind:"literal",value:o}),t}function P(e,n){return e.security.map(t=>t.flatMap(o=>{let i=n.securitySchemes.find(r=>r.key===o);return i===void 0?[]:i.kind==="bearer"||i.kind==="basic"?[{scheme:o,kind:i.kind}]:i.kind==="apiKeyHeader"?[{scheme:o,kind:"apiKey",name:i.headerName,in:"header"}]:i.kind==="apiKeyQuery"?[{scheme:o,kind:"apiKey",name:i.paramName,in:"query"}]:[{scheme:o,kind:"apiKey",name:i.cookieName,in:"cookie"}]})).filter(t=>t.length>0)}function M(e,n,t){if(e===void 0||n===void 0)return;let o=u(e,n,t);return o?.kind==="array"?o.items:void 0}var Z=["Printer","casing","identifierFor","uniqueIdentifiers","RESERVED_WORDS","flattenAllOf","deref","discriminatorCases","jsonSuccessSchema","sseResponse","isMultipartBody","serverUrlParts","securityRequirements","paginationItemSchema","isNullable","unwrapNullable","enumValues","docText","headerCoerceType","schemaAtPointer","paginationRuleFor","renderReferencePage","NotSupportedError"];function O(e){return e}function v(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-")}function q(e){return e.replace(/[^A-Za-z0-9]+/g,"_").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}function w(e,n){let t={...e};for(let[o,i]of Object.entries(n))i!==void 0&&(t[o]=i);return t}function pe(e){return e}async function fe(e){return(await import("./OOLLHPWT.js")).generateClient(e)}export{m as a,R as b,h as c,S as d,b as e,k as f,P as g,M as h,Z as i,O as j,v as k,q as l,w as m,pe as n,fe as o};
|
package/lib/chunks/NB54XRRU.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c as f}from"./HJYFWIVE.js";var o=/^[A-Za-z_$][A-Za-z0-9_$]*$/,u=f.typescript;function m(n){return o.test(n)}function I(n){return o.test(n)&&!u.has(n)}function c(n){let e=n.replace(/[^A-Za-z0-9_$]/g,"_");return(e===""||/^[0-9]/.test(e)||u.has(e))&&(e=`_${e}`),e}var p={"<":"\\u003C",">":"\\u003E","\u2028":"\\u2028","\u2029":"\\u2029"};function s(n){return JSON.stringify(n).replace(/[<>\u2028\u2029]/g,e=>p[e])}function E(n){return o.test(n)&&!u.has(n)?n:s(n)}function b(n,e){let i=c(n),t=i,r=2;for(;e.has(t);)t=`${i}_${r++}`;return e.add(t),t}var L=s;function g(n){if(typeof n=="string")return s(n);if(typeof n=="boolean"||n===null||typeof n=="number")return String(n);if(Array.isArray(n))return`[${n.map(g).join(", ")}]`;let e=Object.entries(n).map(([i,t])=>`${m(i)?i:s(i)}: ${g(t)}`);return e.length===0?"{}":`{ ${e.join(", ")} }`}function d(n){return n.replace(/\*\//g,"*\\/")}function M(n,e){let i=l(n,e);return i.length===0?void 0:i.join(`
|
|
8
|
-
`)}function l(n,e){let i=[];return n&&n.trim()&&i.push(...x(S(n))),e&&i.push(...h(e)),i}function h(n){let e=[],i=(t,r)=>{r===void 0?e.push(`@${t}`):e.push(`@${t} ${r}`)};return n.minimum!==void 0&&i("minimum",n.minimum),n.maximum!==void 0&&i("maximum",n.maximum),n.exclusiveMinimum!==void 0&&i("exclusiveMinimum",n.exclusiveMinimum),n.exclusiveMaximum!==void 0&&i("exclusiveMaximum",n.exclusiveMaximum),n.minLength!==void 0&&i("minLength",n.minLength),n.maxLength!==void 0&&i("maxLength",n.maxLength),n.pattern!==void 0&&i("pattern",d(n.pattern)),n.minItems!==void 0&&i("minItems",n.minItems),n.maxItems!==void 0&&i("maxItems",n.maxItems),n.uniqueItems===!0&&i("uniqueItems"),n.format!==void 0&&i("format",n.format),n.deprecated===!0&&i("deprecated"),e}function x(n){let e=0,i=n.length;for(;e<i&&n[e]==="";)e++;for(;i>e&&n[i-1]==="";)i--;return n.slice(e,i)}function _(n){return n[0].toUpperCase()+n.slice(1)}function y(n){let e=n.split(/[-_]/).filter(i=>i.length>0).map((i,t)=>{let r=i.toLowerCase();return t===0?r:r.charAt(0).toUpperCase()+r.slice(1)}).join("");return c(e)}function S(n){return n.replace(/\r\n/g,`
|
|
9
|
-
`).split(`
|
|
10
|
-
`).map(e=>e.trimEnd())}export{m as a,I as b,c,s as d,E as e,b as f,L as g,g as h,d as i,M as j,_ as k,y as l,S as m};
|
package/lib/chunks/NSIQWNYL.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as g,c as f,d as i,e as c,l as o}from"./HJYFWIVE.js";var s=f.php,h=class extends g{constructor(){super(" ")}typeName(r){return i(r,{style:"pascal",reserved:s})}memberName(r){return i(r,{style:"camel",reserved:s})}identifier(r){return i(r,{style:"camel",reserved:s})}identifiers(r,t){return c(r,{style:"camel",reserved:s,taken:t})}string(r){return`'${r.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`}literal(r){return r==null?"null":typeof r=="boolean"||typeof r=="number"?String(r):typeof r=="string"?this.string(r):Array.isArray(r)?`[${r.map(e=>this.literal(e)).join(", ")}]`:`[${Object.entries(r).map(([e,n])=>`${this.string(e)} => ${this.literal(n)}`).join(", ")}]`}comment(r){for(let t of o(r))this.line(t===""?"//":`// ${t}`);return this}doc(r,t,e=[]){let n=o(t);if(n.length===0&&e.length===0)return this;let l=n.length===0?r:`${r} \u2014 ${n.join(" ")}`;if(e.length===0)return this.line(`/** ${l} */`);this.line("/**"),this.line(` * ${l}`),this.line(" *");for(let m of e)this.line(` * ${m}`);return this.line(" */")}};export{h as a};
|
package/lib/chunks/OOLLHPWT.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as Z,b as ee,f as ne,h as T,i as te}from"./4PT55VGO.js";import{a as h}from"./PFYPTG4G.js";import{C as J,H as V,V as k,X as W,aa as Q,c as R,ca as N,ja as Y,q as O,s as X}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import{b as q,c as E,k as C}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{mkdir as an,readFile as cn,writeFile as dn}from"node:fs/promises";import{dirname as Se,parse as un,resolve as A,sep as pn}from"node:path";function x(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./P37B4DI4.js").then(n=>({run:n.tanstackQueryGenerator(e)}))}}var I={outputMode:"it always emits one self-contained file",runtime:"the runtime is always embedded in the generated file",argsStyle:"inputs follow the target language's own idiom",importExt:"the generated file has no relative imports"},j={typescript:{load:()=>import("./YEK532UO.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./AQT2EJZS.js").then(e=>({run:e.zodGenerator}))},transformers:{requires:["typescript"],dateTypes:["Date"],load:()=>import("./L3TZNNJJ.js").then(e=>({run:e.transformersGenerator}))},"tanstack-query":x("react"),"tanstack-query-vue":x("vue"),"tanstack-query-svelte":x("svelte"),"tanstack-query-solid":x("solid"),swr:{requires:["typescript"],errorModes:["throw"],load:()=>import("./2L3Z5JZA.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./MSRZMIR7.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./77VEOG4O.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:I,load:()=>import("./KNLINRO4.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:I,load:()=>import("./7ZC3TNBP.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:I,load:()=>import("./FJAJ4RIU.js").then(e=>({run:e.phpGenerator,sample:e.phpSample,docs:e.phpDocs}))}};function re(e,n,t,r){let s=new Set(e);n.goPackage!==void 0&&!s.has("go")&&k.warn(`generate-client: goPackage is ignored \u2014 it declares the Go package clause, and no selected generator uses it (add --generator go).
|
|
8
|
-
`);let o=n.errorMode??"throw",i=n.dateType??"string";for(let a of e){let c=t.get(a);if(!c)throw new h(`Unknown generator: ${a}`);for(let u of c.requires??[])if(!s.has(u)){let p=[...new Set([u,...e])].map(g=>`--generator ${g}`).join(" ");throw new h(`The "${a}" generator requires the "${u}" generator. Add it, e.g. ${p}.`)}if(c.errorModes&&!c.errorModes.includes(o))throw new h(`The "${a}" generator does not support --error-mode "${o}" (supported: ${c.errorModes.join(", ")}).`);if(c.dateTypes&&!c.dateTypes.includes(i))throw new h(`The "${a}" generator requires --date-type ${c.dateTypes.join(" or ")} (got "${i}") so the runtime values match the generated types.`);let d={...n,outputMode:r};for(let[u,p]of Object.entries(c.notApplicable??{}))d[u]!==void 0&&k.warn(`generate-client: the "${a}" generator ignores ${u} \u2014 ${p}.
|
|
9
|
-
`)}}function oe(e,n,t){let r=new Map;for(let s of e){let o=n.get(s)?.options,i=t?.[s];if(o===void 0){i!==void 0&&k.warn(`generate-client: the "${s}" generator declares no options, so client.options.${s} is ignored.
|
|
10
|
-
`),r.set(s,{});continue}r.set(s,be(s,o,i))}return r}function be(e,n,t){if(t!==void 0&&!R(t))throw new h(`The "${e}" generator's options must be a map of option names to values.`);let r=t??{},s=Object.keys(n.properties);if(n.additionalProperties!==!0){for(let i of Object.keys(r))if(!s.includes(i))throw new h(`The "${e}" generator got an unknown option "${i}". Declared options: ${s.join(", ")||"(none)"}.`)}for(let i of n.required??[])if(r[i]===void 0)throw new h(`The "${e}" generator requires the "${i}" option.`);let o={...r};for(let[i,a]of Object.entries(n.properties)){if(o[i]===void 0){a.default!==void 0&&(o[i]=a.default);continue}let c=Oe(a,o[i]);if(c!==void 0)throw new h(`The "${e}" generator's "${i}" ${c}.`)}return o}function Oe(e,n){if("enum"in e)return e.enum.includes(n)?void 0:`must be one of: ${e.enum.join(", ")}`;if(e.type==="array"){let t=e.items.type;return Array.isArray(n)&&n.every(r=>typeof r===t)?void 0:`must be an array of ${t}`}return typeof n===e.type?void 0:`must be a ${e.type}`}import{isAbsolute as Me,resolve as $e}from"node:path";import{pathToFileURL as Re}from"node:url";async function ie(e,n={}){let t=new Map;for(let a of n.customGenerators??[])ae(t,a);let r=[];for(let a of e)r.push(await se(a,t,n.configDir));let s=[],o=new Set,i=async a=>{if(!(s.includes(a)||o.has(a))){o.add(a);for(let c of t.get(a).requires??[])(t.has(c)||c in j)&&await i(await se(c,t,n.configDir));o.delete(a),s.push(a)}};for(let a of r)await i(a);return{selected:s,registry:t}}async function se(e,n,t){if(n.has(e))return e;let r=j[e];if(r!==void 0){let{load:o,...i}=r;return n.set(e,{...i,...await o()}),e}if(e==="sdk")throw new h('The "sdk" generator is now named "typescript". Update the `generators` list or the --generator flag.');let s=await ve(e,t??process.cwd());return ae(n,s),s.name}function ae(e,n){if(!R(n)||typeof n.name!="string"||n.name===""||typeof n.run!="function")throw new h("Invalid custom generator: expected an object with a non-empty string `name` and a `run` function (build one with `defineGenerator`).");if(e.has(n.name))throw new h(`Generator name "${n.name}" collides with an existing generator. Rename the custom generator.`);if(n.requiresGenerator!==void 0){let t=te(T,n.requiresGenerator);if(t===void 0)throw new h(`Generator "${n.name}" declares requiresGenerator "${n.requiresGenerator}", which is not a range we read. Use ^1.2.0, ~1.2.0, >=1.2.0, or an exact version.`);if(!t)throw new h(`Generator "${n.name}" needs @redocly/client-generator ${n.requiresGenerator}; this CLI ships ${T}. Upgrade @redocly/cli if the generator is newer, or update the generator \u2014 \`redocly eject-generator <name> --update\` for an ejected file, or upgrade its package.`)}n.name in j&&k.warn(`generate-client: custom generator "${n.name}" takes over the built-in generator of the same name.
|
|
11
|
-
`),e.set(n.name,{run:n.run,sample:n.sample,docs:n.docs,notApplicable:n.notApplicable,options:n.options,requires:n.requires,errorModes:n.errorModes,dateTypes:n.dateTypes})}async function ve(e,n){if(X(e))throw new h(`Remote generator modules are not supported \u2014 use a local path or a package name. Got: ${e}`);let t=e.startsWith(".")||Me(e),r=t?Re($e(n,e)).href:e;if(t&&e.endsWith(".ts")&&!process.features.typescript)throw new h(`Generator "${e}" is TypeScript, which this Node cannot run directly \u2014 use Node 22.18, 23.6, or newer.`);let s;try{s=await import(r)}catch(i){throw new h(`Could not load generator "${e}": ${i.message}`)}let o=s.default??s.generator;if(o===void 0)throw new h(`Generator module "${e}" must export a generator (a default export or a \`generator\` export built with \`defineGenerator\`).`);return o}function ue(e){let n=new Set,t=new Set,r=new Map;for(let f of e.securitySchemes){let m=B(f.key,n,t);m!==f.key&&(r.set(f.key,m),L("security scheme",f.key,m,de(f.key,n)),f.key=m)}let s=new Set(ne()),o=new Set(s),i=new Set,a=new Map;for(let f of e.schemas){let m=B(f.name,o,i);m!==f.name&&(a.set(f.name,m),L("schema",f.name,m,de(f.name,s)),f.name=m)}let c=f=>a.get(f)??ce(f),d=f=>r.get(f)??ce(f);for(let f of e.schemas)S(f.schema,c);let u=new Set(o),p=new Set,g=new Set;for(let f of e.services)for(let m of f.operations){let l=g.has(m.name);g.add(m.name);let y=m.name,P=B(m.name,u,p);if(P!==m.name){let G=l?{kind:"duplicate-operation-id"}:s.has(y)?{kind:"reserved"}:o.has(y)?{kind:"schema-collision"}:{kind:"unusable"};L("operation",y,P,G),m.specName=m.name,m.name=P}Pe(m,c),m.security=m.security.map(G=>G.map(d))}}function B(e,n,t){let r=E(e),s=r,o=2;for(;n.has(s)||t.has(C(s));)s=`${r}_${o++}`;return n.add(s),t.add(C(s)),s}function pe(e){for(let n of e.schemas)if(!q(n.name))throw U("schema",n.name);for(let n of e.securitySchemes)if(!q(n.key))throw U("security scheme",n.key);for(let n of e.services)for(let t of n.operations)if(!q(t.name))throw U("operation",t.name)}function U(e,n){return new Error(`Internal error: ${e} name ${JSON.stringify(n)} is not a safe identifier after sanitization.`)}function ce(e){return E(e)}function L(e,n,t,r){let s=JSON.stringify(n),o=JSON.stringify(t),i=r.kind==="duplicate-operation-id"?`two operations share the operationId ${s}; the second is emitted as ${o} \u2014 give each operation a unique operationId to control its method name`:r.kind==="schema-collision"?`${e} ${s} collides with the schema of the same name, so it is emitted as ${o} \u2014 rename the operation or the schema in the description to control its name`:r.kind==="reserved"?`${e} ${s} is a name a generated client already declares, so it is emitted as ${o} \u2014 the reserved set spans every target language, so one schema keeps one name across the SDKs you generate`:`${e} ${s} is not a usable identifier, so it is emitted as ${o}`;k.warn(`generate-client: ${i}.
|
|
12
|
-
`)}function de(e,n){return n.has(e)?{kind:"reserved"}:{kind:"unusable"}}function S(e,n){switch(e.kind){case"ref":e.name=n(e.name);break;case"omit":e.base=n(e.base);break;case"array":S(e.items,n);break;case"record":S(e.value,n);break;case"object":for(let t of e.properties)S(t.schema,n);break;case"union":for(let t of e.members)S(t,n);if(e.discriminator)for(let t of e.discriminator.mapping)t.schemaName=n(t.schemaName);break;case"intersection":for(let t of e.members)S(t,n);break}}function Pe(e,n){for(let t of e.pathParams)S(t.schema,n);for(let t of e.queryParams)S(t.schema,n);for(let t of e.headerParams)S(t.schema,n);for(let t of e.cookieParams)S(t.schema,n);e.requestBody&&S(e.requestBody.schema,n);for(let t of[...e.successResponses,...e.errorResponses])S(t.schema,n),t.itemSchema&&S(t.itemSchema,n)}var Ge=["get","post","put","delete","patch","head","options"];function fe(e,n){if(!n.startsWith("#/"))throw new h(`External $ref not supported: ${n}`);let t=n.slice(2).split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~")),r=e;for(let s of t){if(!R(r)&&!Array.isArray(r))throw new h(`Cannot resolve $ref: ${n}`);r=r[s]}if(r===void 0)throw new h(`Cannot resolve $ref: ${n}`);return r}function M(e,n){return O(n)?fe(e,n.$ref):n}function D(e){let n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e}function De(e){let n=e,t={};return typeof n.minimum=="number"&&(t.minimum=n.minimum),typeof n.maximum=="number"&&(t.maximum=n.maximum),typeof n.exclusiveMinimum=="number"?t.exclusiveMinimum=n.exclusiveMinimum:n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t.exclusiveMinimum=n.minimum,delete t.minimum),typeof n.exclusiveMaximum=="number"?t.exclusiveMaximum=n.exclusiveMaximum:n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t.exclusiveMaximum=n.maximum,delete t.maximum),typeof n.minLength=="number"&&(t.minLength=n.minLength),typeof n.maxLength=="number"&&(t.maxLength=n.maxLength),typeof n.pattern=="string"&&(t.pattern=n.pattern),typeof n.minItems=="number"&&(t.minItems=n.minItems),typeof n.maxItems=="number"&&(t.maxItems=n.maxItems),n.uniqueItems===!0&&(t.uniqueItems=!0),typeof n.format=="string"&&(t.format=n.format),n.deprecated===!0&&(t.deprecated=!0),n.example!==void 0?t.example=n.example:Array.isArray(n.examples)&&n.examples.length>0&&(t.example=n.examples[0]),n.default!==void 0&&(t.default=n.default),Object.keys(t).length>0?t:void 0}function qe(e,n){let t=e.discriminator;if(!t||typeof t.propertyName!="string")return;let r=[];if(t.mapping)for(let[s,o]of Object.entries(t.mapping))r.push({value:s,schemaName:D(o)});else for(let s of n)if(O(s)){let o=D(s.$ref);r.push({value:o,schemaName:o})}if(r.length!==0)return{propertyName:t.propertyName,mapping:r}}function b(e,n){return n?{...e,metadata:n}:e}function z(e,n){return e?n?{...e,...n}:e:n}function xe(e){return e?e.url.replace(/\{([^{}]+)\}/g,(n,t)=>e.variables?.[t]?.default??n):""}function me(e){let n=e.info?.title??"Api",t=e.info?.version??"0.0.0",r=e.info?.description,s=xe(e.servers?.[0]),o=(e.servers??[]).map(u=>({url:u.url,description:u.description,variables:Object.entries(u.variables??{}).map(([p,g])=>({name:p,default:g.default,description:g.description}))})),i=Ie(e),a=Ee(e),c=Be(e,a),d={title:n,version:t,description:r,serverUrl:s,servers:o,services:c,schemas:i,securitySchemes:a};return ue(d),je(c,i),pe(d),d}function je(e,n){let t=new Map(n.map(r=>[r.name,r.schema]));for(let r of e)for(let s of r.operations)s.requestBody&&(s.requestBody.schema=Ne(s.requestBody.schema,t))}function Ae(e){let n=e.filter(t=>t.kind!=="unknown");return n.length>0?n:[{kind:"unknown"}]}function Ne(e,n){if(e.kind==="ref"){let t=Te(e,n,new Set);return t.length>0?{kind:"omit",base:e.name,keys:t}:e}if(e.kind==="object"){let t=e.properties.filter(r=>!r.readOnly);return t.length===e.properties.length?e:{...e,properties:t}}return e}function Te(e,n,t){let r=[],s=o=>{if(o.kind==="ref"){if(t.has(o.name))return;t.add(o.name);let i=n.get(o.name);i&&s(i)}else if(o.kind==="object")for(let i of o.properties)i.readOnly&&!r.includes(i.name)&&r.push(i.name);else if(o.kind==="intersection")for(let i of o.members)s(i)};return s(e),r}function Ee(e){let n=e.components?.securitySchemes;if(!n)return[];let t=[];for(let[r,s]of Object.entries(n)){let o=M(e,s),i=o.type;i==="oauth2"||i==="openIdConnect"?t.push({kind:"bearer",key:r}):i==="http"&&(o.scheme??"").toLowerCase()==="bearer"?t.push({kind:"bearer",key:r}):i==="http"&&(o.scheme??"").toLowerCase()==="basic"?t.push({kind:"basic",key:r}):i==="apiKey"&&o.in==="header"&&typeof o.name=="string"?t.push({kind:"apiKeyHeader",key:r,headerName:o.name}):i==="apiKey"&&o.in==="query"&&typeof o.name=="string"?t.push({kind:"apiKeyQuery",key:r,paramName:o.name}):i==="apiKey"&&o.in==="cookie"&&typeof o.name=="string"&&(k.warn(`generate-client: security scheme "${r}" sends its credential in the Cookie header, which browsers ignore \u2014 cookie auth works only in server-side clients.
|
|
13
|
-
`),t.push({kind:"apiKeyCookie",key:r,cookieName:o.name}))}return t}function Ce(e,n,t){let r=e.security??n.security;if(!r)return[];let s=[];for(let o of r){let i=Object.keys(o);i.length!==0&&i.every(a=>t.has(a))&&s.push([...new Set(i)])}return s}function Ie(e){let n=e.components?.schemas;return n?Object.entries(n).map(([t,r])=>{if(O(r)){let o=fe(e,r.$ref);return{name:t,schema:v(o,`components.schemas.${t}`,e),description:o.description}}let s=v(r,`components.schemas.${t}`,e);return{name:t,schema:s,description:r.description}}):[]}function Be(e,n){let t=new Set(n.map(i=>i.key)),r=[],s=new Set;for(let[i,a]of Object.entries(e.paths??{})){if(!a)continue;let c=M(e,a),d=(c.parameters??[]).map(u=>ge(M(e,u),`paths.${i}.parameters`,e));for(let u of Ge){let p=c[u];p&&(r.push({method:u,path:i,operation:p,pathLevelParams:d}),p.operationId&&s.add(p.operationId))}}return[{name:"Default",operations:r.map(i=>{let a=i.operation.operationId??ze(Ue(i.method,i.path),s);return He(i.method,i.path,i.operation,a,i.pathLevelParams,e,t)})}]}function Ue(e,n){let t=n.split("/").filter(Boolean).map(r=>Le(r.replace(/[{}]/g,"")));return`${e}${t.join("")}`}function Le(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function ze(e,n){let t=e,r=2;for(;n.has(t);)t=`${e}${r++}`;return n.add(t),t}function He(e,n,t,r,s,o,i){let a=(t.parameters??[]).map(w=>ge(M(o,w),`paths.${n}.${e}.parameters`,o)),c=new Set,d=[];for(let w of a)c.add(`${w.in}:${w.name}`),d.push(w);for(let w of s)c.has(`${w.in}:${w.name}`)||d.push(w);let u=d.filter(w=>w.in==="path"),p=d.filter(w=>w.in==="query"),g=d.filter(w=>w.in==="header"),f=d.filter(w=>w.in==="cookie"),m=t.requestBody?Fe(M(o,t.requestBody),`${e} ${n}`,o):void 0,{successResponses:l,successResponseHeaders:y}=_e(t,n,o),P=Je(t,n,o),G=Ce(t,o,i),F=t["x-redoclyPagination"],_=Ke(l);return{name:r,method:e,path:n,summary:t.summary,description:t.description,pathParams:u,queryParams:p,headerParams:g,cookieParams:f,requestBody:m,successResponses:l,...y===void 0?{}:{successResponseHeaders:y},errorResponses:P,security:G,tags:Array.isArray(t.tags)?t.tags.filter(w=>typeof w=="string"):[],...F!==void 0?{paginationExtension:F}:{},..._===void 0?{}:{sse:_}}}function Ke(e){let n=e.find(s=>s.contentType.split(";")[0].trim().toLowerCase()==="text/event-stream");if(n===void 0)return;let t=n.itemSchema&&n.itemSchema.kind!=="unknown"?n.itemSchema:n.schema.kind!=="unknown"?n.schema:void 0;if(t===void 0)return{dataKind:"text"};let r=t.kind==="object"||t.kind==="ref"||t.kind==="array"||t.kind==="record"||t.kind==="union"||t.kind==="intersection";return{eventSchema:t,dataKind:r?"json":"text"}}function ge(e,n,t){if(!e.in)throw new h(`Parameter ${e.name} at ${n} is missing "in"`);if(!["path","query","header","cookie"].includes(e.in))throw new h(`Unsupported parameter location "${e.in}" for ${e.name} at ${n}`);let r=$(e.schema,`${n}.${e.name}`,t);e.deprecated===!0&&(r={...r,metadata:z(r.metadata,{deprecated:!0})});let s={name:e.name,in:e.in,schema:r,required:!!e.required,description:e.description};if(s.in==="query"){let o=e;(o.style==="form"||o.style==="spaceDelimited"||o.style==="pipeDelimited"||o.style==="deepObject")&&(s.style=o.style),typeof o.explode=="boolean"&&(s.explode=o.explode),typeof o.allowReserved=="boolean"&&(s.allowReserved=o.allowReserved)}return s}function Fe(e,n,t){let r=e.content??{},s=r["application/json"]??r["application/merge-patch+json"]??r["application/x-www-form-urlencoded"]??r["multipart/form-data"]??Object.values(r)[0];if(!s)return;let o=Object.keys(r).find(a=>r[a]===s),i=$(s.schema,`${n}.requestBody`,t);return{contentType:o,schema:i,required:!!e.required,description:e.description}}function _e(e,n,t){let r=e.responses??{},s=Object.keys(r).filter(g=>/^2\d\d$/.test(g));s.length===0&&(r["2XX"]?s.push("2XX"):r.default&&s.push("default"));let o=s[0];if(!o)return{successResponses:[]};let i=r[o];if(!i)return{successResponses:[]};let a=M(t,i),c=Xe(a.headers,`paths.${n}.response.${o}`,t),d=a.content;if(!d)return{successResponses:[],...c===void 0?{}:{successResponseHeaders:c}};let u=o==="default"||o==="2XX"?o:Number(o),p=[];for(let[g,f]of Object.entries(d)){let m=$(f.schema,`paths.${n}.response.${o}.${g}`,t),l=f.itemSchema,y=l!==void 0?$(l,`paths.${n}.response.${o}.${g}.itemSchema`,t):void 0;p.push({contentType:g,schema:m,status:u,...y===void 0?{}:{itemSchema:y}})}return{successResponses:p,...c===void 0?{}:{successResponseHeaders:c}}}function Xe(e,n,t){if(!e)return;let r=[];for(let[s,o]of Object.entries(e)){let i=M(t,o),a={name:s.toLowerCase(),schema:$(i.schema===void 0?void 0:M(t,i.schema),`${n}.headers.${s}`,t)};i.required===!0&&(a.required=!0),r.push(a)}return r.length>0?r:void 0}function Je(e,n,t){let r=e.responses??{},s=Object.keys(r).filter(a=>/^([45]\d\d|4XX|5XX)$/.test(a));Object.keys(r).some(a=>/^(2\d\d|2XX)$/.test(a))&&r.default&&s.push("default");let i=[];for(let a of s){let c=r[a];if(!c)continue;let u=M(t,c).content;if(!u)continue;let p=a==="default"||a==="4XX"||a==="5XX"?a:Number(a);for(let[g,f]of Object.entries(u)){let m=$(f.schema,`paths.${n}.response.${a}.${g}`,t);i.push({contentType:g,schema:m,status:p})}}return i}function $(e,n,t){return e===void 0||typeof e=="boolean"?{kind:"unknown"}:O(e)?{kind:"ref",name:D(e.$ref)}:v(e,n,t)}function v(e,n,t){let r=De(e),s=e.oneOf??e.anyOf;if(s){let a=s.map((u,p)=>O(u)?{kind:"ref",name:D(u.$ref)}:v(u,`${n}.[${p}]`,t)),c=Ae(a);if(c.length===1&&c.length<a.length){let u=c[0];return{...u,description:u.description??e.description,metadata:z(r,u.metadata)}}let d=qe(e,s);return b({kind:"union",members:c,discriminator:d,description:e.description},r)}if(e.allOf){let a=e.allOf.map((d,u)=>O(d)?{kind:"ref",name:D(d.$ref)}:v(d,`${n}.allOf[${u}]`,t)),c=le(e,n,t);if(c.length>0&&a.unshift({kind:"object",properties:c}),a.length===1){let d=a[0];return{...d,description:d.description??e.description,metadata:z(r,d.metadata)}}return b({kind:"intersection",members:a,description:e.description},r)}let o=e.type;if(Array.isArray(o)){let a=o.filter(u=>u!=="null"),c=o.includes("null"),d=a.map(u=>{let p={...e,type:u};if(Array.isArray(p.enum)){let g=p.enum.filter(f=>f!==null);p.enum=g.length>0?g:void 0}return v(p,n,t)});return c&&d.push({kind:"null"}),d.length===1?d[0]:b({kind:"union",members:d,description:e.description},r)}if(e.nullable)return{kind:"union",members:[v({...e,nullable:void 0},n,t),{kind:"null"}],description:e.description};if(e.const!==void 0){let a=e.const;if(typeof a!="string"&&typeof a!="number"&&typeof a!="boolean")throw new h(`Unsupported const value at ${n}: ${JSON.stringify(a)}`);return b({kind:"literal",value:a,description:e.description},r)}if(e.enum){let a=e.enum,c=a.filter(g=>g!==null),d=c.length!==a.length;if(c.length===0)return b({kind:"null",description:e.description},r);let u=Ve(c,n),p=u==="boolean"?{kind:"scalar",scalar:"boolean",description:e.description}:{kind:"enum",values:c,scalar:u,description:e.description};return b(d?{kind:"union",members:[p,{kind:"null"}],description:e.description}:p,r)}let i=o;if(i==="null")return b({kind:"null",description:e.description},r);if(i==="array"){let a=e.items,c=$(a,`${n}.items`,t);return b({kind:"array",items:c,description:e.description},r)}if(i==="object"||e.properties||e.additionalProperties){let a=le(e,n,t),c=e.additionalProperties;if(a.length===0&&c!==!1){let d=$(c,`${n}.additionalProperties`,t);return b({kind:"record",value:d,description:e.description},r)}return b({kind:"object",properties:a,description:e.description},r)}return b(i==="string"||i==="number"||i==="integer"||i==="boolean"?{kind:"scalar",scalar:i,description:e.description}:{kind:"unknown",description:e.description},r)}function Ve(e,n){let t=!1,r=!1,s=!1;for(let o of e)if(typeof o=="string")t=!0;else if(typeof o=="number")r=!0;else if(typeof o=="boolean")s=!0;else throw new h(`Unsupported enum value type at ${n}: ${JSON.stringify(o)}`);return t&&!r&&!s?"string":r&&!t&&!s?"number":s&&!t&&!r?"boolean":"string"}function We(e){return!(e.openapi??"").startsWith("3.0")}function le(e,n,t){let r=e.properties??{},s=new Set(e.required??[]),o=We(t);return Object.entries(r).map(([i,a])=>{let c=a.readOnly===!0;c&&O(a)&&!o&&k.warn(`generate-client: "${i}" declares readOnly beside a $ref, which OpenAPI ${t.openapi} ignores \u2014 the property stays in request bodies. Inline the schema, wrap the $ref in allOf, or move the description to OpenAPI 3.1.
|
|
14
|
-
`);let d=c&&(o||!O(a));return{name:i,schema:$(a,`${n}.${i}`,t),required:s.has(i),description:a.description,...d?{readOnly:!0}:{}}})}function he(e){let n=H(e),t={...n};delete t.swagger,delete t.host,delete t.basePath,delete t.schemes,delete t.definitions,delete t.securityDefinitions,delete t.consumes,delete t.produces,delete t.parameters,delete t.responses,t.openapi="3.0.3";let r=Qe(n);return r&&(t.servers=r),t.components=Ye(n),t.paths=tn(n.paths??{},n.consumes??void 0,n.produces??void 0),t}function Qe(e){let n=e.host,t=e.basePath??"",r=(e.schemes??["https"])[0]??"https";if(n)return[{url:`${r}://${n}${t}`}]}function Ye(e){let n={};e.definitions&&(n.schemas=e.definitions),e.parameters&&(n.parameters=Object.fromEntries(Object.entries(e.parameters).map(([r,s])=>[r,K(s)]))),e.responses&&(n.responses=we(e.responses,void 0));let t=e.securityDefinitions;if(t){let r={};for(let[s,o]of Object.entries(t))r[s]=Ze(o);n.securitySchemes=r}return n}function Ze(e){switch(e.type){case"basic":return{type:"http",scheme:"basic"};case"apiKey":return{type:"apiKey",name:e.name,in:e.in};case"oauth2":{let n=e.flow==="accessCode"?"authorizationCode":e.flow==="application"?"clientCredentials":e.flow,t={scopes:e.scopes??{}};return e.authorizationUrl&&(t.authorizationUrl=e.authorizationUrl),e.tokenUrl&&(t.tokenUrl=e.tokenUrl),{type:"oauth2",flows:{[n]:t}}}default:return e}}function H(e){if(Array.isArray(e))return e.map(H);if(R(e)){let n={};for(let[t,r]of Object.entries(e))t==="$ref"&&typeof r=="string"?n.$ref=r.replace("#/definitions/","#/components/schemas/").replace("#/parameters/","#/components/parameters/").replace("#/responses/","#/components/responses/"):n[t]=H(r);return n}return e}var en="application/json",nn="application/json",ye=new Set(["name","in","required","description","deprecated","allowEmptyValue","collectionFormat"]);function tn(e,n,t){let r={};for(let[s,o]of Object.entries(e)){let i=o,a={};for(let[c,d]of Object.entries(i)){if(c==="parameters"&&Array.isArray(d)){a.parameters=d.map(K);continue}if(!rn(c)){a[c]=d;continue}a[c]=on(d,n,t)}r[s]=a}return r}function rn(e){return["get","put","post","delete","options","head","patch"].includes(e.toLowerCase())}function on(e,n,t){let r=e.consumes??n,s=e.produces??t,o=e.parameters??[],i=o.find(p=>p.in==="body"),a=o.filter(p=>p.in==="formData"),c=o.filter(p=>p.in!=="body"&&p.in!=="formData").map(K),d={...e,parameters:c};delete d.consumes,delete d.produces;let u=r?.[0]??en;if(i)d.requestBody={required:!!i.required,content:{[u]:{schema:i.schema}}};else if(a.length>0){let p={},g=[];for(let l of a)p[l.name]=sn(l),l.required&&g.push(l.name);let f={type:"object",properties:p};g.length>0&&(f.required=g);let m=r?.find(l=>l==="multipart/form-data")??r?.[0]??"application/x-www-form-urlencoded";d.requestBody={required:g.length>0,content:{[m]:{schema:f}}}}return e.responses&&(d.responses=we(e.responses,s)),d}function K(e){if(e.$ref!==void 0||e.in==="body"||e.in==="formData")return e;let n={},t={};for(let[r,s]of Object.entries(e))ye.has(r)?n[r]=s:t[r]=s;if(n.schema=t,delete n.collectionFormat,e.in==="query"&&t.type==="array"){let r=e.collectionFormat??"csv";r!=="multi"&&(n.style=r==="ssv"?"spaceDelimited":r==="pipes"?"pipeDelimited":"form",n.explode=!1)}return n}function sn(e){let n={};for(let[t,r]of Object.entries(e))ye.has(t)||(n[t]=r);return n}function we(e,n){let t=n?.[0]??nn,r={};for(let[s,o]of Object.entries(e)){let i=o;if(i.schema===void 0){r[s]=i;continue}let{schema:a,...c}=i;r[s]={...c,content:{[t]:{schema:a}}}}return r}async function ke(e,n){let t=n??await N({}),r=await Q({ref:e,config:t}),s=await N({rules:{struct:"error"}}),o=await Y({externalRefResolver:new V,document:r.bundle,config:s}),i=[...r.problems,...o].filter(c=>c.severity==="error");if(i.length>0){let c=i.map(d=>`- ${d.message} (at ${d.location?.[0]?.pointer??e})`).join(`
|
|
15
|
-
`);throw new Error(`The API description has ${i.length} error(s):
|
|
16
|
-
${c}`)}let a=r.bundle.parsed;return{document:a,version:W(a)}}var ln=["Generated by @redocly/client-generator \u2014 do not edit by hand.","Source: OpenAPI description. Re-run `redocly generate-client` to update."];function fn(e,n){let t=[],r=new Set,s=A(Se(n.outputPath)),{dir:o,name:i,ext:a}=un(n.outputPath),c={path:n.outputPath,dir:o,stem:i,ext:a},d=ln,u=!1;for(let p of n.generators){let g=n.registry.get(p),f={model:e,output:c,banner:d,outputMode:n.outputMode,emit:n.emit,pagination:n.pagination,selected:n.generators,options:n.generatorOptions?.get(p)??{}},m;try{n.emit.docs===!0&&g.docs!==void 0?(m=[...g.run(f),...g.docs(f)],u=!0):m=g.run(f)}catch(l){let y=l instanceof Error?l.message:String(l);throw new Error(`Generator "${p}" failed: ${y}`)}if(!Array.isArray(m)||m.some(l=>typeof l?.path!="string"||l.path===""||typeof l.content!="string"))throw new Error(`Generator "${p}" failed: run() must return an array of { path, content } files.`);for(let l of m){let y=A(s,l.path);if(y!==s&&!y.startsWith(s+pn))throw new Error(`Generator "${p}" failed: file path escapes the output directory: ${l.path}`);if(r.has(y))throw new Error(`Generator conflict: ${l.path} already emitted by an earlier generator`);r.add(y),t.push({path:y,content:l.content})}}return n.emit.docs===!0&&!u&&k.warn(`generate-client: docs is on, but no selected generator writes documentation (${n.generators.join(", ")}).
|
|
17
|
-
`),t}function mn(e){for(let n of e.services)for(let t of n.operations){let r=new Set,s=new Set;for(let o of[...t.pathParams,...t.queryParams,...t.headerParams,...t.cookieParams])r.has(o.name)&&s.add(o.name),r.add(o.name);s.size!==0&&k.warn(`generate-client: operation "${t.specName??t.name}" uses ${[...s].map(o=>`"${o}"`).join(", ")} in more than one parameter location. Every SDK sends both, and the SDKs whose methods take one argument per parameter give the later one a suffixed name \u2014 rename it in the description to choose the name yourself.
|
|
18
|
-
`)}}function gn(e,n,t,r,s,o){let i=[];for(let a of Z(e.services)){let c=t.map(d=>r.get(d)?.sample?.(a,{model:e,emit:n,outputPath:s,pagination:o})).filter(d=>d!==void 0);c.length>0&&i.push({target:`$.paths['${a.path.replaceAll("'","''")}'].${a.method}`,update:{"x-codeSamples":c}})}if(i.length!==0)return J({overlay:"1.0.0",info:{title:`Code samples for ${e.title}`,version:e.version},actions:i})}async function et(e){if(e.output.split(/[\\/]/).some(l=>l==="undefined"||l==="null"))throw new Error(`output path "${e.output}" contains a literal "undefined" or "null" segment \u2014 this looks like an interpolation bug in the caller`);if(e.setup&&/^[a-z][a-z0-9+.-]+:/i.test(e.setup))throw new h(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let n=A(e.output),{document:t,version:r}=await ke(e.api,e.config),s=r==="oas2"?he(t):t,o=me(s);mn(o);let i;if(e.setup){let{bakeSetup:l}=await import("./ZBL4IVEW.js"),y=A(e.configDir??process.cwd(),e.setup);i=l(await cn(y,"utf-8"))}let a=e.generators?.length?e.generators:["typescript"],{selected:c,registry:d}=await ie(a,{customGenerators:e.customGenerators,configDir:e.configDir}),u=ee(o,e.pagination),p={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,setup:i,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:u,docs:e.docs,docsFrontmatter:e.docsFrontmatter};re(c,p,d,e.outputMode);let g=oe(c,d,e.options),f=fn(o,{outputPath:n,outputMode:e.outputMode??"single",emit:p,pagination:u,generators:c,generatorOptions:g,registry:d});if(e.codeSamples===!0){let l=gn(o,p,c,d,n,u);l!==void 0&&f.push({path:n.replace(/\.[^.]+$/,".code-samples.yaml"),content:l})}let m=[];for(let l of f)await an(Se(l.path),{recursive:!0}),await dn(l.path,l.content,"utf-8"),m.push({path:l.path,bytes:Buffer.byteLength(l.content,"utf-8")});return{outputPath:n,bytes:m.reduce((l,y)=>l+y.bytes,0),files:m}}export{et as generateClient,fn as runGenerators};
|
package/lib/chunks/P37B4DI4.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as k,b as d,c as g,d as f}from"./2WUJ57QA.js";import"./XWZNQKXF.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{b as p,d as O,e as u}from"./NB54XRRU.js";import{m as P}from"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as R}from"node:path";function x(e,t){let n=k(e,"tanstack-query");if(n.length===0)return"";let r=t.pagination??new Map;return[b(n,t,r),...n.filter(d).map(s=>K(s,t.queryKeyPrefix)),j(e,n,r,t.queryKeyPrefix,t.argsStyle),...N(n,r)].join(`
|
|
8
|
-
`)}function h(e,t){if(!d(e))return!1;let n=t.get(e.name);return n!==void 0&&n.spec.style!=="link"}function b(e,t,n){let r=[...e.some(a=>h(a,n))?["infiniteQueryOptions"]:[],...e.some(d)?["queryOptions"]:[]],i=[...e.filter(g).map(f),"RequestOptions"].sort().map(a=>`type ${a}`),s=[];return r.length>0&&s.push(`import { ${r.join(", ")} } from "@tanstack/${t.framework}-query";`),s.push(`import { client, ${i.join(", ")} } from "${t.sdkModule}";`),s.join(`
|
|
9
|
-
`)}function K(e,t){let n=A(e,t);return g(e)?`export const ${e.name}QueryKey = (vars?: ${f(e)}) =>
|
|
10
|
-
vars === undefined ? ([${n}] as const) : ([${n}, vars] as const);`:`export const ${e.name}QueryKey = () => [${n}] as const;`}function A(e,t){return t===void 0?`"${e.name}"`:`${O(t)}, "${e.name}"`}function j(e,t,n,r,i){return`/**
|
|
11
|
-
* Build the factories over a specific client instance \u2014 its config, middleware, and
|
|
12
|
-
* retry apply to every call (\`createQueryFactories(createClient(OPERATIONS, config))\`).
|
|
13
|
-
* The module-level exports below are these factories bound to the generated module's default \`client\`.
|
|
14
|
-
*/
|
|
15
|
-
export const createQueryFactories = (instance: typeof client = client) => ({
|
|
16
|
-
`+t.flatMap(a=>{if(!d(a))return[T(a,r)];let o=n.get(a.name);return o!==void 0&&o.spec.style!=="link"?[v(a),Q(e,a,o.spec,i)]:[v(a)]}).join(`,
|
|
17
|
-
`)+`
|
|
18
|
-
});`}function v(e){let{params:t,keyArg:n,callArgs:r}=q(e);return` ${e.name}Options: (${t}) => queryOptions({
|
|
19
|
-
queryKey: ${e.name}QueryKey(${n}),
|
|
20
|
-
queryFn: ({ signal }) => instance.${e.name}(${r}, { ...init, signal, envelope: undefined }),
|
|
21
|
-
})`}function T(e,t){let n=g(e)?`(vars: ${f(e)}) => instance.${e.name}(vars, { ...init, envelope: undefined })`:`() => instance.${e.name}({}, { ...init, envelope: undefined })`;return` ${e.name}Mutation: (${M}) => ({
|
|
22
|
-
mutationKey: [${A(e,t)}] as const,
|
|
23
|
-
mutationFn: ${n},
|
|
24
|
-
})`}function Q(e,t,n,r){let{params:i,keyArg:s}=q(t),a=u(n.param),o=r==="flat"?`{ ...vars, ${a}: pageParam }`:`{ ...vars, query: { ...vars.query, ${a}: pageParam } }`;return` ${t.name}InfiniteOptions: (${i}) => infiniteQueryOptions({
|
|
25
|
-
queryKey: [...${t.name}QueryKey(${s}), "infinite"] as const,
|
|
26
|
-
queryFn: ({ pageParam, signal }) => instance.${t.name}(${o}, { ...init, signal, envelope: undefined }),
|
|
27
|
-
`+F(e,t,n,r)+" })"}function F(e,t,n,r){let i=w(n.param),s=r==="flat"?C("vars",n.param):`vars.query?.${i}`;if(n.style==="cursor"){let l=n.hasMore===void 0?"":` if (lastPage${y(n.hasMore)} === false) return undefined;
|
|
28
|
-
`,m=I(e,t,n.nextCursor),$=m.length===0?` return lastPage${y(n.nextCursor)};
|
|
29
|
-
`:` const next = lastPage${y(n.nextCursor)};
|
|
30
|
-
return ${m.join(" || ")} ? undefined : next;
|
|
31
|
-
`;return` initialPageParam: ${s},
|
|
32
|
-
getNextPageParam: (lastPage) => {
|
|
33
|
-
`+l+$+` },
|
|
34
|
-
`}let a=n.style==="offset"?"lastPageParam + count":"lastPageParam + 1",o=n.style==="offset"?"0":"1";return` initialPageParam: ${s} ?? ${o},
|
|
35
|
-
getNextPageParam: (lastPage, _allPages, lastPageParam) => {
|
|
36
|
-
const count = ${E(n.items)};
|
|
37
|
-
return count === 0 ? undefined : ${a};
|
|
38
|
-
},
|
|
39
|
-
`}function I(e,t,n){let r=t.successResponses.find(c=>c.contentType.toLowerCase().includes("json")),i=P(r.schema,"",e),s=P(r.schema,n,e),a=n.slice(1).split("/"),o=a.length>1;if(!o&&i?.kind==="object"){let c=i.properties.find(S=>S.name===a[0]);o=c===void 0||!c.required}let l=s?.kind==="union"?s.members:s?[s]:[],m=l.some(c=>c.kind==="null"),$=l.some(c=>c.kind==="scalar"&&c.scalar==="string");return[...o?["next === undefined"]:[],...m?["next === null"]:[],...$?['next === ""']:[]]}var M='init?: Omit<RequestOptions, "envelope">';function q(e){return g(e)?{params:`vars: ${f(e)}, ${M}`,keyArg:"vars",callArgs:"vars"}:{params:M,keyArg:"",callArgs:"{}"}}function w(e){return p(e)?e:`[${u(e)}]`}function C(e,t){return p(t)?`${e}.${t}`:`${e}[${u(t)}]`}function y(e){return e.slice(1).split("/").map(n=>n.replaceAll("~1","/").replaceAll("~0","~")).map((n,r)=>{let i=p(n);return r===0?i?`.${n}`:`[${u(n)}]`:i?`?.${n}`:`?.[${u(n)}]`}).join("")}function E(e){return e===""?"lastPage?.length ?? 0":`lastPage${y(e)}?.length ?? 0`}function N(e,t){return["const defaultFactories = createQueryFactories();",...e.flatMap(r=>d(r)?h(r,t)?[`${r.name}Options`,`${r.name}InfiniteOptions`]:[`${r.name}Options`]:[`${r.name}Mutation`]).map(r=>`export const ${r} = defaultFactories.${r};`)]}function z(e){return({model:t,output:n,banner:r,emit:i,pagination:s})=>{let a=x(t,{argsStyle:i.argsStyle??"grouped",sdkModule:`./${n.stem}.${i.importExt??"js"}`,framework:e,pagination:s,queryKeyPrefix:i.queryKeyPrefix});if(a==="")return[];let o=r.map(l=>`// ${l}`).join(`
|
|
40
|
-
`);return[{path:R(n.dir,`${n.stem}.tanstack.ts`),content:`${o}
|
|
41
|
-
|
|
42
|
-
${a}`}]}}export{z as tanstackQueryGenerator};
|