express-zod-api 19.2.0 → 19.2.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 +4 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ ${o}888${t}
|
|
|
17
17
|
${r}
|
|
18
18
|
`.split(`
|
|
19
19
|
`).map((c,l)=>a[l]?a[l](c):c).join(`
|
|
20
|
-
`)};var Dr=e=>{e.startupLogo!==!1&&console.log(vr());let t=e.errorHandler||be,r=Ar(e.logger)?e.logger:new ae(e.logger);r.debug("Running","v19.2.0 (CJS)");let o=Mr({rootLogger:r,config:e}),i=zr({rootLogger:r,errorHandler:t}),s=Er({rootLogger:r,errorHandler:t});return{rootLogger:r,errorHandler:t,notFoundHandler:i,parserFailureHandler:s,loggingMiddleware:o}},kr=(e,t)=>{let{rootLogger:r,notFoundHandler:o,loggingMiddleware:i}=Dr(e);return Nt({app:e.app.use(i),routing:t,rootLogger:r,config:e}),{notFoundHandler:o,logger:r}},Hr=async(e,t)=>{let{rootLogger:r,notFoundHandler:o,parserFailureHandler:i,loggingMiddleware:s}=Dr(e),a=(0,pt.default)().disable("x-powered-by").use(s);if(e.server.compression){let m=await pe("compression");a.use(m(typeof e.server.compression=="object"?e.server.compression:void 0))}let p={json:[e.server.jsonParser||pt.default.json()],raw:[e.server.rawParser||pt.default.raw(),Nr],upload:e.server.upload?await Zr({config:e,rootLogger:r}):[]};e.server.beforeRouting&&await e.server.beforeRouting({app:a,logger:r}),Nt({app:a,routing:t,rootLogger:r,config:e,parsers:p}),a.use(i,o);let c=(m,y)=>m.listen(y,()=>{r.info("Listening",y)}),l={httpServer:c(Lr.default.createServer(a),e.server.listen),httpsServer:e.https?c(jr.default.createServer(e.https.options,a),e.https.listen):void 0};return{app:a,...l,logger:r}};var no=R(require("assert/strict"),1),io=require("openapi3-ts/oas31"),so=require("ramda");var B=R(require("assert/strict"),1),Y=require("openapi3-ts/oas31"),d=require("ramda"),S=require("zod");var Ae=require("zod");var dt=e=>!isNaN(e.getTime());var Fe=Symbol("DateIn"),Ur=()=>Ae.z.union([Ae.z.string().date(),Ae.z.string().datetime(),Ae.z.string().datetime({local:!0})]).transform(t=>new Date(t)).pipe(Ae.z.date().refine(dt)).brand(Fe);var Fr=require("zod");var Ke=Symbol("DateOut"),Kr=()=>Fr.z.date().refine(dt).transform(e=>e.toISOString()).brand(Ke);var ce=(e,{onEach:t,rules:r,onMissing:o,ctx:i={}})=>{let s=r[e._def[g]?.brand]||r[e._def.typeName],p=s?s(e,{...i,next:l=>ce(l,{ctx:i,onEach:t,rules:r,onMissing:o})}):o(e,i),c=t&&t(e,{prev:p,...i});return c?{...p,...c}:p};var Br=50,$r="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",Fo={integer:0,number:0,string:"",boolean:!1,object:{},null:null,array:[]},Vr=/:([A-Za-z0-9_]+)/g,Ko=e=>e.match(Vr)?.map(t=>t.slice(1))||[],Gr=e=>e.replace(Vr,t=>`{${t.slice(1)}}`),Bo=({_def:e},{next:t})=>({...t(e.innerType),default:e[g]?.defaultLabel||e.defaultValue()}),qo=({_def:{innerType:e}},{next:t})=>t(e),$o=()=>({format:"any"}),Vo=({},e)=>((0,B.default)(!e.isResponse,new P({message:"Please use ez.upload() only for input.",...e})),{type:"string",format:"binary"}),Go=e=>{let t=e.unwrap();return{type:"string",format:t instanceof S.z.ZodString?t._def.checks.find(r=>r.kind==="base64")?"byte":"file":"binary"}},_o=({options:e},{next:t})=>({oneOf:e.map(t)}),Yo=({options:e,discriminator:t},{next:r})=>({discriminator:{propertyName:t},oneOf:e.map(r)}),Qo=e=>{let[t,r]=e.filter(i=>!(0,Y.isReferenceObject)(i)&&i.type==="object"&&Object.keys(i).every(s=>["type","properties","required","examples"].includes(s)));(0,B.default)(t&&r,"Can not flatten objects");let o={type:"object"};return(t.properties||r.properties)&&(o.properties=(0,d.mergeDeepWith)((i,s)=>Array.isArray(i)&&Array.isArray(s)?(0,d.concat)(i,s):i===s?s:B.default.fail("Can not flatten properties"),t.properties||{},r.properties||{})),(t.required||r.required)&&(o.required=(0,d.union)(t.required||[],r.required||[])),(t.examples||r.examples)&&(o.examples=oe(t.examples||[],r.examples||[],([i,s])=>(0,d.mergeDeepRight)(i,s))),o},Jo=({_def:{left:e,right:t}},{next:r})=>{let o=[e,t].map(r);try{return Qo(o)}catch{}return{allOf:o}},Wo=(e,{next:t})=>t(e.unwrap()),Xo=(e,{next:t})=>t(e.unwrap()),en=(e,{next:t})=>{let r=t(e.unwrap());return(0,Y.isReferenceObject)(r)||(r.type=Yr(r)),r},_r=e=>{let t=(0,d.toLower)((0,d.type)(e));return typeof e=="bigint"?"integer":t==="number"||t==="string"||t==="boolean"||t==="object"||t==="null"||t==="array"?t:void 0},qr=e=>({type:_r(Object.values(e.enum)[0]),enum:Object.values(e.enum)}),tn=({value:e})=>({type:_r(e),const:e}),rn=(e,{isResponse:t,next:r})=>{let o=Object.keys(e.shape),i=p=>t&&je(p)?p instanceof S.z.ZodOptional:p.isOptional(),s=o.filter(p=>!i(e.shape[p])),a={type:"object"};return o.length&&(a.properties=ct(e,r)),s.length&&(a.required=s),a},on=()=>({type:"null"}),nn=({},e)=>((0,B.default)(!e.isResponse,new P({message:"Please use ez.dateOut() for output.",...e})),{description:"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?$/.source,externalDocs:{url:$r}}),sn=({},e)=>((0,B.default)(e.isResponse,new P({message:"Please use ez.dateIn() for input.",...e})),{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",externalDocs:{url:$r}}),an=({},e)=>B.default.fail(new P({message:`Using z.date() within ${e.isResponse?"output":"input"} schema is forbidden. Please use ez.date${e.isResponse?"Out":"In"}() instead. Check out the documentation for details.`,...e})),pn=()=>({type:"boolean"}),dn=()=>({type:"integer",format:"bigint"}),cn=e=>e.every(t=>t instanceof S.z.ZodLiteral),ln=({keySchema:e,valueSchema:t},{next:r})=>{if(e instanceof S.z.ZodEnum||e instanceof S.z.ZodNativeEnum){let o=Object.values(e.enum),i={type:"object"};return o.length&&(i.properties=ct(S.z.object((0,d.fromPairs)((0,d.xprod)(o,[t]))),r),i.required=o),i}if(e instanceof S.z.ZodLiteral)return{type:"object",properties:ct(S.z.object({[e.value]:t}),r),required:[e.value]};if(e instanceof S.z.ZodUnion&&cn(e.options)){let o=(0,d.map)(s=>`${s.value}`,e.options),i=(0,d.fromPairs)((0,d.xprod)(o,[t]));return{type:"object",properties:ct(S.z.object(i),r),required:o}}return{type:"object",additionalProperties:r(t)}},mn=({_def:{minLength:e,maxLength:t},element:r},{next:o})=>{let i={type:"array",items:o(r)};return e&&(i.minItems=e.value),t&&(i.maxItems=t.value),i},un=({items:e,_def:{rest:t}},{next:r})=>({type:"array",prefixItems:e.map(r),items:t===null?{not:{}}:r(t)}),fn=({isEmail:e,isURL:t,minLength:r,maxLength:o,isUUID:i,isCUID:s,isCUID2:a,isULID:p,isIP:c,isEmoji:l,isDatetime:m,_def:{checks:y}})=>{let u=y.find(C=>C.kind==="regex"),x=y.find(C=>C.kind==="datetime"),z=u?u.regex:x?x.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"):void 0,T={type:"string"},L={"date-time":m,email:e,url:t,uuid:i,cuid:s,cuid2:a,ulid:p,ip:c,emoji:l};for(let C in L)if(L[C]){T.format=C;break}return r!==null&&(T.minLength=r),o!==null&&(T.maxLength=o),z&&(T.pattern=z.source),T},yn=({isInt:e,maxValue:t,minValue:r,_def:{checks:o}})=>{let i=o.find(({kind:y})=>y==="min"),s=r===null?e?Number.MIN_SAFE_INTEGER:-Number.MAX_VALUE:r,a=i?i.inclusive:!0,p=o.find(({kind:y})=>y==="max"),c=t===null?e?Number.MAX_SAFE_INTEGER:Number.MAX_VALUE:t,l=p?p.inclusive:!0,m={type:e?"integer":"number",format:e?"int64":"double"};return a?m.minimum=s:m.exclusiveMinimum=s,l?m.maximum=c:m.exclusiveMaximum=c,m},ct=({shape:e},t)=>(0,d.map)(t,e),gn=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return Fo?.[t]},Yr=e=>{let t=typeof e.type=="string"?[e.type]:e.type||[];return t.includes("null")?t:t.concat("null")},hn=(e,{isResponse:t,next:r})=>{let o=r(e.innerType()),{effect:i}=e._def;if(t&&i.type==="transform"&&!(0,Y.isReferenceObject)(o)){let s=_e(e,gn(o));return s&&["number","string","boolean"].includes(s)?{type:s}:r(S.z.any())}if(!t&&i.type==="preprocess"&&!(0,Y.isReferenceObject)(o)){let{type:s,...a}=o;return{...a,format:`${a.format||s} (preprocessed)`}}return o},xn=({_def:e},{isResponse:t,next:r})=>r(e[t?"out":"in"]),bn=(e,{next:t})=>t(e.unwrap()),Tn=({schema:e},{next:t,serializer:r,getRef:o,makeRef:i})=>{let s=r(e);return o(s)||(i(s,{}),i(s,t(e)))},Sn=(e,{next:t})=>t(e.unwrap().shape.raw),Qr=e=>e.length?(0,d.fromPairs)((0,d.zip)((0,d.range)(1,e.length+1).map(t=>`example${t}`),(0,d.map)((0,d.objOf)("value"),e))):void 0,Jr=(e,t,r=[])=>(0,d.pipe)(F,(0,d.map)((0,d.when)((0,d.both)(K,(0,d.complement)(Array.isArray)),(0,d.omit)(r))),Qr)({schema:e,variant:t?"parsed":"original",validate:!0}),Rn=(e,t)=>(0,d.pipe)(F,(0,d.filter)((0,d.has)(t)),(0,d.pluck)(t),Qr)({schema:e,variant:"original",validate:!0}),Pe=(e,t)=>e instanceof S.z.ZodObject?e:e instanceof S.z.ZodBranded?Pe(e.unwrap(),t):e instanceof S.z.ZodUnion||e instanceof S.z.ZodDiscriminatedUnion?e.options.map(r=>Pe(r,t)).reduce((r,o)=>r.merge(o.partial()),S.z.object({})):e instanceof S.z.ZodEffects?((0,B.default)(e._def.effect.type==="refinement",t),Pe(e._def.schema,t)):Pe(e._def.left,t).merge(Pe(e._def.right,t)),Wr=({path:e,method:t,schema:r,inputSources:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:c,description:l=`${t.toUpperCase()} ${e} Parameter`})=>{let{shape:m}=Pe(r,new P({message:"Using transformations on the top level schema is not allowed.",path:e,method:t,isResponse:!1})),y=Ko(e),u=o.includes("query"),x=o.includes("params"),z=o.includes("headers"),T=b=>x&&y.includes(b),L=b=>z&&Rt(b);return Object.keys(m).map(b=>({name:b,location:T(b)?"path":L(b)?"header":u?"query":void 0})).filter(b=>b.location!==void 0).map(({name:b,location:Ee})=>{let $=ce(m[b],{rules:{...c,...vt},onEach:Lt,onMissing:jt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:e,method:t}}),W=p==="components"?a(M(l,b),$):$;return{name:b,in:Ee,required:!m[b].isOptional(),description:$.description||l,schema:W,examples:Rn(r,b)}})},vt={ZodString:fn,ZodNumber:yn,ZodBigInt:dn,ZodBoolean:pn,ZodNull:on,ZodArray:mn,ZodTuple:un,ZodRecord:ln,ZodObject:rn,ZodLiteral:tn,ZodIntersection:Jo,ZodUnion:_o,ZodAny:$o,ZodDefault:Bo,ZodEnum:qr,ZodNativeEnum:qr,ZodEffects:hn,ZodOptional:Wo,ZodNullable:en,ZodDiscriminatedUnion:Yo,ZodBranded:bn,ZodDate:an,ZodCatch:qo,ZodPipeline:xn,ZodLazy:Tn,ZodReadonly:Xo,[_]:Go,[He]:Vo,[Ke]:sn,[Fe]:nn,[ne]:Sn},Lt=(e,{isResponse:t,prev:r})=>{if((0,Y.isReferenceObject)(r))return{};let{description:o}=e,i=e instanceof S.z.ZodLazy,s=r.type!==void 0,a=t&&je(e),p=!i&&s&&!a&&e.isNullable(),c=i?[]:F({schema:e,variant:t?"parsed":"original",validate:!0}),l={};return o&&(l.description=o),p&&(l.type=Yr(r)),c.length&&(l.examples=c.slice()),l},jt=(e,t)=>B.default.fail(new P({message:`Zod type ${e.constructor.name} is unsupported.`,...t})),Mt=(e,t)=>{if((0,Y.isReferenceObject)(e))return e;let r={...e};return r.properties&&(r.properties=(0,d.omit)(t,r.properties)),r.examples&&(r.examples=r.examples.map(o=>(0,d.omit)(t,o))),r.required&&(r.required=r.required.filter(o=>!t.includes(o))),r.allOf&&(r.allOf=r.allOf.map(o=>Mt(o,t))),r.oneOf&&(r.oneOf=r.oneOf.map(o=>Mt(o,t))),r},Xr=e=>(0,Y.isReferenceObject)(e)?e:(0,d.omit)(["examples"],e),eo=({method:e,path:t,schema:r,mimeTypes:o,variant:i,serializer:s,getRef:a,makeRef:p,composition:c,hasMultipleStatusCodes:l,statusCode:m,brandHandling:y,description:u=`${e.toUpperCase()} ${t} ${At(i)} response ${l?m:""}`.trim()})=>{let x=Xr(ce(r,{rules:{...y,...vt},onEach:Lt,onMissing:jt,ctx:{isResponse:!0,serializer:s,getRef:a,makeRef:p,path:t,method:e}})),z={schema:c==="components"?p(M(u),x):x,examples:Jr(r,!0)};return{description:u,content:(0,d.fromPairs)((0,d.xprod)(o,[z]))}},On=()=>({type:"http",scheme:"basic"}),An=({format:e})=>{let t={type:"http",scheme:"bearer"};return e&&(t.bearerFormat=e),t},Pn=({name:e},t)=>{let r={type:"apiKey",in:"query",name:e};return t?.includes("body")&&(t?.includes("query")?(r["x-in-alternative"]="body",r.description=`${e} CAN also be supplied within the request body`):(r["x-in-actual"]="body",r.description=`${e} MUST be supplied within the request body instead of query`)),r},Cn=({name:e})=>({type:"apiKey",in:"header",name:e}),In=({name:e})=>({type:"apiKey",in:"cookie",name:e}),wn=({url:e})=>({type:"openIdConnect",openIdConnectUrl:e}),En=({flows:e={}})=>({type:"oauth2",flows:(0,d.map)(t=>({...t,scopes:t.scopes||{}}),(0,d.reject)(d.isNil,e))}),to=(e,t)=>{let r={basic:On,bearer:An,input:Pn,header:Cn,cookie:In,openid:wn,oauth2:En};return tt(e,o=>r[o.type](o,t))},lt=e=>"or"in e?e.or.map(t=>"and"in t?(0,d.mergeAll)((0,d.map)(({name:r,scopes:o})=>(0,d.objOf)(r,o),t.and)):{[t.name]:t.scopes}):"and"in e?lt(wt(e)):lt({or:[e]}),ro=({method:e,path:t,schema:r,mimeTypes:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:c,paramNames:l,description:m=`${e.toUpperCase()} ${t} Request body`})=>{let y=Xr(Mt(ce(r,{rules:{...c,...vt},onEach:Lt,onMissing:jt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:t,method:e}}),l)),u={schema:p==="components"?a(M(m),y):y,examples:Jr(r,!1,l)};return{description:m,content:(0,d.fromPairs)((0,d.xprod)(o,[u]))}},oo=e=>Object.keys(e).map(t=>{let r=e[t],o={name:t,description:typeof r=="string"?r:r.description};return typeof r=="object"&&r.url&&(o.externalDocs={url:r.url}),o}),Dt=e=>e.length<=Br?e:e.slice(0,Br-1)+"\u2026";var mt=class extends io.OpenApiBuilder{lastSecuritySchemaIds=new Map;lastOperationIdSuffixes=new Map;makeRef(t,r){return this.addSchema(t,r),this.getRef(t)}getRef(t){return t in(this.rootDoc.components?.schemas||{})?{$ref:`#/components/schemas/${t}`}:void 0}ensureUniqOperationId(t,r,o){let i=o||M(r,t),s=this.lastOperationIdSuffixes.get(i);return s===void 0?(this.lastOperationIdSuffixes.set(i,1),i):(o&&no.default.fail(new P({message:`Duplicated operationId: "${o}"`,method:r,isResponse:!1,path:t})),s++,this.lastOperationIdSuffixes.set(i,s),`${i}${s}`)}ensureUniqSecuritySchemaName(t){let r=JSON.stringify(t);for(let i in this.rootDoc.components?.securitySchemes||{})if(r===JSON.stringify(this.rootDoc.components?.securitySchemes?.[i]))return i;let o=(this.lastSecuritySchemaIds.get(t.type)||0)+1;return this.lastSecuritySchemaIds.set(t.type,o),`${t.type.toUpperCase()}_${o}`}constructor({routing:t,config:r,title:o,version:i,serverUrl:s,descriptions:a,brandHandling:p,hasSummaryFromDescription:c=!0,composition:l="inline",serializer:m=Ge}){super(),this.addInfo({title:o,version:i});for(let u of typeof s=="string"?[s]:s)this.addServer({url:u});de({routing:t,onEndpoint:(u,x,z)=>{let T=z,L={path:x,method:T,endpoint:u,composition:l,serializer:m,brandHandling:p,getRef:this.getRef.bind(this),makeRef:this.makeRef.bind(this)},[C,b]=["short","long"].map(u.getDescription.bind(u)),Ee=C?Dt(C):c&&b?Dt(b):void 0,$=u.getTags(),W=r.inputSources?.[T]||Tt[T],me=this.ensureUniqOperationId(x,T,u.getOperationId(T)),ze=Wr({...L,inputSources:W,schema:u.getSchema("input"),description:a?.requestParameter?.call(null,{method:T,path:x,operationId:me})}),qe={};for(let k of["positive","negative"]){let X=u.getResponses(k);for(let{mimeTypes:Ze,schema:O,statusCodes:A}of X)for(let I of A)qe[I]=eo({...L,variant:k,schema:O,mimeTypes:Ze,statusCode:I,hasMultipleStatusCodes:X.length>1||A.length>1,description:a?.[`${k}Response`]?.call(null,{method:T,path:x,operationId:me,statusCode:I})})}let bt=W.includes("body")?ro({...L,paramNames:(0,so.pluck)("name",ze),schema:u.getSchema("input"),mimeTypes:u.getMimeTypes("input"),description:a?.requestBody?.call(null,{method:T,path:x,operationId:me})}):void 0,$e=lt(tt(to(u.getSecurity(),W),k=>{let X=this.ensureUniqSecuritySchemaName(k),Ze=["oauth2","openIdConnect"].includes(k.type)?u.getScopes().slice():[];return this.addSecurityScheme(X,k),{name:X,scopes:Ze}}));this.addPath(Gr(x),{[T]:{operationId:me,summary:Ee,description:b,tags:$.length>0?$:void 0,parameters:ze.length>0?ze:void 0,requestBody:bt,security:$e.length>0?$e:void 0,responses:qe}})}}),this.rootDoc.tags=r.tags?oo(r.tags):[]}};var kt=R(require("http"),1);var zn=({fnMethod:e,requestProps:t})=>({method:"GET",header:e(()=>N.json),...t}),Zn=({fnMethod:e,responseProps:t})=>{let r={writableEnded:!1,statusCode:200,statusMessage:kt.default.STATUS_CODES[200],set:e(()=>r),setHeader:e(()=>r),header:e(()=>r),status:e(o=>(r.statusCode=o,r.statusMessage=kt.default.STATUS_CODES[o],r)),json:e(()=>r),send:e(()=>r),end:e(()=>(r.writableEnded=!0,r)),locals:{},...t};return r},Nn=({fnMethod:e,loggerProps:t})=>({info:e(),warn:e(),error:e(),debug:e(),...t}),ao=async({endpoint:e,requestProps:t,responseProps:r,configProps:o,loggerProps:i,fnMethod:s})=>{let a=s||(await wr([{moduleName:"vitest",moduleExport:"vi"},{moduleName:"@jest/globals",moduleExport:"jest"}])).fn,p=zn({fnMethod:a,requestProps:t}),c=Zn({fnMethod:a,responseProps:r}),l=Nn({fnMethod:a,loggerProps:i}),m={cors:!1,logger:l,...o};return await e.execute({request:p,response:c,config:m,logger:l}),{requestMock:p,responseMock:c,loggerMock:l}};var E=R(require("typescript"),1);var D=R(require("typescript"),1),Ce=require("ramda"),n=D.default.factory,Q=[n.createModifier(D.default.SyntaxKind.ExportKeyword)],Mn=[n.createModifier(D.default.SyntaxKind.AsyncKeyword)],vn=[n.createModifier(D.default.SyntaxKind.PublicKeyword),n.createModifier(D.default.SyntaxKind.ReadonlyKeyword)],po=[n.createModifier(D.default.SyntaxKind.ProtectedKeyword),n.createModifier(D.default.SyntaxKind.ReadonlyKeyword)],Ht=n.createTemplateHead(""),Ie=n.createTemplateTail(""),Ut=n.createTemplateMiddle(" "),Ft=e=>n.createTemplateLiteralType(Ht,e.map((t,r)=>n.createTemplateLiteralTypeSpan(n.createTypeReferenceNode(t),r===e.length-1?Ie:Ut))),Kt=Ft(["M","P"]),ut=(e,t,r)=>n.createParameterDeclaration(r,void 0,e,void 0,t,void 0),ft=(e,t)=>(0,Ce.chain)(([r,o])=>[ut(n.createIdentifier(r),o,t)],(0,Ce.toPairs)(e)),Bt=(e,t)=>n.createExpressionWithTypeArguments(n.createIdentifier("Record"),[typeof e=="number"?n.createKeywordTypeNode(e):n.createTypeReferenceNode(e),n.createKeywordTypeNode(t)]),co=e=>n.createConstructorDeclaration(void 0,e,n.createBlock([])),lo=(e,t)=>n.createPropertySignature(void 0,e,void 0,n.createTypeReferenceNode(t)),J=(e,t,r)=>n.createVariableDeclarationList([n.createVariableDeclaration(e,void 0,r,t)],D.default.NodeFlags.Const),qt=(e,t)=>n.createTypeAliasDeclaration(Q,e,void 0,n.createUnionTypeNode(t.map(r=>n.createLiteralTypeNode(n.createStringLiteral(r))))),yt=(e,t)=>n.createTypeAliasDeclaration(Q,e,void 0,t),mo=(e,t,r)=>n.createPropertyDeclaration(vn,e,void 0,t,r),uo=(e,t,r)=>n.createClassDeclaration(Q,e,void 0,void 0,[t,...r]),fo=(e,t)=>n.createTypeReferenceNode("Promise",[n.createIndexedAccessTypeNode(n.createTypeReferenceNode(e),t)]),yo=()=>n.createTypeReferenceNode("Promise",[n.createKeywordTypeNode(D.default.SyntaxKind.AnyKeyword)]),go=(e,t,r)=>n.createInterfaceDeclaration(Q,e,void 0,t,r),ho=e=>(0,Ce.chain)(([t,r])=>[n.createTypeParameterDeclaration([],t,n.createTypeReferenceNode(r))],(0,Ce.toPairs)(e)),$t=(e,t,r)=>n.createArrowFunction(r?Mn:void 0,void 0,e.map(o=>ut(o)),void 0,void 0,t),Vt=(e,t,r)=>n.createCallExpression(n.createPropertyAccessExpression(n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("Object"),"keys"),void 0,[e]),"reduce"),void 0,[n.createArrowFunction(void 0,void 0,ft({acc:void 0,key:void 0}),void 0,void 0,t),r]),xo=(...e)=>`"${e.join(" ")}"`;var bo=["get","post","put","delete","patch"];var h=R(require("typescript"),1),ht=require("zod");var q=R(require("typescript"),1),{factory:gt}=q.default,Gt=(e,t)=>{q.default.addSyntheticLeadingComment(e,q.default.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0)},we=(e,t,r)=>{let o=gt.createTypeAliasDeclaration(void 0,gt.createIdentifier(t),void 0,e);return r&&Gt(o,r),o},_t=(e,t)=>{let r=q.default.createSourceFile("print.ts","",q.default.ScriptTarget.Latest,!1,q.default.ScriptKind.TS);return q.default.createPrinter(t).printNode(q.default.EmitHint.Unspecified,e,r)},Ln=/^[A-Za-z_$][A-Za-z0-9_$]*$/,To=e=>Ln.test(e)?gt.createIdentifier(e):gt.createStringLiteral(e);var{factory:f}=h.default,jn={[h.default.SyntaxKind.AnyKeyword]:"",[h.default.SyntaxKind.BigIntKeyword]:BigInt(0),[h.default.SyntaxKind.BooleanKeyword]:!1,[h.default.SyntaxKind.NumberKeyword]:0,[h.default.SyntaxKind.ObjectKeyword]:{},[h.default.SyntaxKind.StringKeyword]:"",[h.default.SyntaxKind.UndefinedKeyword]:void 0},Dn=({value:e})=>f.createLiteralTypeNode(typeof e=="number"?f.createNumericLiteral(e):typeof e=="boolean"?e?f.createTrue():f.createFalse():f.createStringLiteral(e)),kn=({shape:e},{isResponse:t,next:r,optionalPropStyle:{withQuestionMark:o}})=>{let i=Object.entries(e).map(([s,a])=>{let p=t&&je(a)?a instanceof ht.z.ZodOptional:a.isOptional(),c=f.createPropertySignature(void 0,To(s),p&&o?f.createToken(h.default.SyntaxKind.QuestionToken):void 0,r(a));return a.description&&Gt(c,a.description),c});return f.createTypeLiteralNode(i)},Hn=({element:e},{next:t})=>f.createArrayTypeNode(t(e)),Un=({options:e})=>f.createUnionTypeNode(e.map(t=>f.createLiteralTypeNode(f.createStringLiteral(t)))),So=({options:e},{next:t})=>f.createUnionTypeNode(e.map(t)),Fn=e=>jn?.[e.kind],Kn=(e,{next:t,isResponse:r})=>{let o=t(e.innerType()),i=e._def.effect;if(r&&i.type==="transform"){let s=_e(e,Fn(o)),a={number:h.default.SyntaxKind.NumberKeyword,bigint:h.default.SyntaxKind.BigIntKeyword,boolean:h.default.SyntaxKind.BooleanKeyword,string:h.default.SyntaxKind.StringKeyword,undefined:h.default.SyntaxKind.UndefinedKeyword,object:h.default.SyntaxKind.ObjectKeyword};return f.createKeywordTypeNode(s&&a[s]||h.default.SyntaxKind.AnyKeyword)}return o},Bn=e=>f.createUnionTypeNode(Object.values(e.enum).map(t=>f.createLiteralTypeNode(typeof t=="number"?f.createNumericLiteral(t):f.createStringLiteral(t)))),qn=(e,{next:t,optionalPropStyle:{withUndefined:r}})=>{let o=t(e.unwrap());return r?f.createUnionTypeNode([o,f.createKeywordTypeNode(h.default.SyntaxKind.UndefinedKeyword)]):o},$n=(e,{next:t})=>f.createUnionTypeNode([t(e.unwrap()),f.createLiteralTypeNode(f.createNull())]),Vn=({items:e,_def:{rest:t}},{next:r})=>f.createTupleTypeNode(e.map(r).concat(t===null?[]:f.createRestTypeNode(r(t)))),Gn=({keySchema:e,valueSchema:t},{next:r})=>f.createExpressionWithTypeArguments(f.createIdentifier("Record"),[e,t].map(r)),_n=({_def:e},{next:t})=>f.createIntersectionTypeNode([e.left,e.right].map(t)),Yn=({_def:e},{next:t})=>t(e.innerType),le=e=>()=>f.createKeywordTypeNode(e),Qn=(e,{next:t})=>t(e.unwrap()),Jn=(e,{next:t})=>t(e.unwrap()),Wn=({_def:e},{next:t})=>t(e.innerType),Xn=({_def:e},{next:t,isResponse:r})=>t(e[r?"out":"in"]),ei=()=>f.createLiteralTypeNode(f.createNull()),ti=({schema:e},{getAlias:t,makeAlias:r,next:o,serializer:i})=>{let s=`Type${i(e)}`;return t(s)||(r(s,f.createLiteralTypeNode(f.createNull())),r(s,o(e)))},ri=e=>{let t=e.unwrap(),r=f.createKeywordTypeNode(h.default.SyntaxKind.StringKeyword),o=f.createTypeReferenceNode("Buffer"),i=f.createUnionTypeNode([r,o]);return t instanceof ht.z.ZodString?r:t instanceof ht.z.ZodUnion?i:o},oi=(e,{next:t})=>t(e.unwrap().shape.raw),ni={ZodString:le(h.default.SyntaxKind.StringKeyword),ZodNumber:le(h.default.SyntaxKind.NumberKeyword),ZodBigInt:le(h.default.SyntaxKind.BigIntKeyword),ZodBoolean:le(h.default.SyntaxKind.BooleanKeyword),ZodAny:le(h.default.SyntaxKind.AnyKeyword),[Fe]:le(h.default.SyntaxKind.StringKeyword),[Ke]:le(h.default.SyntaxKind.StringKeyword),ZodNull:ei,ZodArray:Hn,ZodTuple:Vn,ZodRecord:Gn,ZodObject:kn,ZodLiteral:Dn,ZodIntersection:_n,ZodUnion:So,ZodDefault:Yn,ZodEnum:Un,ZodNativeEnum:Bn,ZodEffects:Kn,ZodOptional:qn,ZodNullable:$n,ZodDiscriminatedUnion:So,ZodBranded:Qn,ZodCatch:Wn,ZodPipeline:Xn,ZodLazy:ti,ZodReadonly:Jn,[_]:ri,[ne]:oi},Be=(e,{brandHandling:t,ctx:r})=>ce(e,{rules:{...t,...ni},onMissing:()=>f.createKeywordTypeNode(h.default.SyntaxKind.AnyKeyword),ctx:r});var xt=class{program=[];usage=[];registry=new Map;paths=[];aliases=new Map;ids={pathType:n.createIdentifier("Path"),methodType:n.createIdentifier("Method"),methodPathType:n.createIdentifier("MethodPath"),inputInterface:n.createIdentifier("Input"),posResponseInterface:n.createIdentifier("PositiveResponse"),negResponseInterface:n.createIdentifier("NegativeResponse"),responseInterface:n.createIdentifier("Response"),jsonEndpointsConst:n.createIdentifier("jsonEndpoints"),endpointTagsConst:n.createIdentifier("endpointTags"),providerType:n.createIdentifier("Provider"),implementationType:n.createIdentifier("Implementation"),clientClass:n.createIdentifier("ExpressZodAPIClient"),keyParameter:n.createIdentifier("key"),pathParameter:n.createIdentifier("path"),paramsArgument:n.createIdentifier("params"),methodParameter:n.createIdentifier("method"),accumulator:n.createIdentifier("acc"),provideMethod:n.createIdentifier("provide"),implementationArgument:n.createIdentifier("implementation"),headersProperty:n.createIdentifier("headers"),hasBodyConst:n.createIdentifier("hasBody"),undefinedValue:n.createIdentifier("undefined"),bodyProperty:n.createIdentifier("body"),responseConst:n.createIdentifier("response"),searchParamsConst:n.createIdentifier("searchParams"),exampleImplementationConst:n.createIdentifier("exampleImplementation"),clientConst:n.createIdentifier("client")};interfaces=[];getAlias(t){return this.aliases.has(t)?n.createTypeReferenceNode(t):void 0}makeAlias(t,r){return this.aliases.set(t,we(r,t)),this.getAlias(t)}constructor({routing:t,brandHandling:r,variant:o="client",serializer:i=Ge,splitResponse:s=!1,optionalPropStyle:a={withQuestionMark:!0,withUndefined:!0}}){de({routing:t,onEndpoint:(O,A,I)=>{let ue={serializer:i,getAlias:this.getAlias.bind(this),makeAlias:this.makeAlias.bind(this),optionalPropStyle:a},Ne=M(I,A,"input"),Me=Be(O.getSchema("input"),{brandHandling:r,ctx:{...ue,isResponse:!1}}),Z=s?M(I,A,"positive.response"):void 0,Yt=O.getSchema("positive"),Qt=s?Be(Yt,{brandHandling:r,ctx:{...ue,isResponse:!0}}):void 0,ve=s?M(I,A,"negative.response"):void 0,Jt=O.getSchema("negative"),Wt=s?Be(Jt,{brandHandling:r,ctx:{...ue,isResponse:!0}}):void 0,Xt=M(I,A,"response"),Oo=Z&&ve?n.createUnionTypeNode([n.createTypeReferenceNode(Z),n.createTypeReferenceNode(ve)]):Be(Yt.or(Jt),{brandHandling:r,ctx:{...ue,isResponse:!0}});this.program.push(we(Me,Ne)),Qt&&Z&&this.program.push(we(Qt,Z)),Wt&&ve&&this.program.push(we(Wt,ve)),this.program.push(we(Oo,Xt)),I!=="options"&&(this.paths.push(A),this.registry.set({method:I,path:A},{input:Ne,positive:Z,negative:ve,response:Xt,isJson:O.getMimeTypes("positive").includes(N.json),tags:O.getTags()}))}}),this.program.unshift(...this.aliases.values()),this.program.push(qt(this.ids.pathType,this.paths)),this.program.push(qt(this.ids.methodType,bo)),this.program.push(yt(this.ids.methodPathType,Ft([this.ids.methodType,this.ids.pathType])));let p=[n.createHeritageClause(E.default.SyntaxKind.ExtendsKeyword,[Bt(this.ids.methodPathType,E.default.SyntaxKind.AnyKeyword)])];this.interfaces.push({id:this.ids.inputInterface,kind:"input",props:[]}),s&&this.interfaces.push({id:this.ids.posResponseInterface,kind:"positive",props:[]},{id:this.ids.negResponseInterface,kind:"negative",props:[]}),this.interfaces.push({id:this.ids.responseInterface,kind:"response",props:[]});let c=[],l=[];for(let[{method:O,path:A},{isJson:I,tags:ue,...Ne}]of this.registry){let Me=xo(O,A);for(let Z of this.interfaces)Z.kind in Ne&&Z.props.push(lo(Me,Ne[Z.kind]));o!=="types"&&(I&&c.push(n.createPropertyAssignment(Me,n.createTrue())),l.push(n.createPropertyAssignment(Me,n.createArrayLiteralExpression(ue.map(Z=>n.createStringLiteral(Z))))))}for(let{id:O,props:A}of this.interfaces)this.program.push(go(O,p,A));if(o==="types")return;let m=n.createVariableStatement(Q,J(this.ids.jsonEndpointsConst,n.createObjectLiteralExpression(c))),y=n.createVariableStatement(Q,J(this.ids.endpointTagsConst,n.createObjectLiteralExpression(l))),u=yt(this.ids.providerType,n.createFunctionTypeNode(ho({M:this.ids.methodType,P:this.ids.pathType}),ft({method:n.createTypeReferenceNode("M"),path:n.createTypeReferenceNode("P"),params:n.createIndexedAccessTypeNode(n.createTypeReferenceNode(this.ids.inputInterface),Kt)}),fo(this.ids.responseInterface,Kt))),x=yt(this.ids.implementationType,n.createFunctionTypeNode(void 0,ft({method:n.createTypeReferenceNode(this.ids.methodType),path:n.createKeywordTypeNode(E.default.SyntaxKind.StringKeyword),params:Bt(E.default.SyntaxKind.StringKeyword,E.default.SyntaxKind.AnyKeyword)}),yo())),z=n.createTemplateExpression(n.createTemplateHead(":"),[n.createTemplateSpan(this.ids.keyParameter,Ie)]),T=Vt(this.ids.paramsArgument,n.createCallExpression(n.createPropertyAccessExpression(this.ids.accumulator,"replace"),void 0,[z,n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter)]),this.ids.pathParameter),L=Vt(this.ids.paramsArgument,n.createConditionalExpression(n.createBinaryExpression(n.createCallExpression(n.createPropertyAccessExpression(this.ids.pathParameter,"indexOf"),void 0,[z]),E.default.SyntaxKind.GreaterThanEqualsToken,n.createNumericLiteral(0)),void 0,this.ids.accumulator,void 0,n.createObjectLiteralExpression([n.createSpreadAssignment(this.ids.accumulator),n.createPropertyAssignment(n.createComputedPropertyName(this.ids.keyParameter),n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter))])),n.createObjectLiteralExpression()),C=uo(this.ids.clientClass,co([ut(this.ids.implementationArgument,n.createTypeReferenceNode(this.ids.implementationType),po)]),[mo(this.ids.provideMethod,n.createTypeReferenceNode(this.ids.providerType),$t([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createCallExpression(n.createPropertyAccessExpression(n.createThis(),this.ids.implementationArgument),void 0,[this.ids.methodParameter,T,L]),!0))]);this.program.push(m,y,u,x,C);let b=n.createPropertyAssignment(this.ids.methodParameter,n.createCallExpression(n.createPropertyAccessExpression(this.ids.methodParameter,"toUpperCase"),void 0,void 0)),Ee=n.createPropertyAssignment(this.ids.headersProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createObjectLiteralExpression([n.createPropertyAssignment(n.createStringLiteral("Content-Type"),n.createStringLiteral(N.json))]),void 0,this.ids.undefinedValue)),$=n.createPropertyAssignment(this.ids.bodyProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("JSON"),"stringify"),void 0,[this.ids.paramsArgument]),void 0,this.ids.undefinedValue)),W=n.createVariableStatement(void 0,J(this.ids.responseConst,n.createAwaitExpression(n.createCallExpression(n.createIdentifier("fetch"),void 0,[n.createTemplateExpression(n.createTemplateHead("https://example.com"),[n.createTemplateSpan(this.ids.pathParameter,n.createTemplateMiddle("")),n.createTemplateSpan(this.ids.searchParamsConst,Ie)]),n.createObjectLiteralExpression([b,Ee,$])])))),me=n.createVariableStatement(void 0,J(this.ids.hasBodyConst,n.createLogicalNot(n.createCallExpression(n.createPropertyAccessExpression(n.createArrayLiteralExpression([n.createStringLiteral("get"),n.createStringLiteral("delete")]),"includes"),void 0,[this.ids.methodParameter])))),ze=n.createVariableStatement(void 0,J(this.ids.searchParamsConst,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createStringLiteral(""),void 0,n.createTemplateExpression(n.createTemplateHead("?"),[n.createTemplateSpan(n.createNewExpression(n.createIdentifier("URLSearchParams"),void 0,[this.ids.paramsArgument]),Ie)])))),[qe,bt]=["json","text"].map(O=>n.createReturnStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.responseConst,O),void 0,void 0))),$e=n.createIfStatement(n.createBinaryExpression(n.createTemplateExpression(Ht,[n.createTemplateSpan(this.ids.methodParameter,Ut),n.createTemplateSpan(this.ids.pathParameter,Ie)]),E.default.SyntaxKind.InKeyword,this.ids.jsonEndpointsConst),n.createBlock([qe])),k=n.createVariableStatement(Q,J(this.ids.exampleImplementationConst,$t([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createBlock([me,ze,W,$e,bt]),!0),n.createTypeReferenceNode(this.ids.implementationType))),X=n.createExpressionStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.clientConst,this.ids.provideMethod),void 0,[n.createStringLiteral("get"),n.createStringLiteral("/v1/user/retrieve"),n.createObjectLiteralExpression([n.createPropertyAssignment("id",n.createStringLiteral("10"))])])),Ze=n.createVariableStatement(void 0,J(this.ids.clientConst,n.createNewExpression(this.ids.clientClass,void 0,[this.ids.exampleImplementationConst])));this.usage.push(k,Ze,X)}printUsage(t){return this.usage.length?this.usage.map(r=>typeof r=="string"?r:_t(r,t)).join(`
|
|
20
|
+
`)};var Dr=e=>{e.startupLogo!==!1&&console.log(vr());let t=e.errorHandler||be,r=Ar(e.logger)?e.logger:new ae(e.logger);r.debug("Running","v19.2.1 (CJS)");let o=Mr({rootLogger:r,config:e}),i=zr({rootLogger:r,errorHandler:t}),s=Er({rootLogger:r,errorHandler:t});return{rootLogger:r,errorHandler:t,notFoundHandler:i,parserFailureHandler:s,loggingMiddleware:o}},kr=(e,t)=>{let{rootLogger:r,notFoundHandler:o,loggingMiddleware:i}=Dr(e);return Nt({app:e.app.use(i),routing:t,rootLogger:r,config:e}),{notFoundHandler:o,logger:r}},Hr=async(e,t)=>{let{rootLogger:r,notFoundHandler:o,parserFailureHandler:i,loggingMiddleware:s}=Dr(e),a=(0,pt.default)().disable("x-powered-by").use(s);if(e.server.compression){let m=await pe("compression");a.use(m(typeof e.server.compression=="object"?e.server.compression:void 0))}let p={json:[e.server.jsonParser||pt.default.json()],raw:[e.server.rawParser||pt.default.raw(),Nr],upload:e.server.upload?await Zr({config:e,rootLogger:r}):[]};e.server.beforeRouting&&await e.server.beforeRouting({app:a,logger:r}),Nt({app:a,routing:t,rootLogger:r,config:e,parsers:p}),a.use(i,o);let c=(m,y)=>m.listen(y,()=>{r.info("Listening",y)}),l={httpServer:c(Lr.default.createServer(a),e.server.listen),httpsServer:e.https?c(jr.default.createServer(e.https.options,a),e.https.listen):void 0};return{app:a,...l,logger:r}};var no=R(require("assert/strict"),1),io=require("openapi3-ts/oas31"),so=require("ramda");var B=R(require("assert/strict"),1),Y=require("openapi3-ts/oas31"),d=require("ramda"),S=require("zod");var Ae=require("zod");var dt=e=>!isNaN(e.getTime());var Fe=Symbol("DateIn"),Ur=()=>Ae.z.union([Ae.z.string().date(),Ae.z.string().datetime(),Ae.z.string().datetime({local:!0})]).transform(t=>new Date(t)).pipe(Ae.z.date().refine(dt)).brand(Fe);var Fr=require("zod");var Ke=Symbol("DateOut"),Kr=()=>Fr.z.date().refine(dt).transform(e=>e.toISOString()).brand(Ke);var ce=(e,{onEach:t,rules:r,onMissing:o,ctx:i={}})=>{let s=r[e._def[g]?.brand]||r[e._def.typeName],p=s?s(e,{...i,next:l=>ce(l,{ctx:i,onEach:t,rules:r,onMissing:o})}):o(e,i),c=t&&t(e,{prev:p,...i});return c?{...p,...c}:p};var Br=50,$r="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",Fo={integer:0,number:0,string:"",boolean:!1,object:{},null:null,array:[]},Vr=/:([A-Za-z0-9_]+)/g,Ko=e=>e.match(Vr)?.map(t=>t.slice(1))||[],Gr=e=>e.replace(Vr,t=>`{${t.slice(1)}}`),Bo=({_def:e},{next:t})=>({...t(e.innerType),default:e[g]?.defaultLabel||e.defaultValue()}),qo=({_def:{innerType:e}},{next:t})=>t(e),$o=()=>({format:"any"}),Vo=({},e)=>((0,B.default)(!e.isResponse,new P({message:"Please use ez.upload() only for input.",...e})),{type:"string",format:"binary"}),Go=e=>{let t=e.unwrap();return{type:"string",format:t instanceof S.z.ZodString?t._def.checks.find(r=>r.kind==="base64")?"byte":"file":"binary"}},_o=({options:e},{next:t})=>({oneOf:e.map(t)}),Yo=({options:e,discriminator:t},{next:r})=>({discriminator:{propertyName:t},oneOf:e.map(r)}),Qo=e=>{let[t,r]=e.filter(i=>!(0,Y.isReferenceObject)(i)&&i.type==="object"&&Object.keys(i).every(s=>["type","properties","required","examples"].includes(s)));(0,B.default)(t&&r,"Can not flatten objects");let o={type:"object"};return(t.properties||r.properties)&&(o.properties=(0,d.mergeDeepWith)((i,s)=>Array.isArray(i)&&Array.isArray(s)?(0,d.concat)(i,s):i===s?s:B.default.fail("Can not flatten properties"),t.properties||{},r.properties||{})),(t.required||r.required)&&(o.required=(0,d.union)(t.required||[],r.required||[])),(t.examples||r.examples)&&(o.examples=oe(t.examples||[],r.examples||[],([i,s])=>(0,d.mergeDeepRight)(i,s))),o},Jo=({_def:{left:e,right:t}},{next:r})=>{let o=[e,t].map(r);try{return Qo(o)}catch{}return{allOf:o}},Wo=(e,{next:t})=>t(e.unwrap()),Xo=(e,{next:t})=>t(e.unwrap()),en=(e,{next:t})=>{let r=t(e.unwrap());return(0,Y.isReferenceObject)(r)||(r.type=Yr(r)),r},_r=e=>{let t=(0,d.toLower)((0,d.type)(e));return typeof e=="bigint"?"integer":t==="number"||t==="string"||t==="boolean"||t==="object"||t==="null"||t==="array"?t:void 0},qr=e=>({type:_r(Object.values(e.enum)[0]),enum:Object.values(e.enum)}),tn=({value:e})=>({type:_r(e),const:e}),rn=(e,{isResponse:t,next:r})=>{let o=Object.keys(e.shape),i=p=>t&&je(p)?p instanceof S.z.ZodOptional:p.isOptional(),s=o.filter(p=>!i(e.shape[p])),a={type:"object"};return o.length&&(a.properties=ct(e,r)),s.length&&(a.required=s),a},on=()=>({type:"null"}),nn=({},e)=>((0,B.default)(!e.isResponse,new P({message:"Please use ez.dateOut() for output.",...e})),{description:"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?$/.source,externalDocs:{url:$r}}),sn=({},e)=>((0,B.default)(e.isResponse,new P({message:"Please use ez.dateIn() for input.",...e})),{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",externalDocs:{url:$r}}),an=({},e)=>B.default.fail(new P({message:`Using z.date() within ${e.isResponse?"output":"input"} schema is forbidden. Please use ez.date${e.isResponse?"Out":"In"}() instead. Check out the documentation for details.`,...e})),pn=()=>({type:"boolean"}),dn=()=>({type:"integer",format:"bigint"}),cn=e=>e.every(t=>t instanceof S.z.ZodLiteral),ln=({keySchema:e,valueSchema:t},{next:r})=>{if(e instanceof S.z.ZodEnum||e instanceof S.z.ZodNativeEnum){let o=Object.values(e.enum),i={type:"object"};return o.length&&(i.properties=ct(S.z.object((0,d.fromPairs)((0,d.xprod)(o,[t]))),r),i.required=o),i}if(e instanceof S.z.ZodLiteral)return{type:"object",properties:ct(S.z.object({[e.value]:t}),r),required:[e.value]};if(e instanceof S.z.ZodUnion&&cn(e.options)){let o=(0,d.map)(s=>`${s.value}`,e.options),i=(0,d.fromPairs)((0,d.xprod)(o,[t]));return{type:"object",properties:ct(S.z.object(i),r),required:o}}return{type:"object",additionalProperties:r(t)}},mn=({_def:{minLength:e,maxLength:t},element:r},{next:o})=>{let i={type:"array",items:o(r)};return e&&(i.minItems=e.value),t&&(i.maxItems=t.value),i},un=({items:e,_def:{rest:t}},{next:r})=>({type:"array",prefixItems:e.map(r),items:t===null?{not:{}}:r(t)}),fn=({isEmail:e,isURL:t,minLength:r,maxLength:o,isUUID:i,isCUID:s,isCUID2:a,isULID:p,isIP:c,isEmoji:l,isDatetime:m,_def:{checks:y}})=>{let u=y.find(C=>C.kind==="regex"),x=y.find(C=>C.kind==="datetime"),z=u?u.regex:x?x.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"):void 0,T={type:"string"},L={"date-time":m,email:e,url:t,uuid:i,cuid:s,cuid2:a,ulid:p,ip:c,emoji:l};for(let C in L)if(L[C]){T.format=C;break}return r!==null&&(T.minLength=r),o!==null&&(T.maxLength=o),z&&(T.pattern=z.source),T},yn=({isInt:e,maxValue:t,minValue:r,_def:{checks:o}})=>{let i=o.find(({kind:y})=>y==="min"),s=r===null?e?Number.MIN_SAFE_INTEGER:-Number.MAX_VALUE:r,a=i?i.inclusive:!0,p=o.find(({kind:y})=>y==="max"),c=t===null?e?Number.MAX_SAFE_INTEGER:Number.MAX_VALUE:t,l=p?p.inclusive:!0,m={type:e?"integer":"number",format:e?"int64":"double"};return a?m.minimum=s:m.exclusiveMinimum=s,l?m.maximum=c:m.exclusiveMaximum=c,m},ct=({shape:e},t)=>(0,d.map)(t,e),gn=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return Fo?.[t]},Yr=e=>{let t=typeof e.type=="string"?[e.type]:e.type||[];return t.includes("null")?t:t.concat("null")},hn=(e,{isResponse:t,next:r})=>{let o=r(e.innerType()),{effect:i}=e._def;if(t&&i.type==="transform"&&!(0,Y.isReferenceObject)(o)){let s=_e(e,gn(o));return s&&["number","string","boolean"].includes(s)?{type:s}:r(S.z.any())}if(!t&&i.type==="preprocess"&&!(0,Y.isReferenceObject)(o)){let{type:s,...a}=o;return{...a,format:`${a.format||s} (preprocessed)`}}return o},xn=({_def:e},{isResponse:t,next:r})=>r(e[t?"out":"in"]),bn=(e,{next:t})=>t(e.unwrap()),Tn=({schema:e},{next:t,serializer:r,getRef:o,makeRef:i})=>{let s=r(e);return o(s)||(i(s,{}),i(s,t(e)))},Sn=(e,{next:t})=>t(e.unwrap().shape.raw),Qr=e=>e.length?(0,d.fromPairs)((0,d.zip)((0,d.range)(1,e.length+1).map(t=>`example${t}`),(0,d.map)((0,d.objOf)("value"),e))):void 0,Jr=(e,t,r=[])=>(0,d.pipe)(F,(0,d.map)((0,d.when)((0,d.both)(K,(0,d.complement)(Array.isArray)),(0,d.omit)(r))),Qr)({schema:e,variant:t?"parsed":"original",validate:!0}),Rn=(e,t)=>(0,d.pipe)(F,(0,d.filter)((0,d.has)(t)),(0,d.pluck)(t),Qr)({schema:e,variant:"original",validate:!0}),Pe=(e,t)=>e instanceof S.z.ZodObject?e:e instanceof S.z.ZodBranded?Pe(e.unwrap(),t):e instanceof S.z.ZodUnion||e instanceof S.z.ZodDiscriminatedUnion?e.options.map(r=>Pe(r,t)).reduce((r,o)=>r.merge(o.partial()),S.z.object({})):e instanceof S.z.ZodEffects?((0,B.default)(e._def.effect.type==="refinement",t),Pe(e._def.schema,t)):Pe(e._def.left,t).merge(Pe(e._def.right,t)),Wr=({path:e,method:t,schema:r,inputSources:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:c,description:l=`${t.toUpperCase()} ${e} Parameter`})=>{let{shape:m}=Pe(r,new P({message:"Using transformations on the top level schema is not allowed.",path:e,method:t,isResponse:!1})),y=Ko(e),u=o.includes("query"),x=o.includes("params"),z=o.includes("headers"),T=b=>x&&y.includes(b),L=b=>z&&Rt(b);return Object.keys(m).map(b=>({name:b,location:T(b)?"path":L(b)?"header":u?"query":void 0})).filter(b=>b.location!==void 0).map(({name:b,location:Ee})=>{let $=ce(m[b],{rules:{...c,...vt},onEach:Lt,onMissing:jt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:e,method:t}}),W=p==="components"?a(M(l,b),$):$;return{name:b,in:Ee,required:!m[b].isOptional(),description:$.description||l,schema:W,examples:Rn(r,b)}})},vt={ZodString:fn,ZodNumber:yn,ZodBigInt:dn,ZodBoolean:pn,ZodNull:on,ZodArray:mn,ZodTuple:un,ZodRecord:ln,ZodObject:rn,ZodLiteral:tn,ZodIntersection:Jo,ZodUnion:_o,ZodAny:$o,ZodDefault:Bo,ZodEnum:qr,ZodNativeEnum:qr,ZodEffects:hn,ZodOptional:Wo,ZodNullable:en,ZodDiscriminatedUnion:Yo,ZodBranded:bn,ZodDate:an,ZodCatch:qo,ZodPipeline:xn,ZodLazy:Tn,ZodReadonly:Xo,[_]:Go,[He]:Vo,[Ke]:sn,[Fe]:nn,[ne]:Sn},Lt=(e,{isResponse:t,prev:r})=>{if((0,Y.isReferenceObject)(r))return{};let{description:o}=e,i=e instanceof S.z.ZodLazy,s=r.type!==void 0,a=t&&je(e),p=!i&&s&&!a&&e.isNullable(),c=i?[]:F({schema:e,variant:t?"parsed":"original",validate:!0}),l={};return o&&(l.description=o),p&&(l.type=Yr(r)),c.length&&(l.examples=c.slice()),l},jt=(e,t)=>B.default.fail(new P({message:`Zod type ${e.constructor.name} is unsupported.`,...t})),Mt=(e,t)=>{if((0,Y.isReferenceObject)(e))return e;let r={...e};return r.properties&&(r.properties=(0,d.omit)(t,r.properties)),r.examples&&(r.examples=r.examples.map(o=>(0,d.omit)(t,o))),r.required&&(r.required=r.required.filter(o=>!t.includes(o))),r.allOf&&(r.allOf=r.allOf.map(o=>Mt(o,t))),r.oneOf&&(r.oneOf=r.oneOf.map(o=>Mt(o,t))),r},Xr=e=>(0,Y.isReferenceObject)(e)?e:(0,d.omit)(["examples"],e),eo=({method:e,path:t,schema:r,mimeTypes:o,variant:i,serializer:s,getRef:a,makeRef:p,composition:c,hasMultipleStatusCodes:l,statusCode:m,brandHandling:y,description:u=`${e.toUpperCase()} ${t} ${At(i)} response ${l?m:""}`.trim()})=>{let x=Xr(ce(r,{rules:{...y,...vt},onEach:Lt,onMissing:jt,ctx:{isResponse:!0,serializer:s,getRef:a,makeRef:p,path:t,method:e}})),z={schema:c==="components"?p(M(u),x):x,examples:Jr(r,!0)};return{description:u,content:(0,d.fromPairs)((0,d.xprod)(o,[z]))}},On=()=>({type:"http",scheme:"basic"}),An=({format:e})=>{let t={type:"http",scheme:"bearer"};return e&&(t.bearerFormat=e),t},Pn=({name:e},t)=>{let r={type:"apiKey",in:"query",name:e};return t?.includes("body")&&(t?.includes("query")?(r["x-in-alternative"]="body",r.description=`${e} CAN also be supplied within the request body`):(r["x-in-actual"]="body",r.description=`${e} MUST be supplied within the request body instead of query`)),r},Cn=({name:e})=>({type:"apiKey",in:"header",name:e}),In=({name:e})=>({type:"apiKey",in:"cookie",name:e}),wn=({url:e})=>({type:"openIdConnect",openIdConnectUrl:e}),En=({flows:e={}})=>({type:"oauth2",flows:(0,d.map)(t=>({...t,scopes:t.scopes||{}}),(0,d.reject)(d.isNil,e))}),to=(e,t)=>{let r={basic:On,bearer:An,input:Pn,header:Cn,cookie:In,openid:wn,oauth2:En};return tt(e,o=>r[o.type](o,t))},lt=e=>"or"in e?e.or.map(t=>"and"in t?(0,d.mergeAll)((0,d.map)(({name:r,scopes:o})=>(0,d.objOf)(r,o),t.and)):{[t.name]:t.scopes}):"and"in e?lt(wt(e)):lt({or:[e]}),ro=({method:e,path:t,schema:r,mimeTypes:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:c,paramNames:l,description:m=`${e.toUpperCase()} ${t} Request body`})=>{let y=Xr(Mt(ce(r,{rules:{...c,...vt},onEach:Lt,onMissing:jt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:t,method:e}}),l)),u={schema:p==="components"?a(M(m),y):y,examples:Jr(r,!1,l)};return{description:m,content:(0,d.fromPairs)((0,d.xprod)(o,[u]))}},oo=e=>Object.keys(e).map(t=>{let r=e[t],o={name:t,description:typeof r=="string"?r:r.description};return typeof r=="object"&&r.url&&(o.externalDocs={url:r.url}),o}),Dt=e=>e.length<=Br?e:e.slice(0,Br-1)+"\u2026";var mt=class extends io.OpenApiBuilder{lastSecuritySchemaIds=new Map;lastOperationIdSuffixes=new Map;makeRef(t,r){return this.addSchema(t,r),this.getRef(t)}getRef(t){return t in(this.rootDoc.components?.schemas||{})?{$ref:`#/components/schemas/${t}`}:void 0}ensureUniqOperationId(t,r,o){let i=o||M(r,t),s=this.lastOperationIdSuffixes.get(i);return s===void 0?(this.lastOperationIdSuffixes.set(i,1),i):(o&&no.default.fail(new P({message:`Duplicated operationId: "${o}"`,method:r,isResponse:!1,path:t})),s++,this.lastOperationIdSuffixes.set(i,s),`${i}${s}`)}ensureUniqSecuritySchemaName(t){let r=JSON.stringify(t);for(let i in this.rootDoc.components?.securitySchemes||{})if(r===JSON.stringify(this.rootDoc.components?.securitySchemes?.[i]))return i;let o=(this.lastSecuritySchemaIds.get(t.type)||0)+1;return this.lastSecuritySchemaIds.set(t.type,o),`${t.type.toUpperCase()}_${o}`}constructor({routing:t,config:r,title:o,version:i,serverUrl:s,descriptions:a,brandHandling:p,hasSummaryFromDescription:c=!0,composition:l="inline",serializer:m=Ge}){super(),this.addInfo({title:o,version:i});for(let u of typeof s=="string"?[s]:s)this.addServer({url:u});de({routing:t,onEndpoint:(u,x,z)=>{let T=z,L={path:x,method:T,endpoint:u,composition:l,serializer:m,brandHandling:p,getRef:this.getRef.bind(this),makeRef:this.makeRef.bind(this)},[C,b]=["short","long"].map(u.getDescription.bind(u)),Ee=C?Dt(C):c&&b?Dt(b):void 0,$=u.getTags(),W=r.inputSources?.[T]||Tt[T],me=this.ensureUniqOperationId(x,T,u.getOperationId(T)),ze=Wr({...L,inputSources:W,schema:u.getSchema("input"),description:a?.requestParameter?.call(null,{method:T,path:x,operationId:me})}),qe={};for(let k of["positive","negative"]){let X=u.getResponses(k);for(let{mimeTypes:Ze,schema:O,statusCodes:A}of X)for(let I of A)qe[I]=eo({...L,variant:k,schema:O,mimeTypes:Ze,statusCode:I,hasMultipleStatusCodes:X.length>1||A.length>1,description:a?.[`${k}Response`]?.call(null,{method:T,path:x,operationId:me,statusCode:I})})}let bt=W.includes("body")?ro({...L,paramNames:(0,so.pluck)("name",ze),schema:u.getSchema("input"),mimeTypes:u.getMimeTypes("input"),description:a?.requestBody?.call(null,{method:T,path:x,operationId:me})}):void 0,$e=lt(tt(to(u.getSecurity(),W),k=>{let X=this.ensureUniqSecuritySchemaName(k),Ze=["oauth2","openIdConnect"].includes(k.type)?u.getScopes().slice():[];return this.addSecurityScheme(X,k),{name:X,scopes:Ze}}));this.addPath(Gr(x),{[T]:{operationId:me,summary:Ee,description:b,tags:$.length>0?$:void 0,parameters:ze.length>0?ze:void 0,requestBody:bt,security:$e.length>0?$e:void 0,responses:qe}})}}),this.rootDoc.tags=r.tags?oo(r.tags):[]}};var kt=R(require("http"),1);var zn=({fnMethod:e,requestProps:t})=>({method:"GET",header:e(()=>N.json),...t}),Zn=({fnMethod:e,responseProps:t})=>{let r={writableEnded:!1,statusCode:200,statusMessage:kt.default.STATUS_CODES[200],set:e(()=>r),setHeader:e(()=>r),header:e(()=>r),status:e(o=>(r.statusCode=o,r.statusMessage=kt.default.STATUS_CODES[o],r)),json:e(()=>r),send:e(()=>r),end:e(()=>(r.writableEnded=!0,r)),locals:{},...t};return r},Nn=({fnMethod:e,loggerProps:t})=>({info:e(),warn:e(),error:e(),debug:e(),...t}),ao=async({endpoint:e,requestProps:t,responseProps:r,configProps:o,loggerProps:i,fnMethod:s})=>{let a=s||(await wr([{moduleName:"vitest",moduleExport:"vi"},{moduleName:"@jest/globals",moduleExport:"jest"}])).fn,p=zn({fnMethod:a,requestProps:t}),c=Zn({fnMethod:a,responseProps:r}),l=Nn({fnMethod:a,loggerProps:i}),m={cors:!1,logger:l,...o};return await e.execute({request:p,response:c,config:m,logger:l}),{requestMock:p,responseMock:c,loggerMock:l}};var E=R(require("typescript"),1);var D=R(require("typescript"),1),Ce=require("ramda"),n=D.default.factory,Q=[n.createModifier(D.default.SyntaxKind.ExportKeyword)],Mn=[n.createModifier(D.default.SyntaxKind.AsyncKeyword)],vn=[n.createModifier(D.default.SyntaxKind.PublicKeyword),n.createModifier(D.default.SyntaxKind.ReadonlyKeyword)],po=[n.createModifier(D.default.SyntaxKind.ProtectedKeyword),n.createModifier(D.default.SyntaxKind.ReadonlyKeyword)],Ht=n.createTemplateHead(""),Ie=n.createTemplateTail(""),Ut=n.createTemplateMiddle(" "),Ft=e=>n.createTemplateLiteralType(Ht,e.map((t,r)=>n.createTemplateLiteralTypeSpan(n.createTypeReferenceNode(t),r===e.length-1?Ie:Ut))),Kt=Ft(["M","P"]),ut=(e,t,r)=>n.createParameterDeclaration(r,void 0,e,void 0,t,void 0),ft=(e,t)=>(0,Ce.chain)(([r,o])=>[ut(n.createIdentifier(r),o,t)],(0,Ce.toPairs)(e)),Bt=(e,t)=>n.createExpressionWithTypeArguments(n.createIdentifier("Record"),[typeof e=="number"?n.createKeywordTypeNode(e):n.createTypeReferenceNode(e),n.createKeywordTypeNode(t)]),co=e=>n.createConstructorDeclaration(void 0,e,n.createBlock([])),lo=(e,t)=>n.createPropertySignature(void 0,e,void 0,n.createTypeReferenceNode(t)),J=(e,t,r)=>n.createVariableDeclarationList([n.createVariableDeclaration(e,void 0,r,t)],D.default.NodeFlags.Const),qt=(e,t)=>n.createTypeAliasDeclaration(Q,e,void 0,n.createUnionTypeNode(t.map(r=>n.createLiteralTypeNode(n.createStringLiteral(r))))),yt=(e,t)=>n.createTypeAliasDeclaration(Q,e,void 0,t),mo=(e,t,r)=>n.createPropertyDeclaration(vn,e,void 0,t,r),uo=(e,t,r)=>n.createClassDeclaration(Q,e,void 0,void 0,[t,...r]),fo=(e,t)=>n.createTypeReferenceNode("Promise",[n.createIndexedAccessTypeNode(n.createTypeReferenceNode(e),t)]),yo=()=>n.createTypeReferenceNode("Promise",[n.createKeywordTypeNode(D.default.SyntaxKind.AnyKeyword)]),go=(e,t,r)=>n.createInterfaceDeclaration(Q,e,void 0,t,r),ho=e=>(0,Ce.chain)(([t,r])=>[n.createTypeParameterDeclaration([],t,n.createTypeReferenceNode(r))],(0,Ce.toPairs)(e)),$t=(e,t,r)=>n.createArrowFunction(r?Mn:void 0,void 0,e.map(o=>ut(o)),void 0,void 0,t),Vt=(e,t,r)=>n.createCallExpression(n.createPropertyAccessExpression(n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("Object"),"keys"),void 0,[e]),"reduce"),void 0,[n.createArrowFunction(void 0,void 0,ft({acc:void 0,key:void 0}),void 0,void 0,t),r]),xo=(...e)=>`"${e.join(" ")}"`;var bo=["get","post","put","delete","patch"];var h=R(require("typescript"),1),ht=require("zod");var q=R(require("typescript"),1),{factory:gt}=q.default,Gt=(e,t)=>{q.default.addSyntheticLeadingComment(e,q.default.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0)},we=(e,t,r)=>{let o=gt.createTypeAliasDeclaration(void 0,gt.createIdentifier(t),void 0,e);return r&&Gt(o,r),o},_t=(e,t)=>{let r=q.default.createSourceFile("print.ts","",q.default.ScriptTarget.Latest,!1,q.default.ScriptKind.TS);return q.default.createPrinter(t).printNode(q.default.EmitHint.Unspecified,e,r)},Ln=/^[A-Za-z_$][A-Za-z0-9_$]*$/,To=e=>Ln.test(e)?gt.createIdentifier(e):gt.createStringLiteral(e);var{factory:f}=h.default,jn={[h.default.SyntaxKind.AnyKeyword]:"",[h.default.SyntaxKind.BigIntKeyword]:BigInt(0),[h.default.SyntaxKind.BooleanKeyword]:!1,[h.default.SyntaxKind.NumberKeyword]:0,[h.default.SyntaxKind.ObjectKeyword]:{},[h.default.SyntaxKind.StringKeyword]:"",[h.default.SyntaxKind.UndefinedKeyword]:void 0},Dn=({value:e})=>f.createLiteralTypeNode(typeof e=="number"?f.createNumericLiteral(e):typeof e=="boolean"?e?f.createTrue():f.createFalse():f.createStringLiteral(e)),kn=({shape:e},{isResponse:t,next:r,optionalPropStyle:{withQuestionMark:o}})=>{let i=Object.entries(e).map(([s,a])=>{let p=t&&je(a)?a instanceof ht.z.ZodOptional:a.isOptional(),c=f.createPropertySignature(void 0,To(s),p&&o?f.createToken(h.default.SyntaxKind.QuestionToken):void 0,r(a));return a.description&&Gt(c,a.description),c});return f.createTypeLiteralNode(i)},Hn=({element:e},{next:t})=>f.createArrayTypeNode(t(e)),Un=({options:e})=>f.createUnionTypeNode(e.map(t=>f.createLiteralTypeNode(f.createStringLiteral(t)))),So=({options:e},{next:t})=>f.createUnionTypeNode(e.map(t)),Fn=e=>jn?.[e.kind],Kn=(e,{next:t,isResponse:r})=>{let o=t(e.innerType()),i=e._def.effect;if(r&&i.type==="transform"){let s=_e(e,Fn(o)),a={number:h.default.SyntaxKind.NumberKeyword,bigint:h.default.SyntaxKind.BigIntKeyword,boolean:h.default.SyntaxKind.BooleanKeyword,string:h.default.SyntaxKind.StringKeyword,undefined:h.default.SyntaxKind.UndefinedKeyword,object:h.default.SyntaxKind.ObjectKeyword};return f.createKeywordTypeNode(s&&a[s]||h.default.SyntaxKind.AnyKeyword)}return o},Bn=e=>f.createUnionTypeNode(Object.values(e.enum).map(t=>f.createLiteralTypeNode(typeof t=="number"?f.createNumericLiteral(t):f.createStringLiteral(t)))),qn=(e,{next:t,optionalPropStyle:{withUndefined:r}})=>{let o=t(e.unwrap());return r?f.createUnionTypeNode([o,f.createKeywordTypeNode(h.default.SyntaxKind.UndefinedKeyword)]):o},$n=(e,{next:t})=>f.createUnionTypeNode([t(e.unwrap()),f.createLiteralTypeNode(f.createNull())]),Vn=({items:e,_def:{rest:t}},{next:r})=>f.createTupleTypeNode(e.map(r).concat(t===null?[]:f.createRestTypeNode(r(t)))),Gn=({keySchema:e,valueSchema:t},{next:r})=>f.createExpressionWithTypeArguments(f.createIdentifier("Record"),[e,t].map(r)),_n=({_def:e},{next:t})=>f.createIntersectionTypeNode([e.left,e.right].map(t)),Yn=({_def:e},{next:t})=>t(e.innerType),le=e=>()=>f.createKeywordTypeNode(e),Qn=(e,{next:t})=>t(e.unwrap()),Jn=(e,{next:t})=>t(e.unwrap()),Wn=({_def:e},{next:t})=>t(e.innerType),Xn=({_def:e},{next:t,isResponse:r})=>t(e[r?"out":"in"]),ei=()=>f.createLiteralTypeNode(f.createNull()),ti=({schema:e},{getAlias:t,makeAlias:r,next:o,serializer:i})=>{let s=`Type${i(e)}`;return t(s)||(r(s,f.createLiteralTypeNode(f.createNull())),r(s,o(e)))},ri=e=>{let t=e.unwrap(),r=f.createKeywordTypeNode(h.default.SyntaxKind.StringKeyword),o=f.createTypeReferenceNode("Buffer"),i=f.createUnionTypeNode([r,o]);return t instanceof ht.z.ZodString?r:t instanceof ht.z.ZodUnion?i:o},oi=(e,{next:t})=>t(e.unwrap().shape.raw),ni={ZodString:le(h.default.SyntaxKind.StringKeyword),ZodNumber:le(h.default.SyntaxKind.NumberKeyword),ZodBigInt:le(h.default.SyntaxKind.BigIntKeyword),ZodBoolean:le(h.default.SyntaxKind.BooleanKeyword),ZodAny:le(h.default.SyntaxKind.AnyKeyword),[Fe]:le(h.default.SyntaxKind.StringKeyword),[Ke]:le(h.default.SyntaxKind.StringKeyword),ZodNull:ei,ZodArray:Hn,ZodTuple:Vn,ZodRecord:Gn,ZodObject:kn,ZodLiteral:Dn,ZodIntersection:_n,ZodUnion:So,ZodDefault:Yn,ZodEnum:Un,ZodNativeEnum:Bn,ZodEffects:Kn,ZodOptional:qn,ZodNullable:$n,ZodDiscriminatedUnion:So,ZodBranded:Qn,ZodCatch:Wn,ZodPipeline:Xn,ZodLazy:ti,ZodReadonly:Jn,[_]:ri,[ne]:oi},Be=(e,{brandHandling:t,ctx:r})=>ce(e,{rules:{...t,...ni},onMissing:()=>f.createKeywordTypeNode(h.default.SyntaxKind.AnyKeyword),ctx:r});var xt=class{program=[];usage=[];registry=new Map;paths=[];aliases=new Map;ids={pathType:n.createIdentifier("Path"),methodType:n.createIdentifier("Method"),methodPathType:n.createIdentifier("MethodPath"),inputInterface:n.createIdentifier("Input"),posResponseInterface:n.createIdentifier("PositiveResponse"),negResponseInterface:n.createIdentifier("NegativeResponse"),responseInterface:n.createIdentifier("Response"),jsonEndpointsConst:n.createIdentifier("jsonEndpoints"),endpointTagsConst:n.createIdentifier("endpointTags"),providerType:n.createIdentifier("Provider"),implementationType:n.createIdentifier("Implementation"),clientClass:n.createIdentifier("ExpressZodAPIClient"),keyParameter:n.createIdentifier("key"),pathParameter:n.createIdentifier("path"),paramsArgument:n.createIdentifier("params"),methodParameter:n.createIdentifier("method"),accumulator:n.createIdentifier("acc"),provideMethod:n.createIdentifier("provide"),implementationArgument:n.createIdentifier("implementation"),headersProperty:n.createIdentifier("headers"),hasBodyConst:n.createIdentifier("hasBody"),undefinedValue:n.createIdentifier("undefined"),bodyProperty:n.createIdentifier("body"),responseConst:n.createIdentifier("response"),searchParamsConst:n.createIdentifier("searchParams"),exampleImplementationConst:n.createIdentifier("exampleImplementation"),clientConst:n.createIdentifier("client")};interfaces=[];getAlias(t){return this.aliases.has(t)?n.createTypeReferenceNode(t):void 0}makeAlias(t,r){return this.aliases.set(t,we(r,t)),this.getAlias(t)}constructor({routing:t,brandHandling:r,variant:o="client",serializer:i=Ge,splitResponse:s=!1,optionalPropStyle:a={withQuestionMark:!0,withUndefined:!0}}){de({routing:t,onEndpoint:(O,A,I)=>{let ue={serializer:i,getAlias:this.getAlias.bind(this),makeAlias:this.makeAlias.bind(this),optionalPropStyle:a},Ne=M(I,A,"input"),Me=Be(O.getSchema("input"),{brandHandling:r,ctx:{...ue,isResponse:!1}}),Z=s?M(I,A,"positive.response"):void 0,Yt=O.getSchema("positive"),Qt=s?Be(Yt,{brandHandling:r,ctx:{...ue,isResponse:!0}}):void 0,ve=s?M(I,A,"negative.response"):void 0,Jt=O.getSchema("negative"),Wt=s?Be(Jt,{brandHandling:r,ctx:{...ue,isResponse:!0}}):void 0,Xt=M(I,A,"response"),Oo=Z&&ve?n.createUnionTypeNode([n.createTypeReferenceNode(Z),n.createTypeReferenceNode(ve)]):Be(Yt.or(Jt),{brandHandling:r,ctx:{...ue,isResponse:!0}});this.program.push(we(Me,Ne)),Qt&&Z&&this.program.push(we(Qt,Z)),Wt&&ve&&this.program.push(we(Wt,ve)),this.program.push(we(Oo,Xt)),I!=="options"&&(this.paths.push(A),this.registry.set({method:I,path:A},{input:Ne,positive:Z,negative:ve,response:Xt,isJson:O.getMimeTypes("positive").includes(N.json),tags:O.getTags()}))}}),this.program.unshift(...this.aliases.values()),this.program.push(qt(this.ids.pathType,this.paths)),this.program.push(qt(this.ids.methodType,bo)),this.program.push(yt(this.ids.methodPathType,Ft([this.ids.methodType,this.ids.pathType])));let p=[n.createHeritageClause(E.default.SyntaxKind.ExtendsKeyword,[Bt(this.ids.methodPathType,E.default.SyntaxKind.AnyKeyword)])];this.interfaces.push({id:this.ids.inputInterface,kind:"input",props:[]}),s&&this.interfaces.push({id:this.ids.posResponseInterface,kind:"positive",props:[]},{id:this.ids.negResponseInterface,kind:"negative",props:[]}),this.interfaces.push({id:this.ids.responseInterface,kind:"response",props:[]});let c=[],l=[];for(let[{method:O,path:A},{isJson:I,tags:ue,...Ne}]of this.registry){let Me=xo(O,A);for(let Z of this.interfaces)Z.kind in Ne&&Z.props.push(lo(Me,Ne[Z.kind]));o!=="types"&&(I&&c.push(n.createPropertyAssignment(Me,n.createTrue())),l.push(n.createPropertyAssignment(Me,n.createArrayLiteralExpression(ue.map(Z=>n.createStringLiteral(Z))))))}for(let{id:O,props:A}of this.interfaces)this.program.push(go(O,p,A));if(o==="types")return;let m=n.createVariableStatement(Q,J(this.ids.jsonEndpointsConst,n.createObjectLiteralExpression(c))),y=n.createVariableStatement(Q,J(this.ids.endpointTagsConst,n.createObjectLiteralExpression(l))),u=yt(this.ids.providerType,n.createFunctionTypeNode(ho({M:this.ids.methodType,P:this.ids.pathType}),ft({method:n.createTypeReferenceNode("M"),path:n.createTypeReferenceNode("P"),params:n.createIndexedAccessTypeNode(n.createTypeReferenceNode(this.ids.inputInterface),Kt)}),fo(this.ids.responseInterface,Kt))),x=yt(this.ids.implementationType,n.createFunctionTypeNode(void 0,ft({method:n.createTypeReferenceNode(this.ids.methodType),path:n.createKeywordTypeNode(E.default.SyntaxKind.StringKeyword),params:Bt(E.default.SyntaxKind.StringKeyword,E.default.SyntaxKind.AnyKeyword)}),yo())),z=n.createTemplateExpression(n.createTemplateHead(":"),[n.createTemplateSpan(this.ids.keyParameter,Ie)]),T=Vt(this.ids.paramsArgument,n.createCallExpression(n.createPropertyAccessExpression(this.ids.accumulator,"replace"),void 0,[z,n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter)]),this.ids.pathParameter),L=Vt(this.ids.paramsArgument,n.createConditionalExpression(n.createBinaryExpression(n.createCallExpression(n.createPropertyAccessExpression(this.ids.pathParameter,"indexOf"),void 0,[z]),E.default.SyntaxKind.GreaterThanEqualsToken,n.createNumericLiteral(0)),void 0,this.ids.accumulator,void 0,n.createObjectLiteralExpression([n.createSpreadAssignment(this.ids.accumulator),n.createPropertyAssignment(n.createComputedPropertyName(this.ids.keyParameter),n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter))])),n.createObjectLiteralExpression()),C=uo(this.ids.clientClass,co([ut(this.ids.implementationArgument,n.createTypeReferenceNode(this.ids.implementationType),po)]),[mo(this.ids.provideMethod,n.createTypeReferenceNode(this.ids.providerType),$t([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createCallExpression(n.createPropertyAccessExpression(n.createThis(),this.ids.implementationArgument),void 0,[this.ids.methodParameter,T,L]),!0))]);this.program.push(m,y,u,x,C);let b=n.createPropertyAssignment(this.ids.methodParameter,n.createCallExpression(n.createPropertyAccessExpression(this.ids.methodParameter,"toUpperCase"),void 0,void 0)),Ee=n.createPropertyAssignment(this.ids.headersProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createObjectLiteralExpression([n.createPropertyAssignment(n.createStringLiteral("Content-Type"),n.createStringLiteral(N.json))]),void 0,this.ids.undefinedValue)),$=n.createPropertyAssignment(this.ids.bodyProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("JSON"),"stringify"),void 0,[this.ids.paramsArgument]),void 0,this.ids.undefinedValue)),W=n.createVariableStatement(void 0,J(this.ids.responseConst,n.createAwaitExpression(n.createCallExpression(n.createIdentifier("fetch"),void 0,[n.createTemplateExpression(n.createTemplateHead("https://example.com"),[n.createTemplateSpan(this.ids.pathParameter,n.createTemplateMiddle("")),n.createTemplateSpan(this.ids.searchParamsConst,Ie)]),n.createObjectLiteralExpression([b,Ee,$])])))),me=n.createVariableStatement(void 0,J(this.ids.hasBodyConst,n.createLogicalNot(n.createCallExpression(n.createPropertyAccessExpression(n.createArrayLiteralExpression([n.createStringLiteral("get"),n.createStringLiteral("delete")]),"includes"),void 0,[this.ids.methodParameter])))),ze=n.createVariableStatement(void 0,J(this.ids.searchParamsConst,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createStringLiteral(""),void 0,n.createTemplateExpression(n.createTemplateHead("?"),[n.createTemplateSpan(n.createNewExpression(n.createIdentifier("URLSearchParams"),void 0,[this.ids.paramsArgument]),Ie)])))),[qe,bt]=["json","text"].map(O=>n.createReturnStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.responseConst,O),void 0,void 0))),$e=n.createIfStatement(n.createBinaryExpression(n.createTemplateExpression(Ht,[n.createTemplateSpan(this.ids.methodParameter,Ut),n.createTemplateSpan(this.ids.pathParameter,Ie)]),E.default.SyntaxKind.InKeyword,this.ids.jsonEndpointsConst),n.createBlock([qe])),k=n.createVariableStatement(Q,J(this.ids.exampleImplementationConst,$t([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createBlock([me,ze,W,$e,bt]),!0),n.createTypeReferenceNode(this.ids.implementationType))),X=n.createExpressionStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.clientConst,this.ids.provideMethod),void 0,[n.createStringLiteral("get"),n.createStringLiteral("/v1/user/retrieve"),n.createObjectLiteralExpression([n.createPropertyAssignment("id",n.createStringLiteral("10"))])])),Ze=n.createVariableStatement(void 0,J(this.ids.clientConst,n.createNewExpression(this.ids.clientClass,void 0,[this.ids.exampleImplementationConst])));this.usage.push(k,Ze,X)}printUsage(t){return this.usage.length?this.usage.map(r=>typeof r=="string"?r:_t(r,t)).join(`
|
|
21
21
|
`):void 0}print(t){let r=this.printUsage(t),o=r&&E.default.addSyntheticLeadingComment(E.default.addSyntheticLeadingComment(n.createEmptyStatement(),E.default.SyntaxKind.SingleLineCommentTrivia," Usage example:"),E.default.SyntaxKind.MultiLineCommentTrivia,`
|
|
22
22
|
${r}`);return this.program.concat(o||[]).map((i,s)=>_t(i,s<this.program.length?t:{...t,omitTrailingSemicolon:!0})).join(`
|
|
23
23
|
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ ${o}888${t}
|
|
|
17
17
|
${r}
|
|
18
18
|
`.split(`
|
|
19
19
|
`).map((d,c)=>a[c]?a[c](d):d).join(`
|
|
20
|
-
`)};var fr=e=>{e.startupLogo!==!1&&console.log(ur());let t=e.errorHandler||Ce,r=or(e.logger)?e.logger:new ue(e.logger);r.debug("Running","v19.2.0 (ESM)");let o=lr({rootLogger:r,config:e}),i=pr({rootLogger:r,errorHandler:t}),s=ar({rootLogger:r,errorHandler:t});return{rootLogger:r,errorHandler:t,notFoundHandler:i,parserFailureHandler:s,loggingMiddleware:o}},Ko=(e,t)=>{let{rootLogger:r,notFoundHandler:o,loggingMiddleware:i}=fr(e);return Tt({app:e.app.use(i),routing:t,rootLogger:r,config:e}),{notFoundHandler:o,logger:r}},Bo=async(e,t)=>{let{rootLogger:r,notFoundHandler:o,parserFailureHandler:i,loggingMiddleware:s}=fr(e),a=St().disable("x-powered-by").use(s);if(e.server.compression){let l=await X("compression");a.use(l(typeof e.server.compression=="object"?e.server.compression:void 0))}let p={json:[e.server.jsonParser||St.json()],raw:[e.server.rawParser||St.raw(),cr],upload:e.server.upload?await dr({config:e,rootLogger:r}):[]};e.server.beforeRouting&&await e.server.beforeRouting({app:a,logger:r}),Tt({app:a,routing:t,rootLogger:r,config:e,parsers:p}),a.use(i,o);let d=(l,f)=>l.listen(f,()=>{r.info("Listening",f)}),c={httpServer:d(Uo.createServer(a),e.server.listen),httpsServer:e.https?d(Fo.createServer(e.https.options,a),e.https.listen):void 0};return{app:a,...c,logger:r}};import Jn from"assert/strict";import{OpenApiBuilder as Wn}from"openapi3-ts/oas31";import{pluck as Xn}from"ramda";import K from"assert/strict";import{isReferenceObject as re}from"openapi3-ts/oas31";import{both as $o,complement as Vo,concat as Go,type as _o,filter as Yo,fromPairs as Me,has as Qo,isNil as Jo,map as ye,mergeAll as Wo,mergeDeepRight as Xo,mergeDeepWith as en,objOf as br,omit as Xe,pipe as Tr,pluck as tn,range as rn,reject as on,toLower as nn,union as sn,when as an,xprod as et,zip as pn}from"ramda";import{z as T}from"zod";import{z as ze}from"zod";var Je=e=>!isNaN(e.getTime());var Ze=Symbol("DateIn"),yr=()=>ze.union([ze.string().date(),ze.string().datetime(),ze.string().datetime({local:!0})]).transform(t=>new Date(t)).pipe(ze.date().refine(Je)).brand(Ze);import{z as qo}from"zod";var Ne=Symbol("DateOut"),gr=()=>qo.date().refine(Je).transform(e=>e.toISOString()).brand(Ne);var te=(e,{onEach:t,rules:r,onMissing:o,ctx:i={}})=>{let s=r[e._def[y]?.brand]||r[e._def.typeName],p=s?s(e,{...i,next:c=>te(c,{ctx:i,onEach:t,rules:r,onMissing:o})}):o(e,i),d=t&&t(e,{prev:p,...i});return d?{...p,...d}:p};var hr=50,Sr="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",dn={integer:0,number:0,string:"",boolean:!1,object:{},null:null,array:[]},Rr=/:([A-Za-z0-9_]+)/g,cn=e=>e.match(Rr)?.map(t=>t.slice(1))||[],Or=e=>e.replace(Rr,t=>`{${t.slice(1)}}`),ln=({_def:e},{next:t})=>({...t(e.innerType),default:e[y]?.defaultLabel||e.defaultValue()}),mn=({_def:{innerType:e}},{next:t})=>t(e),un=()=>({format:"any"}),fn=({},e)=>(K(!e.isResponse,new P({message:"Please use ez.upload() only for input.",...e})),{type:"string",format:"binary"}),yn=e=>{let t=e.unwrap();return{type:"string",format:t instanceof T.ZodString?t._def.checks.find(r=>r.kind==="base64")?"byte":"file":"binary"}},gn=({options:e},{next:t})=>({oneOf:e.map(t)}),hn=({options:e,discriminator:t},{next:r})=>({discriminator:{propertyName:t},oneOf:e.map(r)}),xn=e=>{let[t,r]=e.filter(i=>!re(i)&&i.type==="object"&&Object.keys(i).every(s=>["type","properties","required","examples"].includes(s)));K(t&&r,"Can not flatten objects");let o={type:"object"};return(t.properties||r.properties)&&(o.properties=en((i,s)=>Array.isArray(i)&&Array.isArray(s)?Go(i,s):i===s?s:K.fail("Can not flatten properties"),t.properties||{},r.properties||{})),(t.required||r.required)&&(o.required=sn(t.required||[],r.required||[])),(t.examples||r.examples)&&(o.examples=Q(t.examples||[],r.examples||[],([i,s])=>Xo(i,s))),o},bn=({_def:{left:e,right:t}},{next:r})=>{let o=[e,t].map(r);try{return xn(o)}catch{}return{allOf:o}},Tn=(e,{next:t})=>t(e.unwrap()),Sn=(e,{next:t})=>t(e.unwrap()),Rn=(e,{next:t})=>{let r=t(e.unwrap());return re(r)||(r.type=Pr(r)),r},Ar=e=>{let t=nn(_o(e));return typeof e=="bigint"?"integer":t==="number"||t==="string"||t==="boolean"||t==="object"||t==="null"||t==="array"?t:void 0},xr=e=>({type:Ar(Object.values(e.enum)[0]),enum:Object.values(e.enum)}),On=({value:e})=>({type:Ar(e),const:e}),An=(e,{isResponse:t,next:r})=>{let o=Object.keys(e.shape),i=p=>t&&Ae(p)?p instanceof T.ZodOptional:p.isOptional(),s=o.filter(p=>!i(e.shape[p])),a={type:"object"};return o.length&&(a.properties=We(e,r)),s.length&&(a.required=s),a},Pn=()=>({type:"null"}),Cn=({},e)=>(K(!e.isResponse,new P({message:"Please use ez.dateOut() for output.",...e})),{description:"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?$/.source,externalDocs:{url:Sr}}),In=({},e)=>(K(e.isResponse,new P({message:"Please use ez.dateIn() for input.",...e})),{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",externalDocs:{url:Sr}}),wn=({},e)=>K.fail(new P({message:`Using z.date() within ${e.isResponse?"output":"input"} schema is forbidden. Please use ez.date${e.isResponse?"Out":"In"}() instead. Check out the documentation for details.`,...e})),En=()=>({type:"boolean"}),zn=()=>({type:"integer",format:"bigint"}),Zn=e=>e.every(t=>t instanceof T.ZodLiteral),Nn=({keySchema:e,valueSchema:t},{next:r})=>{if(e instanceof T.ZodEnum||e instanceof T.ZodNativeEnum){let o=Object.values(e.enum),i={type:"object"};return o.length&&(i.properties=We(T.object(Me(et(o,[t]))),r),i.required=o),i}if(e instanceof T.ZodLiteral)return{type:"object",properties:We(T.object({[e.value]:t}),r),required:[e.value]};if(e instanceof T.ZodUnion&&Zn(e.options)){let o=ye(s=>`${s.value}`,e.options),i=Me(et(o,[t]));return{type:"object",properties:We(T.object(i),r),required:o}}return{type:"object",additionalProperties:r(t)}},Mn=({_def:{minLength:e,maxLength:t},element:r},{next:o})=>{let i={type:"array",items:o(r)};return e&&(i.minItems=e.value),t&&(i.maxItems=t.value),i},vn=({items:e,_def:{rest:t}},{next:r})=>({type:"array",prefixItems:e.map(r),items:t===null?{not:{}}:r(t)}),Ln=({isEmail:e,isURL:t,minLength:r,maxLength:o,isUUID:i,isCUID:s,isCUID2:a,isULID:p,isIP:d,isEmoji:c,isDatetime:l,_def:{checks:f}})=>{let m=f.find(O=>O.kind==="regex"),h=f.find(O=>O.kind==="datetime"),C=m?m.regex:h?h.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"):void 0,b={type:"string"},Z={"date-time":l,email:e,url:t,uuid:i,cuid:s,cuid2:a,ulid:p,ip:d,emoji:c};for(let O in Z)if(Z[O]){b.format=O;break}return r!==null&&(b.minLength=r),o!==null&&(b.maxLength=o),C&&(b.pattern=C.source),b},jn=({isInt:e,maxValue:t,minValue:r,_def:{checks:o}})=>{let i=o.find(({kind:f})=>f==="min"),s=r===null?e?Number.MIN_SAFE_INTEGER:-Number.MAX_VALUE:r,a=i?i.inclusive:!0,p=o.find(({kind:f})=>f==="max"),d=t===null?e?Number.MAX_SAFE_INTEGER:Number.MAX_VALUE:t,c=p?p.inclusive:!0,l={type:e?"integer":"number",format:e?"int64":"double"};return a?l.minimum=s:l.exclusiveMinimum=s,c?l.maximum=d:l.exclusiveMaximum=d,l},We=({shape:e},t)=>ye(t,e),Dn=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return dn?.[t]},Pr=e=>{let t=typeof e.type=="string"?[e.type]:e.type||[];return t.includes("null")?t:t.concat("null")},kn=(e,{isResponse:t,next:r})=>{let o=r(e.innerType()),{effect:i}=e._def;if(t&&i.type==="transform"&&!re(o)){let s=He(e,Dn(o));return s&&["number","string","boolean"].includes(s)?{type:s}:r(T.any())}if(!t&&i.type==="preprocess"&&!re(o)){let{type:s,...a}=o;return{...a,format:`${a.format||s} (preprocessed)`}}return o},Hn=({_def:e},{isResponse:t,next:r})=>r(e[t?"out":"in"]),Un=(e,{next:t})=>t(e.unwrap()),Fn=({schema:e},{next:t,serializer:r,getRef:o,makeRef:i})=>{let s=r(e);return o(s)||(i(s,{}),i(s,t(e)))},Kn=(e,{next:t})=>t(e.unwrap().shape.raw),Cr=e=>e.length?Me(pn(rn(1,e.length+1).map(t=>`example${t}`),ye(br("value"),e))):void 0,Ir=(e,t,r=[])=>Tr(U,ye(an($o(v,Vo(Array.isArray)),Xe(r))),Cr)({schema:e,variant:t?"parsed":"original",validate:!0}),Bn=(e,t)=>Tr(U,Yo(Qo(t)),tn(t),Cr)({schema:e,variant:"original",validate:!0}),fe=(e,t)=>e instanceof T.ZodObject?e:e instanceof T.ZodBranded?fe(e.unwrap(),t):e instanceof T.ZodUnion||e instanceof T.ZodDiscriminatedUnion?e.options.map(r=>fe(r,t)).reduce((r,o)=>r.merge(o.partial()),T.object({})):e instanceof T.ZodEffects?(K(e._def.effect.type==="refinement",t),fe(e._def.schema,t)):fe(e._def.left,t).merge(fe(e._def.right,t)),wr=({path:e,method:t,schema:r,inputSources:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:d,description:c=`${t.toUpperCase()} ${e} Parameter`})=>{let{shape:l}=fe(r,new P({message:"Using transformations on the top level schema is not allowed.",path:e,method:t,isResponse:!1})),f=cn(e),m=o.includes("query"),h=o.includes("params"),C=o.includes("headers"),b=x=>h&&f.includes(x),Z=x=>C&&dt(x);return Object.keys(l).map(x=>({name:x,location:b(x)?"path":Z(x)?"header":m?"query":void 0})).filter(x=>x.location!==void 0).map(({name:x,location:xe})=>{let j=te(l[x],{rules:{...d,...Ot},onEach:At,onMissing:Pt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:e,method:t}}),V=p==="components"?a(E(c,x),j):j;return{name:x,in:xe,required:!l[x].isOptional(),description:j.description||c,schema:V,examples:Bn(r,x)}})},Ot={ZodString:Ln,ZodNumber:jn,ZodBigInt:zn,ZodBoolean:En,ZodNull:Pn,ZodArray:Mn,ZodTuple:vn,ZodRecord:Nn,ZodObject:An,ZodLiteral:On,ZodIntersection:bn,ZodUnion:gn,ZodAny:un,ZodDefault:ln,ZodEnum:xr,ZodNativeEnum:xr,ZodEffects:kn,ZodOptional:Tn,ZodNullable:Rn,ZodDiscriminatedUnion:hn,ZodBranded:Un,ZodDate:wn,ZodCatch:mn,ZodPipeline:Hn,ZodLazy:Fn,ZodReadonly:Sn,[F]:yn,[Pe]:fn,[Ne]:In,[Ze]:Cn,[J]:Kn},At=(e,{isResponse:t,prev:r})=>{if(re(r))return{};let{description:o}=e,i=e instanceof T.ZodLazy,s=r.type!==void 0,a=t&&Ae(e),p=!i&&s&&!a&&e.isNullable(),d=i?[]:U({schema:e,variant:t?"parsed":"original",validate:!0}),c={};return o&&(c.description=o),p&&(c.type=Pr(r)),d.length&&(c.examples=d.slice()),c},Pt=(e,t)=>K.fail(new P({message:`Zod type ${e.constructor.name} is unsupported.`,...t})),Rt=(e,t)=>{if(re(e))return e;let r={...e};return r.properties&&(r.properties=Xe(t,r.properties)),r.examples&&(r.examples=r.examples.map(o=>Xe(t,o))),r.required&&(r.required=r.required.filter(o=>!t.includes(o))),r.allOf&&(r.allOf=r.allOf.map(o=>Rt(o,t))),r.oneOf&&(r.oneOf=r.oneOf.map(o=>Rt(o,t))),r},Er=e=>re(e)?e:Xe(["examples"],e),zr=({method:e,path:t,schema:r,mimeTypes:o,variant:i,serializer:s,getRef:a,makeRef:p,composition:d,hasMultipleStatusCodes:c,statusCode:l,brandHandling:f,description:m=`${e.toUpperCase()} ${t} ${lt(i)} response ${c?l:""}`.trim()})=>{let h=Er(te(r,{rules:{...f,...Ot},onEach:At,onMissing:Pt,ctx:{isResponse:!0,serializer:s,getRef:a,makeRef:p,path:t,method:e}})),C={schema:d==="components"?p(E(m),h):h,examples:Ir(r,!0)};return{description:m,content:Me(et(o,[C]))}},qn=()=>({type:"http",scheme:"basic"}),$n=({format:e})=>{let t={type:"http",scheme:"bearer"};return e&&(t.bearerFormat=e),t},Vn=({name:e},t)=>{let r={type:"apiKey",in:"query",name:e};return t?.includes("body")&&(t?.includes("query")?(r["x-in-alternative"]="body",r.description=`${e} CAN also be supplied within the request body`):(r["x-in-actual"]="body",r.description=`${e} MUST be supplied within the request body instead of query`)),r},Gn=({name:e})=>({type:"apiKey",in:"header",name:e}),_n=({name:e})=>({type:"apiKey",in:"cookie",name:e}),Yn=({url:e})=>({type:"openIdConnect",openIdConnectUrl:e}),Qn=({flows:e={}})=>({type:"oauth2",flows:ye(t=>({...t,scopes:t.scopes||{}}),on(Jo,e))}),Zr=(e,t)=>{let r={basic:qn,bearer:$n,input:Vn,header:Gn,cookie:_n,openid:Yn,oauth2:Qn};return Ge(e,o=>r[o.type](o,t))},tt=e=>"or"in e?e.or.map(t=>"and"in t?Wo(ye(({name:r,scopes:o})=>br(r,o),t.and)):{[t.name]:t.scopes}):"and"in e?tt(yt(e)):tt({or:[e]}),Nr=({method:e,path:t,schema:r,mimeTypes:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:d,paramNames:c,description:l=`${e.toUpperCase()} ${t} Request body`})=>{let f=Er(Rt(te(r,{rules:{...d,...Ot},onEach:At,onMissing:Pt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:t,method:e}}),c)),m={schema:p==="components"?a(E(l),f):f,examples:Ir(r,!1,c)};return{description:l,content:Me(et(o,[m]))}},Mr=e=>Object.keys(e).map(t=>{let r=e[t],o={name:t,description:typeof r=="string"?r:r.description};return typeof r=="object"&&r.url&&(o.externalDocs={url:r.url}),o}),Ct=e=>e.length<=hr?e:e.slice(0,hr-1)+"\u2026";var It=class extends Wn{lastSecuritySchemaIds=new Map;lastOperationIdSuffixes=new Map;makeRef(t,r){return this.addSchema(t,r),this.getRef(t)}getRef(t){return t in(this.rootDoc.components?.schemas||{})?{$ref:`#/components/schemas/${t}`}:void 0}ensureUniqOperationId(t,r,o){let i=o||E(r,t),s=this.lastOperationIdSuffixes.get(i);return s===void 0?(this.lastOperationIdSuffixes.set(i,1),i):(o&&Jn.fail(new P({message:`Duplicated operationId: "${o}"`,method:r,isResponse:!1,path:t})),s++,this.lastOperationIdSuffixes.set(i,s),`${i}${s}`)}ensureUniqSecuritySchemaName(t){let r=JSON.stringify(t);for(let i in this.rootDoc.components?.securitySchemes||{})if(r===JSON.stringify(this.rootDoc.components?.securitySchemes?.[i]))return i;let o=(this.lastSecuritySchemaIds.get(t.type)||0)+1;return this.lastSecuritySchemaIds.set(t.type,o),`${t.type.toUpperCase()}_${o}`}constructor({routing:t,config:r,title:o,version:i,serverUrl:s,descriptions:a,brandHandling:p,hasSummaryFromDescription:d=!0,composition:c="inline",serializer:l=ke}){super(),this.addInfo({title:o,version:i});for(let m of typeof s=="string"?[s]:s)this.addServer({url:m});ee({routing:t,onEndpoint:(m,h,C)=>{let b=C,Z={path:h,method:b,endpoint:m,composition:c,serializer:l,brandHandling:p,getRef:this.getRef.bind(this),makeRef:this.makeRef.bind(this)},[O,x]=["short","long"].map(m.getDescription.bind(m)),xe=O?Ct(O):d&&x?Ct(x):void 0,j=m.getTags(),V=r.inputSources?.[b]||at[b],ne=this.ensureUniqOperationId(h,b,m.getOperationId(b)),be=wr({...Z,inputSources:V,schema:m.getSchema("input"),description:a?.requestParameter?.call(null,{method:b,path:h,operationId:ne})}),Le={};for(let M of["positive","negative"]){let G=m.getResponses(M);for(let{mimeTypes:Te,schema:S,statusCodes:R}of G)for(let A of R)Le[A]=zr({...Z,variant:M,schema:S,mimeTypes:Te,statusCode:A,hasMultipleStatusCodes:G.length>1||R.length>1,description:a?.[`${M}Response`]?.call(null,{method:b,path:h,operationId:ne,statusCode:A})})}let st=V.includes("body")?Nr({...Z,paramNames:Xn("name",be),schema:m.getSchema("input"),mimeTypes:m.getMimeTypes("input"),description:a?.requestBody?.call(null,{method:b,path:h,operationId:ne})}):void 0,je=tt(Ge(Zr(m.getSecurity(),V),M=>{let G=this.ensureUniqSecuritySchemaName(M),Te=["oauth2","openIdConnect"].includes(M.type)?m.getScopes().slice():[];return this.addSecurityScheme(G,M),{name:G,scopes:Te}}));this.addPath(Or(h),{[b]:{operationId:ne,summary:xe,description:x,tags:j.length>0?j:void 0,parameters:be.length>0?be:void 0,requestBody:st,security:je.length>0?je:void 0,responses:Le}})}}),this.rootDoc.tags=r.tags?Mr(r.tags):[]}};import vr from"http";var ei=({fnMethod:e,requestProps:t})=>({method:"GET",header:e(()=>w.json),...t}),ti=({fnMethod:e,responseProps:t})=>{let r={writableEnded:!1,statusCode:200,statusMessage:vr.STATUS_CODES[200],set:e(()=>r),setHeader:e(()=>r),header:e(()=>r),status:e(o=>(r.statusCode=o,r.statusMessage=vr.STATUS_CODES[o],r)),json:e(()=>r),send:e(()=>r),end:e(()=>(r.writableEnded=!0,r)),locals:{},...t};return r},ri=({fnMethod:e,loggerProps:t})=>({info:e(),warn:e(),error:e(),debug:e(),...t}),oi=async({endpoint:e,requestProps:t,responseProps:r,configProps:o,loggerProps:i,fnMethod:s})=>{let a=s||(await nr([{moduleName:"vitest",moduleExport:"vi"},{moduleName:"@jest/globals",moduleExport:"jest"}])).fn,p=ei({fnMethod:a,requestProps:t}),d=ti({fnMethod:a,responseProps:r}),c=ri({fnMethod:a,loggerProps:i}),l={cors:!1,logger:c,...o};return await e.execute({request:p,response:d,config:l,logger:c}),{requestMock:p,responseMock:d,loggerMock:c}};import z from"typescript";import L from"typescript";import{chain as Lr,toPairs as jr}from"ramda";var n=L.factory,B=[n.createModifier(L.SyntaxKind.ExportKeyword)],ni=[n.createModifier(L.SyntaxKind.AsyncKeyword)],ii=[n.createModifier(L.SyntaxKind.PublicKeyword),n.createModifier(L.SyntaxKind.ReadonlyKeyword)],Dr=[n.createModifier(L.SyntaxKind.ProtectedKeyword),n.createModifier(L.SyntaxKind.ReadonlyKeyword)],wt=n.createTemplateHead(""),ge=n.createTemplateTail(""),Et=n.createTemplateMiddle(" "),zt=e=>n.createTemplateLiteralType(wt,e.map((t,r)=>n.createTemplateLiteralTypeSpan(n.createTypeReferenceNode(t),r===e.length-1?ge:Et))),Zt=zt(["M","P"]),rt=(e,t,r)=>n.createParameterDeclaration(r,void 0,e,void 0,t,void 0),ot=(e,t)=>Lr(([r,o])=>[rt(n.createIdentifier(r),o,t)],jr(e)),Nt=(e,t)=>n.createExpressionWithTypeArguments(n.createIdentifier("Record"),[typeof e=="number"?n.createKeywordTypeNode(e):n.createTypeReferenceNode(e),n.createKeywordTypeNode(t)]),kr=e=>n.createConstructorDeclaration(void 0,e,n.createBlock([])),Hr=(e,t)=>n.createPropertySignature(void 0,e,void 0,n.createTypeReferenceNode(t)),q=(e,t,r)=>n.createVariableDeclarationList([n.createVariableDeclaration(e,void 0,r,t)],L.NodeFlags.Const),Mt=(e,t)=>n.createTypeAliasDeclaration(B,e,void 0,n.createUnionTypeNode(t.map(r=>n.createLiteralTypeNode(n.createStringLiteral(r))))),nt=(e,t)=>n.createTypeAliasDeclaration(B,e,void 0,t),Ur=(e,t,r)=>n.createPropertyDeclaration(ii,e,void 0,t,r),Fr=(e,t,r)=>n.createClassDeclaration(B,e,void 0,void 0,[t,...r]),Kr=(e,t)=>n.createTypeReferenceNode("Promise",[n.createIndexedAccessTypeNode(n.createTypeReferenceNode(e),t)]),Br=()=>n.createTypeReferenceNode("Promise",[n.createKeywordTypeNode(L.SyntaxKind.AnyKeyword)]),qr=(e,t,r)=>n.createInterfaceDeclaration(B,e,void 0,t,r),$r=e=>Lr(([t,r])=>[n.createTypeParameterDeclaration([],t,n.createTypeReferenceNode(r))],jr(e)),vt=(e,t,r)=>n.createArrowFunction(r?ni:void 0,void 0,e.map(o=>rt(o)),void 0,void 0,t),Lt=(e,t,r)=>n.createCallExpression(n.createPropertyAccessExpression(n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("Object"),"keys"),void 0,[e]),"reduce"),void 0,[n.createArrowFunction(void 0,void 0,ot({acc:void 0,key:void 0}),void 0,void 0,t),r]),Vr=(...e)=>`"${e.join(" ")}"`;var Gr=["get","post","put","delete","patch"];import g from"typescript";import{z as kt}from"zod";import $ from"typescript";var{factory:it}=$,jt=(e,t)=>{$.addSyntheticLeadingComment(e,$.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0)},he=(e,t,r)=>{let o=it.createTypeAliasDeclaration(void 0,it.createIdentifier(t),void 0,e);return r&&jt(o,r),o},Dt=(e,t)=>{let r=$.createSourceFile("print.ts","",$.ScriptTarget.Latest,!1,$.ScriptKind.TS);return $.createPrinter(t).printNode($.EmitHint.Unspecified,e,r)},si=/^[A-Za-z_$][A-Za-z0-9_$]*$/,_r=e=>si.test(e)?it.createIdentifier(e):it.createStringLiteral(e);var{factory:u}=g,ai={[g.SyntaxKind.AnyKeyword]:"",[g.SyntaxKind.BigIntKeyword]:BigInt(0),[g.SyntaxKind.BooleanKeyword]:!1,[g.SyntaxKind.NumberKeyword]:0,[g.SyntaxKind.ObjectKeyword]:{},[g.SyntaxKind.StringKeyword]:"",[g.SyntaxKind.UndefinedKeyword]:void 0},pi=({value:e})=>u.createLiteralTypeNode(typeof e=="number"?u.createNumericLiteral(e):typeof e=="boolean"?e?u.createTrue():u.createFalse():u.createStringLiteral(e)),di=({shape:e},{isResponse:t,next:r,optionalPropStyle:{withQuestionMark:o}})=>{let i=Object.entries(e).map(([s,a])=>{let p=t&&Ae(a)?a instanceof kt.ZodOptional:a.isOptional(),d=u.createPropertySignature(void 0,_r(s),p&&o?u.createToken(g.SyntaxKind.QuestionToken):void 0,r(a));return a.description&&jt(d,a.description),d});return u.createTypeLiteralNode(i)},ci=({element:e},{next:t})=>u.createArrayTypeNode(t(e)),li=({options:e})=>u.createUnionTypeNode(e.map(t=>u.createLiteralTypeNode(u.createStringLiteral(t)))),Yr=({options:e},{next:t})=>u.createUnionTypeNode(e.map(t)),mi=e=>ai?.[e.kind],ui=(e,{next:t,isResponse:r})=>{let o=t(e.innerType()),i=e._def.effect;if(r&&i.type==="transform"){let s=He(e,mi(o)),a={number:g.SyntaxKind.NumberKeyword,bigint:g.SyntaxKind.BigIntKeyword,boolean:g.SyntaxKind.BooleanKeyword,string:g.SyntaxKind.StringKeyword,undefined:g.SyntaxKind.UndefinedKeyword,object:g.SyntaxKind.ObjectKeyword};return u.createKeywordTypeNode(s&&a[s]||g.SyntaxKind.AnyKeyword)}return o},fi=e=>u.createUnionTypeNode(Object.values(e.enum).map(t=>u.createLiteralTypeNode(typeof t=="number"?u.createNumericLiteral(t):u.createStringLiteral(t)))),yi=(e,{next:t,optionalPropStyle:{withUndefined:r}})=>{let o=t(e.unwrap());return r?u.createUnionTypeNode([o,u.createKeywordTypeNode(g.SyntaxKind.UndefinedKeyword)]):o},gi=(e,{next:t})=>u.createUnionTypeNode([t(e.unwrap()),u.createLiteralTypeNode(u.createNull())]),hi=({items:e,_def:{rest:t}},{next:r})=>u.createTupleTypeNode(e.map(r).concat(t===null?[]:u.createRestTypeNode(r(t)))),xi=({keySchema:e,valueSchema:t},{next:r})=>u.createExpressionWithTypeArguments(u.createIdentifier("Record"),[e,t].map(r)),bi=({_def:e},{next:t})=>u.createIntersectionTypeNode([e.left,e.right].map(t)),Ti=({_def:e},{next:t})=>t(e.innerType),oe=e=>()=>u.createKeywordTypeNode(e),Si=(e,{next:t})=>t(e.unwrap()),Ri=(e,{next:t})=>t(e.unwrap()),Oi=({_def:e},{next:t})=>t(e.innerType),Ai=({_def:e},{next:t,isResponse:r})=>t(e[r?"out":"in"]),Pi=()=>u.createLiteralTypeNode(u.createNull()),Ci=({schema:e},{getAlias:t,makeAlias:r,next:o,serializer:i})=>{let s=`Type${i(e)}`;return t(s)||(r(s,u.createLiteralTypeNode(u.createNull())),r(s,o(e)))},Ii=e=>{let t=e.unwrap(),r=u.createKeywordTypeNode(g.SyntaxKind.StringKeyword),o=u.createTypeReferenceNode("Buffer"),i=u.createUnionTypeNode([r,o]);return t instanceof kt.ZodString?r:t instanceof kt.ZodUnion?i:o},wi=(e,{next:t})=>t(e.unwrap().shape.raw),Ei={ZodString:oe(g.SyntaxKind.StringKeyword),ZodNumber:oe(g.SyntaxKind.NumberKeyword),ZodBigInt:oe(g.SyntaxKind.BigIntKeyword),ZodBoolean:oe(g.SyntaxKind.BooleanKeyword),ZodAny:oe(g.SyntaxKind.AnyKeyword),[Ze]:oe(g.SyntaxKind.StringKeyword),[Ne]:oe(g.SyntaxKind.StringKeyword),ZodNull:Pi,ZodArray:ci,ZodTuple:hi,ZodRecord:xi,ZodObject:di,ZodLiteral:pi,ZodIntersection:bi,ZodUnion:Yr,ZodDefault:Ti,ZodEnum:li,ZodNativeEnum:fi,ZodEffects:ui,ZodOptional:yi,ZodNullable:gi,ZodDiscriminatedUnion:Yr,ZodBranded:Si,ZodCatch:Oi,ZodPipeline:Ai,ZodLazy:Ci,ZodReadonly:Ri,[F]:Ii,[J]:wi},ve=(e,{brandHandling:t,ctx:r})=>te(e,{rules:{...t,...Ei},onMissing:()=>u.createKeywordTypeNode(g.SyntaxKind.AnyKeyword),ctx:r});var Ht=class{program=[];usage=[];registry=new Map;paths=[];aliases=new Map;ids={pathType:n.createIdentifier("Path"),methodType:n.createIdentifier("Method"),methodPathType:n.createIdentifier("MethodPath"),inputInterface:n.createIdentifier("Input"),posResponseInterface:n.createIdentifier("PositiveResponse"),negResponseInterface:n.createIdentifier("NegativeResponse"),responseInterface:n.createIdentifier("Response"),jsonEndpointsConst:n.createIdentifier("jsonEndpoints"),endpointTagsConst:n.createIdentifier("endpointTags"),providerType:n.createIdentifier("Provider"),implementationType:n.createIdentifier("Implementation"),clientClass:n.createIdentifier("ExpressZodAPIClient"),keyParameter:n.createIdentifier("key"),pathParameter:n.createIdentifier("path"),paramsArgument:n.createIdentifier("params"),methodParameter:n.createIdentifier("method"),accumulator:n.createIdentifier("acc"),provideMethod:n.createIdentifier("provide"),implementationArgument:n.createIdentifier("implementation"),headersProperty:n.createIdentifier("headers"),hasBodyConst:n.createIdentifier("hasBody"),undefinedValue:n.createIdentifier("undefined"),bodyProperty:n.createIdentifier("body"),responseConst:n.createIdentifier("response"),searchParamsConst:n.createIdentifier("searchParams"),exampleImplementationConst:n.createIdentifier("exampleImplementation"),clientConst:n.createIdentifier("client")};interfaces=[];getAlias(t){return this.aliases.has(t)?n.createTypeReferenceNode(t):void 0}makeAlias(t,r){return this.aliases.set(t,he(r,t)),this.getAlias(t)}constructor({routing:t,brandHandling:r,variant:o="client",serializer:i=ke,splitResponse:s=!1,optionalPropStyle:a={withQuestionMark:!0,withUndefined:!0}}){ee({routing:t,onEndpoint:(S,R,A)=>{let ie={serializer:i,getAlias:this.getAlias.bind(this),makeAlias:this.makeAlias.bind(this),optionalPropStyle:a},Se=E(A,R,"input"),Re=ve(S.getSchema("input"),{brandHandling:r,ctx:{...ie,isResponse:!1}}),I=s?E(A,R,"positive.response"):void 0,Ut=S.getSchema("positive"),Ft=s?ve(Ut,{brandHandling:r,ctx:{...ie,isResponse:!0}}):void 0,Oe=s?E(A,R,"negative.response"):void 0,Kt=S.getSchema("negative"),Bt=s?ve(Kt,{brandHandling:r,ctx:{...ie,isResponse:!0}}):void 0,qt=E(A,R,"response"),Qr=I&&Oe?n.createUnionTypeNode([n.createTypeReferenceNode(I),n.createTypeReferenceNode(Oe)]):ve(Ut.or(Kt),{brandHandling:r,ctx:{...ie,isResponse:!0}});this.program.push(he(Re,Se)),Ft&&I&&this.program.push(he(Ft,I)),Bt&&Oe&&this.program.push(he(Bt,Oe)),this.program.push(he(Qr,qt)),A!=="options"&&(this.paths.push(R),this.registry.set({method:A,path:R},{input:Se,positive:I,negative:Oe,response:qt,isJson:S.getMimeTypes("positive").includes(w.json),tags:S.getTags()}))}}),this.program.unshift(...this.aliases.values()),this.program.push(Mt(this.ids.pathType,this.paths)),this.program.push(Mt(this.ids.methodType,Gr)),this.program.push(nt(this.ids.methodPathType,zt([this.ids.methodType,this.ids.pathType])));let p=[n.createHeritageClause(z.SyntaxKind.ExtendsKeyword,[Nt(this.ids.methodPathType,z.SyntaxKind.AnyKeyword)])];this.interfaces.push({id:this.ids.inputInterface,kind:"input",props:[]}),s&&this.interfaces.push({id:this.ids.posResponseInterface,kind:"positive",props:[]},{id:this.ids.negResponseInterface,kind:"negative",props:[]}),this.interfaces.push({id:this.ids.responseInterface,kind:"response",props:[]});let d=[],c=[];for(let[{method:S,path:R},{isJson:A,tags:ie,...Se}]of this.registry){let Re=Vr(S,R);for(let I of this.interfaces)I.kind in Se&&I.props.push(Hr(Re,Se[I.kind]));o!=="types"&&(A&&d.push(n.createPropertyAssignment(Re,n.createTrue())),c.push(n.createPropertyAssignment(Re,n.createArrayLiteralExpression(ie.map(I=>n.createStringLiteral(I))))))}for(let{id:S,props:R}of this.interfaces)this.program.push(qr(S,p,R));if(o==="types")return;let l=n.createVariableStatement(B,q(this.ids.jsonEndpointsConst,n.createObjectLiteralExpression(d))),f=n.createVariableStatement(B,q(this.ids.endpointTagsConst,n.createObjectLiteralExpression(c))),m=nt(this.ids.providerType,n.createFunctionTypeNode($r({M:this.ids.methodType,P:this.ids.pathType}),ot({method:n.createTypeReferenceNode("M"),path:n.createTypeReferenceNode("P"),params:n.createIndexedAccessTypeNode(n.createTypeReferenceNode(this.ids.inputInterface),Zt)}),Kr(this.ids.responseInterface,Zt))),h=nt(this.ids.implementationType,n.createFunctionTypeNode(void 0,ot({method:n.createTypeReferenceNode(this.ids.methodType),path:n.createKeywordTypeNode(z.SyntaxKind.StringKeyword),params:Nt(z.SyntaxKind.StringKeyword,z.SyntaxKind.AnyKeyword)}),Br())),C=n.createTemplateExpression(n.createTemplateHead(":"),[n.createTemplateSpan(this.ids.keyParameter,ge)]),b=Lt(this.ids.paramsArgument,n.createCallExpression(n.createPropertyAccessExpression(this.ids.accumulator,"replace"),void 0,[C,n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter)]),this.ids.pathParameter),Z=Lt(this.ids.paramsArgument,n.createConditionalExpression(n.createBinaryExpression(n.createCallExpression(n.createPropertyAccessExpression(this.ids.pathParameter,"indexOf"),void 0,[C]),z.SyntaxKind.GreaterThanEqualsToken,n.createNumericLiteral(0)),void 0,this.ids.accumulator,void 0,n.createObjectLiteralExpression([n.createSpreadAssignment(this.ids.accumulator),n.createPropertyAssignment(n.createComputedPropertyName(this.ids.keyParameter),n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter))])),n.createObjectLiteralExpression()),O=Fr(this.ids.clientClass,kr([rt(this.ids.implementationArgument,n.createTypeReferenceNode(this.ids.implementationType),Dr)]),[Ur(this.ids.provideMethod,n.createTypeReferenceNode(this.ids.providerType),vt([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createCallExpression(n.createPropertyAccessExpression(n.createThis(),this.ids.implementationArgument),void 0,[this.ids.methodParameter,b,Z]),!0))]);this.program.push(l,f,m,h,O);let x=n.createPropertyAssignment(this.ids.methodParameter,n.createCallExpression(n.createPropertyAccessExpression(this.ids.methodParameter,"toUpperCase"),void 0,void 0)),xe=n.createPropertyAssignment(this.ids.headersProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createObjectLiteralExpression([n.createPropertyAssignment(n.createStringLiteral("Content-Type"),n.createStringLiteral(w.json))]),void 0,this.ids.undefinedValue)),j=n.createPropertyAssignment(this.ids.bodyProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("JSON"),"stringify"),void 0,[this.ids.paramsArgument]),void 0,this.ids.undefinedValue)),V=n.createVariableStatement(void 0,q(this.ids.responseConst,n.createAwaitExpression(n.createCallExpression(n.createIdentifier("fetch"),void 0,[n.createTemplateExpression(n.createTemplateHead("https://example.com"),[n.createTemplateSpan(this.ids.pathParameter,n.createTemplateMiddle("")),n.createTemplateSpan(this.ids.searchParamsConst,ge)]),n.createObjectLiteralExpression([x,xe,j])])))),ne=n.createVariableStatement(void 0,q(this.ids.hasBodyConst,n.createLogicalNot(n.createCallExpression(n.createPropertyAccessExpression(n.createArrayLiteralExpression([n.createStringLiteral("get"),n.createStringLiteral("delete")]),"includes"),void 0,[this.ids.methodParameter])))),be=n.createVariableStatement(void 0,q(this.ids.searchParamsConst,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createStringLiteral(""),void 0,n.createTemplateExpression(n.createTemplateHead("?"),[n.createTemplateSpan(n.createNewExpression(n.createIdentifier("URLSearchParams"),void 0,[this.ids.paramsArgument]),ge)])))),[Le,st]=["json","text"].map(S=>n.createReturnStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.responseConst,S),void 0,void 0))),je=n.createIfStatement(n.createBinaryExpression(n.createTemplateExpression(wt,[n.createTemplateSpan(this.ids.methodParameter,Et),n.createTemplateSpan(this.ids.pathParameter,ge)]),z.SyntaxKind.InKeyword,this.ids.jsonEndpointsConst),n.createBlock([Le])),M=n.createVariableStatement(B,q(this.ids.exampleImplementationConst,vt([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createBlock([ne,be,V,je,st]),!0),n.createTypeReferenceNode(this.ids.implementationType))),G=n.createExpressionStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.clientConst,this.ids.provideMethod),void 0,[n.createStringLiteral("get"),n.createStringLiteral("/v1/user/retrieve"),n.createObjectLiteralExpression([n.createPropertyAssignment("id",n.createStringLiteral("10"))])])),Te=n.createVariableStatement(void 0,q(this.ids.clientConst,n.createNewExpression(this.ids.clientClass,void 0,[this.ids.exampleImplementationConst])));this.usage.push(M,Te,G)}printUsage(t){return this.usage.length?this.usage.map(r=>typeof r=="string"?r:Dt(r,t)).join(`
|
|
20
|
+
`)};var fr=e=>{e.startupLogo!==!1&&console.log(ur());let t=e.errorHandler||Ce,r=or(e.logger)?e.logger:new ue(e.logger);r.debug("Running","v19.2.1 (ESM)");let o=lr({rootLogger:r,config:e}),i=pr({rootLogger:r,errorHandler:t}),s=ar({rootLogger:r,errorHandler:t});return{rootLogger:r,errorHandler:t,notFoundHandler:i,parserFailureHandler:s,loggingMiddleware:o}},Ko=(e,t)=>{let{rootLogger:r,notFoundHandler:o,loggingMiddleware:i}=fr(e);return Tt({app:e.app.use(i),routing:t,rootLogger:r,config:e}),{notFoundHandler:o,logger:r}},Bo=async(e,t)=>{let{rootLogger:r,notFoundHandler:o,parserFailureHandler:i,loggingMiddleware:s}=fr(e),a=St().disable("x-powered-by").use(s);if(e.server.compression){let l=await X("compression");a.use(l(typeof e.server.compression=="object"?e.server.compression:void 0))}let p={json:[e.server.jsonParser||St.json()],raw:[e.server.rawParser||St.raw(),cr],upload:e.server.upload?await dr({config:e,rootLogger:r}):[]};e.server.beforeRouting&&await e.server.beforeRouting({app:a,logger:r}),Tt({app:a,routing:t,rootLogger:r,config:e,parsers:p}),a.use(i,o);let d=(l,f)=>l.listen(f,()=>{r.info("Listening",f)}),c={httpServer:d(Uo.createServer(a),e.server.listen),httpsServer:e.https?d(Fo.createServer(e.https.options,a),e.https.listen):void 0};return{app:a,...c,logger:r}};import Jn from"assert/strict";import{OpenApiBuilder as Wn}from"openapi3-ts/oas31";import{pluck as Xn}from"ramda";import K from"assert/strict";import{isReferenceObject as re}from"openapi3-ts/oas31";import{both as $o,complement as Vo,concat as Go,type as _o,filter as Yo,fromPairs as Me,has as Qo,isNil as Jo,map as ye,mergeAll as Wo,mergeDeepRight as Xo,mergeDeepWith as en,objOf as br,omit as Xe,pipe as Tr,pluck as tn,range as rn,reject as on,toLower as nn,union as sn,when as an,xprod as et,zip as pn}from"ramda";import{z as T}from"zod";import{z as ze}from"zod";var Je=e=>!isNaN(e.getTime());var Ze=Symbol("DateIn"),yr=()=>ze.union([ze.string().date(),ze.string().datetime(),ze.string().datetime({local:!0})]).transform(t=>new Date(t)).pipe(ze.date().refine(Je)).brand(Ze);import{z as qo}from"zod";var Ne=Symbol("DateOut"),gr=()=>qo.date().refine(Je).transform(e=>e.toISOString()).brand(Ne);var te=(e,{onEach:t,rules:r,onMissing:o,ctx:i={}})=>{let s=r[e._def[y]?.brand]||r[e._def.typeName],p=s?s(e,{...i,next:c=>te(c,{ctx:i,onEach:t,rules:r,onMissing:o})}):o(e,i),d=t&&t(e,{prev:p,...i});return d?{...p,...d}:p};var hr=50,Sr="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString",dn={integer:0,number:0,string:"",boolean:!1,object:{},null:null,array:[]},Rr=/:([A-Za-z0-9_]+)/g,cn=e=>e.match(Rr)?.map(t=>t.slice(1))||[],Or=e=>e.replace(Rr,t=>`{${t.slice(1)}}`),ln=({_def:e},{next:t})=>({...t(e.innerType),default:e[y]?.defaultLabel||e.defaultValue()}),mn=({_def:{innerType:e}},{next:t})=>t(e),un=()=>({format:"any"}),fn=({},e)=>(K(!e.isResponse,new P({message:"Please use ez.upload() only for input.",...e})),{type:"string",format:"binary"}),yn=e=>{let t=e.unwrap();return{type:"string",format:t instanceof T.ZodString?t._def.checks.find(r=>r.kind==="base64")?"byte":"file":"binary"}},gn=({options:e},{next:t})=>({oneOf:e.map(t)}),hn=({options:e,discriminator:t},{next:r})=>({discriminator:{propertyName:t},oneOf:e.map(r)}),xn=e=>{let[t,r]=e.filter(i=>!re(i)&&i.type==="object"&&Object.keys(i).every(s=>["type","properties","required","examples"].includes(s)));K(t&&r,"Can not flatten objects");let o={type:"object"};return(t.properties||r.properties)&&(o.properties=en((i,s)=>Array.isArray(i)&&Array.isArray(s)?Go(i,s):i===s?s:K.fail("Can not flatten properties"),t.properties||{},r.properties||{})),(t.required||r.required)&&(o.required=sn(t.required||[],r.required||[])),(t.examples||r.examples)&&(o.examples=Q(t.examples||[],r.examples||[],([i,s])=>Xo(i,s))),o},bn=({_def:{left:e,right:t}},{next:r})=>{let o=[e,t].map(r);try{return xn(o)}catch{}return{allOf:o}},Tn=(e,{next:t})=>t(e.unwrap()),Sn=(e,{next:t})=>t(e.unwrap()),Rn=(e,{next:t})=>{let r=t(e.unwrap());return re(r)||(r.type=Pr(r)),r},Ar=e=>{let t=nn(_o(e));return typeof e=="bigint"?"integer":t==="number"||t==="string"||t==="boolean"||t==="object"||t==="null"||t==="array"?t:void 0},xr=e=>({type:Ar(Object.values(e.enum)[0]),enum:Object.values(e.enum)}),On=({value:e})=>({type:Ar(e),const:e}),An=(e,{isResponse:t,next:r})=>{let o=Object.keys(e.shape),i=p=>t&&Ae(p)?p instanceof T.ZodOptional:p.isOptional(),s=o.filter(p=>!i(e.shape[p])),a={type:"object"};return o.length&&(a.properties=We(e,r)),s.length&&(a.required=s),a},Pn=()=>({type:"null"}),Cn=({},e)=>(K(!e.isResponse,new P({message:"Please use ez.dateOut() for output.",...e})),{description:"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?$/.source,externalDocs:{url:Sr}}),In=({},e)=>(K(e.isResponse,new P({message:"Please use ez.dateIn() for input.",...e})),{description:"YYYY-MM-DDTHH:mm:ss.sssZ",type:"string",format:"date-time",externalDocs:{url:Sr}}),wn=({},e)=>K.fail(new P({message:`Using z.date() within ${e.isResponse?"output":"input"} schema is forbidden. Please use ez.date${e.isResponse?"Out":"In"}() instead. Check out the documentation for details.`,...e})),En=()=>({type:"boolean"}),zn=()=>({type:"integer",format:"bigint"}),Zn=e=>e.every(t=>t instanceof T.ZodLiteral),Nn=({keySchema:e,valueSchema:t},{next:r})=>{if(e instanceof T.ZodEnum||e instanceof T.ZodNativeEnum){let o=Object.values(e.enum),i={type:"object"};return o.length&&(i.properties=We(T.object(Me(et(o,[t]))),r),i.required=o),i}if(e instanceof T.ZodLiteral)return{type:"object",properties:We(T.object({[e.value]:t}),r),required:[e.value]};if(e instanceof T.ZodUnion&&Zn(e.options)){let o=ye(s=>`${s.value}`,e.options),i=Me(et(o,[t]));return{type:"object",properties:We(T.object(i),r),required:o}}return{type:"object",additionalProperties:r(t)}},Mn=({_def:{minLength:e,maxLength:t},element:r},{next:o})=>{let i={type:"array",items:o(r)};return e&&(i.minItems=e.value),t&&(i.maxItems=t.value),i},vn=({items:e,_def:{rest:t}},{next:r})=>({type:"array",prefixItems:e.map(r),items:t===null?{not:{}}:r(t)}),Ln=({isEmail:e,isURL:t,minLength:r,maxLength:o,isUUID:i,isCUID:s,isCUID2:a,isULID:p,isIP:d,isEmoji:c,isDatetime:l,_def:{checks:f}})=>{let m=f.find(O=>O.kind==="regex"),h=f.find(O=>O.kind==="datetime"),C=m?m.regex:h?h.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}:\\d{2})|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"):void 0,b={type:"string"},Z={"date-time":l,email:e,url:t,uuid:i,cuid:s,cuid2:a,ulid:p,ip:d,emoji:c};for(let O in Z)if(Z[O]){b.format=O;break}return r!==null&&(b.minLength=r),o!==null&&(b.maxLength=o),C&&(b.pattern=C.source),b},jn=({isInt:e,maxValue:t,minValue:r,_def:{checks:o}})=>{let i=o.find(({kind:f})=>f==="min"),s=r===null?e?Number.MIN_SAFE_INTEGER:-Number.MAX_VALUE:r,a=i?i.inclusive:!0,p=o.find(({kind:f})=>f==="max"),d=t===null?e?Number.MAX_SAFE_INTEGER:Number.MAX_VALUE:t,c=p?p.inclusive:!0,l={type:e?"integer":"number",format:e?"int64":"double"};return a?l.minimum=s:l.exclusiveMinimum=s,c?l.maximum=d:l.exclusiveMaximum=d,l},We=({shape:e},t)=>ye(t,e),Dn=e=>{let t=Array.isArray(e.type)?e.type[0]:e.type;return dn?.[t]},Pr=e=>{let t=typeof e.type=="string"?[e.type]:e.type||[];return t.includes("null")?t:t.concat("null")},kn=(e,{isResponse:t,next:r})=>{let o=r(e.innerType()),{effect:i}=e._def;if(t&&i.type==="transform"&&!re(o)){let s=He(e,Dn(o));return s&&["number","string","boolean"].includes(s)?{type:s}:r(T.any())}if(!t&&i.type==="preprocess"&&!re(o)){let{type:s,...a}=o;return{...a,format:`${a.format||s} (preprocessed)`}}return o},Hn=({_def:e},{isResponse:t,next:r})=>r(e[t?"out":"in"]),Un=(e,{next:t})=>t(e.unwrap()),Fn=({schema:e},{next:t,serializer:r,getRef:o,makeRef:i})=>{let s=r(e);return o(s)||(i(s,{}),i(s,t(e)))},Kn=(e,{next:t})=>t(e.unwrap().shape.raw),Cr=e=>e.length?Me(pn(rn(1,e.length+1).map(t=>`example${t}`),ye(br("value"),e))):void 0,Ir=(e,t,r=[])=>Tr(U,ye(an($o(v,Vo(Array.isArray)),Xe(r))),Cr)({schema:e,variant:t?"parsed":"original",validate:!0}),Bn=(e,t)=>Tr(U,Yo(Qo(t)),tn(t),Cr)({schema:e,variant:"original",validate:!0}),fe=(e,t)=>e instanceof T.ZodObject?e:e instanceof T.ZodBranded?fe(e.unwrap(),t):e instanceof T.ZodUnion||e instanceof T.ZodDiscriminatedUnion?e.options.map(r=>fe(r,t)).reduce((r,o)=>r.merge(o.partial()),T.object({})):e instanceof T.ZodEffects?(K(e._def.effect.type==="refinement",t),fe(e._def.schema,t)):fe(e._def.left,t).merge(fe(e._def.right,t)),wr=({path:e,method:t,schema:r,inputSources:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:d,description:c=`${t.toUpperCase()} ${e} Parameter`})=>{let{shape:l}=fe(r,new P({message:"Using transformations on the top level schema is not allowed.",path:e,method:t,isResponse:!1})),f=cn(e),m=o.includes("query"),h=o.includes("params"),C=o.includes("headers"),b=x=>h&&f.includes(x),Z=x=>C&&dt(x);return Object.keys(l).map(x=>({name:x,location:b(x)?"path":Z(x)?"header":m?"query":void 0})).filter(x=>x.location!==void 0).map(({name:x,location:xe})=>{let j=te(l[x],{rules:{...d,...Ot},onEach:At,onMissing:Pt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:e,method:t}}),V=p==="components"?a(E(c,x),j):j;return{name:x,in:xe,required:!l[x].isOptional(),description:j.description||c,schema:V,examples:Bn(r,x)}})},Ot={ZodString:Ln,ZodNumber:jn,ZodBigInt:zn,ZodBoolean:En,ZodNull:Pn,ZodArray:Mn,ZodTuple:vn,ZodRecord:Nn,ZodObject:An,ZodLiteral:On,ZodIntersection:bn,ZodUnion:gn,ZodAny:un,ZodDefault:ln,ZodEnum:xr,ZodNativeEnum:xr,ZodEffects:kn,ZodOptional:Tn,ZodNullable:Rn,ZodDiscriminatedUnion:hn,ZodBranded:Un,ZodDate:wn,ZodCatch:mn,ZodPipeline:Hn,ZodLazy:Fn,ZodReadonly:Sn,[F]:yn,[Pe]:fn,[Ne]:In,[Ze]:Cn,[J]:Kn},At=(e,{isResponse:t,prev:r})=>{if(re(r))return{};let{description:o}=e,i=e instanceof T.ZodLazy,s=r.type!==void 0,a=t&&Ae(e),p=!i&&s&&!a&&e.isNullable(),d=i?[]:U({schema:e,variant:t?"parsed":"original",validate:!0}),c={};return o&&(c.description=o),p&&(c.type=Pr(r)),d.length&&(c.examples=d.slice()),c},Pt=(e,t)=>K.fail(new P({message:`Zod type ${e.constructor.name} is unsupported.`,...t})),Rt=(e,t)=>{if(re(e))return e;let r={...e};return r.properties&&(r.properties=Xe(t,r.properties)),r.examples&&(r.examples=r.examples.map(o=>Xe(t,o))),r.required&&(r.required=r.required.filter(o=>!t.includes(o))),r.allOf&&(r.allOf=r.allOf.map(o=>Rt(o,t))),r.oneOf&&(r.oneOf=r.oneOf.map(o=>Rt(o,t))),r},Er=e=>re(e)?e:Xe(["examples"],e),zr=({method:e,path:t,schema:r,mimeTypes:o,variant:i,serializer:s,getRef:a,makeRef:p,composition:d,hasMultipleStatusCodes:c,statusCode:l,brandHandling:f,description:m=`${e.toUpperCase()} ${t} ${lt(i)} response ${c?l:""}`.trim()})=>{let h=Er(te(r,{rules:{...f,...Ot},onEach:At,onMissing:Pt,ctx:{isResponse:!0,serializer:s,getRef:a,makeRef:p,path:t,method:e}})),C={schema:d==="components"?p(E(m),h):h,examples:Ir(r,!0)};return{description:m,content:Me(et(o,[C]))}},qn=()=>({type:"http",scheme:"basic"}),$n=({format:e})=>{let t={type:"http",scheme:"bearer"};return e&&(t.bearerFormat=e),t},Vn=({name:e},t)=>{let r={type:"apiKey",in:"query",name:e};return t?.includes("body")&&(t?.includes("query")?(r["x-in-alternative"]="body",r.description=`${e} CAN also be supplied within the request body`):(r["x-in-actual"]="body",r.description=`${e} MUST be supplied within the request body instead of query`)),r},Gn=({name:e})=>({type:"apiKey",in:"header",name:e}),_n=({name:e})=>({type:"apiKey",in:"cookie",name:e}),Yn=({url:e})=>({type:"openIdConnect",openIdConnectUrl:e}),Qn=({flows:e={}})=>({type:"oauth2",flows:ye(t=>({...t,scopes:t.scopes||{}}),on(Jo,e))}),Zr=(e,t)=>{let r={basic:qn,bearer:$n,input:Vn,header:Gn,cookie:_n,openid:Yn,oauth2:Qn};return Ge(e,o=>r[o.type](o,t))},tt=e=>"or"in e?e.or.map(t=>"and"in t?Wo(ye(({name:r,scopes:o})=>br(r,o),t.and)):{[t.name]:t.scopes}):"and"in e?tt(yt(e)):tt({or:[e]}),Nr=({method:e,path:t,schema:r,mimeTypes:o,serializer:i,getRef:s,makeRef:a,composition:p,brandHandling:d,paramNames:c,description:l=`${e.toUpperCase()} ${t} Request body`})=>{let f=Er(Rt(te(r,{rules:{...d,...Ot},onEach:At,onMissing:Pt,ctx:{isResponse:!1,serializer:i,getRef:s,makeRef:a,path:t,method:e}}),c)),m={schema:p==="components"?a(E(l),f):f,examples:Ir(r,!1,c)};return{description:l,content:Me(et(o,[m]))}},Mr=e=>Object.keys(e).map(t=>{let r=e[t],o={name:t,description:typeof r=="string"?r:r.description};return typeof r=="object"&&r.url&&(o.externalDocs={url:r.url}),o}),Ct=e=>e.length<=hr?e:e.slice(0,hr-1)+"\u2026";var It=class extends Wn{lastSecuritySchemaIds=new Map;lastOperationIdSuffixes=new Map;makeRef(t,r){return this.addSchema(t,r),this.getRef(t)}getRef(t){return t in(this.rootDoc.components?.schemas||{})?{$ref:`#/components/schemas/${t}`}:void 0}ensureUniqOperationId(t,r,o){let i=o||E(r,t),s=this.lastOperationIdSuffixes.get(i);return s===void 0?(this.lastOperationIdSuffixes.set(i,1),i):(o&&Jn.fail(new P({message:`Duplicated operationId: "${o}"`,method:r,isResponse:!1,path:t})),s++,this.lastOperationIdSuffixes.set(i,s),`${i}${s}`)}ensureUniqSecuritySchemaName(t){let r=JSON.stringify(t);for(let i in this.rootDoc.components?.securitySchemes||{})if(r===JSON.stringify(this.rootDoc.components?.securitySchemes?.[i]))return i;let o=(this.lastSecuritySchemaIds.get(t.type)||0)+1;return this.lastSecuritySchemaIds.set(t.type,o),`${t.type.toUpperCase()}_${o}`}constructor({routing:t,config:r,title:o,version:i,serverUrl:s,descriptions:a,brandHandling:p,hasSummaryFromDescription:d=!0,composition:c="inline",serializer:l=ke}){super(),this.addInfo({title:o,version:i});for(let m of typeof s=="string"?[s]:s)this.addServer({url:m});ee({routing:t,onEndpoint:(m,h,C)=>{let b=C,Z={path:h,method:b,endpoint:m,composition:c,serializer:l,brandHandling:p,getRef:this.getRef.bind(this),makeRef:this.makeRef.bind(this)},[O,x]=["short","long"].map(m.getDescription.bind(m)),xe=O?Ct(O):d&&x?Ct(x):void 0,j=m.getTags(),V=r.inputSources?.[b]||at[b],ne=this.ensureUniqOperationId(h,b,m.getOperationId(b)),be=wr({...Z,inputSources:V,schema:m.getSchema("input"),description:a?.requestParameter?.call(null,{method:b,path:h,operationId:ne})}),Le={};for(let M of["positive","negative"]){let G=m.getResponses(M);for(let{mimeTypes:Te,schema:S,statusCodes:R}of G)for(let A of R)Le[A]=zr({...Z,variant:M,schema:S,mimeTypes:Te,statusCode:A,hasMultipleStatusCodes:G.length>1||R.length>1,description:a?.[`${M}Response`]?.call(null,{method:b,path:h,operationId:ne,statusCode:A})})}let st=V.includes("body")?Nr({...Z,paramNames:Xn("name",be),schema:m.getSchema("input"),mimeTypes:m.getMimeTypes("input"),description:a?.requestBody?.call(null,{method:b,path:h,operationId:ne})}):void 0,je=tt(Ge(Zr(m.getSecurity(),V),M=>{let G=this.ensureUniqSecuritySchemaName(M),Te=["oauth2","openIdConnect"].includes(M.type)?m.getScopes().slice():[];return this.addSecurityScheme(G,M),{name:G,scopes:Te}}));this.addPath(Or(h),{[b]:{operationId:ne,summary:xe,description:x,tags:j.length>0?j:void 0,parameters:be.length>0?be:void 0,requestBody:st,security:je.length>0?je:void 0,responses:Le}})}}),this.rootDoc.tags=r.tags?Mr(r.tags):[]}};import vr from"http";var ei=({fnMethod:e,requestProps:t})=>({method:"GET",header:e(()=>w.json),...t}),ti=({fnMethod:e,responseProps:t})=>{let r={writableEnded:!1,statusCode:200,statusMessage:vr.STATUS_CODES[200],set:e(()=>r),setHeader:e(()=>r),header:e(()=>r),status:e(o=>(r.statusCode=o,r.statusMessage=vr.STATUS_CODES[o],r)),json:e(()=>r),send:e(()=>r),end:e(()=>(r.writableEnded=!0,r)),locals:{},...t};return r},ri=({fnMethod:e,loggerProps:t})=>({info:e(),warn:e(),error:e(),debug:e(),...t}),oi=async({endpoint:e,requestProps:t,responseProps:r,configProps:o,loggerProps:i,fnMethod:s})=>{let a=s||(await nr([{moduleName:"vitest",moduleExport:"vi"},{moduleName:"@jest/globals",moduleExport:"jest"}])).fn,p=ei({fnMethod:a,requestProps:t}),d=ti({fnMethod:a,responseProps:r}),c=ri({fnMethod:a,loggerProps:i}),l={cors:!1,logger:c,...o};return await e.execute({request:p,response:d,config:l,logger:c}),{requestMock:p,responseMock:d,loggerMock:c}};import z from"typescript";import L from"typescript";import{chain as Lr,toPairs as jr}from"ramda";var n=L.factory,B=[n.createModifier(L.SyntaxKind.ExportKeyword)],ni=[n.createModifier(L.SyntaxKind.AsyncKeyword)],ii=[n.createModifier(L.SyntaxKind.PublicKeyword),n.createModifier(L.SyntaxKind.ReadonlyKeyword)],Dr=[n.createModifier(L.SyntaxKind.ProtectedKeyword),n.createModifier(L.SyntaxKind.ReadonlyKeyword)],wt=n.createTemplateHead(""),ge=n.createTemplateTail(""),Et=n.createTemplateMiddle(" "),zt=e=>n.createTemplateLiteralType(wt,e.map((t,r)=>n.createTemplateLiteralTypeSpan(n.createTypeReferenceNode(t),r===e.length-1?ge:Et))),Zt=zt(["M","P"]),rt=(e,t,r)=>n.createParameterDeclaration(r,void 0,e,void 0,t,void 0),ot=(e,t)=>Lr(([r,o])=>[rt(n.createIdentifier(r),o,t)],jr(e)),Nt=(e,t)=>n.createExpressionWithTypeArguments(n.createIdentifier("Record"),[typeof e=="number"?n.createKeywordTypeNode(e):n.createTypeReferenceNode(e),n.createKeywordTypeNode(t)]),kr=e=>n.createConstructorDeclaration(void 0,e,n.createBlock([])),Hr=(e,t)=>n.createPropertySignature(void 0,e,void 0,n.createTypeReferenceNode(t)),q=(e,t,r)=>n.createVariableDeclarationList([n.createVariableDeclaration(e,void 0,r,t)],L.NodeFlags.Const),Mt=(e,t)=>n.createTypeAliasDeclaration(B,e,void 0,n.createUnionTypeNode(t.map(r=>n.createLiteralTypeNode(n.createStringLiteral(r))))),nt=(e,t)=>n.createTypeAliasDeclaration(B,e,void 0,t),Ur=(e,t,r)=>n.createPropertyDeclaration(ii,e,void 0,t,r),Fr=(e,t,r)=>n.createClassDeclaration(B,e,void 0,void 0,[t,...r]),Kr=(e,t)=>n.createTypeReferenceNode("Promise",[n.createIndexedAccessTypeNode(n.createTypeReferenceNode(e),t)]),Br=()=>n.createTypeReferenceNode("Promise",[n.createKeywordTypeNode(L.SyntaxKind.AnyKeyword)]),qr=(e,t,r)=>n.createInterfaceDeclaration(B,e,void 0,t,r),$r=e=>Lr(([t,r])=>[n.createTypeParameterDeclaration([],t,n.createTypeReferenceNode(r))],jr(e)),vt=(e,t,r)=>n.createArrowFunction(r?ni:void 0,void 0,e.map(o=>rt(o)),void 0,void 0,t),Lt=(e,t,r)=>n.createCallExpression(n.createPropertyAccessExpression(n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("Object"),"keys"),void 0,[e]),"reduce"),void 0,[n.createArrowFunction(void 0,void 0,ot({acc:void 0,key:void 0}),void 0,void 0,t),r]),Vr=(...e)=>`"${e.join(" ")}"`;var Gr=["get","post","put","delete","patch"];import g from"typescript";import{z as kt}from"zod";import $ from"typescript";var{factory:it}=$,jt=(e,t)=>{$.addSyntheticLeadingComment(e,$.SyntaxKind.MultiLineCommentTrivia,`* ${t} `,!0)},he=(e,t,r)=>{let o=it.createTypeAliasDeclaration(void 0,it.createIdentifier(t),void 0,e);return r&&jt(o,r),o},Dt=(e,t)=>{let r=$.createSourceFile("print.ts","",$.ScriptTarget.Latest,!1,$.ScriptKind.TS);return $.createPrinter(t).printNode($.EmitHint.Unspecified,e,r)},si=/^[A-Za-z_$][A-Za-z0-9_$]*$/,_r=e=>si.test(e)?it.createIdentifier(e):it.createStringLiteral(e);var{factory:u}=g,ai={[g.SyntaxKind.AnyKeyword]:"",[g.SyntaxKind.BigIntKeyword]:BigInt(0),[g.SyntaxKind.BooleanKeyword]:!1,[g.SyntaxKind.NumberKeyword]:0,[g.SyntaxKind.ObjectKeyword]:{},[g.SyntaxKind.StringKeyword]:"",[g.SyntaxKind.UndefinedKeyword]:void 0},pi=({value:e})=>u.createLiteralTypeNode(typeof e=="number"?u.createNumericLiteral(e):typeof e=="boolean"?e?u.createTrue():u.createFalse():u.createStringLiteral(e)),di=({shape:e},{isResponse:t,next:r,optionalPropStyle:{withQuestionMark:o}})=>{let i=Object.entries(e).map(([s,a])=>{let p=t&&Ae(a)?a instanceof kt.ZodOptional:a.isOptional(),d=u.createPropertySignature(void 0,_r(s),p&&o?u.createToken(g.SyntaxKind.QuestionToken):void 0,r(a));return a.description&&jt(d,a.description),d});return u.createTypeLiteralNode(i)},ci=({element:e},{next:t})=>u.createArrayTypeNode(t(e)),li=({options:e})=>u.createUnionTypeNode(e.map(t=>u.createLiteralTypeNode(u.createStringLiteral(t)))),Yr=({options:e},{next:t})=>u.createUnionTypeNode(e.map(t)),mi=e=>ai?.[e.kind],ui=(e,{next:t,isResponse:r})=>{let o=t(e.innerType()),i=e._def.effect;if(r&&i.type==="transform"){let s=He(e,mi(o)),a={number:g.SyntaxKind.NumberKeyword,bigint:g.SyntaxKind.BigIntKeyword,boolean:g.SyntaxKind.BooleanKeyword,string:g.SyntaxKind.StringKeyword,undefined:g.SyntaxKind.UndefinedKeyword,object:g.SyntaxKind.ObjectKeyword};return u.createKeywordTypeNode(s&&a[s]||g.SyntaxKind.AnyKeyword)}return o},fi=e=>u.createUnionTypeNode(Object.values(e.enum).map(t=>u.createLiteralTypeNode(typeof t=="number"?u.createNumericLiteral(t):u.createStringLiteral(t)))),yi=(e,{next:t,optionalPropStyle:{withUndefined:r}})=>{let o=t(e.unwrap());return r?u.createUnionTypeNode([o,u.createKeywordTypeNode(g.SyntaxKind.UndefinedKeyword)]):o},gi=(e,{next:t})=>u.createUnionTypeNode([t(e.unwrap()),u.createLiteralTypeNode(u.createNull())]),hi=({items:e,_def:{rest:t}},{next:r})=>u.createTupleTypeNode(e.map(r).concat(t===null?[]:u.createRestTypeNode(r(t)))),xi=({keySchema:e,valueSchema:t},{next:r})=>u.createExpressionWithTypeArguments(u.createIdentifier("Record"),[e,t].map(r)),bi=({_def:e},{next:t})=>u.createIntersectionTypeNode([e.left,e.right].map(t)),Ti=({_def:e},{next:t})=>t(e.innerType),oe=e=>()=>u.createKeywordTypeNode(e),Si=(e,{next:t})=>t(e.unwrap()),Ri=(e,{next:t})=>t(e.unwrap()),Oi=({_def:e},{next:t})=>t(e.innerType),Ai=({_def:e},{next:t,isResponse:r})=>t(e[r?"out":"in"]),Pi=()=>u.createLiteralTypeNode(u.createNull()),Ci=({schema:e},{getAlias:t,makeAlias:r,next:o,serializer:i})=>{let s=`Type${i(e)}`;return t(s)||(r(s,u.createLiteralTypeNode(u.createNull())),r(s,o(e)))},Ii=e=>{let t=e.unwrap(),r=u.createKeywordTypeNode(g.SyntaxKind.StringKeyword),o=u.createTypeReferenceNode("Buffer"),i=u.createUnionTypeNode([r,o]);return t instanceof kt.ZodString?r:t instanceof kt.ZodUnion?i:o},wi=(e,{next:t})=>t(e.unwrap().shape.raw),Ei={ZodString:oe(g.SyntaxKind.StringKeyword),ZodNumber:oe(g.SyntaxKind.NumberKeyword),ZodBigInt:oe(g.SyntaxKind.BigIntKeyword),ZodBoolean:oe(g.SyntaxKind.BooleanKeyword),ZodAny:oe(g.SyntaxKind.AnyKeyword),[Ze]:oe(g.SyntaxKind.StringKeyword),[Ne]:oe(g.SyntaxKind.StringKeyword),ZodNull:Pi,ZodArray:ci,ZodTuple:hi,ZodRecord:xi,ZodObject:di,ZodLiteral:pi,ZodIntersection:bi,ZodUnion:Yr,ZodDefault:Ti,ZodEnum:li,ZodNativeEnum:fi,ZodEffects:ui,ZodOptional:yi,ZodNullable:gi,ZodDiscriminatedUnion:Yr,ZodBranded:Si,ZodCatch:Oi,ZodPipeline:Ai,ZodLazy:Ci,ZodReadonly:Ri,[F]:Ii,[J]:wi},ve=(e,{brandHandling:t,ctx:r})=>te(e,{rules:{...t,...Ei},onMissing:()=>u.createKeywordTypeNode(g.SyntaxKind.AnyKeyword),ctx:r});var Ht=class{program=[];usage=[];registry=new Map;paths=[];aliases=new Map;ids={pathType:n.createIdentifier("Path"),methodType:n.createIdentifier("Method"),methodPathType:n.createIdentifier("MethodPath"),inputInterface:n.createIdentifier("Input"),posResponseInterface:n.createIdentifier("PositiveResponse"),negResponseInterface:n.createIdentifier("NegativeResponse"),responseInterface:n.createIdentifier("Response"),jsonEndpointsConst:n.createIdentifier("jsonEndpoints"),endpointTagsConst:n.createIdentifier("endpointTags"),providerType:n.createIdentifier("Provider"),implementationType:n.createIdentifier("Implementation"),clientClass:n.createIdentifier("ExpressZodAPIClient"),keyParameter:n.createIdentifier("key"),pathParameter:n.createIdentifier("path"),paramsArgument:n.createIdentifier("params"),methodParameter:n.createIdentifier("method"),accumulator:n.createIdentifier("acc"),provideMethod:n.createIdentifier("provide"),implementationArgument:n.createIdentifier("implementation"),headersProperty:n.createIdentifier("headers"),hasBodyConst:n.createIdentifier("hasBody"),undefinedValue:n.createIdentifier("undefined"),bodyProperty:n.createIdentifier("body"),responseConst:n.createIdentifier("response"),searchParamsConst:n.createIdentifier("searchParams"),exampleImplementationConst:n.createIdentifier("exampleImplementation"),clientConst:n.createIdentifier("client")};interfaces=[];getAlias(t){return this.aliases.has(t)?n.createTypeReferenceNode(t):void 0}makeAlias(t,r){return this.aliases.set(t,he(r,t)),this.getAlias(t)}constructor({routing:t,brandHandling:r,variant:o="client",serializer:i=ke,splitResponse:s=!1,optionalPropStyle:a={withQuestionMark:!0,withUndefined:!0}}){ee({routing:t,onEndpoint:(S,R,A)=>{let ie={serializer:i,getAlias:this.getAlias.bind(this),makeAlias:this.makeAlias.bind(this),optionalPropStyle:a},Se=E(A,R,"input"),Re=ve(S.getSchema("input"),{brandHandling:r,ctx:{...ie,isResponse:!1}}),I=s?E(A,R,"positive.response"):void 0,Ut=S.getSchema("positive"),Ft=s?ve(Ut,{brandHandling:r,ctx:{...ie,isResponse:!0}}):void 0,Oe=s?E(A,R,"negative.response"):void 0,Kt=S.getSchema("negative"),Bt=s?ve(Kt,{brandHandling:r,ctx:{...ie,isResponse:!0}}):void 0,qt=E(A,R,"response"),Qr=I&&Oe?n.createUnionTypeNode([n.createTypeReferenceNode(I),n.createTypeReferenceNode(Oe)]):ve(Ut.or(Kt),{brandHandling:r,ctx:{...ie,isResponse:!0}});this.program.push(he(Re,Se)),Ft&&I&&this.program.push(he(Ft,I)),Bt&&Oe&&this.program.push(he(Bt,Oe)),this.program.push(he(Qr,qt)),A!=="options"&&(this.paths.push(R),this.registry.set({method:A,path:R},{input:Se,positive:I,negative:Oe,response:qt,isJson:S.getMimeTypes("positive").includes(w.json),tags:S.getTags()}))}}),this.program.unshift(...this.aliases.values()),this.program.push(Mt(this.ids.pathType,this.paths)),this.program.push(Mt(this.ids.methodType,Gr)),this.program.push(nt(this.ids.methodPathType,zt([this.ids.methodType,this.ids.pathType])));let p=[n.createHeritageClause(z.SyntaxKind.ExtendsKeyword,[Nt(this.ids.methodPathType,z.SyntaxKind.AnyKeyword)])];this.interfaces.push({id:this.ids.inputInterface,kind:"input",props:[]}),s&&this.interfaces.push({id:this.ids.posResponseInterface,kind:"positive",props:[]},{id:this.ids.negResponseInterface,kind:"negative",props:[]}),this.interfaces.push({id:this.ids.responseInterface,kind:"response",props:[]});let d=[],c=[];for(let[{method:S,path:R},{isJson:A,tags:ie,...Se}]of this.registry){let Re=Vr(S,R);for(let I of this.interfaces)I.kind in Se&&I.props.push(Hr(Re,Se[I.kind]));o!=="types"&&(A&&d.push(n.createPropertyAssignment(Re,n.createTrue())),c.push(n.createPropertyAssignment(Re,n.createArrayLiteralExpression(ie.map(I=>n.createStringLiteral(I))))))}for(let{id:S,props:R}of this.interfaces)this.program.push(qr(S,p,R));if(o==="types")return;let l=n.createVariableStatement(B,q(this.ids.jsonEndpointsConst,n.createObjectLiteralExpression(d))),f=n.createVariableStatement(B,q(this.ids.endpointTagsConst,n.createObjectLiteralExpression(c))),m=nt(this.ids.providerType,n.createFunctionTypeNode($r({M:this.ids.methodType,P:this.ids.pathType}),ot({method:n.createTypeReferenceNode("M"),path:n.createTypeReferenceNode("P"),params:n.createIndexedAccessTypeNode(n.createTypeReferenceNode(this.ids.inputInterface),Zt)}),Kr(this.ids.responseInterface,Zt))),h=nt(this.ids.implementationType,n.createFunctionTypeNode(void 0,ot({method:n.createTypeReferenceNode(this.ids.methodType),path:n.createKeywordTypeNode(z.SyntaxKind.StringKeyword),params:Nt(z.SyntaxKind.StringKeyword,z.SyntaxKind.AnyKeyword)}),Br())),C=n.createTemplateExpression(n.createTemplateHead(":"),[n.createTemplateSpan(this.ids.keyParameter,ge)]),b=Lt(this.ids.paramsArgument,n.createCallExpression(n.createPropertyAccessExpression(this.ids.accumulator,"replace"),void 0,[C,n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter)]),this.ids.pathParameter),Z=Lt(this.ids.paramsArgument,n.createConditionalExpression(n.createBinaryExpression(n.createCallExpression(n.createPropertyAccessExpression(this.ids.pathParameter,"indexOf"),void 0,[C]),z.SyntaxKind.GreaterThanEqualsToken,n.createNumericLiteral(0)),void 0,this.ids.accumulator,void 0,n.createObjectLiteralExpression([n.createSpreadAssignment(this.ids.accumulator),n.createPropertyAssignment(n.createComputedPropertyName(this.ids.keyParameter),n.createElementAccessExpression(this.ids.paramsArgument,this.ids.keyParameter))])),n.createObjectLiteralExpression()),O=Fr(this.ids.clientClass,kr([rt(this.ids.implementationArgument,n.createTypeReferenceNode(this.ids.implementationType),Dr)]),[Ur(this.ids.provideMethod,n.createTypeReferenceNode(this.ids.providerType),vt([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createCallExpression(n.createPropertyAccessExpression(n.createThis(),this.ids.implementationArgument),void 0,[this.ids.methodParameter,b,Z]),!0))]);this.program.push(l,f,m,h,O);let x=n.createPropertyAssignment(this.ids.methodParameter,n.createCallExpression(n.createPropertyAccessExpression(this.ids.methodParameter,"toUpperCase"),void 0,void 0)),xe=n.createPropertyAssignment(this.ids.headersProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createObjectLiteralExpression([n.createPropertyAssignment(n.createStringLiteral("Content-Type"),n.createStringLiteral(w.json))]),void 0,this.ids.undefinedValue)),j=n.createPropertyAssignment(this.ids.bodyProperty,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createCallExpression(n.createPropertyAccessExpression(n.createIdentifier("JSON"),"stringify"),void 0,[this.ids.paramsArgument]),void 0,this.ids.undefinedValue)),V=n.createVariableStatement(void 0,q(this.ids.responseConst,n.createAwaitExpression(n.createCallExpression(n.createIdentifier("fetch"),void 0,[n.createTemplateExpression(n.createTemplateHead("https://example.com"),[n.createTemplateSpan(this.ids.pathParameter,n.createTemplateMiddle("")),n.createTemplateSpan(this.ids.searchParamsConst,ge)]),n.createObjectLiteralExpression([x,xe,j])])))),ne=n.createVariableStatement(void 0,q(this.ids.hasBodyConst,n.createLogicalNot(n.createCallExpression(n.createPropertyAccessExpression(n.createArrayLiteralExpression([n.createStringLiteral("get"),n.createStringLiteral("delete")]),"includes"),void 0,[this.ids.methodParameter])))),be=n.createVariableStatement(void 0,q(this.ids.searchParamsConst,n.createConditionalExpression(this.ids.hasBodyConst,void 0,n.createStringLiteral(""),void 0,n.createTemplateExpression(n.createTemplateHead("?"),[n.createTemplateSpan(n.createNewExpression(n.createIdentifier("URLSearchParams"),void 0,[this.ids.paramsArgument]),ge)])))),[Le,st]=["json","text"].map(S=>n.createReturnStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.responseConst,S),void 0,void 0))),je=n.createIfStatement(n.createBinaryExpression(n.createTemplateExpression(wt,[n.createTemplateSpan(this.ids.methodParameter,Et),n.createTemplateSpan(this.ids.pathParameter,ge)]),z.SyntaxKind.InKeyword,this.ids.jsonEndpointsConst),n.createBlock([Le])),M=n.createVariableStatement(B,q(this.ids.exampleImplementationConst,vt([this.ids.methodParameter,this.ids.pathParameter,this.ids.paramsArgument],n.createBlock([ne,be,V,je,st]),!0),n.createTypeReferenceNode(this.ids.implementationType))),G=n.createExpressionStatement(n.createCallExpression(n.createPropertyAccessExpression(this.ids.clientConst,this.ids.provideMethod),void 0,[n.createStringLiteral("get"),n.createStringLiteral("/v1/user/retrieve"),n.createObjectLiteralExpression([n.createPropertyAssignment("id",n.createStringLiteral("10"))])])),Te=n.createVariableStatement(void 0,q(this.ids.clientConst,n.createNewExpression(this.ids.clientClass,void 0,[this.ids.exampleImplementationConst])));this.usage.push(M,Te,G)}printUsage(t){return this.usage.length?this.usage.map(r=>typeof r=="string"?r:Dt(r,t)).join(`
|
|
21
21
|
`):void 0}print(t){let r=this.printUsage(t),o=r&&z.addSyntheticLeadingComment(z.addSyntheticLeadingComment(n.createEmptyStatement(),z.SyntaxKind.SingleLineCommentTrivia," Usage example:"),z.SyntaxKind.MultiLineCommentTrivia,`
|
|
22
22
|
${r}`);return this.program.concat(o||[]).map((i,s)=>Dt(i,s<this.program.length?t:{...t,omitTrailingSemicolon:!0})).join(`
|
|
23
23
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-zod-api",
|
|
3
|
-
"version": "19.2.
|
|
3
|
+
"version": "19.2.1",
|
|
4
4
|
"description": "A Typescript library 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": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"ansis": "^3.1.0",
|
|
70
|
-
"openapi3-ts": "^4.2
|
|
70
|
+
"openapi3-ts": "^4.3.2",
|
|
71
71
|
"ramda": "^0.30.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|