express-zod-api 25.6.0 → 25.6.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Version 25
4
4
 
5
+ ### v25.6.1
6
+
7
+ - Technical update before v26: no significant changes.
8
+
5
9
  ### v25.6.0
6
10
 
7
11
  - Added `afterRouting` hook to server configuration:
package/README.md CHANGED
@@ -86,61 +86,61 @@ Therefore, many basic tasks can be accomplished faster and easier, in particular
86
86
 
87
87
  These people contributed to the improvement of the framework by reporting bugs, making changes and suggesting ideas:
88
88
 
89
- [<img src="https://github.com/squishykid.png" alt="@squishykid" width="50px" />](https://github.com/squishykid)
90
- [<img src="https://github.com/jakub-msqt.png" alt="@jakub-msqt" width="50px" />](https://github.com/jakub-msqt)
91
- [<img src="https://github.com/misha-z1nchuk.png" alt="@misha-z1nchuk" width="50px" />](https://github.com/misha-z1nchuk)
92
- [<img src="https://github.com/GreaterTamarack.png" alt="@GreaterTamarack" width="50px" />](https://github.com/GreaterTamarack)
93
- [<img src="https://github.com/pepegc.png" alt="@pepegc" width="50px" />](https://github.com/pepegc)
94
- [<img src="https://github.com/MichaelHindley.png" alt="@MichaelHindley" width="50px" />](https://github.com/MichaelHindley)
95
- [<img src="https://github.com/zoton2.png" alt="@zoton2" width="50px" />](https://github.com/zoton2)
96
- [<img src="https://github.com/ThomasKientz.png" alt="@ThomasKientz" width="50px" />](https://github.com/ThomasKientz)
97
- [<img src="https://github.com/james10424.png" alt="@james10424" width="50px" />](https://github.com/james10424)
98
- [<img src="https://github.com/HeikoOsigus.png" alt="@HeikoOsigus" width="50px" />](https://github.com/HeikoOsigus)
99
- [<img src="https://github.com/crgeary.png" alt="@crgeary" width="50px" />](https://github.com/crgeary)
100
- [<img src="https://github.com/williamgcampbell.png" alt="@williamgcampbell" width="50px" />](https://github.com/williamgcampbell)
101
- [<img src="https://github.com/gmorgen1.png" alt="@gmorgen1" width="50px" />](https://github.com/gmorgen1)
102
- [<img src="https://github.com/danmichaelo.png" alt="@danmichaelo" width="50px" />](https://github.com/danmichaelo)
103
- [<img src="https://github.com/APTy.png" alt="@APTy" width="50px" />](https://github.com/APTy)
104
- [<img src="https://github.com/LufyCZ.png" alt="@LufyCZ" width="50px" />](https://github.com/LufyCZ)
105
- [<img src="https://github.com/mlms13.png" alt="@mlms13" width="50px" />](https://github.com/mlms13)
106
- [<img src="https://github.com/bobgubko.png" alt="@bobgubko" width="50px" />](https://github.com/bobgubko)
107
- [<img src="https://github.com/LucWag.png" alt="@LucWag" width="50px" />](https://github.com/LucWag)
108
- [<img src="https://github.com/HenriJ.png" alt="@HenriJ" width="50px" />](https://github.com/HenriJ)
109
- [<img src="https://github.com/JonParton.png" alt="@JonParton" width="50px" />](https://github.com/JonParton)
110
- [<img src="https://github.com/t1nky.png" alt="@t1nky" width="50px" />](https://github.com/t1nky)
111
- [<img src="https://github.com/Tomtec331.png" alt="@Tomtec331" width="50px" />](https://github.com/Tomtec331)
112
- [<img src="https://github.com/rottmann.png" alt="@rottmann" width="50px" />](https://github.com/rottmann)
113
- [<img src="https://github.com/boarush.png" alt="@boarush" width="50px" />](https://github.com/boarush)
114
- [<img src="https://github.com/shawncarr.png" alt="@shawncarr" width="50px" />](https://github.com/shawncarr)
115
- [<img src="https://github.com/ben-xD.png" alt="@ben-xD" width="50px" />](https://github.com/ben-xD)
116
- [<img src="https://github.com/daniel-white.png" alt="@daniel-white" width="50px" />](https://github.com/daniel-white)
117
- [<img src="https://github.com/kotsmile.png" alt="@kotsmile" width="50px" />](https://github.com/kotsmile)
118
- [<img src="https://github.com/arlyon.png" alt="@arlyon" width="50px" />](https://github.com/arlyon)
119
- [<img src="https://github.com/elee1766.png" alt="@elee1766" width="50px" />](https://github.com/elee1766)
120
- [<img src="https://github.com/danclaytondev.png" alt="@danclaytondev" width="50px" />](https://github.com/danclaytondev)
121
- [<img src="https://github.com/huyhoang160593.png" alt="@huyhoang160593" width="50px" />](https://github.com/huyhoang160593)
122
- [<img src="https://github.com/sarahssharkey.png" alt="@sarahssharkey" width="50px" />](https://github.com/sarahssharkey)
123
- [<img src="https://github.com/master-chu.png" alt="@master-chu" width="50px" />](https://github.com/master-chu)
124
- [<img src="https://github.com/alindsay55661.png" alt="@alindsay55661" width="50px" />](https://github.com/alindsay55661)
125
- [<img src="https://github.com/john-schmitz.png" alt="@john-schmitz" width="50px" />](https://github.com/john-schmitz)
126
- [<img src="https://github.com/miki725.png" alt="@miki725" width="50px" />](https://github.com/miki725)
127
- [<img src="https://github.com/dev-m1-macbook.png" alt="@dev-m1-macbook" width="50px" />](https://github.com/dev-m1-macbook)
128
- [<img src="https://github.com/McMerph.png" alt="@McMerph" width="50px" />](https://github.com/McMerph)
129
- [<img src="https://github.com/niklashigi.png" alt="@niklashigi" width="50px" />](https://github.com/niklashigi)
130
- [<img src="https://github.com/maxcohn.png" alt="@maxcohn" width="50px" />](https://github.com/maxcohn)
131
- [<img src="https://github.com/VideoSystemsTech.png" alt="@VideoSystemsTech" width="50px" />](https://github.com/VideoSystemsTech)
132
- [<img src="https://github.com/TheWisestOne.png" alt="@TheWisestOne" width="50px" />](https://github.com/TheWisestOne)
133
- [<img src="https://github.com/lazylace37.png" alt="@lazylace37" width="50px" />](https://github.com/lazylace37)
134
- [<img src="https://github.com/leosuncin.png" alt="@leosuncin" width="50px" />](https://github.com/leosuncin)
135
- [<img src="https://github.com/kirdk.png" alt="@kirdk" width="50px" />](https://github.com/kirdk)
136
- [<img src="https://github.com/johngeorgewright.png" alt="@johngeorgewright" width="50px" />](https://github.com/johngeorgewright)
137
- [<img src="https://github.com/ssteuteville.png" alt="@ssteuteville" width="50px" />](https://github.com/ssteuteville)
138
- [<img src="https://github.com/foxfirecodes.png" alt="@foxfirecodes" width="50px" />](https://github.com/foxfirecodes)
139
- [<img src="https://github.com/HardCoreQual.png" alt="@HardCoreQual" width="50px" />](https://github.com/HardCoreQual)
140
- [<img src="https://github.com/hellovai.png" alt="@hellovai" width="50px" />](https://github.com/hellovai)
141
- [<img src="https://github.com/Isaac-Leonard.png" alt="@Isaac-Leonard" width="50px" />](https://github.com/Isaac-Leonard)
142
- [<img src="https://github.com/digimuza.png" alt="@digimuza" width="50px" />](https://github.com/digimuza)
143
- [<img src="https://github.com/glitch452.png" alt="@glitch452" width="50px" />](https://github.com/glitch452)
89
+ [<img src="https://github.com/squishykid.png" alt="@squishykid" width="50" />](https://github.com/squishykid)
90
+ [<img src="https://github.com/jakub-msqt.png" alt="@jakub-msqt" width="50" />](https://github.com/jakub-msqt)
91
+ [<img src="https://github.com/misha-z1nchuk.png" alt="@misha-z1nchuk" width="50" />](https://github.com/misha-z1nchuk)
92
+ [<img src="https://github.com/GreaterTamarack.png" alt="@GreaterTamarack" width="50" />](https://github.com/GreaterTamarack)
93
+ [<img src="https://github.com/pepegc.png" alt="@pepegc" width="50" />](https://github.com/pepegc)
94
+ [<img src="https://github.com/MichaelHindley.png" alt="@MichaelHindley" width="50" />](https://github.com/MichaelHindley)
95
+ [<img src="https://github.com/zoton2.png" alt="@zoton2" width="50" />](https://github.com/zoton2)
96
+ [<img src="https://github.com/ThomasKientz.png" alt="@ThomasKientz" width="50" />](https://github.com/ThomasKientz)
97
+ [<img src="https://github.com/james10424.png" alt="@james10424" width="50" />](https://github.com/james10424)
98
+ [<img src="https://github.com/HeikoOsigus.png" alt="@HeikoOsigus" width="50" />](https://github.com/HeikoOsigus)
99
+ [<img src="https://github.com/crgeary.png" alt="@crgeary" width="50" />](https://github.com/crgeary)
100
+ [<img src="https://github.com/williamgcampbell.png" alt="@williamgcampbell" width="50" />](https://github.com/williamgcampbell)
101
+ [<img src="https://github.com/gmorgen1.png" alt="@gmorgen1" width="50" />](https://github.com/gmorgen1)
102
+ [<img src="https://github.com/danmichaelo.png" alt="@danmichaelo" width="50" />](https://github.com/danmichaelo)
103
+ [<img src="https://github.com/APTy.png" alt="@APTy" width="50" />](https://github.com/APTy)
104
+ [<img src="https://github.com/LufyCZ.png" alt="@LufyCZ" width="50" />](https://github.com/LufyCZ)
105
+ [<img src="https://github.com/mlms13.png" alt="@mlms13" width="50" />](https://github.com/mlms13)
106
+ [<img src="https://github.com/bobgubko.png" alt="@bobgubko" width="50" />](https://github.com/bobgubko)
107
+ [<img src="https://github.com/LucWag.png" alt="@LucWag" width="50" />](https://github.com/LucWag)
108
+ [<img src="https://github.com/HenriJ.png" alt="@HenriJ" width="50" />](https://github.com/HenriJ)
109
+ [<img src="https://github.com/JonParton.png" alt="@JonParton" width="50" />](https://github.com/JonParton)
110
+ [<img src="https://github.com/t1nky.png" alt="@t1nky" width="50" />](https://github.com/t1nky)
111
+ [<img src="https://github.com/Tomtec331.png" alt="@Tomtec331" width="50" />](https://github.com/Tomtec331)
112
+ [<img src="https://github.com/rottmann.png" alt="@rottmann" width="50" />](https://github.com/rottmann)
113
+ [<img src="https://github.com/boarush.png" alt="@boarush" width="50" />](https://github.com/boarush)
114
+ [<img src="https://github.com/shawncarr.png" alt="@shawncarr" width="50" />](https://github.com/shawncarr)
115
+ [<img src="https://github.com/ben-xD.png" alt="@ben-xD" width="50" />](https://github.com/ben-xD)
116
+ [<img src="https://github.com/daniel-white.png" alt="@daniel-white" width="50" />](https://github.com/daniel-white)
117
+ [<img src="https://github.com/kotsmile.png" alt="@kotsmile" width="50" />](https://github.com/kotsmile)
118
+ [<img src="https://github.com/arlyon.png" alt="@arlyon" width="50" />](https://github.com/arlyon)
119
+ [<img src="https://github.com/elee1766.png" alt="@elee1766" width="50" />](https://github.com/elee1766)
120
+ [<img src="https://github.com/danclaytondev.png" alt="@danclaytondev" width="50" />](https://github.com/danclaytondev)
121
+ [<img src="https://github.com/huyhoang160593.png" alt="@huyhoang160593" width="50" />](https://github.com/huyhoang160593)
122
+ [<img src="https://github.com/sarahssharkey.png" alt="@sarahssharkey" width="50" />](https://github.com/sarahssharkey)
123
+ [<img src="https://github.com/master-chu.png" alt="@master-chu" width="50" />](https://github.com/master-chu)
124
+ [<img src="https://github.com/alindsay55661.png" alt="@alindsay55661" width="50" />](https://github.com/alindsay55661)
125
+ [<img src="https://github.com/john-schmitz.png" alt="@john-schmitz" width="50" />](https://github.com/john-schmitz)
126
+ [<img src="https://github.com/miki725.png" alt="@miki725" width="50" />](https://github.com/miki725)
127
+ [<img src="https://github.com/dev-m1-macbook.png" alt="@dev-m1-macbook" width="50" />](https://github.com/dev-m1-macbook)
128
+ [<img src="https://github.com/McMerph.png" alt="@McMerph" width="50" />](https://github.com/McMerph)
129
+ [<img src="https://github.com/niklashigi.png" alt="@niklashigi" width="50" />](https://github.com/niklashigi)
130
+ [<img src="https://github.com/maxcohn.png" alt="@maxcohn" width="50" />](https://github.com/maxcohn)
131
+ [<img src="https://github.com/VideoSystemsTech.png" alt="@VideoSystemsTech" width="50" />](https://github.com/VideoSystemsTech)
132
+ [<img src="https://github.com/TheWisestOne.png" alt="@TheWisestOne" width="50" />](https://github.com/TheWisestOne)
133
+ [<img src="https://github.com/lazylace37.png" alt="@lazylace37" width="50" />](https://github.com/lazylace37)
134
+ [<img src="https://github.com/leosuncin.png" alt="@leosuncin" width="50" />](https://github.com/leosuncin)
135
+ [<img src="https://github.com/kirdk.png" alt="@kirdk" width="50" />](https://github.com/kirdk)
136
+ [<img src="https://github.com/johngeorgewright.png" alt="@johngeorgewright" width="50" />](https://github.com/johngeorgewright)
137
+ [<img src="https://github.com/ssteuteville.png" alt="@ssteuteville" width="50" />](https://github.com/ssteuteville)
138
+ [<img src="https://github.com/foxfirecodes.png" alt="@foxfirecodes" width="50" />](https://github.com/foxfirecodes)
139
+ [<img src="https://github.com/HardCoreQual.png" alt="@HardCoreQual" width="50" />](https://github.com/HardCoreQual)
140
+ [<img src="https://github.com/hellovai.png" alt="@hellovai" width="50" />](https://github.com/hellovai)
141
+ [<img src="https://github.com/Isaac-Leonard.png" alt="@Isaac-Leonard" width="50" />](https://github.com/Isaac-Leonard)
142
+ [<img src="https://github.com/digimuza.png" alt="@digimuza" width="50" />](https://github.com/digimuza)
143
+ [<img src="https://github.com/glitch452.png" alt="@glitch452" width="50" />](https://github.com/glitch452)
144
144
 
145
145
  # How it works
146
146
 
package/dist/index.d.ts CHANGED
@@ -15,8 +15,8 @@ import compression from "compression";
15
15
  import * as express_fileupload0 from "express-fileupload";
16
16
  import fileUpload from "express-fileupload";
17
17
  import { ListenOptions } from "node:net";
18
- import * as express_serve_static_core2 from "express-serve-static-core";
19
- import * as qs2 from "qs";
18
+ import * as express_serve_static_core0 from "express-serve-static-core";
19
+ import * as qs0 from "qs";
20
20
  import * as zod_v4_core0 from "zod/v4/core";
21
21
 
22
22
  //#region src/method.d.ts
@@ -701,11 +701,11 @@ declare const arrayEndpointsFactory: EndpointsFactory<undefined, Record<string,
701
701
  //#endregion
702
702
  //#region src/server.d.ts
703
703
  declare const attachRouting: (config: AppConfig, routing: Routing) => {
704
- notFoundHandler: express.RequestHandler<express_serve_static_core2.ParamsDictionary, any, any, qs2.ParsedQs, Record<string, any>>;
704
+ notFoundHandler: express.RequestHandler<express_serve_static_core0.ParamsDictionary, any, any, qs0.ParsedQs, Record<string, any>>;
705
705
  logger: AbstractLogger | BuiltinLogger;
706
706
  };
707
707
  declare const createServer: (config: ServerConfig, routing: Routing) => Promise<{
708
- app: express_serve_static_core2.Express;
708
+ app: express_serve_static_core0.Express;
709
709
  logger: AbstractLogger | BuiltinLogger;
710
710
  servers: (http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | https.Server<typeof http.IncomingMessage, typeof http.ServerResponse>)[];
711
711
  }>;
@@ -870,10 +870,10 @@ declare const testEndpoint: <LOG extends FlatObject, REQ extends RequestOptions>
870
870
  /** @desc The endpoint to test */
871
871
  endpoint: AbstractEndpoint;
872
872
  }) => Promise<{
873
- requestMock: node_mocks_http0.MockRequest<Request<express_serve_static_core2.ParamsDictionary, any, any, qs2.ParsedQs, Record<string, any>> & REQ>;
873
+ requestMock: node_mocks_http0.MockRequest<Request<express_serve_static_core0.ParamsDictionary, any, any, qs0.ParsedQs, Record<string, any>> & REQ>;
874
874
  responseMock: node_mocks_http0.MockResponse<Response<any, Record<string, any>>>;
875
875
  loggerMock: AbstractLogger & LOG & {
876
- _getLogs: () => Record<"error" | "debug" | "info" | "warn", unknown[]>;
876
+ _getLogs: () => Record<"debug" | "info" | "warn" | "error", unknown[]>;
877
877
  };
878
878
  }>;
879
879
  declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOptions>({
@@ -886,10 +886,10 @@ declare const testMiddleware: <LOG extends FlatObject, REQ extends RequestOption
886
886
  /** @desc The aggregated output from previously executed middlewares */
887
887
  options?: FlatObject;
888
888
  }) => Promise<{
889
- requestMock: node_mocks_http0.MockRequest<Request<express_serve_static_core2.ParamsDictionary, any, any, qs2.ParsedQs, Record<string, any>> & REQ>;
889
+ requestMock: node_mocks_http0.MockRequest<Request<express_serve_static_core0.ParamsDictionary, any, any, qs0.ParsedQs, Record<string, any>> & REQ>;
890
890
  responseMock: node_mocks_http0.MockResponse<Response<any, Record<string, any>>>;
891
891
  loggerMock: AbstractLogger & LOG & {
892
- _getLogs: () => Record<"error" | "debug" | "info" | "warn", unknown[]>;
892
+ _getLogs: () => Record<"debug" | "info" | "warn" | "error", unknown[]>;
893
893
  };
894
894
  output: FlatObject;
895
895
  }>;
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ ${i}888${n}
14
14
  ${r}
15
15
  `;e.write(c.split(`
16
16
  `).map((e,t)=>s[t]?s[t](e):e).join(`
17
- `))},cn=e=>{e.startupLogo!==!1&&sn(process.stdout);let t=e.errorHandler||F,n=ht(e.logger)?e.logger:new yt(e.logger);n.debug(`Running`,{build:`v25.6.0`,env:process.env.NODE_ENV||`development`}),an(n);let r=nn({logger:n,config:e}),i={getLogger:rn(n),errorHandler:t},a=Zt(i),o=Xt(i);return{...i,logger:n,notFoundHandler:a,catcher:o,loggingMiddleware:r}},ln=(e,t)=>{let{logger:n,getLogger:r,notFoundHandler:i,loggingMiddleware:a}=cn(e);return Ht({app:e.app.use(a),routing:t,getLogger:r,config:e}),{notFoundHandler:i,logger:n}},un=async(e,t)=>{let{logger:n,getLogger:r,notFoundHandler:i,catcher:a,loggingMiddleware:o}=cn(e),s=g().disable(`x-powered-by`).set(`query parser`,e.queryParser??`simple`).use(o);if(e.compression){let t=await St(`compression`);s.use(t(typeof e.compression==`object`?e.compression:void 0))}await e.beforeRouting?.({app:s,getLogger:r}),Ht({app:s,routing:t,getLogger:r,config:e,parsers:{json:[e.jsonParser||g.json()],raw:[e.rawParser||g.raw(),tn],form:[e.formParser||g.urlencoded()],upload:e.upload?await en({config:e,getLogger:r}):[]}}),await e.afterRouting?.({app:s,getLogger:r}),s.use(a,i);let c=[],l=(e,t)=>()=>e.listen(t,()=>n.info(`Listening`,t)),u=[];if(e.http){let t=te.createServer(s);c.push(t),u.push(l(t,e.http.listen))}if(e.https){let t=ne.createServer(e.https.options,s);c.push(t),u.push(l(t,e.https.listen))}return c.length||n.warn(`No servers configured.`),e.gracefulShutdown&&on({logger:n,servers:c,options:e.gracefulShutdown===!0?{}:e.gracefulShutdown}),{app:s,logger:n,servers:u.map(e=>e())}},dn=e=>T(e)&&`or`in e,fn=e=>T(e)&&`and`in e,pn=e=>!fn(e)&&!dn(e),mn=e=>{let n=t.filter(pn,e),r=t.chain(t.prop(`and`),t.filter(fn,e)),[i,a]=t.partition(pn,r),o=t.concat(n,i),s=t.filter(dn,e);return t.map(t.prop(`or`),t.concat(s,a)).reduce((e,n)=>be(e,t.map(e=>pn(e)?[e]:e.and,n),([e,n])=>t.concat(e,n)),t.reject(t.isEmpty,[o]))};var hn=`a-im.accept.accept-additions.accept-ch.accept-charset.accept-datetime.accept-encoding.accept-features.accept-language.accept-signature.access-control.access-control-request-headers.access-control-request-method.alpn.alt-used.alternates.amp-cache-transform.apply-to-redirect-ref.authentication-control.authentication-info.authorization.available-dictionary.c-ext.c-man.c-opt.c-pep.c-pep-info.cache-control.cal-managed-id.caldav-timezones.capsule-protocol.cert-not-after.cert-not-before.client-cert.client-cert-chain.close.cmcd-object.cmcd-request.cmcd-session.cmcd-status.cmsd-dynamic.cmsd-static.concealed-auth-export.configuration-context.connection.content-digest.content-disposition.content-encoding.content-id.content-language.content-length.content-location.content-md5.content-range.content-script-type.content-type.cookie.cookie2.cross-origin-embedder-policy.cross-origin-embedder-policy-report-only.cross-origin-opener-policy.cross-origin-opener-policy-report-only.cross-origin-resource-policy.cta-common-access-token.dasl.date.dav.default-style.delta-base.deprecation.depth.derived-from.destination.detached-jws.differential-id.dictionary-id.digest.dpop.dpop-nonce.early-data.ediint-features.expect.expect-ct.ext.forwarded.from.getprofile.hobareg.host.http2-settings.if.if-match.if-modified-since.if-none-match.if-range.if-schedule-tag-match.if-unmodified-since.im.include-referred-token-binding-id.isolation.keep-alive.label.last-event-id.link.link-template.lock-token.man.max-forwards.memento-datetime.meter.method-check.method-check-expires.mime-version.negotiate.nel.odata-entityid.odata-isolation.odata-maxversion.odata-version.opt.ordering-type.origin.origin-agent-cluster.oscore.oslc-core-version.overwrite.p3p.pep.pep-info.permissions-policy.pics-label.ping-from.ping-to.position.pragma.prefer.preference-applied.priority.profileobject.protocol.protocol-info.protocol-query.protocol-request.proxy-authorization.proxy-features.proxy-instruction.public.public-key-pins.public-key-pins-report-only.range.redirect-ref.referer.referer-root.referrer-policy.repeatability-client-id.repeatability-first-sent.repeatability-request-id.repeatability-result.replay-nonce.reporting-endpoints.repr-digest.safe.schedule-reply.schedule-tag.sec-fetch-storage-access.sec-gpc.sec-purpose.sec-token-binding.sec-websocket-extensions.sec-websocket-key.sec-websocket-protocol.sec-websocket-version.security-scheme.setprofile.signature.signature-input.slug.soapaction.status-uri.sunset.surrogate-capability.tcn.te.timeout.topic.traceparent.tracestate.trailer.transfer-encoding.ttl.upgrade.urgency.uri.use-as-dictionary.user-agent.variant-vary.via.want-content-digest.want-digest.want-repr-digest.warning.x-content-type-options.x-frame-options`.split(`.`);const gn=`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString`,_n={integer:0,number:0,string:``,boolean:!1,object:{},null:null,array:[]},vn=e=>e.replace(fe,e=>`{${e.slice(1)}}`),yn=({},e)=>{if(e.isResponse)throw new E(`Please use ez.upload() only for input.`,e);return{type:`string`,format:`binary`}},bn=({jsonSchema:e})=>({...e,externalDocs:{description:`raw binary data`,url:`https://swagger.io/specification/#working-with-binary-data`}}),xn=({zodSchema:e,jsonSchema:t})=>{if(!C(e,`union`)||!(`discriminator`in e._zod.def))return t;let n=e._zod.def.discriminator;return{...t,discriminator:t.discriminator??{propertyName:n}}},Sn=t.tryCatch(({jsonSchema:e})=>{if(!e.allOf)throw`no allOf`;return Dt(e,`throw`)},(e,{jsonSchema:t})=>t),Cn=({jsonSchema:e})=>{if(!e.anyOf)return e;let t=e.anyOf[0];return Object.assign(t,{type:kn(t.type)})},L=e=>e,wn=({jsonSchema:{examples:e,description:t}},n)=>{if(n.isResponse)throw new E(`Please use ez.dateOut() for output.`,n);let r={description:t||`YYYY-MM-DDTHH:mm:ss.sssZ`,type:`string`,format:`date-time`,pattern:`^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?)?Z?$`,externalDocs:{url:gn}};return e?.length&&(r.examples=e),r},Tn=({jsonSchema:{examples:e,description:t}},n)=>{if(!n.isResponse)throw new E(`Please use ez.dateIn() for input.`,n);let r={description:t||`YYYY-MM-DDTHH:mm:ss.sssZ`,type:`string`,format:`date-time`,externalDocs:{url:gn}};return e?.length&&(r.examples=e),r},En=()=>({type:`string`,format:`bigint`,pattern:`^-?\\d+$`}),Dn=({zodSchema:e,jsonSchema:t})=>e._zod.def.rest===null?{...t,items:{not:{}}}:t,On=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return _n?.[t]},kn=e=>e===`null`?e:typeof e==`string`?[e,`null`]:e&&[...new Set(e).add(`null`)],An=({zodSchema:e,jsonSchema:t},n)=>{let r=e._zod.def[n.isResponse?`out`:`in`],i=e._zod.def[n.isResponse?`in`:`out`];if(!C(r,`transform`))return t;let a=L(Ln(i,{ctx:n}));if(_(a))if(n.isResponse){let e=Se(r,On(a));if(e&&[`number`,`string`,`boolean`].includes(e))return{...t,type:e}}else{let{type:e,...t}=a;return{...t,format:`${t.format||e} (preprocessed)`}}return t},jn=({jsonSchema:e})=>{if(e.type!==`object`)return e;let t=e;return!t.properties||!(`raw`in t.properties)||!T(t.properties.raw)?e:t.properties.raw},Mn=e=>e.length?t.fromPairs(t.zip(t.times(e=>`example${e+1}`,e.length),t.map(t.objOf(`value`),e))):void 0,Nn=(e,t)=>t?.includes(e)||e.startsWith(`x-`)||hn.includes(e),Pn=({path:e,method:n,request:r,inputSources:i,makeRef:a,composition:o,isHeader:s,security:c,description:l=`${n.toUpperCase()} ${e} Parameter`})=>{let u=Dt(r),d=pe(e),f=i.includes(`query`),p=i.includes(`params`),m=i.includes(`headers`),ee=e=>p&&d.includes(e),h=t.chain(t.filter(e=>e.type===`header`),c??[]).map(({name:e})=>e),g=t=>m&&(s?.(t,n,e)??Nn(t,h));return Object.entries(u.properties).reduce((e,[n,r])=>{if(!T(r))return e;let i=ee(n)?`path`:g(n)?`header`:f?`query`:void 0;if(!i)return e;let s=L(r),c=o===`components`?a(r.id||JSON.stringify(r),s,w(l,n)):s;return e.concat({name:n,in:i,deprecated:r.deprecated,required:u.required?.includes(n)||!1,description:s.description||l,schema:c,examples:Mn(_(s)&&s.examples?.length?s.examples:t.pluck(n,u.examples?.filter(t.both(T,t.has(n)))||[]))})},[])},Fn={nullable:Cn,union:xn,bigint:En,intersection:Sn,tuple:Dn,pipe:An,[De]:wn,[ke]:Tn,[O]:yn,[k]:jn,[Te]:bn},In=(e,n,r)=>{let i=[e,n];for(;i.length;){let e=i.shift();if(t.is(Object,e)){if(ae(e)&&!e.$ref.startsWith(`#/components`)){let t=n[e.$ref.split(`/`).pop()];t&&(e.$ref=r.makeRef(t.id||t,L(t)).$ref);continue}i.push(...t.values(e))}t.is(Array,e)&&i.push(...t.values(e))}return e},Ln=(t,{ctx:n,rules:i=Fn})=>{let{$defs:a={},properties:o={}}=r.toJSONSchema(r.object({subject:t}),{unrepresentable:`any`,io:n.isResponse?`output`:`input`,override:t=>{let r=e(t.zodSchema),a=i[r&&r in i?r:t.zodSchema._zod.def.type];if(a){let e={...a(t,n)};for(let e in t.jsonSchema)delete t.jsonSchema[e];Object.assign(t.jsonSchema,e)}}});return In(T(o.subject)?o.subject:{},a,n)},Rn=(e,n)=>{if(ae(e))return[e,!1];let r=!1,i=t.map(e=>{let[t,i]=Rn(e,n);return r||=i,t}),a=t.omit(n),o={properties:a,examples:t.map(a),required:t.without(n),allOf:i,oneOf:i,anyOf:i},s=t.evolve(o,e);return[s,r||!!s.required?.length]},zn=({method:e,path:n,schema:r,mimeTypes:i,variant:a,makeRef:o,composition:s,hasMultipleStatusCodes:c,statusCode:l,brandHandling:u,description:d=`${e.toUpperCase()} ${n} ${xe(a)} response ${c?l:``}`.trim()})=>{if(!we(e,i))return{description:d};let f=L(Ln(r,{rules:{...u,...Fn},ctx:{isResponse:!0,makeRef:o,path:n,method:e}})),p=[];_(f)&&f.examples&&(p.push(...f.examples),delete f.examples);let m={schema:s===`components`?o(r,f,w(d)):f,examples:Mn(p)};return{description:d,content:t.fromPairs(t.xprod(i,[m]))}},Bn=({format:e})=>{let t={type:`http`,scheme:`bearer`};return e&&(t.bearerFormat=e),t},Vn=({name:e},t)=>{let n={type:`apiKey`,in:`query`,name:e};return t?.includes(`body`)&&(t?.includes(`query`)?(n[`x-in-alternative`]=`body`,n.description=`${e} CAN also be supplied within the request body`):(n[`x-in-actual`]=`body`,n.description=`${e} MUST be supplied within the request body instead of query`)),n},Hn=({name:e})=>({type:`apiKey`,in:`header`,name:e}),Un=({name:e})=>({type:`apiKey`,in:`cookie`,name:e}),Wn=({url:e})=>({type:`openIdConnect`,openIdConnectUrl:e}),Gn=({flows:e={}})=>({type:`oauth2`,flows:t.map(e=>({...e,scopes:e.scopes||{}}),t.reject(t.isNil,e))}),Kn=(e,t=[])=>{let n=e=>e.type===`basic`?{type:`http`,scheme:`basic`}:e.type===`bearer`?Bn(e):e.type===`input`?Vn(e,t):e.type===`header`?Hn(e):e.type===`cookie`?Un(e):e.type===`openid`?Wn(e):Gn(e);return e.map(e=>e.map(n))},qn=(e,t,n)=>e.map(e=>e.reduce((e,r)=>{let i=n(r),a=[`oauth2`,`openIdConnect`].includes(r.type);return Object.assign(e,{[i]:a?t:[]})},{})),Jn=({schema:e,brandHandling:t,makeRef:n,path:r,method:i})=>Ln(e,{rules:{...t,...Fn},ctx:{isResponse:!1,makeRef:n,path:r,method:i}}),Yn=({method:e,path:n,schema:r,request:i,mimeType:a,makeRef:o,composition:s,paramNames:c,description:l=`${e.toUpperCase()} ${n} Request body`})=>{let[u,d]=Rn(L(i),c),f=[];_(u)&&u.examples&&(f.push(...u.examples),delete u.examples);let p={schema:s===`components`?o(r,u,w(l)):u,examples:Mn(f.length?f:Dt(i).examples?.filter(e=>T(e)&&!Array.isArray(e)).map(t.omit(c))||[])},m={description:l,content:{[a]:p}};return(d||a===y.raw)&&(m.required=!0),m},Xn=e=>Object.entries(e).reduce((e,[t,n])=>{if(!n)return e;let r={name:t,description:typeof n==`string`?n:n.description};return typeof n==`object`&&n.url&&(r.externalDocs={url:n.url}),e.concat(r)},[]),Zn=e=>e.length<=50?e:e.slice(0,49)+`…`,Qn=e=>e.length?e.slice():void 0;var $n=class extends ie{#e=new Map;#t=new Map;#n=new Map;#r(e,t,n=this.#n.get(e)){return n||(n=`Schema${this.#n.size+1}`,this.#n.set(e,n)),this.addSchema(n,t),{$ref:`#/components/schemas/${n}`}}#i(e,t,n){let r=n||w(t,e),i=this.#t.get(r);if(i===void 0)return this.#t.set(r,1),r;if(n)throw new E(`Duplicated operationId: "${n}"`,{method:t,isResponse:!1,path:e});return i++,this.#t.set(r,i),`${r}${i}`}#a(e){let t=JSON.stringify(e);for(let e in this.rootDoc.components?.securitySchemes||{})if(t===JSON.stringify(this.rootDoc.components?.securitySchemes?.[e]))return e;let n=(this.#e.get(e.type)||0)+1;return this.#e.set(e.type,n),`${e.type.toUpperCase()}_${n}`}constructor({routing:e,config:n,title:r,version:i,serverUrl:a,descriptions:o,brandHandling:s,tags:c,isHeader:l,hasSummaryFromDescription:u=!0,hasHeadMethod:d=!0,composition:f=`inline`}){super(),this.addInfo({title:r,version:i});for(let e of typeof a==`string`?[a]:a)this.addServer({url:e});let p=(e,r,i)=>{let a={path:r,method:e,endpoint:i,composition:f,brandHandling:s,makeRef:this.#r.bind(this)},{description:c,shortDescription:d,scopes:p,inputSchema:m}=i,ee=d?Zn(d):u&&c?Zn(c):void 0,h=ve(e,n.inputSources),g=this.#i(r,e,i.getOperationId(e)),te=Jn({...a,schema:m}),ne=mn(i.security),re=Pn({...a,inputSources:h,isHeader:l,security:ne,request:te,description:o?.requestParameter?.call(null,{method:e,path:r,operationId:g})}),ie={};for(let t of at){let n=i.getResponses(t);for(let{mimeTypes:i,schema:s,statusCodes:c}of n)for(let l of c)ie[l]=zn({...a,variant:t,schema:s,mimeTypes:i,statusCode:l,hasMultipleStatusCodes:n.length>1||c.length>1,description:o?.[`${t}Response`]?.call(null,{method:e,path:r,operationId:g,statusCode:l})})}let ae=h.includes(`body`)?Yn({...a,request:te,paramNames:t.pluck(`name`,re),schema:m,mimeType:y[i.requestType],description:o?.requestBody?.call(null,{method:e,path:r,operationId:g})}):void 0,_=qn(Kn(ne,h),p,e=>{let t=this.#a(e);return this.addSecurityScheme(t,e),t}),oe={operationId:g,summary:ee,description:c,deprecated:i.isDeprecated||void 0,tags:Qn(i.tags),parameters:Qn(re),requestBody:ae,security:Qn(_),responses:ie};this.addPath(vn(r),{[e]:oe})};Lt({routing:e,onEndpoint:d?At(p):p}),c&&(this.rootDoc.tags=Xn(c))}};const er=e=>oe({...e,headers:{"content-type":y.json,...e?.headers}}),tr=e=>se(e),nr=e=>{let t={warn:[],error:[],info:[],debug:[]};return new Proxy(e||{},{get(e,n,r){return n===`_getLogs`?()=>t:gt(n)?(...e)=>t[n].push(e):Reflect.get(e,n,r)}})},rr=({requestProps:e,responseOptions:t,configProps:n,loggerProps:r})=>{let i=er(e),a=tr({req:i,...t});a.req=t?.req||i,i.res=a;let o=nr(r);return{requestMock:i,responseMock:a,loggerMock:o,configMock:{cors:!1,logger:o,...n}}},ir=async({endpoint:e,...t})=>{let{requestMock:n,responseMock:r,loggerMock:i,configMock:a}=rr(t);return await e.execute({request:n,response:r,config:a,logger:i}),{requestMock:n,responseMock:r,loggerMock:i}},ar=async({middleware:e,options:t={},...n})=>{let{requestMock:r,responseMock:i,loggerMock:a,configMock:{inputSources:o,errorHandler:s=F}}=rr(n),c={request:r,response:i,logger:a,input:ye(r,o),options:t};try{return{requestMock:r,responseMock:i,loggerMock:a,output:await e.execute(c)}}catch(e){return await s.execute({...c,error:x(e),output:null}),{requestMock:r,responseMock:i,loggerMock:a,output:{}}}},R=v.factory,or=[R.createModifier(v.SyntaxKind.ExportKeyword)],sr=[R.createModifier(v.SyntaxKind.AsyncKeyword)],cr={public:[R.createModifier(v.SyntaxKind.PublicKeyword)],protectedReadonly:[R.createModifier(v.SyntaxKind.ProtectedKeyword),R.createModifier(v.SyntaxKind.ReadonlyKeyword)]},lr=(e,t)=>v.addSyntheticLeadingComment(e,v.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0),ur=(e,t)=>{let n=v.createSourceFile(`print.ts`,``,v.ScriptTarget.Latest,!1,v.ScriptKind.TS);return v.createPrinter(t).printNode(v.EmitHint.Unspecified,e,n)},dr=/^[A-Za-z_$][A-Za-z0-9_$]*$/,fr=e=>typeof e==`string`&&dr.test(e)?R.createIdentifier(e):Y(e),pr=(e,...t)=>R.createTemplateExpression(R.createTemplateHead(e),t.map(([e,n=``],r)=>R.createTemplateSpan(e,r===t.length-1?R.createTemplateTail(n):R.createTemplateMiddle(n)))),mr=(e,{type:t,mod:n,init:r,optional:i}={})=>R.createParameterDeclaration(n,void 0,e,i?R.createToken(v.SyntaxKind.QuestionToken):void 0,t?B(t):void 0,r),z=e=>Object.entries(e).map(([e,t])=>mr(e,typeof t==`string`||typeof t==`number`||typeof t==`object`&&`kind`in t?{type:t}:t)),hr=(e,t=[])=>R.createConstructorDeclaration(cr.public,e,R.createBlock(t)),B=(e,n)=>typeof e==`number`?R.createKeywordTypeNode(e):typeof e==`string`||v.isIdentifier(e)?R.createTypeReferenceNode(e,n&&t.map(B,n)):e,gr=B(`Record`,[v.SyntaxKind.StringKeyword,v.SyntaxKind.AnyKeyword]),V=e=>{let t=new Map;for(let n of e)t.set(Pr(n)?n.kind:n,n);return R.createUnionTypeNode(Array.from(t.values()))},_r=(e,n,{isOptional:r,isDeprecated:i,comment:a}={})=>{let o=B(n),s=R.createPropertySignature(void 0,fr(e),r?R.createToken(v.SyntaxKind.QuestionToken):void 0,r?V([o,B(v.SyntaxKind.UndefinedKeyword)]):o),c=t.reject(t.isNil,[i?`@deprecated`:void 0,a]);return c.length?lr(s,c.join(` `)):s},vr=e=>v.setEmitFlags(e,v.EmitFlags.SingleLine),yr=(...e)=>R.createArrayBindingPattern(e.map(e=>R.createBindingElement(void 0,void 0,e))),H=(e,t,{type:n,expose:r}={})=>R.createVariableStatement(r&&or,R.createVariableDeclarationList([R.createVariableDeclaration(e,void 0,n?B(n):void 0,t)],v.NodeFlags.Const)),br=(e,n)=>U(e,V(t.map(X,n)),{expose:!0}),U=(e,t,{expose:n,comment:r,params:i}={})=>{let a=R.createTypeAliasDeclaration(n?or:void 0,e,i&&Dr(i),t);return r?lr(a,r):a},xr=(e,t)=>R.createPropertyDeclaration(cr.public,e,void 0,B(t),void 0),Sr=(e,t,n,{typeParams:r,returns:i}={})=>R.createMethodDeclaration(cr.public,void 0,e,void 0,r&&Dr(r),t,i,R.createBlock(n)),Cr=(e,t,{typeParams:n}={})=>R.createClassDeclaration(or,e,n&&Dr(n),void 0,t),wr=e=>R.createTypeOperatorNode(v.SyntaxKind.KeyOfKeyword,B(e)),Tr=e=>B(Promise.name,[e]),Er=(e,t,{expose:n,comment:r}={})=>{let i=R.createInterfaceDeclaration(n?or:void 0,e,void 0,void 0,t);return r?lr(i,r):i},Dr=e=>(Array.isArray(e)?e.map(e=>t.pair(e,void 0)):Object.entries(e)).map(([e,t])=>{let{type:n,init:r}=typeof t==`object`&&`init`in t?t:{type:t};return R.createTypeParameterDeclaration([],e,n?B(n):void 0,r?B(r):void 0)}),W=(e,n,{isAsync:r}={})=>R.createArrowFunction(r?sr:void 0,void 0,Array.isArray(e)?t.map(mr,e):z(e),void 0,void 0,n),G=e=>e,Or=(e,t,n)=>R.createConditionalExpression(e,R.createToken(v.SyntaxKind.QuestionToken),t,R.createToken(v.SyntaxKind.ColonToken),n),K=(e,...t)=>(...n)=>R.createCallExpression(t.reduce((e,t)=>typeof t==`string`||v.isIdentifier(t)?R.createPropertyAccessExpression(e,t):R.createElementAccessExpression(e,t),typeof e==`string`?R.createIdentifier(e):e),void 0,n),q=(e,...t)=>R.createNewExpression(R.createIdentifier(e),void 0,t),kr=(e,t)=>B(`Extract`,[e,t]),Ar=(e,t)=>R.createExpressionStatement(R.createBinaryExpression(e,R.createToken(v.SyntaxKind.EqualsToken),t)),J=(e,t)=>R.createIndexedAccessTypeNode(B(e),B(t)),jr=e=>V([B(e),Tr(e)]),Mr=(e,t)=>R.createFunctionTypeNode(void 0,z(e),B(t)),Y=e=>typeof e==`number`?R.createNumericLiteral(e):typeof e==`bigint`?R.createBigIntLiteral(e.toString()):typeof e==`boolean`?e?R.createTrue():R.createFalse():e===null?R.createNull():R.createStringLiteral(e),X=e=>R.createLiteralTypeNode(Y(e)),Nr=[v.SyntaxKind.AnyKeyword,v.SyntaxKind.BigIntKeyword,v.SyntaxKind.BooleanKeyword,v.SyntaxKind.NeverKeyword,v.SyntaxKind.NumberKeyword,v.SyntaxKind.ObjectKeyword,v.SyntaxKind.StringKeyword,v.SyntaxKind.SymbolKeyword,v.SyntaxKind.UndefinedKeyword,v.SyntaxKind.UnknownKeyword,v.SyntaxKind.VoidKeyword],Pr=e=>Nr.includes(e.kind);var Fr=class{paths=new Set;tags=new Map;registry=new Map;#e={pathType:R.createIdentifier(`Path`),implementationType:R.createIdentifier(`Implementation`),keyParameter:R.createIdentifier(`key`),pathParameter:R.createIdentifier(`path`),paramsArgument:R.createIdentifier(`params`),ctxArgument:R.createIdentifier(`ctx`),methodParameter:R.createIdentifier(`method`),requestParameter:R.createIdentifier(`request`),eventParameter:R.createIdentifier(`event`),dataParameter:R.createIdentifier(`data`),handlerParameter:R.createIdentifier(`handler`),msgParameter:R.createIdentifier(`msg`),parseRequestFn:R.createIdentifier(`parseRequest`),substituteFn:R.createIdentifier(`substitute`),provideMethod:R.createIdentifier(`provide`),onMethod:R.createIdentifier(`on`),implementationArgument:R.createIdentifier(`implementation`),hasBodyConst:R.createIdentifier(`hasBody`),undefinedValue:R.createIdentifier(`undefined`),responseConst:R.createIdentifier(`response`),restConst:R.createIdentifier(`rest`),searchParamsConst:R.createIdentifier(`searchParams`),defaultImplementationConst:R.createIdentifier(`defaultImplementation`),clientConst:R.createIdentifier(`client`),contentTypeConst:R.createIdentifier(`contentType`),isJsonConst:R.createIdentifier(`isJSON`),sourceProp:R.createIdentifier(`source`)};interfaces={input:R.createIdentifier(`Input`),positive:R.createIdentifier(`PositiveResponse`),negative:R.createIdentifier(`NegativeResponse`),encoded:R.createIdentifier(`EncodedResponse`),response:R.createIdentifier(`Response`)};methodType=br(`Method`,ue);someOfType=U(`SomeOf`,J(`T`,wr(`T`)),{params:[`T`]});requestType=U(`Request`,wr(this.interfaces.input),{expose:!0});constructor(e){this.serverUrl=e}someOf=({name:e})=>B(this.someOfType.name,[e]);makePathType=()=>br(this.#e.pathType,Array.from(this.paths));makePublicInterfaces=()=>Object.keys(this.interfaces).map(e=>Er(this.interfaces[e],Array.from(this.registry).map(([t,{store:n,isDeprecated:r}])=>_r(t,n[e],{isDeprecated:r})),{expose:!0}));makeEndpointTags=()=>H(`endpointTags`,R.createObjectLiteralExpression(Array.from(this.tags).map(([e,n])=>R.createPropertyAssignment(fr(e),R.createArrayLiteralExpression(t.map(Y,n))))),{expose:!0});makeImplementationType=()=>U(this.#e.implementationType,Mr({[this.#e.methodParameter.text]:this.methodType.name,[this.#e.pathParameter.text]:v.SyntaxKind.StringKeyword,[this.#e.paramsArgument.text]:gr,[this.#e.ctxArgument.text]:{optional:!0,type:`T`}},Tr(v.SyntaxKind.AnyKeyword)),{expose:!0,params:{T:{init:v.SyntaxKind.UnknownKeyword}}});makeParseRequestFn=()=>H(this.#e.parseRequestFn,W({[this.#e.requestParameter.text]:v.SyntaxKind.StringKeyword},R.createAsExpression(K(this.#e.requestParameter,G(`split`))(R.createRegularExpressionLiteral(`/ (.+)/`),Y(2)),R.createTupleTypeNode([B(this.methodType.name),B(this.#e.pathType)]))));makeSubstituteFn=()=>H(this.#e.substituteFn,W({[this.#e.pathParameter.text]:v.SyntaxKind.StringKeyword,[this.#e.paramsArgument.text]:gr},R.createBlock([H(this.#e.restConst,R.createObjectLiteralExpression([R.createSpreadAssignment(this.#e.paramsArgument)])),R.createForInStatement(R.createVariableDeclarationList([R.createVariableDeclaration(this.#e.keyParameter)],v.NodeFlags.Const),this.#e.paramsArgument,R.createBlock([Ar(this.#e.pathParameter,K(this.#e.pathParameter,G(`replace`))(pr(`:`,[this.#e.keyParameter]),W([],R.createBlock([R.createExpressionStatement(R.createDeleteExpression(R.createElementAccessExpression(this.#e.restConst,this.#e.keyParameter))),R.createReturnStatement(R.createElementAccessExpression(this.#e.paramsArgument,this.#e.keyParameter))]))))])),R.createReturnStatement(R.createAsExpression(R.createArrayLiteralExpression([this.#e.pathParameter,this.#e.restConst]),B(`const`)))])));#t=()=>Sr(this.#e.provideMethod,z({[this.#e.requestParameter.text]:`K`,[this.#e.paramsArgument.text]:J(this.interfaces.input,`K`),[this.#e.ctxArgument.text]:{optional:!0,type:`T`}}),[H(yr(this.#e.methodParameter,this.#e.pathParameter),K(this.#e.parseRequestFn)(this.#e.requestParameter)),R.createReturnStatement(K(R.createThis(),this.#e.implementationArgument)(this.#e.methodParameter,R.createSpreadElement(K(this.#e.substituteFn)(this.#e.pathParameter,this.#e.paramsArgument)),this.#e.ctxArgument))],{typeParams:{K:this.requestType.name},returns:Tr(J(this.interfaces.response,`K`))});makeClientClass=e=>Cr(e,[hr([mr(this.#e.implementationArgument,{type:B(this.#e.implementationType,[`T`]),mod:cr.protectedReadonly,init:this.#e.defaultImplementationConst})]),this.#t()],{typeParams:[`T`]});#n=e=>pr(`?`,[q(URLSearchParams.name,e)]);#r=()=>q(URL.name,pr(``,[this.#e.pathParameter],[this.#e.searchParamsConst]),Y(this.serverUrl));makeDefaultImplementation=()=>{let e=R.createPropertyAssignment(G(`method`),K(this.#e.methodParameter,G(`toUpperCase`))()),t=R.createPropertyAssignment(G(`headers`),Or(this.#e.hasBodyConst,R.createObjectLiteralExpression([R.createPropertyAssignment(Y(`Content-Type`),Y(y.json))]),this.#e.undefinedValue)),n=R.createPropertyAssignment(G(`body`),Or(this.#e.hasBodyConst,K(JSON[Symbol.toStringTag],G(`stringify`))(this.#e.paramsArgument),this.#e.undefinedValue)),r=H(this.#e.responseConst,R.createAwaitExpression(K(fetch.name)(this.#r(),R.createObjectLiteralExpression([e,t,n])))),i=H(this.#e.hasBodyConst,R.createLogicalNot(K(R.createArrayLiteralExpression([Y(`get`),Y(`head`),Y(`delete`)]),G(`includes`))(this.#e.methodParameter))),a=H(this.#e.searchParamsConst,Or(this.#e.hasBodyConst,Y(``),this.#n(this.#e.paramsArgument))),o=H(this.#e.contentTypeConst,K(this.#e.responseConst,G(`headers`),G(`get`))(Y(`content-type`))),s=R.createIfStatement(R.createPrefixUnaryExpression(v.SyntaxKind.ExclamationToken,this.#e.contentTypeConst),R.createReturnStatement()),c=H(this.#e.isJsonConst,K(this.#e.contentTypeConst,G(`startsWith`))(Y(y.json))),l=R.createReturnStatement(K(this.#e.responseConst,Or(this.#e.isJsonConst,Y(G(`json`)),Y(G(`text`))))());return H(this.#e.defaultImplementationConst,W([this.#e.methodParameter,this.#e.pathParameter,this.#e.paramsArgument],R.createBlock([i,a,r,o,s,c,l]),{isAsync:!0}),{type:this.#e.implementationType})};#i=()=>hr(z({request:`K`,params:J(this.interfaces.input,`K`)}),[H(yr(this.#e.pathParameter,this.#e.restConst),K(this.#e.substituteFn)(R.createElementAccessExpression(K(this.#e.parseRequestFn)(this.#e.requestParameter),Y(1)),this.#e.paramsArgument)),H(this.#e.searchParamsConst,this.#n(this.#e.restConst)),Ar(R.createPropertyAccessExpression(R.createThis(),this.#e.sourceProp),q(`EventSource`,this.#r()))]);#a=e=>R.createTypeLiteralNode([_r(G(`event`),e)]);#o=()=>Sr(this.#e.onMethod,z({[this.#e.eventParameter.text]:`E`,[this.#e.handlerParameter.text]:Mr({[this.#e.dataParameter.text]:J(kr(`R`,vr(this.#a(`E`))),X(G(`data`)))},jr(v.SyntaxKind.VoidKeyword))}),[R.createExpressionStatement(K(R.createThis(),this.#e.sourceProp,G(`addEventListener`))(this.#e.eventParameter,W([this.#e.msgParameter],K(this.#e.handlerParameter)(K(JSON[Symbol.toStringTag],G(`parse`))(R.createPropertyAccessExpression(R.createParenthesizedExpression(R.createAsExpression(this.#e.msgParameter,B(MessageEvent.name))),G(`data`))))))),R.createReturnStatement(R.createThis())],{typeParams:{E:J(`R`,X(G(`event`)))}});makeSubscriptionClass=e=>Cr(e,[xr(this.#e.sourceProp,`EventSource`),this.#i(),this.#o()],{typeParams:{K:kr(this.requestType.name,R.createTemplateLiteralType(R.createTemplateHead(`get `),[R.createTemplateLiteralTypeSpan(B(v.SyntaxKind.StringKeyword),R.createTemplateTail(``))])),R:kr(J(this.interfaces.positive,`K`),vr(this.#a(v.SyntaxKind.StringKeyword)))}});makeUsageStatements=(e,t)=>[H(this.#e.clientConst,q(e)),K(this.#e.clientConst,this.#e.provideMethod)(Y(`get /v1/user/retrieve`),R.createObjectLiteralExpression([R.createPropertyAssignment(`id`,Y(`10`))])),K(q(t,Y(`get /v1/events/stream`),R.createObjectLiteralExpression()),this.#e.onMethod)(Y(`time`),W([`time`],R.createBlock([])))]};const Ir=(t,{onEach:n,rules:r,onMissing:i,ctx:a={}})=>{let o=e(t),s=o&&o in r?r[o]:r[t._zod.def.type],c=e=>Ir(e,{ctx:a,onEach:n,rules:r,onMissing:i}),l=s?s(t,{...a,next:c}):i(t,a),u=n&&n(t,{prev:l,...a});return u?{...l,...u}:l},{factory:Z}=v,Lr={[v.SyntaxKind.AnyKeyword]:``,[v.SyntaxKind.BigIntKeyword]:BigInt(0),[v.SyntaxKind.BooleanKeyword]:!1,[v.SyntaxKind.NumberKeyword]:0,[v.SyntaxKind.ObjectKeyword]:{},[v.SyntaxKind.StringKeyword]:``,[v.SyntaxKind.UndefinedKeyword]:void 0},Rr={name:t.path([`name`,`text`]),type:t.path([`type`]),optional:t.path([`questionToken`])},zr=({_zod:{def:e}})=>{let t=e.values.map(e=>e===void 0?B(v.SyntaxKind.UndefinedKeyword):X(e));return t.length===1?t[0]:V(t)},Br=({_zod:{def:e}},{next:t})=>{let n=[...e.parts],r=()=>{let e=``;for(;n.length;){let t=n.shift();if(C(t)){n.unshift(t);break}e+=t??``}return e},i=Z.createTemplateHead(r()),a=[];for(;n.length;){let e=t(n.shift()),i=r(),o=n.length?Z.createTemplateMiddle:Z.createTemplateTail;a.push(Z.createTemplateLiteralTypeSpan(e,o(i)))}return a.length?Z.createTemplateLiteralType(i,a):X(i.text)},Vr=(e,{isResponse:t,next:r,makeAlias:i})=>{let a=()=>{let i=Object.entries(e._zod.def.shape).map(([e,i])=>{let{description:a,deprecated:o}=n.get(i)||{};return _r(e,r(i),{comment:a,isDeprecated:o,isOptional:(t?i._zod.optout:i._zod.optin)===`optional`})});return Z.createTypeLiteralNode(i)};return We(e,{io:t?`output`:`input`})?i(e,a):a()},Hr=({_zod:{def:e}},{next:t})=>Z.createArrayTypeNode(t(e.element)),Ur=({_zod:{def:e}})=>V(Object.values(e.entries).map(X)),Wr=({_zod:{def:e}},{next:t})=>V(e.options.map(t)),Gr=e=>Lr?.[e.kind],Kr=({_zod:{def:e}},{next:t})=>V([t(e.innerType),X(null)]),qr=({_zod:{def:e}},{next:t})=>Z.createTupleTypeNode(e.items.map(t).concat(e.rest===null?[]:Z.createRestTypeNode(t(e.rest)))),Jr=({_zod:{def:e}},{next:t})=>B(`Record`,[e.keyType,e.valueType].map(t)),Yr=t.tryCatch(e=>{if(!e.every(v.isTypeLiteralNode))throw Error(`Not objects`);let n=t.chain(t.prop(`members`),e),r=t.uniqWith((...e)=>{if(!t.eqBy(Rr.name,...e))return!1;if(t.both(t.eqBy(Rr.type),t.eqBy(Rr.optional))(...e))return!0;throw Error(`Has conflicting prop`)},n);return Z.createTypeLiteralNode(r)},(e,t)=>Z.createIntersectionTypeNode(t)),Xr=({_zod:{def:e}},{next:t})=>Yr([e.left,e.right].map(t)),Q=e=>()=>B(e),$=({_zod:{def:e}},{next:t})=>t(e.innerType),Zr=e=>B(e?v.SyntaxKind.UnknownKeyword:v.SyntaxKind.AnyKeyword),Qr=({_zod:{def:e}},{next:t,isResponse:n})=>{let r=e[n?`out`:`in`],i=e[n?`in`:`out`];if(!C(r,`transform`))return t(r);let a=Se(r,Gr(t(i))),o={number:v.SyntaxKind.NumberKeyword,bigint:v.SyntaxKind.BigIntKeyword,boolean:v.SyntaxKind.BooleanKeyword,string:v.SyntaxKind.StringKeyword,undefined:v.SyntaxKind.UndefinedKeyword,object:v.SyntaxKind.ObjectKeyword};return B(a&&o[a]||Zr(n))},$r=()=>X(null),ei=({_zod:{def:e}},{makeAlias:t,next:n})=>t(e.getter,()=>n(e.getter())),ti=()=>B(`Buffer`),ni=(e,{next:t})=>t(e._zod.def.shape.raw),ri={string:Q(v.SyntaxKind.StringKeyword),number:Q(v.SyntaxKind.NumberKeyword),bigint:Q(v.SyntaxKind.BigIntKeyword),boolean:Q(v.SyntaxKind.BooleanKeyword),any:Q(v.SyntaxKind.AnyKeyword),undefined:Q(v.SyntaxKind.UndefinedKeyword),[De]:Q(v.SyntaxKind.StringKeyword),[ke]:Q(v.SyntaxKind.StringKeyword),never:Q(v.SyntaxKind.NeverKeyword),void:Q(v.SyntaxKind.UndefinedKeyword),unknown:Q(v.SyntaxKind.UnknownKeyword),null:$r,array:Hr,tuple:qr,record:Jr,object:Vr,literal:zr,template_literal:Br,intersection:Xr,union:Wr,default:$,enum:Ur,optional:$,nonoptional:$,nullable:Kr,catch:$,pipe:Qr,lazy:ei,readonly:$,[Te]:ti,[k]:ni},ii=(e,{brandHandling:t,ctx:n})=>Ir(e,{rules:{...t,...ri},onMissing:({},{isResponse:e})=>Zr(e),ctx:n});var ai=class extends Fr{#e=[this.someOfType];#t=new Map;#n=[];#r(e,t){let n=this.#t.get(e)?.name?.text;if(!n){n=`Type${this.#t.size+1}`;let r=X(null);this.#t.set(e,U(n,r)),this.#t.set(e,U(n,t()))}return B(n)}constructor({routing:e,brandHandling:n,variant:i=`client`,clientClassName:a=`Client`,subscriptionClassName:o=`Subscription`,serverUrl:s=`https://example.com`,noContent:c=r.undefined(),hasHeadMethod:l=!0}){super(s);let u={makeAlias:this.#r.bind(this)},d={brandHandling:n,ctx:{...u,isResponse:!1}},f={brandHandling:n,ctx:{...u,isResponse:!0}},p=(e,n,r)=>{let i=w.bind(null,e,n),{isDeprecated:a,inputSchema:o,tags:s}=r,l=`${e} ${n}`,u=U(i(`input`),ii(o,d),{comment:l});this.#e.push(u);let p=at.reduce((n,a)=>{let o=r.getResponses(a),s=t.chain(([t,{schema:n,mimeTypes:r,statusCodes:o}])=>{let s=we(e,r),u=U(i(a,`variant`,`${t+1}`),ii(s?n:c,f),{comment:l});return this.#e.push(u),o.map(e=>_r(e,u.name))},Array.from(o.entries())),u=Er(i(a,`response`,`variants`),s,{comment:l});return this.#e.push(u),Object.assign(n,{[a]:u})},{});this.paths.add(n);let m=X(l),ee={input:B(u.name),positive:this.someOf(p.positive),negative:this.someOf(p.negative),response:V([J(this.interfaces.positive,m),J(this.interfaces.negative,m)]),encoded:R.createIntersectionTypeNode([B(p.positive.name),B(p.negative.name)])};this.registry.set(l,{isDeprecated:a,store:ee}),this.tags.set(l,s)};Lt({routing:e,onEndpoint:l?At(p):p}),this.#e.unshift(...this.#t.values()),this.#e.push(this.makePathType(),this.methodType,...this.makePublicInterfaces(),this.requestType),i!==`types`&&(this.#e.push(this.makeEndpointTags(),this.makeParseRequestFn(),this.makeSubstituteFn(),this.makeImplementationType(),this.makeDefaultImplementation(),this.makeClientClass(a),this.makeSubscriptionClass(o)),this.#n.push(...this.makeUsageStatements(a,o)))}#i(e){return this.#n.length?this.#n.map(t=>typeof t==`string`?t:ur(t,e)).join(`
17
+ `))},cn=e=>{e.startupLogo!==!1&&sn(process.stdout);let t=e.errorHandler||F,n=ht(e.logger)?e.logger:new yt(e.logger);n.debug(`Running`,{build:`v25.6.1`,env:process.env.NODE_ENV||`development`}),an(n);let r=nn({logger:n,config:e}),i={getLogger:rn(n),errorHandler:t},a=Zt(i),o=Xt(i);return{...i,logger:n,notFoundHandler:a,catcher:o,loggingMiddleware:r}},ln=(e,t)=>{let{logger:n,getLogger:r,notFoundHandler:i,loggingMiddleware:a}=cn(e);return Ht({app:e.app.use(a),routing:t,getLogger:r,config:e}),{notFoundHandler:i,logger:n}},un=async(e,t)=>{let{logger:n,getLogger:r,notFoundHandler:i,catcher:a,loggingMiddleware:o}=cn(e),s=g().disable(`x-powered-by`).set(`query parser`,e.queryParser??`simple`).use(o);if(e.compression){let t=await St(`compression`);s.use(t(typeof e.compression==`object`?e.compression:void 0))}await e.beforeRouting?.({app:s,getLogger:r}),Ht({app:s,routing:t,getLogger:r,config:e,parsers:{json:[e.jsonParser||g.json()],raw:[e.rawParser||g.raw(),tn],form:[e.formParser||g.urlencoded()],upload:e.upload?await en({config:e,getLogger:r}):[]}}),await e.afterRouting?.({app:s,getLogger:r}),s.use(a,i);let c=[],l=(e,t)=>()=>e.listen(t,()=>n.info(`Listening`,t)),u=[];if(e.http){let t=te.createServer(s);c.push(t),u.push(l(t,e.http.listen))}if(e.https){let t=ne.createServer(e.https.options,s);c.push(t),u.push(l(t,e.https.listen))}return c.length||n.warn(`No servers configured.`),e.gracefulShutdown&&on({logger:n,servers:c,options:e.gracefulShutdown===!0?{}:e.gracefulShutdown}),{app:s,logger:n,servers:u.map(e=>e())}},dn=e=>T(e)&&`or`in e,fn=e=>T(e)&&`and`in e,pn=e=>!fn(e)&&!dn(e),mn=e=>{let n=t.filter(pn,e),r=t.chain(t.prop(`and`),t.filter(fn,e)),[i,a]=t.partition(pn,r),o=t.concat(n,i),s=t.filter(dn,e);return t.map(t.prop(`or`),t.concat(s,a)).reduce((e,n)=>be(e,t.map(e=>pn(e)?[e]:e.and,n),([e,n])=>t.concat(e,n)),t.reject(t.isEmpty,[o]))};var hn=`a-im.accept.accept-additions.accept-ch.accept-charset.accept-datetime.accept-encoding.accept-features.accept-language.accept-signature.access-control.access-control-request-headers.access-control-request-method.alpn.alt-used.alternates.amp-cache-transform.apply-to-redirect-ref.authentication-control.authentication-info.authorization.available-dictionary.c-ext.c-man.c-opt.c-pep.c-pep-info.cache-control.cal-managed-id.caldav-timezones.capsule-protocol.cert-not-after.cert-not-before.client-cert.client-cert-chain.close.cmcd-object.cmcd-request.cmcd-session.cmcd-status.cmsd-dynamic.cmsd-static.concealed-auth-export.configuration-context.connection.content-digest.content-disposition.content-encoding.content-id.content-language.content-length.content-location.content-md5.content-range.content-script-type.content-type.cookie.cookie2.cross-origin-embedder-policy.cross-origin-embedder-policy-report-only.cross-origin-opener-policy.cross-origin-opener-policy-report-only.cross-origin-resource-policy.cta-common-access-token.dasl.date.dav.default-style.delta-base.deprecation.depth.derived-from.destination.detached-jws.differential-id.dictionary-id.digest.dpop.dpop-nonce.early-data.ediint-features.expect.expect-ct.ext.forwarded.from.getprofile.hobareg.host.http2-settings.if.if-match.if-modified-since.if-none-match.if-range.if-schedule-tag-match.if-unmodified-since.im.include-referred-token-binding-id.isolation.keep-alive.label.last-event-id.link.link-template.lock-token.man.max-forwards.memento-datetime.meter.method-check.method-check-expires.mime-version.negotiate.nel.odata-entityid.odata-isolation.odata-maxversion.odata-version.opt.ordering-type.origin.origin-agent-cluster.oscore.oslc-core-version.overwrite.p3p.pep.pep-info.permissions-policy.pics-label.ping-from.ping-to.position.pragma.prefer.preference-applied.priority.profileobject.protocol.protocol-info.protocol-query.protocol-request.proxy-authorization.proxy-features.proxy-instruction.public.public-key-pins.public-key-pins-report-only.range.redirect-ref.referer.referer-root.referrer-policy.repeatability-client-id.repeatability-first-sent.repeatability-request-id.repeatability-result.replay-nonce.reporting-endpoints.repr-digest.safe.schedule-reply.schedule-tag.sec-fetch-storage-access.sec-gpc.sec-purpose.sec-token-binding.sec-websocket-extensions.sec-websocket-key.sec-websocket-protocol.sec-websocket-version.security-scheme.setprofile.signature.signature-input.slug.soapaction.status-uri.sunset.surrogate-capability.tcn.te.timeout.topic.traceparent.tracestate.trailer.transfer-encoding.ttl.upgrade.urgency.uri.use-as-dictionary.user-agent.variant-vary.via.want-content-digest.want-digest.want-repr-digest.warning.x-content-type-options.x-frame-options`.split(`.`);const gn=`https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString`,_n={integer:0,number:0,string:``,boolean:!1,object:{},null:null,array:[]},vn=e=>e.replace(fe,e=>`{${e.slice(1)}}`),yn=({},e)=>{if(e.isResponse)throw new E(`Please use ez.upload() only for input.`,e);return{type:`string`,format:`binary`}},bn=({jsonSchema:e})=>({...e,externalDocs:{description:`raw binary data`,url:`https://swagger.io/specification/#working-with-binary-data`}}),xn=({zodSchema:e,jsonSchema:t})=>{if(!C(e,`union`)||!(`discriminator`in e._zod.def))return t;let n=e._zod.def.discriminator;return{...t,discriminator:t.discriminator??{propertyName:n}}},Sn=t.tryCatch(({jsonSchema:e})=>{if(!e.allOf)throw`no allOf`;return Dt(e,`throw`)},(e,{jsonSchema:t})=>t),Cn=({jsonSchema:e})=>{if(!e.anyOf)return e;let t=e.anyOf[0];return Object.assign(t,{type:kn(t.type)})},L=e=>e,wn=({jsonSchema:{examples:e,description:t}},n)=>{if(n.isResponse)throw new E(`Please use ez.dateOut() for output.`,n);let r={description:t||`YYYY-MM-DDTHH:mm:ss.sssZ`,type:`string`,format:`date-time`,pattern:`^\\d{4}-\\d{2}-\\d{2}(T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?)?Z?$`,externalDocs:{url:gn}};return e?.length&&(r.examples=e),r},Tn=({jsonSchema:{examples:e,description:t}},n)=>{if(!n.isResponse)throw new E(`Please use ez.dateIn() for input.`,n);let r={description:t||`YYYY-MM-DDTHH:mm:ss.sssZ`,type:`string`,format:`date-time`,externalDocs:{url:gn}};return e?.length&&(r.examples=e),r},En=()=>({type:`string`,format:`bigint`,pattern:`^-?\\d+$`}),Dn=({zodSchema:e,jsonSchema:t})=>e._zod.def.rest===null?{...t,items:{not:{}}}:t,On=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return _n?.[t]},kn=e=>e===`null`?e:typeof e==`string`?[e,`null`]:e&&[...new Set(e).add(`null`)],An=({zodSchema:e,jsonSchema:t},n)=>{let r=e._zod.def[n.isResponse?`out`:`in`],i=e._zod.def[n.isResponse?`in`:`out`];if(!C(r,`transform`))return t;let a=L(Ln(i,{ctx:n}));if(_(a))if(n.isResponse){let e=Se(r,On(a));if(e&&[`number`,`string`,`boolean`].includes(e))return{...t,type:e}}else{let{type:e,...t}=a;return{...t,format:`${t.format||e} (preprocessed)`}}return t},jn=({jsonSchema:e})=>{if(e.type!==`object`)return e;let t=e;return!t.properties||!(`raw`in t.properties)||!T(t.properties.raw)?e:t.properties.raw},Mn=e=>e.length?t.fromPairs(t.zip(t.times(e=>`example${e+1}`,e.length),t.map(t.objOf(`value`),e))):void 0,Nn=(e,t)=>t?.includes(e)||e.startsWith(`x-`)||hn.includes(e),Pn=({path:e,method:n,request:r,inputSources:i,makeRef:a,composition:o,isHeader:s,security:c,description:l=`${n.toUpperCase()} ${e} Parameter`})=>{let u=Dt(r),d=pe(e),f=i.includes(`query`),p=i.includes(`params`),m=i.includes(`headers`),ee=e=>p&&d.includes(e),h=t.chain(t.filter(e=>e.type===`header`),c??[]).map(({name:e})=>e),g=t=>m&&(s?.(t,n,e)??Nn(t,h));return Object.entries(u.properties).reduce((e,[n,r])=>{if(!T(r))return e;let i=ee(n)?`path`:g(n)?`header`:f?`query`:void 0;if(!i)return e;let s=L(r),c=o===`components`?a(r.id||JSON.stringify(r),s,w(l,n)):s;return e.concat({name:n,in:i,deprecated:r.deprecated,required:u.required?.includes(n)||!1,description:s.description||l,schema:c,examples:Mn(_(s)&&s.examples?.length?s.examples:t.pluck(n,u.examples?.filter(t.both(T,t.has(n)))||[]))})},[])},Fn={nullable:Cn,union:xn,bigint:En,intersection:Sn,tuple:Dn,pipe:An,[De]:wn,[ke]:Tn,[O]:yn,[k]:jn,[Te]:bn},In=(e,n,r)=>{let i=[e,n];for(;i.length;){let e=i.shift();if(t.is(Object,e)){if(ae(e)&&!e.$ref.startsWith(`#/components`)){let t=n[e.$ref.split(`/`).pop()];t&&(e.$ref=r.makeRef(t.id||t,L(t)).$ref);continue}i.push(...t.values(e))}t.is(Array,e)&&i.push(...t.values(e))}return e},Ln=(t,{ctx:n,rules:i=Fn})=>{let{$defs:a={},properties:o={}}=r.toJSONSchema(r.object({subject:t}),{unrepresentable:`any`,io:n.isResponse?`output`:`input`,override:t=>{let r=e(t.zodSchema),a=i[r&&r in i?r:t.zodSchema._zod.def.type];if(a){let e={...a(t,n)};for(let e in t.jsonSchema)delete t.jsonSchema[e];Object.assign(t.jsonSchema,e)}}});return In(T(o.subject)?o.subject:{},a,n)},Rn=(e,n)=>{if(ae(e))return[e,!1];let r=!1,i=t.map(e=>{let[t,i]=Rn(e,n);return r||=i,t}),a=t.omit(n),o={properties:a,examples:t.map(a),required:t.without(n),allOf:i,oneOf:i,anyOf:i},s=t.evolve(o,e);return[s,r||!!s.required?.length]},zn=({method:e,path:n,schema:r,mimeTypes:i,variant:a,makeRef:o,composition:s,hasMultipleStatusCodes:c,statusCode:l,brandHandling:u,description:d=`${e.toUpperCase()} ${n} ${xe(a)} response ${c?l:``}`.trim()})=>{if(!we(e,i))return{description:d};let f=L(Ln(r,{rules:{...u,...Fn},ctx:{isResponse:!0,makeRef:o,path:n,method:e}})),p=[];_(f)&&f.examples&&(p.push(...f.examples),delete f.examples);let m={schema:s===`components`?o(r,f,w(d)):f,examples:Mn(p)};return{description:d,content:t.fromPairs(t.xprod(i,[m]))}},Bn=({format:e})=>{let t={type:`http`,scheme:`bearer`};return e&&(t.bearerFormat=e),t},Vn=({name:e},t)=>{let n={type:`apiKey`,in:`query`,name:e};return t?.includes(`body`)&&(t?.includes(`query`)?(n[`x-in-alternative`]=`body`,n.description=`${e} CAN also be supplied within the request body`):(n[`x-in-actual`]=`body`,n.description=`${e} MUST be supplied within the request body instead of query`)),n},Hn=({name:e})=>({type:`apiKey`,in:`header`,name:e}),Un=({name:e})=>({type:`apiKey`,in:`cookie`,name:e}),Wn=({url:e})=>({type:`openIdConnect`,openIdConnectUrl:e}),Gn=({flows:e={}})=>({type:`oauth2`,flows:t.map(e=>({...e,scopes:e.scopes||{}}),t.reject(t.isNil,e))}),Kn=(e,t=[])=>{let n=e=>e.type===`basic`?{type:`http`,scheme:`basic`}:e.type===`bearer`?Bn(e):e.type===`input`?Vn(e,t):e.type===`header`?Hn(e):e.type===`cookie`?Un(e):e.type===`openid`?Wn(e):Gn(e);return e.map(e=>e.map(n))},qn=(e,t,n)=>e.map(e=>e.reduce((e,r)=>{let i=n(r),a=[`oauth2`,`openIdConnect`].includes(r.type);return Object.assign(e,{[i]:a?t:[]})},{})),Jn=({schema:e,brandHandling:t,makeRef:n,path:r,method:i})=>Ln(e,{rules:{...t,...Fn},ctx:{isResponse:!1,makeRef:n,path:r,method:i}}),Yn=({method:e,path:n,schema:r,request:i,mimeType:a,makeRef:o,composition:s,paramNames:c,description:l=`${e.toUpperCase()} ${n} Request body`})=>{let[u,d]=Rn(L(i),c),f=[];_(u)&&u.examples&&(f.push(...u.examples),delete u.examples);let p={schema:s===`components`?o(r,u,w(l)):u,examples:Mn(f.length?f:Dt(i).examples?.filter(e=>T(e)&&!Array.isArray(e)).map(t.omit(c))||[])},m={description:l,content:{[a]:p}};return(d||a===y.raw)&&(m.required=!0),m},Xn=e=>Object.entries(e).reduce((e,[t,n])=>{if(!n)return e;let r={name:t,description:typeof n==`string`?n:n.description};return typeof n==`object`&&n.url&&(r.externalDocs={url:n.url}),e.concat(r)},[]),Zn=e=>e.length<=50?e:e.slice(0,49)+`…`,Qn=e=>e.length?e.slice():void 0;var $n=class extends ie{#e=new Map;#t=new Map;#n=new Map;#r(e,t,n=this.#n.get(e)){return n||(n=`Schema${this.#n.size+1}`,this.#n.set(e,n)),this.addSchema(n,t),{$ref:`#/components/schemas/${n}`}}#i(e,t,n){let r=n||w(t,e),i=this.#t.get(r);if(i===void 0)return this.#t.set(r,1),r;if(n)throw new E(`Duplicated operationId: "${n}"`,{method:t,isResponse:!1,path:e});return i++,this.#t.set(r,i),`${r}${i}`}#a(e){let t=JSON.stringify(e);for(let e in this.rootDoc.components?.securitySchemes||{})if(t===JSON.stringify(this.rootDoc.components?.securitySchemes?.[e]))return e;let n=(this.#e.get(e.type)||0)+1;return this.#e.set(e.type,n),`${e.type.toUpperCase()}_${n}`}constructor({routing:e,config:n,title:r,version:i,serverUrl:a,descriptions:o,brandHandling:s,tags:c,isHeader:l,hasSummaryFromDescription:u=!0,hasHeadMethod:d=!0,composition:f=`inline`}){super(),this.addInfo({title:r,version:i});for(let e of typeof a==`string`?[a]:a)this.addServer({url:e});let p=(e,r,i)=>{let a={path:r,method:e,endpoint:i,composition:f,brandHandling:s,makeRef:this.#r.bind(this)},{description:c,shortDescription:d,scopes:p,inputSchema:m}=i,ee=d?Zn(d):u&&c?Zn(c):void 0,h=ve(e,n.inputSources),g=this.#i(r,e,i.getOperationId(e)),te=Jn({...a,schema:m}),ne=mn(i.security),re=Pn({...a,inputSources:h,isHeader:l,security:ne,request:te,description:o?.requestParameter?.call(null,{method:e,path:r,operationId:g})}),ie={};for(let t of at){let n=i.getResponses(t);for(let{mimeTypes:i,schema:s,statusCodes:c}of n)for(let l of c)ie[l]=zn({...a,variant:t,schema:s,mimeTypes:i,statusCode:l,hasMultipleStatusCodes:n.length>1||c.length>1,description:o?.[`${t}Response`]?.call(null,{method:e,path:r,operationId:g,statusCode:l})})}let ae=h.includes(`body`)?Yn({...a,request:te,paramNames:t.pluck(`name`,re),schema:m,mimeType:y[i.requestType],description:o?.requestBody?.call(null,{method:e,path:r,operationId:g})}):void 0,_=qn(Kn(ne,h),p,e=>{let t=this.#a(e);return this.addSecurityScheme(t,e),t}),oe={operationId:g,summary:ee,description:c,deprecated:i.isDeprecated||void 0,tags:Qn(i.tags),parameters:Qn(re),requestBody:ae,security:Qn(_),responses:ie};this.addPath(vn(r),{[e]:oe})};Lt({routing:e,onEndpoint:d?At(p):p}),c&&(this.rootDoc.tags=Xn(c))}};const er=e=>oe({...e,headers:{"content-type":y.json,...e?.headers}}),tr=e=>se(e),nr=e=>{let t={warn:[],error:[],info:[],debug:[]};return new Proxy(e||{},{get(e,n,r){return n===`_getLogs`?()=>t:gt(n)?(...e)=>t[n].push(e):Reflect.get(e,n,r)}})},rr=({requestProps:e,responseOptions:t,configProps:n,loggerProps:r})=>{let i=er(e),a=tr({req:i,...t});a.req=t?.req||i,i.res=a;let o=nr(r);return{requestMock:i,responseMock:a,loggerMock:o,configMock:{cors:!1,logger:o,...n}}},ir=async({endpoint:e,...t})=>{let{requestMock:n,responseMock:r,loggerMock:i,configMock:a}=rr(t);return await e.execute({request:n,response:r,config:a,logger:i}),{requestMock:n,responseMock:r,loggerMock:i}},ar=async({middleware:e,options:t={},...n})=>{let{requestMock:r,responseMock:i,loggerMock:a,configMock:{inputSources:o,errorHandler:s=F}}=rr(n),c={request:r,response:i,logger:a,input:ye(r,o),options:t};try{return{requestMock:r,responseMock:i,loggerMock:a,output:await e.execute(c)}}catch(e){return await s.execute({...c,error:x(e),output:null}),{requestMock:r,responseMock:i,loggerMock:a,output:{}}}},R=v.factory,or=[R.createModifier(v.SyntaxKind.ExportKeyword)],sr=[R.createModifier(v.SyntaxKind.AsyncKeyword)],cr={public:[R.createModifier(v.SyntaxKind.PublicKeyword)],protectedReadonly:[R.createModifier(v.SyntaxKind.ProtectedKeyword),R.createModifier(v.SyntaxKind.ReadonlyKeyword)]},lr=(e,t)=>v.addSyntheticLeadingComment(e,v.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0),ur=(e,t)=>{let n=v.createSourceFile(`print.ts`,``,v.ScriptTarget.Latest,!1,v.ScriptKind.TS);return v.createPrinter(t).printNode(v.EmitHint.Unspecified,e,n)},dr=/^[A-Za-z_$][A-Za-z0-9_$]*$/,fr=e=>typeof e==`string`&&dr.test(e)?R.createIdentifier(e):Y(e),pr=(e,...t)=>R.createTemplateExpression(R.createTemplateHead(e),t.map(([e,n=``],r)=>R.createTemplateSpan(e,r===t.length-1?R.createTemplateTail(n):R.createTemplateMiddle(n)))),mr=(e,{type:t,mod:n,init:r,optional:i}={})=>R.createParameterDeclaration(n,void 0,e,i?R.createToken(v.SyntaxKind.QuestionToken):void 0,t?B(t):void 0,r),z=e=>Object.entries(e).map(([e,t])=>mr(e,typeof t==`string`||typeof t==`number`||typeof t==`object`&&`kind`in t?{type:t}:t)),hr=(e,t=[])=>R.createConstructorDeclaration(cr.public,e,R.createBlock(t)),B=(e,n)=>typeof e==`number`?R.createKeywordTypeNode(e):typeof e==`string`||v.isIdentifier(e)?R.createTypeReferenceNode(e,n&&t.map(B,n)):e,gr=B(`Record`,[v.SyntaxKind.StringKeyword,v.SyntaxKind.AnyKeyword]),V=e=>{let t=new Map;for(let n of e)t.set(Pr(n)?n.kind:n,n);return R.createUnionTypeNode(Array.from(t.values()))},_r=(e,n,{isOptional:r,isDeprecated:i,comment:a}={})=>{let o=B(n),s=R.createPropertySignature(void 0,fr(e),r?R.createToken(v.SyntaxKind.QuestionToken):void 0,r?V([o,B(v.SyntaxKind.UndefinedKeyword)]):o),c=t.reject(t.isNil,[i?`@deprecated`:void 0,a]);return c.length?lr(s,c.join(` `)):s},vr=e=>v.setEmitFlags(e,v.EmitFlags.SingleLine),yr=(...e)=>R.createArrayBindingPattern(e.map(e=>R.createBindingElement(void 0,void 0,e))),H=(e,t,{type:n,expose:r}={})=>R.createVariableStatement(r&&or,R.createVariableDeclarationList([R.createVariableDeclaration(e,void 0,n?B(n):void 0,t)],v.NodeFlags.Const)),br=(e,n)=>U(e,V(t.map(X,n)),{expose:!0}),U=(e,t,{expose:n,comment:r,params:i}={})=>{let a=R.createTypeAliasDeclaration(n?or:void 0,e,i&&Dr(i),t);return r?lr(a,r):a},xr=(e,t)=>R.createPropertyDeclaration(cr.public,e,void 0,B(t),void 0),Sr=(e,t,n,{typeParams:r,returns:i}={})=>R.createMethodDeclaration(cr.public,void 0,e,void 0,r&&Dr(r),t,i,R.createBlock(n)),Cr=(e,t,{typeParams:n}={})=>R.createClassDeclaration(or,e,n&&Dr(n),void 0,t),wr=e=>R.createTypeOperatorNode(v.SyntaxKind.KeyOfKeyword,B(e)),Tr=e=>B(Promise.name,[e]),Er=(e,t,{expose:n,comment:r}={})=>{let i=R.createInterfaceDeclaration(n?or:void 0,e,void 0,void 0,t);return r?lr(i,r):i},Dr=e=>(Array.isArray(e)?e.map(e=>t.pair(e,void 0)):Object.entries(e)).map(([e,t])=>{let{type:n,init:r}=typeof t==`object`&&`init`in t?t:{type:t};return R.createTypeParameterDeclaration([],e,n?B(n):void 0,r?B(r):void 0)}),W=(e,n,{isAsync:r}={})=>R.createArrowFunction(r?sr:void 0,void 0,Array.isArray(e)?t.map(mr,e):z(e),void 0,void 0,n),G=e=>e,Or=(e,t,n)=>R.createConditionalExpression(e,R.createToken(v.SyntaxKind.QuestionToken),t,R.createToken(v.SyntaxKind.ColonToken),n),K=(e,...t)=>(...n)=>R.createCallExpression(t.reduce((e,t)=>typeof t==`string`||v.isIdentifier(t)?R.createPropertyAccessExpression(e,t):R.createElementAccessExpression(e,t),typeof e==`string`?R.createIdentifier(e):e),void 0,n),q=(e,...t)=>R.createNewExpression(R.createIdentifier(e),void 0,t),kr=(e,t)=>B(`Extract`,[e,t]),Ar=(e,t)=>R.createExpressionStatement(R.createBinaryExpression(e,R.createToken(v.SyntaxKind.EqualsToken),t)),J=(e,t)=>R.createIndexedAccessTypeNode(B(e),B(t)),jr=e=>V([B(e),Tr(e)]),Mr=(e,t)=>R.createFunctionTypeNode(void 0,z(e),B(t)),Y=e=>typeof e==`number`?R.createNumericLiteral(e):typeof e==`bigint`?R.createBigIntLiteral(e.toString()):typeof e==`boolean`?e?R.createTrue():R.createFalse():e===null?R.createNull():R.createStringLiteral(e),X=e=>R.createLiteralTypeNode(Y(e)),Nr=[v.SyntaxKind.AnyKeyword,v.SyntaxKind.BigIntKeyword,v.SyntaxKind.BooleanKeyword,v.SyntaxKind.NeverKeyword,v.SyntaxKind.NumberKeyword,v.SyntaxKind.ObjectKeyword,v.SyntaxKind.StringKeyword,v.SyntaxKind.SymbolKeyword,v.SyntaxKind.UndefinedKeyword,v.SyntaxKind.UnknownKeyword,v.SyntaxKind.VoidKeyword],Pr=e=>Nr.includes(e.kind);var Fr=class{paths=new Set;tags=new Map;registry=new Map;#e={pathType:R.createIdentifier(`Path`),implementationType:R.createIdentifier(`Implementation`),keyParameter:R.createIdentifier(`key`),pathParameter:R.createIdentifier(`path`),paramsArgument:R.createIdentifier(`params`),ctxArgument:R.createIdentifier(`ctx`),methodParameter:R.createIdentifier(`method`),requestParameter:R.createIdentifier(`request`),eventParameter:R.createIdentifier(`event`),dataParameter:R.createIdentifier(`data`),handlerParameter:R.createIdentifier(`handler`),msgParameter:R.createIdentifier(`msg`),parseRequestFn:R.createIdentifier(`parseRequest`),substituteFn:R.createIdentifier(`substitute`),provideMethod:R.createIdentifier(`provide`),onMethod:R.createIdentifier(`on`),implementationArgument:R.createIdentifier(`implementation`),hasBodyConst:R.createIdentifier(`hasBody`),undefinedValue:R.createIdentifier(`undefined`),responseConst:R.createIdentifier(`response`),restConst:R.createIdentifier(`rest`),searchParamsConst:R.createIdentifier(`searchParams`),defaultImplementationConst:R.createIdentifier(`defaultImplementation`),clientConst:R.createIdentifier(`client`),contentTypeConst:R.createIdentifier(`contentType`),isJsonConst:R.createIdentifier(`isJSON`),sourceProp:R.createIdentifier(`source`)};interfaces={input:R.createIdentifier(`Input`),positive:R.createIdentifier(`PositiveResponse`),negative:R.createIdentifier(`NegativeResponse`),encoded:R.createIdentifier(`EncodedResponse`),response:R.createIdentifier(`Response`)};methodType=br(`Method`,ue);someOfType=U(`SomeOf`,J(`T`,wr(`T`)),{params:[`T`]});requestType=U(`Request`,wr(this.interfaces.input),{expose:!0});constructor(e){this.serverUrl=e}someOf=({name:e})=>B(this.someOfType.name,[e]);makePathType=()=>br(this.#e.pathType,Array.from(this.paths));makePublicInterfaces=()=>Object.keys(this.interfaces).map(e=>Er(this.interfaces[e],Array.from(this.registry).map(([t,{store:n,isDeprecated:r}])=>_r(t,n[e],{isDeprecated:r})),{expose:!0}));makeEndpointTags=()=>H(`endpointTags`,R.createObjectLiteralExpression(Array.from(this.tags).map(([e,n])=>R.createPropertyAssignment(fr(e),R.createArrayLiteralExpression(t.map(Y,n))))),{expose:!0});makeImplementationType=()=>U(this.#e.implementationType,Mr({[this.#e.methodParameter.text]:this.methodType.name,[this.#e.pathParameter.text]:v.SyntaxKind.StringKeyword,[this.#e.paramsArgument.text]:gr,[this.#e.ctxArgument.text]:{optional:!0,type:`T`}},Tr(v.SyntaxKind.AnyKeyword)),{expose:!0,params:{T:{init:v.SyntaxKind.UnknownKeyword}}});makeParseRequestFn=()=>H(this.#e.parseRequestFn,W({[this.#e.requestParameter.text]:v.SyntaxKind.StringKeyword},R.createAsExpression(K(this.#e.requestParameter,G(`split`))(R.createRegularExpressionLiteral(`/ (.+)/`),Y(2)),R.createTupleTypeNode([B(this.methodType.name),B(this.#e.pathType)]))));makeSubstituteFn=()=>H(this.#e.substituteFn,W({[this.#e.pathParameter.text]:v.SyntaxKind.StringKeyword,[this.#e.paramsArgument.text]:gr},R.createBlock([H(this.#e.restConst,R.createObjectLiteralExpression([R.createSpreadAssignment(this.#e.paramsArgument)])),R.createForInStatement(R.createVariableDeclarationList([R.createVariableDeclaration(this.#e.keyParameter)],v.NodeFlags.Const),this.#e.paramsArgument,R.createBlock([Ar(this.#e.pathParameter,K(this.#e.pathParameter,G(`replace`))(pr(`:`,[this.#e.keyParameter]),W([],R.createBlock([R.createExpressionStatement(R.createDeleteExpression(R.createElementAccessExpression(this.#e.restConst,this.#e.keyParameter))),R.createReturnStatement(R.createElementAccessExpression(this.#e.paramsArgument,this.#e.keyParameter))]))))])),R.createReturnStatement(R.createAsExpression(R.createArrayLiteralExpression([this.#e.pathParameter,this.#e.restConst]),B(`const`)))])));#t=()=>Sr(this.#e.provideMethod,z({[this.#e.requestParameter.text]:`K`,[this.#e.paramsArgument.text]:J(this.interfaces.input,`K`),[this.#e.ctxArgument.text]:{optional:!0,type:`T`}}),[H(yr(this.#e.methodParameter,this.#e.pathParameter),K(this.#e.parseRequestFn)(this.#e.requestParameter)),R.createReturnStatement(K(R.createThis(),this.#e.implementationArgument)(this.#e.methodParameter,R.createSpreadElement(K(this.#e.substituteFn)(this.#e.pathParameter,this.#e.paramsArgument)),this.#e.ctxArgument))],{typeParams:{K:this.requestType.name},returns:Tr(J(this.interfaces.response,`K`))});makeClientClass=e=>Cr(e,[hr([mr(this.#e.implementationArgument,{type:B(this.#e.implementationType,[`T`]),mod:cr.protectedReadonly,init:this.#e.defaultImplementationConst})]),this.#t()],{typeParams:[`T`]});#n=e=>pr(`?`,[q(URLSearchParams.name,e)]);#r=()=>q(URL.name,pr(``,[this.#e.pathParameter],[this.#e.searchParamsConst]),Y(this.serverUrl));makeDefaultImplementation=()=>{let e=R.createPropertyAssignment(G(`method`),K(this.#e.methodParameter,G(`toUpperCase`))()),t=R.createPropertyAssignment(G(`headers`),Or(this.#e.hasBodyConst,R.createObjectLiteralExpression([R.createPropertyAssignment(Y(`Content-Type`),Y(y.json))]),this.#e.undefinedValue)),n=R.createPropertyAssignment(G(`body`),Or(this.#e.hasBodyConst,K(JSON[Symbol.toStringTag],G(`stringify`))(this.#e.paramsArgument),this.#e.undefinedValue)),r=H(this.#e.responseConst,R.createAwaitExpression(K(fetch.name)(this.#r(),R.createObjectLiteralExpression([e,t,n])))),i=H(this.#e.hasBodyConst,R.createLogicalNot(K(R.createArrayLiteralExpression([Y(`get`),Y(`head`),Y(`delete`)]),G(`includes`))(this.#e.methodParameter))),a=H(this.#e.searchParamsConst,Or(this.#e.hasBodyConst,Y(``),this.#n(this.#e.paramsArgument))),o=H(this.#e.contentTypeConst,K(this.#e.responseConst,G(`headers`),G(`get`))(Y(`content-type`))),s=R.createIfStatement(R.createPrefixUnaryExpression(v.SyntaxKind.ExclamationToken,this.#e.contentTypeConst),R.createReturnStatement()),c=H(this.#e.isJsonConst,K(this.#e.contentTypeConst,G(`startsWith`))(Y(y.json))),l=R.createReturnStatement(K(this.#e.responseConst,Or(this.#e.isJsonConst,Y(G(`json`)),Y(G(`text`))))());return H(this.#e.defaultImplementationConst,W([this.#e.methodParameter,this.#e.pathParameter,this.#e.paramsArgument],R.createBlock([i,a,r,o,s,c,l]),{isAsync:!0}),{type:this.#e.implementationType})};#i=()=>hr(z({request:`K`,params:J(this.interfaces.input,`K`)}),[H(yr(this.#e.pathParameter,this.#e.restConst),K(this.#e.substituteFn)(R.createElementAccessExpression(K(this.#e.parseRequestFn)(this.#e.requestParameter),Y(1)),this.#e.paramsArgument)),H(this.#e.searchParamsConst,this.#n(this.#e.restConst)),Ar(R.createPropertyAccessExpression(R.createThis(),this.#e.sourceProp),q(`EventSource`,this.#r()))]);#a=e=>R.createTypeLiteralNode([_r(G(`event`),e)]);#o=()=>Sr(this.#e.onMethod,z({[this.#e.eventParameter.text]:`E`,[this.#e.handlerParameter.text]:Mr({[this.#e.dataParameter.text]:J(kr(`R`,vr(this.#a(`E`))),X(G(`data`)))},jr(v.SyntaxKind.VoidKeyword))}),[R.createExpressionStatement(K(R.createThis(),this.#e.sourceProp,G(`addEventListener`))(this.#e.eventParameter,W([this.#e.msgParameter],K(this.#e.handlerParameter)(K(JSON[Symbol.toStringTag],G(`parse`))(R.createPropertyAccessExpression(R.createParenthesizedExpression(R.createAsExpression(this.#e.msgParameter,B(MessageEvent.name))),G(`data`))))))),R.createReturnStatement(R.createThis())],{typeParams:{E:J(`R`,X(G(`event`)))}});makeSubscriptionClass=e=>Cr(e,[xr(this.#e.sourceProp,`EventSource`),this.#i(),this.#o()],{typeParams:{K:kr(this.requestType.name,R.createTemplateLiteralType(R.createTemplateHead(`get `),[R.createTemplateLiteralTypeSpan(B(v.SyntaxKind.StringKeyword),R.createTemplateTail(``))])),R:kr(J(this.interfaces.positive,`K`),vr(this.#a(v.SyntaxKind.StringKeyword)))}});makeUsageStatements=(e,t)=>[H(this.#e.clientConst,q(e)),K(this.#e.clientConst,this.#e.provideMethod)(Y(`get /v1/user/retrieve`),R.createObjectLiteralExpression([R.createPropertyAssignment(`id`,Y(`10`))])),K(q(t,Y(`get /v1/events/stream`),R.createObjectLiteralExpression()),this.#e.onMethod)(Y(`time`),W([`time`],R.createBlock([])))]};const Ir=(t,{onEach:n,rules:r,onMissing:i,ctx:a={}})=>{let o=e(t),s=o&&o in r?r[o]:r[t._zod.def.type],c=e=>Ir(e,{ctx:a,onEach:n,rules:r,onMissing:i}),l=s?s(t,{...a,next:c}):i(t,a),u=n&&n(t,{prev:l,...a});return u?{...l,...u}:l},{factory:Z}=v,Lr={[v.SyntaxKind.AnyKeyword]:``,[v.SyntaxKind.BigIntKeyword]:BigInt(0),[v.SyntaxKind.BooleanKeyword]:!1,[v.SyntaxKind.NumberKeyword]:0,[v.SyntaxKind.ObjectKeyword]:{},[v.SyntaxKind.StringKeyword]:``,[v.SyntaxKind.UndefinedKeyword]:void 0},Rr={name:t.path([`name`,`text`]),type:t.path([`type`]),optional:t.path([`questionToken`])},zr=({_zod:{def:e}})=>{let t=e.values.map(e=>e===void 0?B(v.SyntaxKind.UndefinedKeyword):X(e));return t.length===1?t[0]:V(t)},Br=({_zod:{def:e}},{next:t})=>{let n=[...e.parts],r=()=>{let e=``;for(;n.length;){let t=n.shift();if(C(t)){n.unshift(t);break}e+=t??``}return e},i=Z.createTemplateHead(r()),a=[];for(;n.length;){let e=t(n.shift()),i=r(),o=n.length?Z.createTemplateMiddle:Z.createTemplateTail;a.push(Z.createTemplateLiteralTypeSpan(e,o(i)))}return a.length?Z.createTemplateLiteralType(i,a):X(i.text)},Vr=(e,{isResponse:t,next:r,makeAlias:i})=>{let a=()=>{let i=Object.entries(e._zod.def.shape).map(([e,i])=>{let{description:a,deprecated:o}=n.get(i)||{};return _r(e,r(i),{comment:a,isDeprecated:o,isOptional:(t?i._zod.optout:i._zod.optin)===`optional`})});return Z.createTypeLiteralNode(i)};return We(e,{io:t?`output`:`input`})?i(e,a):a()},Hr=({_zod:{def:e}},{next:t})=>Z.createArrayTypeNode(t(e.element)),Ur=({_zod:{def:e}})=>V(Object.values(e.entries).map(X)),Wr=({_zod:{def:e}},{next:t})=>V(e.options.map(t)),Gr=e=>Lr?.[e.kind],Kr=({_zod:{def:e}},{next:t})=>V([t(e.innerType),X(null)]),qr=({_zod:{def:e}},{next:t})=>Z.createTupleTypeNode(e.items.map(t).concat(e.rest===null?[]:Z.createRestTypeNode(t(e.rest)))),Jr=({_zod:{def:e}},{next:t})=>B(`Record`,[e.keyType,e.valueType].map(t)),Yr=t.tryCatch(e=>{if(!e.every(v.isTypeLiteralNode))throw Error(`Not objects`);let n=t.chain(t.prop(`members`),e),r=t.uniqWith((...e)=>{if(!t.eqBy(Rr.name,...e))return!1;if(t.both(t.eqBy(Rr.type),t.eqBy(Rr.optional))(...e))return!0;throw Error(`Has conflicting prop`)},n);return Z.createTypeLiteralNode(r)},(e,t)=>Z.createIntersectionTypeNode(t)),Xr=({_zod:{def:e}},{next:t})=>Yr([e.left,e.right].map(t)),Q=e=>()=>B(e),$=({_zod:{def:e}},{next:t})=>t(e.innerType),Zr=e=>B(e?v.SyntaxKind.UnknownKeyword:v.SyntaxKind.AnyKeyword),Qr=({_zod:{def:e}},{next:t,isResponse:n})=>{let r=e[n?`out`:`in`],i=e[n?`in`:`out`];if(!C(r,`transform`))return t(r);let a=Se(r,Gr(t(i))),o={number:v.SyntaxKind.NumberKeyword,bigint:v.SyntaxKind.BigIntKeyword,boolean:v.SyntaxKind.BooleanKeyword,string:v.SyntaxKind.StringKeyword,undefined:v.SyntaxKind.UndefinedKeyword,object:v.SyntaxKind.ObjectKeyword};return B(a&&o[a]||Zr(n))},$r=()=>X(null),ei=({_zod:{def:e}},{makeAlias:t,next:n})=>t(e.getter,()=>n(e.getter())),ti=()=>B(`Buffer`),ni=(e,{next:t})=>t(e._zod.def.shape.raw),ri={string:Q(v.SyntaxKind.StringKeyword),number:Q(v.SyntaxKind.NumberKeyword),bigint:Q(v.SyntaxKind.BigIntKeyword),boolean:Q(v.SyntaxKind.BooleanKeyword),any:Q(v.SyntaxKind.AnyKeyword),undefined:Q(v.SyntaxKind.UndefinedKeyword),[De]:Q(v.SyntaxKind.StringKeyword),[ke]:Q(v.SyntaxKind.StringKeyword),never:Q(v.SyntaxKind.NeverKeyword),void:Q(v.SyntaxKind.UndefinedKeyword),unknown:Q(v.SyntaxKind.UnknownKeyword),null:$r,array:Hr,tuple:qr,record:Jr,object:Vr,literal:zr,template_literal:Br,intersection:Xr,union:Wr,default:$,enum:Ur,optional:$,nonoptional:$,nullable:Kr,catch:$,pipe:Qr,lazy:ei,readonly:$,[Te]:ti,[k]:ni},ii=(e,{brandHandling:t,ctx:n})=>Ir(e,{rules:{...t,...ri},onMissing:({},{isResponse:e})=>Zr(e),ctx:n});var ai=class extends Fr{#e=[this.someOfType];#t=new Map;#n=[];#r(e,t){let n=this.#t.get(e)?.name?.text;if(!n){n=`Type${this.#t.size+1}`;let r=X(null);this.#t.set(e,U(n,r)),this.#t.set(e,U(n,t()))}return B(n)}constructor({routing:e,brandHandling:n,variant:i=`client`,clientClassName:a=`Client`,subscriptionClassName:o=`Subscription`,serverUrl:s=`https://example.com`,noContent:c=r.undefined(),hasHeadMethod:l=!0}){super(s);let u={makeAlias:this.#r.bind(this)},d={brandHandling:n,ctx:{...u,isResponse:!1}},f={brandHandling:n,ctx:{...u,isResponse:!0}},p=(e,n,r)=>{let i=w.bind(null,e,n),{isDeprecated:a,inputSchema:o,tags:s}=r,l=`${e} ${n}`,u=U(i(`input`),ii(o,d),{comment:l});this.#e.push(u);let p=at.reduce((n,a)=>{let o=r.getResponses(a),s=t.chain(([t,{schema:n,mimeTypes:r,statusCodes:o}])=>{let s=we(e,r),u=U(i(a,`variant`,`${t+1}`),ii(s?n:c,f),{comment:l});return this.#e.push(u),o.map(e=>_r(e,u.name))},Array.from(o.entries())),u=Er(i(a,`response`,`variants`),s,{comment:l});return this.#e.push(u),Object.assign(n,{[a]:u})},{});this.paths.add(n);let m=X(l),ee={input:B(u.name),positive:this.someOf(p.positive),negative:this.someOf(p.negative),response:V([J(this.interfaces.positive,m),J(this.interfaces.negative,m)]),encoded:R.createIntersectionTypeNode([B(p.positive.name),B(p.negative.name)])};this.registry.set(l,{isDeprecated:a,store:ee}),this.tags.set(l,s)};Lt({routing:e,onEndpoint:l?At(p):p}),this.#e.unshift(...this.#t.values()),this.#e.push(this.makePathType(),this.methodType,...this.makePublicInterfaces(),this.requestType),i!==`types`&&(this.#e.push(this.makeEndpointTags(),this.makeParseRequestFn(),this.makeSubstituteFn(),this.makeImplementationType(),this.makeDefaultImplementation(),this.makeClientClass(a),this.makeSubscriptionClass(o)),this.#n.push(...this.makeUsageStatements(a,o)))}#i(e){return this.#n.length?this.#n.map(t=>typeof t==`string`?t:ur(t,e)).join(`
18
18
  `):void 0}print(e){let t=this.#i(e),n=t&&v.addSyntheticLeadingComment(v.addSyntheticLeadingComment(R.createEmptyStatement(),v.SyntaxKind.SingleLineCommentTrivia,` Usage example:`),v.SyntaxKind.MultiLineCommentTrivia,`\n${t}`);return this.#e.concat(n||[]).map((t,n)=>ur(t,n<this.#e.length?e:{...e,omitTrailingSemicolon:!0})).join(`
19
19
 
20
20
  `)}async printFormatted({printerOptions:e,format:t}={}){let n=t;if(!n)try{let e=(await St(`prettier`)).format;n=t=>e(t,{filepath:`client.ts`})}catch{}let r=this.#i(e);this.#n=r&&n?[await n(r)]:this.#n;let i=this.print(e);return n?n(i):i}};const oi=(e,t)=>r.object({data:t,event:r.literal(e),id:r.string().optional(),retry:r.int().positive().optional()}),si=(e,t,n)=>oi(String(t),e[t]).transform(e=>[`event: ${e.event}`,`data: ${JSON.stringify(e.data)}`,``,``].join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-zod-api",
3
- "version": "25.6.0",
3
+ "version": "25.6.1",
4
4
  "description": "A Typescript framework to help you get an API server up and running with I/O schema validation and custom middlewares in minutes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -88,7 +88,7 @@
88
88
  "express": "^5.1.0",
89
89
  "express-fileupload": "^1.5.1",
90
90
  "http-errors": "^2.0.0",
91
- "node-forge": "^1.3.1",
91
+ "node-forge": "^1.3.2",
92
92
  "snakify-ts": "^2.3.0",
93
93
  "typescript": "^5.9.2",
94
94
  "undici": "^7.10.0",