@povio/openapi-codegen-cli 0.3.5 → 0.3.6
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/README.md +1 -0
- package/dist/commands/generate.d.ts +3 -8
- package/dist/generators/core/SchemaResolver.class.d.ts +1 -0
- package/dist/generators/utils/generate/generate.endpoints.utils.d.ts +1 -4
- package/dist/generators/utils/generate/generate.imports.utils.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/sh.js +52 -52
- package/package.json +1 -1
- package/src/generators/templates/models.hbs +2 -2
- package/src/generators/templates/partials/endpoint-config.hbs +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,7 @@ yarn openapi-codegen generate --input http://localhost:3001/docs-json
|
|
|
30
30
|
--defaultTag Default tag name for code shared accross multiple tags (default: 'Common')
|
|
31
31
|
--excludeTags Comma separated list of tags excluded from the output
|
|
32
32
|
--removeOperationPrefixEndingWith Removes prefix that ends with value from operation names (default: 'Controller_')
|
|
33
|
+
--importPath Import path (default: 'ts', possible: 'ts' | 'relative' | 'absolute')
|
|
33
34
|
--prettier Run prettier command on output after code generation (default: true)
|
|
34
35
|
--verbose Show log messages during execution
|
|
35
36
|
```
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
+
import { GenerateOptions } from "src/generators/types/options";
|
|
1
2
|
export type GenerateParams = {
|
|
2
3
|
input: string;
|
|
3
|
-
output: string;
|
|
4
|
-
includeNamespaces: boolean;
|
|
5
|
-
useRelativeImports: boolean;
|
|
6
|
-
splitByTags: boolean;
|
|
7
|
-
defaultTag: string;
|
|
8
4
|
excludeTags: string;
|
|
9
|
-
removeOperationPrefixEndingWith: string;
|
|
10
5
|
prettier: boolean;
|
|
11
6
|
verbose: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function generate({ input,
|
|
7
|
+
} & Pick<GenerateOptions, "output" | "includeNamespaces" | "splitByTags" | "defaultTag" | "removeOperationPrefixEndingWith" | "importPath">;
|
|
8
|
+
export declare function generate({ input, excludeTags, prettier, verbose, ...params }: GenerateParams): Promise<void>;
|
|
@@ -24,6 +24,7 @@ export declare class SchemaResolver {
|
|
|
24
24
|
getSchemaByCompositeZodSchemaName(compositeZodSchemaName: string): OpenAPIV3.SchemaObject | undefined;
|
|
25
25
|
getZodSchemas(): {};
|
|
26
26
|
resolveObject<T>(obj: OpenAPIV3.ReferenceObject | T): T;
|
|
27
|
+
isSchemaCircular(ref: string): boolean;
|
|
27
28
|
private intializeSchemaInfo;
|
|
28
29
|
private initializeSchemaTags;
|
|
29
30
|
private getOperationSchemaRefs;
|
|
@@ -17,10 +17,7 @@ export declare function mapEndpointParamsToFunctionParams({ resolver, endpoint,
|
|
|
17
17
|
required: boolean;
|
|
18
18
|
}[];
|
|
19
19
|
export declare function getEndpointConfig(endpoint: Endpoint): {
|
|
20
|
-
headers?:
|
|
21
|
-
Accept?: string | undefined;
|
|
22
|
-
"Content-Type"?: string | undefined;
|
|
23
|
-
} | undefined;
|
|
20
|
+
headers?: Record<string, string> | undefined;
|
|
24
21
|
params?: {
|
|
25
22
|
name: string;
|
|
26
23
|
value: string;
|
|
@@ -14,4 +14,4 @@ export declare function getEndpointsImports({ tag, endpoints, options, }: {
|
|
|
14
14
|
endpoints: Endpoint[];
|
|
15
15
|
options: GenerateOptions;
|
|
16
16
|
}): Import[];
|
|
17
|
-
export declare function getImportPath(options: Pick<GenerateOptions, "output" | "
|
|
17
|
+
export declare function getImportPath(options: Pick<GenerateOptions, "output" | "importPath">): string;
|
package/dist/index.js
CHANGED
|
@@ -47,8 +47,8 @@ Too many redirects:
|
|
|
47
47
|
Cannot set "${t}" of a non-object.`);return r}s(lh,"setValue");function ph(e){if(rE(e))throw e;return e}s(ph,"unwrapOrThrow")});var Ur=h((dR,yh)=>{"use strict";yh.exports=ce;var hh=Fn(),{InvalidPointerError:aE,isHandledError:cE,normalizeError:mh}=Re(),{safePointerToPath:uE,stripHash:fE,getHash:lE}=ge();function ce(){this.path=void 0,this.value=void 0,this.$refs=void 0,this.pathType=void 0,this.errors=void 0}s(ce,"$Ref");ce.prototype.addError=function(e){this.errors===void 0&&(this.errors=[]),Array.isArray(e.errors)?this.errors.push(...e.errors.map(mh)):this.errors.push(mh(e))};ce.prototype.exists=function(e,t){try{return this.resolve(e,t),!0}catch{return!1}};ce.prototype.get=function(e,t){return this.resolve(e,t).value};ce.prototype.resolve=function(e,t,r,n){let i=new hh(this,e,r);try{return i.resolve(this.value,t,n)}catch(o){if(!t||!t.continueOnError||!cE(o))throw o;return o.path===null&&(o.path=uE(lE(n))),o instanceof aE&&(o.source=fE(n)),this.addError(o),null}};ce.prototype.set=function(e,t){let r=new hh(this,e);this.value=r.set(this.value,t)};ce.is$Ref=function(e){return e&&typeof e=="object"&&typeof e.$ref=="string"&&e.$ref.length>0};ce.isExternal$Ref=function(e){return ce.is$Ref(e)&&e.$ref[0]!=="#"};ce.isAllowed$Ref=function(e,t){if(ce.is$Ref(e)){if(e.$ref.substr(0,2)==="#/"||e.$ref==="#")return!0;if(e.$ref[0]!=="#"&&(!t||t.resolve.external))return!0}};ce.isExtended$Ref=function(e){return ce.is$Ref(e)&&Object.keys(e).length>1};ce.dereference=function(e,t){if(t&&typeof t=="object"&&ce.isExtended$Ref(e)){let r={};for(let n of Object.keys(e))n!=="$ref"&&(r[n]=e[n]);for(let n of Object.keys(t))n in r||(r[n]=t[n]);return r}else return t}});var bh=h((hR,vh)=>{"use strict";var{ono:gh}=Ee(),pE=Ur(),bt=ge();vh.exports=Ne;function Ne(){this.circular=!1,this._$refs={},this._root$Ref=null}s(Ne,"$Refs");Ne.prototype.paths=function(e){return $h(this._$refs,arguments).map(r=>r.decoded)};Ne.prototype.values=function(e){let t=this._$refs;return $h(t,arguments).reduce((n,i)=>(n[i.decoded]=t[i.encoded].value,n),{})};Ne.prototype.toJSON=Ne.prototype.values;Ne.prototype.exists=function(e,t){try{return this._resolve(e,"",t),!0}catch{return!1}};Ne.prototype.get=function(e,t){return this._resolve(e,"",t).value};Ne.prototype.set=function(e,t){let r=bt.resolve(this._root$Ref.path,e),n=bt.stripHash(r),i=this._$refs[n];if(!i)throw gh(`Error resolving $ref pointer "${e}".
|
|
48
48
|
"${n}" not found.`);i.set(r,t)};Ne.prototype._add=function(e){let t=bt.stripHash(e),r=new pE;return r.path=t,r.$refs=this,this._$refs[t]=r,this._root$Ref=this._root$Ref||r,r};Ne.prototype._resolve=function(e,t,r){let n=bt.resolve(this._root$Ref.path,e),i=bt.stripHash(n),o=this._$refs[i];if(!o)throw gh(`Error resolving $ref pointer "${e}".
|
|
49
49
|
"${i}" not found.`);return o.resolve(n,r,e,t)};Ne.prototype._get$Ref=function(e){e=bt.resolve(this._root$Ref.path,e);let t=bt.stripHash(e);return this._$refs[t]};function $h(e,t){let r=Object.keys(e);return t=Array.isArray(t[0])?t[0]:Array.prototype.slice.call(t),t.length>0&&t[0]&&(r=r.filter(n=>t.indexOf(e[n].pathType)!==-1)),r.map(n=>({encoded:n,decoded:e[n].pathType==="file"?bt.toFileSystemPath(n,!0):n}))}s($h,"getPaths")});var Ph=h(Vn=>{"use strict";Vn.all=function(e){return Object.keys(e).filter(t=>typeof e[t]=="object").map(t=>(e[t].name=t,e[t]))};Vn.filter=function(e,t,r){return e.filter(n=>!!_h(n,t,r))};Vn.sort=function(e){for(let t of e)t.order=t.order||Number.MAX_SAFE_INTEGER;return e.sort((t,r)=>t.order-r.order)};Vn.run=function(e,t,r,n){let i,o,a=0;return new Promise((c,u)=>{f();function f(){if(i=e[a++],!i)return u(o);try{let m=_h(i,t,r,l,n);if(m&&typeof m.then=="function")m.then(p,d);else if(m!==void 0)p(m);else if(a===e.length)throw new Error("No promise has been returned or callback has been called.")}catch(m){d(m)}}s(f,"runNextPlugin");function l(m,y){m?d(m):p(y)}s(l,"callback");function p(m){c({plugin:i,result:m})}s(p,"onSuccess");function d(m){o={plugin:i,error:m},f()}s(d,"onError")})};function _h(e,t,r,n,i){let o=e[t];if(typeof o=="function")return o.apply(e,[r,n,i]);if(!n){if(o instanceof RegExp)return o.test(r.url);if(typeof o=="string")return o===r.extension;if(Array.isArray(o))return o.indexOf(r.extension)!==-1}return o}s(_h,"getResult")});var zc=h((vR,wh)=>{"use strict";var{ono:Lc}=Ee(),Sh=ge(),_t=Ph(),{ResolverError:Oh,ParserError:xh,UnmatchedParserError:dE,UnmatchedResolverError:mE,isHandledError:hE}=Re();wh.exports=yE;async function yE(e,t,r){e=Sh.stripHash(e);let n=t._add(e),i={url:e,extension:Sh.getExtension(e)};try{let o=await gE(i,r,t);n.pathType=o.plugin.name,i.data=o.result;let a=await $E(i,r,t);return n.value=a.result,a.result}catch(o){throw hE(o)&&(n.value=o),o}}s(yE,"parse");function gE(e,t,r){return new Promise((n,i)=>{let o=_t.all(t.resolve);o=_t.filter(o,"canRead",e),_t.sort(o),_t.run(o,"read",e,r).then(n,a);function a(c){!c&&t.continueOnError?i(new mE(e.url)):!c||!("error"in c)?i(Lc.syntax(`Unable to resolve $ref pointer "${e.url}"`)):c.error instanceof Oh?i(c.error):i(new Oh(c,e.url))}s(a,"onError")})}s(gE,"readFile");function $E(e,t,r){return new Promise((n,i)=>{let o=_t.all(t.parse),a=_t.filter(o,"canParse",e),c=a.length>0?a:o;_t.sort(c),_t.run(c,"parse",e,r).then(u,f);function u(l){!l.plugin.allowEmpty&&vE(l.result)?i(Lc.syntax(`Error parsing "${e.url}" as ${l.plugin.name}.
|
|
50
|
-
Parsed value is empty`)):n(l)}s(u,"onParsed");function f(l){!l&&t.continueOnError?i(new dE(e.url)):!l||!("error"in l)?i(Lc.syntax(`Unable to parse ${e.url}`)):l.error instanceof xh?i(l.error):i(new xh(l.error.message,e.url))}s(f,"onError")})}s($E,"parseFile");function vE(e){return e===void 0||typeof e=="object"&&Object.keys(e).length===0||typeof e=="string"&&e.trim().length===0||Buffer.isBuffer(e)&&e.length===0}s(vE,"isEmpty")});var qh=h((_R,Ah)=>{"use strict";var Eh=Ur(),bE=Fn(),_E=zc(),Ln=ge(),{isHandledError:PE}=Re();Ah.exports=SE;function SE(e,t){if(!t.resolve.external)return Promise.resolve();try{let r=Uc(e.schema,e.$refs._root$Ref.path+"#",e.$refs,t);return Promise.all(r)}catch(r){return Promise.reject(r)}}s(SE,"resolveExternal");function Uc(e,t,r,n){let i=[];if(e&&typeof e=="object"&&!ArrayBuffer.isView(e))if(Eh.isExternal$Ref(e))i.push(jh(e,t,r,n));else for(let o of Object.keys(e)){let a=bE.join(t,o),c=e[o];Eh.isExternal$Ref(c)?i.push(jh(c,a,r,n)):i=i.concat(Uc(c,a,r,n))}return i}s(Uc,"crawl");async function jh(e,t,r,n){let i=Ln.resolve(t,e.$ref),o=Ln.stripHash(i);if(e=r._$refs[o],e)return Promise.resolve(e.value);try{let a=await _E(i,r,n),c=Uc(a,o+"#",r,n);return Promise.all(c)}catch(a){if(!n.continueOnError||!PE(a))throw a;return r._$refs[o]&&(a.source=Ln.stripHash(t),a.path=Ln.safePointerToPath(Ln.getHash(t))),[]}}s(jh,"resolve$Ref")});var Rh=h((SR,Th)=>{"use strict";var Ji=Ur(),zn=Fn(),Bc=ge();Th.exports=OE;function OE(e,t){let r=[];Hc(e,"schema",e.$refs._root$Ref.path+"#","#",0,r,e.$refs,t),xE(r)}s(OE,"bundle");function Hc(e,t,r,n,i,o,a,c){let u=t===null?e:e[t];if(u&&typeof u=="object"&&!ArrayBuffer.isView(u))if(Ji.isAllowed$Ref(u))Ih(e,t,r,n,i,o,a,c);else{let f=Object.keys(u).sort((l,p)=>l==="definitions"?-1:p==="definitions"?1:l.length-p.length);for(let l of f){let p=zn.join(r,l),d=zn.join(n,l),m=u[l];Ji.isAllowed$Ref(m)?Ih(u,l,r,d,i,o,a,c):Hc(u,l,p,d,i,o,a,c)}}}s(Hc,"crawl");function Ih(e,t,r,n,i,o,a,c){let u=t===null?e:e[t],f=Bc.resolve(r,u.$ref),l=a._resolve(f,n,c);if(l===null)return;let p=zn.parse(n).length,d=Bc.stripHash(l.path),m=Bc.getHash(l.path),y=d!==a._root$Ref.path,$=Ji.isExtended$Ref(u);i+=l.indirections;let g=wE(o,e,t);if(g)if(p<g.depth||i<g.indirections)EE(o,g);else return;o.push({$ref:u,parent:e,key:t,pathFromRoot:n,depth:p,file:d,hash:m,value:l.value,circular:l.circular,extended:$,external:y,indirections:i}),g||Hc(l.value,null,l.path,n,i+1,o,a,c)}s(Ih,"inventory$Ref");function xE(e){e.sort((i,o)=>{if(i.file!==o.file)return i.file<o.file?-1:1;if(i.hash!==o.hash)return i.hash<o.hash?-1:1;if(i.circular!==o.circular)return i.circular?-1:1;if(i.extended!==o.extended)return i.extended?1:-1;if(i.indirections!==o.indirections)return i.indirections-o.indirections;if(i.depth!==o.depth)return i.depth-o.depth;{let a=i.pathFromRoot.lastIndexOf("/definitions"),c=o.pathFromRoot.lastIndexOf("/definitions");return a!==c?c-a:i.pathFromRoot.length-o.pathFromRoot.length}});let t,r,n;for(let i of e)i.external?i.file===t&&i.hash===r?i.$ref.$ref=n:i.file===t&&i.hash.indexOf(r+"/")===0?i.$ref.$ref=zn.join(n,zn.parse(i.hash.replace(r,"#"))):(t=i.file,r=i.hash,n=i.pathFromRoot,i.$ref=i.parent[i.key]=Ji.dereference(i.$ref,i.value),i.circular&&(i.$ref.$ref=i.pathFromRoot)):i.$ref.$ref=i.hash}s(xE,"remap");function wE(e,t,r){for(let n=0;n<e.length;n++){let i=e[n];if(i.parent===t&&i.key===r)return i}}s(wE,"findInInventory");function EE(e,t){let r=e.indexOf(t);e.splice(r,1)}s(EE,"removeFromInventory")});var Kc=h((xR,Mh)=>{"use strict";var Gc=Ur(),Nh=Fn(),{ono:jE}=Ee(),AE=ge();Mh.exports=qE;function qE(e,t){let r=Zc(e.schema,e.$refs._root$Ref.path,"#",[],e.$refs,t);e.$refs.circular=r.circular,e.schema=r.value}s(qE,"dereference");function Zc(e,t,r,n,i,o){let a,c={value:e,circular:!1};if(e&&typeof e=="object"&&!ArrayBuffer.isView(e)){if(n.push(e),Gc.isAllowed$Ref(e,o))a=kh(e,t,r,n,i,o),c.circular=a.circular,c.value=a.value;else for(let u of Object.keys(e)){let f=Nh.join(t,u),l=Nh.join(r,u),p=e[u],d=!1;Gc.isAllowed$Ref(p,o)?(a=kh(p,f,l,n,i,o),d=a.circular,e[u]!==a.value&&(e[u]=a.value)):n.indexOf(p)===-1?(a=Zc(p,f,l,n,i,o),d=a.circular,e[u]!==a.value&&(e[u]=a.value)):d=Ch(f,i,o),c.circular=c.circular||d}n.pop()}return c}s(Zc,"crawl");function kh(e,t,r,n,i,o){let a=AE.resolve(t,e.$ref),c=i._resolve(a,t,o);if(c===null)return{circular:!1,value:null};let u=c.circular,f=u||n.indexOf(c.value)!==-1;f&&Ch(t,i,o);let l=Gc.dereference(e,c.value);if(!f){let p=Zc(l,c.path,r,n,i,o);f=p.circular,l=p.value}return f&&!u&&o.dereference.circular==="ignore"&&(l=e),u&&(l.$ref=r),{circular:f,value:l}}s(kh,"dereference$Ref");function Ch(e,t,r){if(t.circular=!0,!r.dereference.circular)throw jE.reference(`Circular $ref pointer found at ${e}`);return!0}s(Ch,"foundCircularReference")});var Lh=h((ER,Ge)=>{"use strict";var Vh=bh(),IE=zc(),Xi=Cc(),TE=qh(),RE=Rh(),NE=Kc(),Br=ge(),{JSONParserError:kE,InvalidPointerError:CE,MissingPointerError:ME,ResolverError:DE,ParserError:FE,UnmatchedParserError:VE,UnmatchedResolverError:LE,isHandledError:zE,JSONParserErrorGroup:Dh}=Re(),ke=Dc(),{ono:Fh}=Ee();Ge.exports=He;Ge.exports.default=He;Ge.exports.JSONParserError=kE;Ge.exports.InvalidPointerError=CE;Ge.exports.MissingPointerError=ME;Ge.exports.ResolverError=DE;Ge.exports.ParserError=FE;Ge.exports.UnmatchedParserError=VE;Ge.exports.UnmatchedResolverError=LE;function He(){this.schema=null,this.$refs=new Vh}s(He,"$RefParser");He.parse=s(function(t,r,n,i){let o=this,a=new o;return a.parse.apply(a,arguments)},"parse");He.prototype.parse=s(async function(t,r,n,i){let o=Xi(arguments),a;if(!o.path&&!o.schema){let f=Fh(`Expected a file path, URL, or object. Got ${o.path||o.schema}`);return ke(o.callback,Promise.reject(f))}this.schema=null,this.$refs=new Vh;let c="http";if(Br.isFileSystemPath(o.path)&&(o.path=Br.fromFileSystemPath(o.path),c="file"),o.path=Br.resolve(Br.cwd(),o.path),o.schema&&typeof o.schema=="object"){let f=this.$refs._add(o.path);f.value=o.schema,f.pathType=c,a=Promise.resolve(o.schema)}else a=IE(o.path,this.$refs,o.options);let u=this;try{let f=await a;if(f!==null&&typeof f=="object"&&!Buffer.isBuffer(f))return u.schema=f,ke(o.callback,Promise.resolve(u.schema));if(o.options.continueOnError)return u.schema=null,ke(o.callback,Promise.resolve(u.schema));throw Fh.syntax(`"${u.$refs._root$Ref.path||f}" is not a valid JSON Schema`)}catch(f){return!o.options.continueOnError||!zE(f)?ke(o.callback,Promise.reject(f)):(this.$refs._$refs[Br.stripHash(o.path)]&&this.$refs._$refs[Br.stripHash(o.path)].addError(f),ke(o.callback,Promise.resolve(null)))}},"parse");He.resolve=s(function(t,r,n,i){let o=this,a=new o;return a.resolve.apply(a,arguments)},"resolve");He.prototype.resolve=s(async function(t,r,n,i){let o=this,a=Xi(arguments);try{return await this.parse(a.path,a.schema,a.options),await TE(o,a.options),Wc(o),ke(a.callback,Promise.resolve(o.$refs))}catch(c){return ke(a.callback,Promise.reject(c))}},"resolve");He.bundle=s(function(t,r,n,i){let o=this,a=new o;return a.bundle.apply(a,arguments)},"bundle");He.prototype.bundle=s(async function(t,r,n,i){let o=this,a=Xi(arguments);try{return await this.resolve(a.path,a.schema,a.options),RE(o,a.options),Wc(o),ke(a.callback,Promise.resolve(o.schema))}catch(c){return ke(a.callback,Promise.reject(c))}},"bundle");He.dereference=s(function(t,r,n,i){let o=this,a=new o;return a.dereference.apply(a,arguments)},"dereference");He.prototype.dereference=s(async function(t,r,n,i){let o=this,a=Xi(arguments);try{return await this.resolve(a.path,a.schema,a.options),NE(o,a.options),Wc(o),ke(a.callback,Promise.resolve(o.schema))}catch(c){return ke(a.callback,Promise.reject(c))}},"dereference");function Wc(e){if(Dh.getParserErrors(e).length>0)throw new Dh(e)}s(Wc,"finalize")});var Gh=h((AR,Hh)=>{"use strict";var UE=hc(),BE=$c(),zh=Cc(),Uh=Yn(),Bh=sh(),Qi=Dc(),{ono:Ce}=Ee(),Jt=Lh(),HE=Kc();Hh.exports=Ze;function Ze(){Jt.apply(this,arguments)}s(Ze,"SwaggerParser");Uh.inherits(Ze,Jt);Ze.parse=Jt.parse;Ze.resolve=Jt.resolve;Ze.bundle=Jt.bundle;Ze.dereference=Jt.dereference;Object.defineProperty(Ze.prototype,"api",{configurable:!0,enumerable:!0,get(){return this.schema}});Ze.prototype.parse=async function(e,t,r,n){let i=zh(arguments);i.options=new Bh(i.options);try{let o=await Jt.prototype.parse.call(this,i.path,i.schema,i.options);if(o.swagger){if(o.swagger===void 0||o.info===void 0||o.paths===void 0)throw Ce.syntax(`${i.path||i.schema} is not a valid Swagger API definition`);if(typeof o.swagger=="number")throw Ce.syntax('Swagger version number must be a string (e.g. "2.0") not a number.');if(typeof o.info.version=="number")throw Ce.syntax('API version number must be a string (e.g. "1.0.0") not a number.');if(o.swagger!=="2.0")throw Ce.syntax(`Unrecognized Swagger version: ${o.swagger}. Expected 2.0`)}else{let a=["3.0.0","3.0.1","3.0.2","3.0.3","3.1.0"];if(o.openapi===void 0||o.info===void 0)throw Ce.syntax(`${i.path||i.schema} is not a valid Openapi API definition`);if(o.paths===void 0)if(o.openapi==="3.1.0"){if(o.webhooks===void 0)throw Ce.syntax(`${i.path||i.schema} is not a valid Openapi API definition`)}else throw Ce.syntax(`${i.path||i.schema} is not a valid Openapi API definition`);else{if(typeof o.openapi=="number")throw Ce.syntax('Openapi version number must be a string (e.g. "3.0.0") not a number.');if(typeof o.info.version=="number")throw Ce.syntax('API version number must be a string (e.g. "1.0.0") not a number.');if(a.indexOf(o.openapi)===-1)throw Ce.syntax(`Unsupported OpenAPI version: ${o.openapi}. Swagger Parser only supports versions ${a.join(", ")}`)}Uh.fixOasRelativeServers(o,i.path)}return Qi(i.callback,Promise.resolve(o))}catch(o){return Qi(i.callback,Promise.reject(o))}};Ze.validate=function(e,t,r,n){let i=this,o=new i;return o.validate.apply(o,arguments)};Ze.prototype.validate=async function(e,t,r,n){let i=this,o=zh(arguments);o.options=new Bh(o.options);let a=o.options.dereference.circular;o.options.validate.schema&&(o.options.dereference.circular="ignore");try{if(await this.dereference(o.path,o.schema,o.options),o.options.dereference.circular=a,o.options.validate.schema&&(UE(i.api),i.$refs.circular)){if(a===!0)HE(i,o.options);else if(a===!1)throw Ce.reference("The API contains circular references")}return o.options.validate.spec&&BE(i.api),Qi(o.callback,Promise.resolve(i.schema))}catch(c){return Qi(o.callback,Promise.reject(c))}}});var _j={};Wy(_j,{getGenerateMetadata:()=>bj});module.exports=Jy(_j);var Uy=Yy(Gh());var Zh="Schema",Kh="Body",Wh="Param",Yh="Response",Jh="ErrorResponse",Yc="z.void()";var Xh={output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,useRelativeImports:!1,configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"}},schemaSuffix:Zh,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var Ke=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),eo=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),Jc=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),Me=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),Qh=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),ey=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),ty=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var ry=s(e=>`use${Ke(Me(e.operationName))}`,"getQueryName");function to({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${eo(t)}/`:""}${eo(t)}.${i}`:i}s(to,"getTagFileName");var Xt=s(({type:e,tag:t,options:r})=>`${Ke(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Xc=s(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var it=Symbol.for("@ts-pattern/matcher"),GE=Symbol.for("@ts-pattern/isVariadic"),no="@ts-pattern/anonymous-select-key",Qc=s(e=>!!(e&&typeof e=="object"),"r"),ro=s(e=>e&&!!e[it],"i"),Je=s((e,t,r)=>{if(ro(e)){let n=e[it](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(Qc(e)){if(!Qc(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],o=[];for(let a of e.keys()){let c=e[a];ro(c)&&c[GE]?o.push(c):o.length?i.push(c):n.push(c)}if(o.length){if(o.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<n.length+i.length)return!1;let a=t.slice(0,n.length),c=i.length===0?[]:t.slice(-i.length),u=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((f,l)=>Je(f,a[l],r))&&i.every((f,l)=>Je(f,c[l],r))&&(o.length===0||Je(o[0],u,r))}return e.length===t.length&&e.every((a,c)=>Je(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||ro(o=i)&&o[it]().matcherType==="optional")&&Je(i,t[n],r);var o})}return Object.is(t,e)},"s"),wt=s(e=>{var t,r,n;return Qc(e)?ro(e)?(t=(r=(n=e[it]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?Hn(e,wt):Hn(Object.values(e),wt):[]},"o"),Hn=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function xe(e){return Object.assign(e,{optional:s(()=>ZE(e),"optional"),and:s(t=>V(e,t),"and"),or:s(t=>KE(e,t),"or"),select:s(t=>t===void 0?ny(e):ny(t,e),"select")})}s(xe,"u");function ZE(e){return xe({[it]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return t===void 0?(wt(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Je(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>wt(e),"getSelectionKeys"),matcherType:"optional"})})}s(ZE,"h");function V(...e){return xe({[it]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>Je(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Hn(e,wt),"getSelectionKeys"),matcherType:"and"})})}s(V,"m");function KE(...e){return xe({[it]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return Hn(e,wt).forEach(i=>n(i,void 0)),{matched:e.some(i=>Je(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Hn(e,wt),"getSelectionKeys"),matcherType:"or"})})}s(KE,"d");function N(e){return{[it]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(N,"p");function ny(...e){let t=typeof e[0]=="string"?e[0]:void 0,r=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return xe({[it]:()=>({match:s(n=>{let i={[t??no]:n};return{matched:r===void 0||Je(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??no].concat(r===void 0?[]:wt(r)),"getSelectionKeys")})})}s(ny,"y");function We(e){return typeof e=="number"}s(We,"v");function Pt(e){return typeof e=="string"}s(Pt,"b");function St(e){return typeof e=="bigint"}s(St,"w");var GR=xe(N(function(e){return!0}));var Ot=s(e=>Object.assign(xe(e),{startsWith:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>Ot(V(e,(r=>N(n=>Pt(n)&&n.length>=r))(t))),"minLength"),length:s(t=>Ot(V(e,(r=>N(n=>Pt(n)&&n.length===r))(t))),"length"),maxLength:s(t=>Ot(V(e,(r=>N(n=>Pt(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&!!n.match(r)))));var r},"regex")}),"j"),ZR=Ot(N(Pt)),Ye=s(e=>Object.assign(xe(e),{between:s((t,r)=>Ye(V(e,((n,i)=>N(o=>We(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n<r))(t))),"lt"),gt:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n>r))(t))),"gt"),lte:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n<=r))(t))),"lte"),gte:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n>=r))(t))),"gte"),int:s(()=>Ye(V(e,N(t=>We(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Ye(V(e,N(t=>We(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Ye(V(e,N(t=>We(t)&&t>0))),"positive"),negative:s(()=>Ye(V(e,N(t=>We(t)&&t<0))),"negative")}),"x"),KR=Ye(N(We)),xt=s(e=>Object.assign(xe(e),{between:s((t,r)=>xt(V(e,((n,i)=>N(o=>St(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>xt(V(e,(r=>N(n=>St(n)&&n<r))(t))),"lt"),gt:s(t=>xt(V(e,(r=>N(n=>St(n)&&n>r))(t))),"gt"),lte:s(t=>xt(V(e,(r=>N(n=>St(n)&&n<=r))(t))),"lte"),gte:s(t=>xt(V(e,(r=>N(n=>St(n)&&n>=r))(t))),"gte"),positive:s(()=>xt(V(e,N(t=>St(t)&&t>0))),"positive"),negative:s(()=>xt(V(e,N(t=>St(t)&&t<0))),"negative")}),"A"),WR=xt(N(St)),YR=xe(N(function(e){return typeof e=="boolean"})),JR=xe(N(function(e){return typeof e=="symbol"})),XR=xe(N(function(e){return e==null})),QR=xe(N(function(e){return e!=null}));var nu=class nu extends Error{constructor(t){let r;try{r=JSON.stringify(t)}catch{r=t}super(`Pattern matching error: no pattern matches value ${r}`),this.input=void 0,this.input=t}};s(nu,"W");var eu=nu,tu={matched:!1,value:void 0};function oe(e){return new ru(e,tu)}s(oe,"z");var Bn=class Bn{constructor(t,r){this.input=void 0,this.state=void 0,this.input=t,this.state=r}with(...t){if(this.state.matched)return this;let r=t[t.length-1],n=[t[0]],i;t.length===3&&typeof t[1]=="function"?i=t[1]:t.length>2&&n.push(...t.slice(1,t.length-1));let o=!1,a={},c=s((f,l)=>{o=!0,a[f]=l},"a"),u=!n.some(f=>Je(f,this.input,c))||i&&!i(this.input)?tu:{matched:!0,value:r(o?no in a?a[no]:a:this.input,this.input)};return new Bn(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new Bn(this.input,n?{matched:!0,value:r(this.input,this.input)}:tu)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new eu(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(Bn,"I");var ru=Bn;var iy=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with"];var iu=2,oy=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],sy=["query","header","path"],Qt=["get","put","post","delete","options","head","patch","trace"],ay=["string","number","integer","boolean"],er=["allOf","anyOf","oneOf"];function tr(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(tr,"pick");var uy=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Gn=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),au=s(e=>Gn(e).split("/").at(-1),"getSchemaNameByRef");function z(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s(z,"isReferenceObject");function fy(e){let t=WE(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/--+/g,"-").replace(/-+/g,"_").replace(/[^\w-]+/g,"_");return Me(t)}s(fy,"normalizeString");function ly(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(ly,"wrapWithQuotesIfNeeded");function py(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(py,"unwrapQuotesIfNeeded");function WE(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(WE,"prefixStringStartingWithNumberIfNeeded");function cu(e){let t=e.replaceAll("_","#");return Me(t.replaceAll("-","_")).replaceAll("#","_")}s(cu,"pathParamToVariableName");var Et=s(e=>ay.includes(e),"isPrimitiveType");function dy(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g,(t,r)=>{let n=r.codePointAt(),i=n.toString(16);return n<=255?`\\x${`00${i}`.slice(-2)}`:`\\u${`0000${i}`.slice(-4)}`}).replace(/\//g,"\\/")}s(dy,"escapeControlCharacters");function jt(e){return e.includes("application/")&&e.includes("json")||oy.includes(e)||e.includes("text/")}s(jt,"isParamMediaTypeAllowed");function uu(e){return e>=200&&e<300}s(uu,"isMainResponseStatus");function fu(e){return!(e>=200&&e<300)}s(fu,"isErrorStatus");function Hr(e){return e==="application/json"}s(Hr,"isMediaTypeAllowed");function ou({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let o=`${t}${XE(e)}`,a=r.operationId??o;if(n.removeOperationPrefixEndingWith&&i)return a.split(n.removeOperationPrefixEndingWith).map((u,f)=>f===0?u:Ke(u)).join("");if(n.removeOperationPrefixEndingWith&&!i){let c=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);a=a.replace(c,"")}return iy.includes(a)?o:a}s(ou,"getOperationName");function lu({path:e,method:t,operation:r,openApiDoc:n,options:i}){let o=YE(n,i),a=i.splitByTags?Gr(r,i):i.defaultTag,c=ou({path:e,method:t,operation:r,options:i});return o[a].filter(f=>ou({path:e,method:t,operation:f,options:i})===c).length===1?c:ou({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}s(lu,"getUniqueOperationName");function YE(e,t){let r={};for(let n in e.paths){let i=e.paths[n],o=tr(i,Qt);for(let a in o){let c=o[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?Gr(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}s(YE,"getOperationsByTag");function my(e,t,r){let n=[];for(let i in t.paths){let o=t.paths[i],a=tr(o,Qt);for(let c in a){let u=a[c];if(!u||u.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let f=lu({path:i,method:c,operation:u,openApiDoc:t,options:r});n.push(f)}}return n.filter(i=>i===e).length<=1}s(my,"isUniqueOperationNameWithoutSplitByTags");function ot(e){return Qh(e)}s(ot,"formatTag");function Gr(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return ot(r??t.defaultTag)}s(Gr,"getOperationTag");var cy=/({\w+})/g,JE=/[^\w\-]+/g;function XE(e){e=Ke(Jc(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(cy)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(cy,"")}By${Ke(r.slice(1,-1))}`}return e.replace(JE,"_")}s(XE,"pathToVariableName");var su=/{(\b\w+(?:-\w+)*\b)}/g;function hy(e){let t=e.match(su);return t===null?e.replaceAll(su,":$1"):(t.forEach(r=>{let n=cu(r.replaceAll(su,":$1"));e=e.replaceAll(r,n)}),e)}s(hy,"replaceHyphenatedPath");var yy=s(e=>e.method==="get","isQuery"),gy=s(e=>e.method!=="get","isMutation");var At=s((e,t)=>ey(Ke(fy(e)),t),"getZodSchemaName"),rr=s(e=>!e.startsWith("z."),"isNamedZodSchema"),Zr=s((e,t,r)=>t?e:`${r}_${e}`,"getZodSchemaOperationName"),$y=s(e=>Me(`${e}_${Kh}`),"getBodyZodSchemaName"),vy=s((e,t)=>Me(`${e}_${t}${Wh}`),"getParamZodSchemaName"),by=s(e=>Me(`${e}${Yh}`),"getMainResponseZodSchemaName"),_y=s((e,t)=>Me(`${e}_${t}_${Jh}`),"getErrorResponseZodSchemaName");var QE=s((e,t)=>ty(e,t.schemaSuffix),"getZodSchemaInferedTypeName");var pu=s(({resolver:e,zodSchemaName:t,options:r})=>rr(t)?`${r.includeNamespaces?`${Xt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${QE(t,r)}`:t,"getImportedZodSchemaInferedTypeName");function du(e){return oe(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(du,"primitiveTypeToTsType");function Kr({zodSchemaName:e,schema:t,resolver:r,options:n}){let i="void",o;e&&rr(e)?(i=pu({resolver:r,zodSchemaName:e,options:n}),o=r.getTagByZodSchemaName(e)):t!=null&&t.type&&Et(t==null?void 0:t.type)&&(i=du(t==null?void 0:t.type));let a=i.split(".");return{type:a[a.length-1],...a.length>1?{namespace:a[0]}:{},...o?{filePath:to({type:"models",tag:o,includeTagDir:!0,options:n})}:{}}}s(Kr,"getTsTypeBase");function nr({schema:e,isCircular:t,parentTypes:r,resolver:n,options:i}){if(!e)return{metaType:"primitive"};for(let o of er){let a=e[o];if(a)if(a.length>1){let c=a.map(u=>{let f=n.resolveObject(u);return nr({schema:f,parentTypes:r,resolver:n,options:i})});return c.every(({metaType:u})=>u==="object")?{metaType:"object",objectProperties:c.reduce((u,{objectProperties:f})=>{let l=f.map(({name:p})=>p);return[...u.filter(({name:p})=>!l.includes(p)),...f]},[])}:{metaType:"composite",[o]:c}}else e=n.resolveObject(a[0])}return e.type==="array"?{metaType:"array",arrayType:Py({arraySchema:e,resolver:n,options:i,parentTypes:r})}:(e.type==="object"||e.properties)&&t?{metaType:"object",objectProperties:[],isCircular:!0}:e.type==="object"||e.properties?{metaType:"object",objectProperties:ej({schema:e,parentTypes:r,resolver:n,options:i})}:{metaType:"primitive"}}s(nr,"getSchemaTsMetaType");function Py({arraySchema:e,parentTypes:t,resolver:r,options:n}){let i,o;if(z(e.items)){let f=e.items.$ref;i=r.getZodSchemaNameByRef(f),o=r.getSchemaByRef(f)}else o=e.items;let a=Kr({zodSchemaName:i,schema:o,resolver:r,options:n}),c=Sy(a,t),u=nr({schema:o,isCircular:c,parentTypes:[...t,a],resolver:r,options:n});return{...a,...u}}s(Py,"getArraySchemaTsType");function ej({schema:e,parentTypes:t,resolver:r,options:n}){return Object.entries((e==null?void 0:e.properties)??{}).map(([i,o])=>{var c;let a=((c=e==null?void 0:e.required)==null?void 0:c.includes(i))??!1;if(z(o)){let u=r.getZodSchemaNameByRef(o.$ref),f=r.getSchemaByRef(o.$ref),l=Kr({zodSchemaName:u,schema:f,resolver:r,options:n}),p=Sy(l,t),d=nr({schema:f,isCircular:p,parentTypes:[...t,l],resolver:r,options:n});return{name:i,isRequired:a,...l,...d}}else if(o.type==="array"){let u=Py({arraySchema:o,parentTypes:t,resolver:r,options:n});return{name:i,isRequired:a,type:"array",metaType:"array",arrayType:u}}else if(Et(o.type))return{name:i,isRequired:a,type:du(o.type),metaType:"primitive"};return{name:i,isRequired:a,type:"void",metaType:"primitive"}})}s(ej,"getSchemaTsProperties");function Sy(e,t){return t.findIndex(({type:r,namespace:n})=>r===e.type&&n===e.namespace)>-1}s(Sy,"getIsCircular");var Oy="data";function qt(e){return!z(e)}s(qt,"isSchemaObject");function xy(e){return e.type==="array"}s(xy,"isArraySchemaObject");function wy(e){if(!e.allOf)throw new Error("function inferRequiredSchema is specialized to handle item with required only in an allOf array.");let[t,r]=e.allOf.reduce((i,o)=>{if(tj(o)){let a=o.required;i[0].push(...a??[])}else i[1].push(o);return i},[[],[]]),n={properties:t.reduce((i,o)=>(i[o]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:s((i,o)=>{if(z(i)){let a=o(i.$ref);a&&n.required.forEach(c=>{var u;n.properties[c]=((u=a==null?void 0:a.properties)==null?void 0:u[c])??{}})}else{let a=i.properties??{};n.required.forEach(c=>{a[c]&&(n.properties[c]=a[c]??{})})}},"patchRequiredSchemaInLoop")}}s(wy,"inferRequiredSchema");var tj=s(e=>!z(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function Ey(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return ot(r??t.defaultTag)}s(Ey,"getEndpointTag");function Xe({schema:e,meta:t,options:r}){let n=[];oe(e.type).with("string",()=>n.push(ij(e))).with("number","integer",()=>n.push(sj(e))).with("array",()=>n.push(aj(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
50
|
+
Parsed value is empty`)):n(l)}s(u,"onParsed");function f(l){!l&&t.continueOnError?i(new dE(e.url)):!l||!("error"in l)?i(Lc.syntax(`Unable to parse ${e.url}`)):l.error instanceof xh?i(l.error):i(new xh(l.error.message,e.url))}s(f,"onError")})}s($E,"parseFile");function vE(e){return e===void 0||typeof e=="object"&&Object.keys(e).length===0||typeof e=="string"&&e.trim().length===0||Buffer.isBuffer(e)&&e.length===0}s(vE,"isEmpty")});var qh=h((_R,Ah)=>{"use strict";var Eh=Ur(),bE=Fn(),_E=zc(),Ln=ge(),{isHandledError:PE}=Re();Ah.exports=SE;function SE(e,t){if(!t.resolve.external)return Promise.resolve();try{let r=Uc(e.schema,e.$refs._root$Ref.path+"#",e.$refs,t);return Promise.all(r)}catch(r){return Promise.reject(r)}}s(SE,"resolveExternal");function Uc(e,t,r,n){let i=[];if(e&&typeof e=="object"&&!ArrayBuffer.isView(e))if(Eh.isExternal$Ref(e))i.push(jh(e,t,r,n));else for(let o of Object.keys(e)){let a=bE.join(t,o),c=e[o];Eh.isExternal$Ref(c)?i.push(jh(c,a,r,n)):i=i.concat(Uc(c,a,r,n))}return i}s(Uc,"crawl");async function jh(e,t,r,n){let i=Ln.resolve(t,e.$ref),o=Ln.stripHash(i);if(e=r._$refs[o],e)return Promise.resolve(e.value);try{let a=await _E(i,r,n),c=Uc(a,o+"#",r,n);return Promise.all(c)}catch(a){if(!n.continueOnError||!PE(a))throw a;return r._$refs[o]&&(a.source=Ln.stripHash(t),a.path=Ln.safePointerToPath(Ln.getHash(t))),[]}}s(jh,"resolve$Ref")});var Rh=h((SR,Th)=>{"use strict";var Ji=Ur(),zn=Fn(),Bc=ge();Th.exports=OE;function OE(e,t){let r=[];Hc(e,"schema",e.$refs._root$Ref.path+"#","#",0,r,e.$refs,t),xE(r)}s(OE,"bundle");function Hc(e,t,r,n,i,o,a,c){let u=t===null?e:e[t];if(u&&typeof u=="object"&&!ArrayBuffer.isView(u))if(Ji.isAllowed$Ref(u))Ih(e,t,r,n,i,o,a,c);else{let f=Object.keys(u).sort((l,p)=>l==="definitions"?-1:p==="definitions"?1:l.length-p.length);for(let l of f){let p=zn.join(r,l),d=zn.join(n,l),m=u[l];Ji.isAllowed$Ref(m)?Ih(u,l,r,d,i,o,a,c):Hc(u,l,p,d,i,o,a,c)}}}s(Hc,"crawl");function Ih(e,t,r,n,i,o,a,c){let u=t===null?e:e[t],f=Bc.resolve(r,u.$ref),l=a._resolve(f,n,c);if(l===null)return;let p=zn.parse(n).length,d=Bc.stripHash(l.path),m=Bc.getHash(l.path),y=d!==a._root$Ref.path,$=Ji.isExtended$Ref(u);i+=l.indirections;let g=wE(o,e,t);if(g)if(p<g.depth||i<g.indirections)EE(o,g);else return;o.push({$ref:u,parent:e,key:t,pathFromRoot:n,depth:p,file:d,hash:m,value:l.value,circular:l.circular,extended:$,external:y,indirections:i}),g||Hc(l.value,null,l.path,n,i+1,o,a,c)}s(Ih,"inventory$Ref");function xE(e){e.sort((i,o)=>{if(i.file!==o.file)return i.file<o.file?-1:1;if(i.hash!==o.hash)return i.hash<o.hash?-1:1;if(i.circular!==o.circular)return i.circular?-1:1;if(i.extended!==o.extended)return i.extended?1:-1;if(i.indirections!==o.indirections)return i.indirections-o.indirections;if(i.depth!==o.depth)return i.depth-o.depth;{let a=i.pathFromRoot.lastIndexOf("/definitions"),c=o.pathFromRoot.lastIndexOf("/definitions");return a!==c?c-a:i.pathFromRoot.length-o.pathFromRoot.length}});let t,r,n;for(let i of e)i.external?i.file===t&&i.hash===r?i.$ref.$ref=n:i.file===t&&i.hash.indexOf(r+"/")===0?i.$ref.$ref=zn.join(n,zn.parse(i.hash.replace(r,"#"))):(t=i.file,r=i.hash,n=i.pathFromRoot,i.$ref=i.parent[i.key]=Ji.dereference(i.$ref,i.value),i.circular&&(i.$ref.$ref=i.pathFromRoot)):i.$ref.$ref=i.hash}s(xE,"remap");function wE(e,t,r){for(let n=0;n<e.length;n++){let i=e[n];if(i.parent===t&&i.key===r)return i}}s(wE,"findInInventory");function EE(e,t){let r=e.indexOf(t);e.splice(r,1)}s(EE,"removeFromInventory")});var Kc=h((xR,Mh)=>{"use strict";var Gc=Ur(),Nh=Fn(),{ono:jE}=Ee(),AE=ge();Mh.exports=qE;function qE(e,t){let r=Zc(e.schema,e.$refs._root$Ref.path,"#",[],e.$refs,t);e.$refs.circular=r.circular,e.schema=r.value}s(qE,"dereference");function Zc(e,t,r,n,i,o){let a,c={value:e,circular:!1};if(e&&typeof e=="object"&&!ArrayBuffer.isView(e)){if(n.push(e),Gc.isAllowed$Ref(e,o))a=kh(e,t,r,n,i,o),c.circular=a.circular,c.value=a.value;else for(let u of Object.keys(e)){let f=Nh.join(t,u),l=Nh.join(r,u),p=e[u],d=!1;Gc.isAllowed$Ref(p,o)?(a=kh(p,f,l,n,i,o),d=a.circular,e[u]!==a.value&&(e[u]=a.value)):n.indexOf(p)===-1?(a=Zc(p,f,l,n,i,o),d=a.circular,e[u]!==a.value&&(e[u]=a.value)):d=Ch(f,i,o),c.circular=c.circular||d}n.pop()}return c}s(Zc,"crawl");function kh(e,t,r,n,i,o){let a=AE.resolve(t,e.$ref),c=i._resolve(a,t,o);if(c===null)return{circular:!1,value:null};let u=c.circular,f=u||n.indexOf(c.value)!==-1;f&&Ch(t,i,o);let l=Gc.dereference(e,c.value);if(!f){let p=Zc(l,c.path,r,n,i,o);f=p.circular,l=p.value}return f&&!u&&o.dereference.circular==="ignore"&&(l=e),u&&(l.$ref=r),{circular:f,value:l}}s(kh,"dereference$Ref");function Ch(e,t,r){if(t.circular=!0,!r.dereference.circular)throw jE.reference(`Circular $ref pointer found at ${e}`);return!0}s(Ch,"foundCircularReference")});var Lh=h((ER,Ge)=>{"use strict";var Vh=bh(),IE=zc(),Xi=Cc(),TE=qh(),RE=Rh(),NE=Kc(),Br=ge(),{JSONParserError:kE,InvalidPointerError:CE,MissingPointerError:ME,ResolverError:DE,ParserError:FE,UnmatchedParserError:VE,UnmatchedResolverError:LE,isHandledError:zE,JSONParserErrorGroup:Dh}=Re(),ke=Dc(),{ono:Fh}=Ee();Ge.exports=He;Ge.exports.default=He;Ge.exports.JSONParserError=kE;Ge.exports.InvalidPointerError=CE;Ge.exports.MissingPointerError=ME;Ge.exports.ResolverError=DE;Ge.exports.ParserError=FE;Ge.exports.UnmatchedParserError=VE;Ge.exports.UnmatchedResolverError=LE;function He(){this.schema=null,this.$refs=new Vh}s(He,"$RefParser");He.parse=s(function(t,r,n,i){let o=this,a=new o;return a.parse.apply(a,arguments)},"parse");He.prototype.parse=s(async function(t,r,n,i){let o=Xi(arguments),a;if(!o.path&&!o.schema){let f=Fh(`Expected a file path, URL, or object. Got ${o.path||o.schema}`);return ke(o.callback,Promise.reject(f))}this.schema=null,this.$refs=new Vh;let c="http";if(Br.isFileSystemPath(o.path)&&(o.path=Br.fromFileSystemPath(o.path),c="file"),o.path=Br.resolve(Br.cwd(),o.path),o.schema&&typeof o.schema=="object"){let f=this.$refs._add(o.path);f.value=o.schema,f.pathType=c,a=Promise.resolve(o.schema)}else a=IE(o.path,this.$refs,o.options);let u=this;try{let f=await a;if(f!==null&&typeof f=="object"&&!Buffer.isBuffer(f))return u.schema=f,ke(o.callback,Promise.resolve(u.schema));if(o.options.continueOnError)return u.schema=null,ke(o.callback,Promise.resolve(u.schema));throw Fh.syntax(`"${u.$refs._root$Ref.path||f}" is not a valid JSON Schema`)}catch(f){return!o.options.continueOnError||!zE(f)?ke(o.callback,Promise.reject(f)):(this.$refs._$refs[Br.stripHash(o.path)]&&this.$refs._$refs[Br.stripHash(o.path)].addError(f),ke(o.callback,Promise.resolve(null)))}},"parse");He.resolve=s(function(t,r,n,i){let o=this,a=new o;return a.resolve.apply(a,arguments)},"resolve");He.prototype.resolve=s(async function(t,r,n,i){let o=this,a=Xi(arguments);try{return await this.parse(a.path,a.schema,a.options),await TE(o,a.options),Wc(o),ke(a.callback,Promise.resolve(o.$refs))}catch(c){return ke(a.callback,Promise.reject(c))}},"resolve");He.bundle=s(function(t,r,n,i){let o=this,a=new o;return a.bundle.apply(a,arguments)},"bundle");He.prototype.bundle=s(async function(t,r,n,i){let o=this,a=Xi(arguments);try{return await this.resolve(a.path,a.schema,a.options),RE(o,a.options),Wc(o),ke(a.callback,Promise.resolve(o.schema))}catch(c){return ke(a.callback,Promise.reject(c))}},"bundle");He.dereference=s(function(t,r,n,i){let o=this,a=new o;return a.dereference.apply(a,arguments)},"dereference");He.prototype.dereference=s(async function(t,r,n,i){let o=this,a=Xi(arguments);try{return await this.resolve(a.path,a.schema,a.options),NE(o,a.options),Wc(o),ke(a.callback,Promise.resolve(o.schema))}catch(c){return ke(a.callback,Promise.reject(c))}},"dereference");function Wc(e){if(Dh.getParserErrors(e).length>0)throw new Dh(e)}s(Wc,"finalize")});var Gh=h((AR,Hh)=>{"use strict";var UE=hc(),BE=$c(),zh=Cc(),Uh=Yn(),Bh=sh(),Qi=Dc(),{ono:Ce}=Ee(),Jt=Lh(),HE=Kc();Hh.exports=Ze;function Ze(){Jt.apply(this,arguments)}s(Ze,"SwaggerParser");Uh.inherits(Ze,Jt);Ze.parse=Jt.parse;Ze.resolve=Jt.resolve;Ze.bundle=Jt.bundle;Ze.dereference=Jt.dereference;Object.defineProperty(Ze.prototype,"api",{configurable:!0,enumerable:!0,get(){return this.schema}});Ze.prototype.parse=async function(e,t,r,n){let i=zh(arguments);i.options=new Bh(i.options);try{let o=await Jt.prototype.parse.call(this,i.path,i.schema,i.options);if(o.swagger){if(o.swagger===void 0||o.info===void 0||o.paths===void 0)throw Ce.syntax(`${i.path||i.schema} is not a valid Swagger API definition`);if(typeof o.swagger=="number")throw Ce.syntax('Swagger version number must be a string (e.g. "2.0") not a number.');if(typeof o.info.version=="number")throw Ce.syntax('API version number must be a string (e.g. "1.0.0") not a number.');if(o.swagger!=="2.0")throw Ce.syntax(`Unrecognized Swagger version: ${o.swagger}. Expected 2.0`)}else{let a=["3.0.0","3.0.1","3.0.2","3.0.3","3.1.0"];if(o.openapi===void 0||o.info===void 0)throw Ce.syntax(`${i.path||i.schema} is not a valid Openapi API definition`);if(o.paths===void 0)if(o.openapi==="3.1.0"){if(o.webhooks===void 0)throw Ce.syntax(`${i.path||i.schema} is not a valid Openapi API definition`)}else throw Ce.syntax(`${i.path||i.schema} is not a valid Openapi API definition`);else{if(typeof o.openapi=="number")throw Ce.syntax('Openapi version number must be a string (e.g. "3.0.0") not a number.');if(typeof o.info.version=="number")throw Ce.syntax('API version number must be a string (e.g. "1.0.0") not a number.');if(a.indexOf(o.openapi)===-1)throw Ce.syntax(`Unsupported OpenAPI version: ${o.openapi}. Swagger Parser only supports versions ${a.join(", ")}`)}Uh.fixOasRelativeServers(o,i.path)}return Qi(i.callback,Promise.resolve(o))}catch(o){return Qi(i.callback,Promise.reject(o))}};Ze.validate=function(e,t,r,n){let i=this,o=new i;return o.validate.apply(o,arguments)};Ze.prototype.validate=async function(e,t,r,n){let i=this,o=zh(arguments);o.options=new Bh(o.options);let a=o.options.dereference.circular;o.options.validate.schema&&(o.options.dereference.circular="ignore");try{if(await this.dereference(o.path,o.schema,o.options),o.options.dereference.circular=a,o.options.validate.schema&&(UE(i.api),i.$refs.circular)){if(a===!0)HE(i,o.options);else if(a===!1)throw Ce.reference("The API contains circular references")}return o.options.validate.spec&&BE(i.api),Qi(o.callback,Promise.resolve(i.schema))}catch(c){return Qi(o.callback,Promise.reject(c))}}});var _j={};Wy(_j,{getGenerateMetadata:()=>bj});module.exports=Jy(_j);var Uy=Yy(Gh());var Zh="Schema",Kh="Body",Wh="Param",Yh="Response",Jh="ErrorResponse",Yc="z.void()";var Xh={output:"output",splitByTags:!0,defaultTag:"Common",excludeTags:[],includeNamespaces:!0,importPath:"ts",configs:{models:{outputFileNameSuffix:"models",namespaceSuffix:"Models"},endpoints:{outputFileNameSuffix:"api",namespaceSuffix:"Api"},queries:{outputFileNameSuffix:"queries",namespaceSuffix:"Queries"}},schemaSuffix:Zh,additionalPropertiesDefaultValue:!1,removeOperationPrefixEndingWith:"Controller_"};var Ke=s(e=>e.charAt(0).toUpperCase()+e.slice(1),"capitalize"),eo=s(e=>e.charAt(0).toLowerCase()+e.slice(1),"decapitalize"),Jc=s(e=>e.replace(/(-\w)/g,t=>t[1].toUpperCase()),"kebabToCamel"),Me=s(e=>e.replace(/(_\w)/g,t=>t[1].toUpperCase()),"snakeToCamel"),Qh=s(e=>e.replace(/[\W_]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"nonWordCharactersToCamel"),ey=s((e,t="")=>e.endsWith(t)?e:`${e}${t}`,"suffixIfNeeded"),ty=s((e,t)=>e.replace(new RegExp(`${t}$`),""),"removeSuffix");var ry=s(e=>`use${Ke(Me(e.operationName))}`,"getQueryName");function to({type:e,tag:t,options:r,includeTagDir:n=!0}){let i=r.configs[e].outputFileNameSuffix;return t?`${n?`${eo(t)}/`:""}${eo(t)}.${i}`:i}s(to,"getTagFileName");var Xt=s(({type:e,tag:t,options:r})=>`${Ke(t)}${r.configs[e].namespaceSuffix}`,"getNamespaceName");var Xc=s(e=>e.replace(/^[^a-zA-Z_$]*/g,"").replace(/[^a-zA-Z0-9_$]+(\w)?/g,(t,r)=>(r==null?void 0:r.toUpperCase())??""),"invalidVariableNameCharactersToCamel");var it=Symbol.for("@ts-pattern/matcher"),GE=Symbol.for("@ts-pattern/isVariadic"),no="@ts-pattern/anonymous-select-key",Qc=s(e=>!!(e&&typeof e=="object"),"r"),ro=s(e=>e&&!!e[it],"i"),Je=s((e,t,r)=>{if(ro(e)){let n=e[it](),{matched:i,selections:o}=n.match(t);return i&&o&&Object.keys(o).forEach(a=>r(a,o[a])),i}if(Qc(e)){if(!Qc(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let n=[],i=[],o=[];for(let a of e.keys()){let c=e[a];ro(c)&&c[GE]?o.push(c):o.length?i.push(c):n.push(c)}if(o.length){if(o.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(t.length<n.length+i.length)return!1;let a=t.slice(0,n.length),c=i.length===0?[]:t.slice(-i.length),u=t.slice(n.length,i.length===0?1/0:-i.length);return n.every((f,l)=>Je(f,a[l],r))&&i.every((f,l)=>Je(f,c[l],r))&&(o.length===0||Je(o[0],u,r))}return e.length===t.length&&e.every((a,c)=>Je(a,t[c],r))}return Reflect.ownKeys(e).every(n=>{let i=e[n];return(n in t||ro(o=i)&&o[it]().matcherType==="optional")&&Je(i,t[n],r);var o})}return Object.is(t,e)},"s"),wt=s(e=>{var t,r,n;return Qc(e)?ro(e)?(t=(r=(n=e[it]()).getSelectionKeys)==null?void 0:r.call(n))!=null?t:[]:Array.isArray(e)?Hn(e,wt):Hn(Object.values(e),wt):[]},"o"),Hn=s((e,t)=>e.reduce((r,n)=>r.concat(t(n)),[]),"c");function xe(e){return Object.assign(e,{optional:s(()=>ZE(e),"optional"),and:s(t=>V(e,t),"and"),or:s(t=>KE(e,t),"or"),select:s(t=>t===void 0?ny(e):ny(t,e),"select")})}s(xe,"u");function ZE(e){return xe({[it]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return t===void 0?(wt(e).forEach(i=>n(i,void 0)),{matched:!0,selections:r}):{matched:Je(e,t,n),selections:r}},"match"),getSelectionKeys:s(()=>wt(e),"getSelectionKeys"),matcherType:"optional"})})}s(ZE,"h");function V(...e){return xe({[it]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return{matched:e.every(i=>Je(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Hn(e,wt),"getSelectionKeys"),matcherType:"and"})})}s(V,"m");function KE(...e){return xe({[it]:()=>({match:s(t=>{let r={},n=s((i,o)=>{r[i]=o},"r");return Hn(e,wt).forEach(i=>n(i,void 0)),{matched:e.some(i=>Je(i,t,n)),selections:r}},"match"),getSelectionKeys:s(()=>Hn(e,wt),"getSelectionKeys"),matcherType:"or"})})}s(KE,"d");function N(e){return{[it]:()=>({match:s(t=>({matched:!!e(t)}),"match")})}}s(N,"p");function ny(...e){let t=typeof e[0]=="string"?e[0]:void 0,r=e.length===2?e[1]:typeof e[0]=="string"?void 0:e[0];return xe({[it]:()=>({match:s(n=>{let i={[t??no]:n};return{matched:r===void 0||Je(r,n,(o,a)=>{i[o]=a}),selections:i}},"match"),getSelectionKeys:s(()=>[t??no].concat(r===void 0?[]:wt(r)),"getSelectionKeys")})})}s(ny,"y");function We(e){return typeof e=="number"}s(We,"v");function Pt(e){return typeof e=="string"}s(Pt,"b");function St(e){return typeof e=="bigint"}s(St,"w");var GR=xe(N(function(e){return!0}));var Ot=s(e=>Object.assign(xe(e),{startsWith:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&n.startsWith(r)))));var r},"startsWith"),endsWith:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&n.endsWith(r)))));var r},"endsWith"),minLength:s(t=>Ot(V(e,(r=>N(n=>Pt(n)&&n.length>=r))(t))),"minLength"),length:s(t=>Ot(V(e,(r=>N(n=>Pt(n)&&n.length===r))(t))),"length"),maxLength:s(t=>Ot(V(e,(r=>N(n=>Pt(n)&&n.length<=r))(t))),"maxLength"),includes:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&n.includes(r)))));var r},"includes"),regex:s(t=>{return Ot(V(e,(r=t,N(n=>Pt(n)&&!!n.match(r)))));var r},"regex")}),"j"),ZR=Ot(N(Pt)),Ye=s(e=>Object.assign(xe(e),{between:s((t,r)=>Ye(V(e,((n,i)=>N(o=>We(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n<r))(t))),"lt"),gt:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n>r))(t))),"gt"),lte:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n<=r))(t))),"lte"),gte:s(t=>Ye(V(e,(r=>N(n=>We(n)&&n>=r))(t))),"gte"),int:s(()=>Ye(V(e,N(t=>We(t)&&Number.isInteger(t)))),"int"),finite:s(()=>Ye(V(e,N(t=>We(t)&&Number.isFinite(t)))),"finite"),positive:s(()=>Ye(V(e,N(t=>We(t)&&t>0))),"positive"),negative:s(()=>Ye(V(e,N(t=>We(t)&&t<0))),"negative")}),"x"),KR=Ye(N(We)),xt=s(e=>Object.assign(xe(e),{between:s((t,r)=>xt(V(e,((n,i)=>N(o=>St(o)&&n<=o&&i>=o))(t,r))),"between"),lt:s(t=>xt(V(e,(r=>N(n=>St(n)&&n<r))(t))),"lt"),gt:s(t=>xt(V(e,(r=>N(n=>St(n)&&n>r))(t))),"gt"),lte:s(t=>xt(V(e,(r=>N(n=>St(n)&&n<=r))(t))),"lte"),gte:s(t=>xt(V(e,(r=>N(n=>St(n)&&n>=r))(t))),"gte"),positive:s(()=>xt(V(e,N(t=>St(t)&&t>0))),"positive"),negative:s(()=>xt(V(e,N(t=>St(t)&&t<0))),"negative")}),"A"),WR=xt(N(St)),YR=xe(N(function(e){return typeof e=="boolean"})),JR=xe(N(function(e){return typeof e=="symbol"})),XR=xe(N(function(e){return e==null})),QR=xe(N(function(e){return e!=null}));var nu=class nu extends Error{constructor(t){let r;try{r=JSON.stringify(t)}catch{r=t}super(`Pattern matching error: no pattern matches value ${r}`),this.input=void 0,this.input=t}};s(nu,"W");var eu=nu,tu={matched:!1,value:void 0};function oe(e){return new ru(e,tu)}s(oe,"z");var Bn=class Bn{constructor(t,r){this.input=void 0,this.state=void 0,this.input=t,this.state=r}with(...t){if(this.state.matched)return this;let r=t[t.length-1],n=[t[0]],i;t.length===3&&typeof t[1]=="function"?i=t[1]:t.length>2&&n.push(...t.slice(1,t.length-1));let o=!1,a={},c=s((f,l)=>{o=!0,a[f]=l},"a"),u=!n.some(f=>Je(f,this.input,c))||i&&!i(this.input)?tu:{matched:!0,value:r(o?no in a?a[no]:a:this.input,this.input)};return new Bn(this.input,u)}when(t,r){if(this.state.matched)return this;let n=!!t(this.input);return new Bn(this.input,n?{matched:!0,value:r(this.input,this.input)}:tu)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){if(this.state.matched)return this.state.value;throw new eu(this.input)}run(){return this.exhaustive()}returnType(){return this}};s(Bn,"I");var ru=Bn;var iy=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with"];var iu=2,oy=["application/octet-stream","multipart/form-data","application/x-www-form-urlencoded","*/*"],sy=["query","header","path"],Qt=["get","put","post","delete","options","head","patch","trace"],ay=["string","number","integer","boolean"],er=["allOf","anyOf","oneOf"];function tr(e,t){let r={};return Object.keys(e).forEach(n=>{t.includes(n)&&(r[n]=e[n])}),r}s(tr,"pick");var uy=s(e=>`#/components/schemas/${e}`,"getSchemaRef"),Gn=s(e=>e[1]==="/"?e:"#/"+e.slice(1),"autocorrectRef"),au=s(e=>Gn(e).split("/").at(-1),"getSchemaNameByRef");function z(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,"$ref")}s(z,"isReferenceObject");function fy(e){let t=WE(e).normalize("NFKD").trim().replace(/\s+/g,"_").replace(/--+/g,"-").replace(/-+/g,"_").replace(/[^\w-]+/g,"_");return Me(t)}s(fy,"normalizeString");function ly(e){return/^[a-zA-Z]\w*$/.test(e)?e:`"${e}"`}s(ly,"wrapWithQuotesIfNeeded");function py(e){return typeof e=="string"&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}s(py,"unwrapQuotesIfNeeded");function WE(e){let t=Number(e[0]);return typeof t=="number"&&!Number.isNaN(t)?"_"+e:e}s(WE,"prefixStringStartingWithNumberIfNeeded");function cu(e){let t=e.replaceAll("_","#");return Me(t.replaceAll("-","_")).replaceAll("#","_")}s(cu,"pathParamToVariableName");var Et=s(e=>ay.includes(e),"isPrimitiveType");function dy(e){return e.replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/([\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\uFFFE\uFFFF])/g,(t,r)=>{let n=r.codePointAt(),i=n.toString(16);return n<=255?`\\x${`00${i}`.slice(-2)}`:`\\u${`0000${i}`.slice(-4)}`}).replace(/\//g,"\\/")}s(dy,"escapeControlCharacters");function jt(e){return e.includes("application/")&&e.includes("json")||oy.includes(e)||e.includes("text/")}s(jt,"isParamMediaTypeAllowed");function uu(e){return e>=200&&e<300}s(uu,"isMainResponseStatus");function fu(e){return!(e>=200&&e<300)}s(fu,"isErrorStatus");function Hr(e){return e==="application/json"}s(Hr,"isMediaTypeAllowed");function ou({path:e,method:t,operation:r,options:n,keepOperationPrefixWithoutEnding:i}){let o=`${t}${XE(e)}`,a=r.operationId??o;if(n.removeOperationPrefixEndingWith&&i)return a.split(n.removeOperationPrefixEndingWith).map((u,f)=>f===0?u:Ke(u)).join("");if(n.removeOperationPrefixEndingWith&&!i){let c=new RegExp(`^.*${n.removeOperationPrefixEndingWith}`);a=a.replace(c,"")}return iy.includes(a)?o:a}s(ou,"getOperationName");function lu({path:e,method:t,operation:r,openApiDoc:n,options:i}){let o=YE(n,i),a=i.splitByTags?Gr(r,i):i.defaultTag,c=ou({path:e,method:t,operation:r,options:i});return o[a].filter(f=>ou({path:e,method:t,operation:f,options:i})===c).length===1?c:ou({path:e,method:t,operation:r,options:i,keepOperationPrefixWithoutEnding:!0})}s(lu,"getUniqueOperationName");function YE(e,t){let r={};for(let n in e.paths){let i=e.paths[n],o=tr(i,Qt);for(let a in o){let c=o[a];if(!c||c.deprecated&&!(t!=null&&t.withDeprecatedEndpoints))continue;let u=t.splitByTags?Gr(c,t):t.defaultTag;r[u]||(r[u]=[]),r[u].push(c)}}return r}s(YE,"getOperationsByTag");function my(e,t,r){let n=[];for(let i in t.paths){let o=t.paths[i],a=tr(o,Qt);for(let c in a){let u=a[c];if(!u||u.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let f=lu({path:i,method:c,operation:u,openApiDoc:t,options:r});n.push(f)}}return n.filter(i=>i===e).length<=1}s(my,"isUniqueOperationNameWithoutSplitByTags");function ot(e){return Qh(e)}s(ot,"formatTag");function Gr(e,t){var n;let r=(n=e.tags)==null?void 0:n[0];return ot(r??t.defaultTag)}s(Gr,"getOperationTag");var cy=/({\w+})/g,JE=/[^\w\-]+/g;function XE(e){e=Ke(Jc(e.replaceAll("/","-")).replaceAll("-",""));let t=[...e.matchAll(cy)];if(t.length>0){let r=t.sort((n,i)=>n.index-i.index)[t.length-1][0];e=`${e.replace(cy,"")}By${Ke(r.slice(1,-1))}`}return e.replace(JE,"_")}s(XE,"pathToVariableName");var su=/{(\b\w+(?:-\w+)*\b)}/g;function hy(e){let t=e.match(su);return t===null?e.replaceAll(su,":$1"):(t.forEach(r=>{let n=cu(r.replaceAll(su,":$1"));e=e.replaceAll(r,n)}),e)}s(hy,"replaceHyphenatedPath");var yy=s(e=>e.method==="get","isQuery"),gy=s(e=>e.method!=="get","isMutation");var At=s((e,t)=>ey(Ke(fy(e)),t),"getZodSchemaName"),rr=s(e=>!e.startsWith("z."),"isNamedZodSchema"),Zr=s((e,t,r)=>t?e:`${r}_${e}`,"getZodSchemaOperationName"),$y=s(e=>Me(`${e}_${Kh}`),"getBodyZodSchemaName"),vy=s((e,t)=>Me(`${e}_${t}${Wh}`),"getParamZodSchemaName"),by=s(e=>Me(`${e}${Yh}`),"getMainResponseZodSchemaName"),_y=s((e,t)=>Me(`${e}_${t}_${Jh}`),"getErrorResponseZodSchemaName");var QE=s((e,t)=>ty(e,t.schemaSuffix),"getZodSchemaInferedTypeName");var pu=s(({resolver:e,zodSchemaName:t,options:r})=>rr(t)?`${r.includeNamespaces?`${Xt({type:"models",tag:e.getTagByZodSchemaName(t),options:r})}.`:""}${QE(t,r)}`:t,"getImportedZodSchemaInferedTypeName");function du(e){return oe(e).with("string",()=>"string").with("number",()=>"number").with("integer",()=>"number").with("boolean",()=>"boolean").exhaustive()}s(du,"primitiveTypeToTsType");function Kr({zodSchemaName:e,schema:t,resolver:r,options:n}){let i="void",o;e&&rr(e)?(i=pu({resolver:r,zodSchemaName:e,options:n}),o=r.getTagByZodSchemaName(e)):t!=null&&t.type&&Et(t==null?void 0:t.type)&&(i=du(t==null?void 0:t.type));let a=i.split(".");return{type:a[a.length-1],...a.length>1?{namespace:a[0]}:{},...o?{filePath:to({type:"models",tag:o,includeTagDir:!0,options:n})}:{}}}s(Kr,"getTsTypeBase");function nr({schema:e,isCircular:t,parentTypes:r,resolver:n,options:i}){if(!e)return{metaType:"primitive"};for(let o of er){let a=e[o];if(a)if(a.length>1){let c=a.map(u=>{let f=n.resolveObject(u);return nr({schema:f,parentTypes:r,resolver:n,options:i})});return c.every(({metaType:u})=>u==="object")?{metaType:"object",objectProperties:c.reduce((u,{objectProperties:f})=>{let l=f.map(({name:p})=>p);return[...u.filter(({name:p})=>!l.includes(p)),...f]},[])}:{metaType:"composite",[o]:c}}else e=n.resolveObject(a[0])}return e.type==="array"?{metaType:"array",arrayType:Py({arraySchema:e,resolver:n,options:i,parentTypes:r})}:(e.type==="object"||e.properties)&&t?{metaType:"object",objectProperties:[],isCircular:!0}:e.type==="object"||e.properties?{metaType:"object",objectProperties:ej({schema:e,parentTypes:r,resolver:n,options:i})}:{metaType:"primitive"}}s(nr,"getSchemaTsMetaType");function Py({arraySchema:e,parentTypes:t,resolver:r,options:n}){let i,o;if(z(e.items)){let f=e.items.$ref;i=r.getZodSchemaNameByRef(f),o=r.getSchemaByRef(f)}else o=e.items;let a=Kr({zodSchemaName:i,schema:o,resolver:r,options:n}),c=Sy(a,t),u=nr({schema:o,isCircular:c,parentTypes:[...t,a],resolver:r,options:n});return{...a,...u}}s(Py,"getArraySchemaTsType");function ej({schema:e,parentTypes:t,resolver:r,options:n}){return Object.entries((e==null?void 0:e.properties)??{}).map(([i,o])=>{var c;let a=((c=e==null?void 0:e.required)==null?void 0:c.includes(i))??!1;if(z(o)){let u=r.getZodSchemaNameByRef(o.$ref),f=r.getSchemaByRef(o.$ref),l=Kr({zodSchemaName:u,schema:f,resolver:r,options:n}),p=Sy(l,t),d=nr({schema:f,isCircular:p,parentTypes:[...t,l],resolver:r,options:n});return{name:i,isRequired:a,...l,...d}}else if(o.type==="array"){let u=Py({arraySchema:o,parentTypes:t,resolver:r,options:n});return{name:i,isRequired:a,type:"array",metaType:"array",arrayType:u}}else if(Et(o.type))return{name:i,isRequired:a,type:du(o.type),metaType:"primitive"};return{name:i,isRequired:a,type:"void",metaType:"primitive"}})}s(ej,"getSchemaTsProperties");function Sy(e,t){return t.findIndex(({type:r,namespace:n})=>r===e.type&&n===e.namespace)>-1}s(Sy,"getIsCircular");var Oy="data";function qt(e){return!z(e)}s(qt,"isSchemaObject");function xy(e){return e.type==="array"}s(xy,"isArraySchemaObject");function wy(e){if(!e.allOf)throw new Error("function inferRequiredSchema is specialized to handle item with required only in an allOf array.");let[t,r]=e.allOf.reduce((i,o)=>{if(tj(o)){let a=o.required;i[0].push(...a??[])}else i[1].push(o);return i},[[],[]]),n={properties:t.reduce((i,o)=>(i[o]={},i),{}),type:"object",required:t};return{noRequiredOnlyAllof:r,composedRequiredSchema:n,patchRequiredSchemaInLoop:s((i,o)=>{if(z(i)){let a=o(i.$ref);a&&n.required.forEach(c=>{var u;n.properties[c]=((u=a==null?void 0:a.properties)==null?void 0:u[c])??{}})}else{let a=i.properties??{};n.required.forEach(c=>{a[c]&&(n.properties[c]=a[c]??{})})}},"patchRequiredSchemaInLoop")}}s(wy,"inferRequiredSchema");var tj=s(e=>!z(e)&&!!e.required&&!e.type&&!e.properties&&!(e!=null&&e.allOf)&&!(e!=null&&e.anyOf)&&!e.oneOf,"isBrokenAllOfItem");function Ey(e,t){var n;let r=t.splitByTags?(n=e.tags)==null?void 0:n[0]:t.defaultTag;return ot(r??t.defaultTag)}s(Ey,"getEndpointTag");function Xe({schema:e,meta:t,options:r}){let n=[];oe(e.type).with("string",()=>n.push(ij(e))).with("number","integer",()=>n.push(sj(e))).with("array",()=>n.push(aj(e))).otherwise(()=>{}),typeof e.description=="string"&&e.description!==""&&(r!=null&&r.withDescription)&&([`
|
|
51
51
|
`,"\r",`\r
|
|
52
52
|
`].some(o=>String.prototype.includes.call(e.description,o))?n.push(`describe(\`${e.description}\`)`):n.push(`describe("${e.description}")`));let i=n.concat(rj(e,t),(r==null?void 0:r.withDefaultValues)!==!1?nj(e):[]).filter(Boolean).join(".");return i?`.${i}`:""}s(Xe,"getZodChain");function rj(e,t){return e.nullable&&!(t!=null&&t.isRequired)?"nullish()":e.nullable?"nullable()":t!=null&&t.isRequired?"":"optional()"}s(rj,"getZodChainablePresence");function nj(e){return e.default!==void 0?`default(${oe(e.type).with("number","integer",()=>py(e.default)).otherwise(()=>JSON.stringify(e.default))})`:""}s(nj,"getZodChainableDefault");function ij(e){let t=[];if(e.enum||(e.minLength!==void 0&&t.push(`min(${e.minLength})`),e.maxLength!==void 0&&t.push(`max(${e.maxLength})`)),e.pattern&&t.push(`regex(${oj(e.pattern)})`),e.format){let r=oe(e.format).with("email",()=>"email()").with("hostname",()=>"url()").with("uri",()=>"url()").with("uuid",()=>"uuid()").with("date-time",()=>"datetime({ offset: true })").otherwise(()=>"");r&&t.push(r)}return t.join(".")}s(ij,"getZodChainableStringValidations");function oj(e){return e.startsWith("/")&&e.endsWith("/")&&(e=e.slice(1,-1)),e=dy(e),`/${e}/`}s(oj,"formatPatternIfNeeded");function sj(e){let t=[];return e.enum?"":(e.type==="integer"&&t.push("int()"),e.minimum!==void 0?e.exclusiveMinimum===!0?t.push(`gt(${e.minimum})`):t.push(`gte(${e.minimum})`):typeof e.exclusiveMinimum=="number"&&t.push(`gt(${e.exclusiveMinimum})`),e.maximum!==void 0?e.exclusiveMaximum===!0?t.push(`lt(${e.maximum})`):t.push(`lte(${e.maximum})`):typeof e.exclusiveMaximum=="number"&&t.push(`lt(${e.exclusiveMaximum})`),e.multipleOf&&t.push(`multipleOf(${e.multipleOf})`),t.join("."))}s(sj,"getZodChainableNumberValidations");function aj(e){let t=[];return e.minItems&&t.push(`min(${e.minItems})`),e.maxItems&&t.push(`max(${e.maxItems})`),t.join(".")}s(aj,"getZodChainableArrayValidations");var ir=s(e=>e.reduce((t,r)=>t+r,0),"sum");function K({current:e,schema:t}){if(!t)return e;if(z(t))return e+2;if(Array.isArray(t.type))return t.type.length===1?ue("oneOf")+K({current:e,schema:{...t,type:t.type[0]}}):e+ue("oneOf")+ir(t.type.map(r=>K({current:0,schema:{...t,type:r}})));if(t.oneOf)return t.oneOf.length===1?ue("oneOf")+K({current:e,schema:t.oneOf[0]}):e+ue("oneOf")+ir(t.oneOf.map(r=>K({current:0,schema:r})));if(t.anyOf)return t.anyOf.length===1?ue("anyOf")+K({current:e,schema:t.anyOf[0]}):e+ue("anyOf")+ir(t.anyOf.map(r=>K({current:0,schema:r})));if(t.allOf)return t.allOf.length===1?ue("allOf")+K({current:e,schema:t.allOf[0]}):e+ue("allOf")+ir(t.allOf.map(r=>K({current:0,schema:r})));if(!t.type)return e;if(Et(t.type))return t.enum?e+jy(t)+ue("enum")+ir(t.enum.map(r=>K({current:0,schema:r}))):e+jy(t);if(t.type==="array")return t.items?ue("array")+K({current:e,schema:t.items}):ue("array")+K({current:e,schema:void 0});if(t.type==="object"||t.properties||t.additionalProperties){if(t.additionalProperties)return t.additionalProperties===!0?ue("record")+K({current:e,schema:void 0}):ue("record")+K({current:e,schema:t.additionalProperties});if(t.properties){let r=Object.values(t.properties);return e+ue("object")+ir(r.map(n=>K({current:0,schema:n})))}return ue("empty-object")+K({current:e,schema:void 0})}return e}s(K,"getOpenAPISchemaComplexity");function jy(e){let t=e.type;return t?oe(t).with("string",()=>1).with("number",()=>1).with("integer",()=>1).with("boolean",()=>1).otherwise(()=>0):0}s(jy,"complexityByType");function ue(e){return e?oe(e).with("oneOf",()=>2).with("anyOf",()=>3).with("allOf",()=>2).with("enum",()=>1).with("array",()=>1).with("record",()=>1).with("empty-object",()=>1).with("object",()=>2).otherwise(()=>0):0}s(ue,"complexityByComposite");var mu=class mu{constructor(t,r,n={referencedBy:[]}){this.schema=t;this.resolver=r;z(t)&&(this.ref=t.$ref),this.meta={...n,referencedBy:[...(n==null?void 0:n.referencedBy)??[]]},this.ref&&this.meta.referencedBy.push(this)}code;ref;children=[];meta;getCodeString(t,r){var o,a;if((!this.ref||!this.resolver)&&this.code)return this.code;let n=(o=this.resolver)==null?void 0:o.getZodSchemaNameByRef(this.ref);if(!n)return this.ref;let i=(a=this.resolver)==null?void 0:a.getTagByZodSchemaName(n);return r!=null&&r.includeNamespaces&&i&&i!==t?`${Xt({type:"models",tag:i,options:r})}.${n}`:n}get complexity(){return K({current:0,schema:this.schema})}assign(t){return this.code=t,this}inherit(t){return t&&t.children.push(this),this}};s(mu,"ZodSchema");var io=mu;function U({schema:e,resolver:t,meta:r,tag:n,options:i}){var $;if(!e)throw new Error("Schema is required");let o=new io(e,t,r),a={parent:o.inherit(r==null?void 0:r.parent),referencedBy:[...o.meta.referencedBy]},c={resolver:t,meta:a,tag:n,options:i};if(z(e))return cj({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});let u=fj({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(u)return u;let f=uj({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(f)return f;let l=lj({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(l)return l;let p=pj({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(p)return p;let d=dj({schema:e,zodSchema:o,resolver:t,meta:a,tag:n,options:i});if(d)return d;let m=i!=null&&i.allReadonly?".readonly()":"";if(xy(e))return e.items?o.assign(`z.array(${U({...c,schema:e.items}).getCodeString(n,i)}${Xe({schema:e.items,meta:{...a,isRequired:!0},options:i})})${m}`):o.assign(`z.array(z.any())${m}`);let y=e.type?e.type.toLowerCase():void 0;if(y==="object"||e.properties||e.additionalProperties){let g=(i==null?void 0:i.additionalPropertiesDefaultValue)!==void 0?i==null?void 0:i.additionalPropertiesDefaultValue:!0,_=(e.additionalProperties===null||e.additionalProperties===void 0?g:e.additionalProperties)===!1?"":".passthrough()";if(typeof e.additionalProperties=="object"&&Object.keys(e.additionalProperties).length>0)return o.assign(`z.record(${U({...c,schema:e.additionalProperties}).getCodeString(n,i)+Xe({schema:e.additionalProperties,meta:{...a,isRequired:!0},options:i})})`);let O=e.required&&e.required.length>0,k=i!=null&&i.withImplicitRequiredProps?!1:!(($=e.required)!=null&&$.length),S="{}";e.properties&&(S="{ "+Object.entries(e.properties).map(([ve,fe])=>{var Kn;let or={...a,isRequired:k?!0:O?(Kn=e.required)==null?void 0:Kn.includes(ve):i==null?void 0:i.withImplicitRequiredProps,name:ve},sr=fe;if(z(fe)&&t&&(sr=t.getSchemaByRef(fe.$ref),!sr))throw new Error(`Schema ${fe.$ref} not found`);let Zn=U({...c,schema:fe,meta:or}).getCodeString(n,i)+Xe({schema:sr,meta:or,options:i});return[ve,Zn]}).map(([ve,fe])=>`${ly(ve)}: ${fe}`).join(", ")+" }");let Y=k?".partial()":"",J=i!=null&&i.strictObjects?".strict()":"";return o.assign(`z.object(${S})${Y}${J}${_}${m}`)}if(!y)return o.assign("z.unknown()");throw new Error(`Unsupported schema type: ${y}`)}s(U,"getZodSchema");function cj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!z(e)||!r)return;let a=t.meta.referencedBy.slice(0,-1).map(f=>(r==null?void 0:r.getZodSchemaNameByRef(f.ref))??f.ref),c=r.getZodSchemaNameByRef(e.$ref);if(a.length>1&&a.includes(c))return t.assign(r.getCodeByZodSchemaName(t.ref));let u=r.getCodeByZodSchemaName(e.$ref);if(!u){let f=r.getSchemaByRef(e.$ref);if(!f)throw new Error(`Schema ${e.$ref} not found`);u=U({schema:f,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)}return r.getCodeByZodSchemaName(c)||r.setZodSchema(c,u,i),t}s(cj,"getReferenceZodSchema");function uj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){var c;if(!qt(e)||!e.oneOf)return;if(e.oneOf.length===1){let u=U({schema:e.oneOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(u.getCodeString(i,o))}let a=(c=e.oneOf)==null?void 0:c.some(u=>qt(u)&&((u==null?void 0:u.allOf)||[]).length>1);if(e.discriminator&&!a){let u=e.discriminator.propertyName;return t.assign(`
|
|
53
53
|
z.discriminatedUnion("${u}", [${e.oneOf.map(f=>U({schema:f,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])
|
|
54
|
-
`)}return t.assign(`z.union([${e.oneOf.map(u=>U({schema:u,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])`)}s(uj,"getOneOfZodSchema");function fj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!(!qt(e)||!Array.isArray(e.type)))return e.type.length===1?U({schema:{...e,type:e.type[0]},resolver:r,meta:n,tag:i,options:o}):t.assign(`z.union([${e.type.map(a=>U({schema:{...e,type:a},resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])`)}s(fj,"getArrayZodSchema");function lj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!qt(e)||!e.anyOf)return;if(e.anyOf.length===1){let c=U({schema:e.anyOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(c.getCodeString(i,o))}let a=e.anyOf.map(c=>U({schema:c,resolver:r,meta:n,tag:i,options:o})).map(c=>c.getCodeString(i,o)).join(", ");return t.assign(`z.union([${a}])`)}s(lj,"getAnyOfZodSchema");function pj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!qt(e)||!e.allOf)return;if(e.allOf.length===1){let d=U({schema:e.allOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(d.getCodeString(i,o))}let{patchRequiredSchemaInLoop:a,noRequiredOnlyAllof:c,composedRequiredSchema:u}=wy(e),f=c.map(d=>{let m=U({schema:d,resolver:r,meta:n,tag:i,options:o});return r&&a(d,r.getSchemaByRef.bind(r)),m});u.required.length&&f.push(U({schema:u,resolver:r,meta:n,tag:i,options:o}));let l=f.at(0),p=f.slice(1).map(d=>`merge(${d.getCodeString(i,o)})`).join(".");return t.assign(`${l.getCodeString(i,o)}.${p}`)}s(pj,"getAllOfZodSchema");function dj({schema:e,zodSchema:t}){if(!qt(e))return;let r=e.type?e.type.toLowerCase():void 0;if(r&&Et(r)){if(e.enum){if(r==="string"){if(e.enum.length===1){let n=e.enum[0],i=n===null?"null":`"${n}"`;return t.assign(`z.literal(${i})`)}return t.assign(`z.enum([${e.enum.map(n=>n===null?"null":`"${n}"`).join(", ")}])`)}if(e.enum.some(n=>typeof n=="string"))return t.assign("z.never()");if(e.enum.length===1){let n=e.enum[0];return t.assign(`z.literal(${n===null?"null":n})`)}return t.assign(`z.union([${e.enum.map(n=>`z.literal(${n===null?"null":n})`).join(", ")}])`)}return t.assign(oe(r).with("integer",()=>"z.number()").with("string",()=>oe(e.format).with("binary",()=>"z.instanceof(File)").otherwise(()=>"z.string()")).otherwise(n=>`z.${n}()`))}}s(dj,"getPrimitiveZodSchema");function Wr({schema:e,zodSchema:t,fallbackName:r,resolver:n,tag:i,options:o}){var u;let a=t.getCodeString();if((!rr(a)||t.ref===void 0)&&r){if(t.complexity<iu)return a;let f=At(r,o.schemaSuffix),l=f;for(;n.getCodeByZodSchemaName(l);){if((u=n.getZodSchemaNamesByCompositeCode(a))!=null&&u.includes(l))return l;if(n.getCodeByZodSchemaName(l)===f)return l;throw new Error(`Can't uniquely resolve zod schema name: ${l}`)}return n.setZodSchema(l,a,i),n.addZodSchemaForCompositeCode(a,t,l,e),l}let c=n.getCodeByZodSchemaName(a);if(!c&&t.ref&&(c=n.getCodeByZodSchemaName(n.getZodSchemaNameByRef(t.ref))),t.ref&&c)return K({current:0,schema:n.getSchemaByRef(t.ref)})<iu?n.getCodeByZodSchemaName(a):a;throw new Error("Invalid ref: "+t.ref)}s(Wr,"resolveZodSchemaName");function Ay({resolver:e,operation:t,operationName:r,isUniqueOperationName:n,tag:i,options:o}){var y,$;let a=e.resolveObject(t.requestBody);if(!a)return;let u=Object.keys(a.content??{}).find(jt);if(!u)return;let f=($=(y=a.content)==null?void 0:y[u])==null?void 0:$.schema;if(!f)return;let l=U({schema:f,resolver:e,meta:{isRequired:a.required??!0},tag:i,options:o}),p=e.resolveObject(f),d=Wr({schema:p,zodSchema:l,fallbackName:$y(Zr(r,n,i)),resolver:e,tag:i,options:o}),m=Xe({schema:p,meta:l.meta,options:o});return{endpointParameter:{name:Oy,type:"Body",description:a.description,zodSchema:d+m,bodyObject:a},requestFormat:u}}s(Ay,"getEndpointBody");function qy({resolver:e,param:t,operationName:r,isUniqueOperationName:n,tag:i,options:o}){let a=e.resolveObject(t);if(!sy.includes(a.in))return;let c={};if(a.content){let d=Object.keys(a.content??{}),m=d.find(jt);if(!m)throw new Error(`Unsupported media type for param ${a.name}: ${d.join(", ")}`);let y=a.content[m];if(!y)throw new Error(`No content with media type for param ${a.name}: ${m}`);c=(y==null?void 0:y.schema)??y}else a.schema&&(c=a.schema);o!=null&&o.withDescription&&c&&(c.description=(a.description??"").trim());let u=U({schema:c,resolver:e,meta:{isRequired:a.in==="path"?!0:a.required??!1},tag:i,options:o}),f=e.resolveObject(c),l=Xe({schema:f,meta:u.meta,options:o}),p=Wr({schema:f,zodSchema:u.assign(u.getCodeString(i,o)+l),fallbackName:vy(Zr(r,n,i),a.name),resolver:e,tag:i,options:o});return{name:oe(a.in).with("path",()=>cu(a.name)).otherwise(()=>a.name),type:oe(a.in).with("header",()=>"Header").with("query",()=>"Query").with("path",()=>"Path").run(),zodSchema:p,parameterObject:a}}s(qy,"getEndpointParameter");function Ty({openApiDoc:e,resolver:t,options:r}){var i,o,a;let n=[];for(let c in e.paths){let u=e.paths[c],f=tr(u,Qt),l=Iy(u.parameters??[]);for(let p in f){let d=f[p];if(!d||d.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let m=Object.entries({...l,...Iy(d.parameters??[])}).map(([,_])=>_),y=lu({path:c,method:p,operation:d,openApiDoc:e,options:r}),$=my(y,e,r),g=Gr(d,r),v={method:p,path:hy(c),operationName:y,description:d.description,tags:(i=d.tags)==null?void 0:i.map(ot),requestFormat:"application/json",parameters:[],response:"",errors:[]};if(d.requestBody){let _=Ay({resolver:t,operation:d,operationName:y,isUniqueOperationName:$,tag:g,options:r});_&&(v.parameters.push(_.endpointParameter),v.requestFormat=_.requestFormat)}for(let _ of m){let O=qy({resolver:t,param:_,operationName:y,isUniqueOperationName:$,tag:g,options:r});O&&v.parameters.push(O)}for(let _ in d.responses){let O=t.resolveObject(d.responses[_]),S=Object.keys(O.content??{}).find(Hr),Y,J;if(S?(v.responseFormat=S,Y=(a=(o=O.content)==null?void 0:o[S])==null?void 0:a.schema):J=Yc,Y){let $e=U({schema:Y,resolver:t,meta:{isRequired:!0},tag:g,options:r}),ve=t.resolveObject(Y);J=Wr({schema:ve,zodSchema:$e,fallbackName:$e.ref?void 0:mj({statusCode:_,endpoint:v,operationName:y,isUniqueOperationName:$,tag:g}),resolver:t,tag:g,options:r})+Xe({schema:ve,meta:$e.meta,options:r})}if(J){let $e=Number(_);uu($e)?(v.response=J,v.responseObject=O):_!=="default"&&fu($e)&&v.errors.push({zodSchema:J,status:$e,description:O.description})}}v.response||(v.response=Yc),n.push(v)}}return n}s(Ty,"getEndpointsFromOpenAPIDoc");function mj({statusCode:e,endpoint:t,operationName:r,isUniqueOperationName:n,tag:i}){let o=Number(e),a=Zr(r,n,i);return(!uu(o)||t.response)&&e!=="default"&&fu(o)?_y(a,e):by(a)}s(mj,"getResponseZodSchemaName");function Iy(e){return Object.fromEntries((e??[]).map(t=>[z(t)?t.$ref:t.name,t]))}s(Iy,"getParameters");function Ry({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n={},refsDependencyGraph:i={}}){return Yr({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n,refsDependencyGraph:i}),{visitedRefs:n,refsDependencyGraph:i}}s(Ry,"getSchemaRefsDependencyGraph");function Yr({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n,refsDependencyGraph:i}){if(!e)return;let o={fromRef:t,getSchemaByRef:r,visitedRefs:n,refsDependencyGraph:i};if(z(e)){if(i[t]||(i[t]=new Set),i[t].add(e.$ref),n[e.$ref])return;n[t]=!0,Yr({...o,schema:r(e.$ref),fromRef:e.$ref});return}for(let a of er)if(e[a])for(let c of e[a])Yr({...o,schema:c});if(!er.some(a=>e[a])){if(e.type==="array"){if(!e.items)return;Yr({...o,schema:e.items});return}if(e.type==="object"||e.properties||e.additionalProperties){if(e.properties)for(let a in e.properties)Yr({...o,schema:e.properties[a]});e.additionalProperties&&typeof e.additionalProperties=="object"&&Yr({...o,schema:e.additionalProperties})}}}s(Yr,"visit");function Ny(e,t){let r=hj(e,t),n=yj(e,r);return{refsDependencyGraph:r,deepDependencyGraph:n}}s(Ny,"getOpenAPISchemaDependencyGraph");function hj(e,t){let r={},n={};return e.forEach(i=>Ry({schema:t(i),fromRef:i,getSchemaByRef:t,visitedRefs:r,refsDependencyGraph:n})),n}s(hj,"getRefsDependencyGraph");function yj(e,t){let r={},n={},i=s((o,a)=>{n[a].add(o),t[o]&&a!==o&&t[o].forEach(c=>{let u=`${a}__${c}`;r[u]||(r[u]=!0,i(c,a))})},"visit");return e.forEach(o=>{let a=t[o];a&&(n[o]||(n[o]=new Set),a.forEach(c=>i(c,o)))}),n}s(yj,"getDeepRefsDependencyGraph");var hu=class hu{constructor(t,r){this.openApiDoc=t;this.options=r;this.dependencyGraph=Ny(this.schemaRefs,this.getSchemaByRef.bind(this)),this.intializeSchemaInfo(),this.initializeSchemaTags()}schemaData=[];zodSchemaData=[];compositeZodSchemaData=[];dependencyGraph;get docSchemas(){var t;return((t=this.openApiDoc.components)==null?void 0:t.schemas)??{}}get schemaRefs(){return Object.keys(this.docSchemas).map(uy)}getSchemaByRef(t){return this.docSchemas[au(t)]}getZodSchemaNameByRef(t){return this.schemaData.find(r=>r.ref===Gn(t)).zodSchemaName}getRefByZodSchemaName(t){var r;return(r=this.schemaData.find(n=>n.zodSchemaName===t))==null?void 0:r.ref}getTagByZodSchemaName(t){var n,i;let r;if(this.options.splitByTags){let o=this.getRefByZodSchemaName(t),a=((n=this.schemaData.find(f=>f.ref===o))==null?void 0:n.tags)??[],c=((i=this.zodSchemaData.find(f=>f.zodSchemaName===t))==null?void 0:i.tags)??[],u=new Set([...a,...c]);r=u.size===1?u.values().next().value:this.options.defaultTag}return ot(r??this.options.defaultTag)}getCodeByZodSchemaName(t){var r;return(r=this.zodSchemaData.find(n=>n.zodSchemaName===t))==null?void 0:r.code}getZodSchemaNamesByCompositeCode(t){var r;return(r=this.compositeZodSchemaData.find(n=>n.code===t))==null?void 0:r.zodSchemas.map(n=>n.zodSchemaName)}setZodSchema(t,r,n){let i=this.zodSchemaData.find(o=>o.zodSchemaName===t);i?(i.code=r,i.tags=(i.tags??[]).concat(n)):this.zodSchemaData.push({zodSchemaName:t,code:r,tags:[n]})}addZodSchemaForCompositeCode(t,r,n,i){let o={zodSchemaName:n,zodSchema:r,schema:i},a=this.compositeZodSchemaData.find(c=>c.code===t);a?a.zodSchemas.push(o):this.compositeZodSchemaData.push({code:t,zodSchemas:[o]})}getCompositeZodSchemaByZodSchemaName(t){var n;let r=this.compositeZodSchemaData.find(i=>i.zodSchemas.some(o=>o.zodSchemaName===t));return(n=r==null?void 0:r.zodSchemas.find(i=>i.zodSchemaName===t))==null?void 0:n.zodSchema}getSchemaByCompositeZodSchemaName(t){var r,n;return(n=(r=this.compositeZodSchemaData.find(i=>i.zodSchemas.some(o=>o.zodSchemaName===t)))==null?void 0:r.zodSchemas.find(i=>i.zodSchemaName===t))==null?void 0:n.schema}getZodSchemas(){return this.zodSchemaData.reduce((t,{zodSchemaName:r,code:n})=>({...t,[r]:n}),{})}resolveObject(t){return z(t)?this.getSchemaByRef(t.$ref):t}intializeSchemaInfo(){this.schemaRefs.forEach(t=>{let r=Gn(t),n=au(r),i=At(n,this.options.schemaSuffix);this.schemaData.push({ref:r,name:n,zodSchemaName:i,tags:[]})})}initializeSchemaTags(){var t,r,n,i,o,a;for(let c in this.openApiDoc.paths){let u=this.openApiDoc.paths[c],f=tr(u,Qt);for(let l in f){let p=f[l];if(!p||p.deprecated&&!((t=this.options)!=null&&t.withDeprecatedEndpoints))continue;let d=[];if((r=p.parameters)==null||r.map(g=>{d.push(...this.getOperationSchemaRefs(g.schema))}),p.requestBody){let g=this.resolveObject(p.requestBody),_=Object.keys(g.content??{}).find(jt);_&&d.push(...this.getOperationSchemaRefs((i=(n=g.content)==null?void 0:n[_])==null?void 0:i.schema))}for(let g in p.responses){let v=this.resolveObject(p.responses[g]),O=Object.keys(v.content??{}).find(Hr);O&&d.push(...this.getOperationSchemaRefs((a=(o=v.content)==null?void 0:o[O])==null?void 0:a.schema))}let y=d.map(g=>Gn(g.$ref)).reduce((g,v)=>{let _=this.dependencyGraph.deepDependencyGraph[v];return[...g,v,...Array.from(_??[])]},[]),$=Gr(p,this.options);y.forEach(g=>{let v=this.schemaData.find(_=>_.ref===g);v&&v.tags.push($)})}}}getOperationSchemaRefs(t){if(!t)return[];let r=[];z(t)&&r.push(t);let n=t;return er.some(i=>i in n&&n[i])&&(n.allOf??n.anyOf??n.oneOf??[]).forEach(o=>r.push(...this.getOperationSchemaRefs(o))),n.properties&&Object.values(n.properties).forEach(i=>r.push(...this.getOperationSchemaRefs(i))),n.type==="array"&&r.push(...this.getOperationSchemaRefs(t.items)),r}};s(hu,"SchemaResolver");var oo=hu;function ky({resolver:e,openApiDoc:t,options:r}){var i;let n={};return Object.entries(((i=t.components)==null?void 0:i.schemas)??{}).forEach(([o,a])=>{let c=At(o,r.schemaSuffix);if(!n[c]){let u=e.getTagByZodSchemaName(c);n[c]=U({schema:a,resolver:e,tag:u,options:r}).getCodeString(u,r)}}),n}s(ky,"getZodSchemasFromOpenAPIDoc");function Cy(e){let t=[],r={};function n(i,o){Array.isArray(o)||(o=[]),o.push(i),r[i]=!0,e[i]&&e[i].forEach(a=>{o.includes(a)||r[a]||n(a,o.slice(0))}),t.includes(i)||t.push(i)}return s(n,"visit"),Object.keys(e).forEach(i=>n(i,[])),t}s(Cy,"topologicalSort");function My(e,t){let r=Object.entries(e),n=r.filter(([i])=>t.includes(i)).sort(([i],[o])=>t.indexOf(i)-t.indexOf(o)).concat(r.filter(([i])=>!t.includes(i)));return Object.fromEntries(n)}s(My,"sortObjKeysFromArray");function Dy({resolver:e,zodSchemas:t}){let r=Cy(e.dependencyGraph.deepDependencyGraph).map(i=>e.getZodSchemaNameByRef(i));return My(t,r)}s(Dy,"sortZodSchemasByTopology");function Fy({resolver:e,zodSchemas:t,options:r}){let n={};return Object.entries(t).forEach(([i,o])=>{var u;let a=e.getRefByZodSchemaName(i),c=a&&((u=e.dependencyGraph.deepDependencyGraph[a])==null?void 0:u.has(a));n[At(i,r.schemaSuffix)]=c?`z.lazy(() => ${o})`:o}),n}s(Fy,"wrapCircularZodSchemas");function Ly({openApiDoc:e,options:t}){let r=new oo(e,t),n=Ty({resolver:r,openApiDoc:e,options:t}),o={...ky({resolver:r,openApiDoc:e,options:t}),...r.getZodSchemas()};return o=Fy({resolver:r,zodSchemas:o,options:t}),o=Dy({resolver:r,zodSchemas:o}),{resolver:r,data:gj({resolver:r,endpoints:n,zodSchemas:o,options:t})}}s(Ly,"getDataFromOpenAPIDoc");function gj({resolver:e,endpoints:t,zodSchemas:r,options:n}){let i=new Map;return n.splitByTags?(t.forEach(o=>{let a=Ey(o,n);Vy(a,i).endpoints.push(o)}),Object.entries(r).forEach(([o,a])=>{let c=e.getTagByZodSchemaName(o);c&&(Vy(c,i).zodSchemas[o]=a)}),i):(i.set(n.defaultTag,{endpoints:t,zodSchemas:r}),i)}s(gj,"splitDataByTags");function Vy(e,t){return t.has(e)||t.set(e,{endpoints:[],zodSchemas:{}}),t.get(e)}s(Vy,"getTagElement");async function zy({openApiDoc:e,options:t}){let{resolver:r,data:n}=await Ly({openApiDoc:e,options:t}),i=[],o=[];return n.forEach(({endpoints:c,zodSchemas:u},f)=>{var d;((d=t.excludeTags)==null?void 0:d.findIndex(m=>m.toLocaleLowerCase()===f.toLocaleLowerCase()))===-1&&(Object.keys(u).forEach(m=>{let y=r.getRefByZodSchemaName(m),$=y?r.getSchemaByRef(y):r.getSchemaByCompositeZodSchemaName(m),g=Kr({zodSchemaName:m,schema:$,resolver:r,options:t}),v;$&&(v=nr({schema:$,parentTypes:[g],resolver:r,options:t})),i.push({...g,metaType:"primitive",...v})}),c.forEach(m=>{let y="queries",$=ot(f);o.push({name:ry(m),filePath:to({type:y,tag:$,includeTagDir:!0,options:t}),namespace:t.includeNamespaces?Xt({type:y,tag:$,options:t}):void 0,isQuery:yy(m),isMutation:gy(m),params:$j({resolver:r,endpoint:m,options:t}),response:vj({resolver:r,endpoint:m,options:t})})}))}),{openApiDoc:e,models:i,queries:o}}s(zy,"getMetadataFromOpenAPIDoc");function $j({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var c,u,f,l;let i;if((c=n.parameterObject)!=null&&c.schema)i=e.resolveObject(n.parameterObject.schema);else if(n.bodyObject){let d=Object.keys(n.bodyObject.content??{}).find(jt);d&&(i=e.resolveObject((f=(u=n.bodyObject.content)==null?void 0:u[d])==null?void 0:f.schema))}let o=Kr({zodSchemaName:n.zodSchema,schema:i,resolver:e,options:r}),a;return i&&(a=nr({schema:i,parentTypes:[o],resolver:e,options:r})),{name:Xc(n.name),isRequired:((l=n.parameterObject)==null?void 0:l.required)??!0,...o,...a,paramType:n.type}}).sort((n,i)=>{if(n.isRequired===i.isRequired){let o=["Path","Body","Query","Header"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.isRequired?-1:1}).map(({paramType:n,...i})=>i)}s($j,"getQueryMetadataParams");function vj({resolver:e,endpoint:t,options:r}){var c,u,f,l;let n,i=Object.keys(((c=t.responseObject)==null?void 0:c.content)??{}).find(Hr);i&&(n=e.resolveObject((l=(f=(u=t.responseObject)==null?void 0:u.content)==null?void 0:f[i])==null?void 0:l.schema));let o=Kr({zodSchemaName:t.response,schema:n,resolver:e,options:r}),a;return n&&(a=nr({schema:n,parentTypes:[o],resolver:e,options:r})),{...o,metaType:"primitive",...a}}s(vj,"getQueryMetadataResponse");async function bj({input:e,options:t}){let r={...Xh,...t},n=await Uy.default.bundle(e);return await zy({openApiDoc:n,options:r})}s(bj,"getGenerateMetadata");0&&(module.exports={getGenerateMetadata});
|
|
54
|
+
`)}return t.assign(`z.union([${e.oneOf.map(u=>U({schema:u,resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])`)}s(uj,"getOneOfZodSchema");function fj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!(!qt(e)||!Array.isArray(e.type)))return e.type.length===1?U({schema:{...e,type:e.type[0]},resolver:r,meta:n,tag:i,options:o}):t.assign(`z.union([${e.type.map(a=>U({schema:{...e,type:a},resolver:r,meta:n,tag:i,options:o}).getCodeString(i,o)).join(", ")}])`)}s(fj,"getArrayZodSchema");function lj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!qt(e)||!e.anyOf)return;if(e.anyOf.length===1){let c=U({schema:e.anyOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(c.getCodeString(i,o))}let a=e.anyOf.map(c=>U({schema:c,resolver:r,meta:n,tag:i,options:o})).map(c=>c.getCodeString(i,o)).join(", ");return t.assign(`z.union([${a}])`)}s(lj,"getAnyOfZodSchema");function pj({schema:e,zodSchema:t,resolver:r,meta:n,tag:i,options:o}){if(!qt(e)||!e.allOf)return;if(e.allOf.length===1){let d=U({schema:e.allOf[0],resolver:r,meta:n,tag:i,options:o});return t.assign(d.getCodeString(i,o))}let{patchRequiredSchemaInLoop:a,noRequiredOnlyAllof:c,composedRequiredSchema:u}=wy(e),f=c.map(d=>{let m=U({schema:d,resolver:r,meta:n,tag:i,options:o});return r&&a(d,r.getSchemaByRef.bind(r)),m});u.required.length&&f.push(U({schema:u,resolver:r,meta:n,tag:i,options:o}));let l=f.at(0),p=f.slice(1).map(d=>`merge(${d.getCodeString(i,o)})`).join(".");return t.assign(`${l.getCodeString(i,o)}.${p}`)}s(pj,"getAllOfZodSchema");function dj({schema:e,zodSchema:t}){if(!qt(e))return;let r=e.type?e.type.toLowerCase():void 0;if(r&&Et(r)){if(e.enum){if(r==="string"){if(e.enum.length===1){let n=e.enum[0],i=n===null?"null":`"${n}"`;return t.assign(`z.literal(${i})`)}return t.assign(`z.enum([${e.enum.map(n=>n===null?"null":`"${n}"`).join(", ")}])`)}if(e.enum.some(n=>typeof n=="string"))return t.assign("z.never()");if(e.enum.length===1){let n=e.enum[0];return t.assign(`z.literal(${n===null?"null":n})`)}return t.assign(`z.union([${e.enum.map(n=>`z.literal(${n===null?"null":n})`).join(", ")}])`)}return t.assign(oe(r).with("integer",()=>"z.number()").with("string",()=>oe(e.format).with("binary",()=>"z.instanceof(File)").otherwise(()=>"z.string()")).otherwise(n=>`z.${n}()`))}}s(dj,"getPrimitiveZodSchema");function Wr({schema:e,zodSchema:t,fallbackName:r,resolver:n,tag:i,options:o}){var u;let a=t.getCodeString();if((!rr(a)||t.ref===void 0)&&r){if(t.complexity<iu)return a;let f=At(r,o.schemaSuffix),l=f;for(;n.getCodeByZodSchemaName(l);){if((u=n.getZodSchemaNamesByCompositeCode(a))!=null&&u.includes(l))return l;if(n.getCodeByZodSchemaName(l)===f)return l;throw new Error(`Can't uniquely resolve zod schema name: ${l}`)}return n.setZodSchema(l,a,i),n.addZodSchemaForCompositeCode(a,t,l,e),l}let c=n.getCodeByZodSchemaName(a);if(!c&&t.ref&&(c=n.getCodeByZodSchemaName(n.getZodSchemaNameByRef(t.ref))),t.ref&&c)return K({current:0,schema:n.getSchemaByRef(t.ref)})<iu?n.getCodeByZodSchemaName(a):a;throw new Error("Invalid ref: "+t.ref)}s(Wr,"resolveZodSchemaName");function Ay({resolver:e,operation:t,operationName:r,isUniqueOperationName:n,tag:i,options:o}){var y,$;let a=e.resolveObject(t.requestBody);if(!a)return;let u=Object.keys(a.content??{}).find(jt);if(!u)return;let f=($=(y=a.content)==null?void 0:y[u])==null?void 0:$.schema;if(!f)return;let l=U({schema:f,resolver:e,meta:{isRequired:a.required??!0},tag:i,options:o}),p=e.resolveObject(f),d=Wr({schema:p,zodSchema:l,fallbackName:$y(Zr(r,n,i)),resolver:e,tag:i,options:o}),m=Xe({schema:p,meta:l.meta,options:o});return{endpointParameter:{name:Oy,type:"Body",description:a.description,zodSchema:d+m,bodyObject:a},requestFormat:u}}s(Ay,"getEndpointBody");function qy({resolver:e,param:t,operationName:r,isUniqueOperationName:n,tag:i,options:o}){let a=e.resolveObject(t);if(!sy.includes(a.in))return;let c={};if(a.content){let d=Object.keys(a.content??{}),m=d.find(jt);if(!m)throw new Error(`Unsupported media type for param ${a.name}: ${d.join(", ")}`);let y=a.content[m];if(!y)throw new Error(`No content with media type for param ${a.name}: ${m}`);c=(y==null?void 0:y.schema)??y}else a.schema&&(c=a.schema);o!=null&&o.withDescription&&c&&(c.description=(a.description??"").trim());let u=U({schema:c,resolver:e,meta:{isRequired:a.in==="path"?!0:a.required??!1},tag:i,options:o}),f=e.resolveObject(c),l=Xe({schema:f,meta:u.meta,options:o}),p=Wr({schema:f,zodSchema:u.assign(u.getCodeString(i,o)+l),fallbackName:vy(Zr(r,n,i),a.name),resolver:e,tag:i,options:o});return{name:oe(a.in).with("path",()=>cu(a.name)).otherwise(()=>a.name),type:oe(a.in).with("header",()=>"Header").with("query",()=>"Query").with("path",()=>"Path").run(),zodSchema:p,parameterObject:a}}s(qy,"getEndpointParameter");function Ty({openApiDoc:e,resolver:t,options:r}){var i,o,a;let n=[];for(let c in e.paths){let u=e.paths[c],f=tr(u,Qt),l=Iy(u.parameters??[]);for(let p in f){let d=f[p];if(!d||d.deprecated&&!(r!=null&&r.withDeprecatedEndpoints))continue;let m=Object.entries({...l,...Iy(d.parameters??[])}).map(([,_])=>_),y=lu({path:c,method:p,operation:d,openApiDoc:e,options:r}),$=my(y,e,r),g=Gr(d,r),v={method:p,path:hy(c),operationName:y,description:d.description,tags:(i=d.tags)==null?void 0:i.map(ot),requestFormat:"application/json",parameters:[],response:"",errors:[]};if(d.requestBody){let _=Ay({resolver:t,operation:d,operationName:y,isUniqueOperationName:$,tag:g,options:r});_&&(v.parameters.push(_.endpointParameter),v.requestFormat=_.requestFormat)}for(let _ of m){let O=qy({resolver:t,param:_,operationName:y,isUniqueOperationName:$,tag:g,options:r});O&&v.parameters.push(O)}for(let _ in d.responses){let O=t.resolveObject(d.responses[_]),S=Object.keys(O.content??{}).find(Hr),Y,J;if(S?(v.responseFormat=S,Y=(a=(o=O.content)==null?void 0:o[S])==null?void 0:a.schema):J=Yc,Y){let $e=U({schema:Y,resolver:t,meta:{isRequired:!0},tag:g,options:r}),ve=t.resolveObject(Y);J=Wr({schema:ve,zodSchema:$e,fallbackName:$e.ref?void 0:mj({statusCode:_,endpoint:v,operationName:y,isUniqueOperationName:$,tag:g}),resolver:t,tag:g,options:r})+Xe({schema:ve,meta:$e.meta,options:r})}if(J){let $e=Number(_);uu($e)?(v.response=J,v.responseObject=O):_!=="default"&&fu($e)&&v.errors.push({zodSchema:J,status:$e,description:O.description})}}v.response||(v.response=Yc),n.push(v)}}return n}s(Ty,"getEndpointsFromOpenAPIDoc");function mj({statusCode:e,endpoint:t,operationName:r,isUniqueOperationName:n,tag:i}){let o=Number(e),a=Zr(r,n,i);return(!uu(o)||t.response)&&e!=="default"&&fu(o)?_y(a,e):by(a)}s(mj,"getResponseZodSchemaName");function Iy(e){return Object.fromEntries((e??[]).map(t=>[z(t)?t.$ref:t.name,t]))}s(Iy,"getParameters");function Ry({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n={},refsDependencyGraph:i={}}){return Yr({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n,refsDependencyGraph:i}),{visitedRefs:n,refsDependencyGraph:i}}s(Ry,"getSchemaRefsDependencyGraph");function Yr({schema:e,fromRef:t,getSchemaByRef:r,visitedRefs:n,refsDependencyGraph:i}){if(!e)return;let o={fromRef:t,getSchemaByRef:r,visitedRefs:n,refsDependencyGraph:i};if(z(e)){if(i[t]||(i[t]=new Set),i[t].add(e.$ref),n[e.$ref])return;n[t]=!0,Yr({...o,schema:r(e.$ref),fromRef:e.$ref});return}for(let a of er)if(e[a])for(let c of e[a])Yr({...o,schema:c});if(!er.some(a=>e[a])){if(e.type==="array"){if(!e.items)return;Yr({...o,schema:e.items});return}if(e.type==="object"||e.properties||e.additionalProperties){if(e.properties)for(let a in e.properties)Yr({...o,schema:e.properties[a]});e.additionalProperties&&typeof e.additionalProperties=="object"&&Yr({...o,schema:e.additionalProperties})}}}s(Yr,"visit");function Ny(e,t){let r=hj(e,t),n=yj(e,r);return{refsDependencyGraph:r,deepDependencyGraph:n}}s(Ny,"getOpenAPISchemaDependencyGraph");function hj(e,t){let r={},n={};return e.forEach(i=>Ry({schema:t(i),fromRef:i,getSchemaByRef:t,visitedRefs:r,refsDependencyGraph:n})),n}s(hj,"getRefsDependencyGraph");function yj(e,t){let r={},n={},i=s((o,a)=>{n[a].add(o),t[o]&&a!==o&&t[o].forEach(c=>{let u=`${a}__${c}`;r[u]||(r[u]=!0,i(c,a))})},"visit");return e.forEach(o=>{let a=t[o];a&&(n[o]||(n[o]=new Set),a.forEach(c=>i(c,o)))}),n}s(yj,"getDeepRefsDependencyGraph");var hu=class hu{constructor(t,r){this.openApiDoc=t;this.options=r;this.dependencyGraph=Ny(this.schemaRefs,this.getSchemaByRef.bind(this)),this.intializeSchemaInfo(),this.initializeSchemaTags()}schemaData=[];zodSchemaData=[];compositeZodSchemaData=[];dependencyGraph;get docSchemas(){var t;return((t=this.openApiDoc.components)==null?void 0:t.schemas)??{}}get schemaRefs(){return Object.keys(this.docSchemas).map(uy)}getSchemaByRef(t){return this.docSchemas[au(t)]}getZodSchemaNameByRef(t){return this.schemaData.find(r=>r.ref===Gn(t)).zodSchemaName}getRefByZodSchemaName(t){var r;return(r=this.schemaData.find(n=>n.zodSchemaName===t))==null?void 0:r.ref}getTagByZodSchemaName(t){var n,i;let r;if(this.options.splitByTags){let o=this.getRefByZodSchemaName(t),a=((n=this.schemaData.find(f=>f.ref===o))==null?void 0:n.tags)??[],c=((i=this.zodSchemaData.find(f=>f.zodSchemaName===t))==null?void 0:i.tags)??[],u=new Set([...a,...c]);r=u.size===1?u.values().next().value:this.options.defaultTag}return ot(r??this.options.defaultTag)}getCodeByZodSchemaName(t){var r;return(r=this.zodSchemaData.find(n=>n.zodSchemaName===t))==null?void 0:r.code}getZodSchemaNamesByCompositeCode(t){var r;return(r=this.compositeZodSchemaData.find(n=>n.code===t))==null?void 0:r.zodSchemas.map(n=>n.zodSchemaName)}setZodSchema(t,r,n){let i=this.zodSchemaData.find(o=>o.zodSchemaName===t);i?(i.code=r,i.tags=(i.tags??[]).concat(n)):this.zodSchemaData.push({zodSchemaName:t,code:r,tags:[n]})}addZodSchemaForCompositeCode(t,r,n,i){let o={zodSchemaName:n,zodSchema:r,schema:i},a=this.compositeZodSchemaData.find(c=>c.code===t);a?a.zodSchemas.push(o):this.compositeZodSchemaData.push({code:t,zodSchemas:[o]})}getCompositeZodSchemaByZodSchemaName(t){var n;let r=this.compositeZodSchemaData.find(i=>i.zodSchemas.some(o=>o.zodSchemaName===t));return(n=r==null?void 0:r.zodSchemas.find(i=>i.zodSchemaName===t))==null?void 0:n.zodSchema}getSchemaByCompositeZodSchemaName(t){var r,n;return(n=(r=this.compositeZodSchemaData.find(i=>i.zodSchemas.some(o=>o.zodSchemaName===t)))==null?void 0:r.zodSchemas.find(i=>i.zodSchemaName===t))==null?void 0:n.schema}getZodSchemas(){return this.zodSchemaData.reduce((t,{zodSchemaName:r,code:n})=>({...t,[r]:n}),{})}resolveObject(t){return z(t)?this.getSchemaByRef(t.$ref):t}isSchemaCircular(t){var r;return(r=this.dependencyGraph.deepDependencyGraph[t])==null?void 0:r.has(t)}intializeSchemaInfo(){this.schemaRefs.forEach(t=>{let r=Gn(t),n=au(r),i=At(n,this.options.schemaSuffix);this.schemaData.push({ref:r,name:n,zodSchemaName:i,tags:[]})})}initializeSchemaTags(){var t,r,n,i,o,a;for(let c in this.openApiDoc.paths){let u=this.openApiDoc.paths[c],f=tr(u,Qt);for(let l in f){let p=f[l];if(!p||p.deprecated&&!((t=this.options)!=null&&t.withDeprecatedEndpoints))continue;let d=[];if((r=p.parameters)==null||r.map(g=>{d.push(...this.getOperationSchemaRefs(g.schema))}),p.requestBody){let g=this.resolveObject(p.requestBody),_=Object.keys(g.content??{}).find(jt);_&&d.push(...this.getOperationSchemaRefs((i=(n=g.content)==null?void 0:n[_])==null?void 0:i.schema))}for(let g in p.responses){let v=this.resolveObject(p.responses[g]),O=Object.keys(v.content??{}).find(Hr);O&&d.push(...this.getOperationSchemaRefs((a=(o=v.content)==null?void 0:o[O])==null?void 0:a.schema))}let y=d.map(g=>Gn(g.$ref)).reduce((g,v)=>{let _=this.dependencyGraph.deepDependencyGraph[v];return[...g,v,...Array.from(_??[])]},[]),$=Gr(p,this.options);y.forEach(g=>{let v=this.schemaData.find(_=>_.ref===g);v&&v.tags.push($)})}}}getOperationSchemaRefs(t){if(!t)return[];let r=[];z(t)&&r.push(t);let n=t;return er.some(i=>i in n&&n[i])&&(n.allOf??n.anyOf??n.oneOf??[]).forEach(o=>r.push(...this.getOperationSchemaRefs(o))),n.properties&&Object.values(n.properties).forEach(i=>r.push(...this.getOperationSchemaRefs(i))),n.type==="array"&&r.push(...this.getOperationSchemaRefs(t.items)),r}};s(hu,"SchemaResolver");var oo=hu;function ky({resolver:e,openApiDoc:t,options:r}){var i;let n={};return Object.entries(((i=t.components)==null?void 0:i.schemas)??{}).forEach(([o,a])=>{let c=At(o,r.schemaSuffix);if(!n[c]){let u=e.getTagByZodSchemaName(c);n[c]=U({schema:a,resolver:e,tag:u,options:r}).getCodeString(u,r)}}),n}s(ky,"getZodSchemasFromOpenAPIDoc");function Cy(e){let t=[],r={};function n(i,o){Array.isArray(o)||(o=[]),o.push(i),r[i]=!0,e[i]&&e[i].forEach(a=>{o.includes(a)||r[a]||n(a,o.slice(0))}),t.includes(i)||t.push(i)}return s(n,"visit"),Object.keys(e).forEach(i=>n(i,[])),t}s(Cy,"topologicalSort");function My(e,t){let r=Object.entries(e),n=r.filter(([i])=>t.includes(i)).sort(([i],[o])=>t.indexOf(i)-t.indexOf(o)).concat(r.filter(([i])=>!t.includes(i)));return Object.fromEntries(n)}s(My,"sortObjKeysFromArray");function Dy({resolver:e,zodSchemas:t}){let r=Cy(e.dependencyGraph.deepDependencyGraph).map(i=>e.getZodSchemaNameByRef(i));return My(t,r)}s(Dy,"sortZodSchemasByTopology");function Fy({resolver:e,zodSchemas:t,options:r}){let n={};return Object.entries(t).forEach(([i,o])=>{let a=e.getRefByZodSchemaName(i),c=a&&e.isSchemaCircular(a);n[At(i,r.schemaSuffix)]=c?`z.lazy(() => ${o})`:o}),n}s(Fy,"wrapCircularZodSchemas");function Ly({openApiDoc:e,options:t}){let r=new oo(e,t),n=Ty({resolver:r,openApiDoc:e,options:t}),o={...ky({resolver:r,openApiDoc:e,options:t}),...r.getZodSchemas()};return o=Fy({resolver:r,zodSchemas:o,options:t}),o=Dy({resolver:r,zodSchemas:o}),{resolver:r,data:gj({resolver:r,endpoints:n,zodSchemas:o,options:t})}}s(Ly,"getDataFromOpenAPIDoc");function gj({resolver:e,endpoints:t,zodSchemas:r,options:n}){let i=new Map;return n.splitByTags?(t.forEach(o=>{let a=Ey(o,n);Vy(a,i).endpoints.push(o)}),Object.entries(r).forEach(([o,a])=>{let c=e.getTagByZodSchemaName(o);c&&(Vy(c,i).zodSchemas[o]=a)}),i):(i.set(n.defaultTag,{endpoints:t,zodSchemas:r}),i)}s(gj,"splitDataByTags");function Vy(e,t){return t.has(e)||t.set(e,{endpoints:[],zodSchemas:{}}),t.get(e)}s(Vy,"getTagElement");async function zy({openApiDoc:e,options:t}){let{resolver:r,data:n}=await Ly({openApiDoc:e,options:t}),i=[],o=[];return n.forEach(({endpoints:c,zodSchemas:u},f)=>{var d;((d=t.excludeTags)==null?void 0:d.findIndex(m=>m.toLocaleLowerCase()===f.toLocaleLowerCase()))===-1&&(Object.keys(u).forEach(m=>{let y=r.getRefByZodSchemaName(m),$=y?r.getSchemaByRef(y):r.getSchemaByCompositeZodSchemaName(m),g=Kr({zodSchemaName:m,schema:$,resolver:r,options:t}),v;$&&(v=nr({schema:$,parentTypes:[g],resolver:r,options:t})),i.push({...g,metaType:"primitive",...v})}),c.forEach(m=>{let y="queries",$=ot(f);o.push({name:ry(m),filePath:to({type:y,tag:$,includeTagDir:!0,options:t}),namespace:t.includeNamespaces?Xt({type:y,tag:$,options:t}):void 0,isQuery:yy(m),isMutation:gy(m),params:$j({resolver:r,endpoint:m,options:t}),response:vj({resolver:r,endpoint:m,options:t})})}))}),{openApiDoc:e,models:i,queries:o}}s(zy,"getMetadataFromOpenAPIDoc");function $j({resolver:e,endpoint:t,options:r}){return t.parameters.map(n=>{var c,u,f,l;let i;if((c=n.parameterObject)!=null&&c.schema)i=e.resolveObject(n.parameterObject.schema);else if(n.bodyObject){let d=Object.keys(n.bodyObject.content??{}).find(jt);d&&(i=e.resolveObject((f=(u=n.bodyObject.content)==null?void 0:u[d])==null?void 0:f.schema))}let o=Kr({zodSchemaName:n.zodSchema,schema:i,resolver:e,options:r}),a;return i&&(a=nr({schema:i,parentTypes:[o],resolver:e,options:r})),{name:Xc(n.name),isRequired:((l=n.parameterObject)==null?void 0:l.required)??!0,...o,...a,paramType:n.type}}).sort((n,i)=>{if(n.isRequired===i.isRequired){let o=["Path","Body","Query","Header"];return o.indexOf(n.paramType)-o.indexOf(i.paramType)}return n.isRequired?-1:1}).map(({paramType:n,...i})=>i)}s($j,"getQueryMetadataParams");function vj({resolver:e,endpoint:t,options:r}){var c,u,f,l;let n,i=Object.keys(((c=t.responseObject)==null?void 0:c.content)??{}).find(Hr);i&&(n=e.resolveObject((l=(f=(u=t.responseObject)==null?void 0:u.content)==null?void 0:f[i])==null?void 0:l.schema));let o=Kr({zodSchemaName:t.response,schema:n,resolver:e,options:r}),a;return n&&(a=nr({schema:n,parentTypes:[o],resolver:e,options:r})),{...o,metaType:"primitive",...a}}s(vj,"getQueryMetadataResponse");async function bj({input:e,options:t}){let r={...Xh,...t},n=await Uy.default.bundle(e);return await zy({openApiDoc:n,options:r})}s(bj,"getGenerateMetadata");0&&(module.exports={getGenerateMetadata});
|