@redocly/cli 2.47.0 → 2.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chunks/{QRD3XQNU.js → 2U54VUOE.js} +1 -1
- package/lib/chunks/3JJEI7CJ.js +456 -0
- package/lib/chunks/4I2OVMBJ.js +11 -0
- package/lib/chunks/{REBHK2JR.js → 4JDAOKRJ.js} +1 -1
- package/lib/chunks/5JIGUBC3.js +7 -0
- package/lib/chunks/{QVV2EKMT.js → 5SAFIITS.js} +1 -1
- package/lib/chunks/6KCIFTIG.js +57 -0
- package/lib/chunks/{5NR4DJW4.js → 6VSHPQXO.js} +1 -1
- package/lib/chunks/{W2NJCZOS.js → 74WJ7S7J.js} +1 -1
- package/lib/chunks/{QL4V2A4A.js → 7R5PBTLG.js} +1 -1
- package/lib/chunks/BT3ELZVX.js +42 -0
- package/lib/chunks/C5TR4MMN.js +19 -0
- package/lib/chunks/CCR5RYCX.js +20 -0
- package/lib/chunks/DCN3GSUA.js +7 -0
- package/lib/chunks/{TEQA5OM7.js → E5I67ZCZ.js} +1 -1
- package/lib/chunks/FUMCRNTK.js +78 -0
- package/lib/chunks/GNMJA2V2.js +16 -0
- package/lib/chunks/GRJG3TOI.js +14 -0
- package/lib/chunks/HA22GUKQ.js +7 -0
- package/lib/chunks/HJ36YGCI.js +184 -0
- package/lib/chunks/HJYFWIVE.js +9 -0
- package/lib/chunks/HL5FOKC4.js +16 -0
- package/lib/chunks/{SL6AH3N2.js → JBNPGEIJ.js} +1 -1
- package/lib/chunks/KHEMMNFU.js +26 -0
- package/lib/chunks/{SN2EC2ZR.js → KK2STV73.js} +1 -1
- package/lib/chunks/KK77ANZH.js +7 -0
- package/lib/chunks/L3TZNNJJ.js +13 -0
- package/lib/chunks/M6KLAAY4.js +7 -0
- package/lib/chunks/MHITBEGC.js +90 -0
- package/lib/chunks/NB54XRRU.js +10 -0
- package/lib/chunks/NSIQWNYL.js +7 -0
- package/lib/chunks/{YQW463Z7.js → NTPLYWAB.js} +1 -1
- package/lib/chunks/{5PXRDPHV.js → NUNOXB7Z.js} +1 -1
- package/lib/chunks/NWMTC4AN.js +7 -0
- package/lib/chunks/NYLAOZPO.js +22 -0
- package/lib/chunks/O4R6BSAS.js +20 -0
- package/lib/chunks/OKITK6EF.js +30 -0
- package/lib/chunks/OUCZOBEX.js +22 -0
- package/lib/chunks/PFYPTG4G.js +7 -0
- package/lib/chunks/QZH7EL26.js +7 -0
- package/lib/chunks/R4XFBOJU.js +9 -0
- package/lib/chunks/REFX2EKS.js +13 -0
- package/lib/chunks/{S4MX7JPH.js → RXOEH2LN.js} +1 -1
- package/lib/chunks/SGBB4RNM.js +11 -0
- package/lib/chunks/SQVG3CEM.js +8 -0
- package/lib/chunks/{RIFZSMUA.js → T5EPIBMA.js} +1 -1
- package/lib/chunks/TLQZAJQU.js +18 -0
- package/lib/chunks/TSB6PODJ.js +13 -0
- package/lib/chunks/TSRK76GA.js +19 -0
- package/lib/chunks/{34J2ZJDK.js → U2H2LXZE.js} +1 -1
- package/lib/chunks/UKSQ7B5H.js +2268 -0
- package/lib/chunks/UMQN5HTL.js +42 -0
- package/lib/chunks/V2LJ4UGM.js +7 -0
- package/lib/chunks/VBPP2WUF.js +7 -0
- package/lib/chunks/WPGKH5NI.js +177 -0
- package/lib/chunks/WXVC3KOI.js +67 -0
- package/lib/chunks/{KEUH3PST.js → YI34NB7D.js} +1 -1
- package/lib/chunks/YOJGIGE3.js +7 -0
- package/lib/chunks/{TO2KJ36N.js → YP5GHFYE.js} +1 -1
- package/lib/chunks/YXXYE4G2.js +7 -0
- package/lib/chunks/ZBL4IVEW.js +11 -0
- package/lib/chunks/ZMCRMR2V.js +5400 -0
- package/lib/chunks/ZOUQBK53.js +14 -0
- package/lib/chunks/ZXKOHMC6.js +177 -0
- package/lib/eject-assets/AGENTS.md +137 -0
- package/lib/eject-assets/generators/cli/docs.ts +224 -0
- package/lib/eject-assets/generators/cli/engine-source.ts +21 -0
- package/lib/eject-assets/generators/cli/index.ts +90 -0
- package/lib/eject-assets/generators/cli/render.ts +348 -0
- package/lib/eject-assets/generators/go/client.ts +57 -0
- package/lib/eject-assets/generators/go/descriptor.ts +41 -0
- package/lib/eject-assets/generators/go/index.ts +336 -0
- package/lib/eject-assets/generators/go/models.ts +179 -0
- package/lib/eject-assets/generators/go/naming.ts +49 -0
- package/lib/eject-assets/generators/go/operations.ts +296 -0
- package/lib/eject-assets/generators/go/pagination.ts +194 -0
- package/lib/eject-assets/generators/go/types.ts +60 -0
- package/lib/eject-assets/generators/mock/faker.ts +214 -0
- package/lib/eject-assets/generators/mock/index.ts +35 -0
- package/lib/eject-assets/generators/mock/render.ts +282 -0
- package/lib/eject-assets/generators/mock/sample.ts +316 -0
- package/lib/eject-assets/generators/mock/values.ts +63 -0
- package/lib/eject-assets/generators/php/client.ts +63 -0
- package/lib/eject-assets/generators/php/descriptor.ts +58 -0
- package/lib/eject-assets/generators/php/index.ts +237 -0
- package/lib/eject-assets/generators/php/models.ts +275 -0
- package/lib/eject-assets/generators/php/naming.ts +51 -0
- package/lib/eject-assets/generators/php/operations.ts +232 -0
- package/lib/eject-assets/generators/php/pagination.ts +133 -0
- package/lib/eject-assets/generators/php/types.ts +148 -0
- package/lib/eject-assets/generators/python/client.ts +123 -0
- package/lib/eject-assets/generators/python/descriptor.ts +52 -0
- package/lib/eject-assets/generators/python/index.ts +251 -0
- package/lib/eject-assets/generators/python/models.ts +242 -0
- package/lib/eject-assets/generators/python/naming.ts +46 -0
- package/lib/eject-assets/generators/python/operations.ts +147 -0
- package/lib/eject-assets/generators/python/pagination.ts +128 -0
- package/lib/eject-assets/generators/python/types.ts +54 -0
- package/lib/eject-assets/generators/swr/index.ts +37 -0
- package/lib/eject-assets/generators/swr/render.ts +78 -0
- package/lib/eject-assets/generators/tanstack-query/index.ts +48 -0
- package/lib/eject-assets/generators/tanstack-query/render.ts +346 -0
- package/lib/eject-assets/generators/transformers/index.ts +46 -0
- package/lib/eject-assets/generators/transformers/render.ts +506 -0
- package/lib/eject-assets/generators/typescript/banner.ts +35 -0
- package/lib/eject-assets/generators/typescript/client.ts +254 -0
- package/lib/eject-assets/generators/typescript/descriptor.ts +137 -0
- package/lib/eject-assets/generators/typescript/index.ts +101 -0
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +135 -0
- package/lib/eject-assets/generators/typescript/operation-signature.ts +62 -0
- package/lib/eject-assets/generators/typescript/operation-types.ts +17 -0
- package/lib/eject-assets/generators/typescript/operations.ts +524 -0
- package/lib/eject-assets/generators/typescript/response-headers.ts +74 -0
- package/lib/eject-assets/generators/typescript/type-guards.ts +159 -0
- package/lib/eject-assets/generators/typescript/types.ts +172 -0
- package/lib/eject-assets/generators/zod/index.ts +32 -0
- package/lib/eject-assets/generators/zod/schemas.ts +456 -0
- package/lib/eject-assets/skills/cli-generator/SKILL.md +121 -0
- package/lib/eject-assets/skills/client-generators/SKILL.md +142 -0
- package/lib/eject-assets/skills/go-generator/SKILL.md +96 -0
- package/lib/eject-assets/skills/mock-generator/SKILL.md +50 -0
- package/lib/eject-assets/skills/php-generator/SKILL.md +112 -0
- package/lib/eject-assets/skills/python-generator/SKILL.md +110 -0
- package/lib/eject-assets/skills/swr-generator/SKILL.md +50 -0
- package/lib/eject-assets/skills/tanstack-query-generator/SKILL.md +55 -0
- package/lib/eject-assets/skills/transformers-generator/SKILL.md +47 -0
- package/lib/eject-assets/skills/typescript-generator/SKILL.md +95 -0
- package/lib/eject-assets/skills/zod-generator/SKILL.md +54 -0
- package/lib/index.js +271 -193
- package/package.json +1 -1
- package/lib/chunks/B6HS7CVY.js +0 -184
- package/lib/chunks/PIJLRHNN.js +0 -8
- package/lib/chunks/Y5HLCNL5.js +0 -2542
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{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"./4I2OVMBJ.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};
|
|
@@ -0,0 +1,30 @@
|
|
|
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 T}from"./ZMCRMR2V.js";import{a as x,e as M,f as j,i as H,j as O,k as f,l as v}from"./NB54XRRU.js";import{n as N}from"./HJYFWIVE.js";function w(e){return e.contentType==="multipart/form-data"&&e.schema.kind==="object"}var V=" ";function K(e,s=[]){let t=N(e,{schemas:s});return t==="integer"?"number":t}function re(e,s=[]){let t=C(e,s);if(t.length!==0)return t.map(n=>({name:n.name,key:n.key,type:n.type}))}function q(e,s=[],t=""){let n=t+V,r=C(e,s).map(o=>`${n}${o.key}${o.required===!0?"":"?"}: ${o.type};`);return r.length===0?"{}":`{
|
|
8
|
+
${r.join(`
|
|
9
|
+
`)}
|
|
10
|
+
${t}}`}function C(e,s){let t=new Set;return(e??[]).map(n=>({...n,key:j(v(n.name),t),type:K(n.schema,s)}))}var E=" ";function h(e,s,t){let n=O(e,s);return n===void 0?[]:[`${t}/**`,...H(n).split(`
|
|
11
|
+
`).map(r=>`${t} * ${r}`.replace(/ +$/,"")),`${t} */`]}function D(e){return typeof e=="string"?JSON.stringify(e):String(e)}function W(e,s,t){switch(e){case"string":return s?.format==="binary"?"Blob":t==="Date"&&(s?.format==="date-time"||s?.format==="date")?"Date":"string";case"number":case"integer":return"number";case"boolean":return"boolean"}}function k(e){return e.kind==="union"||e.kind==="intersection"||e.kind==="enum"&&e.values.length>1}function u(e,s="string",t=""){switch(e.kind){case"scalar":return W(e.scalar,e.metadata,s);case"ref":return e.name;case"literal":return D(e.value);case"enum":return e.values.map(D).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let n=u(e.items,s,t);return k(e.items)?`(${n})[]`:`${n}[]`}case"record":return`Record<string, ${u(e.value,s,t)}>`;case"object":{if(e.properties.length===0)return"{}";let n=t+E;return`{
|
|
12
|
+
${e.properties.flatMap(o=>F(o,s,n)).join(`
|
|
13
|
+
`)}
|
|
14
|
+
${t}}`}case"union":return e.members.map(n=>{let r=u(n,s,t);return k(n)?`(${r})`:r}).join(" | ");case"intersection":return e.members.map(n=>{let r=u(n,s,t);return k(n)?`(${r})`:r}).join(" & ");case"omit":return`Omit<${e.base}, ${e.keys.map(n=>JSON.stringify(n)).join(" | ")}>`}}function F(e,s,t){let n=M(e.name),r=e.readOnly?"readonly ":"",o=e.required?"":"?",a=u(e.schema,s,t);return[...h(e.description,e.schema.metadata,t),`${t}${r}${n}${o}: ${a};`]}function U(e){let s=e.schema;return s.kind!=="enum"||s.scalar!=="string"?[]:s.values.every(t=>typeof t=="string"&&x(t))?[`export const ${e.name} = {`,...s.values.map((t,n)=>`${E}${t}: ${JSON.stringify(t)}${n===s.values.length-1?"":","}`),"} as const;"]:[]}function ae(e,s="string"){let t=[];for(let n of e){let r=[...h(n.schema.description??n.description,n.schema.metadata,""),`export type ${n.name} = ${u(n.schema,s)};`];t.push(r.join(`
|
|
15
|
+
`));let o=U(n);o.length>0&&t.push(o.join(`
|
|
16
|
+
`))}return t.join(`
|
|
17
|
+
|
|
18
|
+
`)}function g(e){let s=new Map(e.pathParams.map(n=>[n.name,n])),t=[];for(let n of e.path.matchAll(/\{([^{}]+)\}/g)){let r=s.get(n[1]);r!==void 0&&t.push(r)}return t}function A(e){let s=g(e),t=e.queryParams.length>0,n=!!e.requestBody,r=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:t,hasBody:n,hasHeaders:r,hasCookies:o,hasInputs:s.length>0||t||n||r||o,varsRequired:s.length>0||e.queryParams.some(a=>a.required)||(e.requestBody?.required??!1)||e.headerParams.some(a=>a.required)||e.cookieParams.some(a=>a.required),variablesTypeName:`${f(e.name)}Variables`}}var y=" ";function S(e,s,t=""){if(w(e))return u(e.schema,s,t);switch(e.contentType){case"multipart/form-data":return"FormData";case"application/x-www-form-urlencoded":return"URLSearchParams";case"application/octet-stream":return"Blob | ArrayBuffer";default:return u(e.schema,s,t)}}function p(e,s,t=""){let n=t+y,r=e.flatMap(o=>[...h(o.description,o.schema.metadata,n),`${n}${M(o.name)}${o.required?"":"?"}: ${u(o.schema,s,n)};`]);return r.length===0?"{}":`{
|
|
19
|
+
${r.join(`
|
|
20
|
+
`)}
|
|
21
|
+
${t}}`}function I(e,s,t=""){if(e.length===0)return{type:"void",kind:"void"};let n=e.find(i=>i.contentType.toLowerCase().includes("json"));if(n)return{type:u(n.schema,s,t),kind:"json"};let r=[],o=new Set,a=!1,d=!1;for(let i of e){let c;i.contentType.startsWith("image/")||i.contentType==="application/octet-stream"?(c="Blob",a=!0):i.contentType.startsWith("text/")?(c="string",d=!0):c=u(i.schema,s,t),!o.has(c)&&(o.add(c),r.push(c))}return{type:r.join(" | "),kind:a?"blob":d?"text":"json"}}function J(e,s,t=""){let n=new Set,r=[];for(let o of e){let a=u(o.schema,s,t);n.has(a)||(n.add(a),r.push(a))}return r}function z(e,s,t=""){let n=e.sse?.eventSchema;return n?u(n,s,t):"string"}function $(e,s,t,n,r,o){let a=r.has(s)?t():s;return`${o}${e}${n?"":"?"}: ${a};`}function G(e,s){let t=new Set,n=e;for(;n.kind==="ref";){let{name:r}=n;if(t.has(r))return;t.add(r);let o=s?.find(a=>a.name===r);if(o===void 0)return;n=o.schema}return n}function L(e,s){let t=G(e,s);if(t?.kind==="object")return t.properties.map(r=>r.name);if(t?.kind!=="intersection")return;let n=new Set;for(let r of t.members){let o=L(r,s);if(o===void 0)return;for(let a of o)n.add(a)}return[...n]}function X(e,s){let t=[...g(e),...e.queryParams,...e.headerParams,...e.cookieParams],n=(e.requestBody?.required??!1)&&e.requestBody!==void 0?L(e.requestBody.schema,s):void 0,r=n!==void 0,o=new Map;for(let d of t)o.set(d.name,(o.get(d.name)??0)+1);e.requestBody&&!r&&o.set("body",(o.get("body")??0)+1);for(let d of n??[])o.set(d,(o.get(d)??0)+1);let a=[...o].filter(([,d])=>d>1).map(([d])=>d);return a.length>0?{collisions:a}:{mergeBody:r}}function Y(e,s,t){return e.flatMap(n=>[...h(n.description,n.schema.metadata,t),`${t}${M(n.name)}${n.required?"":"?"}: ${u(n.schema,s.dateType,t)};`])}function Q(e,s,t,n=""){let{dateType:r,schemaNames:o}=t,a=n+y,d=t.argsStyle==="flat"?X(e,t.schemas):void 0;if(d!==void 0&&"mergeBody"in d)return Z(e,s,t,d.mergeBody,n);let i=[],c=g(e);return c.length>0&&i.push($("path",`${s}Path`,()=>p(c,r,a),!0,o,a)),e.queryParams.length>0&&i.push($("query",`${s}Query`,()=>p(e.queryParams,r,a),e.queryParams.some(m=>m.required),o,a)),e.requestBody&&i.push($("body",`${s}Body`,()=>S(e.requestBody,r,a),e.requestBody.required,o,a)),e.headerParams.length>0&&i.push($("headers",`${s}Headers`,()=>p(e.headerParams,r,a),e.headerParams.some(m=>m.required),o,a)),e.cookieParams.length>0&&i.push($("cookies",`${s}Cookies`,()=>p(e.cookieParams,r,a),e.cookieParams.some(m=>m.required),o,a)),i.length===0?"{}":`{
|
|
22
|
+
${i.join(`
|
|
23
|
+
`)}
|
|
24
|
+
${n}}`}function Z(e,s,t,n,r){let o=r+y,a=Y([...g(e),...e.queryParams,...e.headerParams,...e.cookieParams],t,o);e.requestBody&&!n&&a.push($("body",`${s}Body`,()=>S(e.requestBody,t.dateType,o),e.requestBody.required,t.schemaNames,o));let d=t.schemaNames.has(`${s}Body`)?S(e.requestBody,t.dateType,r):`${s}Body`,i=a.length===0?"{}":`{
|
|
25
|
+
${a.join(`
|
|
26
|
+
`)}
|
|
27
|
+
${r}}`;return n?a.length===0?d:`${i} & ${d}`:i}function B(e,s,t){let n=`${f(e.name)}Result`;return s.schemaNames.has(n)?I(e.successResponses,s.dateType,t).type:n}function _(e,s,t){let n=J(e.errorResponses,s.dateType,t);if(n.length===0)return"unknown";let r=`${f(e.name)}Error`;return s.schemaNames.has(r)?n.join(" | "):r}function he(e,s,t){let n=T(e.services);if(n.length===0)return"";let r=n.flatMap(o=>{let a=s.get(o.name),d=f(o.name),i=y+y,c=Q(o,d,t,i),m=o.sse!==void 0,P=m?z(o,t.dateType,i):t.errorMode==="result"?`Result<${B(o,t,i)}, ${_(o,t,i)}>`:B(o,t,i),l=[`${i}args: ${c};`,`${i}result: ${P};`];t.errorMode==="result"&&!m&&l.push(`${i}mode: "result";`);let b=o.successResponseHeaders;b&&b.length>0&&l.push(`${i}headers: ${q(b,t.schemas,i)};`);let R=t.pagination?.get(o.name);return R&&(l.push(`${i}item: ${u(R.itemSchema,t.dateType,i)};`),t.errorMode==="result"&&l.push(`${i}page: ${B(o,t,i)};`)),m&&l.push(`${i}kind: "sse";`),[`${y}${a}: {`,...l,`${y}};`]});return[...h("Per-operation `args`/`result` shapes (plus `kind: 'sse'` for event streams) \u2014 the\ntype-level companion of `OPERATIONS` that gives `createClient<Ops>` its typed methods.",void 0,""),"export type Ops = {",...r,"};"].join(`
|
|
28
|
+
`)}function ge(e,s){let{dateType:t,schemaNames:n}=s,r=f(e.name),o=e.sse!==void 0,{hasInputs:a}=A(e),d=[];if(!o){let m=`${r}Result`;if(n.has(m)||d.push(`export type ${m} = ${I(e.successResponses,t).type};`),s.errorMode==="result"){let P=J(e.errorResponses,t),l=`${r}Error`;P.length>0&&!n.has(l)&&d.push(`export type ${l} = ${P.join(" | ")};`)}}let i=g(e);i.length>0&&!n.has(`${r}Path`)&&d.push(`export type ${r}Path = ${p(i,t)};`),e.queryParams.length>0&&!n.has(`${r}Query`)&&d.push(`export type ${r}Query = ${p(e.queryParams,t)};`),e.requestBody&&!n.has(`${r}Body`)&&d.push(`export type ${r}Body = ${S(e.requestBody,t)};`),e.headerParams.length>0&&!n.has(`${r}Headers`)&&d.push(`export type ${r}Headers = ${p(e.headerParams,t)};`);let c=e.successResponseHeaders;return c&&c.length>0&&!n.has(`${r}ResponseHeaders`)&&d.push(`export type ${r}ResponseHeaders = ${q(c,s.schemas)};`),e.cookieParams.length>0&&!n.has(`${r}Cookies`)&&d.push(`export type ${r}Cookies = ${p(e.cookieParams,t)};`),a&&!n.has(`${r}Variables`)&&d.push(`export type ${r}Variables = ${Q(e,r,s)};`),d.join(`
|
|
29
|
+
|
|
30
|
+
`)}function $e(e,s){let t=new Set,n=r=>{switch(r.kind){case"ref":t.add(r.name);return;case"omit":t.add(r.base);return;case"array":n(r.items);return;case"record":n(r.value);return;case"object":for(let o of r.properties)n(o.schema);return;case"union":case"intersection":for(let o of r.members)n(o);return;default:return}};for(let r of T(e.services)){for(let a of[...r.pathParams,...r.queryParams,...r.headerParams,...r.cookieParams])n(a.schema);r.requestBody&&n(r.requestBody.schema);for(let a of r.successResponses)n(a.schema),a.itemSchema&&n(a.itemSchema);if(s.errorMode==="result")for(let a of r.errorResponses)n(a.schema);let o=s.pagination?.get(r.name);o&&n(o.itemSchema)}return[...t].filter(r=>s.schemaNames.has(r)).sort()}export{A as a,w as b,re as c,h as d,ae as e,I as f,X as g,he as h,ge as i,$e as j};
|
|
@@ -0,0 +1,22 @@
|
|
|
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}from"./ZMCRMR2V.js";import{c as w}from"./HJ36YGCI.js";import{a as H,e as q,g as P,h as g,k as E}from"./NB54XRRU.js";import{join as ae}from"node:path";var j=class{code;constructor(r){this.code=r}};function A(e,r,n={}){let t=new Map(r.map(s=>[s.name,s.schema])),o=k(e,t,new Set,n.dateType??"string");return o===b?null:o}var b=Symbol("cycle");function J(e,r){if(e.kind==="union"){for(let t of e.members){let o=J(t,r);if(o)return o}return}if(e.kind!=="scalar")return;let n=e.metadata?.format;if(n==="binary")return new j("new Blob([])");if(r==="Date"){if(n==="date-time")return new j('new Date("2024-01-01T00:00:00Z")');if(n==="date")return new j('new Date("2024-01-01")')}}function I(e,r){let n=new Map,t=[],o=!1;for(let s of e){if(s.kind==="unknown")continue;let i=G(s,r);if(i?.kind!=="object"){t.push(s);continue}o=!0;for(let a of i.properties){let u=O(a.schema,r,new Set),c=n.get(a.name);(c===void 0||u>=c.rank)&&n.set(a.name,{schema:a.schema,required:a.required||(c?.required??!1),rank:u})}}return o?{merged:{kind:"object",properties:[...n.entries()].map(([s,i])=>({name:s,schema:i.schema,required:i.required}))},rest:t}:{merged:void 0,rest:t}}function G(e,r){let n=new Set,t=e;for(;t?.kind==="ref";){if(n.has(t.name))return;n.add(t.name),t=r.get(t.name)}return t}function O(e,r,n){switch(e.kind){case"literal":return 40;case"enum":return e.values.length===1?40:30;case"union":return Math.max(0,...e.members.map(t=>O(t,r,n)))-1;case"ref":{if(n.has(e.name))return 20;let t=r.get(e.name);return t===void 0?20:O(t,r,new Set(n).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,r,n,t){let o=J(e,t);if(o)return o;let s=e.metadata,i=a=>a===null?e.kind==="null"||e.kind==="union"&&e.members.some(u=>u.kind==="null"):e.kind==="enum"?e.values.includes(a):e.kind==="literal"?a===e.value:!0;if(s?.example!==void 0&&i(s.example))return s.example;if(s?.default!==void 0&&i(s.default))return s.default;switch(e.kind){case"scalar":return K(e.scalar,s);case"array":{let a=k(e.items,r,n,t);return a===b?[]:[a]}case"object":return Object.fromEntries(e.properties.flatMap(a=>{let u=k(a.schema,r,n,t);return u===b?a.required?[[a.name,null]]:[]:[[a.name,u]]}));case"record":{let a=k(e.value,r,n,t);return a===b?{}:{key:a}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let a of e.members){let u=k(a,r,n,t);if(u!==b)return u}return e.members.length>0?b:null}case"intersection":{let{merged:a,rest:u}=I(e.members,r),c=u.map(m=>k(m,r,n,t)).filter(m=>m!==b);if(a){let m=k(a,r,n,t),M=w(m)?m:{};for(let V of c)w(V)&&Object.assign(M,V);return M}let h=c.filter(w);return h.length>0?h.reduce((m,M)=>Object.assign(m,M),{}):c.length>0?c[0]:{}}case"omit":{let a=r.get(e.base);if(!a)return null;let u=k(a,r,n,t);if(w(u)){let c={...u};for(let h of e.keys)delete c[h];return c}return u}case"ref":{if(n.has(e.name))return b;let a=r.get(e.name);if(!a)return null;n.add(e.name);let u=k(a,r,n,t);return n.delete(e.name),u}case"null":case"unknown":return null}}function K(e,r){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(r?.format){case"email":return"user@example.com";case"uuid":return"00000000-0000-4000-8000-000000000000";case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"uri":case"url":return"https://example.com";default:return"string"}}var f=e=>({kind:"expr",text:e}),d=e=>({kind:"object",entries:e});function l(e){return e.kind==="object"}function D(e,r){return l(e)?d([...e.entries,{spread:r}]):e}var L=" ";function x(e,r){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${x(e.value,r)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let n=r+L;return`[
|
|
8
|
+
${e.items.map((o,s)=>`${n}${x(o,n)}${s===e.items.length-1?"":","}`).join(`
|
|
9
|
+
`)}
|
|
10
|
+
${r}]`}case"object":{if(e.entries.length===0)return"{}";let n=r+L;return`{
|
|
11
|
+
${e.entries.map((o,s)=>{let i=s===e.entries.length-1?"":",";if("spread"in o)return`${n}...${o.spread}${i}`;let a=q(o.key)===o.key?o.key:P(o.key);return`${n}${a}: ${x(o.value,n)}${i}`}).join(`
|
|
12
|
+
`)}
|
|
13
|
+
${r}}`}}}function U(e,r,n={}){let t=new Map(r.map(s=>[s.name,s.schema])),o=$(e,t,new Set,n.dateType??"string");return o===p?f("null"):o}var p=Symbol("cycle");function $(e,r,n,t){switch(e.kind){case"scalar":return f(Q(e.scalar,e.metadata,t));case"array":{let o=$(e.items,r,n,t);return o===p?f("[]"):W(o)}case"object":return d(e.properties.flatMap(o=>{let s=$(o.schema,r,n,t);return s===p?o.required?[{key:o.name,value:f("null")}]:[]:[{key:o.name,value:s}]}));case"record":{let o=$(e.value,r,n,t);return o===p?f("{}"):d([{key:"key",value:o}])}case"enum":return f(`faker.helpers.arrayElement([${e.values.map(o=>g(o)).join(", ")}] as const)`);case"literal":return f(g(e.value));case"union":{for(let o of e.members){let s=$(o,r,n,t);if(s!==p)return s}return e.members.length>0?p:f("null")}case"intersection":{let{merged:o,rest:s}=I(e.members,r),i=s.map(u=>$(u,r,n,t)).filter(u=>u!==p);if(o){let u=$(o,r,n,t),c=u!==p&&l(u)?u.entries:[],h=i.filter(l).flatMap(m=>m.entries);return d([...c,...h])}let a=i.filter(l);return a.length>0?d(a.flatMap(u=>u.entries)):i[0]??d([])}case"omit":return X(e.base,e.keys,r,n,t);case"ref":{if(n.has(e.name))return p;let o=r.get(e.name);if(!o)return f("null");n.add(e.name);let s=$(o,r,n,t);return n.delete(e.name),s}case"null":case"unknown":return f("null")}}function Q(e,r,n){if(r?.format==="binary")return"new Blob([])";if(e==="boolean")return"faker.datatype.boolean()";if(e==="integer")return`faker.number.int(${F(r)})`;if(e==="number")return`faker.number.float(${F(r)})`;switch(r?.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 B(n,!1);case"date":return B(n,!0);default:return"faker.lorem.word()"}}function B(e,r){if(e==="Date")return"faker.date.recent()";let n="faker.date.recent().toISOString()";return r?`${n}.slice(0, 10)`:n}function F(e){let r=[...e?.minimum!==void 0?[`min: ${e.minimum}`]:[],...e?.maximum!==void 0?[`max: ${e.maximum}`]:[]];return r.length>0?`{ ${r.join(", ")} }`:""}function W(e){let r=l(e);return{kind:"wrap",before:`faker.helpers.multiple(() => ${r?"(":""}`,value:e,after:`${r?")":""}, { count: 1 })`}}function X(e,r,n,t,o){let s=n.get(e);if(!s)return f("null");let i=$(s,n,t,o);if(i===p||!l(i))return i;let a=new Set(r);return d(i.entries.filter(u=>"spread"in u||!a.has(u.key)))}var Y=" ";function S(e,r,n){return n.mockData==="faker"?U(e,r.schemas,{dateType:n.dateType}):R(A(e,r.schemas,{dateType:n.dateType}))}function Z(e,r){let n=C(e.services);if(n.length===0)return"";let t=[..._(e,r),...r.mockData==="faker"&&r.mockSeed!==void 0?[`faker.seed(${r.mockSeed});`]:[],...e.schemas.map(s=>v(s,e,r)),...n.flatMap(s=>[T(s,e,r),...s.errorResponses.length>0?[N(s,e,r)]:[]]),se(n)];return`import { http, HttpResponse } from 'msw';
|
|
14
|
+
${r.mockData==="faker"?`import { faker } from '@faker-js/faker';
|
|
15
|
+
`:""}
|
|
16
|
+
${t.join(`
|
|
17
|
+
|
|
18
|
+
`)}`}function _(e,r){return e.schemas.length===0?[]:[`import type { ${e.schemas.map(t=>t.name).sort().join(", ")} } from ${JSON.stringify(r.sdkModule)};`]}function v(e,r,n){let t=E(e.name),o=S(e.schema,r,n),s=e.name,i=l(o),a=x(i?D(o,"overrides"):o,Y),u=i?e.schema.kind==="union"?`${a} as ${s}`:a:`overrides ?? ${a}`,c=i?`Partial<${s}>`:s;return[`export function create${t}(overrides?: ${c}): ${s} {`,`${Y}return ${u};`,"}"].join(`
|
|
19
|
+
`)}function y(e){if(!H(e))throw new Error(`Unsafe identifier in mock emission: ${JSON.stringify(e)}`);return e}function T(e,r,n){let o=ne(e,r,n)??"",s=`http.${y(e.method)}(${JSON.stringify(z(e.path))}, () => ${te(e,r,n)})`;return`export const ${y(e.name)}Handler = (${o}) => ${s};`}function N(e,r,n){let t=e.errorResponses[0],s=`() => HttpResponse.json(body ?? ${x(S(t.schema,r,n),"")}, { status })`,i=`http.${y(e.method)}(${JSON.stringify(z(e.path))}, ${s})`;return`export const ${y(e.name)}ErrorHandler = (status: ${ee(e)}, body?: ${re(e)}) => ${i};`}function ee(e){let n=[...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")&&n.push("number"),n.join(" | ")}function re(e){let r=new Set,n=!1;for(let o of e.errorResponses)o.schema.kind==="ref"?r.add(o.schema.name):n=!0;let t=[...r];return(n||t.length===0)&&t.push("unknown"),t.join(" | ")}function ne(e,r,n){let t=e.successResponses[0];if(!(!t||t.schema.kind==="unknown")){if(t.schema.kind==="ref"){let o=t.schema.name;return`override?: ${l(S(t.schema,r,n))?`Partial<${o}>`:o}`}if(l(S(t.schema,r,n)))return"override?: Record<string, unknown>"}}function te(e,r,n){let t=e.successResponses[0],o=oe(t?.status);if(!t||t.schema.kind==="unknown")return`new HttpResponse(null, { status: ${o} })`;let s=t.schema.kind==="ref"?`create${E(t.schema.name)}(override)`:x(D(S(t.schema,r,n),"override"),"");return`HttpResponse.json(${o===200?s:`${s}, { status: ${o} }`})`}function oe(e){return typeof e=="number"?e:200}function se(e){return`export const handlers = [${e.map(n=>`${y(n.name)}Handler()`).join(", ")}];`}function z(e){return`*${e.replace(/\{([^{}]+)\}/g,":$1")}`}function R(e){return e instanceof j?f(e.code):Array.isArray(e)?{kind:"array",items:e.map(R)}:w(e)?d(Object.entries(e).map(([r,n])=>({key:r,value:R(n)}))):f(g(e))}var ye=({model:e,output:r,banner:n,emit:t})=>{let o=n.map(i=>`// ${i}`).join(`
|
|
20
|
+
`),s=Z(e,{sdkModule:`./${r.stem}.${t.importExt??"js"}`,dateType:t.dateType,mockData:t.mockData,mockSeed:t.mockSeed});return s===""?[]:[{path:ae(r.dir,`${r.stem}.mocks.ts`),content:`${o}
|
|
21
|
+
|
|
22
|
+
${s}`}]};export{ye as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
var r=class extends Error{constructor(s){super(s),this.name="NotSupportedError"}};export{r as a};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
+
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
+
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import{a,b,c,d,e}from"./O4R6BSAS.js";import"./NSIQWNYL.js";import"./UKSQ7B5H.js";import"./4I2OVMBJ.js";import"./ZMCRMR2V.js";import"./PFYPTG4G.js";import"./HJ36YGCI.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as phpDocs,c as phpGenerator,d as phpSample,a as phpType,b as renderPhpModels};
|
|
@@ -0,0 +1,9 @@
|
|
|
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 i}from"./OKITK6EF.js";import{O as p}from"./HJ36YGCI.js";function h(t,o){let n=t.services.flatMap(e=>e.operations),r=n.filter(e=>e.sse!==void 0);r.length>0&&p.warn(`generate-client: ${o} skipped ${r.length} server-sent-events operation(s) \u2014 iterate the sdk's exported async generators directly: ${r.map(e=>e.name).join(", ")}.
|
|
8
|
+
`);let s=new Set(t.schemas.map(e=>e.name)),a=n.filter(e=>e.sse===void 0&&l(e,s));return a.length>0&&p.warn(`generate-client: ${o} skipped ${a.length} operation(s) whose variables type name collides with a schema \u2014 rename the schema or the operation: ${a.map(e=>e.name).join(", ")}.
|
|
9
|
+
`),n.filter(e=>e.sse===void 0&&!l(e,s))}function l(t,o){let n=i(t);return n.hasInputs&&o.has(n.variablesTypeName)}function g(t){return t.method==="get"||t.method==="head"}function m(t){return i(t).hasInputs}function u(t){return i(t).variablesTypeName}function O(t,o,n){let r=[];return i(t).hasInputs?r.push(o):n&&r.push("{}"),n&&r.push("{ ...init, envelope: undefined }"),`${t.name}(${r.join(", ")})`}function x(t,o,n){let r=t.map(e=>e.name).sort(),s=t.filter(m).map(u).sort();return n&&s.push("RequestOptions"),`import { ${[...r,...s.map(e=>`type ${e}`)].join(", ")} } from ${JSON.stringify(o)};`}export{h as a,g as b,m as c,u as d,O as e,x as f};
|
|
@@ -0,0 +1,13 @@
|
|
|
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 E,c as b,d as m,l as y}from"./HJYFWIVE.js";var $=b.go,w=class extends E{constructor(){super(" ")}typeName(t){return x(t)}memberName(t){return x(t)}identifier(t){return m(t,{style:"camel",reserved:$})}identifiers(t,n){let r=new Set(n??[]);return t.map(e=>{let a=x(e),c=a;for(let o=2;r.has(c);o++)c=`${a}${o}`;return r.add(c),c})}packageName(t){let n=t.toLowerCase().replace(/[^a-z0-9]/g,"");return n===""||/^[0-9]/.test(n)?"client":n}string(t){let n='"';for(let r of t){let e=r.codePointAt(0);r==="\\"?n+="\\\\":r==='"'?n+='\\"':r===`
|
|
8
|
+
`?n+="\\n":r==="\r"?n+="\\r":r===" "?n+="\\t":e<32||e===127?n+=`\\x${e.toString(16).padStart(2,"0")}`:e>=55296&&e<=57343?n+="\\uFFFD":n+=r}return n+'"'}literal(t){return t==null?"nil":typeof t=="boolean"||typeof t=="number"?String(t):typeof t=="string"?this.string(t):Array.isArray(t)?`[]any{${t.map(r=>this.literal(r)).join(", ")}}`:`map[string]any{${Object.entries(t).map(([r,e])=>`${this.string(r)}: ${this.literal(e)}`).join(", ")}}`}comment(t){for(let n of y(t))this.line(n===""?"//":`// ${n}`);return this}doc(t,n){let r=y(n);if(r.length===0)return this;this.line(`// ${t} \u2014 ${r[0]}`);let e=!1;for(let a of r.slice(1)){if(a===""){e||this.line("//"),e=!0;continue}this.line(`// ${a}`),e=!1}return this}layout(t){return A(N(t))}toString(){return this.layout(super.toString())}};function x(g){let t=m(g,{style:"pascal",reserved:$});return t.startsWith("_")?`N${t.slice(1)}`:t}function A(g){return`${g.replace(/\n{3,}/g,`
|
|
9
|
+
|
|
10
|
+
`).trimEnd()}
|
|
11
|
+
`}function N(g){let t=g.split(`
|
|
12
|
+
`),n=[...t],r=/^(\t+)([A-Za-z_]\w*) (\S+)( `[^`]*`)?$/,e=/^(\t+)([A-Za-z_]\w*) (\S+) = (.+)$/,a=/^(\t+)("(?:[^"\\]|\\.)*":) (.+)$/,c=u=>{if(u.length<2)return;let d=[];for(let{parts:i}of u)i.forEach((s,l)=>{l<i.length-1&&(d[l]=Math.max(d[l]??0,s.length))});for(let{index:i,parts:s,indent:l}of u){let f=s.map((p,h)=>h<s.length-1?p.padEnd(d[h]??0):p);n[i]=l+f.join(" ").trimEnd()}},o=[],S;return t.forEach((u,d)=>{let i=a.exec(u),s=i===null?e.exec(u):null,l=i===null&&s===null?r.exec(u):null,f=l!==null&&!$.has(l[2])?l:null,p=i!==null?"entry":s!==null?"const":f!==null?"field":void 0;if((p===void 0||p!==S)&&(c(o),o=[],S=p),i!==null){o.push({index:d,indent:i[1],parts:[i[2],i[3]]});return}if(s!==null){o.push({index:d,indent:s[1],parts:[s[2],s[3],"=",s[4]]});return}if(f!==null){let h=[f[2],f[3]];f[4]!==void 0&&h.push(f[4].trimStart()),o.push({index:d,indent:f[1],parts:h})}}),c(o),n.join(`
|
|
13
|
+
`)}export{w as a,x as b};
|
|
@@ -4,7 +4,7 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c as Wz,e as jz}from"./
|
|
7
|
+
import{c as Wz,e as jz}from"./74WJ7S7J.js";import{b as g1}from"./2U54VUOE.js";import{a as nre,b as rre}from"./O6PRCLSV.js";import{a as tre}from"./RS5PUOTT.js";import{d as Uz,e as Hz}from"./6VSHPQXO.js";import"./32XCOMOR.js";import{O as zv,k as $ne,s as p1,v as zz,w as ere}from"./HJ36YGCI.js";import"./NEWT5A6S.js";import{a as Br,b as Bz,c as V,d as Zne,e as Bv,f as Jne}from"./RFWIIJFG.js";var Yz=V((Vz,Gz)=>{(function(){var e=function(t){var n=new e.Builder;return n.pipeline.add(e.trimmer,e.stopWordFilter,e.stemmer),n.searchPipeline.add(e.stemmer),t.call(n,n),n.build()};e.version="2.3.9";e.utils={},e.utils.warn=(function(t){return function(n){t.console&&console.warn&&console.warn(n)}})(this),e.utils.asString=function(t){return t==null?"":t.toString()},e.utils.clone=function(t){if(t==null)return t;for(var n=Object.create(null),r=Object.keys(t),i=0;i<r.length;i++){var o=r[i],s=t[o];if(Array.isArray(s)){n[o]=s.slice();continue}if(typeof s=="string"||typeof s=="number"||typeof s=="boolean"){n[o]=s;continue}throw new TypeError("clone is not deep and does not support nested objects")}return n},e.FieldRef=function(t,n,r){this.docRef=t,this.fieldName=n,this._stringValue=r},e.FieldRef.joiner="/",e.FieldRef.fromString=function(t){var n=t.indexOf(e.FieldRef.joiner);if(n===-1)throw"malformed field ref string";var r=t.slice(0,n),i=t.slice(n+1);return new e.FieldRef(i,r,t)},e.FieldRef.prototype.toString=function(){return this._stringValue==null&&(this._stringValue=this.fieldName+e.FieldRef.joiner+this.docRef),this._stringValue};e.Set=function(t){if(this.elements=Object.create(null),t){this.length=t.length;for(var n=0;n<this.length;n++)this.elements[t[n]]=!0}else this.length=0},e.Set.complete={intersect:function(t){return t},union:function(){return this},contains:function(){return!0}},e.Set.empty={intersect:function(){return this},union:function(t){return t},contains:function(){return!1}},e.Set.prototype.contains=function(t){return!!this.elements[t]},e.Set.prototype.intersect=function(t){var n,r,i,o=[];if(t===e.Set.complete)return this;if(t===e.Set.empty)return t;this.length<t.length?(n=this,r=t):(n=t,r=this),i=Object.keys(n.elements);for(var s=0;s<i.length;s++){var a=i[s];a in r.elements&&o.push(a)}return new e.Set(o)},e.Set.prototype.union=function(t){return t===e.Set.complete?e.Set.complete:t===e.Set.empty?this:new e.Set(Object.keys(this.elements).concat(Object.keys(t.elements)))},e.idf=function(t,n){var r=0;for(var i in t)i!="_index"&&(r+=Object.keys(t[i]).length);var o=(n-r+.5)/(r+.5);return Math.log(1+Math.abs(o))},e.Token=function(t,n){this.str=t||"",this.metadata=n||{}},e.Token.prototype.toString=function(){return this.str},e.Token.prototype.update=function(t){return this.str=t(this.str,this.metadata),this},e.Token.prototype.clone=function(t){return t=t||function(n){return n},new e.Token(t(this.str,this.metadata),this.metadata)};e.tokenizer=function(t,n){if(t==null||t==null)return[];if(Array.isArray(t))return t.map(function(d){return new e.Token(e.utils.asString(d).toLowerCase(),e.utils.clone(n))});for(var r=t.toString().toLowerCase(),i=r.length,o=[],s=0,a=0;s<=i;s++){var l=r.charAt(s),c=s-a;if(l.match(e.tokenizer.separator)||s==i){if(c>0){var y=e.utils.clone(n)||{};y.position=[a,c],y.index=o.length,o.push(new e.Token(r.slice(a,s),y))}a=s+1}}return o},e.tokenizer.separator=/[\s\-]+/;e.Pipeline=function(){this._stack=[]},e.Pipeline.registeredFunctions=Object.create(null),e.Pipeline.registerFunction=function(t,n){n in this.registeredFunctions&&e.utils.warn("Overwriting existing registered function: "+n),t.label=n,e.Pipeline.registeredFunctions[t.label]=t},e.Pipeline.warnIfFunctionNotRegistered=function(t){var n=t.label&&t.label in this.registeredFunctions;n||e.utils.warn(`Function is not registered with pipeline. This may cause problems when serialising the index.
|
|
8
8
|
`,t)},e.Pipeline.load=function(t){var n=new e.Pipeline;return t.forEach(function(r){var i=e.Pipeline.registeredFunctions[r];if(i)n.add(i);else throw new Error("Cannot load unregistered function: "+r)}),n},e.Pipeline.prototype.add=function(){var t=Array.prototype.slice.call(arguments);t.forEach(function(n){e.Pipeline.warnIfFunctionNotRegistered(n),this._stack.push(n)},this)},e.Pipeline.prototype.after=function(t,n){e.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(t);if(r==-1)throw new Error("Cannot find existingFn");r=r+1,this._stack.splice(r,0,n)},e.Pipeline.prototype.before=function(t,n){e.Pipeline.warnIfFunctionNotRegistered(n);var r=this._stack.indexOf(t);if(r==-1)throw new Error("Cannot find existingFn");this._stack.splice(r,0,n)},e.Pipeline.prototype.remove=function(t){var n=this._stack.indexOf(t);n!=-1&&this._stack.splice(n,1)},e.Pipeline.prototype.run=function(t){for(var n=this._stack.length,r=0;r<n;r++){for(var i=this._stack[r],o=[],s=0;s<t.length;s++){var a=i(t[s],s,t);if(!(a==null||a===""))if(Array.isArray(a))for(var l=0;l<a.length;l++)o.push(a[l]);else o.push(a)}t=o}return t},e.Pipeline.prototype.runString=function(t,n){var r=new e.Token(t,n);return this.run([r]).map(function(i){return i.toString()})},e.Pipeline.prototype.reset=function(){this._stack=[]},e.Pipeline.prototype.toJSON=function(){return this._stack.map(function(t){return e.Pipeline.warnIfFunctionNotRegistered(t),t.label})};e.Vector=function(t){this._magnitude=0,this.elements=t||[]},e.Vector.prototype.positionForIndex=function(t){if(this.elements.length==0)return 0;for(var n=0,r=this.elements.length/2,i=r-n,o=Math.floor(i/2),s=this.elements[o*2];i>1&&(s<t&&(n=o),s>t&&(r=o),s!=t);)i=r-n,o=n+Math.floor(i/2),s=this.elements[o*2];if(s==t||s>t)return o*2;if(s<t)return(o+1)*2},e.Vector.prototype.insert=function(t,n){this.upsert(t,n,function(){throw"duplicate index"})},e.Vector.prototype.upsert=function(t,n,r){this._magnitude=0;var i=this.positionForIndex(t);this.elements[i]==t?this.elements[i+1]=r(this.elements[i+1],n):this.elements.splice(i,0,t,n)},e.Vector.prototype.magnitude=function(){if(this._magnitude)return this._magnitude;for(var t=0,n=this.elements.length,r=1;r<n;r+=2){var i=this.elements[r];t+=i*i}return this._magnitude=Math.sqrt(t)},e.Vector.prototype.dot=function(t){for(var n=0,r=this.elements,i=t.elements,o=r.length,s=i.length,a=0,l=0,c=0,y=0;c<o&&y<s;)a=r[c],l=i[y],a<l?c+=2:a>l?y+=2:a==l&&(n+=r[c+1]*i[y+1],c+=2,y+=2);return n},e.Vector.prototype.similarity=function(t){return this.dot(t)/this.magnitude()||0},e.Vector.prototype.toArray=function(){for(var t=new Array(this.elements.length/2),n=1,r=0;n<this.elements.length;n+=2,r++)t[r]=this.elements[n];return t},e.Vector.prototype.toJSON=function(){return this.elements};e.stemmer=(function(){var t={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},n={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},r="[^aeiou]",i="[aeiouy]",o=r+"[^aeiouy]*",s=i+"[aeiou]*",a="^("+o+")?"+s+o,l="^("+o+")?"+s+o+"("+s+")?$",c="^("+o+")?"+s+o+s+o,y="^("+o+")?"+i,d=new RegExp(a),v=new RegExp(c),x=new RegExp(l),T=new RegExp(y),O=/^(.+?)(ss|i)es$/,k=/^(.+?)([^s])s$/,R=/^(.+?)eed$/,N=/^(.+?)(ed|ing)$/,H=/.$/,z=/(at|bl|iz)$/,ee=new RegExp("([^aeiouylsz])\\1$"),j=new RegExp("^"+o+i+"[^aeiouwxy]$"),re=/^(.+?[^aeiou])y$/,U=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,ie=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,ne=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,ue=/^(.+?)(s|t)(ion)$/,he=/^(.+?)e$/,Y=/ll$/,le=new RegExp("^"+o+i+"[^aeiouwxy]$"),de=function(ce){var Te,pe,ke,oe,we,De,at;if(ce.length<3)return ce;if(ke=ce.substr(0,1),ke=="y"&&(ce=ke.toUpperCase()+ce.substr(1)),oe=O,we=k,oe.test(ce)?ce=ce.replace(oe,"$1$2"):we.test(ce)&&(ce=ce.replace(we,"$1$2")),oe=R,we=N,oe.test(ce)){var Ge=oe.exec(ce);oe=d,oe.test(Ge[1])&&(oe=H,ce=ce.replace(oe,""))}else if(we.test(ce)){var Ge=we.exec(ce);Te=Ge[1],we=T,we.test(Te)&&(ce=Te,we=z,De=ee,at=j,we.test(ce)?ce=ce+"e":De.test(ce)?(oe=H,ce=ce.replace(oe,"")):at.test(ce)&&(ce=ce+"e"))}if(oe=re,oe.test(ce)){var Ge=oe.exec(ce);Te=Ge[1],ce=Te+"i"}if(oe=U,oe.test(ce)){var Ge=oe.exec(ce);Te=Ge[1],pe=Ge[2],oe=d,oe.test(Te)&&(ce=Te+t[pe])}if(oe=ie,oe.test(ce)){var Ge=oe.exec(ce);Te=Ge[1],pe=Ge[2],oe=d,oe.test(Te)&&(ce=Te+n[pe])}if(oe=ne,we=ue,oe.test(ce)){var Ge=oe.exec(ce);Te=Ge[1],oe=v,oe.test(Te)&&(ce=Te)}else if(we.test(ce)){var Ge=we.exec(ce);Te=Ge[1]+Ge[2],we=v,we.test(Te)&&(ce=Te)}if(oe=he,oe.test(ce)){var Ge=oe.exec(ce);Te=Ge[1],oe=v,we=x,De=le,(oe.test(Te)||we.test(Te)&&!De.test(Te))&&(ce=Te)}return oe=Y,we=v,oe.test(ce)&&we.test(ce)&&(oe=H,ce=ce.replace(oe,"")),ke=="y"&&(ce=ke.toLowerCase()+ce.substr(1)),ce};return function(ve){return ve.update(de)}})(),e.Pipeline.registerFunction(e.stemmer,"stemmer");e.generateStopWordFilter=function(t){var n=t.reduce(function(r,i){return r[i]=i,r},{});return function(r){if(r&&n[r.toString()]!==r.toString())return r}},e.stopWordFilter=e.generateStopWordFilter(["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","dear","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"]),e.Pipeline.registerFunction(e.stopWordFilter,"stopWordFilter");e.trimmer=function(t){return t.update(function(n){return n.replace(/^\W+/,"").replace(/\W+$/,"")})},e.Pipeline.registerFunction(e.trimmer,"trimmer");e.TokenSet=function(){this.final=!1,this.edges={},this.id=e.TokenSet._nextId,e.TokenSet._nextId+=1},e.TokenSet._nextId=1,e.TokenSet.fromArray=function(t){for(var n=new e.TokenSet.Builder,r=0,i=t.length;r<i;r++)n.insert(t[r]);return n.finish(),n.root},e.TokenSet.fromClause=function(t){return"editDistance"in t?e.TokenSet.fromFuzzyString(t.term,t.editDistance):e.TokenSet.fromString(t.term)},e.TokenSet.fromFuzzyString=function(t,n){for(var r=new e.TokenSet,i=[{node:r,editsRemaining:n,str:t}];i.length;){var o=i.pop();if(o.str.length>0){var s=o.str.charAt(0),a;s in o.node.edges?a=o.node.edges[s]:(a=new e.TokenSet,o.node.edges[s]=a),o.str.length==1&&(a.final=!0),i.push({node:a,editsRemaining:o.editsRemaining,str:o.str.slice(1)})}if(o.editsRemaining!=0){if("*"in o.node.edges)var l=o.node.edges["*"];else{var l=new e.TokenSet;o.node.edges["*"]=l}if(o.str.length==0&&(l.final=!0),i.push({node:l,editsRemaining:o.editsRemaining-1,str:o.str}),o.str.length>1&&i.push({node:o.node,editsRemaining:o.editsRemaining-1,str:o.str.slice(1)}),o.str.length==1&&(o.node.final=!0),o.str.length>=1){if("*"in o.node.edges)var c=o.node.edges["*"];else{var c=new e.TokenSet;o.node.edges["*"]=c}o.str.length==1&&(c.final=!0),i.push({node:c,editsRemaining:o.editsRemaining-1,str:o.str.slice(1)})}if(o.str.length>1){var y=o.str.charAt(0),d=o.str.charAt(1),v;d in o.node.edges?v=o.node.edges[d]:(v=new e.TokenSet,o.node.edges[d]=v),o.str.length==1&&(v.final=!0),i.push({node:v,editsRemaining:o.editsRemaining-1,str:y+o.str.slice(2)})}}}return r},e.TokenSet.fromString=function(t){for(var n=new e.TokenSet,r=n,i=0,o=t.length;i<o;i++){var s=t[i],a=i==o-1;if(s=="*")n.edges[s]=n,n.final=a;else{var l=new e.TokenSet;l.final=a,n.edges[s]=l,n=l}}return r},e.TokenSet.prototype.toArray=function(){for(var t=[],n=[{prefix:"",node:this}];n.length;){var r=n.pop(),i=Object.keys(r.node.edges),o=i.length;r.node.final&&(r.prefix.charAt(0),t.push(r.prefix));for(var s=0;s<o;s++){var a=i[s];n.push({prefix:r.prefix.concat(a),node:r.node.edges[a]})}}return t},e.TokenSet.prototype.toString=function(){if(this._str)return this._str;for(var t=this.final?"1":"0",n=Object.keys(this.edges).sort(),r=n.length,i=0;i<r;i++){var o=n[i],s=this.edges[o];t=t+o+s.id}return t},e.TokenSet.prototype.intersect=function(t){for(var n=new e.TokenSet,r=void 0,i=[{qNode:t,output:n,node:this}];i.length;){r=i.pop();for(var o=Object.keys(r.qNode.edges),s=o.length,a=Object.keys(r.node.edges),l=a.length,c=0;c<s;c++)for(var y=o[c],d=0;d<l;d++){var v=a[d];if(v==y||y=="*"){var x=r.node.edges[v],T=r.qNode.edges[y],O=x.final&&T.final,k=void 0;v in r.output.edges?(k=r.output.edges[v],k.final=k.final||O):(k=new e.TokenSet,k.final=O,r.output.edges[v]=k),i.push({qNode:T,output:k,node:x})}}}return n},e.TokenSet.Builder=function(){this.previousWord="",this.root=new e.TokenSet,this.uncheckedNodes=[],this.minimizedNodes={}},e.TokenSet.Builder.prototype.insert=function(t){var n,r=0;if(t<this.previousWord)throw new Error("Out of order word insertion");for(var i=0;i<t.length&&i<this.previousWord.length&&t[i]==this.previousWord[i];i++)r++;this.minimize(r),this.uncheckedNodes.length==0?n=this.root:n=this.uncheckedNodes[this.uncheckedNodes.length-1].child;for(var i=r;i<t.length;i++){var o=new e.TokenSet,s=t[i];n.edges[s]=o,this.uncheckedNodes.push({parent:n,char:s,child:o}),n=o}n.final=!0,this.previousWord=t},e.TokenSet.Builder.prototype.finish=function(){this.minimize(0)},e.TokenSet.Builder.prototype.minimize=function(t){for(var n=this.uncheckedNodes.length-1;n>=t;n--){var r=this.uncheckedNodes[n],i=r.child.toString();i in this.minimizedNodes?r.parent.edges[r.char]=this.minimizedNodes[i]:(r.child._str=i,this.minimizedNodes[i]=r.child),this.uncheckedNodes.pop()}};e.Index=function(t){this.invertedIndex=t.invertedIndex,this.fieldVectors=t.fieldVectors,this.tokenSet=t.tokenSet,this.fields=t.fields,this.pipeline=t.pipeline},e.Index.prototype.search=function(t){return this.query(function(n){var r=new e.QueryParser(t,n);r.parse()})},e.Index.prototype.query=function(t){for(var n=new e.Query(this.fields),r=Object.create(null),i=Object.create(null),o=Object.create(null),s=Object.create(null),a=Object.create(null),l=0;l<this.fields.length;l++)i[this.fields[l]]=new e.Vector;t.call(n,n);for(var l=0;l<n.clauses.length;l++){var c=n.clauses[l],y=null,d=e.Set.empty;c.usePipeline?y=this.pipeline.runString(c.term,{fields:c.fields}):y=[c.term];for(var v=0;v<y.length;v++){var x=y[v];c.term=x;var T=e.TokenSet.fromClause(c),O=this.tokenSet.intersect(T).toArray();if(O.length===0&&c.presence===e.Query.presence.REQUIRED){for(var k=0;k<c.fields.length;k++){var R=c.fields[k];s[R]=e.Set.empty}break}for(var N=0;N<O.length;N++)for(var H=O[N],z=this.invertedIndex[H],ee=z._index,k=0;k<c.fields.length;k++){var R=c.fields[k],j=z[R],re=Object.keys(j),U=H+"/"+R,ie=new e.Set(re);if(c.presence==e.Query.presence.REQUIRED&&(d=d.union(ie),s[R]===void 0&&(s[R]=e.Set.complete)),c.presence==e.Query.presence.PROHIBITED){a[R]===void 0&&(a[R]=e.Set.empty),a[R]=a[R].union(ie);continue}if(i[R].upsert(ee,c.boost,function(K,Le){return K+Le}),!o[U]){for(var ne=0;ne<re.length;ne++){var ue=re[ne],he=new e.FieldRef(ue,R),Y=j[ue],le;(le=r[he])===void 0?r[he]=new e.MatchData(H,R,Y):le.add(H,R,Y)}o[U]=!0}}}if(c.presence===e.Query.presence.REQUIRED)for(var k=0;k<c.fields.length;k++){var R=c.fields[k];s[R]=s[R].intersect(d)}}for(var de=e.Set.complete,ve=e.Set.empty,l=0;l<this.fields.length;l++){var R=this.fields[l];s[R]&&(de=de.intersect(s[R])),a[R]&&(ve=ve.union(a[R]))}var ce=Object.keys(r),Te=[],pe=Object.create(null);if(n.isNegated()){ce=Object.keys(this.fieldVectors);for(var l=0;l<ce.length;l++){var he=ce[l],ke=e.FieldRef.fromString(he);r[he]=new e.MatchData}}for(var l=0;l<ce.length;l++){var ke=e.FieldRef.fromString(ce[l]),oe=ke.docRef;if(de.contains(oe)&&!ve.contains(oe)){var we=this.fieldVectors[ke],De=i[ke.fieldName].similarity(we),at;if((at=pe[oe])!==void 0)at.score+=De,at.matchData.combine(r[ke]);else{var Ge={ref:oe,score:De,matchData:r[ke]};pe[oe]=Ge,Te.push(Ge)}}}return Te.sort(function(xe,Be){return Be.score-xe.score})},e.Index.prototype.toJSON=function(){var t=Object.keys(this.invertedIndex).sort().map(function(r){return[r,this.invertedIndex[r]]},this),n=Object.keys(this.fieldVectors).map(function(r){return[r,this.fieldVectors[r].toJSON()]},this);return{version:e.version,fields:this.fields,fieldVectors:n,invertedIndex:t,pipeline:this.pipeline.toJSON()}},e.Index.load=function(t){var n={},r={},i=t.fieldVectors,o=Object.create(null),s=t.invertedIndex,a=new e.TokenSet.Builder,l=e.Pipeline.load(t.pipeline);t.version!=e.version&&e.utils.warn("Version mismatch when loading serialised index. Current version of lunr '"+e.version+"' does not match serialized index '"+t.version+"'");for(var c=0;c<i.length;c++){var y=i[c],d=y[0],v=y[1];r[d]=new e.Vector(v)}for(var c=0;c<s.length;c++){var y=s[c],x=y[0],T=y[1];a.insert(x),o[x]=T}return a.finish(),n.fields=t.fields,n.fieldVectors=r,n.invertedIndex=o,n.tokenSet=a.root,n.pipeline=l,new e.Index(n)};e.Builder=function(){this._ref="id",this._fields=Object.create(null),this._documents=Object.create(null),this.invertedIndex=Object.create(null),this.fieldTermFrequencies={},this.fieldLengths={},this.tokenizer=e.tokenizer,this.pipeline=new e.Pipeline,this.searchPipeline=new e.Pipeline,this.documentCount=0,this._b=.75,this._k1=1.2,this.termIndex=0,this.metadataWhitelist=[]},e.Builder.prototype.ref=function(t){this._ref=t},e.Builder.prototype.field=function(t,n){if(/\//.test(t))throw new RangeError("Field '"+t+"' contains illegal character '/'");this._fields[t]=n||{}},e.Builder.prototype.b=function(t){t<0?this._b=0:t>1?this._b=1:this._b=t},e.Builder.prototype.k1=function(t){this._k1=t},e.Builder.prototype.add=function(t,n){var r=t[this._ref],i=Object.keys(this._fields);this._documents[r]=n||{},this.documentCount+=1;for(var o=0;o<i.length;o++){var s=i[o],a=this._fields[s].extractor,l=a?a(t):t[s],c=this.tokenizer(l,{fields:[s]}),y=this.pipeline.run(c),d=new e.FieldRef(r,s),v=Object.create(null);this.fieldTermFrequencies[d]=v,this.fieldLengths[d]=0,this.fieldLengths[d]+=y.length;for(var x=0;x<y.length;x++){var T=y[x];if(v[T]==null&&(v[T]=0),v[T]+=1,this.invertedIndex[T]==null){var O=Object.create(null);O._index=this.termIndex,this.termIndex+=1;for(var k=0;k<i.length;k++)O[i[k]]=Object.create(null);this.invertedIndex[T]=O}this.invertedIndex[T][s][r]==null&&(this.invertedIndex[T][s][r]=Object.create(null));for(var R=0;R<this.metadataWhitelist.length;R++){var N=this.metadataWhitelist[R],H=T.metadata[N];this.invertedIndex[T][s][r][N]==null&&(this.invertedIndex[T][s][r][N]=[]),this.invertedIndex[T][s][r][N].push(H)}}}},e.Builder.prototype.calculateAverageFieldLengths=function(){for(var t=Object.keys(this.fieldLengths),n=t.length,r={},i={},o=0;o<n;o++){var s=e.FieldRef.fromString(t[o]),a=s.fieldName;i[a]||(i[a]=0),i[a]+=1,r[a]||(r[a]=0),r[a]+=this.fieldLengths[s]}for(var l=Object.keys(this._fields),o=0;o<l.length;o++){var c=l[o];r[c]=r[c]/i[c]}this.averageFieldLength=r},e.Builder.prototype.createFieldVectors=function(){for(var t={},n=Object.keys(this.fieldTermFrequencies),r=n.length,i=Object.create(null),o=0;o<r;o++){for(var s=e.FieldRef.fromString(n[o]),a=s.fieldName,l=this.fieldLengths[s],c=new e.Vector,y=this.fieldTermFrequencies[s],d=Object.keys(y),v=d.length,x=this._fields[a].boost||1,T=this._documents[s.docRef].boost||1,O=0;O<v;O++){var k=d[O],R=y[k],N=this.invertedIndex[k]._index,H,z,ee;i[k]===void 0?(H=e.idf(this.invertedIndex[k],this.documentCount),i[k]=H):H=i[k],z=H*((this._k1+1)*R)/(this._k1*(1-this._b+this._b*(l/this.averageFieldLength[a]))+R),z*=x,z*=T,ee=Math.round(z*1e3)/1e3,c.insert(N,ee)}t[s]=c}this.fieldVectors=t},e.Builder.prototype.createTokenSet=function(){this.tokenSet=e.TokenSet.fromArray(Object.keys(this.invertedIndex).sort())},e.Builder.prototype.build=function(){return this.calculateAverageFieldLengths(),this.createFieldVectors(),this.createTokenSet(),new e.Index({invertedIndex:this.invertedIndex,fieldVectors:this.fieldVectors,tokenSet:this.tokenSet,fields:Object.keys(this._fields),pipeline:this.searchPipeline})},e.Builder.prototype.use=function(t){var n=Array.prototype.slice.call(arguments,1);n.unshift(this),t.apply(this,n)},e.MatchData=function(t,n,r){for(var i=Object.create(null),o=Object.keys(r||{}),s=0;s<o.length;s++){var a=o[s];i[a]=r[a].slice()}this.metadata=Object.create(null),t!==void 0&&(this.metadata[t]=Object.create(null),this.metadata[t][n]=i)},e.MatchData.prototype.combine=function(t){for(var n=Object.keys(t.metadata),r=0;r<n.length;r++){var i=n[r],o=Object.keys(t.metadata[i]);this.metadata[i]==null&&(this.metadata[i]=Object.create(null));for(var s=0;s<o.length;s++){var a=o[s],l=Object.keys(t.metadata[i][a]);this.metadata[i][a]==null&&(this.metadata[i][a]=Object.create(null));for(var c=0;c<l.length;c++){var y=l[c];this.metadata[i][a][y]==null?this.metadata[i][a][y]=t.metadata[i][a][y]:this.metadata[i][a][y]=this.metadata[i][a][y].concat(t.metadata[i][a][y])}}}},e.MatchData.prototype.add=function(t,n,r){if(!(t in this.metadata)){this.metadata[t]=Object.create(null),this.metadata[t][n]=r;return}if(!(n in this.metadata[t])){this.metadata[t][n]=r;return}for(var i=Object.keys(r),o=0;o<i.length;o++){var s=i[o];s in this.metadata[t][n]?this.metadata[t][n][s]=this.metadata[t][n][s].concat(r[s]):this.metadata[t][n][s]=r[s]}},e.Query=function(t){this.clauses=[],this.allFields=t},e.Query.wildcard=new String("*"),e.Query.wildcard.NONE=0,e.Query.wildcard.LEADING=1,e.Query.wildcard.TRAILING=2,e.Query.presence={OPTIONAL:1,REQUIRED:2,PROHIBITED:3},e.Query.prototype.clause=function(t){return"fields"in t||(t.fields=this.allFields),"boost"in t||(t.boost=1),"usePipeline"in t||(t.usePipeline=!0),"wildcard"in t||(t.wildcard=e.Query.wildcard.NONE),t.wildcard&e.Query.wildcard.LEADING&&t.term.charAt(0)!=e.Query.wildcard&&(t.term="*"+t.term),t.wildcard&e.Query.wildcard.TRAILING&&t.term.slice(-1)!=e.Query.wildcard&&(t.term=""+t.term+"*"),"presence"in t||(t.presence=e.Query.presence.OPTIONAL),this.clauses.push(t),this},e.Query.prototype.isNegated=function(){for(var t=0;t<this.clauses.length;t++)if(this.clauses[t].presence!=e.Query.presence.PROHIBITED)return!1;return!0},e.Query.prototype.term=function(t,n){if(Array.isArray(t))return t.forEach(function(i){this.term(i,e.utils.clone(n))},this),this;var r=n||{};return r.term=t.toString(),this.clause(r),this},e.QueryParseError=function(t,n,r){this.name="QueryParseError",this.message=t,this.start=n,this.end=r},e.QueryParseError.prototype=new Error,e.QueryLexer=function(t){this.lexemes=[],this.str=t,this.length=t.length,this.pos=0,this.start=0,this.escapeCharPositions=[]},e.QueryLexer.prototype.run=function(){for(var t=e.QueryLexer.lexText;t;)t=t(this)},e.QueryLexer.prototype.sliceString=function(){for(var t=[],n=this.start,r=this.pos,i=0;i<this.escapeCharPositions.length;i++)r=this.escapeCharPositions[i],t.push(this.str.slice(n,r)),n=r+1;return t.push(this.str.slice(n,this.pos)),this.escapeCharPositions.length=0,t.join("")},e.QueryLexer.prototype.emit=function(t){this.lexemes.push({type:t,str:this.sliceString(),start:this.start,end:this.pos}),this.start=this.pos},e.QueryLexer.prototype.escapeCharacter=function(){this.escapeCharPositions.push(this.pos-1),this.pos+=1},e.QueryLexer.prototype.next=function(){if(this.pos>=this.length)return e.QueryLexer.EOS;var t=this.str.charAt(this.pos);return this.pos+=1,t},e.QueryLexer.prototype.width=function(){return this.pos-this.start},e.QueryLexer.prototype.ignore=function(){this.start==this.pos&&(this.pos+=1),this.start=this.pos},e.QueryLexer.prototype.backup=function(){this.pos-=1},e.QueryLexer.prototype.acceptDigitRun=function(){var t,n;do t=this.next(),n=t.charCodeAt(0);while(n>47&&n<58);t!=e.QueryLexer.EOS&&this.backup()},e.QueryLexer.prototype.more=function(){return this.pos<this.length},e.QueryLexer.EOS="EOS",e.QueryLexer.FIELD="FIELD",e.QueryLexer.TERM="TERM",e.QueryLexer.EDIT_DISTANCE="EDIT_DISTANCE",e.QueryLexer.BOOST="BOOST",e.QueryLexer.PRESENCE="PRESENCE",e.QueryLexer.lexField=function(t){return t.backup(),t.emit(e.QueryLexer.FIELD),t.ignore(),e.QueryLexer.lexText},e.QueryLexer.lexTerm=function(t){if(t.width()>1&&(t.backup(),t.emit(e.QueryLexer.TERM)),t.ignore(),t.more())return e.QueryLexer.lexText},e.QueryLexer.lexEditDistance=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.EDIT_DISTANCE),e.QueryLexer.lexText},e.QueryLexer.lexBoost=function(t){return t.ignore(),t.acceptDigitRun(),t.emit(e.QueryLexer.BOOST),e.QueryLexer.lexText},e.QueryLexer.lexEOS=function(t){t.width()>0&&t.emit(e.QueryLexer.TERM)},e.QueryLexer.termSeparator=e.tokenizer.separator,e.QueryLexer.lexText=function(t){for(;;){var n=t.next();if(n==e.QueryLexer.EOS)return e.QueryLexer.lexEOS;if(n.charCodeAt(0)==92){t.escapeCharacter();continue}if(n==":")return e.QueryLexer.lexField;if(n=="~")return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexEditDistance;if(n=="^")return t.backup(),t.width()>0&&t.emit(e.QueryLexer.TERM),e.QueryLexer.lexBoost;if(n=="+"&&t.width()===1||n=="-"&&t.width()===1)return t.emit(e.QueryLexer.PRESENCE),e.QueryLexer.lexText;if(n.match(e.QueryLexer.termSeparator))return e.QueryLexer.lexTerm}},e.QueryParser=function(t,n){this.lexer=new e.QueryLexer(t),this.query=n,this.currentClause={},this.lexemeIdx=0},e.QueryParser.prototype.parse=function(){this.lexer.run(),this.lexemes=this.lexer.lexemes;for(var t=e.QueryParser.parseClause;t;)t=t(this);return this.query},e.QueryParser.prototype.peekLexeme=function(){return this.lexemes[this.lexemeIdx]},e.QueryParser.prototype.consumeLexeme=function(){var t=this.peekLexeme();return this.lexemeIdx+=1,t},e.QueryParser.prototype.nextClause=function(){var t=this.currentClause;this.query.clause(t),this.currentClause={}},e.QueryParser.parseClause=function(t){var n=t.peekLexeme();if(n!=null)switch(n.type){case e.QueryLexer.PRESENCE:return e.QueryParser.parsePresence;case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var r="expected either a field or a term, found "+n.type;throw n.str.length>=1&&(r+=" with value '"+n.str+"'"),new e.QueryParseError(r,n.start,n.end)}},e.QueryParser.parsePresence=function(t){var n=t.consumeLexeme();if(n!=null){switch(n.str){case"-":t.currentClause.presence=e.Query.presence.PROHIBITED;break;case"+":t.currentClause.presence=e.Query.presence.REQUIRED;break;default:var r="unrecognised presence operator'"+n.str+"'";throw new e.QueryParseError(r,n.start,n.end)}var i=t.peekLexeme();if(i==null){var r="expecting term or field, found nothing";throw new e.QueryParseError(r,n.start,n.end)}switch(i.type){case e.QueryLexer.FIELD:return e.QueryParser.parseField;case e.QueryLexer.TERM:return e.QueryParser.parseTerm;default:var r="expecting term or field, found '"+i.type+"'";throw new e.QueryParseError(r,i.start,i.end)}}},e.QueryParser.parseField=function(t){var n=t.consumeLexeme();if(n!=null){if(t.query.allFields.indexOf(n.str)==-1){var r=t.query.allFields.map(function(s){return"'"+s+"'"}).join(", "),i="unrecognised field '"+n.str+"', possible fields: "+r;throw new e.QueryParseError(i,n.start,n.end)}t.currentClause.fields=[n.str];var o=t.peekLexeme();if(o==null){var i="expecting term, found nothing";throw new e.QueryParseError(i,n.start,n.end)}if(o.type===e.QueryLexer.TERM)return e.QueryParser.parseTerm;var i="expecting term, found '"+o.type+"'";throw new e.QueryParseError(i,o.start,o.end)}},e.QueryParser.parseTerm=function(t){var n=t.consumeLexeme();if(n!=null){t.currentClause.term=n.str.toLowerCase(),n.str.indexOf("*")!=-1&&(t.currentClause.usePipeline=!1);var r=t.peekLexeme();if(r==null){t.nextClause();return}switch(r.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+r.type+"'";throw new e.QueryParseError(i,r.start,r.end)}}},e.QueryParser.parseEditDistance=function(t){var n=t.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="edit distance must be numeric";throw new e.QueryParseError(i,n.start,n.end)}t.currentClause.editDistance=r;var o=t.peekLexeme();if(o==null){t.nextClause();return}switch(o.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+o.type+"'";throw new e.QueryParseError(i,o.start,o.end)}}},e.QueryParser.parseBoost=function(t){var n=t.consumeLexeme();if(n!=null){var r=parseInt(n.str,10);if(isNaN(r)){var i="boost must be numeric";throw new e.QueryParseError(i,n.start,n.end)}t.currentClause.boost=r;var o=t.peekLexeme();if(o==null){t.nextClause();return}switch(o.type){case e.QueryLexer.TERM:return t.nextClause(),e.QueryParser.parseTerm;case e.QueryLexer.FIELD:return t.nextClause(),e.QueryParser.parseField;case e.QueryLexer.EDIT_DISTANCE:return e.QueryParser.parseEditDistance;case e.QueryLexer.BOOST:return e.QueryParser.parseBoost;case e.QueryLexer.PRESENCE:return t.nextClause(),e.QueryParser.parsePresence;default:var i="Unexpected lexeme type '"+o.type+"'";throw new e.QueryParseError(i,o.start,o.end)}}},(function(t,n){typeof define=="function"&&define.amd?define(n):typeof Vz=="object"?Gz.exports=n():t.lunr=n()})(this,function(){return e})})()});var qz=V((ZFe,Xz)=>{"use strict";function ire(){return typeof process=="object"&&typeof process.nextTick=="function"?process.nextTick:typeof setImmediate=="function"?setImmediate:function(t){setTimeout(t,0)}}Xz.exports=ire()});var Zz=V((JFe,Kz)=>{"use strict";var Qz=qz();Kz.exports=function(t,n){if(t){n.then(function(r){Qz(function(){t(null,r)})},function(r){Qz(function(){t(r)})});return}else return n}});var r5=V(($Fe,n5)=>{n5.exports=kS;kS.default=kS;kS.stable=e5;kS.stableStringify=e5;var m1="[...]",Jz="[Circular]",Py=[],Cy=[];function $z(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function kS(e,t,n,r){typeof r>"u"&&(r=$z()),VA(e,"",0,[],void 0,0,r);var i;try{Cy.length===0?i=JSON.stringify(e,t,n):i=JSON.stringify(e,t5(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Py.length!==0;){var o=Py.pop();o.length===4?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function Uv(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);i.get!==void 0?i.configurable?(Object.defineProperty(r,n,{value:e}),Py.push([r,n,t,i])):Cy.push([t,n,e]):(r[n]=e,Py.push([r,n,t]))}function VA(e,t,n,r,i,o,s){o+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<r.length;a++)if(r[a]===e){Uv(Jz,e,t,i);return}if(typeof s.depthLimit<"u"&&o>s.depthLimit){Uv(m1,e,t,i);return}if(typeof s.edgesLimit<"u"&&n+1>s.edgesLimit){Uv(m1,e,t,i);return}if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)VA(e[a],a,a,r,e,o,s);else{var l=Object.keys(e);for(a=0;a<l.length;a++){var c=l[a];VA(e[c],c,a,r,e,o,s)}}r.pop()}}function ore(e,t){return e<t?-1:e>t?1:0}function e5(e,t,n,r){typeof r>"u"&&(r=$z());var i=GA(e,"",0,[],void 0,0,r)||e,o;try{Cy.length===0?o=JSON.stringify(i,t,n):o=JSON.stringify(i,t5(t),n)}catch{return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;Py.length!==0;){var s=Py.pop();s.length===4?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return o}function GA(e,t,n,r,i,o,s){o+=1;var a;if(typeof e=="object"&&e!==null){for(a=0;a<r.length;a++)if(r[a]===e){Uv(Jz,e,t,i);return}try{if(typeof e.toJSON=="function")return}catch{return}if(typeof s.depthLimit<"u"&&o>s.depthLimit){Uv(m1,e,t,i);return}if(typeof s.edgesLimit<"u"&&n+1>s.edgesLimit){Uv(m1,e,t,i);return}if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)GA(e[a],a,a,r,e,o,s);else{var l={},c=Object.keys(e).sort(ore);for(a=0;a<c.length;a++){var y=c[a];GA(e[y],y,a,r,e,o,s),l[y]=e[y]}if(typeof i<"u")Py.push([i,t,e]),i[t]=l;else return l}r.pop()}}function t5(e){return e=typeof e<"u"?e:function(t,n){return n},function(t,n){if(Cy.length>0)for(var r=0;r<Cy.length;r++){var i=Cy[r];if(i[1]===t&&i[0]===n){n=i[2],Cy.splice(r,1);break}}return e.call(this,t,n)}}});var o5=V((e3e,i5)=>{i5.exports=(function(e,t){e||(e=document),t||(t=window);var n=[],r,i=!1,o=e.documentElement,s=function(){},a,l="hidden",c="visibilitychange";e.webkitHidden!==void 0&&(l="webkitHidden",c="webkitvisibilitychange"),t.getComputedStyle||x();for(var y=["","-webkit-","-moz-","-ms-"],d=document.createElement("div"),v=y.length-1;v>=0;v--){try{d.style.position=y[v]+"sticky"}catch{}d.style.position!=""&&x()}k();function x(){pe=at=ke=oe=we=De=s}function T(xe,Be){for(key in Be)Be.hasOwnProperty(key)&&(xe[key]=Be[key])}function O(xe){return parseFloat(xe)||0}function k(){r={top:t.pageYOffset,left:t.pageXOffset}}function R(){if(t.pageXOffset!=r.left){k(),ke();return}t.pageYOffset!=r.top&&(k(),H())}function N(xe){setTimeout(function(){t.pageYOffset!=r.top&&(r.top=t.pageYOffset,H())},0)}function H(){for(var xe=n.length-1;xe>=0;xe--)z(n[xe])}function z(xe){if(xe.inited){var Be=r.top<=xe.limit.start?0:r.top>=xe.limit.end?2:1;xe.mode!=Be&&ne(xe,Be)}}function ee(){for(var xe=n.length-1;xe>=0;xe--)if(n[xe].inited){var Be=Math.abs(le(n[xe].clone)-n[xe].docOffsetTop),L=Math.abs(n[xe].parent.node.offsetHeight-n[xe].parent.height);if(Be>=2||L>=2)return!1}return!0}function j(xe){isNaN(parseFloat(xe.computed.top))||xe.isCell||(xe.inited=!0,xe.clone||ue(xe),xe.parent.computed.position!="absolute"&&xe.parent.computed.position!="relative"&&(xe.parent.node.style.position="relative"),z(xe),xe.parent.height=xe.parent.node.offsetHeight,xe.docOffsetTop=le(xe.clone))}function re(xe){var Be=!0;xe.clone&&he(xe),T(xe.node.style,xe.css);for(var L=n.length-1;L>=0;L--)if(n[L].node!==xe.node&&n[L].parent.node===xe.parent.node){Be=!1;break}Be&&(xe.parent.node.style.position=xe.parent.css.position),xe.mode=-1}function U(){for(var xe=n.length-1;xe>=0;xe--)j(n[xe])}function ie(){for(var xe=n.length-1;xe>=0;xe--)re(n[xe])}function ne(xe,Be){var L=xe.node.style;switch(Be){case 0:L.position="absolute",L.left=xe.offset.left+"px",L.right=xe.offset.right+"px",L.top=xe.offset.top+"px",L.bottom="auto",L.width="auto",L.marginLeft=0,L.marginRight=0,L.marginTop=0;break;case 1:L.position="fixed",L.left=xe.box.left+"px",L.right=xe.box.right+"px",L.top=xe.css.top,L.bottom="auto",L.width="auto",L.marginLeft=0,L.marginRight=0,L.marginTop=0;break;case 2:L.position="absolute",L.left=xe.offset.left+"px",L.right=xe.offset.right+"px",L.top="auto",L.bottom=0,L.width="auto",L.marginLeft=0,L.marginRight=0;break}xe.mode=Be}function ue(xe){xe.clone=document.createElement("div");var Be=xe.node.nextSibling||xe.node,L=xe.clone.style;L.height=xe.height+"px",L.width=xe.width+"px",L.marginTop=xe.computed.marginTop,L.marginBottom=xe.computed.marginBottom,L.marginLeft=xe.computed.marginLeft,L.marginRight=xe.computed.marginRight,L.padding=L.border=L.borderSpacing=0,L.fontSize="1em",L.position="static",L.cssFloat=xe.computed.cssFloat,xe.node.parentNode.insertBefore(xe.clone,Be)}function he(xe){xe.clone.parentNode.removeChild(xe.clone),xe.clone=void 0}function Y(xe){var Be=getComputedStyle(xe),L=xe.parentNode,K=getComputedStyle(L),Le=xe.style.position;xe.style.position="relative";var $e={top:Be.top,marginTop:Be.marginTop,marginBottom:Be.marginBottom,marginLeft:Be.marginLeft,marginRight:Be.marginRight,cssFloat:Be.cssFloat},Oe={top:O(Be.top),marginBottom:O(Be.marginBottom),paddingLeft:O(Be.paddingLeft),paddingRight:O(Be.paddingRight),borderLeftWidth:O(Be.borderLeftWidth),borderRightWidth:O(Be.borderRightWidth)};xe.style.position=Le;var te={position:xe.style.position,top:xe.style.top,bottom:xe.style.bottom,left:xe.style.left,right:xe.style.right,width:xe.style.width,marginTop:xe.style.marginTop,marginLeft:xe.style.marginLeft,marginRight:xe.style.marginRight},q=de(xe),Ie=de(L),Ee={node:L,css:{position:L.style.position},computed:{position:K.position},numeric:{borderLeftWidth:O(K.borderLeftWidth),borderRightWidth:O(K.borderRightWidth),borderTopWidth:O(K.borderTopWidth),borderBottomWidth:O(K.borderBottomWidth)}},nt={node:xe,box:{left:q.win.left,right:o.clientWidth-q.win.right},offset:{top:q.win.top-Ie.win.top-Ee.numeric.borderTopWidth,left:q.win.left-Ie.win.left-Ee.numeric.borderLeftWidth,right:-q.win.right+Ie.win.right-Ee.numeric.borderRightWidth},css:te,isCell:Be.display=="table-cell",computed:$e,numeric:Oe,width:q.win.right-q.win.left,height:q.win.bottom-q.win.top,mode:-1,inited:!1,parent:Ee,limit:{start:q.doc.top-Oe.top,end:Ie.doc.top+L.offsetHeight-Ee.numeric.borderBottomWidth-xe.offsetHeight-Oe.top-Oe.marginBottom}};return nt}function le(xe){for(var Be=0;xe;)Be+=xe.offsetTop,xe=xe.offsetParent;return Be}function de(xe){var Be=xe.getBoundingClientRect();return{doc:{top:Be.top+t.pageYOffset,left:Be.left+t.pageXOffset},win:Be}}function ve(){a=setInterval(function(){!ee()&&ke()},500)}function ce(){clearInterval(a)}function Te(){i&&(document[l]?ce():ve())}function pe(){i||(k(),U(),t.addEventListener("scroll",R),t.addEventListener("wheel",N),t.addEventListener("resize",ke),t.addEventListener("orientationchange",ke),e.addEventListener(c,Te),ve(),i=!0)}function ke(){if(i){ie();for(var xe=n.length-1;xe>=0;xe--)n[xe]=Y(n[xe].node);U()}}function oe(){t.removeEventListener("scroll",R),t.removeEventListener("wheel",N),t.removeEventListener("resize",ke),t.removeEventListener("orientationchange",ke),e.removeEventListener(c,Te),ce(),i=!1}function we(){oe(),ie()}function De(){for(we();n.length;)n.pop()}function at(xe){for(var Be=n.length-1;Be>=0;Be--)if(n[Be].node===xe)return;var L=Y(xe);n.push(L),i?j(L):pe()}function Ge(xe){for(var Be=n.length-1;Be>=0;Be--)n[Be].node===xe&&(re(n[Be]),n.splice(Be,1))}return{stickies:n,add:at,remove:Ge,init:pe,rebuild:ke,pause:oe,stop:we,kill:De}})});var nr=V(sa=>{"use strict";var YA=Symbol.for("yaml.alias"),s5=Symbol.for("yaml.document"),y1=Symbol.for("yaml.map"),a5=Symbol.for("yaml.pair"),XA=Symbol.for("yaml.scalar"),b1=Symbol.for("yaml.seq"),ep=Symbol.for("yaml.node.type"),sre=e=>!!e&&typeof e=="object"&&e[ep]===YA,are=e=>!!e&&typeof e=="object"&&e[ep]===s5,lre=e=>!!e&&typeof e=="object"&&e[ep]===y1,cre=e=>!!e&&typeof e=="object"&&e[ep]===a5,l5=e=>!!e&&typeof e=="object"&&e[ep]===XA,ure=e=>!!e&&typeof e=="object"&&e[ep]===b1;function c5(e){if(e&&typeof e=="object")switch(e[ep]){case y1:case b1:return!0}return!1}function fre(e){if(e&&typeof e=="object")switch(e[ep]){case YA:case y1:case XA:case b1:return!0}return!1}var dre=e=>(l5(e)||c5(e))&&!!e.anchor;sa.ALIAS=YA;sa.DOC=s5;sa.MAP=y1;sa.NODE_TYPE=ep;sa.PAIR=a5;sa.SCALAR=XA;sa.SEQ=b1;sa.hasAnchor=dre;sa.isAlias=sre;sa.isCollection=c5;sa.isDocument=are;sa.isMap=lre;sa.isNode=fre;sa.isPair=cre;sa.isScalar=l5;sa.isSeq=ure});var CS=V(qA=>{"use strict";var Es=nr(),dc=Symbol("break visit"),u5=Symbol("skip children"),Wd=Symbol("remove node");function v1(e,t){let n=f5(t);Es.isDocument(e)?Hv(null,e.contents,n,Object.freeze([e]))===Wd&&(e.contents=null):Hv(null,e,n,Object.freeze([]))}v1.BREAK=dc;v1.SKIP=u5;v1.REMOVE=Wd;function Hv(e,t,n,r){let i=d5(e,t,n,r);if(Es.isNode(i)||Es.isPair(i))return h5(e,r,i),Hv(e,i,n,r);if(typeof i!="symbol"){if(Es.isCollection(t)){r=Object.freeze(r.concat(t));for(let o=0;o<t.items.length;++o){let s=Hv(o,t.items[o],n,r);if(typeof s=="number")o=s-1;else{if(s===dc)return dc;s===Wd&&(t.items.splice(o,1),o-=1)}}}else if(Es.isPair(t)){r=Object.freeze(r.concat(t));let o=Hv("key",t.key,n,r);if(o===dc)return dc;o===Wd&&(t.key=null);let s=Hv("value",t.value,n,r);if(s===dc)return dc;s===Wd&&(t.value=null)}}return i}async function w1(e,t){let n=f5(t);Es.isDocument(e)?await Wv(null,e.contents,n,Object.freeze([e]))===Wd&&(e.contents=null):await Wv(null,e,n,Object.freeze([]))}w1.BREAK=dc;w1.SKIP=u5;w1.REMOVE=Wd;async function Wv(e,t,n,r){let i=await d5(e,t,n,r);if(Es.isNode(i)||Es.isPair(i))return h5(e,r,i),Wv(e,i,n,r);if(typeof i!="symbol"){if(Es.isCollection(t)){r=Object.freeze(r.concat(t));for(let o=0;o<t.items.length;++o){let s=await Wv(o,t.items[o],n,r);if(typeof s=="number")o=s-1;else{if(s===dc)return dc;s===Wd&&(t.items.splice(o,1),o-=1)}}}else if(Es.isPair(t)){r=Object.freeze(r.concat(t));let o=await Wv("key",t.key,n,r);if(o===dc)return dc;o===Wd&&(t.key=null);let s=await Wv("value",t.value,n,r);if(s===dc)return dc;s===Wd&&(t.value=null)}}return i}function f5(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function d5(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(Es.isMap(t))return n.Map?.(e,t,r);if(Es.isSeq(t))return n.Seq?.(e,t,r);if(Es.isPair(t))return n.Pair?.(e,t,r);if(Es.isScalar(t))return n.Scalar?.(e,t,r);if(Es.isAlias(t))return n.Alias?.(e,t,r)}function h5(e,t,n){let r=t[t.length-1];if(Es.isCollection(r))r.items[e]=n;else if(Es.isPair(r))e==="key"?r.key=n:r.value=n;else if(Es.isDocument(r))r.contents=n;else{let i=Es.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}qA.visit=v1;qA.visitAsync=w1});var QA=V(g5=>{"use strict";var p5=nr(),hre=CS(),pre={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gre=e=>e.replace(/[!,[\]{}]/g,t=>pre[t]),PS=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[o,s]=r;return this.tags[o]=s,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=r;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let s=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,s),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let s=t.slice(2,-1);return s==="!"||s==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),s)}let[,r,i]=t.match(/^(.*!)([^!]*)$/s);i||n(`The ${t} tag has no suffix`);let o=this.tags[r];if(o)try{return o+decodeURIComponent(i)}catch(s){return n(String(s)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+gre(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),i;if(t&&r.length>0&&p5.isNode(t.contents)){let o={};hre.visit(t.contents,(s,a)=>{p5.isNode(a)&&a.tag&&(o[a.tag]=!0)}),i=Object.keys(o)}else i=[];for(let[o,s]of r)o==="!!"&&s==="tag:yaml.org,2002:"||(!t||i.some(a=>a.startsWith(s)))&&n.push(`%TAG ${o} ${s}`);return n.join(`
|
|
9
9
|
`)}};PS.defaultYaml={explicit:!1,version:"1.2"};PS.defaultTags={"!!":"tag:yaml.org,2002:"};g5.Directives=PS});var S1=V(AS=>{"use strict";var m5=nr(),mre=CS();function yre(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function y5(e){let t=new Set;return mre.visit(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function b5(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function bre(e,t){let n=[],r=new Map,i=null;return{onAnchor:o=>{n.push(o),i??(i=y5(e));let s=b5(t,i);return i.add(s),s},setAnchors:()=>{for(let o of n){let s=r.get(o);if(typeof s=="object"&&s.anchor&&(m5.isScalar(s.node)||m5.isCollection(s.node)))s.node.anchor=s.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:r}}AS.anchorIsValid=yre;AS.anchorNames=y5;AS.createNodeAnchors=bre;AS.findNewAnchor=b5});var KA=V(v5=>{"use strict";function RS(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let i=0,o=r.length;i<o;++i){let s=r[i],a=RS(e,r,String(i),s);a===void 0?delete r[i]:a!==s&&(r[i]=a)}else if(r instanceof Map)for(let i of Array.from(r.keys())){let o=r.get(i),s=RS(e,r,i,o);s===void 0?r.delete(i):s!==o&&r.set(i,s)}else if(r instanceof Set)for(let i of Array.from(r)){let o=RS(e,r,i,i);o===void 0?r.delete(i):o!==i&&(r.delete(i),r.add(o))}else for(let[i,o]of Object.entries(r)){let s=RS(e,r,i,o);s===void 0?delete r[i]:s!==o&&(r[i]=s)}return e.call(t,n,r)}v5.applyReviver=RS});var Bg=V(S5=>{"use strict";var vre=nr();function w5(e,t,n){if(Array.isArray(e))return e.map((r,i)=>w5(r,String(i),n));if(e&&typeof e.toJSON=="function"){if(!n||!vre.hasAnchor(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=o=>{r.res=o,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e=="bigint"&&!n?.keep?Number(e):e}S5.toJS=w5});var x1=V(E5=>{"use strict";var wre=KA(),x5=nr(),Sre=Bg(),ZA=class{constructor(t){Object.defineProperty(this,x5.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){if(!x5.isDocument(t))throw new TypeError("A document argument is required");let s={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=Sre.toJS(this,"",s);if(typeof i=="function")for(let{count:l,res:c}of s.anchors.values())i(c,l);return typeof o=="function"?wre.applyReviver(o,{"":a},"",a):a}};E5.NodeBase=ZA});var IS=V(_5=>{"use strict";var xre=S1(),Ere=CS(),jv=nr(),_re=x1(),Ore=Bg(),JA=class extends _re.NodeBase{constructor(t){super(jv.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Ere.visit(t,{Node:(o,s)=>{(jv.isAlias(s)||jv.hasAnchor(s))&&r.push(s)}}),n&&(n.aliasResolveCache=r));let i;for(let o of r){if(o===this)break;o.anchor===this.source&&(i=o)}return i}toJSON(t,n){if(!n)return{source:this.source};let{anchors:r,doc:i,maxAliasCount:o}=n,s=this.resolve(i,n);if(!s){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=r.get(s);if(a||(Ore.toJS(s,null,n),a=r.get(s)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(o>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=E1(i,s,r)),a.count*a.aliasCount>o)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(t,n,r){let i=`*${this.source}`;if(t){if(xre.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(t.implicitKey)return`${i} `}return i}};function E1(e,t,n){if(jv.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(jv.isCollection(t)){let r=0;for(let i of t.items){let o=E1(e,i,n);o>r&&(r=o)}return r}else if(jv.isPair(t)){let r=E1(e,t.key,n),i=E1(e,t.value,n);return Math.max(r,i)}return 1}_5.Alias=JA});var os=V($A=>{"use strict";var Tre=nr(),kre=x1(),Cre=Bg(),Pre=e=>!e||typeof e!="function"&&typeof e!="object",zg=class extends kre.NodeBase{constructor(t){super(Tre.SCALAR),this.value=t}toJSON(t,n){return n?.keep?this.value:Cre.toJS(this.value,t,n)}toString(){return String(this.value)}};zg.BLOCK_FOLDED="BLOCK_FOLDED";zg.BLOCK_LITERAL="BLOCK_LITERAL";zg.PLAIN="PLAIN";zg.QUOTE_DOUBLE="QUOTE_DOUBLE";zg.QUOTE_SINGLE="QUOTE_SINGLE";$A.Scalar=zg;$A.isScalarValue=Pre});var MS=V(T5=>{"use strict";var Are=IS(),Ay=nr(),O5=os(),Rre="tag:yaml.org,2002:";function Ire(e,t,n){if(t){let r=n.filter(o=>o.tag===t),i=r.find(o=>!o.format)??r[0];if(!i)throw new Error(`Tag ${t} not found`);return i}return n.find(r=>r.identify?.(e)&&!r.format)}function Mre(e,t,n){if(Ay.isDocument(e)&&(e=e.contents),Ay.isNode(e))return e;if(Ay.isPair(e)){let d=n.schema[Ay.MAP].createNode?.(n.schema,null,n);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:o,schema:s,sourceObjects:a}=n,l;if(r&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=i(e)),new Are.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=Rre+t.slice(2));let c=Ire(e,t,s.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new O5.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?s[Ay.MAP]:Symbol.iterator in Object(e)?s[Ay.SEQ]:s[Ay.MAP]}o&&(o(c),delete n.onTagObj);let y=c?.createNode?c.createNode(n.schema,e,n):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(n.schema,e,n):new O5.Scalar(e);return t?y.tag=t:c.default||(y.tag=c.tag),l&&(l.node=y),y}T5.createNode=Mre});var O1=V(_1=>{"use strict";var Lre=MS(),jd=nr(),Nre=x1();function eR(e,t,n){let r=n;for(let i=t.length-1;i>=0;--i){let o=t[i];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let s=[];s[o]=r,r=s}else r=new Map([[o,r]])}return Lre.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var k5=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,tR=class extends Nre.NodeBase{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>jd.isNode(r)||jd.isPair(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(k5(t))this.add(n);else{let[r,...i]=t,o=this.get(r,!0);if(jd.isCollection(o))o.addIn(i,n);else if(o===void 0&&this.schema)this.set(r,eR(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}deleteIn(t){let[n,...r]=t;if(r.length===0)return this.delete(n);let i=this.get(n,!0);if(jd.isCollection(i))return i.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){let[r,...i]=t,o=this.get(r,!0);return i.length===0?!n&&jd.isScalar(o)?o.value:o:jd.isCollection(o)?o.getIn(i,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!jd.isPair(n))return!1;let r=n.value;return r==null||t&&jd.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[n,...r]=t;if(r.length===0)return this.has(n);let i=this.get(n,!0);return jd.isCollection(i)?i.hasIn(r):!1}setIn(t,n){let[r,...i]=t;if(i.length===0)this.set(r,n);else{let o=this.get(r,!0);if(jd.isCollection(o))o.setIn(i,n);else if(o===void 0&&this.schema)this.set(r,eR(this.schema,i,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${i}`)}}};_1.Collection=tR;_1.collectionFromPath=eR;_1.isEmptyPath=k5});var LS=V(T1=>{"use strict";var Dre=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function nR(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Fre=(e,t,n)=>e.endsWith(`
|
|
10
10
|
`)?nR(n,t):n.includes(`
|
|
@@ -0,0 +1,11 @@
|
|
|
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 s}from"./WZXA5XPB.js";import{a as m}from"./3JJEI7CJ.js";import{e as f}from"./RFWIIJFG.js";var e=f(m(),1);if(typeof e.default?.createSourceFile!="function")throw new Error(`Baking a --setup module needs the TypeScript compiler API, but the installed \`typescript\` package${e.default?.version?` (${e.default.version})`:""} does not include it \u2014 TypeScript 7 ships only the native tsc. Install TypeScript 6 for generation (npm i -D typescript@6); your app can still compile the generated client with TypeScript 7.`);var a="@redocly/client-generator";function g(n){let i=e.default.createSourceFile("setup.ts",n,e.default.ScriptTarget.Latest,!0,e.default.ScriptKind.TS),p=[],o,d="defineClientSetup";for(let t of i.statements){if(e.default.isImportDeclaration(t)){let r=t.moduleSpecifier.text;if(r!==a)throw new s(`A --setup file may only import from "${a}"; found "${r}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);let c=t.importClause?.namedBindings;if(c&&e.default.isNamedImports(c))for(let l of c.elements)(l.propertyName?.text??l.name.text)==="defineClientSetup"&&(d=l.name.text);continue}if(e.default.isExportAssignment(t)&&!t.isExportEquals){o=y(t.expression,d).getText(i);continue}if(e.default.isExportDeclaration(t)){if(t.moduleSpecifier!==void 0)throw new s(`A --setup file may only import from "${a}"; found "${t.moduleSpecifier.text}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);continue}let u=e.default.canHaveModifiers(t)?e.default.getModifiers(t)?.find(r=>r.kind===e.default.SyntaxKind.ExportKeyword):void 0;p.push(u===void 0?t.getText(i):n.slice(u.end,t.getEnd()).trimStart())}if(o===void 0)throw new s("A --setup file must `export default defineClientSetup({ config, middleware })` (or a setup object).");return p.length===0?o:`(() => {
|
|
8
|
+
${p.join(`
|
|
9
|
+
`)}
|
|
10
|
+
return ${o};
|
|
11
|
+
})()`}function y(n,i){return e.default.isCallExpression(n)&&e.default.isIdentifier(n.expression)&&n.expression.text===i&&n.arguments.length===1?n.arguments[0]:n}export{g as bakeSetup};
|
|
@@ -0,0 +1,8 @@
|
|
|
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 f,c as l,d as i,e as g,l as o}from"./HJYFWIVE.js";var s=l.python,d=class extends f{constructor(){super(" ")}typeName(r){return i(r,{style:"pascal",reserved:s})}memberName(r){let e=i(r,{style:"snake",reserved:s});return{identifier:e,renamed:e!==r}}identifier(r){return i(r,{style:"snake",reserved:s})}identifiers(r,e){return g(r,{style:"snake",reserved:s,taken:e})}constName(r){return i(r,{style:"screaming",reserved:s})}string(r){let e='"';for(let t of r){let n=t.codePointAt(0);t==="\\"?e+="\\\\":t==='"'?e+='\\"':t===`
|
|
8
|
+
`?e+="\\n":t==="\r"?e+="\\r":t===" "?e+="\\t":n<32||n===127?e+=`\\x${n.toString(16).padStart(2,"0")}`:n>=55296&&n<=57343?e+=`\\u${n.toString(16).padStart(4,"0")}`:e+=t}return e+'"'}literal(r){return r==null?"None":r===!0?"True":r===!1?"False":typeof r=="number"?String(r):typeof r=="string"?this.string(r):Array.isArray(r)?`[${r.map(t=>this.literal(t)).join(", ")}]`:`{${Object.entries(r).map(([t,n])=>`${this.string(t)}: ${this.literal(n)}`).join(", ")}}`}comment(r){for(let e of o(r))this.line(e===""?"#":`# ${e}`);return this}doc(r){let e=o(r);if(e.length===0)return this;if(e.length===1)return this.line(`"""${e[0]}"""`);this.line(`"""${e[0]}`);for(let t of e.slice(1))this.line(t);return this.line('"""')}};export{d as a};
|
|
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
|
|
|
4
4
|
const require = __createRequire(import.meta.url);
|
|
5
5
|
var __filename = __fileURLToPath(import.meta.url);
|
|
6
6
|
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{O as e}from"./
|
|
7
|
+
import{O as e}from"./HJ36YGCI.js";var n=["get","put","post","delete","options","head","patch","trace","query"],o=["schemas","responses","parameters","examples","headers","requestBodies","links","callbacks","securitySchemes"];import*as r from"node:process";var i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],t=class{frames;currentFrame;intervalId;message;constructor(){this.frames=i,this.currentFrame=0,this.intervalId=null,this.message=""}showFrame(){e.info("\r"+this.frames[this.currentFrame]+" "+this.message),this.currentFrame=(this.currentFrame+1)%this.frames.length}start(s){if(this.message!==s){if(this.message=s,!r.stderr.isTTY){e.info(`${s}...
|
|
8
8
|
`);return}this.intervalId===null&&(this.intervalId=setInterval(()=>{this.showFrame()},100))}}stop(){this.intervalId!==null&&(clearInterval(this.intervalId),this.intervalId=null,e.info("\r")),this.message=""}};export{n as a,o as b,t as c};
|
|
@@ -0,0 +1,18 @@
|
|
|
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"./ZMCRMR2V.js";import{a as h}from"./PFYPTG4G.js";import{C as J,O as k,R as V,W,aa as Q,c as R,ca as N,ja as Y,q as O,s as X}from"./HJ36YGCI.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("./UMQN5HTL.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("./WXVC3KOI.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./ZXKOHMC6.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("./HL5FOKC4.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./NYLAOZPO.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./6KCIFTIG.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:I,load:()=>import("./C5TR4MMN.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:I,load:()=>import("./GRJG3TOI.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:I,load:()=>import("./CCR5RYCX.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 W,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:V(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};
|
|
@@ -0,0 +1,13 @@
|
|
|
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 T,k as y}from"./NB54XRRU.js";import{join as q}from"node:path";var a=" ";function j(r){return`transform${y(r)}`}var C="type __Writable<T> = { -readonly [K in keyof T]: T[K] };",A=!1;function D(r){return{text:r,path:[r]}}function W(r,t){return{text:`${r.text}[${JSON.stringify(t)}]`,path:[...r.path,t]}}function d(r,t,n){if(k(r))return!0;switch(r.kind){case"array":return d(r.items,t,n);case"union":return r.members.some(o=>d(o,t,n));case"ref":{if(n.has(r.name))return!1;let o=t.get(r.name);return o!==void 0&&d(o,t,new Set(n).add(r.name))}default:return!1}}function k(r){return r.kind==="scalar"&&r.scalar==="string"&&(r.metadata?.format==="date-time"||r.metadata?.format==="date")}function $(r,t,n){if(k(r))return!0;switch(r.kind){case"array":return $(r.items,t,n);case"record":return $(r.value,t,n);case"object":return r.properties.some(o=>$(o.schema,t,n));case"union":case"intersection":return r.members.some(o=>$(o,t,n));case"ref":{let o=t.get(r.name);return o!==void 0&&!n.has(r.name)?$(o,t,new Set(n).add(r.name)):!1}default:return!1}}function l(r,t,n,o=!1){return o?[`${n}if (${r}) {`,...t(n+a),`${n}}`]:[`${n}if (${r})`,...t(n+a)]}function v(r,t,n=!1){let o=n?B(r):r.text;return u=>[`${u}${o} = ${t};`]}function S(r){return t=>[`${t}${r};`]}function B(r){if(r.path.length<2)return r.text;A=!0;let t={text:r.text.slice(0,r.text.lastIndexOf("[")),path:r.path.slice(0,-1)},n=r.path[r.path.length-1];return`(${t.text} as __Writable<${G(t)}>)[${JSON.stringify(n)}]`}function G(r){let t=`typeof ${r.path[0]}`;for(let n of r.path.slice(1))t=`NonNullable<${t}>[${JSON.stringify(n)}]`;return`NonNullable<${t}>`}function K(r){return r==="data"?"item":`item${Number(r.slice(4))+1}`}function p(r,t,n,o,u,e,s=!1){if(k(t))return l(`typeof ${r.text} === "string"`,v(r,`new Date(${r.text})`,s),e);switch(t.kind){case"ref":return h(r,t.name,n,o,e,s);case"object":{let f=[];for(let c of t.properties)f.push(...b(W(r,c.name),c.schema,n,o,u,e,c.readOnly===!0));return f}case"array":return P(r,t.items,n,o,u,e,s);case"record":return I(r,t.value,n,o,u,e,!0);case"intersection":{let f=[];for(let c of t.members)f.push(...p(r,c,n,o,u,e,s));return f}case"union":return U(r,t.members,n,o,u,e,s);default:return[]}}function U(r,t,n,o,u,e,s=!1){let f=[],c=e+a,x=[];for(let i of t)if(k(i))f.push(...p(r,i,n,o,u,e,s));else if(i.kind==="ref"){if(!$(i,n,o))continue;let w=`${j(i.name)}(${r.text} as ${i.name})`,_=d(i,n,o)?v(r,w,s):S(w);x.push(..._(c))}else x.push(...p(r,i,n,o,u,c,s));return x.length>0&&f.push(...l(`${r.text} && typeof ${r.text} === "object"`,()=>x,e,!0)),f}function h(r,t,n,o,u,e=!1){let s={kind:"ref",name:t};if(!$(s,n,o))return[];let f=`${j(t)}(${r.text})`;return l(r.text,d(s,n,o)?v(r,f,e):S(f),u)}function b(r,t,n,o,u,e,s=!1){if(t.kind==="ref")return h(r,t.name,n,o,e,s);if(t.kind==="object"){let f=p(r,t,n,o,u,e+a);return f.length===0?[]:l(r.text,()=>f,e,!0)}return p(r,t,n,o,u,e,s)}function m(r,t,n,o,u=0){if(k(t))return`new Date(${r})`;if(t.kind==="ref"&&d(t,n,o))return`${j(t.name)}(${r})`;if(t.kind==="array"){let e=t.items.kind==="array"?E(u+1):"v",s=m(e,t.items,n,o,u+1);return s===null?null:`${r}.map(${e} => ${s})`}return null}function E(r){return r<=1?"row":`row${r}`}function P(r,t,n,o,u,e,s=!1){let f=t.kind==="array"?E(1):"v",c=m(f,t,n,o,1);return c!==null?l(`Array.isArray(${r.text})`,v(r,`${r.text}.map(${f} => ${c})`,s),e):t.kind==="ref"?$(t,n,o)?l(`Array.isArray(${r.text})`,S(`${r.text}.forEach(${j(t.name)})`),e):[]:I(r,t,n,o,u,e,!1)}function I(r,t,n,o,u,e,s){if(s){let i={text:`${r.text}[__k]`,path:[...r.path,"__k"]},w=m(i.text,t,n,o);if(w!==null){let _=k(t)?`typeof ${i.text} === "string"`:`Array.isArray(${i.text})`;return l(r.text,O=>[`${O}for (const __k of Object.keys(${r.text}))`,...l(_,J=>[`${J}${i.text} = ${w};`],O+a)],e)}}let f=K(u),c=p(D(f),t,n,o,f,e+a+a);if(c.length===0)return[];let x=s?`Object.values(${r.text})`:r.text;return l(s?r.text:`Array.isArray(${r.text})`,i=>[`${i}${x}.forEach(${f} => {`,...c,`${i}});`],e)}function R(r,t){let n=r.name,o=D("data"),u=r.schema.kind==="ref"?h(o,r.schema.name,t,new Set,a):p(o,r.schema,t,new Set,"data",a);return[`export const ${j(r.name)} = (data: ${n}): ${n} => {`,...u,`${a}return data;`,"};"].join(`
|
|
8
|
+
`)}function M(r,t){let n=new Map(r.schemas.map(f=>[f.name,f.schema])),o=r.schemas.filter(f=>$(f.schema,n,new Set));if(o.length===0)return"";let u=o.map(f=>T(f.name)).join(", ");A=!1;let e=o.map(f=>R(f,n));return[`import type { ${u} } from ${JSON.stringify(t.sdkModule)};`,...A?[C]:[],...e].join(`
|
|
9
|
+
|
|
10
|
+
`)}var X=({model:r,output:t,banner:n,emit:o})=>{let u=M(r,{sdkModule:`./${t.stem}.${o.importExt??"js"}`});if(u==="")return[];let e=n.map(s=>`// ${s}`).join(`
|
|
11
|
+
`);return[{path:q(t.dir,`${t.stem}.transformers.ts`),content:`${e}
|
|
12
|
+
|
|
13
|
+
${u}`}]};export{X as a};
|
|
@@ -0,0 +1,19 @@
|
|
|
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 R}from"./SQVG3CEM.js";import{c as L}from"./UKSQ7B5H.js";import{b as J,c as E,d as F,e as W,f as ne,g as B,h as te}from"./4I2OVMBJ.js";import{c as z,d as w,e as A,g as U,h as C,i as Q,j as X,k as Z,n as ee}from"./HJYFWIVE.js";var k=z.python,f=new R;function O(e){return f.typeName(e)}function q(e){let{identifier:n,renamed:s}=f.memberName(e);return{python:n,renamed:s}}function I(e){let n=e.services.flatMap(t=>t.operations),s=A(n.map(t=>t.name),{style:"snake",reserved:k});return n.map((t,r)=>({op:t,ident:s[r]}))}var T=["self","body","headers","timeout","retry","idempotency_key"];function se(e){return f.literal(e)}function oe(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 ae(e,n){let s=new Set;return`[${(e.successResponseHeaders??[]).map(r=>{let a=w(r.name,{style:"snake",reserved:k}),c=a,i=2;for(;s.has(c);)c=`${a}_${i++}`;s.add(c);let m=ee(r.schema,n);return`(${f.string(r.name)}, ${f.string(c)}, ${f.string(m)})`}).join(", ")}]`}function y(e,n="string"){if(Q(e))return`Optional[${y(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[${y(e.items,n)}]`;case"record":return`Dict[str, ${y(e.value,n)}]`;case"ref":return O(e.name);case"literal":return`Literal[${f.literal(e.value)}]`;case"enum":return{string:"str",integer:"int",number:"float",boolean:"bool"}[e.scalar];case"union":return`Union[${e.members.map(s=>y(s,n)).join(", ")}]`;case"null":return"None";case"omit":return O(e.base);case"object":case"intersection":case"unknown":return"Any"}}function H(e,n,s,t,r,a,c,i=!1){let m=A([...n.pathParams,...n.queryParams].map(N=>N.name),{style:"snake",reserved:k,taken:T}),l=n.pathParams.map((N,S)=>({param:N,python:m[S]})),o=n.queryParams.map((N,S)=>({param:N,python:m[n.pathParams.length+S]})),p=l.map(({param:N,python:S})=>`${S}: ${y(N.schema,a)}`),u=n.requestBody?[`body: ${y(n.requestBody.schema,a)}`]:[],$=[...o.map(({param:N,python:S})=>{let D=y(N.schema,a),j=D.startsWith("Optional[")?D:`Optional[${D}]`;return`${S}: ${j} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None","idempotency_key: Any = None"],h=E(n),g=F(n),v=i?`Envelope[${h===void 0?"None":y(h,a)}]`:g!==void 0?`${r?"AsyncIterator":"Iterator"}[ServerSentEvent]`:t==="result"?"Result":h===void 0?"None":y(h,a),P=r&&g===void 0?"async def":"def",d=r?"await ":"",_=r?"send_async":"send",b=["self",...p,...u,"*",...$].join(", "),x=i?`${s}_with_headers`:s;e.block(`${P} ${x}(${b}) -> ${v}:`,()=>{e.doc(i?`Like ${s}(), returning an Envelope with the declared response headers.`:n.summary),e.line(`op = _OPERATIONS["${s}"]`),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:j,python:M}of o)e.block(`if ${M} is not None:`,()=>{e.line(`params[${f.string(j.name)}] = encode(${M})`)});let N=l.map(({param:j,python:M})=>`${f.string(j.name)}: ${M}`).join(", ");if(e.line(`url = build_url(self._server_url, op["path"], {${N}})`),g!==void 0){let j=g.schema!==void 0&&g.schema.kind!=="unknown"?"json":"text";e.block("def _open(extra_headers: Dict[str, str]):",()=>{e.line('return self._http.stream(op["method"], url, headers={**auth_headers, **(headers or {}), **extra_headers}, params=params, timeout=timeout)')}),e.line(`return ${r?"aiter_sse":"iter_sse"}(_open, data_kind="${j}")`);return}W(n)&&e.line("form_data, form_files = to_multipart(body)");let S=n.requestBody?W(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${S}, timeout=timeout, retry=retry, idempotency_key=idempotency_key)`);let D=h===void 0?"None":`decode(${y(h,a)}, _safe_json(response))`;i?(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(`return Envelope(data=${D}, headers=read_envelope_headers(response, ${ae(n,c)}), 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=${D}, error=None, response=response)`)):(e.block("if not response.is_success:",()=>{e.line("raise ApiError(url, response.status_code, response.reason_phrase, _safe_json(response))")}),e.line(h===void 0?"return None":`return ${D}`))}),e.blank()}function re(e,n,s,t,r,a){let c=E(n),i=c===void 0?"Any":y(c,a),m=A([...n.pathParams,...n.queryParams].map(d=>d.name),{style:"snake",reserved:k,taken:T}),l=n.pathParams.map((d,_)=>({param:d,python:m[_]})),o=n.queryParams.map((d,_)=>({param:d,python:m[n.pathParams.length+_]})),p=l.map(({param:d,python:_})=>`${_}: ${y(d.schema,a)}`),u=[...o.map(({param:d,python:_})=>{let b=y(d.schema,a),x=b.startsWith("Optional[")?b:`Optional[${b}]`;return`${_}: ${x} = None`}),"headers: Optional[Dict[str, str]] = None","timeout: Optional[float] = None","retry: Optional[Dict[str, Any]] = None"],$=["self",...p,"*",...u].join(", "),h=t?"AsyncIterator":"Iterator",g=t?"aiter_pages":"iter_pages",v=t?"aiter_items":"iter_items",P=()=>{e.line("base: Dict[str, Any] = {}");for(let{param:b,python:x}of o)e.block(`if ${x} is not None:`,()=>{e.line(`base[${f.string(b.name)}] = encode(${x})`)});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=l.map(({param:x,python:N})=>`${f.string(x.name)}: ${N}`).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 ${s}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.block(`async for page in ${g}(_page, op["pagination"], base):`,()=>{e.line(i==="Any"?"yield page":`yield decode(${i}, page)`)})}),e.blank(),e.block(`async def ${s}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.block(`async for item in ${v}(_page, op["pagination"], base):`,()=>{e.line(r==="Any"?"yield item":`yield decode(${r}, item)`)})})):(e.block(`def ${s}_pages(${$}) -> ${h}[${i}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.line(i==="Any"?`return ${g}(_page, op["pagination"], base)`:`return (decode(${i}, page) for page in ${g}(_page, op["pagination"], base))`)}),e.blank(),e.block(`def ${s}_items(${$}) -> ${h}[${r}]:`,()=>{e.line(`op = _OPERATIONS["${s}"]`),P(),e.line(r==="Any"?`return ${v}(_page, op["pagination"], base)`:`return (decode(${r}, item) for item in ${v}(_page, op["pagination"], base))`)})),e.blank()}function le(e){return ne(e).map(s=>s.kind==="literal"?f.string(s.value):q(s.name).python).join(" + ")}function ie(e,n){let s=n.servers??[];if(s.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(),s.forEach((r,a)=>{let c=w(r.description??`server${a+1}`,{style:"snake",reserved:k});t.has(c)&&(c=`${c}_${a+1}`),t.add(c);let i=r.variables.map(m=>`${q(m.name).python}: str = ${f.string(m.default)}`);a>0&&e.blank(),e.line("@staticmethod"),e.block(`def ${c}(${i.join(", ")}) -> str:`,()=>{e.line(`return ${le(r)}`)})})}),e.blank()}function K(e,n,s,t,r,a,c){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 = ${f.string(a)}, *, auth: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None, timeout: Optional[float] = None, retry: Optional[Dict[str, Any]] = None, middleware: Optional[List[Any]] = None, idempotency_key: Any = None, http_client: Optional[${m}] = None) -> None:`,()=>{e.line("self._server_url = server_url"),e.line("self._auth = auth or {}"),e.line("self._config: Dict[str, Any] = {"),e.indent(()=>{e.line('"headers": headers or {},'),e.line('"timeout": timeout,'),e.line('"retry": retry or {},'),e.line('"middleware": middleware or [],'),e.line('"idempotency_key": idempotency_key,')}),e.line("}"),e.line(`self._http = http_client or ${m}()`)}),e.blank();for(let{op:l,ident:o}of I(n)){H(e,l,o,s,t,c),F(l)===void 0&&(l.successResponseHeaders?.length??0)>0&&H(e,l,o,s,t,c,n,!0);let p=r.get(o);if(p!==void 0){let u=E(l),$=te(u,typeof p.items=="string"?p.items:void 0,n);re(e,l,o,t,$===void 0?"Any":y($,c),c)}}}),e.blank()}function Y(e){let n=new Map,s=new Set,t=[];for(let{name:a,schema:c}of e.schemas){let i=C(c,e);if(!(i===void 0||!i.cases.every(l=>U(l.schema,e)?.properties.some(o=>o.name===i.property)===!0))){for(let l of i.cases){let o=n.get(l.schemaName);if(o!==void 0&&o.value!==l.value){s.add(l.schemaName);continue}n.set(l.schemaName,{property:i.property,value:l.value})}t.push({name:a,property:i.property,members:i.cases.map(l=>l.schemaName)})}}let r=new Map;for(let a of t)a.members.some(c=>s.has(c))||r.set(a.name,q(a.property).python);for(let a of s)n.delete(a);return{pins:n,unions:r}}function pe(e,n,s,t,r,a,c){let i=r==="pydantic";i||e.line("@dataclass");let m=i?`class ${O(n)}(BaseModel):`:`class ${O(n)}:`;e.block(m,()=>{e.doc(a),i&&(e.line("model_config = ConfigDict(populate_by_name=True)"),e.blank());let l=[...s.filter(p=>p.required),...s.filter(p=>!p.required)],o=[];l.length===0&&e.line("pass");for(let p of l){let{python:u,renamed:$}=q(p.name);$&&!i&&o.push([u,p.name]);let h=$&&i?`alias=${f.string(p.name)}`:void 0,g=c?.property===p.name?`Literal[${f.literal(c.value)}]`:y(p.schema,t);if(p.required){let v=h===void 0?"":` = Field(${h})`;e.line(`${u}: ${g}${v}`)}else{let v=g.startsWith("Optional[")?g:`Optional[${g}]`,P=h===void 0?"None":`Field(default=None, ${h})`;e.line(`${u}: ${v} = ${P}`)}}if(o.length>0){e.blank(),e.line("# Python field name -> wire (JSON) name, for (de)serialization.");let p=o.map(([u,$])=>`"${u}": ${f.string($)}`).join(", ");e.line(`_field_map: ClassVar[Dict[str, str]] = {${p}}`)}}),e.blank(),e.blank()}function G(e,n="string",s="dataclass"){let t=new R,{pins:r,unions:a}=s==="pydantic"?Y(e):{pins:new Map,unions:new Map};t.line("from __future__ import annotations"),t.blank(),s==="dataclass"&&t.line("from dataclasses import dataclass"),t.line("from enum import Enum");let c=["Any","AsyncIterator","Dict","Iterator","List","Literal","Optional","Tuple","Union"];s==="dataclass"&&c.splice(2,0,"ClassVar"),a.size>0&&c.unshift("Annotated"),t.line(`from typing import ${c.join(", ")}`),s==="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:l}of e.schemas){let o=Z(l);if(o!==void 0){let p=o.scalar==="string"?"str, Enum":"int, Enum";t.block(`class ${O(m)}(${p}):`,()=>{t.doc(l.description),o.values.forEach((u,$)=>{t.line(`${o.memberNames[$]} = ${f.literal(u)}`)})}),t.blank(),t.blank();continue}if(l.kind==="object"||l.kind==="intersection"){let p=U(l,e);if(p!==void 0){pe(t,m,p.properties,n,s,p.description??l.description,r.get(m));continue}}i.push(()=>{let p=C(l,e);if(p!==void 0){let h=p.cases.map(g=>`${g.value} -> ${O(g.schemaName)}`).join(", ");t.line(`# Discriminated by "${p.property}": ${h}`)}let u=a.get(m),$=u===void 0?y(l,n):`Annotated[${y(l,n)}, Field(discriminator=${f.string(u)})]`;t.line(`${O(m)} = ${$}`),t.blank()})}for(let m of i)m();return t.toString()}function ce(e,n){let s=[];for(let{name:t,schema:r}of e.schemas){if(n.has(t))continue;let a=C(r,e);if(a===void 0)continue;let c=a.cases.map(i=>`${f.string(i.value)}: ${O(i.schemaName)}`).join(", ");s.push(`DISCRIMINATORS[${O(t)}] = (${f.string(a.property)}, {${c}})`)}return s}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?"/":"\\",s=e.lastIndexOf(n),t=s>=0?e.slice(0,s+1):"",r=(s>=0?e.slice(s+1):e).replace(/\.[^.]+$/,"");return`${t}${w(r,{style:"snake",reserved:k})}.py`}var ze=({model:e,output:n,banner:s,emit:t,options:r,pagination:a})=>{let c=t.errorMode??"throw",i=t.dateType??"string",m=r?.models??"dataclass",l=m==="pydantic"?Y(e):void 0,o=new R;if(o.line(`# Generated by @redocly/client-generator (python) from "${e.title}" ${e.version}.`),o.line("# Do not edit by hand \u2014 regenerate with `redocly generate-client`."),o.line(m==="pydantic"?"# Requires Python >= 3.9, httpx, and pydantic: pip install httpx pydantic":"# Requires Python >= 3.9 and httpx: pip install httpx"),o.blank(),o.line(G(e,i,m).trimEnd()),o.blank(),o.blank(),ie(o,e),t.runtime==="module"){o.line("# \u2500\u2500\u2500 Runtime (real modules beside this file, written by the same run) \u2500\u2500\u2500");for(let d of Object.keys(L))o.line(`from ${d.replace(/\.py$/,"")} import *`);o.blank(),o.blank()}else{o.line("# \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator python runtime) \u2500\u2500\u2500");for(let d of Object.values(L)){let _=d.split(`
|
|
8
|
+
`).filter(b=>!b.startsWith("from __future__")&&!b.startsWith("from ._")).join(`
|
|
9
|
+
`).trim();o.line(_),o.blank()}o.blank()}let p=ce(e,new Set(l?.unions.keys()));if(p.length>0){o.line("# Discriminated unions dispatch by their property inside decode().");for(let d of p)o.line(d);o.blank()}o.block("def _safe_json(response: httpx.Response) -> Any:",()=>{o.block("try:",()=>{o.line("return response.json()")}),o.block("except Exception:",()=>{o.line("return None")})}),o.blank();let u=new Map;for(let{op:d,ident:_}of I(e))u.set(_,oe(a?.get(d.name)?.spec));o.line("_OPERATIONS = {"),o.indent(()=>{for(let{op:d,ident:_}of I(e)){let b={id:d.specName??d.name,method:d.method.toUpperCase(),path:d.path,...B(d,e).length>0?{security:B(d,e)}:{},...u.get(_)!==void 0?{pagination:u.get(_)}:{}};o.line(`"${_}": ${se(b)},`)}}),o.line("}"),o.blank(),o.blank();let $=t.serverUrl??e.serverUrl??"";K(o,e,c,!1,u,$,i),K(o,e,c,!0,u,$,i);let h={path:V(n.path),content:o.toString()};if(t.runtime!=="module")return[h];let g=s.map(d=>`# ${d}`).join(`
|
|
10
|
+
`),v=V(n.path).replace(/[^\\/]+$/,""),P=Object.entries(L).map(([d,_])=>({path:`${v}${d}`,content:`${g}
|
|
11
|
+
|
|
12
|
+
${_.split(`
|
|
13
|
+
`).map(b=>b.startsWith("from ._")?b.replace("from ._","from _"):b).join(`
|
|
14
|
+
`).trim()}
|
|
15
|
+
`}));return[h,...P]};function de(e,n){let s=V(n.outputPath).replace(/^.*[\\/]/,"").replace(/\.py$/,""),t=I(n.model).find(a=>a.op.name===e.name)?.ident??w(e.name,{style:"snake",reserved:k}),r=[...e.pathParams.map(a=>{let c=w(a.name,{style:"snake",reserved:k});return`${c}="<${c}>"`}),...e.queryParams.filter(a=>a.required).map(a=>`${w(a.name,{style:"snake",reserved:k})}=...`),...e.requestBody?["body=..."]:[]];return{lang:"python",label:"Python SDK",source:`from ${s} import Client
|
|
16
|
+
|
|
17
|
+
client = Client()
|
|
18
|
+
result = client.${t}(${r.join(", ")})
|
|
19
|
+
`}}var Je=({model:e,output:n,emit:s,pagination:t})=>[{path:n.path.replace(/\.[^.\\/]+$/,".python.md"),content:J(e,{title:`${e.title} Python SDK reference`,frontmatter:s.docsFrontmatter===!0,language:{name:"python",label:"Python",fence:"python",requires:"The SDK needs `httpx`."},sample:r=>de(r,{model:e,emit:s,outputPath:n.path}),paginated:new Set(t?.keys()??[])})}];export{y as a,G as b,Ve as c,ze as d,de as e,Je as f};
|