@redocly/cli 2.51.1 → 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 +1 -1
- package/lib/chunks/{LE7OKNLO.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/{CXRHOXPI.js → ADW6GVRA.js} +1 -1
- package/lib/chunks/{IPFRJMV6.js → AEUD4DDQ.js} +1 -1
- package/lib/chunks/{RXUHCIFX.js → BFHO7GW5.js} +1 -1
- 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/{SKB7KFUK.js → D2LIZR7C.js} +1 -1
- package/lib/chunks/{B3QINORT.js → D3EE6JIC.js} +1 -1
- package/lib/chunks/{K732KQHY.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/{Y2G2CYSF.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/{OEBWRENF.js → JW436AQL.js} +1 -1
- package/lib/chunks/LD5MEXEL.js +10 -0
- package/lib/chunks/{WHTCOU4Z.js → MA3DQUED.js} +1 -1
- package/lib/chunks/{LWB43R4X.js → NEUHMRVX.js} +3 -3
- package/lib/chunks/{XMYTYWHZ.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/{SXKUE52F.js → RBQSJMUA.js} +1 -1
- package/lib/chunks/SK7RTQX6.js +18 -0
- package/lib/chunks/T22N7JRE.js +7 -0
- package/lib/chunks/{KQJOSAUI.js → TMUDD3AQ.js} +1 -1
- package/lib/chunks/{6PX2QTPF.js → UJ7OYRJC.js} +1 -1
- package/lib/chunks/{HJYFWIVE.js → UW4UC7ZI.js} +2 -2
- package/lib/chunks/{6UH63WWT.js → V3JDIYRX.js} +1 -1
- package/lib/chunks/VZNKVS6Q.js +7 -0
- package/lib/chunks/W62WTKL6.js +67 -0
- package/lib/chunks/{ZYLX724C.js → W7NMFHT5.js} +1 -1
- package/lib/chunks/{4PIDMMUD.js → WSWUTUN2.js} +1 -1
- package/lib/chunks/{N5SXQI4I.js → XA64NLCK.js} +1 -1
- package/lib/chunks/{CGINWISC.js → YHUS4LA4.js} +1 -1
- package/lib/chunks/{KXYI4EET.js → YOD7FLHY.js} +1 -1
- package/lib/chunks/{2UDYQ5CZ.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/25O4YORJ.js +0 -14
- package/lib/chunks/3A5KYQ7N.js +0 -26
- package/lib/chunks/5BMLOFU4.js +0 -20
- package/lib/chunks/67BLI5YQ.js +0 -90
- package/lib/chunks/6ZHC3PYG.js +0 -7
- package/lib/chunks/7SSQGR7O.js +0 -20
- package/lib/chunks/AH3V6J6B.js +0 -67
- package/lib/chunks/BGIV3YYM.js +0 -19
- package/lib/chunks/BJDVYUKU.js +0 -177
- package/lib/chunks/ECZA233J.js +0 -19
- package/lib/chunks/EE3PGFTZ.js +0 -16
- package/lib/chunks/EOS3ZB2L.js +0 -8
- package/lib/chunks/K2X43E7U.js +0 -57
- package/lib/chunks/L3TZNNJJ.js +0 -13
- package/lib/chunks/LAFBWLA7.js +0 -42
- package/lib/chunks/NB54XRRU.js +0 -10
- package/lib/chunks/NSIQWNYL.js +0 -7
- package/lib/chunks/NYFYWKQQ.js +0 -9
- package/lib/chunks/OIVSGFXK.js +0 -18
- package/lib/chunks/OKRLSOE5.js +0 -22
- package/lib/chunks/PFYPTG4G.js +0 -7
- package/lib/chunks/RBHN62FF.js +0 -7
- package/lib/chunks/REFX2EKS.js +0 -13
- package/lib/chunks/SGBB4RNM.js +0 -11
- package/lib/chunks/SQVG3CEM.js +0 -8
- package/lib/chunks/TVJE32GA.js +0 -11
- package/lib/chunks/VRWULG7P.js +0 -7
- package/lib/chunks/VZCENZBY.js +0 -30
- package/lib/chunks/WSOCDFHJ.js +0 -7
- package/lib/chunks/Y4BUDNR4.js +0 -14
- package/lib/chunks/ZBL4IVEW.js +0 -11
- /package/lib/chunks/{UKSQ7B5H.js → 2U6O26CV.js} +0 -0
package/lib/chunks/OIVSGFXK.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as Z,b as ee,f as ne,h as T,i as te}from"./LWB43R4X.js";import{a as h}from"./PFYPTG4G.js";import{C as J,H as V,V as k,X as W,aa as Q,c as R,ca as N,ja as Y,q as O,s as X}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import{b as q,c as E,k as C}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{mkdir as an,readFile as cn,writeFile as dn}from"node:fs/promises";import{dirname as Se,parse as un,resolve as A,sep as pn}from"node:path";function x(e){return{requires:["typescript"],errorModes:["throw"],load:()=>import("./LAFBWLA7.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("./AH3V6J6B.js").then(e=>({run:e.typescriptGenerator,sample:e.typescriptSample,docs:e.typescriptDocs}))},zod:{load:()=>import("./BJDVYUKU.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("./EE3PGFTZ.js").then(e=>({run:e.swrGenerator}))},mock:{requires:["typescript"],load:()=>import("./OKRLSOE5.js").then(e=>({run:e.mockGenerator}))},cli:{requires:["typescript","zod"],errorModes:["throw"],load:()=>import("./K2X43E7U.js").then(e=>({run:e.cliGenerator,sample:e.cliSample,docs:e.cliDocs}))},python:{notApplicable:I,load:()=>import("./BGIV3YYM.js").then(e=>({run:e.pythonGenerator,sample:e.pythonSample,docs:e.pythonDocs,options:e.pythonOptions}))},go:{errorModes:["throw"],notApplicable:I,load:()=>import("./25O4YORJ.js").then(e=>({run:e.goGenerator,sample:e.goSample,docs:e.goDocs}))},php:{errorModes:["throw"],notApplicable:I,load:()=>import("./7SSQGR7O.js").then(e=>({run:e.phpGenerator,sample:e.phpSample,docs:e.phpDocs}))}};function re(e,n,t,r){let s=new Set(e);n.goPackage!==void 0&&!s.has("go")&&k.warn(`generate-client: goPackage is ignored \u2014 it declares the Go package clause, and no selected generator uses it (add --generator go).
|
|
8
|
-
`);let o=n.errorMode??"throw",i=n.dateType??"string";for(let a of e){let c=t.get(a);if(!c)throw new h(`Unknown generator: ${a}`);for(let u of c.requires??[])if(!s.has(u)){let p=[...new Set([u,...e])].map(g=>`--generator ${g}`).join(" ");throw new h(`The "${a}" generator requires the "${u}" generator. Add it, e.g. ${p}.`)}if(c.errorModes&&!c.errorModes.includes(o))throw new h(`The "${a}" generator does not support --error-mode "${o}" (supported: ${c.errorModes.join(", ")}).`);if(c.dateTypes&&!c.dateTypes.includes(i))throw new h(`The "${a}" generator requires --date-type ${c.dateTypes.join(" or ")} (got "${i}") so the runtime values match the generated types.`);let d={...n,outputMode:r};for(let[u,p]of Object.entries(c.notApplicable??{}))d[u]!==void 0&&k.warn(`generate-client: the "${a}" generator ignores ${u} \u2014 ${p}.
|
|
9
|
-
`)}}function oe(e,n,t){let r=new Map;for(let s of e){let o=n.get(s)?.options,i=t?.[s];if(o===void 0){i!==void 0&&k.warn(`generate-client: the "${s}" generator declares no options, so client.options.${s} is ignored.
|
|
10
|
-
`),r.set(s,{});continue}r.set(s,be(s,o,i))}return r}function be(e,n,t){if(t!==void 0&&!R(t))throw new h(`The "${e}" generator's options must be a map of option names to values.`);let r=t??{},s=Object.keys(n.properties);if(n.additionalProperties!==!0){for(let i of Object.keys(r))if(!s.includes(i))throw new h(`The "${e}" generator got an unknown option "${i}". Declared options: ${s.join(", ")||"(none)"}.`)}for(let i of n.required??[])if(r[i]===void 0)throw new h(`The "${e}" generator requires the "${i}" option.`);let o={...r};for(let[i,a]of Object.entries(n.properties)){if(o[i]===void 0){a.default!==void 0&&(o[i]=a.default);continue}let c=Oe(a,o[i]);if(c!==void 0)throw new h(`The "${e}" generator's "${i}" ${c}.`)}return o}function Oe(e,n){if("enum"in e)return e.enum.includes(n)?void 0:`must be one of: ${e.enum.join(", ")}`;if(e.type==="array"){let t=e.items.type;return Array.isArray(n)&&n.every(r=>typeof r===t)?void 0:`must be an array of ${t}`}return typeof n===e.type?void 0:`must be a ${e.type}`}import{isAbsolute as Me,resolve as $e}from"node:path";import{pathToFileURL as Re}from"node:url";async function ie(e,n={}){let t=new Map;for(let a of n.customGenerators??[])ae(t,a);let r=[];for(let a of e)r.push(await se(a,t,n.configDir));let s=[],o=new Set,i=async a=>{if(!(s.includes(a)||o.has(a))){o.add(a);for(let c of t.get(a).requires??[])(t.has(c)||c in j)&&await i(await se(c,t,n.configDir));o.delete(a),s.push(a)}};for(let a of r)await i(a);return{selected:s,registry:t}}async function se(e,n,t){if(n.has(e))return e;let r=j[e];if(r!==void 0){let{load:o,...i}=r;return n.set(e,{...i,...await o()}),e}if(e==="sdk")throw new h('The "sdk" generator is now named "typescript". Update the `generators` list or the --generator flag.');let s=await ve(e,t??process.cwd());return ae(n,s),s.name}function ae(e,n){if(!R(n)||typeof n.name!="string"||n.name===""||typeof n.run!="function")throw new h("Invalid custom generator: expected an object with a non-empty string `name` and a `run` function (build one with `defineGenerator`).");if(e.has(n.name))throw new h(`Generator name "${n.name}" collides with an existing generator. Rename the custom generator.`);if(n.requiresGenerator!==void 0){let t=te(T,n.requiresGenerator);if(t===void 0)throw new h(`Generator "${n.name}" declares requiresGenerator "${n.requiresGenerator}", which is not a range we read. Use ^1.2.0, ~1.2.0, >=1.2.0, or an exact version.`);if(!t)throw new h(`Generator "${n.name}" needs @redocly/client-generator ${n.requiresGenerator}; this CLI ships ${T}. Upgrade @redocly/cli if the generator is newer, or update the generator \u2014 \`redocly eject-generator <name> --update\` for an ejected file, or upgrade its package.`)}n.name in j&&k.warn(`generate-client: custom generator "${n.name}" takes over the built-in generator of the same name.
|
|
11
|
-
`),e.set(n.name,{run:n.run,sample:n.sample,docs:n.docs,notApplicable:n.notApplicable,options:n.options,requires:n.requires,errorModes:n.errorModes,dateTypes:n.dateTypes})}async function ve(e,n){if(X(e))throw new h(`Remote generator modules are not supported \u2014 use a local path or a package name. Got: ${e}`);let t=e.startsWith(".")||Me(e),r=t?Re($e(n,e)).href:e;if(t&&e.endsWith(".ts")&&!process.features.typescript)throw new h(`Generator "${e}" is TypeScript, which this Node cannot run directly \u2014 use Node 22.18, 23.6, or newer.`);let s;try{s=await import(r)}catch(i){throw new h(`Could not load generator "${e}": ${i.message}`)}let o=s.default??s.generator;if(o===void 0)throw new h(`Generator module "${e}" must export a generator (a default export or a \`generator\` export built with \`defineGenerator\`).`);return o}function ue(e){let n=new Set,t=new Set,r=new Map;for(let f of e.securitySchemes){let m=B(f.key,n,t);m!==f.key&&(r.set(f.key,m),L("security scheme",f.key,m,de(f.key,n)),f.key=m)}let s=new Set(ne()),o=new Set(s),i=new Set,a=new Map;for(let f of e.schemas){let m=B(f.name,o,i);m!==f.name&&(a.set(f.name,m),L("schema",f.name,m,de(f.name,s)),f.name=m)}let c=f=>a.get(f)??ce(f),d=f=>r.get(f)??ce(f);for(let f of e.schemas)S(f.schema,c);let u=new Set(o),p=new Set,g=new Set;for(let f of e.services)for(let m of f.operations){let l=g.has(m.name);g.add(m.name);let y=m.name,P=B(m.name,u,p);if(P!==m.name){let G=l?{kind:"duplicate-operation-id"}:s.has(y)?{kind:"reserved"}:o.has(y)?{kind:"schema-collision"}:{kind:"unusable"};L("operation",y,P,G),m.specName=m.name,m.name=P}Pe(m,c),m.security=m.security.map(G=>G.map(d))}}function B(e,n,t){let r=E(e),s=r,o=2;for(;n.has(s)||t.has(C(s));)s=`${r}_${o++}`;return n.add(s),t.add(C(s)),s}function pe(e){for(let n of e.schemas)if(!q(n.name))throw U("schema",n.name);for(let n of e.securitySchemes)if(!q(n.key))throw U("security scheme",n.key);for(let n of e.services)for(let t of n.operations)if(!q(t.name))throw U("operation",t.name)}function U(e,n){return new Error(`Internal error: ${e} name ${JSON.stringify(n)} is not a safe identifier after sanitization.`)}function ce(e){return E(e)}function L(e,n,t,r){let s=JSON.stringify(n),o=JSON.stringify(t),i=r.kind==="duplicate-operation-id"?`two operations share the operationId ${s}; the second is emitted as ${o} \u2014 give each operation a unique operationId to control its method name`:r.kind==="schema-collision"?`${e} ${s} collides with the schema of the same name, so it is emitted as ${o} \u2014 rename the operation or the schema in the description to control its name`:r.kind==="reserved"?`${e} ${s} is a name a generated client already declares, so it is emitted as ${o} \u2014 the reserved set spans every target language, so one schema keeps one name across the SDKs you generate`:`${e} ${s} is not a usable identifier, so it is emitted as ${o}`;k.warn(`generate-client: ${i}.
|
|
12
|
-
`)}function de(e,n){return n.has(e)?{kind:"reserved"}:{kind:"unusable"}}function S(e,n){switch(e.kind){case"ref":e.name=n(e.name);break;case"omit":e.base=n(e.base);break;case"array":S(e.items,n);break;case"record":S(e.value,n);break;case"object":for(let t of e.properties)S(t.schema,n);break;case"union":for(let t of e.members)S(t,n);if(e.discriminator)for(let t of e.discriminator.mapping)t.schemaName=n(t.schemaName);break;case"intersection":for(let t of e.members)S(t,n);break}}function Pe(e,n){for(let t of e.pathParams)S(t.schema,n);for(let t of e.queryParams)S(t.schema,n);for(let t of e.headerParams)S(t.schema,n);for(let t of e.cookieParams)S(t.schema,n);e.requestBody&&S(e.requestBody.schema,n);for(let t of[...e.successResponses,...e.errorResponses])S(t.schema,n),t.itemSchema&&S(t.itemSchema,n)}var Ge=["get","post","put","delete","patch","head","options"];function fe(e,n){if(!n.startsWith("#/"))throw new h(`External $ref not supported: ${n}`);let t=n.slice(2).split("/").map(s=>s.replace(/~1/g,"/").replace(/~0/g,"~")),r=e;for(let s of t){if(!R(r)&&!Array.isArray(r))throw new h(`Cannot resolve $ref: ${n}`);r=r[s]}if(r===void 0)throw new h(`Cannot resolve $ref: ${n}`);return r}function M(e,n){return O(n)?fe(e,n.$ref):n}function D(e){let n=e.lastIndexOf("/");return n>=0?e.slice(n+1):e}function De(e){let n=e,t={};return typeof n.minimum=="number"&&(t.minimum=n.minimum),typeof n.maximum=="number"&&(t.maximum=n.maximum),typeof n.exclusiveMinimum=="number"?t.exclusiveMinimum=n.exclusiveMinimum:n.exclusiveMinimum===!0&&typeof n.minimum=="number"&&(t.exclusiveMinimum=n.minimum,delete t.minimum),typeof n.exclusiveMaximum=="number"?t.exclusiveMaximum=n.exclusiveMaximum:n.exclusiveMaximum===!0&&typeof n.maximum=="number"&&(t.exclusiveMaximum=n.maximum,delete t.maximum),typeof n.minLength=="number"&&(t.minLength=n.minLength),typeof n.maxLength=="number"&&(t.maxLength=n.maxLength),typeof n.pattern=="string"&&(t.pattern=n.pattern),typeof n.minItems=="number"&&(t.minItems=n.minItems),typeof n.maxItems=="number"&&(t.maxItems=n.maxItems),n.uniqueItems===!0&&(t.uniqueItems=!0),typeof n.format=="string"&&(t.format=n.format),n.deprecated===!0&&(t.deprecated=!0),n.example!==void 0?t.example=n.example:Array.isArray(n.examples)&&n.examples.length>0&&(t.example=n.examples[0]),n.default!==void 0&&(t.default=n.default),Object.keys(t).length>0?t:void 0}function qe(e,n){let t=e.discriminator;if(!t||typeof t.propertyName!="string")return;let r=[];if(t.mapping)for(let[s,o]of Object.entries(t.mapping))r.push({value:s,schemaName:D(o)});else for(let s of n)if(O(s)){let o=D(s.$ref);r.push({value:o,schemaName:o})}if(r.length!==0)return{propertyName:t.propertyName,mapping:r}}function b(e,n){return n?{...e,metadata:n}:e}function z(e,n){return e?n?{...e,...n}:e:n}function xe(e){return e?e.url.replace(/\{([^{}]+)\}/g,(n,t)=>e.variables?.[t]?.default??n):""}function me(e){let n=e.info?.title??"Api",t=e.info?.version??"0.0.0",r=e.info?.description,s=xe(e.servers?.[0]),o=(e.servers??[]).map(u=>({url:u.url,description:u.description,variables:Object.entries(u.variables??{}).map(([p,g])=>({name:p,default:g.default,description:g.description}))})),i=Ie(e),a=Ee(e),c=Be(e,a),d={title:n,version:t,description:r,serverUrl:s,servers:o,services:c,schemas:i,securitySchemes:a};return ue(d),je(c,i),pe(d),d}function je(e,n){let t=new Map(n.map(r=>[r.name,r.schema]));for(let r of e)for(let s of r.operations)s.requestBody&&(s.requestBody.schema=Ne(s.requestBody.schema,t))}function Ae(e){let n=e.filter(t=>t.kind!=="unknown");return n.length>0?n:[{kind:"unknown"}]}function Ne(e,n){if(e.kind==="ref"){let t=Te(e,n,new Set);return t.length>0?{kind:"omit",base:e.name,keys:t}:e}if(e.kind==="object"){let t=e.properties.filter(r=>!r.readOnly);return t.length===e.properties.length?e:{...e,properties:t}}return e}function Te(e,n,t){let r=[],s=o=>{if(o.kind==="ref"){if(t.has(o.name))return;t.add(o.name);let i=n.get(o.name);i&&s(i)}else if(o.kind==="object")for(let i of o.properties)i.readOnly&&!r.includes(i.name)&&r.push(i.name);else if(o.kind==="intersection")for(let i of o.members)s(i)};return s(e),r}function Ee(e){let n=e.components?.securitySchemes;if(!n)return[];let t=[];for(let[r,s]of Object.entries(n)){let o=M(e,s),i=o.type;i==="oauth2"||i==="openIdConnect"?t.push({kind:"bearer",key:r}):i==="http"&&(o.scheme??"").toLowerCase()==="bearer"?t.push({kind:"bearer",key:r}):i==="http"&&(o.scheme??"").toLowerCase()==="basic"?t.push({kind:"basic",key:r}):i==="apiKey"&&o.in==="header"&&typeof o.name=="string"?t.push({kind:"apiKeyHeader",key:r,headerName:o.name}):i==="apiKey"&&o.in==="query"&&typeof o.name=="string"?t.push({kind:"apiKeyQuery",key:r,paramName:o.name}):i==="apiKey"&&o.in==="cookie"&&typeof o.name=="string"&&(k.warn(`generate-client: security scheme "${r}" sends its credential in the Cookie header, which browsers ignore \u2014 cookie auth works only in server-side clients.
|
|
13
|
-
`),t.push({kind:"apiKeyCookie",key:r,cookieName:o.name}))}return t}function Ce(e,n,t){let r=e.security??n.security;if(!r)return[];let s=[];for(let o of r){let i=Object.keys(o);i.length!==0&&i.every(a=>t.has(a))&&s.push([...new Set(i)])}return s}function Ie(e){let n=e.components?.schemas;return n?Object.entries(n).map(([t,r])=>{if(O(r)){let o=fe(e,r.$ref);return{name:t,schema:v(o,`components.schemas.${t}`,e),description:o.description}}let s=v(r,`components.schemas.${t}`,e);return{name:t,schema:s,description:r.description}}):[]}function Be(e,n){let t=new Set(n.map(i=>i.key)),r=[],s=new Set;for(let[i,a]of Object.entries(e.paths??{})){if(!a)continue;let c=M(e,a),d=(c.parameters??[]).map(u=>ge(M(e,u),`paths.${i}.parameters`,e));for(let u of Ge){let p=c[u];p&&(r.push({method:u,path:i,operation:p,pathLevelParams:d}),p.operationId&&s.add(p.operationId))}}return[{name:"Default",operations:r.map(i=>{let a=i.operation.operationId??ze(Ue(i.method,i.path),s);return He(i.method,i.path,i.operation,a,i.pathLevelParams,e,t)})}]}function Ue(e,n){let t=n.split("/").filter(Boolean).map(r=>Le(r.replace(/[{}]/g,"")));return`${e}${t.join("")}`}function Le(e){return e.split(/[^A-Za-z0-9]+/).filter(Boolean).map(n=>n[0].toUpperCase()+n.slice(1)).join("")}function ze(e,n){let t=e,r=2;for(;n.has(t);)t=`${e}${r++}`;return n.add(t),t}function He(e,n,t,r,s,o,i){let a=(t.parameters??[]).map(w=>ge(M(o,w),`paths.${n}.${e}.parameters`,o)),c=new Set,d=[];for(let w of a)c.add(`${w.in}:${w.name}`),d.push(w);for(let w of s)c.has(`${w.in}:${w.name}`)||d.push(w);let u=d.filter(w=>w.in==="path"),p=d.filter(w=>w.in==="query"),g=d.filter(w=>w.in==="header"),f=d.filter(w=>w.in==="cookie"),m=t.requestBody?Fe(M(o,t.requestBody),`${e} ${n}`,o):void 0,{successResponses:l,successResponseHeaders:y}=_e(t,n,o),P=Je(t,n,o),G=Ce(t,o,i),F=t["x-redoclyPagination"],_=Ke(l);return{name:r,method:e,path:n,summary:t.summary,description:t.description,pathParams:u,queryParams:p,headerParams:g,cookieParams:f,requestBody:m,successResponses:l,...y===void 0?{}:{successResponseHeaders:y},errorResponses:P,security:G,tags:Array.isArray(t.tags)?t.tags.filter(w=>typeof w=="string"):[],...F!==void 0?{paginationExtension:F}:{},..._===void 0?{}:{sse:_}}}function Ke(e){let n=e.find(s=>s.contentType.split(";")[0].trim().toLowerCase()==="text/event-stream");if(n===void 0)return;let t=n.itemSchema&&n.itemSchema.kind!=="unknown"?n.itemSchema:n.schema.kind!=="unknown"?n.schema:void 0;if(t===void 0)return{dataKind:"text"};let r=t.kind==="object"||t.kind==="ref"||t.kind==="array"||t.kind==="record"||t.kind==="union"||t.kind==="intersection";return{eventSchema:t,dataKind:r?"json":"text"}}function ge(e,n,t){if(!e.in)throw new h(`Parameter ${e.name} at ${n} is missing "in"`);if(!["path","query","header","cookie"].includes(e.in))throw new h(`Unsupported parameter location "${e.in}" for ${e.name} at ${n}`);let r=$(e.schema,`${n}.${e.name}`,t);e.deprecated===!0&&(r={...r,metadata:z(r.metadata,{deprecated:!0})});let s={name:e.name,in:e.in,schema:r,required:!!e.required,description:e.description};if(s.in==="query"){let o=e;(o.style==="form"||o.style==="spaceDelimited"||o.style==="pipeDelimited"||o.style==="deepObject")&&(s.style=o.style),typeof o.explode=="boolean"&&(s.explode=o.explode),typeof o.allowReserved=="boolean"&&(s.allowReserved=o.allowReserved)}return s}function Fe(e,n,t){let r=e.content??{},s=r["application/json"]??r["application/merge-patch+json"]??r["application/x-www-form-urlencoded"]??r["multipart/form-data"]??Object.values(r)[0];if(!s)return;let o=Object.keys(r).find(a=>r[a]===s),i=$(s.schema,`${n}.requestBody`,t);return{contentType:o,schema:i,required:!!e.required,description:e.description}}function _e(e,n,t){let r=e.responses??{},s=Object.keys(r).filter(g=>/^2\d\d$/.test(g));s.length===0&&(r["2XX"]?s.push("2XX"):r.default&&s.push("default"));let o=s[0];if(!o)return{successResponses:[]};let i=r[o];if(!i)return{successResponses:[]};let a=M(t,i),c=Xe(a.headers,`paths.${n}.response.${o}`,t),d=a.content;if(!d)return{successResponses:[],...c===void 0?{}:{successResponseHeaders:c}};let u=o==="default"||o==="2XX"?o:Number(o),p=[];for(let[g,f]of Object.entries(d)){let m=$(f.schema,`paths.${n}.response.${o}.${g}`,t),l=f.itemSchema,y=l!==void 0?$(l,`paths.${n}.response.${o}.${g}.itemSchema`,t):void 0;p.push({contentType:g,schema:m,status:u,...y===void 0?{}:{itemSchema:y}})}return{successResponses:p,...c===void 0?{}:{successResponseHeaders:c}}}function Xe(e,n,t){if(!e)return;let r=[];for(let[s,o]of Object.entries(e)){let i=M(t,o),a={name:s.toLowerCase(),schema:$(i.schema===void 0?void 0:M(t,i.schema),`${n}.headers.${s}`,t)};i.required===!0&&(a.required=!0),r.push(a)}return r.length>0?r:void 0}function Je(e,n,t){let r=e.responses??{},s=Object.keys(r).filter(a=>/^([45]\d\d|4XX|5XX)$/.test(a));Object.keys(r).some(a=>/^(2\d\d|2XX)$/.test(a))&&r.default&&s.push("default");let i=[];for(let a of s){let c=r[a];if(!c)continue;let u=M(t,c).content;if(!u)continue;let p=a==="default"||a==="4XX"||a==="5XX"?a:Number(a);for(let[g,f]of Object.entries(u)){let m=$(f.schema,`paths.${n}.response.${a}.${g}`,t);i.push({contentType:g,schema:m,status:p})}}return i}function $(e,n,t){return e===void 0||typeof e=="boolean"?{kind:"unknown"}:O(e)?{kind:"ref",name:D(e.$ref)}:v(e,n,t)}function v(e,n,t){let r=De(e),s=e.oneOf??e.anyOf;if(s){let a=s.map((u,p)=>O(u)?{kind:"ref",name:D(u.$ref)}:v(u,`${n}.[${p}]`,t)),c=Ae(a);if(c.length===1&&c.length<a.length){let u=c[0];return{...u,description:u.description??e.description,metadata:z(r,u.metadata)}}let d=qe(e,s);return b({kind:"union",members:c,discriminator:d,description:e.description},r)}if(e.allOf){let a=e.allOf.map((d,u)=>O(d)?{kind:"ref",name:D(d.$ref)}:v(d,`${n}.allOf[${u}]`,t)),c=le(e,n,t);if(c.length>0&&a.unshift({kind:"object",properties:c}),a.length===1){let d=a[0];return{...d,description:d.description??e.description,metadata:z(r,d.metadata)}}return b({kind:"intersection",members:a,description:e.description},r)}let o=e.type;if(Array.isArray(o)){let a=o.filter(u=>u!=="null"),c=o.includes("null"),d=a.map(u=>{let p={...e,type:u};if(Array.isArray(p.enum)){let g=p.enum.filter(f=>f!==null);p.enum=g.length>0?g:void 0}return v(p,n,t)});return c&&d.push({kind:"null"}),d.length===1?d[0]:b({kind:"union",members:d,description:e.description},r)}if(e.nullable)return{kind:"union",members:[v({...e,nullable:void 0},n,t),{kind:"null"}],description:e.description};if(e.const!==void 0){let a=e.const;if(typeof a!="string"&&typeof a!="number"&&typeof a!="boolean")throw new h(`Unsupported const value at ${n}: ${JSON.stringify(a)}`);return b({kind:"literal",value:a,description:e.description},r)}if(e.enum){let a=e.enum,c=a.filter(g=>g!==null),d=c.length!==a.length;if(c.length===0)return b({kind:"null",description:e.description},r);let u=Ve(c,n),p=u==="boolean"?{kind:"scalar",scalar:"boolean",description:e.description}:{kind:"enum",values:c,scalar:u,description:e.description};return b(d?{kind:"union",members:[p,{kind:"null"}],description:e.description}:p,r)}let i=o;if(i==="null")return b({kind:"null",description:e.description},r);if(i==="array"){let a=e.items,c=$(a,`${n}.items`,t);return b({kind:"array",items:c,description:e.description},r)}if(i==="object"||e.properties||e.additionalProperties){let a=le(e,n,t),c=e.additionalProperties;if(a.length===0&&c!==!1){let d=$(c,`${n}.additionalProperties`,t);return b({kind:"record",value:d,description:e.description},r)}return b({kind:"object",properties:a,description:e.description},r)}return b(i==="string"||i==="number"||i==="integer"||i==="boolean"?{kind:"scalar",scalar:i,description:e.description}:{kind:"unknown",description:e.description},r)}function Ve(e,n){let t=!1,r=!1,s=!1;for(let o of e)if(typeof o=="string")t=!0;else if(typeof o=="number")r=!0;else if(typeof o=="boolean")s=!0;else throw new h(`Unsupported enum value type at ${n}: ${JSON.stringify(o)}`);return t&&!r&&!s?"string":r&&!t&&!s?"number":s&&!t&&!r?"boolean":"string"}function We(e){return!(e.openapi??"").startsWith("3.0")}function le(e,n,t){let r=e.properties??{},s=new Set(e.required??[]),o=We(t);return Object.entries(r).map(([i,a])=>{let c=a.readOnly===!0;c&&O(a)&&!o&&k.warn(`generate-client: "${i}" declares readOnly beside a $ref, which OpenAPI ${t.openapi} ignores \u2014 the property stays in request bodies. Inline the schema, wrap the $ref in allOf, or move the description to OpenAPI 3.1.
|
|
14
|
-
`);let d=c&&(o||!O(a));return{name:i,schema:$(a,`${n}.${i}`,t),required:s.has(i),description:a.description,...d?{readOnly:!0}:{}}})}function he(e){let n=H(e),t={...n};delete t.swagger,delete t.host,delete t.basePath,delete t.schemes,delete t.definitions,delete t.securityDefinitions,delete t.consumes,delete t.produces,delete t.parameters,delete t.responses,t.openapi="3.0.3";let r=Qe(n);return r&&(t.servers=r),t.components=Ye(n),t.paths=tn(n.paths??{},n.consumes??void 0,n.produces??void 0),t}function Qe(e){let n=e.host,t=e.basePath??"",r=(e.schemes??["https"])[0]??"https";if(n)return[{url:`${r}://${n}${t}`}]}function Ye(e){let n={};e.definitions&&(n.schemas=e.definitions),e.parameters&&(n.parameters=Object.fromEntries(Object.entries(e.parameters).map(([r,s])=>[r,K(s)]))),e.responses&&(n.responses=we(e.responses,void 0));let t=e.securityDefinitions;if(t){let r={};for(let[s,o]of Object.entries(t))r[s]=Ze(o);n.securitySchemes=r}return n}function Ze(e){switch(e.type){case"basic":return{type:"http",scheme:"basic"};case"apiKey":return{type:"apiKey",name:e.name,in:e.in};case"oauth2":{let n=e.flow==="accessCode"?"authorizationCode":e.flow==="application"?"clientCredentials":e.flow,t={scopes:e.scopes??{}};return e.authorizationUrl&&(t.authorizationUrl=e.authorizationUrl),e.tokenUrl&&(t.tokenUrl=e.tokenUrl),{type:"oauth2",flows:{[n]:t}}}default:return e}}function H(e){if(Array.isArray(e))return e.map(H);if(R(e)){let n={};for(let[t,r]of Object.entries(e))t==="$ref"&&typeof r=="string"?n.$ref=r.replace("#/definitions/","#/components/schemas/").replace("#/parameters/","#/components/parameters/").replace("#/responses/","#/components/responses/"):n[t]=H(r);return n}return e}var en="application/json",nn="application/json",ye=new Set(["name","in","required","description","deprecated","allowEmptyValue","collectionFormat"]);function tn(e,n,t){let r={};for(let[s,o]of Object.entries(e)){let i=o,a={};for(let[c,d]of Object.entries(i)){if(c==="parameters"&&Array.isArray(d)){a.parameters=d.map(K);continue}if(!rn(c)){a[c]=d;continue}a[c]=on(d,n,t)}r[s]=a}return r}function rn(e){return["get","put","post","delete","options","head","patch"].includes(e.toLowerCase())}function on(e,n,t){let r=e.consumes??n,s=e.produces??t,o=e.parameters??[],i=o.find(p=>p.in==="body"),a=o.filter(p=>p.in==="formData"),c=o.filter(p=>p.in!=="body"&&p.in!=="formData").map(K),d={...e,parameters:c};delete d.consumes,delete d.produces;let u=r?.[0]??en;if(i)d.requestBody={required:!!i.required,content:{[u]:{schema:i.schema}}};else if(a.length>0){let p={},g=[];for(let l of a)p[l.name]=sn(l),l.required&&g.push(l.name);let f={type:"object",properties:p};g.length>0&&(f.required=g);let m=r?.find(l=>l==="multipart/form-data")??r?.[0]??"application/x-www-form-urlencoded";d.requestBody={required:g.length>0,content:{[m]:{schema:f}}}}return e.responses&&(d.responses=we(e.responses,s)),d}function K(e){if(e.$ref!==void 0||e.in==="body"||e.in==="formData")return e;let n={},t={};for(let[r,s]of Object.entries(e))ye.has(r)?n[r]=s:t[r]=s;if(n.schema=t,delete n.collectionFormat,e.in==="query"&&t.type==="array"){let r=e.collectionFormat??"csv";r!=="multi"&&(n.style=r==="ssv"?"spaceDelimited":r==="pipes"?"pipeDelimited":"form",n.explode=!1)}return n}function sn(e){let n={};for(let[t,r]of Object.entries(e))ye.has(t)||(n[t]=r);return n}function we(e,n){let t=n?.[0]??nn,r={};for(let[s,o]of Object.entries(e)){let i=o;if(i.schema===void 0){r[s]=i;continue}let{schema:a,...c}=i;r[s]={...c,content:{[t]:{schema:a}}}}return r}async function ke(e,n){let t=n??await N({}),r=await Q({ref:e,config:t}),s=await N({rules:{struct:"error"}}),o=await Y({externalRefResolver:new V,document:r.bundle,config:s}),i=[...r.problems,...o].filter(c=>c.severity==="error");if(i.length>0){let c=i.map(d=>`- ${d.message} (at ${d.location?.[0]?.pointer??e})`).join(`
|
|
15
|
-
`);throw new Error(`The API description has ${i.length} error(s):
|
|
16
|
-
${c}`)}let a=r.bundle.parsed;return{document:a,version:W(a)}}var ln=["Generated by @redocly/client-generator \u2014 do not edit by hand.","Source: OpenAPI description. Re-run `redocly generate-client` to update."];function fn(e,n){let t=[],r=new Set,s=A(Se(n.outputPath)),{dir:o,name:i,ext:a}=un(n.outputPath),c={path:n.outputPath,dir:o,stem:i,ext:a},d=ln,u=!1;for(let p of n.generators){let g=n.registry.get(p),f={model:e,output:c,banner:d,outputMode:n.outputMode,emit:n.emit,pagination:n.pagination,selected:n.generators,options:n.generatorOptions?.get(p)??{}},m;try{n.emit.docs===!0&&g.docs!==void 0?(m=[...g.run(f),...g.docs(f)],u=!0):m=g.run(f)}catch(l){let y=l instanceof Error?l.message:String(l);throw new Error(`Generator "${p}" failed: ${y}`)}if(!Array.isArray(m)||m.some(l=>typeof l?.path!="string"||l.path===""||typeof l.content!="string"))throw new Error(`Generator "${p}" failed: run() must return an array of { path, content } files.`);for(let l of m){let y=A(s,l.path);if(y!==s&&!y.startsWith(s+pn))throw new Error(`Generator "${p}" failed: file path escapes the output directory: ${l.path}`);if(r.has(y))throw new Error(`Generator conflict: ${l.path} already emitted by an earlier generator`);r.add(y),t.push({path:y,content:l.content})}}return n.emit.docs===!0&&!u&&k.warn(`generate-client: docs is on, but no selected generator writes documentation (${n.generators.join(", ")}).
|
|
17
|
-
`),t}function mn(e){for(let n of e.services)for(let t of n.operations){let r=new Set,s=new Set;for(let o of[...t.pathParams,...t.queryParams,...t.headerParams,...t.cookieParams])r.has(o.name)&&s.add(o.name),r.add(o.name);s.size!==0&&k.warn(`generate-client: operation "${t.specName??t.name}" uses ${[...s].map(o=>`"${o}"`).join(", ")} in more than one parameter location. Every SDK sends both, and the SDKs whose methods take one argument per parameter give the later one a suffixed name \u2014 rename it in the description to choose the name yourself.
|
|
18
|
-
`)}}function gn(e,n,t,r,s,o){let i=[];for(let a of Z(e.services)){let c=t.map(d=>r.get(d)?.sample?.(a,{model:e,emit:n,outputPath:s,pagination:o})).filter(d=>d!==void 0);c.length>0&&i.push({target:`$.paths['${a.path.replaceAll("'","''")}'].${a.method}`,update:{"x-codeSamples":c}})}if(i.length!==0)return J({overlay:"1.0.0",info:{title:`Code samples for ${e.title}`,version:e.version},actions:i})}async function et(e){if(e.output.split(/[\\/]/).some(l=>l==="undefined"||l==="null"))throw new Error(`output path "${e.output}" contains a literal "undefined" or "null" segment \u2014 this looks like an interpolation bug in the caller`);if(e.setup&&/^[a-z][a-z0-9+.-]+:/i.test(e.setup))throw new h(`setup must be a local file path \u2014 remote setup modules are not supported (got: ${e.setup})`);let n=A(e.output),{document:t,version:r}=await ke(e.api,e.config),s=r==="oas2"?he(t):t,o=me(s);mn(o);let i;if(e.setup){let{bakeSetup:l}=await import("./ZBL4IVEW.js"),y=A(e.configDir??process.cwd(),e.setup);i=l(await cn(y,"utf-8"))}let a=e.generators?.length?e.generators:["typescript"],{selected:c,registry:d}=await ie(a,{customGenerators:e.customGenerators,configDir:e.configDir}),u=ee(o,e.pagination),p={serverUrl:e.serverUrl,argsStyle:e.argsStyle,errorMode:e.errorMode,dateType:e.dateType,mockData:e.mockData,mockSeed:e.mockSeed,queryKeyPrefix:e.queryKeyPrefix,setup:i,runtime:e.runtime,importExt:e.importExt,goPackage:e.goPackage,pagination:u,docs:e.docs,docsFrontmatter:e.docsFrontmatter};re(c,p,d,e.outputMode);let g=oe(c,d,e.options),f=fn(o,{outputPath:n,outputMode:e.outputMode??"single",emit:p,pagination:u,generators:c,generatorOptions:g,registry:d});if(e.codeSamples===!0){let l=gn(o,p,c,d,n,u);l!==void 0&&f.push({path:n.replace(/\.[^.]+$/,".code-samples.yaml"),content:l})}let m=[];for(let l of f)await an(Se(l.path),{recursive:!0}),await dn(l.path,l.content,"utf-8"),m.push({path:l.path,bytes:Buffer.byteLength(l.content,"utf-8")});return{outputPath:n,bytes:m.reduce((l,y)=>l+y.bytes,0),files:m}}export{et as generateClient,fn as runGenerators};
|
package/lib/chunks/OKRLSOE5.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import"./TVJE32GA.js";import{a as I}from"./LWB43R4X.js";import"./PFYPTG4G.js";import{c as $}from"./OZMIIHFH.js";import"./NEWT5A6S.js";import{a as T,e as C,g as q,h as b,k as O}from"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";import{join as se}from"node:path";var S=class{constructor(n){this.code=n}code};function H(e,n,r={}){let t=new Map(n.map(a=>[a.name,a.schema])),o=k(e,t,new Set,r.dateType??"string");return o===g?null:o}var g=Symbol("cycle");function P(e,n){if(e.kind==="union"){for(let t of e.members){let o=P(t,n);if(o)return o}return}if(e.kind!=="scalar")return;let r=e.metadata?.format;if(r==="binary")return new S("new Blob([])");if(n==="Date"){if(r==="date-time")return new S('new Date("2024-01-01T00:00:00Z")');if(r==="date")return new S('new Date("2024-01-01")')}}function D(e,n){let r=new Map,t=[],o=!1;for(let a of e){if(a.kind==="unknown")continue;let c=Y(a,n);if(c?.kind!=="object"){t.push(a);continue}o=!0;for(let s of c.properties){let i=V(s.schema,n,new Set),u=r.get(s.name);(u===void 0||i>=u.rank)&&r.set(s.name,{schema:s.schema,required:s.required||(u?.required??!1),rank:i})}}return o?{merged:{kind:"object",properties:[...r.entries()].map(([a,c])=>({name:a,schema:c.schema,required:c.required}))},rest:t}:{merged:void 0,rest:t}}function Y(e,n){let r=new Set,t=e;for(;t?.kind==="ref";){if(r.has(t.name))return;r.add(t.name),t=n.get(t.name)}return t}function V(e,n,r){switch(e.kind){case"literal":return 40;case"enum":return e.values.length===1?40:30;case"union":return Math.max(0,...e.members.map(t=>V(t,n,r)))-1;case"ref":{if(r.has(e.name))return 20;let t=n.get(e.name);return t===void 0?20:V(t,n,new Set(r).add(e.name))}case"null":case"unknown":return 10;default:return 20}}function k(e,n,r,t){let o=P(e,t);if(o)return o;let a=e.metadata,c=s=>s===null?e.kind==="null"||e.kind==="union"&&e.members.some(i=>i.kind==="null"):e.kind==="enum"?e.values.includes(s):e.kind==="literal"?s===e.value:!0;if(a?.example!==void 0&&c(a.example))return a.example;if(a?.default!==void 0&&c(a.default))return a.default;switch(e.kind){case"scalar":return v(e.scalar,a);case"array":{let s=k(e.items,n,r,t);return s===g?[]:[s]}case"object":return Object.fromEntries(e.properties.flatMap(s=>{let i=k(s.schema,n,r,t);return i===g?s.required?[[s.name,null]]:[]:[[s.name,i]]}));case"record":{let s=k(e.value,n,r,t);return s===g?{}:{key:s}}case"enum":return e.values[0];case"literal":return e.value;case"union":{for(let s of e.members){let i=k(s,n,r,t);if(i!==g)return i}return e.members.length>0?g:null}case"intersection":{let{merged:s,rest:i}=D(e.members,n),u=i.map(f=>k(f,n,r,t)).filter(f=>f!==g);if(s){let f=k(s,n,r,t),j=$(f)?f:{};for(let A of u)$(A)&&Object.assign(j,A);return j}let h=u.filter($);return h.length>0?h.reduce((f,j)=>Object.assign(f,j),{}):u.length>0?u[0]:{}}case"omit":{let s=n.get(e.base);if(!s)return null;let i=k(s,n,r,t);if($(i)){let u={...i};for(let h of e.keys)delete u[h];return u}return i}case"ref":{if(r.has(e.name))return g;let s=n.get(e.name);if(!s)return null;r.add(e.name);let i=k(s,n,r,t);return r.delete(e.name),i}case"null":case"unknown":return null}}function v(e,n){if(e==="boolean")return!0;if(e==="integer"||e==="number")return 0;switch(n?.format){case"email":return"user@example.com";case"uuid":return"00000000-0000-4000-8000-000000000000";case"date-time":return"2024-01-01T00:00:00Z";case"date":return"2024-01-01";case"uri":case"url":return"https://example.com";default:return"string"}}var l=e=>({kind:"expr",text:e}),m=e=>({kind:"object",entries:e});function d(e){return e.kind==="object"}function E(e,n){return d(e)?m([...e.entries,{spread:n}]):e}var B=" ";function y(e,n){switch(e.kind){case"expr":return e.text;case"wrap":return`${e.before}${y(e.value,n)}${e.after}`;case"array":{if(e.items.length===0)return"[]";let r=n+B;return`[
|
|
8
|
-
${e.items.map((o,a)=>`${r}${y(o,r)}${a===e.items.length-1?"":","}`).join(`
|
|
9
|
-
`)}
|
|
10
|
-
${n}]`}case"object":{if(e.entries.length===0)return"{}";let r=n+B;return`{
|
|
11
|
-
${e.entries.map((o,a)=>{let c=a===e.entries.length-1?"":",";if("spread"in o)return`${r}...${o.spread}${c}`;let s=C(o.key)===o.key?o.key:q(o.key);return`${r}${s}: ${y(o.value,r)}${c}`}).join(`
|
|
12
|
-
`)}
|
|
13
|
-
${n}}`}}}function K(e,n,r={}){let t=new Map(n.map(a=>[a.name,a.schema])),o=M(e,t,new Set,r.dateType??"string");return o===p?l("null"):o}var p=Symbol("cycle");function M(e,n,r,t){switch(e.kind){case"scalar":return l(U(e.scalar,e.metadata,t));case"array":{let o=M(e.items,n,r,t);return o===p?l("[]"):Z(o)}case"object":return m(e.properties.flatMap(o=>{let a=M(o.schema,n,r,t);return a===p?o.required?[{key:o.name,value:l("null")}]:[]:[{key:o.name,value:a}]}));case"record":{let o=M(e.value,n,r,t);return o===p?l("{}"):m([{key:"key",value:o}])}case"enum":return l(`faker.helpers.arrayElement([${e.values.map(o=>b(o)).join(", ")}] as const)`);case"literal":return l(b(e.value));case"union":{for(let o of e.members){let a=M(o,n,r,t);if(a!==p)return a}return e.members.length>0?p:l("null")}case"intersection":{let{merged:o,rest:a}=D(e.members,n),c=a.map(i=>M(i,n,r,t)).filter(i=>i!==p);if(o){let i=M(o,n,r,t),u=i!==p&&d(i)?i.entries:[],h=c.filter(d).flatMap(f=>f.entries);return m([...u,...h])}let s=c.filter(d);return s.length>0?m(s.flatMap(i=>i.entries)):c[0]??m([])}case"omit":return z(e.base,e.keys,n,r,t);case"ref":{if(r.has(e.name))return p;let o=n.get(e.name);if(!o)return l("null");r.add(e.name);let a=M(o,n,r,t);return r.delete(e.name),a}case"null":case"unknown":return l("null")}}function U(e,n,r){if(n?.format==="binary")return"new Blob([])";if(e==="boolean")return"faker.datatype.boolean()";if(e==="integer")return`faker.number.int(${J(n)})`;if(e==="number")return`faker.number.float(${J(n)})`;switch(n?.format){case"email":return"faker.internet.email()";case"uuid":return"faker.string.uuid()";case"uri":case"url":return"faker.internet.url()";case"hostname":return"faker.internet.domainName()";case"ipv4":return"faker.internet.ipv4()";case"date-time":return L(r,!1);case"date":return L(r,!0);default:return"faker.lorem.word()"}}function L(e,n){if(e==="Date")return"faker.date.recent()";let r="faker.date.recent().toISOString()";return n?`${r}.slice(0, 10)`:r}function J(e){let n=[...e?.minimum!==void 0?[`min: ${e.minimum}`]:[],...e?.maximum!==void 0?[`max: ${e.maximum}`]:[]];return n.length>0?`{ ${n.join(", ")} }`:""}function Z(e){let n=d(e);return{kind:"wrap",before:`faker.helpers.multiple(() => ${n?"(":""}`,value:e,after:`${n?")":""}, { count: 1 })`}}function z(e,n,r,t,o){let a=r.get(e);if(!a)return l("null");let c=M(a,r,t,o);if(c===p||!d(c))return c;let s=new Set(n);return m(c.entries.filter(i=>"spread"in i||!s.has(i.key)))}var F=" ";function w(e,n,r){return r.mockData==="faker"?K(e,n.schemas,{dateType:r.dateType}):R(H(e,n.schemas,{dateType:r.dateType}))}function G(e,n){let r=I(e.services);if(r.length===0)return"";let t=[...Q(e,n),...n.mockData==="faker"&&n.mockSeed!==void 0?[`faker.seed(${n.mockSeed});`]:[],...e.schemas.map(a=>X(a,e,n)),...r.flatMap(a=>[_(a,e,n),...a.errorResponses.length>0?[N(a,e,n)]:[]]),ae(r)];return`import { http, HttpResponse } from 'msw';
|
|
14
|
-
${n.mockData==="faker"?`import { faker } from '@faker-js/faker';
|
|
15
|
-
`:""}
|
|
16
|
-
${t.join(`
|
|
17
|
-
|
|
18
|
-
`)}`}function Q(e,n){return e.schemas.length===0?[]:[`import type { ${e.schemas.map(t=>t.name).sort().join(", ")} } from ${JSON.stringify(n.sdkModule)};`]}function X(e,n,r){let t=O(e.name),o=w(e.schema,n,r),a=e.name,c=d(o),s=y(c?E(o,"overrides"):o,F),i=c?e.schema.kind==="union"?`${s} as ${a}`:s:`overrides ?? ${s}`,u=c?`Partial<${a}>`:a;return[`export function create${t}(overrides?: ${u}): ${a} {`,`${F}return ${i};`,"}"].join(`
|
|
19
|
-
`)}function x(e){if(!T(e))throw new Error(`Unsafe identifier in mock emission: ${JSON.stringify(e)}`);return e}function _(e,n,r){let o=re(e,n,r)??"",a=`http.${x(e.method)}(${JSON.stringify(W(e.path))}, () => ${te(e,n,r)})`;return`export const ${x(e.name)}Handler = (${o}) => ${a};`}function N(e,n,r){let t=e.errorResponses[0],a=`() => HttpResponse.json(body ?? ${y(w(t.schema,n,r),"")}, { status })`,c=`http.${x(e.method)}(${JSON.stringify(W(e.path))}, ${a})`;return`export const ${x(e.name)}ErrorHandler = (status: ${ee(e)}, body?: ${ne(e)}) => ${c};`}function ee(e){let r=[...new Set(e.errorResponses.filter(t=>typeof t.status=="number").map(t=>t.status))].map(String);return e.errorResponses.some(t=>typeof t.status!="number")&&r.push("number"),r.join(" | ")}function ne(e){let n=new Set,r=!1;for(let o of e.errorResponses)o.schema.kind==="ref"?n.add(o.schema.name):r=!0;let t=[...n];return(r||t.length===0)&&t.push("unknown"),t.join(" | ")}function re(e,n,r){let t=e.successResponses[0];if(!(!t||t.schema.kind==="unknown")){if(t.schema.kind==="ref"){let o=t.schema.name;return`override?: ${d(w(t.schema,n,r))?`Partial<${o}>`:o}`}if(d(w(t.schema,n,r)))return"override?: Record<string, unknown>"}}function te(e,n,r){let t=e.successResponses[0],o=oe(t?.status);if(!t||t.schema.kind==="unknown")return`new HttpResponse(null, { status: ${o} })`;let a=t.schema.kind==="ref"?`create${O(t.schema.name)}(override)`:y(E(w(t.schema,n,r),"override"),"");return`HttpResponse.json(${o===200?a:`${a}, { status: ${o} }`})`}function oe(e){return typeof e=="number"?e:200}function ae(e){return`export const handlers = [${e.map(r=>`${x(r.name)}Handler()`).join(", ")}];`}function W(e){return`*${e.replace(/\{([^{}]+)\}/g,":$1")}`}function R(e){return e instanceof S?l(e.code):Array.isArray(e)?{kind:"array",items:e.map(R)}:$(e)?m(Object.entries(e).map(([n,r])=>({key:n,value:R(r)}))):l(b(e))}var xe=({model:e,output:n,banner:r,emit:t})=>{let o=r.map(c=>`// ${c}`).join(`
|
|
20
|
-
`),a=G(e,{sdkModule:`./${n.stem}.${t.importExt??"js"}`,dateType:t.dateType,mockData:t.mockData,mockSeed:t.mockSeed});return a===""?[]:[{path:se(n.dir,`${n.stem}.mocks.ts`),content:`${o}
|
|
21
|
-
|
|
22
|
-
${a}`}]};export{xe as mockGenerator};
|
package/lib/chunks/PFYPTG4G.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
|
-
var r=class extends Error{constructor(s){super(s),this.name="NotSupportedError"}};export{r as a};
|
package/lib/chunks/RBHN62FF.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{d as a,e as b,f as c}from"./67BLI5YQ.js";import"./UKSQ7B5H.js";import"./TVJE32GA.js";import"./LWB43R4X.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./NB54XRRU.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{b as typescriptDocs,a as typescriptGenerator,c as typescriptSample};
|
package/lib/chunks/REFX2EKS.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{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};
|
package/lib/chunks/SGBB4RNM.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as 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};
|
package/lib/chunks/SQVG3CEM.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{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};
|
package/lib/chunks/TVJE32GA.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as c,m as u}from"./HJYFWIVE.js";function m(e,n){let t=n??{},o=e.specName??e.name;if(Array.isArray(t.exclude)&&t.exclude.includes(o))return;let r=(t.operations??{})[o]??e.paginationExtension;if(r===void 0&&typeof t.style=="string"){let{exclude:l,operations:A,...p}=t,f=p.style==="cursor"?p.cursorParam:p.offsetParam;(p.style==="link"?e.successResponseHeaders?.some(d=>d.name==="link")===!0:typeof f=="string"&&e.queryParams.some(d=>d.name===f))&&(r=p)}if(r===void 0||typeof r.style!="string")return;let s=r.style==="cursor"?r.cursorParam:r.offsetParam;return{style:r.style,...typeof s=="string"?{param:s}:{},...typeof r.nextCursor=="string"?{nextCursor:r.nextCursor}:{},...typeof r.hasMore=="string"?{hasMore:r.hasMore}:{},...typeof r.limitParam=="string"?{limitParam:r.limitParam}:{},...typeof r.items=="string"?{items:r.items}:{}}}function g(e){return(e??"").replace(/\s+/g," ").trim().replace(/\\/g,"\\\\").replace(/\|/g,"\\|")}function a(e){switch(e.kind){case"ref":return e.name;case"omit":return e.base;case"scalar":return e.scalar;case"array":return`array of ${a(e.items)}`;case"record":return`map of ${a(e.value)}`;case"enum":{let n=e.values.map(String),t=n.slice(0,6).join(", ");return n.length>6?`enum: ${t}, and ${n.length-6} more`:`enum: ${t}`}case"literal":return String(e.value);case"union":return e.members.map(a).join(" or ");case"intersection":return e.members.map(a).join(" and ");case"object":return"object";case"null":return"null";case"unknown":return"any"}}function y(e){return e.successResponses.some(n=>n.contentType.toLowerCase().includes("json"))?!1:e.successResponses.some(n=>n.contentType.startsWith("image/")||n.contentType==="application/octet-stream")}function x(e,n){e.line("| Parameter | In | Type | Required | Description |"),e.line("| --------- | -- | ---- | -------- | ----------- |");for(let t of n)e.line(`| \`${t.name}\` | ${t.in} | ${g(a(t.schema))} | ${t.required?"yes":"no"} | ${g(t.description)} |`);e.blank()}function C(e,n,t){e.line(`### \`${n.specName??n.name}\``),e.blank(),n.summary!==void 0&&(e.line(g(n.summary)),e.blank()),e.line(`\`${n.method.toUpperCase()} ${n.path}\``),e.blank();let o=t.sample(n);if(o!==void 0){e.line("```"+t.language.fence);for(let l of o.source.replace(/\n+$/,"").split(`
|
|
8
|
-
`))e.line(l);e.line("```"),e.blank()}let i=[...n.pathParams,...n.queryParams,...n.headerParams];i.length>0&&x(e,i),n.requestBody!==void 0&&e.line(`Body: \`${n.requestBody.contentType}\`${n.requestBody.required?", required":", optional"}, of type ${a(n.requestBody.schema)}.`);let r=n.successResponses[0];e.line(r===void 0?"Returns no content.":`Returns \`${r.contentType}\`, of type ${a(r.schema)}.`),(t.paginated!==void 0?t.paginated.has(n.name):m(n,t.pagination)!==void 0)&&e.line("This operation is paginated, so the SDK gives it page and item iterators."),n.successResponses.some(l=>l.contentType==="text/event-stream")&&e.line("This operation streams server-sent events, so the SDK iterates the events."),y(n)&&e.line("This operation returns binary content."),e.blank()}function R(e,n){let t=new c;if(n.frontmatter&&(t.line("---"),t.line(`title: ${n.title}`),t.line("---"),t.blank()),t.line(`# ${n.title}`),t.blank(),t.line(`Generated reference for the ${n.language.label} SDK, produced from the API description by \`redocly generate-client\`.`),t.line("Re-run generation to update it \u2014 this file is not hand-edited."),t.blank(),t.line(n.language.requires),t.blank(),t.line("## Authentication"),t.blank(),e.securitySchemes.length===0)t.line("The description declares no security schemes.");else{t.line("The description declares these schemes, which you pass to the client:"),t.blank(),t.line("| Scheme | Kind | Sent as |"),t.line("| ------ | ---- | ------- |");for(let r of e.securitySchemes){let s=r.kind==="bearer"?"`Authorization: Bearer <token>`":r.kind==="basic"?"`Authorization: Basic <base64>`":r.kind==="apiKeyHeader"?`the \`${r.headerName}\` header`:r.kind==="apiKeyQuery"?`the \`${r.paramName}\` query parameter`:`the \`${r.cookieName}\` cookie`;t.line(`| \`${r.key}\` | ${r.kind} | ${s} |`)}}t.blank();let o=e.services.flatMap(r=>r.operations),i=[...new Set(o.map(r=>r.tags[0]))];for(let r of i){t.line(r===void 0?"## Operations":`## ${r}`),t.blank();for(let s of o.filter(l=>l.tags[0]===r))C(t,s,n)}return t.toString().replace(/\n{3,}/g,`
|
|
9
|
-
|
|
10
|
-
`).trimEnd()+`
|
|
11
|
-
`}function h(e){return e.successResponses.find(n=>n.contentType.toLowerCase().includes("json"))?.schema}function S(e){return e.successResponses.find(n=>n.contentType.toLowerCase().includes("text/event-stream"))}function b(e){return e.requestBody?.contentType.toLowerCase().includes("multipart")??!1}function k(e){let n=new Set(e.variables.map(s=>s.name)),t=[],o="",i=e.url,r=/\{([^{}]+)\}/;for(let s=r.exec(i);s!==null;s=r.exec(i))o+=i.slice(0,s.index),n.has(s[1])?(o!==""&&t.push({kind:"literal",value:o}),o="",t.push({kind:"variable",name:s[1]})):o+=s[0],i=i.slice(s.index+s[0].length);return o+=i,(o!==""||t.length===0)&&t.push({kind:"literal",value:o}),t}function P(e,n){return e.security.map(t=>t.flatMap(o=>{let i=n.securitySchemes.find(r=>r.key===o);return i===void 0?[]:i.kind==="bearer"||i.kind==="basic"?[{scheme:o,kind:i.kind}]:i.kind==="apiKeyHeader"?[{scheme:o,kind:"apiKey",name:i.headerName,in:"header"}]:i.kind==="apiKeyQuery"?[{scheme:o,kind:"apiKey",name:i.paramName,in:"query"}]:[{scheme:o,kind:"apiKey",name:i.cookieName,in:"cookie"}]})).filter(t=>t.length>0)}function M(e,n,t){if(e===void 0||n===void 0)return;let o=u(e,n,t);return o?.kind==="array"?o.items:void 0}var Z=["Printer","casing","identifierFor","uniqueIdentifiers","RESERVED_WORDS","flattenAllOf","deref","discriminatorCases","jsonSuccessSchema","sseResponse","isMultipartBody","serverUrlParts","securityRequirements","paginationItemSchema","isNullable","unwrapNullable","enumValues","docText","headerCoerceType","schemaAtPointer","paginationRuleFor","renderReferencePage","NotSupportedError"];function O(e){return e}function v(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).join("-")}function q(e){return e.replace(/[^A-Za-z0-9]+/g,"_").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toUpperCase()}function w(e,n){let t={...e};for(let[o,i]of Object.entries(n))i!==void 0&&(t[o]=i);return t}function pe(e){return e}async function fe(e){return(await import("./OIVSGFXK.js")).generateClient(e)}export{m as a,R as b,h as c,S as d,b as e,k as f,P as g,M as h,Z as i,O as j,v as k,q as l,w as m,pe as n,fe as o};
|
package/lib/chunks/VRWULG7P.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,f}from"./ECZA233J.js";import"./SQVG3CEM.js";import"./UKSQ7B5H.js";import"./TVJE32GA.js";import"./LWB43R4X.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{f as pythonDocs,d as pythonGenerator,c as pythonOptions,e as pythonSample,a as pythonType,b as renderPythonModels};
|
package/lib/chunks/VZCENZBY.js
DELETED
|
@@ -1,30 +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 T}from"./LWB43R4X.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};
|
package/lib/chunks/WSOCDFHJ.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"./Y4BUDNR4.js";import"./REFX2EKS.js";import"./UKSQ7B5H.js";import"./TVJE32GA.js";import"./LWB43R4X.js";import"./PFYPTG4G.js";import"./OZMIIHFH.js";import"./NEWT5A6S.js";import"./HJYFWIVE.js";import"./RFWIIJFG.js";export{e as goDocs,c as goGenerator,d as goSample,a as goType,b as renderGoModels};
|
package/lib/chunks/Y4BUDNR4.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 f}from"./REFX2EKS.js";import{a as N}from"./UKSQ7B5H.js";import{b as E,c as U,d as j,e as K,f as J,g as z,h as Q}from"./TVJE32GA.js";import{a as M}from"./PFYPTG4G.js";import{b as O,c as H,d as w,e as B,g as F,h as G,i as T,j as W,k as _,n as A}from"./HJYFWIVE.js";var c=new S,y=H.go;function V(e){if(e===void 0)return"client";if(!/^[a-z_][a-z0-9_]*$/.test(e)||y.has(e))throw new M(`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 R(e){let t=new Set,n=[];for(let r of e.services)for(let o of r.operations){let a=f(o.name),s=2;for(;t.has(a);)a=`${f(o.name)}${s++}`;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):w(n.name,{style:"camel",reserved:y})).join(" + ")}function X(e,t){let n=t.servers??[];if(n.length===0)return;let r=new Set;n.forEach((o,a)=>{let s=`${f(o.description??`server${a+1}`)}URL`;r.has(s)&&(s=`${s}${a+1}`),r.add(s);let i=o.variables.map(l=>`${w(l.name,{style:"camel",reserved:y})} string`),u=o.variables.map(l=>`${w(l.name,{style:"camel",reserved:y})} default: ${c.string(l.default)}`).join(", ");e.line(`// ${s} returns the ${c.string(o.description??o.url)} base URL${u===""?".":` (${u}).`}`),e.block(`func ${s}(${i.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(T(e)){let n=g(W(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 f(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 f(e.base);case"union":case"null":case"object":case"intersection":case"unknown":return"any"}}function ae(e,t,n,r,o){e.doc(f(t),o),e.block(`type ${f(t)} struct {`,()=>{for(let a of n){let s=f(a.name),i=g(a.schema,r),u=`\`json:"${a.name}"\``;a.required||(!i.startsWith("*")&&!i.startsWith("[]")&&!i.startsWith("map[")&&i!=="any"&&(i=`*${i}`),u=`\`json:"${a.name},omitempty"\``),e.line(`${s} ${i} ${u}`)}},"}"),e.blank()}function D(e,t="string"){let n=new S;n.line("package client"),n.blank(),e.schemas.some(({schema:a})=>G(a,e)!==void 0)&&(n.line('import "encoding/json"'),n.blank());let o=se(e,t);return t==="Date"&&o.includes("time.Time")&&(n.line('import "time"'),n.blank()),n.line(o),n.toString()}function se(e,t){let n=new S;for(let{name:r,schema:o}of e.schemas){let a=_(o);if(a!==void 0){let i=a.scalar==="string"?"string":"int64";n.doc(f(r),o.description),n.line(`type ${f(r)} ${i}`),n.blank(),n.block("const (",()=>{let u=new Set;a.values.forEach(l=>{let d=O.pascal(String(l))||"Value",m="";for(let k=2;u.has(d+m);k++)m=String(k);u.add(d+m);let p=f(r)+d+m;n.line(`${p} ${f(r)} = ${c.literal(l)}`)})},")"),n.blank();continue}if(o.kind==="object"||o.kind==="intersection"){let i=F(o,e);if(i!==void 0){ae(n,r,i.properties,t,i.description??o.description);continue}}let s=G(o,e);if(s!==void 0){let i=f(r),u=s.cases.map(l=>`${l.value} -> ${f(l.schemaName)}`).join(", ");n.line(`// ${i} is a discriminated union ("${s.property}"): ${u}.`),n.line(`type ${i} = any`),n.blank(),n.line(`// Unmarshal${i} decodes into the member selected by "${s.property}".`),n.block(`func Unmarshal${i}(data []byte) (${i}, error) {`,()=>{n.block("var probe struct {",()=>{n.line(`Discriminant string \`json:"${s.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 s.cases)n.block(`case ${c.string(l.value)}:`,()=>{n.line(`var value ${f(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(f(r),o.description),n.line(`type ${f(r)} = ${g(o,t)}`),n.blank()}return n.toString()}function q(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 ie=["c","ctx","body","params","out","op"];function I(e,t){let n=B(e.pathParams.map(r=>r.name),{style:"camel",reserved:y,taken:ie});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=f(r.name),a=o,s=2;for(;n.has(a);)a=`${o}${s++}`;n.add(a);let i=A(r.schema,t),u={integer:{goType:"*int64",helper:"headerInt64"},number:{goType:"*float64",helper:"headerFloat64"},boolean:{goType:"*bool",helper:"headerBool"},string:{goType:"*string",helper:"headerString"}}[i];return{field:a,name:r.name,...u}})}function L(e,t,n,r,o,a=!1){let s=I(t,r),i=t.queryParams.length>0,u=U(t),l=u===void 0?void 0:g(u,r),d=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 $ of d)e.line(`${$.field} ${$.goType}`)},"}"),e.blank());let m=["ctx context.Context",...s.map(({go:$,type:v})=>`${$} ${v}`),...t.requestBody?[`body ${g(t.requestBody.schema,r)}`]:[],...i?[`params *${n}Params`]:[]],p=j(t),k=a?l===void 0?`(${n}Headers, error)`:`(${l}, ${n}Headers, error)`:p!==void 0?"func(yield func(ServerSentEvent, error) bool)":l===void 0?"error":`(${l}, error)`,b=$=>a?l===void 0?`return headers, ${$}`:`return out, headers, ${$}`:l===void 0?`return ${$}`:`return out, ${$}`,P=a?`${n}WithHeaders`:n;e.doc(P,a?`Like ${n}, also returning the declared response headers.`:t.summary),e.block(`func (c *Client) ${P}(${m.join(", ")}) ${k} {`,()=>{p===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)"),i&&e.block("if params != nil {",()=>{for(let h of t.queryParams){let x=f(h.name);e.block(`if params.${x} != nil {`,()=>{if(h.schema.kind==="array"){let C=g(h.schema.items,r);e.block(`for _, item := range *params.${x} {`,()=>{e.line(`query.Add(${c.string(h.name)}, ${q("item",C)})`)},"}")}else e.line(`query.Set(${c.string(h.name)}, ${q(`*params.${x}`,g(h.schema,r))})`)},"}")}},"}");let $=s.map(({param:h,go:x,type:C})=>`${c.string(h.name)}: ${q(x,C)}`).join(", ");if(e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${$}})`),p!==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, ${p.schema!==void 0&&p.schema.kind!=="unknown"})`);return}let v=["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(b("err"))},"}"),v.push("Body: reader"),v.push("ContentType: contentType")):t.requestBody&&(e.line("payload, err := json.Marshal(body)"),e.block("if err != nil {",()=>{e.line(b("err"))},"}"),v.push("Body: bytes.NewReader(payload)"),v.push(`ContentType: ${c.string(t.requestBody.contentType)}`)),e.line(`resp, err := send(ctx, &c.config, requestSpec{${v.join(", ")}})`),e.block("if err != nil {",()=>{e.line(b("err"))},"}"),e.block("if resp.StatusCode >= 400 {",()=>{e.line(b("apiErrorFrom(resp, requestURL)"))},"}"),a){e.block(`if err := decodeJSON(resp, ${l===void 0?"nil":"&out"}); err != nil {`,()=>{e.line(b("err"))},"}");for(let h of d)e.line(`headers.${h.field} = ${h.helper}(resp.Header, ${c.string(h.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 s=I(t,r),i=t.queryParams.length>0,u=["ctx context.Context",...s.map(({go:d,type:m})=>`${d} ${m}`),...i?[`params *${n}Params`]:[]].join(", "),l=()=>{e.line(`op := operations[${c.string(t.specName??t.name)}]`),e.line("base := url.Values{}"),i&&e.block("if params != nil {",()=>{for(let d of t.queryParams){let m=f(d.name);e.block(`if params.${m} != nil {`,()=>{e.line(`base.Set(${c.string(d.name)}, ${q(`*params.${m}`,g(d.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 d=s.map(({param:m,go:p,type:k})=>`${c.string(m.name)}: ${q(p,k)}`).join(", ");e.line(`requestURL := buildURL(c.config.ServerURL, op.Path, map[string]string{${d}})`),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(D(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(N)),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:s,ident:i}of R(t)){let u=s.specName??s.name,l=Y(s,t),d=o.get(i),m=[`ID: ${c.string(u)}`,`Method: ${c.string(s.method.toUpperCase())}`,`Path: ${c.string(s.path)}`,...l!==void 0?[`Security: ${l}`]:[],...d!==void 0?[`Pagination: ${Z(d)}`]:[]];e.line(`${c.string(u)}: {${m.join(", ")}},`)}},"}"),e.blank();for(let{op:s,ident:i}of R(t))s.queryParams.length!==0&&(e.block(`type ${i}Params struct {`,()=>{for(let u of s.queryParams){let l=g(u.schema,r);e.line(`${f(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:s,ident:i}of R(t)){L(e,s,i,r),j(s)===void 0&&(s.successResponseHeaders?.length??0)>0&&L(e,s,i,r,t,!0);let u=o.get(i);if(u===void 0)continue;let l=U(s),d=l===void 0?"any":g(l,r),m=Q(l,u.items,t);ee(e,s,i,r,d,m===void 0?"any":g(m,r))}}var ze=({model:e,output:t,banner:n,emit:r,pagination:o})=>{let a=new S,s=r.dateType??"string",i=V(r.goPackage),u=new Map;for(let{op:b,ident:P}of R(e)){let $=o?.get(b.name)?.spec;$!==void 0&&u.set(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 ${i}`),a.blank();let l=r.runtime!=="module",d=l?te:(()=>{let b=new S;re(b,e,r,s,u,!1);let P=b.toString();return te.filter($=>new RegExp(`\\b${$.split("/").pop()}\\.`).test(P))})();a.block("import (",()=>{for(let b of d)a.line(c.string(b))},")"),a.blank(),re(a,e,r,s,u,l);let m={path:t.path.replace(/\.[^.\\/]+$/,".go"),content:a.toString()};if(l)return[m];let p=n.map(b=>`// ${b}`).join(`
|
|
10
|
-
`),k=N.replace(/^package .*$/m,`package ${i}`);return[m,{path:m.path.replace(/[^\\/]+$/,"runtime.go"),content:`${p}
|
|
11
|
-
${k.trimEnd()}
|
|
12
|
-
`}]};function ce(e,t){let n=t.emit.dateType??"string",r=t.emit.goPackage??"client",o=R(t.model).find(u=>u.op.name===e.name)?.ident??f(e.name),a=["ctx",...e.pathParams.map(u=>`"<${w(u.name,{style:"camel",reserved:y})}>"`),...e.requestBody?[`${g(e.requestBody.schema,n)}{ /* \u2026 */ }`]:[],...e.queryParams.length>0?["nil"]:[]],s=`client.${o}(${a.join(", ")})`,i=j(e)!==void 0?`stream := ${s}`:U(e)===void 0?`err := ${s}`:`result, err := ${s}`;return{lang:"go",label:"Go SDK",source:`client := ${r}.New(${r}.Config{})
|
|
13
|
-
${i}
|
|
14
|
-
`}}var Qe=({model:e,output:t,emit:n,pagination:r})=>[{path:t.path.replace(/\.[^.\\/]+$/,".go.md"),content:E(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{g as a,D as b,ze as c,ce as d,Qe as e};
|
package/lib/chunks/ZBL4IVEW.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from 'node:module';
|
|
2
|
-
import { fileURLToPath as __fileURLToPath } from 'node:url';
|
|
3
|
-
import { dirname as __pathDirname } from 'node:path';
|
|
4
|
-
const require = __createRequire(import.meta.url);
|
|
5
|
-
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = __pathDirname(__filename);
|
|
7
|
-
import{a as m}from"./3JJEI7CJ.js";import{a as s}from"./PFYPTG4G.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 l="@redocly/client-generator";function y(n){let i=e.default.createSourceFile("setup.ts",n,e.default.ScriptTarget.Latest,!0,e.default.ScriptKind.TS),p=[],r,d="defineClientSetup";for(let t of i.statements){if(e.default.isImportDeclaration(t)){let o=t.moduleSpecifier.text;if(o!==l)throw new s(`A --setup file may only import from "${l}"; found "${o}". Setup code may use web globals and the client contract only (keeps the client zero-dependency).`);let a=t.importClause?.namedBindings;if(a&&e.default.isNamedImports(a))for(let c of a.elements)(c.propertyName?.text??c.name.text)==="defineClientSetup"&&(d=c.name.text);continue}if(e.default.isExportAssignment(t)&&!t.isExportEquals){r=g(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 "${l}"; 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(o=>o.kind===e.default.SyntaxKind.ExportKeyword):void 0;p.push(u===void 0?t.getText(i):n.slice(u.end,t.getEnd()).trimStart())}if(r===void 0)throw new s("A --setup file must `export default defineClientSetup({ config, middleware })` (or a setup object).");return p.length===0?r:`(() => {
|
|
8
|
-
${p.join(`
|
|
9
|
-
`)}
|
|
10
|
-
return ${r};
|
|
11
|
-
})()`}function g(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{y as bakeSetup};
|
|
File without changes
|