@redocly/cli 2.51.0 → 2.51.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES +2 -2
- package/lib/chunks/{3XSOTIDJ.js → 2QB2GQK4.js} +1 -1
- package/lib/chunks/57HELKSP.js +11 -0
- package/lib/chunks/5FCIOXHF.js +7 -0
- package/lib/chunks/75JBXLYL.js +7 -0
- package/lib/chunks/{65LLBIQA.js → ADW6GVRA.js} +1 -1
- package/lib/chunks/{IPFRJMV6.js → AEUD4DDQ.js} +1 -1
- package/lib/chunks/BFHO7GW5.js +97 -0
- package/lib/chunks/C2P2K3EL.js +7 -0
- package/lib/chunks/{TMULAWFD.js → CHYVBQIC.js} +1 -1
- package/lib/chunks/{3JJEI7CJ.js → CQMMUWIJ.js} +99 -95
- package/lib/chunks/{MXZKXUIJ.js → D2LIZR7C.js} +1 -1
- package/lib/chunks/{B3QINORT.js → D3EE6JIC.js} +1 -1
- package/lib/chunks/{QKWUIMTP.js → D6R7VN2E.js} +1 -1
- package/lib/chunks/DV6O45KM.js +20 -0
- package/lib/chunks/F2OX5CFF.js +7 -0
- package/lib/chunks/H7GBQYOQ.js +20 -0
- package/lib/chunks/{NSKVRJLY.js → HJBZSEOJ.js} +1 -1
- package/lib/chunks/{46OWJR6X.js → HTZLTEUF.js} +1 -1
- package/lib/chunks/{CA4BPC77.js → ITXYN4EV.js} +1 -1
- package/lib/chunks/{NWMTC4AN.js → IULINGO6.js} +1 -1
- package/lib/chunks/{TKFA7G4G.js → JGDGNU3W.js} +1 -1
- package/lib/chunks/{TSB6PODJ.js → JM7BMZLD.js} +1 -1
- package/lib/chunks/{NGC5R7OH.js → JW436AQL.js} +1 -1
- package/lib/chunks/LD5MEXEL.js +10 -0
- package/lib/chunks/{73NWWLM3.js → MA3DQUED.js} +1 -1
- package/lib/chunks/{4PT55VGO.js → NEUHMRVX.js} +3 -3
- package/lib/chunks/{MONT6PMR.js → OHIVXMXU.js} +1 -1
- package/lib/chunks/OHW62OX6.js +8 -0
- package/lib/chunks/{2OHNINBQ.js → ONCO376P.js} +1 -1
- package/lib/chunks/P6UQ46OM.js +20 -0
- package/lib/chunks/POEVQHCC.js +30 -0
- package/lib/chunks/QYUMGE2L.js +9 -0
- package/lib/chunks/{XOZ4UMDG.js → RBQSJMUA.js} +1 -1
- package/lib/chunks/SK7RTQX6.js +18 -0
- package/lib/chunks/T22N7JRE.js +7 -0
- package/lib/chunks/{NIH6ZKB3.js → TMUDD3AQ.js} +1 -1
- package/lib/chunks/{WPSBZRFR.js → UJ7OYRJC.js} +1 -1
- package/lib/chunks/{HJYFWIVE.js → UW4UC7ZI.js} +2 -2
- package/lib/chunks/{KF7NA4HQ.js → V3JDIYRX.js} +1 -1
- package/lib/chunks/{PFYPTG4G.js → VZNKVS6Q.js} +1 -1
- package/lib/chunks/W62WTKL6.js +67 -0
- package/lib/chunks/{HMPJ7TN6.js → W7NMFHT5.js} +1 -1
- package/lib/chunks/{KBGRTZ3S.js → WSWUTUN2.js} +1 -1
- package/lib/chunks/{N5SXQI4I.js → XA64NLCK.js} +1 -1
- package/lib/chunks/{62X4OKFV.js → YHUS4LA4.js} +1 -1
- package/lib/chunks/{SQYP47H6.js → YOD7FLHY.js} +1 -1
- package/lib/chunks/{OKMAGS7N.js → YUQGMTD4.js} +1 -1
- package/lib/chunks/{OZMIIHFH.js → ZMAMNQ5K.js} +95 -95
- package/lib/eject-assets/generators/cli/docs.ts +1 -1
- package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
- package/lib/eject-assets/generators/cli/index.ts +2 -2
- package/lib/eject-assets/generators/cli/render.ts +1 -1
- package/lib/eject-assets/generators/go/client.ts +1 -1
- package/lib/eject-assets/generators/go/descriptor.ts +1 -1
- package/lib/eject-assets/generators/go/index.ts +2 -2
- package/lib/eject-assets/generators/go/models.ts +1 -1
- package/lib/eject-assets/generators/go/naming.ts +1 -1
- package/lib/eject-assets/generators/go/operations.ts +1 -1
- package/lib/eject-assets/generators/go/pagination.ts +1 -1
- package/lib/eject-assets/generators/go/types.ts +1 -1
- package/lib/eject-assets/generators/mock/faker.ts +1 -1
- package/lib/eject-assets/generators/mock/index.ts +2 -2
- package/lib/eject-assets/generators/mock/render.ts +1 -1
- package/lib/eject-assets/generators/mock/sample.ts +1 -1
- package/lib/eject-assets/generators/mock/values.ts +1 -1
- package/lib/eject-assets/generators/php/client.ts +1 -1
- package/lib/eject-assets/generators/php/descriptor.ts +1 -1
- package/lib/eject-assets/generators/php/index.ts +2 -2
- package/lib/eject-assets/generators/php/models.ts +1 -1
- package/lib/eject-assets/generators/php/naming.ts +1 -1
- package/lib/eject-assets/generators/php/operations.ts +1 -1
- package/lib/eject-assets/generators/php/pagination.ts +1 -1
- package/lib/eject-assets/generators/php/types.ts +1 -1
- package/lib/eject-assets/generators/python/client.ts +1 -1
- package/lib/eject-assets/generators/python/descriptor.ts +1 -1
- package/lib/eject-assets/generators/python/index.ts +2 -2
- package/lib/eject-assets/generators/python/models.ts +1 -1
- package/lib/eject-assets/generators/python/naming.ts +1 -1
- package/lib/eject-assets/generators/python/operations.ts +1 -1
- package/lib/eject-assets/generators/python/pagination.ts +1 -1
- package/lib/eject-assets/generators/python/types.ts +1 -1
- package/lib/eject-assets/generators/swr/index.ts +2 -2
- package/lib/eject-assets/generators/swr/render.ts +1 -1
- package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
- package/lib/eject-assets/generators/transformers/index.ts +2 -2
- package/lib/eject-assets/generators/transformers/render.ts +1 -1
- package/lib/eject-assets/generators/typescript/banner.ts +1 -1
- package/lib/eject-assets/generators/typescript/client.ts +1 -1
- package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/lib/eject-assets/generators/typescript/index.ts +2 -2
- package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/lib/eject-assets/generators/typescript/operations.ts +1 -1
- package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/lib/eject-assets/generators/typescript/types.ts +1 -1
- package/lib/eject-assets/generators/zod/index.ts +2 -2
- package/lib/eject-assets/generators/zod/schemas.ts +1 -1
- package/lib/index.js +8 -8
- package/package.json +1 -1
- package/lib/chunks/2L3Z5JZA.js +0 -16
- package/lib/chunks/2WUJ57QA.js +0 -9
- package/lib/chunks/45LW7ZJ2.js +0 -7
- package/lib/chunks/77VEOG4O.js +0 -57
- package/lib/chunks/7ZC3TNBP.js +0 -14
- package/lib/chunks/AQT2EJZS.js +0 -177
- package/lib/chunks/BFGFT7E3.js +0 -90
- package/lib/chunks/EOS3ZB2L.js +0 -8
- package/lib/chunks/ESNPHQEK.js +0 -93
- package/lib/chunks/FJAJ4RIU.js +0 -20
- package/lib/chunks/FVKTV62N.js +0 -20
- package/lib/chunks/KNLINRO4.js +0 -19
- package/lib/chunks/L3TZNNJJ.js +0 -13
- package/lib/chunks/L4GUU6OS.js +0 -7
- package/lib/chunks/MSRZMIR7.js +0 -22
- package/lib/chunks/NAGDQV7J.js +0 -11
- package/lib/chunks/NB54XRRU.js +0 -10
- package/lib/chunks/NSIQWNYL.js +0 -7
- package/lib/chunks/OOLLHPWT.js +0 -18
- package/lib/chunks/P37B4DI4.js +0 -42
- package/lib/chunks/QPW3IML7.js +0 -26
- package/lib/chunks/REFX2EKS.js +0 -13
- package/lib/chunks/SGBB4RNM.js +0 -11
- package/lib/chunks/SQVG3CEM.js +0 -8
- package/lib/chunks/U6E22USS.js +0 -14
- package/lib/chunks/ULV3D265.js +0 -19
- package/lib/chunks/V4SBON7Y.js +0 -7
- package/lib/chunks/X3MZMREJ.js +0 -7
- package/lib/chunks/XWZNQKXF.js +0 -30
- package/lib/chunks/YEK532UO.js +0 -67
- package/lib/chunks/ZBL4IVEW.js +0 -11
- /package/lib/chunks/{UKSQ7B5H.js → 2U6O26CV.js} +0 -0
package/lib/chunks/45LW7ZJ2.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a,b,c,d,e}from"./FVKTV62N.js";import"./NSIQWNYL.js";import"./UKSQ7B5H.js";import"./NAGDQV7J.js";import"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as phpDocs,c as phpGenerator,d as phpSample,a as phpType,b as renderPhpModels};
|
package/lib/chunks/77VEOG4O.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import"./UKSQ7B5H.js";import"./2WUJ57QA.js";import{g as m}from"./XWZNQKXF.js";import{k as l,l as c}from"./NAGDQV7J.js";import{c as b,d as $}from"./4PT55VGO.js";import"./PFYPTG4G.js";import{V as h}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import{a as C,b as S}from"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as y}from"node:path";function g(t){return(t??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function k(t){return[t.group===void 0?void 0:l(t.group),t.name].filter(Boolean).join(" ")}function R(t,e){return[t,k(e),...e.positionals.map(i=>`<${i.name}>`),...e.flags.filter(i=>i.required).map(i=>`--${i.name} <${i.type}>`),...e.body?[e.body.required?"--json '<json>'":"[--json '<json>']"]:[]].filter(i=>i!=="").join(" ")}function P(t,e){t.line("| Flag | Type | Required | Description |"),t.line("| ---- | ---- | -------- | ----------- |");for(let n of e){let i=[g(n.description),n.enum===void 0?"":`One of ${n.enum.map(r=>`\`${r}\``).join(", ")}.`,n.type==="array"?"Repeat the flag for multiple values.":""].filter(r=>r!=="").join(" ");t.line(`| \`--${n.name}\` | ${n.type} | ${n.required?"yes":"no"} | ${i} |`)}t.blank()}function A(t,e,n){if(t.line(`### \`${k(e)}\``),t.blank(),e.summary!==void 0&&(t.line(g(e.summary)),t.blank()),t.line(`\`${e.method} ${e.path}\``),t.blank(),t.line("```sh"),t.line(R(n.name,e)),t.line("```"),t.blank(),e.positionals.length>0){t.line("| Argument | Description |"),t.line("| -------- | ----------- |");for(let r of e.positionals)t.line(`| \`<${r.name}>\` | ${g(r.description)} |`);t.blank()}e.flags.length>0&&P(t,e.flags);let i=[e.body===void 0?"":`Takes a JSON body${e.body.required?" (required)":""}: \`--json '<json>'\`, \`--json @file.json\`, or \`--json @-\` for stdin.`,e.unsupportedBody===void 0?"":`Takes a \`${e.unsupportedBody}\` body, which the CLI cannot build \u2014 call this operation through the generated client instead.`,e.paginated===!0?"Paginated: `--page-all` follows every page, printing one JSON page per line.":"",e.sse===!0?"Streams server-sent events as one JSON object per line.":"",e.blob===!0?"Returns binary content, so `--output <path>` is required.":""].filter(r=>r!=="");for(let r of i)t.line(r);i.length>0&&t.blank()}function v(t,e){let n=new C;e.frontmatter&&(n.line("---"),n.line(`title: ${e.title}`),n.line("---"),n.blank()),n.line(`# ${e.title}`),n.blank(),n.line(`Generated command-line reference for \`${e.name}\`, produced from the API description by \`redocly generate-client\`.`),n.line("Re-run generation to update it \u2014 this file is not hand-edited."),n.blank(),n.line("## Usage"),n.blank(),n.line("```sh"),n.line(`${e.name} <command> [flags]`),n.line(`${e.name} --help`),n.line(`${e.name} schema <command> # request/response schemas`),n.line("```"),n.blank(),n.line("Install the file under any `bin` name: the command takes that name, and the credential variables below do not change."),n.blank(),n.line("## Global flags"),n.blank(),n.line("| Flag | Description |"),n.line("| ---- | ----------- |");let i=e.schemes.some(o=>o.kind==="bearer");for(let[o,s]of[["--server-url <url>","Override the server URL included in the client."],["--format <json\\|ndjson>","Output format."],["--dry-run","Print the prepared request, credentials redacted, without sending it."],["--page-all","Follow pagination, printing one JSON page per line."],["--output <path>","Write the response body to a file. Required for binary responses."],...i?[["--token <token>","Bearer token, overriding the environment."]]:[],["--json <json\\|@file\\|@->","Request body, inline or from a file or stdin."]])n.line(`| \`${o}\` | ${s} |`);n.blank();let r=c(e.name);if(n.line("## Credentials"),n.blank(),e.schemes.length===0)n.line("The description declares no security schemes, so no credentials are read.");else{n.line("Credentials come from the environment:"),n.blank(),n.line("| Scheme | Variable |"),n.line("| ------ | -------- |");for(let o of e.schemes){let s=o.kind==="bearer"?`\`${r}_TOKEN\` (or \`--token\`)`:o.kind==="basic"?`\`${r}_USERNAME\` and \`${r}_PASSWORD\``:`\`${r}_API_KEY_${c(o.key)}\``;n.line(`| ${o.kind} (\`${o.key}\`) | ${s} |`)}}n.blank(),n.line("## Exit codes"),n.blank(),n.line("| Code | Meaning |"),n.line("| ---- | ------- |");for(let[o,s]of[[0,"success"],[1,"API error (status other than 401 or 403)"],[2,"auth error (401 or 403)"],[3,"validation error"],[4,"usage error (unknown command or flag, bad `--json`)"]])n.line(`| ${o} | ${s} |`);n.blank(),n.line("Errors print one JSON object to stderr, so stdout stays clean for piping."),n.blank();let a=[...new Set(t.map(o=>o.group))];for(let o of a){let s=t.filter(d=>d.group===o);o===void 0?(n.line("## Commands"),n.blank()):(n.line(`## ${o}`),n.blank(),n.line(`Addressed as \`${e.name} ${l(o)} <command>\`.`),n.blank());for(let d of s)A(n,d,e)}return n.toString().replace(/\n{3,}/g,`
|
|
8
|
-
|
|
9
|
-
`).trimEnd()+`
|
|
10
|
-
`}function w(){return $["cli.ts"]}function x(){return b["cli.ts"]}var E="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function q(t){return S.snake(t).replace(/_/g,"-")}function j(t){let e=t.schema,n=e.kind==="array"?"array":e.kind==="scalar"&&(e.scalar==="integer"||e.scalar==="number")?"number":e.kind==="scalar"&&e.scalar==="boolean"?"boolean":"string";return{name:q(t.name),param:t.name,type:n,required:t.required,...e.kind==="enum"?{enum:e.values.map(String)}:{},...t.description!==void 0?{description:t.description}:{}}}function F(t){let e=t.successResponses;return e.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function N(t){return t.successResponses.find(e=>e.contentType.toLowerCase().includes("json"))?.schema}function T(t,e,n){if(n!=="flat")return{};let i=m(t,e.schemas);return"mergeBody"in i&&i.mergeBody?{merged:!0}:{}}function D(t,e,n){return n!=="flat"?{}:"collisions"in m(t,e.schemas)?{argsStyle:"grouped"}:{}}function p(t,e){let n=[];for(let i of t.services)for(let r of i.operations){let a=r.requestBody?.contentType.toLowerCase().includes("json")?r.requestBody:void 0,o=N(r);n.push({...r.tags.length>0?{group:r.tags[0]}:{},name:r.name,...r.summary!==void 0?{summary:r.summary}:{},method:r.method.toUpperCase(),path:r.path,positionals:r.pathParams.map(s=>({name:s.name,type:j(s).type,...s.description!==void 0?{description:s.description}:{}})),flags:r.queryParams.map(j),...a?{body:{required:a.required,...T(r,t,e.argsStyle)}}:{},...a===void 0&&r.requestBody!==void 0?{unsupportedBody:r.requestBody.contentType}:{},...e.pagination?.has(r.name)===!0?{paginated:!0}:{},...D(r,t,e.argsStyle),...r.sse!==void 0?{sse:!0}:{},...F(r)?{blob:!0}:{},...a!==void 0||o!==void 0?{schemas:{...a?{request:a.schema}:{},...o!==void 0?{response:o}:{}}}:{}})}return n}var U=`function isProcessEntry(): boolean {
|
|
11
|
-
if (process.argv[1] === undefined) return false;
|
|
12
|
-
try {
|
|
13
|
-
return realpathSync(fileURLToPath(import.meta.url)) === realpathSync(process.argv[1]);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (isProcessEntry()) {
|
|
19
|
-
process.exit(await run());
|
|
20
|
-
}`;function u(t,e){return JSON.stringify(t,null,e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function f(t){return t.securitySchemes.map(e=>({key:e.key,kind:e.kind==="bearer"||e.kind==="basic"?e.kind:"apiKey"}))}function _(t){return t.group===void 0?`${t.name} (keeps the bare word, so the "${t.name}" group has no help page)`:`${t.name} (run it as "${l(t.group)} ${t.name}")`}function B(t){let e=new Set(t.filter(i=>i.group).map(i=>l(i.group))),n=t.filter(i=>e.has(i.name));n.length!==0&&h.warn(`generate-client: cli reads a leading group name as the group, so ${n.length} operation(s) named after a tag resolve unusually \u2014 rename the operation or the tag: ${n.map(_).join(", ")}.
|
|
21
|
-
`)}function M(t,e){let n=p(t,{pagination:e.pagination,argsStyle:e.argsStyle});B(n);let i=f(t),r=`./${e.stem}.${e.importExt}`,a=["client","configure",...e.zodSelected?["use"]:[]];return["#!/usr/bin/env node",E,`import { readFileSync, realpathSync, writeFileSync } from "node:fs";
|
|
22
|
-
import { fileURLToPath } from "node:url";`,[`import { ${a.join(", ")} } from "${r}";`,...e.zodSelected?[`import { zodValidation } from "./${e.stem}.zod.${e.importExt}";`]:[]].join(`
|
|
23
|
-
`),e.runtime==="module"?`import { invokedName, runCli, type CliCommand, type CliWiring } from "./runtime/cli.${e.importExt}";`:`// \u2500\u2500\u2500 Embedded cli engine (@redocly/client-generator) \u2500\u2500\u2500
|
|
24
|
-
`+w(),`export const COMMANDS: CliCommand[] = ${u(n,2)};`,...e.zodSelected?['use(zodValidation(process.argv.includes("--dry-run") ? { response: false } : {}));']:[],`export const wiring: CliWiring = {
|
|
25
|
-
name: invokedName(process.argv[1], ${u(e.stem)}),
|
|
26
|
-
envPrefix: ${u(c(e.stem))},
|
|
27
|
-
client,
|
|
28
|
-
${e.argsStyle==="flat"?` argsStyle: "flat",
|
|
29
|
-
`:""} configure,
|
|
30
|
-
schemes: ${u(i)},
|
|
31
|
-
env: process.env,
|
|
32
|
-
stdin: () => readFileSync(0, "utf-8"),
|
|
33
|
-
readFile: (path: string) => readFileSync(path, "utf-8"),
|
|
34
|
-
writeFile: (path: string, data: Uint8Array) => writeFileSync(path, data),
|
|
35
|
-
stdout: (line: string) => console.log(line),
|
|
36
|
-
stderr: (line: string) => console.error(line),
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/** Run this CLI programmatically; defaults to the process argv. */
|
|
40
|
-
export const run = (argv: string[] = process.argv.slice(2)): Promise<number> =>
|
|
41
|
-
runCli(COMMANDS, wiring, argv);
|
|
42
|
-
|
|
43
|
-
// Re-exported so a composed entry can run these commands without its own runtime copy.
|
|
44
|
-
export { runCli };
|
|
45
|
-
|
|
46
|
-
// Self-execute only as the process entry, so importing this module is side-effect-safe:
|
|
47
|
-
// composed binaries and login-style wrappers import COMMANDS/wiring/run instead of
|
|
48
|
-
// editing this generated file.
|
|
49
|
-
${U}`].join(`
|
|
50
|
-
|
|
51
|
-
`)+`
|
|
52
|
-
`}var ne=({model:t,output:e,banner:n,emit:i,selected:r,pagination:a})=>{let o=M(t,{stem:e.stem,importExt:i.importExt??"js",zodSelected:r?.includes("zod")??!1,pagination:a,argsStyle:i.argsStyle??"grouped",runtime:i.runtime??"inline"}),s={path:y(e.dir,`${e.stem}.cli.ts`),content:o};if(i.runtime!=="module")return[s];let d=n.map(O=>`// ${O}`).join(`
|
|
53
|
-
`);return[s,{path:y(e.dir,"runtime","cli.ts"),content:`${d}
|
|
54
|
-
|
|
55
|
-
${x().trim()}
|
|
56
|
-
`}]},te=({model:t,output:e,emit:n,pagination:i})=>{let r=v(p(t,{pagination:i}),{title:`${t.title} command-line reference`,frontmatter:n.docsFrontmatter===!0,name:e.stem,schemes:f(t)});return[{path:y(e.dir,`${e.stem}.cli.md`),content:r}]};function re(t,e){let n=p(e.model,{pagination:e.pagination}).find(r=>r.name===t.name);return n===void 0?void 0:{lang:"shell",label:"CLI",source:`npx tsx client.cli.ts ${["client",...n.group?[l(n.group)]:[],n.name,...n.positionals.map(r=>`<${r.name}>`),...n.flags.filter(r=>r.required).map(r=>`--${r.name} <${r.type}>`),...n.body?["--json '<json>'"]:[]].slice(1).join(" ")}
|
|
57
|
-
`}}export{te as cliDocs,ne as cliGenerator,re as cliSample};
|
package/lib/chunks/7ZC3TNBP.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as S,b as d}from"./REFX2EKS.js";import{a as C}from"./UKSQ7B5H.js";import{b as H,c as D,d as G,e as K,f as J,g as z,h as Q}from"./NAGDQV7J.js";import"./4PT55VGO.js";import{a as j}from"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{b as A,c as I,d as v,e as L,g as E,h as x,i as B,j as F,k as W,n as _}from"./HJYFWIVE.js";import"./RFWIIJFG.js";var c=new S,b=I.go;function V(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||b.has(e))throw new j(`goPackage "${e}" is not a valid Go package name: use lowercase letters, digits, and underscores, don't start with a digit, and avoid Go keywords.`);return e}function w(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let a=d(o.name),i=2;for(;t.has(a);)a=`${d(o.name)}${i++}`;t.add(a),n.push({op:o,ident:a})}return n}function oe(e){return J(e).map(n=>n.kind==="literal"?c.string(n.value):v(n.name,{style:"camel",reserved:b})).join(" + ")}function X(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,a)=>{let i=`${d(o.description??`server${a+1}`)}URL`;r.has(i)&&(i=`${i}${a+1}`),r.add(i);let s=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} string`),u=o.variables.map(l=>`${v(l.name,{style:"camel",reserved:b})} default: ${c.string(l.default)}`).join(", ");e.line(`// ${i} returns the ${c.string(o.description??o.url)} base URL${u===""?".":` (${u}).`}`),e.block(`func ${i}(${s.join(", ")}) string {`,()=>{e.line(`return ${oe(o)}`)},"}"),e.blank()})}function Y(e,t){let n=z(e,t).map(r=>r.map(o=>o.kind==="apiKey"?`{Scheme: ${c.string(o.scheme)}, Kind: "apiKey", Name: ${c.string(o.name)}, In: ${c.string(o.in)}}`:`{Scheme: ${c.string(o.scheme)}, Kind: ${c.string(o.kind)}}`));if(n.length!==0)return`[][]SecuritySpec{${n.map(r=>`{${r.join(", ")}}`).join(", ")}}`}function Z(e){return`&PaginationSpec{${[`Style: ${c.string(e.style)}`,...e.param!==void 0?[`Param: ${c.string(e.param)}`]:[],...e.nextCursor!==void 0?[`NextCursor: ${c.string(e.nextCursor)}`]:[],...e.hasMore!==void 0?[`HasMore: ${c.string(e.hasMore)}`]:[],...e.limitParam!==void 0?[`LimitParam: ${c.string(e.limitParam)}`]:[],...e.items!==void 0?[`Items: ${c.string(e.items)}`]:[]].join(", ")}}`}function g(e,t="string"){if(B(e)){let n=g(F(e),t);return n.startsWith("*")||n==="any"?n:`*${n}`}switch(e.kind){case"scalar":if(t==="Date"&&e.scalar==="string"){if(e.metadata?.format==="date-time")return"time.Time";if(e.metadata?.format==="date")return"Date"}return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"array":return`[]${g(e.items,t)}`;case"record":return`map[string]${g(e.value,t)}`;case"ref":return d(e.name);case"literal":return typeof e.value=="string"?"string":typeof e.value=="boolean"?"bool":"float64";case"enum":return{string:"string",integer:"int64",number:"float64",boolean:"bool"}[e.scalar];case"omit":return d(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ae(e,t,n,r,o){e.doc(d(t),o),e.block(`type ${d(t)} struct {`,()=>{for(let a of n){let i=d(a.name),s=g(a.schema,r),u=`\`json:"${a.name}"\``;a.required||(!s.startsWith("*")&&!s.startsWith("[]")&&!s.startsWith("map[")&&s!=="any"&&(s=`*${s}`),u=`\`json:"${a.name},omitempty"\``),e.line(`${i} ${s} ${u}`)}},"}"),e.blank()}function N(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:a})=>x(a,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=ie(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function ie(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let a=W(o);if(a!==void 0){let s=a.scalar==="string"?"string":"int64";n.doc(d(r),o.description),n.line(`type ${d(r)} ${s}`),n.blank(),n.block("const (",()=>{let u=new Set;a.values.forEach(l=>{let f=A.pascal(String(l))||"Value",m="";for(let k=2;u.has(f+m);k++)m=String(k);u.add(f+m);let h=d(r)+f+m;n.line(`${h} ${d(r)} = ${c.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let s=E(o,e);if(s!==void 0){ae(n,r,s.properties,t,s.description??o.description);continue}}let i=x(o,e);if(i!==void 0){let s=d(r),u=i.cases.map(l=>`${l.value} -> ${d(l.schemaName)}`).join(", ");n.line(`// ${s} is a discriminated union ("${i.property}"): ${u}.`),n.line(`type ${s} = any`),n.blank(),n.line(`// Unmarshal${s} decodes into the member selected by "${i.property}".`),n.block(`func Unmarshal${s}(data []byte) (${s}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${i.property}"\``)},"}"),n.block("if err := json.Unmarshal(data, &probe); err != nil {",()=>{n.line("return nil, err")},"}"),n.line("switch probe.Discriminant {");for(let l of i.cases)n.block(`case ${c.string(l.value)}:`,()=>{n.line(`var value ${d(l.schemaName)}`),n.line("err := json.Unmarshal(data, &value)"),n.line("return value, err")});n.line("}"),n.line("var fallback any"),n.line("err := json.Unmarshal(data, &fallback)"),n.line("return fallback, err")},"}"),n.blank();continue}n.doc(d(r),o.description),n.line(`type ${d(r)} = ${g(o,t)}`),n.blank()}return n.toString()}function R(e,t){if(t==="string")return e;let n=e.startsWith("*")?`(${e})`:e;return t==="time.Time"?`${n}.Format(time.RFC3339)`:t==="Date"?`${n}.Format("2006-01-02")`:t==="int64"?`strconv.FormatInt(${e}, 10)`:t==="float64"?`strconv.FormatFloat(${e}, 'f', -1, 64)`:t==="bool"?`strconv.FormatBool(${e})`:`fmt.Sprint(${e})`}var se=["c","ctx","body","params","out","op"];function T(e,t){let n=L(e.pathParams.map(r=>r.name),{style:"camel",reserved:b,taken:se});return e.pathParams.map((r,o)=>({param:r,go:n[o],type:g(r.schema,t)}))}function le(e,t){let n=new Set;return(e.successResponseHeaders??[]).map(r=>{let o=d(r.name),a=o,i=2;for(;n.has(a);)a=`${o}${i++}`;n.add(a);let s=_(r.schema,t),u={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[s];return{field:a,name:r.name,...u}})}function U(e,t,n,r,o,a=!1){let i=T(t,r),s=t.queryParams.length>0,u=D(t),l=u===void 0?void 0:g(u,r),f=a?le(t,o):[];a&&(e.line(`// ${n}Headers carries the declared response headers of ${n}WithHeaders (nil when absent or unparsable).`),e.block(`type ${n}Headers struct {`,()=>{for(let p of f)e.line(`${p.field} ${p.goType}`)},"}"),e.blank());let m=["ctx context.Context",...i.map(({go:p,type:P})=>`${p} ${P}`),...t.requestBody?[`body ${g(t.requestBody.schema,r)}`]:[],...s?[`params *${n}Params`]:[]],h=G(t),k=a?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:h!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,$=p=>a?l===void 0?`return headers, ${p}`:`return out, headers, ${p}`:l===void 0?`return ${p}`:`return out, ${p}`,M=a?`${n}WithHeaders`:n;e.doc(M,a?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${M}(${m.join(", ")}) ${k} {`,()=>{h===void 0&&l!==void 0&&e.line(`var out ${l}`),a&&e.line(`var headers ${n}Headers`),e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),s&&e.block("if params != nil {",()=>{for(let y of t.queryParams){let O=d(y.name);e.block(`if params.${O} != nil {`,()=>{if(y.schema.kind==="array"){let q=g(y.schema.items,r);e.block(`for _, item := range *params.${O} {`,()=>{e.line(`query.Add(${c.string(y.name)}, ${R("item",q)})`)},"}")}else e.line(`query.Set(${c.string(y.name)}, ${R(`*params.${O}`,g(y.schema,r))})`)},"}")}},"}");let p=i.map(({param:y,go:O,type:q})=>`${c.string(y.name)}: ${R(O,q)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${p}})`),h!==void 0){e.block("open := func(extraHeaders map[string]string) (*http.Response, error) {",()=>{e.line("merged := map[string]string{}"),e.block("for key, value := range authHeaders {",()=>{e.line("merged[key] = value")},"}"),e.block("for key, value := range extraHeaders {",()=>{e.line("merged[key] = value")},"}"),e.line("return send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: merged, Query: query})")},"}"),e.line(`return iterSSE(open, ${h.schema!==void 0&&h.schema.kind!=="unknown"})`);return}let P=["OperationID: op.ID","Method: op.Method","URL: requestURL","Headers: authHeaders","Query: query"];if(t.requestBody&&K(t)?(e.line("contentType, reader, err := toMultipart(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: reader"),P.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line($("err"))},"}"),P.push("Body: bytes.NewReader(payload)"),P.push(`ContentType: ${c.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${P.join(", ")}})`),e.block("if err != nil {",()=>{e.line($("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line($("apiErrorFrom(resp, requestURL)"))},"}"),a){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line($("err"))},"}");for(let y of f)e.line(`headers.${y.field} = ${y.helper}(resp.Header, ${c.string(y.name)})`);e.line(l===void 0?"return headers, nil":"return out, headers, nil")}else l===void 0?e.line("return decodeJSON(resp, nil)"):(e.block("if err := decodeJSON(resp, &out); err != nil {",()=>{e.line("return out, err")},"}"),e.line("return out, nil"))},"}"),e.blank()}function ee(e,t,n,r,o,a){let i=T(t,r),s=t.queryParams.length>0,u=["ctx context.Context",...i.map(({go:f,type:m})=>`${f} ${m}`),...s?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),s&&e.block("if params != nil {",()=>{for(let f of t.queryParams){let m=d(f.name);e.block(`if params.${m} != nil {`,()=>{e.line(`base.Set(${c.string(f.name)}, ${R(`*params.${m}`,g(f.schema,r))})`)},"}")}},"}"),e.block("call := func(pageParams url.Values) (any, *http.Response, error) {",()=>{e.line("authHeaders, query := resolveAuth(op.Security, c.config.Auth)"),e.block("for key, values := range pageParams {",()=>{e.block("for _, value := range values {",()=>{e.line("query.Set(key, value)")},"}")},"}");let f=i.map(({param:m,go:h,type:k})=>`${c.string(m.name)}: ${R(h,k)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${f}})`),e.line("resp, err := send(ctx, &c.config, requestSpec{OperationID: op.ID, Method: op.Method, URL: requestURL, Headers: authHeaders, Query: query})"),e.block("if err != nil {",()=>{e.line("return nil, nil, err")},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line("return nil, resp, apiErrorFrom(resp, requestURL)")},"}"),e.line("var raw any"),e.block("if err := decodeJSON(resp, &raw); err != nil {",()=>{e.line("return nil, resp, err")},"}"),e.line("return raw, resp, nil")},"}"),e.line("pages := iterPages(call, *op.Pagination, base)")};e.line(`// ${n}Pages iterates ${n} response pages; use with \`for page, err := range\`.`),e.block(`func (c *Client) ${n}Pages(${u}) func(yield func(${o}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${o}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.line(`var page ${o}`),e.block("if err == nil {",()=>{e.line("err = reencode(raw, &page)")},"}"),e.line("return yield(page, err)")},"})")},"}")},"}"),e.blank(),e.line(`// ${n}Items iterates the items of every ${n} page.`),e.block(`func (c *Client) ${n}Items(${u}) func(yield func(${a}, error) bool) {`,()=>{l(),e.block(`return func(yield func(${a}, error) bool) {`,()=>{e.block("pages(func(raw any, err error) bool {",()=>{e.block("if err != nil {",()=>{e.line(`var zero ${a}`),e.line("return yield(zero, err)")},"}"),e.line("pageItems, _ := resolvePointer(raw, op.Pagination.Items).([]any)"),e.block("for _, item := range pageItems {",()=>{e.line(`var typed ${a}`),e.block("if err := reencode(item, &typed); err != nil {",()=>{e.line("return yield(typed, err)")},"}"),e.block("if !yield(typed, nil) {",()=>{e.line("return false")},"}")},"}"),e.line("return true")},"})")},"}")},"}"),e.blank()}function ne(e){let t=e.split(`
|
|
8
|
-
`),n=[],r=!1;for(let o of t)if(!o.startsWith("package ")){if(o.startsWith("import (")){r=!0;continue}if(r){o.startsWith(")")&&(r=!1);continue}o.startsWith("import ")||n.push(o)}return n.join(`
|
|
9
|
-
`).trim()}var te=["bytes","context","encoding/base64","encoding/json","errors","fmt","io","math/rand","mime/multipart","net/http","net/url","strconv","strings","time"];function re(e,t,n,r,o,a){e.line(ne(N(t,r))),e.blank(),X(e,t),a&&(e.line("// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator go runtime) \u2500\u2500\u2500"),e.line(ne(C)),e.blank()),e.block("type operationMeta struct {",()=>{e.line("ID string"),e.line("Method string"),e.line("Path string"),e.line("Security [][]SecuritySpec"),e.line("Pagination *PaginationSpec")},"}"),e.blank(),e.block("var operations = map[string]operationMeta{",()=>{for(let{op:i,ident:s}of w(t)){let u=i.specName??i.name,l=Y(i,t),f=o.get(s),m=[`ID: ${c.string(u)}`,`Method: ${c.string(i.method.toUpperCase())}`,`Path: ${c.string(i.path)}`,...l!==void 0?[`Security: ${l}`]:[],...f!==void 0?[`Pagination: ${Z(f)}`]:[]];e.line(`${c.string(u)}: {${m.join(", ")}},`)}},"}"),e.blank();for(let{op:i,ident:s}of w(t))i.queryParams.length!==0&&(e.block(`type ${s}Params struct {`,()=>{for(let u of i.queryParams){let l=g(u.schema,r);e.line(`${d(u.name)} ${l.startsWith("*")?l:`*${l}`}`)}},"}"),e.blank());e.doc("Client",`Client for ${t.title} (${t.version}).`),e.block("type Client struct {",()=>{e.line("config Config")},"}"),e.blank(),e.block("func New(config Config) *Client {",()=>{e.block('if config.ServerURL == "" {',()=>{e.line(`config.ServerURL = ${c.string(n.serverUrl??t.serverUrl??"")}`)},"}"),e.line("return &Client{config: config}")},"}"),e.blank();for(let{op:i,ident:s}of w(t)){U(e,i,s,r),G(i)===void 0&&(i.successResponseHeaders?.length??0)>0&&U(e,i,s,r,t,!0);let u=o.get(s);if(u===void 0)continue;let l=D(i),f=l===void 0?"any":g(l,r),m=Q(l,u.items,t);ee(e,i,s,r,f,m===void 0?"any":g(m,r))}}var ze=({model:e,output:t,banner:n,emit:r,pagination:o})=>{let a=new S,i=r.dateType??"string",s=V(r.goPackage),u=new Map;for(let{op:$,ident:M}of w(e)){let p=o?.get($.name)?.spec;p!==void 0&&u.set(M,p)}a.line(`// Code generated by @redocly/client-generator (go) from "${e.title}" ${e.version}. DO NOT EDIT.`),a.line("// Regenerate with `redocly generate-client`. Standard library only \u2014 zero dependencies."),a.line(`package ${s}`),a.blank();let l=r.runtime!=="module",f=l?te:(()=>{let $=new S;re($,e,r,i,u,!1);let M=$.toString();return te.filter(p=>new RegExp(`\\b${p.split("/").pop()}\\.`).test(M))})();a.block("import (",()=>{for(let $ of f)a.line(c.string($))},")"),a.blank(),re(a,e,r,i,u,l);let m={path:t.path.replace(/\.[^.\\/]+$/,".go"),content:a.toString()};if(l)return[m];let h=n.map($=>`// ${$}`).join(`
|
|
10
|
-
`),k=C.replace(/^package .*$/m,`package ${s}`);return[m,{path:m.path.replace(/[^\\/]+$/,"runtime.go"),content:`${h}
|
|
11
|
-
${k.trimEnd()}
|
|
12
|
-
`}]};function ce(e,t){let n=t.emit.dateType??"string",r=t.emit.goPackage??"client",o=w(t.model).find(u=>u.op.name===e.name)?.ident??d(e.name),a=["ctx",...e.pathParams.map(u=>`"<${v(u.name,{style:"camel",reserved:b})}>"`),...e.requestBody?[`${g(e.requestBody.schema,n)}{ /* \u2026 */ }`]:[],...e.queryParams.length>0?["nil"]:[]],i=`client.${o}(${a.join(", ")})`,s=G(e)!==void 0?`stream := ${i}`:D(e)===void 0?`err := ${i}`:`result, err := ${i}`;return{lang:"go",label:"Go SDK",source:`client := ${r}.New(${r}.Config{})
|
|
13
|
-
${s}
|
|
14
|
-
`}}var Qe=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".go.md"),content:H(e,{title:`${e.title} Go SDK reference`,frontmatter:n.docsFrontmatter===!0,language:{name:"go",label:"Go",fence:"go",requires:"The SDK needs the standard library only."},sample:o=>ce(o,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];export{Qe as goDocs,ze as goGenerator,ce as goSample,g as goType,N as renderGoModels};
|
package/lib/chunks/AQT2EJZS.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import"./NAGDQV7J.js";import{a as h}from"./4PT55VGO.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import{e as g,h as p,k as y}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as M}from"node:path";var a=" ";function f(e){return`${y(e)}Schema`}var x=new Map;function u(e,r=x,t=""){return k(w(e,r,t),e)}function w(e,r,t){switch(e.kind){case"scalar":return S(e.scalar,e.metadata);case"object":return b(e.properties,r,t);case"array":return`z.array(${u(e.items,r,t)})`;case"record":return`z.record(z.string(), ${u(e.value,r,t)})`;case"ref":return`z.lazy(() => ${f(e.name)})`;case"literal":return`z.literal(${p(e.value)})`;case"enum":return z(e.values);case"union":return E(e.members,r,t);case"intersection":return e.members.map(n=>u(n,r,t)).reduce((n,o)=>`${n}.and(${o})`);case"null":return"z.null()";case"unknown":return"z.unknown()";case"omit":return q(e.base,e.keys,r,t)}}function S(e,r){switch(e){case"string":return r?.format==="binary"?"z.instanceof(Blob)":"z.string()";case"integer":return"z.number().int()";case"number":return"z.number()";case"boolean":return"z.boolean()"}}function c(e){return g(e)===e?e:JSON.stringify(e)}function b(e,r,t){if(e.length===0)return"z.object({})";let n=t+a;return`z.object({
|
|
8
|
-
${e.map((s,i)=>{let d=u(s.schema,r,n),l=s.required?d:`${d}.optional()`,v=i===e.length-1?"":",";return`${n}${c(s.name)}: ${l}${v}`}).join(`
|
|
9
|
-
`)}
|
|
10
|
-
${t}})`}function z(e){return e.every(r=>typeof r=="string")?`z.enum([${e.map(r=>JSON.stringify(r)).join(", ")}])`:`z.union([${e.map(r=>`z.literal(${p(r)})`).join(", ")}])`}function E(e,r,t){let n=e.map(o=>u(o,r,t));return n.length===1?n[0]:`z.union([${n.join(", ")}])`}function q(e,r,t,n){let o=t.get(e);if(o&&o.kind!=="object")return u(m(o,r,t,new Set([e])),t,n);let s=r.map(i=>`${c(i)}: true`).join(", ");return`${f(e)}.omit({ ${s} })`}function m(e,r,t,n){switch(e.kind){case"object":return{...e,properties:e.properties.filter(o=>!r.includes(o.name))};case"union":case"intersection":return{...e,members:e.members.map(o=>m(o,r,t,n))};case"ref":{if(n.has(e.name))return e;let o=t.get(e.name);if(!o)return e;if(o.kind==="object"){let s=r.filter(i=>o.properties.some(d=>d.name===i));return s.length>0?{kind:"omit",base:e.name,keys:s}:e}return m(o,r,t,new Set([...n,e.name]))}default:return e}}function k(e,r){let t=r.metadata;if(!t)return e;let n=e;return r.kind==="scalar"&&r.scalar==="string"&&(t.minLength!==void 0&&(n=`${n}.min(${t.minLength})`),t.maxLength!==void 0&&(n=`${n}.max(${t.maxLength})`),t.pattern!==void 0&&(n=`${n}.regex(new RegExp(${JSON.stringify(t.pattern)}))`)),r.kind==="scalar"&&(r.scalar==="number"||r.scalar==="integer")&&(t.minimum!==void 0&&(n=`${n}.min(${t.minimum})`),t.maximum!==void 0&&(n=`${n}.max(${t.maximum})`),t.exclusiveMinimum!==void 0&&(n=`${n}.gt(${t.exclusiveMinimum})`),t.exclusiveMaximum!==void 0&&(n=`${n}.lt(${t.exclusiveMaximum})`)),r.kind==="array"&&(t.minItems!==void 0&&(n=`${n}.min(${t.minItems})`),t.maxItems!==void 0&&(n=`${n}.max(${t.maxItems})`)),n}function j(e,r){let t=[];for(let n of h(e.services)){if(n.sse!==void 0)continue;let o=n.requestBody,s=o&&o.contentType.toLowerCase().includes("json")?u(o.schema,r,a):void 0,i=n.successResponses.find(l=>l.contentType.toLowerCase().includes("json")),d=i?u(i.schema,r,a):void 0;!s&&!d||t.push({name:n.specName??n.name,request:s,response:d})}return t}function Z(e){let r=e.flatMap(n=>[`${a}${c(n.name)}: {`,...n.request?[`${a}${a}request: z.ZodType;`]:[],...n.response?[`${a}${a}response: z.ZodType;`]:[],`${a}};`]),t=e.map((n,o)=>{let s=[...n.request?[`request: ${n.request}`]:[],...n.response?[`response: ${n.response}`]:[]].join(", "),i=o===e.length-1?"":",";return`${a}${c(n.name)}: { ${s} }${i}`});return["/**"," * Request/response validators by operationId \u2014 powers `zodValidation`, or import one directly."," */","export const operationSchemas: {",...r,"} = {",...t,"};"].join(`
|
|
11
|
-
`)}var I=`/** \`request\`/\`response\` validators for one operation (an absent side is not validated). */
|
|
12
|
-
export type OperationSchemaSet = { request?: z.ZodType; response?: z.ZodType };
|
|
13
|
-
|
|
14
|
-
const schemaIndex: Partial<Record<string, OperationSchemaSet>> = operationSchemas;
|
|
15
|
-
|
|
16
|
-
/** One flattened validation problem: the full nested path and a short preview of the value. */
|
|
17
|
-
export type ZodViolation = { path: string; message: string; received: string };
|
|
18
|
-
|
|
19
|
-
/** A request or response payload failed validation. Requests throw it; response handling is configurable. */
|
|
20
|
-
export class ZodValidationError extends Error {
|
|
21
|
-
// Declared and assigned in the body, NOT as constructor parameter properties: those
|
|
22
|
-
// need a transform, so they break \`node --experimental-strip-types\` for anything
|
|
23
|
-
// importing this module (the generated CLI runs that way).
|
|
24
|
-
readonly operationId: string;
|
|
25
|
-
readonly direction: "request" | "response";
|
|
26
|
-
readonly issues: z.ZodError["issues"];
|
|
27
|
-
readonly violations: ZodViolation[];
|
|
28
|
-
|
|
29
|
-
constructor(
|
|
30
|
-
operationId: string,
|
|
31
|
-
direction: "request" | "response",
|
|
32
|
-
issues: z.ZodError["issues"],
|
|
33
|
-
violations: ZodViolation[]
|
|
34
|
-
) {
|
|
35
|
-
const detail = violations
|
|
36
|
-
.slice(0, 5)
|
|
37
|
-
.map((violation) => \`\${violation.path || "(root)"}: \${violation.message} (received \${violation.received})\`)
|
|
38
|
-
.join("; ");
|
|
39
|
-
const more = violations.length > 5 ? \`; \u2026and \${violations.length - 5} more\` : "";
|
|
40
|
-
super(\`\${direction === "request" ? "Request" : "Response"} validation failed for operation "\${operationId}": \${detail}\${more}\`);
|
|
41
|
-
this.operationId = operationId;
|
|
42
|
-
this.direction = direction;
|
|
43
|
-
this.issues = issues;
|
|
44
|
-
this.violations = violations;
|
|
45
|
-
this.name = "ZodValidationError";
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Flatten zod issues into leaf violations. Union branches (zod 3 \`unionErrors\`, zod 4
|
|
50
|
-
// nested \`errors\`) are recursed into, so the message names the actual failing fields
|
|
51
|
-
// instead of just the union root ("Invalid input").
|
|
52
|
-
function flattenIssues(
|
|
53
|
-
issues: z.ZodError["issues"],
|
|
54
|
-
value: unknown,
|
|
55
|
-
base: PropertyKey[] = []
|
|
56
|
-
): ZodViolation[] {
|
|
57
|
-
const violations: ZodViolation[] = [];
|
|
58
|
-
for (const issue of issues) {
|
|
59
|
-
const path = [...base, ...issue.path];
|
|
60
|
-
const nested = nestedIssueLists(issue);
|
|
61
|
-
if (nested.length > 0) {
|
|
62
|
-
for (const sub of nested) violations.push(...flattenIssues(sub, value, path));
|
|
63
|
-
} else {
|
|
64
|
-
violations.push({
|
|
65
|
-
path: path.map(String).join("."),
|
|
66
|
-
message: issue.message,
|
|
67
|
-
received: preview(valueAt(value, path)),
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return violations;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** The nested issue lists of a union-ish issue, across zod 3 (\`unionErrors\`) and zod 4 (\`errors\`). */
|
|
75
|
-
function nestedIssueLists(issue: unknown): Array<z.ZodError["issues"]> {
|
|
76
|
-
const candidate = issue as {
|
|
77
|
-
unionErrors?: Array<{ issues: z.ZodError["issues"] }>;
|
|
78
|
-
errors?: Array<z.ZodError["issues"]>;
|
|
79
|
-
};
|
|
80
|
-
if (Array.isArray(candidate.unionErrors)) return candidate.unionErrors.map((error) => error.issues);
|
|
81
|
-
if (Array.isArray(candidate.errors)) return candidate.errors;
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function valueAt(value: unknown, path: PropertyKey[]): unknown {
|
|
86
|
-
let current = value;
|
|
87
|
-
for (const key of path) {
|
|
88
|
-
if (current === null || typeof current !== "object") return undefined;
|
|
89
|
-
current = (current as Record<PropertyKey, unknown>)[key];
|
|
90
|
-
}
|
|
91
|
-
return current;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** A short single-line preview of the offending value. NOTE: validation output can surface
|
|
95
|
-
* payload data \u2014 route \`onViolation\` to a scrubbed logger when responses may carry secrets. */
|
|
96
|
-
function preview(value: unknown): string {
|
|
97
|
-
let text: string;
|
|
98
|
-
try {
|
|
99
|
-
text = JSON.stringify(value) ?? String(value);
|
|
100
|
-
} catch {
|
|
101
|
-
text = String(value);
|
|
102
|
-
}
|
|
103
|
-
return text.length > 80 ? \`\${text.slice(0, 77)}\u2026\` : text;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type ZodValidationOptions = {
|
|
107
|
-
/** Validate request bodies before any network call; a failure THROWS (it is the caller's own bug). Default: true. */
|
|
108
|
-
request?: boolean;
|
|
109
|
-
/** Replace the outgoing body with the parsed result, dropping keys the schema does not declare
|
|
110
|
-
* (for strict-DTO servers that 400 on excess properties). Runs request validation. Default: false. */
|
|
111
|
-
stripRequestBodies?: boolean;
|
|
112
|
-
/** Response drift handling: \`"warn"\` (default) reports via \`onViolation\` and lets the call
|
|
113
|
-
* succeed \u2014 a server drifting from its description should not crash the consumer;
|
|
114
|
-
* \`"throw"\` fails the call (even on result-mode clients); \`false\` skips response validation. */
|
|
115
|
-
response?: "warn" | "throw" | false;
|
|
116
|
-
/** Sink for \`"warn"\` mode. Default: \`console.warn\` with the error message. */
|
|
117
|
-
onViolation?: (error: ZodValidationError) => void;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Schema-validation middleware for the generated client: \`use(zodValidation())\`.
|
|
122
|
-
* Request bodies are validated before any network call and throw on failure; successful
|
|
123
|
-
* JSON responses are validated against the operation's response schema and WARN by
|
|
124
|
-
* default (see \`ZodValidationOptions.response\`). Operations without a schema pass
|
|
125
|
-
* through untouched. Payloads are never mutated unless \`stripRequestBodies\` is set.
|
|
126
|
-
*/
|
|
127
|
-
export function zodValidation(options: ZodValidationOptions = {}) {
|
|
128
|
-
const { request = true, stripRequestBodies = false, response = "warn", onViolation } = options;
|
|
129
|
-
const report = onViolation ?? ((error: ZodValidationError) => console.warn(error.message));
|
|
130
|
-
return {
|
|
131
|
-
onRequest(context: { body?: unknown; operation: { id: string } }): void {
|
|
132
|
-
if ((!request && !stripRequestBodies) || context.body === undefined) return;
|
|
133
|
-
const schema = schemaIndex[context.operation.id]?.request;
|
|
134
|
-
if (!schema) return;
|
|
135
|
-
const result = schema.safeParse(context.body);
|
|
136
|
-
if (!result.success) {
|
|
137
|
-
throw new ZodValidationError(
|
|
138
|
-
context.operation.id,
|
|
139
|
-
"request",
|
|
140
|
-
result.error.issues,
|
|
141
|
-
flattenIssues(result.error.issues, context.body)
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
// zod object schemas drop undeclared keys during parsing, so the parsed value
|
|
145
|
-
// IS the declared shape (intersections keep their own zod semantics).
|
|
146
|
-
if (stripRequestBodies) context.body = result.data;
|
|
147
|
-
},
|
|
148
|
-
async onResponse(incoming: Response, context: { operation: { id: string } }): Promise<void> {
|
|
149
|
-
if (response === false || !incoming.ok) return;
|
|
150
|
-
const schema = schemaIndex[context.operation.id]?.response;
|
|
151
|
-
if (!schema) return;
|
|
152
|
-
const contentType = (incoming.headers.get("content-type") ?? "").toLowerCase();
|
|
153
|
-
if (!contentType.includes("json")) return;
|
|
154
|
-
const payload: unknown = await incoming.clone().json();
|
|
155
|
-
const result = schema.safeParse(payload);
|
|
156
|
-
if (!result.success) {
|
|
157
|
-
const error = new ZodValidationError(
|
|
158
|
-
context.operation.id,
|
|
159
|
-
"response",
|
|
160
|
-
result.error.issues,
|
|
161
|
-
flattenIssues(result.error.issues, payload)
|
|
162
|
-
);
|
|
163
|
-
if (response === "throw") throw error;
|
|
164
|
-
report(error);
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
}`;function $(e){let r=new Map(e.schemas.map(o=>[o.name,o.schema])),t=j(e,r);if(e.schemas.length===0&&t.length===0)return"";let n=['import { z } from "zod";',...e.schemas.map(o=>`export const ${f(o.name)} = ${u(o.schema,r)};`)];return t.length===0?n.join(`
|
|
169
|
-
|
|
170
|
-
`):(n.push(Z(t)),`${n.join(`
|
|
171
|
-
|
|
172
|
-
`)}
|
|
173
|
-
${I}
|
|
174
|
-
`)}var T=({model:e,output:r,banner:t})=>{let n=$(e);if(n==="")return[];let o=t.map(s=>`// ${s}`).join(`
|
|
175
|
-
`);return[{path:M(r.dir,`${r.stem}.zod.ts`),content:`${o}
|
|
176
|
-
|
|
177
|
-
${n}`}]};export{T as zodGenerator};
|
package/lib/chunks/BFGFT7E3.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{b as D,g as L}from"./NAGDQV7J.js";import{a as h,c as F,d as J,e as U}from"./4PT55VGO.js";import{a as _,d as G,e as x,f as R,h as K,i as O,j as Q,k as b,l as V,m as z}from"./NB54XRRU.js";import{n as H}from"./HJYFWIVE.js";import{join as Se}from"node:path";var q="// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";function N(e){return e.filter(t=>t.length>0).join(`
|
|
8
|
-
|
|
9
|
-
`)+`
|
|
10
|
-
`}function v(e){let t=["/**",` * ${O(`${e.title} (v${e.version})`)}`];if(e.description)for(let n of z(O(e.description)))t.push(` * ${n}`.replace(/ +$/,""));return t.push(" */"),t.join(`
|
|
11
|
-
`)}function P(e){return e.contentType==="multipart/form-data"&&e.schema.kind==="object"}function k(e){let t=new Map(e.pathParams.map(r=>[r.name,r])),n=[];for(let r of e.path.matchAll(/\{([^{}]+)\}/g)){let s=t.get(r[1]);s!==void 0&&n.push(s)}return n}function W(e){let t=k(e),n=e.queryParams.length>0,r=!!e.requestBody,s=e.headerParams.length>0,o=e.cookieParams.length>0;return{hasQuery:n,hasBody:r,hasHeaders:s,hasCookies:o,hasInputs:t.length>0||n||r||s||o,varsRequired:t.length>0||e.queryParams.some(i=>i.required)||(e.requestBody?.required??!1)||e.headerParams.some(i=>i.required)||e.cookieParams.some(i=>i.required),variablesTypeName:`${b(e.name)}Variables`}}var Te=" ";function Pe(e,t=[]){let n=H(e,{schemas:t});return n==="integer"?"number":n}function X(e,t=[]){let n=Y(e,t);if(n.length!==0)return n.map(r=>({name:r.name,key:r.key,type:r.type}))}function C(e,t=[],n=""){let r=n+Te,s=Y(e,t).map(o=>`${r}${o.key}${o.required===!0?"":"?"}: ${o.type};`);return s.length===0?"{}":`{
|
|
12
|
-
${s.join(`
|
|
13
|
-
`)}
|
|
14
|
-
${n}}`}function Y(e,t){let n=new Set;return(e??[]).map(r=>({...r,key:R(V(r.name),n),type:Pe(r.schema,t)}))}var ee=" ";function g(e,t,n){let r=Q(e,t);return r===void 0?[]:[`${n}/**`,...O(r).split(`
|
|
15
|
-
`).map(s=>`${n} * ${s}`.replace(/ +$/,"")),`${n} */`]}function Z(e){return typeof e=="string"?JSON.stringify(e):String(e)}function ke(e,t,n){switch(e){case"string":return t?.format==="binary"?"Blob":n==="Date"&&(t?.format==="date-time"||t?.format==="date")?"Date":"string";case"number":case"integer":return"number";case"boolean":return"boolean"}}function E(e){return e.kind==="union"||e.kind==="intersection"||e.kind==="enum"&&e.values.length>1}function l(e,t="string",n=""){switch(e.kind){case"scalar":return ke(e.scalar,e.metadata,t);case"ref":return e.name;case"literal":return Z(e.value);case"enum":return e.values.map(Z).join(" | ");case"null":return"null";case"unknown":return"unknown";case"array":{let r=l(e.items,t,n);return E(e.items)?`(${r})[]`:`${r}[]`}case"record":return`Record<string, ${l(e.value,t,n)}>`;case"object":{if(e.properties.length===0)return"{}";let r=n+ee;return`{
|
|
16
|
-
${e.properties.flatMap(o=>je(o,t,r)).join(`
|
|
17
|
-
`)}
|
|
18
|
-
${n}}`}case"union":return e.members.map(r=>{let s=l(r,t,n);return E(r)?`(${s})`:s}).join(" | ");case"intersection":return e.members.map(r=>{let s=l(r,t,n);return E(r)?`(${s})`:s}).join(" & ");case"omit":return`Omit<${e.base}, ${e.keys.map(r=>JSON.stringify(r)).join(" | ")}>`}}function je(e,t,n){let r=x(e.name),s=e.readOnly?"readonly ":"",o=e.required?"":"?",i=l(e.schema,t,n);return[...g(e.description,e.schema.metadata,n),`${n}${s}${r}${o}: ${i};`]}function xe(e){let t=e.schema;return t.kind!=="enum"||t.scalar!=="string"?[]:t.values.every(n=>typeof n=="string"&&_(n))?[`export const ${e.name} = {`,...t.values.map((n,r)=>`${ee}${n}: ${JSON.stringify(n)}${r===t.values.length-1?"":","}`),"} as const;"]:[]}function te(e,t="string"){let n=[];for(let r of e){let s=[...g(r.schema.description??r.description,r.schema.metadata,""),`export type ${r.name} = ${l(r.schema,t)};`];n.push(s.join(`
|
|
19
|
-
`));let o=xe(r);o.length>0&&n.push(o.join(`
|
|
20
|
-
`))}return n.join(`
|
|
21
|
-
|
|
22
|
-
`)}var S=" ";function w(e,t,n=""){if(P(e))return l(e.schema,t,n);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 l(e.schema,t,n)}}function $(e,t,n=""){let r=n+S,s=e.flatMap(o=>[...g(o.description,o.schema.metadata,r),`${r}${x(o.name)}${o.required?"":"?"}: ${l(o.schema,t,r)};`]);return s.length===0?"{}":`{
|
|
23
|
-
${s.join(`
|
|
24
|
-
`)}
|
|
25
|
-
${n}}`}function B(e,t,n=""){if(e.length===0)return{type:"void",kind:"void"};let r=e.find(a=>a.contentType.toLowerCase().includes("json"));if(r)return{type:l(r.schema,t,n),kind:"json"};let s=[],o=new Set,i=!1,c=!1;for(let a of e){let u;a.contentType.startsWith("image/")||a.contentType==="application/octet-stream"?(u="Blob",i=!0):a.contentType.startsWith("text/")?(u="string",c=!0):u=l(a.schema,t,n),!o.has(u)&&(o.add(u),s.push(u))}return{type:s.join(" | "),kind:i?"blob":c?"text":"json"}}function ne(e,t,n=""){let r=new Set,s=[];for(let o of e){let i=l(o.schema,t,n);r.has(i)||(r.add(i),s.push(i))}return s}function Oe(e,t,n=""){let r=e.sse?.eventSchema;return r?l(r,t,n):"string"}function j(e,t,n,r,s,o){let i=s.has(t)?n():t;return`${o}${e}${r?"":"?"}: ${i};`}function qe(e,t){let n=new Set,r=e;for(;r.kind==="ref";){let{name:s}=r;if(n.has(s))return;n.add(s);let o=t?.find(i=>i.name===s);if(o===void 0)return;r=o.schema}return r}function re(e,t){let n=qe(e,t);if(n?.kind==="object")return n.properties.map(s=>s.name);if(n?.kind!=="intersection")return;let r=new Set;for(let s of n.members){let o=re(s,t);if(o===void 0)return;for(let i of o)r.add(i)}return[...r]}function A(e,t){let n=[...k(e),...e.queryParams,...e.headerParams,...e.cookieParams],r=(e.requestBody?.required??!1)&&e.requestBody!==void 0?re(e.requestBody.schema,t):void 0,s=r!==void 0,o=new Map;for(let c of n)o.set(c.name,(o.get(c.name)??0)+1);e.requestBody&&!s&&o.set("body",(o.get("body")??0)+1);for(let c of r??[])o.set(c,(o.get(c)??0)+1);let i=[...o].filter(([,c])=>c>1).map(([c])=>c);return i.length>0?{collisions:i}:{mergeBody:s}}function Re(e,t,n){return e.flatMap(r=>[...g(r.description,r.schema.metadata,n),`${n}${x(r.name)}${r.required?"":"?"}: ${l(r.schema,t.dateType,n)};`])}function se(e,t,n,r=""){let{dateType:s,schemaNames:o}=n,i=r+S,c=n.argsStyle==="flat"?A(e,n.schemas):void 0;if(c!==void 0&&"mergeBody"in c)return Ne(e,t,n,c.mergeBody,r);let a=[],u=k(e);return u.length>0&&a.push(j("path",`${t}Path`,()=>$(u,s,i),!0,o,i)),e.queryParams.length>0&&a.push(j("query",`${t}Query`,()=>$(e.queryParams,s,i),e.queryParams.some(m=>m.required),o,i)),e.requestBody&&a.push(j("body",`${t}Body`,()=>w(e.requestBody,s,i),e.requestBody.required,o,i)),e.headerParams.length>0&&a.push(j("headers",`${t}Headers`,()=>$(e.headerParams,s,i),e.headerParams.some(m=>m.required),o,i)),e.cookieParams.length>0&&a.push(j("cookies",`${t}Cookies`,()=>$(e.cookieParams,s,i),e.cookieParams.some(m=>m.required),o,i)),a.length===0?"{}":`{
|
|
26
|
-
${a.join(`
|
|
27
|
-
`)}
|
|
28
|
-
${r}}`}function Ne(e,t,n,r,s){let o=s+S,i=Re([...k(e),...e.queryParams,...e.headerParams,...e.cookieParams],n,o);e.requestBody&&!r&&i.push(j("body",`${t}Body`,()=>w(e.requestBody,n.dateType,o),e.requestBody.required,n.schemaNames,o));let c=n.schemaNames.has(`${t}Body`)?w(e.requestBody,n.dateType,s):`${t}Body`,a=i.length===0?"{}":`{
|
|
29
|
-
${i.join(`
|
|
30
|
-
`)}
|
|
31
|
-
${s}}`;return r?i.length===0?c:`${a} & ${c}`:a}function M(e,t,n){let r=`${b(e.name)}Result`;return t.schemaNames.has(r)?B(e.successResponses,t.dateType,n).type:r}function ve(e,t,n){let r=ne(e.errorResponses,t.dateType,n);if(r.length===0)return"unknown";let s=`${b(e.name)}Error`;return t.schemaNames.has(s)?r.join(" | "):s}function oe(e,t,n){let r=h(e.services);if(r.length===0)return"";let s=r.flatMap(o=>{let i=t.get(o.name),c=b(o.name),a=S+S,u=se(o,c,n,a),m=o.sse!==void 0,p=m?Oe(o,n.dateType,a):n.errorMode==="result"?`Result<${M(o,n,a)}, ${ve(o,n,a)}>`:M(o,n,a),f=[`${a}args: ${u};`,`${a}result: ${p};`];n.errorMode==="result"&&!m&&f.push(`${a}mode: "result";`);let y=o.successResponseHeaders;y&&y.length>0&&f.push(`${a}headers: ${C(y,n.schemas,a)};`);let d=n.pagination?.get(o.name);return d&&(f.push(`${a}item: ${l(d.itemSchema,n.dateType,a)};`),n.errorMode==="result"&&f.push(`${a}page: ${M(o,n,a)};`)),m&&f.push(`${a}kind: "sse";`),[`${S}${i}: {`,...f,`${S}};`]});return[...g("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 = {",...s,"};"].join(`
|
|
32
|
-
`)}function ie(e,t){let{dateType:n,schemaNames:r}=t,s=b(e.name),o=e.sse!==void 0,{hasInputs:i}=W(e),c=[];if(!o){let m=`${s}Result`;if(r.has(m)||c.push(`export type ${m} = ${B(e.successResponses,n).type};`),t.errorMode==="result"){let p=ne(e.errorResponses,n),f=`${s}Error`;p.length>0&&!r.has(f)&&c.push(`export type ${f} = ${p.join(" | ")};`)}}let a=k(e);a.length>0&&!r.has(`${s}Path`)&&c.push(`export type ${s}Path = ${$(a,n)};`),e.queryParams.length>0&&!r.has(`${s}Query`)&&c.push(`export type ${s}Query = ${$(e.queryParams,n)};`),e.requestBody&&!r.has(`${s}Body`)&&c.push(`export type ${s}Body = ${w(e.requestBody,n)};`),e.headerParams.length>0&&!r.has(`${s}Headers`)&&c.push(`export type ${s}Headers = ${$(e.headerParams,n)};`);let u=e.successResponseHeaders;return u&&u.length>0&&!r.has(`${s}ResponseHeaders`)&&c.push(`export type ${s}ResponseHeaders = ${C(u,t.schemas)};`),e.cookieParams.length>0&&!r.has(`${s}Cookies`)&&c.push(`export type ${s}Cookies = ${$(e.cookieParams,n)};`),i&&!r.has(`${s}Variables`)&&c.push(`export type ${s}Variables = ${se(e,s,t)};`),c.join(`
|
|
33
|
-
|
|
34
|
-
`)}function ae(e,t){let n=new Set,r=s=>{switch(s.kind){case"ref":n.add(s.name);return;case"omit":n.add(s.base);return;case"array":r(s.items);return;case"record":r(s.value);return;case"object":for(let o of s.properties)r(o.schema);return;case"union":case"intersection":for(let o of s.members)r(o);return;default:return}};for(let s of h(e.services)){for(let i of[...s.pathParams,...s.queryParams,...s.headerParams,...s.cookieParams])r(i.schema);s.requestBody&&r(s.requestBody.schema);for(let i of s.successResponses)r(i.schema),i.itemSchema&&r(i.itemSchema);if(t.errorMode==="result")for(let i of s.errorResponses)r(i.schema);let o=t.pagination?.get(s.name);o&&r(o.itemSchema)}return[...n].filter(s=>t.schemaNames.has(s)).sort()}function I(e){let t=new Set(U),n=new Map;for(let r of h(e.services))n.set(r.name,R(r.name,t));return n}function we(e,t,n,r,s=[],o="grouped"){let i=[...e.pathParams,...e.queryParams,...e.headerParams,...e.cookieParams].map(p=>({name:p.name,in:p.in,...p.style!==void 0?{style:p.style}:{},...p.explode!==void 0?{explode:p.explode}:{},...p.allowReserved!==void 0?{allowReserved:p.allowReserved}:{}})),c=L(e,{securitySchemes:t}),u=e.sse!==void 0?"sse":B(e.successResponses,n).kind,m=X(e.successResponseHeaders,s);return{id:e.specName??e.name,method:e.method.toUpperCase(),path:e.path,...e.tags.length>0?{tags:e.tags}:{},...i.length>0?{params:i}:{},...e.requestBody?{body:{contentType:e.requestBody.contentType,...P(e.requestBody)?{multipart:!0}:{}}}:{},...u!=="json"?{responseKind:u}:{},...e.sse===void 0?{}:{sseDataKind:e.sse.dataKind},...c.length>0?{security:c}:{},...m===void 0?{}:{responseHeaders:m},...r?.has(e.name)?{pagination:r.get(e.name).spec}:{},...o==="flat"&&"collisions"in A(e,s)?{argsStyle:"grouped"}:{}}}function ce(e,t,n,r,s="grouped"){let o=h(e.services);if(o.length===0)return"";let i=o.map((a,u)=>{let m=K(we(a,e.securitySchemes,n,r,e.schemas,s));return` ${t.get(a.name)}: ${m}${u===o.length-1?"":","}`}),c=[[...g(`The wire-shape descriptor for every operation, keyed by operationId \u2014 the data the
|
|
35
|
-
runtime routes requests by. Also minification-safe static metadata (method, path,
|
|
36
|
-
tags) for cache keys, tracing span names, and request logging.`,void 0,""),"export const OPERATIONS = {",...i,"} as const satisfies Record<string, OperationDescriptor>;"].join(`
|
|
37
|
-
`),'export type OperationId = (typeof OPERATIONS)[keyof typeof OPERATIONS]["id"];','export type OperationPath = (typeof OPERATIONS)[keyof typeof OPERATIONS]["path"];'];return o.some(a=>a.tags.length>0)&&c.push(`export type OperationTag = Extract<(typeof OPERATIONS)[keyof typeof OPERATIONS], {
|
|
38
|
-
tags: readonly string[];
|
|
39
|
-
}>["tags"][number];`),c.join(`
|
|
40
|
-
|
|
41
|
-
`)}var Be="// \u2500\u2500\u2500 Embedded runtime (@redocly/client-generator, assembled per this API's needs) \u2500\u2500\u2500";function ue(e){let t=["types.ts","errors.ts","url.ts","parse.ts","retry.ts"];return e.multipart&&t.push("multipart.ts"),e.auth&&t.push("auth.ts"),e.setup&&t.push("setup.ts"),e.paginate&&t.push("paginate.ts"),t.push("send.ts"),e.sse&&t.push("sse.ts"),t.push("create-client.ts"),t}function me(e){return[Be,...ue(e).map(t=>J[t]),fe(e)].join(`
|
|
42
|
-
|
|
43
|
-
`)}function pe(e,t="js"){let n=[...ue(e).map(r=>({name:r,content:F[r]})),{name:"factory.ts",content:Ie(e)}];return t==="js"?n:n.map(({name:r,content:s})=>({name:r,content:s.replace(/(from '\.\/[a-z-]+)\.js'/g,"$1.ts'")}))}function Ie(e){let t=["import { createClientCore } from './create-client.js';",...e.multipart?["import { toFormData } from './multipart.js';"]:[],...e.auth?["import { resolveAuth } from './auth.js';"]:[],...e.paginate?["import { items, itemsByLink, pages, pagesByLink } from './paginate.js';"]:[],...e.sse?["import { sse } from './sse.js';"]:[],`import type {
|
|
44
|
-
Client,
|
|
45
|
-
ClientConfig,
|
|
46
|
-
OperationContext,
|
|
47
|
-
OperationDescriptor,
|
|
48
|
-
OpsShape,
|
|
49
|
-
} from './types.js';`],n=["export { ApiError, TimeoutError } from './errors.js';","export { defaultRetryOn } from './retry.js';",...e.setup?["export { mergeSetup } from './setup.js';"]:[],"export type * from './types.js';"];return[t.join(`
|
|
50
|
-
`),fe(e),n.join(`
|
|
51
|
-
`)].join(`
|
|
52
|
-
|
|
53
|
-
`)}function fe(e){let t=[...e.multipart?["serializeMultipart: toFormData"]:[],...e.auth?["resolveAuth"]:[],...e.sse?["sse"]:[],...e.paginate?["paginate: { pages, items, pagesByLink, itemsByLink }"]:[]];return`/**
|
|
54
|
-
* The client factory: \`createClientCore\` wired with the capabilities this API needs.
|
|
55
|
-
* Exported so apps can build additional instances (per-tenant, per-environment) over
|
|
56
|
-
* the same \`OPERATIONS\`/\`Ops\`. The trailing string params carry the wiring's literal
|
|
57
|
-
* unions (\`OperationId\`/\`OperationPath\`/\`OperationTag\`) into \`ctx.operation\`.
|
|
58
|
-
*/
|
|
59
|
-
export function createClient<
|
|
60
|
-
Ops extends OpsShape,
|
|
61
|
-
Id extends string = string,
|
|
62
|
-
Path extends string = string,
|
|
63
|
-
Tag extends string = string,
|
|
64
|
-
>(
|
|
65
|
-
operations: Record<string, OperationDescriptor>,
|
|
66
|
-
config?: ClientConfig<OperationContext<Id, Path, Tag>>
|
|
67
|
-
): Client<Ops, OperationContext<Id, Path, Tag>> {
|
|
68
|
-
return createClientCore<Ops, Id, Path, Tag>(operations, config, ${t.length>0?`{ ${t.join(", ")} }`:"{}"});
|
|
69
|
-
}`}function le(e){let t=new Map(e.map(s=>[s.name,s.schema])),n=[],r=new Set;for(let s of e)for(let o of Ce(s)){let i=o.union.discriminator??Ee(o.union,t);if(!i)continue;let c=new Map;for(let a of i.mapping){if(!t.has(a.schemaName))continue;let u=c.get(a.schemaName);u?u.push(a.value):c.set(a.schemaName,[a.value])}for(let[a,u]of c){let m=`is${a}`;if(r.has(m))continue;r.add(m);let p=`(value as Record<string, unknown>)[${JSON.stringify(i.propertyName)}]`,f=u.length===1?`${p} === ${JSON.stringify(u[0])}`:`([${u.map(y=>JSON.stringify(y)).join(", ")}] as readonly unknown[]).includes(${p})`;n.push(["/**",` * Narrow a \`${o.label}\` to \`${a}\` via its \`${i.propertyName}\` discriminant.`," */",`export function ${m}(value: ${o.label}): value is ${a} {`,` return ${f};`,"}"].join(`
|
|
70
|
-
`))}}return n.join(`
|
|
71
|
-
|
|
72
|
-
`)}function Ce(e){let t=[],n=e.schema;if(n.kind==="union"){t.push({union:n,label:e.name});for(let r of n.members)T(r,t)}else T(n,t);return t}function T(e,t){switch(e.kind){case"union":{let n=e.members.map(r=>r.kind==="ref"?r.name:void 0);n.every(r=>r!==void 0)&&t.push({union:e,label:n.join(" | ")});for(let r of e.members)T(r,t);break}case"array":T(e.items,t);break;case"record":T(e.value,t);break;case"object":for(let n of e.properties)T(n.schema,t);break;case"intersection":for(let n of e.members)T(n,t);break}}function Ee(e,t){let n=[];for(let s of e.members){if(s.kind!=="ref"||!t.get(s.name))return;n.push(s.name)}if(n.length<2)return;let r=n.map(s=>Me(t.get(s)));for(let s of Object.keys(r[0])){if(!r.every(i=>s in i))continue;let o=r.map(i=>i[s]);if(o.every(i=>typeof i=="string")&&new Set(o).size===o.length)return{propertyName:s,mapping:n.map((i,c)=>({value:o[c],schemaName:i}))}}}function Me(e){let t={},n=r=>{if(r.kind==="object")for(let s of r.properties)s.schema.kind==="literal"&&(t[s.name]=s.schema.value);else if(r.kind==="intersection")for(let s of r.members)n(s)};return n(e),t}function he(e,t={}){return be(e,t).entry}function ye(e,t){let n=h(e.services);return{multipart:n.some(r=>r.requestBody&&P(r.requestBody)),auth:e.securitySchemes.length>0||n.some(r=>r.security.length>0),sse:n.some(r=>r.sse!==void 0),setup:!!t.setup,paginate:(t.pagination??new Map).size>0}}function ge(e,t){return t.runtime!=="module"?[]:pe(ye(e,t),t.importExt??"js").map(({name:n,content:r})=>({name:n,content:`${q}
|
|
73
|
-
|
|
74
|
-
${r.trim()}
|
|
75
|
-
`}))}function Ae(e,t,n){let r=e.importExt??"js",s=["OperationDescriptor",...e.setup?["ClientConfig","Middleware"]:[],...t.errorMode==="result"&&n?["Result"]:[]].sort();return[`import { createClient${e.setup?", mergeSetup":""} } from './runtime/factory.${r}';`,`import type { ${s.join(", ")} } from './runtime/types.${r}';`,`export * from './runtime/factory.${r}';`].join(`
|
|
76
|
-
`)}function $e(e,t,n){return be(e,t,n)}function be(e,t,n){let r=h(e.services),s=I(e),o=t.pagination??new Map,i={argsStyle:t.argsStyle??"grouped",errorMode:t.errorMode??"throw",dateType:t.dateType??"string",schemaNames:new Set(e.schemas.map(d=>d.name)),schemas:e.schemas,pagination:o},c=r.length>0?[oe(e,s,i),ce(e,s,i.dateType,o,i.argsStyle)]:["export type Ops = Record<string, never>;","export const OPERATIONS = {} as const satisfies Record<string, OperationDescriptor>;"],a=t.runtime==="module"?Ae(t,i,r.length>0):me(ye(e,t)),u=[te(e.schemas,i.dateType),le(e.schemas)].filter(d=>d.length>0).join(`
|
|
77
|
-
|
|
78
|
-
`),m=[...r.map(d=>ie(d,i)),...c].filter(d=>d.length>0).join(`
|
|
79
|
-
|
|
80
|
-
`),p=He(r,s),f=t.runtime==="module";if(n===void 0)return{entry:N([q,v(e),...f?[a]:[],[u,m].filter(d=>d.length>0).join(`
|
|
81
|
-
|
|
82
|
-
`),...f?[]:[a],de(t,i,e),p])};let y=u.length>0;return{entry:N([q,v(e),...f?[a]:[],y?De(e,i,`./${n}.schemas.${t.importExt??"js"}`):"",m,...f?[]:[a],de(t,i,e),p]),schemas:y?N([q,v(e),u]):void 0}}function De(e,t,n){let r=ae(e,t);return`${r.length>0?`import type { ${r.join(", ")} } from '${n}';
|
|
83
|
-
`:""}export * from '${n}';`}function de(e,t,n){let r=e.serverUrl??n.serverUrl,s=[...r!==void 0?[`serverUrl: ${G(r)}`]:[],...t.errorMode==="result"?['errorMode: "result"']:[],...t.argsStyle==="flat"?['argsStyle: "flat"']:[],'clientHeader: "redocly-client-generator"'],o=s.length>0?`{ ${s.join(", ")} }`:"{}",i=e.setup?`mergeSetup({ config: ${o} }, mergeSetup(__redoclySetup, {}))`:o,c=h(n.services),a=c.some(p=>p.tags.length>0),m=`export const client = createClient${c.length>0?`<Ops, OperationId, OperationPath, ${a?"OperationTag":"string"}>`:"<Ops>"}(OPERATIONS, ${i});`;return e.setup?`// \u2500\u2500\u2500 Baked-in setup (--setup) \u2500\u2500\u2500
|
|
84
|
-
const __redoclySetup: { config?: ClientConfig; middleware?: Middleware[] } = ${e.setup};
|
|
85
|
-
`+m:m}function He(e,t){let n=["export const { configure, use } = client;"];if(e.length===0)return n.join(`
|
|
86
|
-
`);let r=e.map(s=>t.get(s.name)).join(", ");return n.push(`export const { ${r} } = client;`),n.join(`
|
|
87
|
-
`)}var Rt=({model:e,output:t,outputMode:n,emit:r})=>{let s=ge(e,r).map(({name:o,content:i})=>({path:Se(t.dir,"runtime",o),content:i}));if(n==="split"){let{dir:o,stem:i}=t,{entry:c,schemas:a}=$e(e,r,i);return[...a===void 0?[]:[{path:Se(o,`${i}.schemas.ts`),content:a}],{path:t.path,content:c},...s]}return[{path:t.path,content:he(e,r)},...s]},Nt=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".typescript.md"),content:D(e,{title:`${e.title} TypeScript client reference`,frontmatter:n.docsFrontmatter===!0,language:{name:"typescript",label:"TypeScript",fence:"typescript",requires:"The client has no dependencies."},sample:s=>Le(s,{model:e,emit:n,outputPath:t.path}),paginated:new Set(r?.keys()??[])})}];function Le(e,t){let n=I(t.model).get(e.name)??e.name,s=`./${t.outputPath.replace(/^.*[\\/]/,"").replace(/\.[^.]+$/,"")}.${t.emit.importExt??"js"}`,o=e.queryParams.filter(p=>p.required),i=t.emit.argsStyle==="flat",c=e.pathParams.map(p=>`${p.name}: '<${p.name}>'`),a=o.map(p=>`${p.name}: /* \u2026 */`),u=i?[...c,...a,...e.requestBody?["/* body properties */"]:[]]:[...c.length>0?[`path: { ${c.join(", ")} }`]:[],...a.length>0?[`query: { ${a.join(", ")} }`]:[],...e.requestBody?["body: { /* \u2026 */ }"]:[]],m=u.length>0?[`{ ${u.join(", ")} }`]:[];return{lang:"typescript",label:"TypeScript SDK",source:`import { ${n} } from '${s}';
|
|
88
|
-
|
|
89
|
-
const result = await ${n}(${m.join(", ")});
|
|
90
|
-
`}}export{W as a,g as b,l as c,Rt as d,Nt as e,Le as f};
|
package/lib/chunks/EOS3ZB2L.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{c}from"./OZMIIHFH.js";import{open as C,readdir as N,stat as P}from"node:fs/promises";import d from"node:path";var $=new Set([".yaml",".yml",".json"]);async function D(e){let n=[];async function t(r){let o=await N(r,{withFileTypes:!0});for(let s of o){if(s.name.startsWith("."))continue;let i=d.join(r,s.name);if(s.isDirectory()){await t(i);continue}s.isFile()&&$.has(d.extname(s.name).toLowerCase())&&n.push(i)}}return await t(e),n.sort(),n}async function _(e,n=4096){let t=await C(e,"r");try{let r=Buffer.allocUnsafe(n),{bytesRead:o}=await t.read(r,0,n,0);return r.toString("utf8",0,o)}finally{await t.close()}}function M(e){return d.resolve(process.cwd(),e)}async function K(e){let n=await P(e);if(n.isFile())return[e];if(!n.isDirectory())return[];let t=[];async function r(o){let s=await N(o,{withFileTypes:!0});for(let i of s){if(i.name.startsWith("."))continue;let a=d.join(o,i.name);if(i.isDirectory()){await r(a);continue}i.isFile()&&t.push(a)}}return await r(e),t.sort(),t}var k="drift.local",O=`http://${k}`;function u(e){return e===k}var U=new Set(["accept","accept-charset","accept-encoding","accept-language","authorization","baggage","cache-control","cdn-loop","cookie","connection","content-length","content-type","dpr","dnt","downlink","ect","forwarded","host","if-match","if-modified-since","if-none-match","if-range","if-unmodified-since","origin","pragma","priority","range","referer","sec-fetch-dest","sec-fetch-mode","sec-fetch-site","sec-fetch-user","sec-gpc","sentry-trace","te","traceparent","tracestate","upgrade","upgrade-insecure-requests","user-agent","via","x-client-trace-id","x-cloud-trace-context","x-correlation-id","x-http-method-override","x-hub-signature","x-hub-signature-256","x-method-override","x-real-ip","x-request-id","x-forwarded-for","x-forwarded-host","x-forwarded-port","x-forwarded-proto"]),J=["cf-","sec-ch-","sec-fetch-","x-amz-","x-amzn-","x-b3-","x-envoy-","x-forwarded-","x-github-"],R=`
|
|
8
|
-
`;function Y(e){return e.split(R)}function g(e,n,t){let r=n.toLowerCase(),o=e[r];if(o===void 0){e[r]=t;return}e[r]=r==="set-cookie"?`${o}${R}${t}`:`${o},${t}`}function p(e){if(!c(e)&&!Array.isArray(e))return{};let n={};if(Array.isArray(e)){for(let t of e){if(!c(t))continue;let{name:r,value:o}=t;typeof r=="string"&&o!==void 0&&g(n,r,String(o))}return n}for(let[t,r]of Object.entries(e))if(r!=null){if(Array.isArray(r)){for(let o of r)g(n,t,String(o));continue}g(n,t,String(r))}return n}function f(e){try{return new URL(e)}catch{return new URL(e,O)}}function m(e){return e.length>1&&e.endsWith("/")?e.slice(0,-1):e}function L(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(e){let n=[],t=0,r=e.startsWith("/")?e:`/${e}`,s=m(r).split("/").map(i=>{if(!i)return"";let a=i.match(/^\{([^}]+)\}$/);return a?(n.push(a[1]),"([^/]+)"):(t+=2,L(i))}).join("/");return{regex:new RegExp(`^${s||"/"}$`),params:n,score:t}}function l(e,n){if(n&&A(e))try{return JSON.parse(n)}catch{return}}function E(e){return e?e.split(";")[0]?.trim().toLowerCase()??"":""}function A(e){let n=E(e);return n==="application/json"||n.endsWith("+json")}function Q(e,n){let t=E(n);if(!t)return e["application/json"]??e["*/*"];if(e[t]!==void 0)return e[t];let[r,o]=t.split("/");if(r&&o){let s=`${r}/*`;if(e[s]!==void 0)return e[s]}return e["*/*"]}function Z(e){let n=new Set,t=[];for(let r of e){let o=r.trim().toLowerCase();o.length!==0&&(o.endsWith("*")?t.push(o.slice(0,-1)):n.add(o))}return{names:n,prefixes:t}}function v(e,n){let t=e.toLowerCase();return t.startsWith(":")||U.has(t)||J.some(r=>t.startsWith(r))?!0:n?n.names.has(t)||n.prefixes.some(r=>t.startsWith(r)):!1}import{createReadStream as q}from"node:fs";import{readFile as B}from"node:fs/promises";import{createInterface as F}from"node:readline";function I(e){if(e!=null){if(typeof e=="string")return e;if(Buffer.isBuffer(e))return e.toString("utf8");if(c(e)||Array.isArray(e))try{return JSON.stringify(e)}catch{return String(e)}return String(e)}}function se(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()!==""){let n=Number(e);if(Number.isFinite(n))return n}}function H(e,n){if(e!=null){if(n==="base64"&&typeof e=="string")try{return Buffer.from(e,"base64").toString("utf8")}catch{return e}return I(e)}}function ae(e,n,t){let r=e.method?.toUpperCase(),o=e.url;if(!r||!o)return null;let s=p(e.requestHeaders),i=f(o);if(u(i.host)&&s.host)try{i=new URL(`${i.protocol}//${s.host}${i.pathname}${i.search}`)}catch{i=f(o)}let a=e.requestContentType??s["content-type"],y=H(e.requestBody),T={method:r,url:i.toString(),path:i.pathname,query:i.searchParams,protocol:i.protocol,protocolKnown:e.schemeKnown??/^https?:\/\//i.test(o),host:u(i.host)?void 0:i.host||void 0,headers:s,contentType:a,bodyText:y,bodyJson:l(a,y)},h,x=e.responseStatus;if(x!==void 0){let w=p(e.responseHeaders),S=e.responseContentType??w["content-type"],b=H(e.responseBody);h={status:x,statusText:e.responseStatusText,headers:w,contentType:S,bodyText:b,bodyJson:l(S,b)}}return{index:n,source:t,startedAt:e.startedAt,request:T,response:h,raw:e.raw}}async function*ce(e){let n=q(e,{encoding:"utf8"}),t=F({input:n,crlfDelay:1/0});for await(let r of t){let o=r.trim();if(o)try{let s=JSON.parse(o);c(s)&&(yield s)}catch{}}}async function*ue(e,n){let t=await B(e,"utf8"),r=JSON.parse(t);if(n)for(let o of n.split("."))r=c(r)?r[o]:void 0;if(Array.isArray(r))for(let o of r)c(o)&&(yield o)}function fe(e){return p(e)["content-type"]}function ge(e){return e?.replace(/\/+$/,"")||void 0}function z(e,n){if(!n||n==="/")return e||"/";if(e===n)return"/";if(e.startsWith(`${n}/`))return e.slice(n.length)||"/"}function me(e,n){if(n.startsWith("/"))return z(e.path,n);let t=f(n.includes("://")?n:`http://${n}`);if(!(u(t.host)||e.host!==void 0&&e.host.toLowerCase()!==t.host))return z(e.path,m(t.pathname))}export{D as a,_ as b,M as c,K as d,u as e,Y as f,f as g,m as h,V as i,E as j,A as k,Q as l,Z as m,v as n,I as o,se as p,H as q,ae as r,ce as s,ue as t,fe as u,ge as v,me as w};
|