@ez4/gateway 0.28.0 → 0.30.0

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/dist/library.cjs CHANGED
@@ -1,230 +1,266 @@
1
- "use strict";var ge=Object.defineProperty;var Yr=Object.getOwnPropertyDescriptor;var Wr=Object.getOwnPropertyNames;var Xr=Object.prototype.hasOwnProperty;var p=(e,r)=>ge(e,"name",{value:r,configurable:!0});var Zr=(e,r)=>{for(var t in r)ge(e,t,{get:r[t],enumerable:!0})},_r=(e,r,t,o)=>{if(r&&
2
- typeof r=="object"||typeof r=="function")for(let n of Wr(r))!Xr.call(e,n)&&n!==t&&
3
- ge(e,n,{get:()=>r[n],enumerable:!(o=Yr(r,n))||o.enumerable});return e};var $r=e=>_r(ge({},"__esModule",{value:!0}),e);var Tt={};Zr(Tt,{IncompleteAuthorizerError:()=>Y,IncompleteCacheError:()=>ye,IncompleteCorsError:()=>ae,
4
- IncompleteHandlerError:()=>me,IncompleteRouteError:()=>K,IncompleteServiceError:()=>N,
5
- IncorrectBodyTypeError:()=>te,IncorrectCacheTypeError:()=>Te,IncorrectCorsTypeError:()=>fe,
6
- IncorrectDefaultsTypeError:()=>G,IncorrectHeadersTypeError:()=>L,IncorrectIdentityTypeError:()=>_,
7
- IncorrectParameterTypeError:()=>ie,IncorrectPreferencesTypeError:()=>Q,IncorrectQueryTypeError:()=>le,
8
- IncorrectRequestTypeError:()=>pe,IncorrectResponseTypeError:()=>X,InvalidBodyTypeError:()=>re,
9
- InvalidCacheTypeError:()=>de,InvalidCorsTypeError:()=>ue,InvalidDefaultsTypeError:()=>J,
10
- InvalidHeadersTypeError:()=>$,InvalidIdentityTypeError:()=>Z,InvalidParameterTypeError:()=>se,
11
- InvalidPreferencesTypeError:()=>V,InvalidQueryTypeError:()=>ce,InvalidRequestTypeError:()=>ne,
12
- InvalidResponseTypeError:()=>W,InvalidRouteErrorTypeError:()=>P,ServiceType:()=>Me,
13
- getHttpAuthRequest:()=>Ge,getHttpAuthResponse:()=>Ne,getHttpAuthorizer:()=>We,getHttpBody:()=>oe,
14
- getHttpCache:()=>Le,getHttpCors:()=>_e,getHttpHandler:()=>Xe,getHttpHandlerRequest:()=>Ke,
15
- getHttpHandlerResponse:()=>Ve,getHttpHeaders:()=>ee,getHttpIdentity:()=>O,getHttpParameters:()=>Qe,
16
- getHttpQuery:()=>Je,getHttpRoutes:()=>Ze,getHttpServices:()=>er,isHttpService:()=>Lr,
17
- registerTriggers:()=>dt});module.exports=$r(Tt);var Jr=require("@ez4/common/library"),Gr=require("@ez4/schema/library"),Kr=require("@ez4/project/library");var g=require("@ez4/common/library"),Vr=require("@ez4/reflection");var Me="@ez4/http",Lr=p(e=>e.type===Me,"isHttpService");var rr=require("@ez4/common/library");var N=class extends rr.IncompleteTypeError{static{p(this,"IncompleteServiceError")}constructor(r,t){
18
- super("Incomplete service",r,t)}};var d=require("@ez4/common/library"),w=require("@ez4/reflection");var M=require("@ez4/common/library"),R=require("@ez4/reflection");var a=require("@ez4/common/library"),v=require("@ez4/reflection");var et=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),tr=p(e=>{let[
19
- r]=e.split(" ",2);return et.has(r)},"isHttpPath"),or=p(e=>(0,a.isClassDeclaration)(
20
- e)&&(0,a.hasHeritageType)(e,"Http.Service"),"isHttpService"),nr=p(e=>(0,a.isModelDeclaration)(
21
- e)&&(0,a.hasHeritageType)(e,"Http.Route"),"isHttpRoute");var pr=p(e=>(0,a.hasHeritageType)(e,"Http.Defaults"),"isHttpDefaults"),sr=p(e=>(0,a.hasHeritageType)(
22
- e,"Http.Preferences"),"isHttpPreferences"),ir=p(e=>(0,a.hasHeritageType)(e,"Http\
23
- .Headers"),"isHttpHeaders"),cr=p(e=>(0,a.hasHeritageType)(e,"Http.Identity"),"is\
24
- HttpIdentity"),lr=p(e=>(0,a.hasHeritageType)(e,"Http.QueryStrings"),"isHttpQuery"),
25
- mr=p(e=>(0,a.hasHeritageType)(e,"Http.PathParameters"),"isHttpParameters"),ar=p(
26
- e=>(0,a.hasHeritageType)(e,"Http.JsonBody"),"isJsonBody"),ur=p(e=>(0,a.hasHeritageType)(
27
- e,"Http.Cors"),"isHttpCors"),fr=p(e=>(0,a.hasHeritageType)(e,"Http.Cache"),"isHt\
28
- tpCache"),yr=p(e=>(0,v.isTypeCallback)(e)||(0,v.isTypeFunction)(e),"isHttpAuthor\
29
- izer"),dr=p(e=>(0,v.isTypeCallback)(e)||(0,v.isTypeFunction)(e),"isHttpHandler");var A=require("@ez4/schema");var He=p((e,r,t,o)=>{if(!(0,R.isTypeReference)(e))return Tr(e,r,o);let n=(0,M.getReferenceType)(
30
- e,t);if(n)return Tr(n,r,o)},"getHttpPreferences"),Tr=p((e,r,t)=>{if((0,R.isTypeObject)(
31
- e))return gr(r,(0,M.getObjectMembers)(e),t);if(!(0,M.isModelDeclaration)(e)){t.push(
32
- new V(r.file));return}if(!sr(e)){t.push(new Q(e.name,r.file));return}return gr(r,
33
- (0,M.getModelMembers)(e),t)},"getTypePreferences"),gr=p((e,r,t)=>{let o={};for(let n of r)
34
- if((0,R.isModelProperty)(n))switch(n.name){default:t.push(new M.InvalidServicePropertyError(
1
+ "use strict";var Ee=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var Tt=Object.prototype.hasOwnProperty;var p=(e,t)=>Ee(e,"name",{value:t,configurable:!0});var gt=(e,t)=>{for(var r in t)Ee(e,r,{get:t[r],enumerable:!0})},Mt=(e,t,r,o)=>{if(t&&
2
+ typeof t=="object"||typeof t=="function")for(let n of yt(t))!Tt.call(e,n)&&n!==r&&
3
+ Ee(e,n,{get:()=>t[n],enumerable:!(o=dt(t,n))||o.enumerable});return e};var Ht=e=>Mt(Ee({},"__esModule",{value:!0}),e);var Ut={};gt(Ut,{IncompleteAccessError:()=>he,IncompleteAuthorizerError:()=>$,IncompleteCacheError:()=>Me,
4
+ IncompleteCorsError:()=>ve,IncompleteHandlerError:()=>ye,IncompleteProviderError:()=>ge,
5
+ IncompleteRouteError:()=>_,IncompleteServiceError:()=>G,IncorrectAccessTypeError:()=>xe,
6
+ IncorrectBodyTypeError:()=>ie,IncorrectCacheTypeError:()=>be,IncorrectCorsTypeError:()=>Ae,
7
+ IncorrectDefaultsTypeError:()=>Z,IncorrectHeadersTypeError:()=>ne,IncorrectIdentityTypeError:()=>te,
8
+ IncorrectParameterTypeError:()=>ue,IncorrectPreferencesTypeError:()=>W,IncorrectQueryTypeError:()=>de,
9
+ IncorrectRequestTypeError:()=>me,IncorrectResponseTypeError:()=>ee,InvalidAccessTypeError:()=>Se,
10
+ InvalidBodyTypeError:()=>se,InvalidCacheTypeError:()=>He,InvalidCorsTypeError:()=>Ie,
11
+ InvalidDefaultsTypeError:()=>X,InvalidHeadersTypeError:()=>oe,InvalidIdentityTypeError:()=>re,
12
+ InvalidParameterTypeError:()=>ae,InvalidPreferencesTypeError:()=>Y,InvalidProviderTypeError:()=>Te,
13
+ InvalidQueryTypeError:()=>fe,InvalidRequestTypeError:()=>le,InvalidResponseTypeError:()=>L,
14
+ InvalidRouteErrorTypeError:()=>O,ServiceCollisionError:()=>K,ServiceType:()=>Pe,
15
+ getHttpAuthRequest:()=>pr,getHttpAuthResponse:()=>rr,getHttpAuthorizer:()=>cr,getHttpBody:()=>ce,
16
+ getHttpCache:()=>ur,getHttpCors:()=>dr,getHttpHandler:()=>lr,getHttpHandlerRequest:()=>sr,
17
+ getHttpHandlerResponse:()=>tr,getHttpHeaders:()=>pe,getHttpIdentity:()=>j,getHttpParameters:()=>or,
18
+ getHttpQuery:()=>nr,getHttpRoutes:()=>mr,getHttpServices:()=>yr,isHttpService:()=>bt,
19
+ registerTriggers:()=>Bt});module.exports=Ht(Ut);var at=require("@ez4/common/library"),ut=require("@ez4/schema/library"),ft=require("@ez4/project/library");var g=require("@ez4/common/library"),ct=require("@ez4/reflection");var Pe="@ez4/http",bt=p(e=>e.type===Pe,"isHttpService");var Re=require("@ez4/common/library");var G=class extends Re.IncompleteTypeError{static{p(this,"IncompleteServiceError")}constructor(t,r){
20
+ super("Incomplete service",t,r)}},K=class extends Re.TypeCollisionError{static{p(
21
+ this,"ServiceCollisionError")}constructor(t,r){super("Service error",t,r)}};var T=require("@ez4/common/library"),z=require("@ez4/reflection");var M=require("@ez4/common/library"),w=require("@ez4/reflection");var a=require("@ez4/common/library"),P=require("@ez4/reflection");var ht=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),gr=p(e=>{let[
22
+ t]=e.split(" ",2);return ht.has(t)},"isHttpPath"),we=p(e=>(0,a.isClassDeclaration)(
23
+ e)&&(0,a.hasHeritageType)(e,"Http.Service"),"isHttpService");var Mr=p(e=>(0,a.isModelDeclaration)(e)&&(0,a.hasHeritageType)(e,"Http.Route"),"\
24
+ isHttpRoute");var Hr=p(e=>(0,a.hasHeritageType)(e,"Http.Defaults"),"isHttpDefaults"),br=p(e=>(0,a.hasHeritageType)(
25
+ e,"Http.Preferences"),"isHttpPreferences"),hr=p(e=>(0,a.hasHeritageType)(e,"Http\
26
+ .Headers"),"isHttpHeaders"),Sr=p(e=>(0,a.hasHeritageType)(e,"Http.Identity"),"is\
27
+ HttpIdentity"),xr=p(e=>(0,a.hasHeritageType)(e,"Http.QueryStrings"),"isHttpQuery"),
28
+ vr=p(e=>(0,a.hasHeritageType)(e,"Http.PathParameters"),"isHttpParameters"),Ir=p(
29
+ e=>(0,a.hasHeritageType)(e,"Http.JsonBody"),"isJsonBody"),Ar=p(e=>(0,a.hasHeritageType)(
30
+ e,"Http.Cache"),"isHttpCache"),Er=p(e=>(0,a.hasHeritageType)(e,"Http.Access"),"i\
31
+ sHttpAccess"),Pr=p(e=>(0,a.hasHeritageType)(e,"Http.Cors"),"isHttpCors"),Rr=p(e=>(0,P.isTypeCallback)(
32
+ e)||(0,P.isTypeFunction)(e),"isHttpAuthorizer"),wr=p(e=>(0,P.isTypeCallback)(e)||
33
+ (0,P.isTypeFunction)(e),"isHttpHandler");var R=require("@ez4/schema");var Oe=p((e,t,r,o)=>{if(!(0,w.isTypeReference)(e))return Or(e,t,o);let n=(0,M.getReferenceType)(
34
+ e,r);if(n)return Or(n,t,o)},"getHttpPreferences"),Or=p((e,t,r)=>{if((0,w.isTypeObject)(
35
+ e))return zr(t,(0,M.getObjectMembers)(e),r);if(!(0,M.isModelDeclaration)(e)){r.push(
36
+ new Y(t.file));return}if(!br(e)){r.push(new W(e.name,t.file));return}return zr(t,
37
+ (0,M.getModelMembers)(e),r)},"getTypePreferences"),zr=p((e,t,r)=>{let o={};for(let n of t)
38
+ if((0,w.isModelProperty)(n))switch(n.name){default:r.push(new M.InvalidServicePropertyError(
35
39
  e.name,n.name,e.file));break;case"namingStyle":o.namingStyle=(0,M.getPropertyStringIn)(
36
- n,[A.NamingStyle.Preserve,A.NamingStyle.CamelCase,A.NamingStyle.PascalCase,A.NamingStyle.
37
- SnakeCase,A.NamingStyle.KebabCase]);break}return o},"getTypeFromMembers");var S=require("@ez4/common/library"),be=require("@ez4/utils"),x=require("@ez4/reflection");var he=p((e,r,t,o)=>{if(!(0,x.isTypeReference)(e))return Mr(e,r,t,o);let n=(0,S.getReferenceType)(
38
- e,t);return n?Mr(n,r,t,o):null},"getHttpErrors"),Mr=p((e,r,t,o)=>(0,x.isTypeObject)(
39
- e)?rt(e,r,(0,S.getObjectMembers)(e),t,o):null,"getTypeErrors"),rt=p((e,r,t,o,n)=>{
40
- let s={};for(let i of t){if(!(0,x.isModelProperty)(i)||i.inherited)continue;let c=parseInt(
41
- i.name,10);(0,be.isAnyNumber)(c)||n.push(new S.InvalidServicePropertyError(r.name,
42
- i.name,e.file));let l=tt(i,c,r,o,n);l&&Object.assign(s,l)}return(0,be.isEmptyObject)(
43
- s)?null:s},"getTypeFromMembers"),tt=p((e,r,t,o,n)=>{let s=(0,S.getPropertyTuple)(
44
- e)??[],i={};for(let c of s){if(!(0,x.isTypeReference)(c)){n.push(new P(t.file));
45
- continue}let l=(0,S.getReferenceType)(c,o);if(!l||!(0,x.isTypeClass)(l)){n.push(
46
- new P(t.file));continue}i[l.name]=r}return i},"getErrorClasses");var hr=p((e,r,t,o)=>{if(!(0,w.isTypeReference)(e))return Hr(e,r,t,o);let n=(0,d.getReferenceType)(
47
- e,t);return n?Hr(n,r,t,o):null},"getHttpDefaults"),Hr=p((e,r,t,o)=>(0,w.isTypeObject)(
48
- e)?br(r,(0,d.getObjectMembers)(e),t,o):(0,d.isModelDeclaration)(e)?pr(e)?br(r,(0,d.getModelMembers)(
49
- e),t,o):(o.push(new G(e.name,r.file)),null):(o.push(new J(r.file)),null),"getTyp\
50
- eDefaults"),br=p((e,r,t,o)=>{let n={};for(let s of r)if(!(!(0,w.isModelProperty)(
51
- s)||s.inherited))switch(s.name){default:o.push(new d.InvalidServicePropertyError(
52
- e.name,s.name,e.file));break;case"httpErrors":n.httpErrors=he(s.value,e,t,o);break;case"\
53
- preferences":n.preferences=He(s.value,e,t,o);break;case"memory":case"logRetentio\
54
- n":case"timeout":n[s.name]=(0,d.getPropertyNumber)(s);break;case"listener":n.listener=
55
- (0,d.getServiceListener)(s.value,o);break}return n},"getTypeFromMembers");var E=require("@ez4/reflection"),m=require("@ez4/common/library");var Se=require("@ez4/common/library");var K=class extends Se.IncompleteTypeError{static{p(this,"IncompleteRouteError")}constructor(r,t){
56
- super("Incomplete gateway route",r,t)}},P=class extends Se.TypeError{static{p(this,
57
- "InvalidRouteErrorTypeError")}constructor(r){super("Invalid route error type.",r)}};var Sr=require("@ez4/common/library");var Y=class extends Sr.IncompleteTypeError{static{p(this,"IncompleteAuthorizerEr\
58
- ror")}constructor(r,t){super("Incomplete route authorizer",r,t)}};var T=require("@ez4/common/library"),C=require("@ez4/reflection"),Rr=require("@ez4/utils");var xe=require("@ez4/common/library");var W=class extends xe.InvalidTypeError{constructor(t,o){super("Invalid route re\
59
- sponse",void 0,t,o);this.baseType=t}static{p(this,"InvalidResponseTypeError")}},
60
- X=class extends xe.IncorrectTypeError{constructor(t,o,n){super("Incorrect route \
61
- response",t,o,n);this.responseType=t;this.baseType=o}static{p(this,"IncorrectRes\
62
- ponseTypeError")}};var h=require("@ez4/reflection"),ve=require("@ez4/common/library"),Ir=require("@ez4/schema/library");var Ie=require("@ez4/common/library");var Z=class extends Ie.InvalidTypeError{static{p(this,"InvalidIdentityTypeError")}constructor(r){
63
- super("Invalid identity",void 0,"Http.Identity",r)}},_=class extends Ie.IncorrectTypeError{constructor(t,o){
64
- super("Incorrect identity",t,"Http.Identity",o);this.identityType=t}static{p(this,
65
- "IncorrectIdentityTypeError")}};var Ee=require("@ez4/schema/library");var f=p((e,r)=>{let t=(0,Ee.getObjectSchema)(e,r);return t&&(0,Ee.isObjectSchema)(
66
- t)?t:null},"getSchemaFromType");var O=p((e,r,t,o)=>{if((0,h.isTypeUndefined)(e))return null;if(!(0,h.isTypeReference)(
67
- e))return xr(e,r,t,o);let n=(0,ve.getReferenceType)(e,t);return n?xr(n,r,t,o):null},
68
- "getHttpIdentity"),xr=p((e,r,t,o)=>{if((0,h.isTypeUnion)(e))return ot(e.elements,
69
- r,t,o);if((0,h.isTypeObject)(e)||(0,h.isTypeIntersection)(e))return f(e,t);if(!(0,ve.isModelDeclaration)(
70
- e))return o.push(new Z(r.file)),null;if(!cr(e))return o.push(new _(e.name,r.file)),
71
- null;let n=f(e,t);return n&&(n.definitions={...n.definitions,extensible:!0}),n},
72
- "getTypeIdentity"),ot=p((e,r,t,o)=>{let n=[];for(let s of e){let i=O(s,r,t,o);i&&
73
- n.push(i)}return n.length>1?(0,Ir.createUnionSchema)({elements:n}):n[0]},"getIde\
74
- ntityFromUnion");var z=require("@ez4/reflection"),Re=require("@ez4/common/library");var Ae=require("@ez4/common/library");var $=class extends Ae.InvalidTypeError{static{p(this,"InvalidHeadersTypeError")}constructor(r){
75
- super("Invalid headers",void 0,"Http.Headers",r)}},L=class extends Ae.IncorrectTypeError{constructor(t,o){
76
- super("Incorrect headers",t,"Http.Headers",o);this.headersType=t}static{p(this,"\
77
- IncorrectHeadersTypeError")}};var ee=p((e,r,t,o)=>{if(!(0,z.isTypeReference)(e))return Er(e,r,t,o);let n=(0,Re.getReferenceType)(
78
- e,t);return n?Er(n,r,t,o):null},"getHttpHeaders"),Er=p((e,r,t,o)=>(0,z.isTypeObject)(
79
- e)||(0,z.isTypeIntersection)(e)?f(e,t):(0,Re.isModelDeclaration)(e)?ir(e)?f(e,t):
80
- (o.push(new L(e.name,r.file)),null):(o.push(new $(r.file)),null),"getTypeHeaders");var j=require("@ez4/schema/library"),we=require("@ez4/common/library"),y=require("@ez4/reflection");var Pe=require("@ez4/common/library");var re=class extends Pe.InvalidTypeError{static{p(this,"InvalidBodyTypeError")}constructor(r){
81
- super("Invalid body",void 0,"Http.JsonBody",r)}},te=class extends Pe.IncorrectTypeError{constructor(t,o){
82
- super("Incorrect body",t,"Http.JsonBody",o);this.bodyType=t}static{p(this,"Incor\
83
- rectBodyTypeError")}};var oe=p((e,r,t,o)=>Ue(e,t,n=>Fe(n)??Be(n,r,t,o)),"getHttpBody"),Ue=p((e,r,t)=>{
84
- if((0,y.isTypeUndefined)(e))return null;if(!(0,y.isTypeReference)(e))return t(e);
85
- let o=(0,we.getReferenceType)(e,r);return o?t(o):null},"getTypeBody"),Fe=p(e=>(0,y.isTypeScalar)(
86
- e)?(0,j.getScalarSchema)(e):null,"getScalarTypeBody"),Be=p((e,r,t,o)=>(0,y.isTypeUnion)(
87
- e)?nt(e.elements,t,n=>Fe(n)??Be(n,r,t,o)):(0,y.isTypeArray)(e)?pt(e.element,t,n=>Fe(
88
- n)??Be(n,r,t,o)):(0,y.isTypeObject)(e)||(0,y.isTypeIntersection)(e)?f(e,t):(0,we.isModelDeclaration)(
89
- e)?ar(e)?f(e,t):(o.push(new te(e.name,e.file)),null):(o.push(new re(r.file)),null),
90
- "getCompoundTypeBody"),nt=p((e,r,t)=>{let o={optional:!1,elements:[]};for(let n of e){
91
- if((0,y.isTypeUndefined)(n)){o.optional=!0;continue}let s=Ue(n,r,t);s&&o.elements.
92
- push(s)}return o.elements.length?(0,j.createUnionSchema)(o):null},"getUnionTypeB\
93
- ody"),pt=p((e,r,t)=>{let o=Ue(e,r,t);return o?(0,j.createArraySchema)({element:o}):
94
- null},"getArrayTypeBody");var Ne=p((e,r,t,o)=>{let n=Pr(e,r,t,o,"Http.AuthResponse");return n&&st(n)?n:null},
95
- "getHttpAuthResponse"),Ve=p((e,r,t,o)=>{let n=Pr(e,r,t,o,"Http.Response");return n&&
96
- it(n)?n:null},"getHttpHandlerResponse"),Pr=p((e,r,t,o,n)=>{if(!(0,C.isTypeReference)(
97
- e))return vr(e,r,t,o,n);let s=(0,T.getReferenceType)(e,t);return s?vr(s,r,t,o,n):
98
- null},"getHttpResponse"),st=p(e=>!!e.identity,"isValidAuthResponse"),it=p(e=>(0,Rr.isAnyNumber)(
99
- e.status),"isValidHandlerResponse"),vr=p((e,r,t,o,n)=>(0,C.isTypeObject)(e)?Ar(e,
100
- r,(0,T.getObjectMembers)(e),t,o):(0,T.isModelDeclaration)(e)?(0,T.hasHeritageType)(
101
- e,n)?Ar(e,r,(0,T.getModelMembers)(e),t,o):(o.push(new X(e.name,n,e.file)),null):
102
- (o.push(new W(n,r.file)),null),"getTypeResponse"),Ar=p((e,r,t,o,n)=>{let s={};for(let i of t)
103
- if(!(!(0,C.isModelProperty)(i)||i.inherited))switch(i.name){default:n.push(new T.InvalidServicePropertyError(
104
- r.name,i.name,e.file));break;case"status":s.status=(0,T.getPropertyNumber)(i);break;case"\
105
- headers":{s.headers=ee(i.value,e,o,n),s.headers&&i.description&&(s.headers.description=
106
- i.description);break}case"identity":{s.identity=O(i.value,e,o,n),s.identity&&i.description&&
107
- (s.identity.description=i.description);break}case"body":{s.body=oe(i.value,e,o,n),
108
- s.body&&i.description&&(s.body.description=i.description);break}}return s},"getT\
109
- ypeFromMembers");var I=require("@ez4/reflection"),H=require("@ez4/common/library");var Oe=require("@ez4/common/library");var ne=class extends Oe.InvalidTypeError{constructor(t,o){super("Invalid route r\
110
- equest",void 0,t,o);this.baseType=t}static{p(this,"InvalidRequestTypeError")}},pe=class extends Oe.IncorrectTypeError{constructor(t,o,n){
111
- super("Incorrect route request",t,o,n);this.requestType=t;this.baseType=o}static{
112
- p(this,"IncorrectRequestTypeError")}};var k=require("@ez4/reflection"),je=require("@ez4/common/library");var ze=require("@ez4/common/library");var se=class extends ze.InvalidTypeError{static{p(this,"InvalidParameterTypeErro\
113
- r")}constructor(r){super("Invalid request parameters",void 0,"Http.PathParameter\
114
- s",r)}},ie=class extends ze.IncorrectTypeError{constructor(t,o){super("Incorrect\
115
- request parameters",t,"Http.PathParameters",o);this.parametersType=t}static{p(this,
116
- "IncorrectParameterTypeError")}};var Qe=p((e,r,t,o)=>{if(!(0,k.isTypeReference)(e))return wr(e,r,t,o);let n=(0,je.getReferenceType)(
117
- e,t);return n?wr(n,r,t,o):null},"getHttpParameters"),wr=p((e,r,t,o)=>(0,k.isTypeObject)(
118
- e)||(0,k.isTypeIntersection)(e)?f(e,t):(0,je.isModelDeclaration)(e)?mr(e)?f(e,t):
119
- (o.push(new ie(e.name,e.file)),null):(o.push(new se(r.file)),null),"getTypeParam\
120
- eter");var q=require("@ez4/reflection"),ke=require("@ez4/common/library");var Ce=require("@ez4/common/library");var ce=class extends Ce.InvalidTypeError{static{p(this,"InvalidQueryTypeError")}constructor(r){
121
- super("Invalid request query strings",void 0,"Http.QueryStrings",r)}},le=class extends Ce.IncorrectTypeError{constructor(t,o){
122
- super("Incorrect request query strings",t,"Http.QueryStrings",o);this.queryType=
123
- t}static{p(this,"IncorrectQueryTypeError")}};var Je=p((e,r,t,o)=>{if(!(0,q.isTypeReference)(e))return Or(e,r,t,o);let n=(0,ke.getReferenceType)(
124
- e,t);return n?Or(n,r,t,o):null},"getHttpQuery"),Or=p((e,r,t,o)=>(0,q.isTypeObject)(
125
- e)||(0,q.isTypeIntersection)(e)?f(e,t):(0,ke.isModelDeclaration)(e)?lr(e)?f(e,t):
126
- (o.push(new le(e.name,r.file)),null):(o.push(new ce(r.file)),null),"getTypeQuery");var Ge=p((e,r,t,o)=>Ye(e,r,t,o,"Http.AuthRequest"),"getHttpAuthRequest"),Ke=p((e,r,t,o)=>Ye(
127
- e,r,t,o,"Http.Request"),"getHttpHandlerRequest"),Ye=p((e,r,t,o,n)=>{if((0,I.isTypeIntersection)(
128
- e)&&e.elements.length>0)return Ye(e.elements[0],r,t,o,n);if(!(0,I.isTypeReference)(
129
- e))return zr(e,r,t,o,n);let s=(0,H.getReferenceType)(e,t);return s?zr(s,r,t,o,n):
130
- null},"getHttpRequest"),zr=p((e,r,t,o,n)=>(0,I.isTypeObject)(e)?jr(e,r,(0,H.getObjectMembers)(
131
- e),t,o):(0,H.isModelDeclaration)(e)?(0,H.hasHeritageType)(e,n)?jr(e,r,(0,H.getModelMembers)(
132
- e),t,o):(o.push(new pe(e.name,n,e.file)),null):(o.push(new ne(n,r.file)),null),"\
133
- getTypeRequest"),jr=p((e,r,t,o,n)=>{let s={};for(let i of t)if(!(!(0,I.isModelProperty)(
134
- i)||i.inherited))switch(i.name){default:n.push(new H.InvalidServicePropertyError(
135
- r.name,i.name,e.file));break;case"headers":{s.headers=ee(i.value,e,o,n),s.headers&&
136
- i.description&&(s.headers.description=i.description);break}case"identity":{s.identity=
137
- O(i.value,e,o,n),s.identity&&i.description&&(s.identity.description=i.description);
138
- break}case"query":{s.query=Je(i.value,e,o,n),s.query&&i.description&&(s.query.description=
139
- i.description);break}case"parameters":{s.parameters=Qe(i.value,e,o,n),s.parameters&&
140
- i.description&&(s.parameters.description=i.description);break}case"body":{s.body=
141
- oe(i.value,e,o,n),s.body&&i.description&&(s.body.description=i.description);break}}
142
- return s},"getTypeFromMembers");var We=p((e,r,t,o)=>{if(!yr(e))return null;let{description:n,module:s}=e,i={...n&&
143
- {description:n},...s&&{module:s}},c=new Set(["name","file"]);if((i.name=e.name)&&
144
- c.delete("name"),(i.file=e.file)&&c.delete("file"),e.parameters){let[{value:l}]=e.
145
- parameters;i.request=Ge(l,r,t,o)}return e.return&&(i.response=Ne(e.return,r,t,o)),
146
- ct(i)?i:(o.push(new Y([...c],e.file)),null)},"getHttpAuthorizer"),ct=p(e=>!!e.name&&
147
- !!e.file,"isValidAuthorizer");var Cr=require("@ez4/common/library");var me=class extends Cr.IncompleteTypeError{static{p(this,"IncompleteHandlerErro\
148
- r")}constructor(r,t){super("Incomplete route handler",r,t)}};var Xe=p((e,r,t,o)=>{if(!dr(e))return null;let{description:n,module:s}=e,i={...n&&
149
- {description:n},...s&&{module:s}},c=new Set(["name","file","response"]);if((i.name=
150
- e.name)&&c.delete("name"),(i.file=e.file)&&c.delete("file"),e.parameters){let[{value:l}]=e.
151
- parameters;i.request=Ke(l,r,t,o)}if(e.return){let l=Ve(e.return,r,t,o);l&&(i.response=
152
- l,c.delete("response"))}return lt(i)?i:(o.push(new me([...c],e.file)),null)},"ge\
153
- tHttpHandler"),lt=p(e=>!!e.name&&!!e.file&&!!e.response,"isValidHandler");var Ze=p((e,r,t,o)=>{let n=(0,m.getPropertyTuple)(r)??[];return Dr(n,e,t,o)},"ge\
154
- tHttpRoutes"),Dr=p((e,r,t,o)=>{let n=[];for(let s of e){let i=mt(s,r,t,o);Array.
155
- isArray(i)?n.push(...i):i&&n.push(i)}return n},"getRouteFromTuple"),mt=p((e,r,t,o)=>{
156
- if(!(0,E.isTypeReference)(e))return kr(e,r,t,o);let n=(0,m.getReferenceType)(e,t);
157
- return n?kr(n,r,t,o):null},"getTypeFromRoute"),at=p(e=>!!e.path&&!!e.handler,"is\
158
- ValidRoute"),kr=p((e,r,t,o)=>nr(e)?qr(e,r,(0,m.getModelMembers)(e),t,o):(0,E.isTypeObject)(
159
- e)?qr(e,r,(0,m.getObjectMembers)(e),t,o):(0,E.isTypeTuple)(e)&&e.spread?Dr(e.elements,
160
- r,t,o):null,"getRouteType"),qr=p((e,r,t,o,n)=>{let s={},i=new Set(["path","handl\
161
- er"]);for(let c of t)if(!(!(0,E.isModelProperty)(c)||c.inherited))switch(c.name){default:
162
- n.push(new m.InvalidServicePropertyError(r.name,c.name,e.file));break;case"path":{
163
- let l=(0,m.getPropertyString)(c);l&&tr(l)&&(i.delete(c.name),s.path=l);break}case"\
164
- handler":(s.handler=Xe(c.value,r,o,n))&&i.delete(c.name);break;case"authorizer":
165
- s.authorizer=We(c.value,r,o,n);break;case"httpErrors":s.httpErrors=he(c.value,r,
166
- o,n);break;case"preferences":s.preferences=He(c.value,r,o,n);break;case"memory":case"\
167
- logRetention":case"timeout":s[c.name]=(0,m.getPropertyNumber)(c);break;case"cors":
168
- s.cors=(0,m.getPropertyBoolean)(c);break;case"listener":s.listener=(0,m.getServiceListener)(
169
- c.value,n);break;case"variables":s.variables=(0,m.getLinkedVariableList)(c,n);break}
170
- return at(s)?s:(n.push(new K([...i],e.file)),null)},"getTypeFromMembers");var u=require("@ez4/common/library"),F=require("@ez4/reflection");var D=require("@ez4/common/library");var ae=class extends D.IncompleteTypeError{static{p(this,"IncompleteCorsError")}constructor(r,t){
171
- super("Incomplete HTTP CORS",r,t)}},ue=class extends D.InvalidTypeError{static{p(
172
- this,"InvalidCorsTypeError")}constructor(r){super("Invalid HTTP CORS type",void 0,
173
- "Http.Cors",r)}},fe=class extends D.IncorrectTypeError{constructor(t,o){super("I\
174
- ncorrect HTTP CORS type",t,"Http.Cors",o);this.fallbackType=t}static{p(this,"Inc\
175
- orrectCorsTypeError")}};var _e=p((e,r,t,o)=>{if(!(0,F.isTypeReference)(e))return Fr(e,r,o);let n=(0,u.getReferenceType)(
176
- e,t);return n?Fr(n,r,o):null},"getHttpCors"),ut=p(e=>!!e.allowOrigins?.length,"i\
177
- sValidCors"),Fr=p((e,r,t)=>(0,F.isTypeObject)(e)?Br(e,r,(0,u.getObjectMembers)(e),
178
- t):(0,u.isModelDeclaration)(e)?ur(e)?Br(e,r,(0,u.getModelMembers)(e),t):(t.push(
179
- new fe(e.name,e.file)),null):(t.push(new ue(r.file)),null),"getTypeCors"),Br=p((e,r,t,o)=>{
180
- let n={},s=new Set(["allowOrigins"]);for(let i of t)if(!(!(0,F.isModelProperty)(
181
- i)||i.inherited))switch(i.name){default:o.push(new u.InvalidServicePropertyError(
182
- r.name,i.name,e.file));break;case"allowOrigins":case"allowMethods":case"allowHea\
183
- ders":case"exposeHeaders":n[i.name]=(0,u.getPropertyStringList)(i);break;case"al\
184
- lowCredentials":n.allowCredentials=(0,u.getPropertyBoolean)(i);break;case"maxAge":
185
- n.maxAge=(0,u.getPropertyNumber)(i);break}return ut(n)?n:(o.push(new ae([...s],e.
186
- file)),null)},"getTypeFromMembers");var b=require("@ez4/common/library"),U=require("@ez4/reflection"),$e=require("@ez4/utils");var B=require("@ez4/common/library");var ye=class extends B.IncompleteTypeError{static{p(this,"IncompleteCacheError")}constructor(r,t){
187
- super("Incomplete gateway cache",r,t)}},de=class extends B.InvalidTypeError{static{
188
- p(this,"InvalidCacheTypeError")}constructor(r){super("Invalid gateway cache type",
189
- void 0,"Http.Cache",r)}},Te=class extends B.IncorrectTypeError{constructor(t,o){
190
- super("Incorrect gateway cache type",t,"Http.Cache",o);this.cacheType=t}static{p(
191
- this,"IncorrectCacheTypeError")}};var Le=p((e,r,t,o)=>{if(!(0,U.isTypeReference)(e))return Ur(e,r,o);let n=(0,b.getReferenceType)(
192
- e,t);return n?Ur(n,r,o):null},"getHttpCache"),ft=p(e=>(0,$e.isAnyNumber)(e.authorizerTTL),
193
- "isValidCache"),Ur=p((e,r,t)=>(0,U.isTypeObject)(e)?Nr(e,r,(0,b.getObjectMembers)(
194
- e),t):(0,b.isModelDeclaration)(e)?fr(e)?Nr(e,r,(0,b.getModelMembers)(e),t):(t.push(
195
- new Te(e.name,e.file)),null):(t.push(new de(r.file)),null),"getTypeCache"),Nr=p(
196
- (e,r,t,o)=>{let n={},s=new Set(["authorizerTTL"]);for(let i of t)if(!(!(0,U.isModelProperty)(
197
- i)||i.inherited))switch(i.name){default:o.push(new b.InvalidServicePropertyError(
198
- r.name,i.name,e.file));break;case"authorizerTTL":{let c=(0,b.getPropertyNumber)(
199
- i);(0,$e.isAnyNumber)(c)&&(n[i.name]=c,s.delete(i.name));break}}return ft(n)?n:(o.
200
- push(new ye([...s],e.file)),null)},"getTypeFromMembers");var er=p(e=>{let r={},t=[];for(let o in e){let n=e[o];if(!or(n)||(0,g.isExternalDeclaration)(
201
- n))continue;let s={type:Me,extras:{}},i=new Set(["routes"]),c=n.file;s.name=n.name,
202
- n.description&&(s.description=n.description);for(let l of(0,g.getModelMembers)(n))
203
- if(!(!(0,Vr.isModelProperty)(l)||l.inherited))switch(l.name){default:t.push(new g.InvalidServicePropertyError(
204
- s.name,l.name,c));break;case"routes":(s.routes=Ze(n,l,e,t))&&i.delete(l.name);break;case"\
205
- name":s.displayName=(0,g.getPropertyString)(l);break;case"defaults":s.defaults=hr(
206
- l.value,n,e,t);break;case"cache":s.cache=Le(l.value,n,e,t);break;case"cors":s.cors=
207
- _e(l.value,n,e,t);break;case"variables":s.variables=(0,g.getLinkedVariableList)(
208
- l,t);break;case"services":s.services=(0,g.getLinkedServiceList)(l,e,t);break}if(!yt(
209
- s)){t.push(new N([...i],c));continue}if(r[n.name]){t.push(new g.DuplicateServiceError(
210
- n.name,c));continue}r[n.name]=s}return{services:r,errors:t}},"getHttpServices"),
211
- yt=p(e=>!!e.name&&!!e.routes&&!!e.extras,"isValidService");var Qr=!1,dt=p(()=>{Qr||((0,Jr.registerTriggers)(),(0,Gr.registerTriggers)(),(0,Kr.createTrigger)(
212
- "@ez4/gateway",{"metadata:getServices":er}),Qr=!0)},"registerTriggers");var qe=require("@ez4/common/library");var J=class extends qe.InvalidTypeError{static{p(this,"InvalidDefaultsTypeError")}constructor(r){
213
- super("Invalid defaults",void 0,"Http.Defaults",r)}},G=class extends qe.IncorrectTypeError{constructor(t,o){
214
- super("Incorrect defaults",t,"Http.Defaults",o);this.defaultsType=t}static{p(this,
215
- "IncorrectDefaultsTypeError")}};var De=require("@ez4/common/library");var V=class extends De.InvalidTypeError{static{p(this,"InvalidPreferencesTypeErr\
216
- or")}constructor(r){super("Invalid preferences",void 0,"Http.Preferences",r)}},Q=class extends De.IncorrectTypeError{constructor(t,o){
217
- super("Incorrect preferences",t,"Http.Preferences",o);this.preferencesType=t}static{
218
- p(this,"IncorrectPreferencesTypeError")}};0&&(module.exports={IncompleteAuthorizerError,IncompleteCacheError,IncompleteCorsError,
219
- IncompleteHandlerError,IncompleteRouteError,IncompleteServiceError,IncorrectBodyTypeError,
220
- IncorrectCacheTypeError,IncorrectCorsTypeError,IncorrectDefaultsTypeError,IncorrectHeadersTypeError,
221
- IncorrectIdentityTypeError,IncorrectParameterTypeError,IncorrectPreferencesTypeError,
222
- IncorrectQueryTypeError,IncorrectRequestTypeError,IncorrectResponseTypeError,InvalidBodyTypeError,
40
+ n,[R.NamingStyle.Preserve,R.NamingStyle.CamelCase,R.NamingStyle.PascalCase,R.NamingStyle.
41
+ SnakeCase,R.NamingStyle.KebabCase]);break}return o},"getTypeFromMembers");var x=require("@ez4/common/library"),ze=require("@ez4/utils"),v=require("@ez4/reflection");var je=p((e,t,r,o)=>{if(!(0,v.isTypeReference)(e))return jr(e,t,r,o);let n=(0,x.getReferenceType)(
42
+ e,r);return n?jr(n,t,r,o):null},"getHttpErrors"),jr=p((e,t,r,o)=>(0,v.isTypeObject)(
43
+ e)?St(e,t,(0,x.getObjectMembers)(e),r,o):null,"getTypeErrors"),St=p((e,t,r,o,n)=>{
44
+ let i={};for(let s of r){if(!(0,v.isModelProperty)(s)||s.inherited)continue;let c=parseInt(
45
+ s.name,10);(0,ze.isAnyNumber)(c)||n.push(new x.InvalidServicePropertyError(t.name,
46
+ s.name,e.file));let l=xt(s,c,t,o,n);l&&Object.assign(i,l)}return(0,ze.isEmptyObject)(
47
+ i)?null:i},"getTypeFromMembers"),xt=p((e,t,r,o,n)=>{let i=(0,x.getPropertyTuple)(
48
+ e)??[],s={};for(let c of i){if(!(0,v.isTypeReference)(c)){n.push(new O(r.file));
49
+ continue}let l=(0,x.getReferenceType)(c,o);if(!l||!(0,v.isTypeClass)(l)){n.push(
50
+ new O(r.file));continue}s[l.name]=t}return s},"getErrorClasses");var qr=p((e,t,r,o)=>{if(!(0,z.isTypeReference)(e))return kr(e,t,r,o);let n=(0,T.getReferenceType)(
51
+ e,r);return n?kr(n,t,r,o):null},"getHttpDefaults"),kr=p((e,t,r,o)=>(0,z.isTypeObject)(
52
+ e)?Cr(t,(0,T.getObjectMembers)(e),r,o):(0,T.isModelDeclaration)(e)?Hr(e)?Cr(t,(0,T.getModelMembers)(
53
+ e),r,o):(o.push(new Z(e.name,t.file)),null):(o.push(new X(t.file)),null),"getTyp\
54
+ eDefaults"),Cr=p((e,t,r,o)=>{let n={};for(let i of t)if(!(!(0,z.isModelProperty)(
55
+ i)||i.inherited))switch(i.name){default:o.push(new T.InvalidServicePropertyError(
56
+ e.name,i.name,e.file));break;case"httpErrors":n.httpErrors=je(i.value,e,r,o);break;case"\
57
+ preferences":n.preferences=Oe(i.value,e,r,o);break;case"memory":case"logRetentio\
58
+ n":case"timeout":n[i.name]=(0,T.getPropertyNumber)(i);break;case"listener":n.listener=
59
+ (0,T.getServiceListener)(i.value,o);break}return n},"getTypeFromMembers");var E=require("@ez4/reflection"),m=require("@ez4/common/library");var ke=require("@ez4/common/library");var _=class extends ke.IncompleteTypeError{static{p(this,"IncompleteRouteError")}constructor(t,r){
60
+ super("Incomplete gateway route",t,r)}},O=class extends ke.TypeError{static{p(this,
61
+ "InvalidRouteErrorTypeError")}constructor(t){super("Invalid route error type.",t)}};var Dr=require("@ez4/common/library");var $=class extends Dr.IncompleteTypeError{static{p(this,"IncompleteAuthorizerEr\
62
+ ror")}constructor(t,r){super("Incomplete route authorizer",t,r)}};var u=require("@ez4/common/library"),q=require("@ez4/reflection"),Qr=require("@ez4/utils");var Ce=require("@ez4/common/library");var L=class extends Ce.InvalidTypeError{constructor(r,o){super("Invalid route re\
63
+ sponse",void 0,r,o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},
64
+ ee=class extends Ce.IncorrectTypeError{constructor(r,o,n){super("Incorrect route\
65
+ response",r,o,n);this.responseType=r;this.baseType=o}static{p(this,"IncorrectRe\
66
+ sponseTypeError")}};var S=require("@ez4/reflection"),Fe=require("@ez4/common/library"),Nr=require("@ez4/schema/library");var qe=require("@ez4/common/library");var re=class extends qe.InvalidTypeError{static{p(this,"InvalidIdentityTypeError")}constructor(t){
67
+ super("Invalid identity",void 0,"Http.Identity",t)}},te=class extends qe.IncorrectTypeError{constructor(r,o){
68
+ super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}static{p(this,
69
+ "IncorrectIdentityTypeError")}};var De=require("@ez4/schema/library");var d=p((e,t)=>{let r=(0,De.getObjectSchema)(e,t);return r&&(0,De.isObjectSchema)(
70
+ r)?r:null},"getSchemaFromType");var j=p((e,t,r,o)=>{if((0,S.isTypeUndefined)(e))return null;if(!(0,S.isTypeReference)(
71
+ e))return Fr(e,t,r,o);let n=(0,Fe.getReferenceType)(e,r);return n?Fr(n,t,r,o):null},
72
+ "getHttpIdentity"),Fr=p((e,t,r,o)=>{if((0,S.isTypeUnion)(e))return vt(e.elements,
73
+ t,r,o);if((0,S.isTypeObject)(e)||(0,S.isTypeIntersection)(e))return d(e,r);if(!(0,Fe.isModelDeclaration)(
74
+ e))return o.push(new re(t.file)),null;if(!Sr(e))return o.push(new te(e.name,t.file)),
75
+ null;let n=d(e,r);return n&&(n.definitions={...n.definitions,extensible:!0}),n},
76
+ "getTypeIdentity"),vt=p((e,t,r,o)=>{let n=[];for(let i of e){let s=j(i,t,r,o);s&&
77
+ n.push(s)}return n.length>1?(0,Nr.createUnionSchema)({elements:n}):n[0]},"getIde\
78
+ ntityFromUnion");var k=require("@ez4/reflection"),Be=require("@ez4/common/library");var Ne=require("@ez4/common/library");var oe=class extends Ne.InvalidTypeError{static{p(this,"InvalidHeadersTypeError")}constructor(t){
79
+ super("Invalid headers",void 0,"Http.Headers",t)}},ne=class extends Ne.IncorrectTypeError{constructor(r,o){
80
+ super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}static{p(this,"\
81
+ IncorrectHeadersTypeError")}};var pe=p((e,t,r,o)=>{if(!(0,k.isTypeReference)(e))return Br(e,t,r,o);let n=(0,Be.getReferenceType)(
82
+ e,r);return n?Br(n,t,r,o):null},"getHttpHeaders"),Br=p((e,t,r,o)=>(0,k.isTypeObject)(
83
+ e)||(0,k.isTypeIntersection)(e)?d(e,r):(0,Be.isModelDeclaration)(e)?hr(e)?d(e,r):
84
+ (o.push(new ne(e.name,t.file)),null):(o.push(new oe(t.file)),null),"getTypeHeade\
85
+ rs");var C=require("@ez4/schema/library"),Ve=require("@ez4/common/library"),y=require("@ez4/reflection");var Ue=require("@ez4/common/library");var se=class extends Ue.InvalidTypeError{static{p(this,"InvalidBodyTypeError")}constructor(t){
86
+ super("Invalid body",void 0,"Http.JsonBody",t)}},ie=class extends Ue.IncorrectTypeError{constructor(r,o){
87
+ super("Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}static{p(this,"Incor\
88
+ rectBodyTypeError")}};var ce=p((e,t,r,o)=>er(e,r,n=>$e(n)??Le(n,t,r,o)),"getHttpBody"),er=p((e,t,r)=>{
89
+ if((0,y.isTypeUndefined)(e))return null;if(!(0,y.isTypeReference)(e))return r(e);
90
+ let o=(0,Ve.getReferenceType)(e,t);return o?r(o):null},"getTypeBody"),$e=p(e=>(0,y.isTypeScalar)(
91
+ e)?(0,C.getScalarSchema)(e):null,"getScalarTypeBody"),Le=p((e,t,r,o)=>(0,y.isTypeUnion)(
92
+ e)?It(e.elements,r,n=>$e(n)??Le(n,t,r,o)):(0,y.isTypeArray)(e)?At(e.element,r,n=>$e(
93
+ n)??Le(n,t,r,o)):(0,y.isTypeObject)(e)||(0,y.isTypeIntersection)(e)?d(e,r):(0,Ve.isModelDeclaration)(
94
+ e)?Ir(e)?d(e,r):(o.push(new ie(e.name,e.file)),null):(o.push(new se(t.file)),null),
95
+ "getCompoundTypeBody"),It=p((e,t,r)=>{let o={optional:!1,elements:[]};for(let n of e){
96
+ if((0,y.isTypeUndefined)(n)){o.optional=!0;continue}let i=er(n,t,r);i&&o.elements.
97
+ push(i)}return o.elements.length?(0,C.createUnionSchema)(o):null},"getUnionTypeB\
98
+ ody"),At=p((e,t,r)=>{let o=er(e,t,r);return o?(0,C.createArraySchema)({element:o}):
99
+ null},"getArrayTypeBody");var rr=p((e,t,r,o)=>{let n=Jr(e,t,r,o,"Http.AuthResponse");return n&&Et(n)?n:null},
100
+ "getHttpAuthResponse"),tr=p((e,t,r,o)=>{let n=Jr(e,t,r,o,"Http.Response");return n&&
101
+ Pt(n)?n:null},"getHttpHandlerResponse"),Jr=p((e,t,r,o,n)=>{if(!(0,q.isTypeReference)(
102
+ e))return Ur(e,t,r,o,n);let i=(0,u.getReferenceType)(e,r);return i?Ur(i,t,r,o,n):
103
+ null},"getHttpResponse"),Et=p(e=>!!e.identity,"isValidAuthResponse"),Pt=p(e=>(0,Qr.isAnyNumber)(
104
+ e.status)||Array.isArray(e.status),"isValidHandlerResponse"),Ur=p((e,t,r,o,n)=>(0,q.isTypeObject)(
105
+ e)?Vr(e,t,(0,u.getObjectMembers)(e),r,o):(0,u.isModelDeclaration)(e)?(0,u.hasHeritageType)(
106
+ e,n)?Vr(e,t,(0,u.getModelMembers)(e),r,o):(o.push(new ee(e.name,n,e.file)),null):
107
+ (o.push(new L(n,t.file)),null),"getTypeResponse"),Vr=p((e,t,r,o,n)=>{let i={};for(let s of r)
108
+ if(!(!(0,q.isModelProperty)(s)||s.inherited))switch(s.name){default:n.push(new u.InvalidServicePropertyError(
109
+ t.name,s.name,e.file));break;case"status":i.status=(0,u.getPropertyNumber)(s)??(0,u.getPropertyNumberList)(
110
+ s);break;case"headers":{i.headers=pe(s.value,e,o,n),i.headers&&s.description&&(i.
111
+ headers.description=s.description);break}case"identity":{i.identity=j(s.value,e,
112
+ o,n),i.identity&&s.description&&(i.identity.description=s.description);break}case"\
113
+ body":{i.body=ce(s.value,e,o,n),i.body&&s.description&&(i.body.description=s.description);
114
+ break}}return i},"getTypeFromMembers");var I=require("@ez4/reflection"),H=require("@ez4/common/library");var Qe=require("@ez4/common/library");var le=class extends Qe.InvalidTypeError{constructor(r,o){super("Invalid route r\
115
+ equest",void 0,r,o);this.baseType=r}static{p(this,"InvalidRequestTypeError")}},me=class extends Qe.IncorrectTypeError{constructor(r,o,n){
116
+ super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}static{
117
+ p(this,"IncorrectRequestTypeError")}};var D=require("@ez4/reflection"),Ge=require("@ez4/common/library");var Je=require("@ez4/common/library");var ae=class extends Je.InvalidTypeError{static{p(this,"InvalidParameterTypeErro\
118
+ r")}constructor(t){super("Invalid request parameters",void 0,"Http.PathParameter\
119
+ s",t)}},ue=class extends Je.IncorrectTypeError{constructor(r,o){super("Incorrect\
120
+ request parameters",r,"Http.PathParameters",o);this.parametersType=r}static{p(this,
121
+ "IncorrectParameterTypeError")}};var or=p((e,t,r,o)=>{if(!(0,D.isTypeReference)(e))return Gr(e,t,r,o);let n=(0,Ge.getReferenceType)(
122
+ e,r);return n?Gr(n,t,r,o):null},"getHttpParameters"),Gr=p((e,t,r,o)=>(0,D.isTypeObject)(
123
+ e)||(0,D.isTypeIntersection)(e)?d(e,r):(0,Ge.isModelDeclaration)(e)?vr(e)?d(e,r):
124
+ (o.push(new ue(e.name,e.file)),null):(o.push(new ae(t.file)),null),"getTypeParam\
125
+ eter");var F=require("@ez4/reflection"),Ye=require("@ez4/common/library");var Ke=require("@ez4/common/library");var fe=class extends Ke.InvalidTypeError{static{p(this,"InvalidQueryTypeError")}constructor(t){
126
+ super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},de=class extends Ke.IncorrectTypeError{constructor(r,o){
127
+ super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
128
+ r}static{p(this,"IncorrectQueryTypeError")}};var nr=p((e,t,r,o)=>{if(!(0,F.isTypeReference)(e))return Kr(e,t,r,o);let n=(0,Ye.getReferenceType)(
129
+ e,r);return n?Kr(n,t,r,o):null},"getHttpQuery"),Kr=p((e,t,r,o)=>(0,F.isTypeObject)(
130
+ e)||(0,F.isTypeIntersection)(e)?d(e,r):(0,Ye.isModelDeclaration)(e)?xr(e)?d(e,r):
131
+ (o.push(new de(e.name,t.file)),null):(o.push(new fe(t.file)),null),"getTypeQuery");var pr=p((e,t,r,o)=>ir(e,t,r,o,"Http.AuthRequest"),"getHttpAuthRequest"),sr=p((e,t,r,o)=>ir(
132
+ e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),ir=p((e,t,r,o,n)=>{if((0,I.isTypeIntersection)(
133
+ e)&&e.elements.length>0)return ir(e.elements[0],t,r,o,n);if(!(0,I.isTypeReference)(
134
+ e))return Yr(e,t,r,o,n);let i=(0,H.getReferenceType)(e,r);return i?Yr(i,t,r,o,n):
135
+ null},"getHttpRequest"),Yr=p((e,t,r,o,n)=>(0,I.isTypeObject)(e)?Wr(e,t,(0,H.getObjectMembers)(
136
+ e),r,o):(0,H.isModelDeclaration)(e)?(0,H.hasHeritageType)(e,n)?Wr(e,t,(0,H.getModelMembers)(
137
+ e),r,o):(o.push(new me(e.name,n,e.file)),null):(o.push(new le(n,t.file)),null),"\
138
+ getTypeRequest"),Wr=p((e,t,r,o,n)=>{let i={};for(let s of r)if(!(!(0,I.isModelProperty)(
139
+ s)||s.inherited))switch(s.name){default:n.push(new H.InvalidServicePropertyError(
140
+ t.name,s.name,e.file));break;case"headers":{i.headers=pe(s.value,e,o,n),i.headers&&
141
+ s.description&&(i.headers.description=s.description);break}case"identity":{i.identity=
142
+ j(s.value,e,o,n),i.identity&&s.description&&(i.identity.description=s.description);
143
+ break}case"query":{i.query=nr(s.value,e,o,n),i.query&&s.description&&(i.query.description=
144
+ s.description);break}case"parameters":{i.parameters=or(s.value,e,o,n),i.parameters&&
145
+ s.description&&(i.parameters.description=s.description);break}case"body":{i.body=
146
+ ce(s.value,e,o,n),i.body&&s.description&&(i.body.description=s.description);break}}
147
+ return i},"getTypeFromMembers");var cr=p((e,t,r,o)=>{if(!Rr(e))return null;let{description:n,module:i}=e,s={...n&&
148
+ {description:n},...i&&{module:i}},c=new Set(["name","file"]);if((s.name=e.name)&&
149
+ c.delete("name"),(s.file=e.file)&&c.delete("file"),e.parameters){let[{value:l}]=e.
150
+ parameters;s.request=pr(l,t,r,o)}return e.return&&(s.response=rr(e.return,t,r,o)),
151
+ Rt(s)?s:(o.push(new $([...c],e.file)),null)},"getHttpAuthorizer"),Rt=p(e=>!!e.name&&
152
+ !!e.file,"isValidAuthorizer");var Xr=require("@ez4/common/library");var ye=class extends Xr.IncompleteTypeError{static{p(this,"IncompleteHandlerErro\
153
+ r")}constructor(t,r){super("Incomplete route handler",t,r)}};var A=require("@ez4/common/library"),Xe=require("@ez4/reflection");var We=require("@ez4/common/library");var Te=class extends We.InvalidTypeError{constructor(r,o){super("Invalid route p\
154
+ rovider",void 0,r,o);this.baseType=r}static{p(this,"InvalidProviderTypeError")}},
155
+ ge=class extends We.IncompleteTypeError{static{p(this,"IncompleteProviderError")}constructor(t,r){
156
+ super("Incomplete route provider",t,r)}};var _r=p((e,t,r,o)=>{if(!(0,Xe.isTypeReference)(e))return Zr(e,t,r,o,"Http.Provi\
157
+ der");let n=(0,A.getReferenceType)(e,r);return n?Zr(n,t,r,o,"Http.Provider"):null},
158
+ "getHttpProvider"),wt=p(e=>!!e.services,"isValidProvider"),Zr=p((e,t,r,o,n)=>(0,A.isModelDeclaration)(
159
+ e)?Ot(e,(0,A.getModelMembers)(e),r,o):(o.push(new Te(n,t.file)),null),"getProvid\
160
+ erType"),Ot=p((e,t,r,o)=>{let n={},i=new Set(["services"]);for(let s of t)if(!(!(0,Xe.isModelProperty)(
161
+ s)||s.inherited))switch(s.name){case"services":let c=(0,A.getLinkedServiceList)(
162
+ s,r,o);c&&(n.services=c),i.delete(s.name);break}return wt(n)?n:(o.push(new ge([...i],
163
+ e.file)),null)},"getTypeFromMembers");var lr=p((e,t,r,o)=>{if(!wr(e))return null;let{description:n,module:i}=e,s={...n&&
164
+ {description:n},...i&&{module:i}},c=new Set(["name","file","response"]);if((s.name=
165
+ e.name)&&c.delete("name"),(s.file=e.file)&&c.delete("file"),e.parameters){let[{value:l},
166
+ Tr]=e.parameters;s.request=sr(l,t,r,o),Tr&&(s.provider=_r(Tr.value,t,r,o))}if(e.
167
+ return){let l=tr(e.return,t,r,o);l&&(s.response=l,c.delete("response"))}return zt(
168
+ s)?s:(o.push(new ye([...c],e.file)),null)},"getHttpHandler"),zt=p(e=>!!e.name&&!!e.
169
+ file&&!!e.response,"isValidHandler");var mr=p((e,t,r,o)=>{let n=(0,m.getPropertyTuple)(t)??[];return et(n,e,r,o)},"ge\
170
+ tHttpRoutes"),et=p((e,t,r,o)=>{let n=[];for(let i of e){let s=jt(i,t,r,o);Array.
171
+ isArray(s)?n.push(...s):s&&n.push(s)}return n},"getRouteFromTuple"),jt=p((e,t,r,o)=>{
172
+ if(!(0,E.isTypeReference)(e))return $r(e,t,r,o);let n=(0,m.getReferenceType)(e,r);
173
+ return n?$r(n,t,r,o):null},"getTypeFromRoute"),kt=p(e=>!!e.path&&!!e.handler,"is\
174
+ ValidRoute"),$r=p((e,t,r,o)=>Mr(e)?Lr(e,t,(0,m.getModelMembers)(e),r,o):(0,E.isTypeObject)(
175
+ e)?Lr(e,t,(0,m.getObjectMembers)(e),r,o):(0,E.isTypeTuple)(e)&&e.spread?et(e.elements,
176
+ t,r,o):null,"getRouteType"),Lr=p((e,t,r,o,n)=>{let i={},s=new Set(["path","handl\
177
+ er"]);for(let c of r)if(!(!(0,E.isModelProperty)(c)||c.inherited))switch(c.name){default:
178
+ n.push(new m.InvalidServicePropertyError(t.name,c.name,e.file));break;case"path":{
179
+ let l=(0,m.getPropertyString)(c);l&&gr(l)&&(s.delete(c.name),i.path=l);break}case"\
180
+ handler":(i.handler=lr(c.value,t,o,n))&&s.delete(c.name);break;case"authorizer":
181
+ i.authorizer=cr(c.value,t,o,n);break;case"httpErrors":i.httpErrors=je(c.value,t,
182
+ o,n);break;case"preferences":i.preferences=Oe(c.value,t,o,n);break;case"memory":case"\
183
+ logRetention":case"timeout":i[c.name]=(0,m.getPropertyNumber)(c);break;case"cors":
184
+ i.cors=(0,m.getPropertyBoolean)(c);break;case"listener":i.listener=(0,m.getServiceListener)(
185
+ c.value,n);break;case"variables":i.variables=(0,m.getLinkedVariableList)(c,n);break}
186
+ return kt(i)?i:(n.push(new _([...s],e.file)),null)},"getTypeFromMembers");var b=require("@ez4/common/library"),B=require("@ez4/reflection"),ar=require("@ez4/utils");var N=require("@ez4/common/library");var Me=class extends N.IncompleteTypeError{static{p(this,"IncompleteCacheError")}constructor(t,r){
187
+ super("Incomplete gateway cache",t,r)}},He=class extends N.InvalidTypeError{static{
188
+ p(this,"InvalidCacheTypeError")}constructor(t){super("Invalid gateway cache type",
189
+ void 0,"Http.Cache",t)}},be=class extends N.IncorrectTypeError{constructor(r,o){
190
+ super("Incorrect gateway cache type",r,"Http.Cache",o);this.cacheType=r}static{p(
191
+ this,"IncorrectCacheTypeError")}};var ur=p((e,t,r,o)=>{if(!(0,B.isTypeReference)(e))return rt(e,t,o);let n=(0,b.getReferenceType)(
192
+ e,r);return n?rt(n,t,o):null},"getHttpCache"),Ct=p(e=>(0,ar.isAnyNumber)(e.authorizerTTL),
193
+ "isValidCache"),rt=p((e,t,r)=>(0,B.isTypeObject)(e)?tt(e,t,(0,b.getObjectMembers)(
194
+ e),r):(0,b.isModelDeclaration)(e)?Ar(e)?tt(e,t,(0,b.getModelMembers)(e),r):(r.push(
195
+ new be(e.name,e.file)),null):(r.push(new He(t.file)),null),"getTypeCache"),tt=p(
196
+ (e,t,r,o)=>{let n={},i=new Set(["authorizerTTL"]);for(let s of r)if(!(!(0,B.isModelProperty)(
197
+ s)||s.inherited))switch(s.name){default:o.push(new b.InvalidServicePropertyError(
198
+ t.name,s.name,e.file));break;case"authorizerTTL":{let c=(0,b.getPropertyNumber)(
199
+ s);(0,ar.isAnyNumber)(c)&&(n[s.name]=c,i.delete(s.name));break}}return Ct(n)?n:(o.
200
+ push(new Me([...i],e.file)),null)},"getTypeFromMembers");var h=require("@ez4/common/library"),V=require("@ez4/reflection"),fr=require("@ez4/utils");var U=require("@ez4/common/library");var he=class extends U.IncompleteTypeError{static{p(this,"IncompleteAccessError")}constructor(t,r){
201
+ super("Incomplete gateway access",t,r)}},Se=class extends U.InvalidTypeError{static{
202
+ p(this,"InvalidAccessTypeError")}constructor(t){super("Invalid gateway access ty\
203
+ pe",void 0,"Http.Access",t)}},xe=class extends U.IncorrectTypeError{constructor(r,o){
204
+ super("Incorrect gateway access type",r,"Http.Access",o);this.cacheType=r}static{
205
+ p(this,"IncorrectAccessTypeError")}};var pt=p((e,t,r,o)=>{if(!(0,V.isTypeReference)(e))return ot(e,t,o);let n=(0,h.getReferenceType)(
206
+ e,r);return n?ot(n,t,o):null},"getHttpAccess"),qt=p(e=>(0,fr.isAnyNumber)(e.logRetention),
207
+ "isValidAccess"),ot=p((e,t,r)=>(0,V.isTypeObject)(e)?nt(e,t,(0,h.getObjectMembers)(
208
+ e),r):(0,h.isModelDeclaration)(e)?Er(e)?nt(e,t,(0,h.getModelMembers)(e),r):(r.push(
209
+ new xe(e.name,e.file)),null):(r.push(new Se(t.file)),null),"getTypeAccess"),nt=p(
210
+ (e,t,r,o)=>{let n={},i=new Set(["logRetention"]);for(let s of r)if(!(!(0,V.isModelProperty)(
211
+ s)||s.inherited))switch(s.name){default:o.push(new h.InvalidServicePropertyError(
212
+ t.name,s.name,e.file));break;case"logRetention":{let c=(0,h.getPropertyNumber)(s);
213
+ (0,fr.isAnyNumber)(c)&&(n[s.name]=c,i.delete(s.name));break}}return qt(n)?n:(o.push(
214
+ new he([...i],e.file)),null)},"getTypeFromMembers");var f=require("@ez4/common/library"),J=require("@ez4/reflection");var Q=require("@ez4/common/library");var ve=class extends Q.IncompleteTypeError{static{p(this,"IncompleteCorsError")}constructor(t,r){
215
+ super("Incomplete HTTP CORS",t,r)}},Ie=class extends Q.InvalidTypeError{static{p(
216
+ this,"InvalidCorsTypeError")}constructor(t){super("Invalid HTTP CORS type",void 0,
217
+ "Http.Cors",t)}},Ae=class extends Q.IncorrectTypeError{constructor(r,o){super("I\
218
+ ncorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}static{p(this,"Inc\
219
+ orrectCorsTypeError")}};var dr=p((e,t,r,o)=>{if(!(0,J.isTypeReference)(e))return st(e,t,o);let n=(0,f.getReferenceType)(
220
+ e,r);return n?st(n,t,o):null},"getHttpCors"),Dt=p(e=>!!e.allowOrigins?.length,"i\
221
+ sValidCors"),st=p((e,t,r)=>(0,J.isTypeObject)(e)?it(e,t,(0,f.getObjectMembers)(e),
222
+ r):(0,f.isModelDeclaration)(e)?Pr(e)?it(e,t,(0,f.getModelMembers)(e),r):(r.push(
223
+ new Ae(e.name,e.file)),null):(r.push(new Ie(t.file)),null),"getTypeCors"),it=p((e,t,r,o)=>{
224
+ let n={},i=new Set(["allowOrigins"]);for(let s of r)if(!(!(0,J.isModelProperty)(
225
+ s)||s.inherited))switch(s.name){default:o.push(new f.InvalidServicePropertyError(
226
+ t.name,s.name,e.file));break;case"allowOrigins":case"allowMethods":case"allowHea\
227
+ ders":case"exposeHeaders":n[s.name]=(0,f.getPropertyStringList)(s);break;case"al\
228
+ lowCredentials":n.allowCredentials=(0,f.getPropertyBoolean)(s);break;case"maxAge":
229
+ n.maxAge=(0,f.getPropertyNumber)(s);break}return Dt(n)?n:(o.push(new ve([...i],e.
230
+ file)),null)},"getTypeFromMembers");var yr=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!we(n)||(0,g.isExternalDeclaration)(
231
+ n))continue;let i={type:Pe,extras:{}},s=new Set(["routes"]),c=n.file;i.name=n.name,
232
+ n.description&&(i.description=n.description);for(let l of(0,g.getModelMembers)(n))
233
+ if(!(!(0,ct.isModelProperty)(l)||l.inherited))switch(l.name){default:r.push(new g.InvalidServicePropertyError(
234
+ i.name,l.name,c));break;case"routes":(i.routes=mr(n,l,e,r))&&s.delete(l.name);break;case"\
235
+ name":i.displayName=(0,g.getPropertyString)(l);break;case"defaults":i.defaults=qr(
236
+ l.value,n,e,r);break;case"cache":i.cache=ur(l.value,n,e,r);break;case"access":i.
237
+ access=pt(l.value,n,e,r);break;case"cors":i.cors=dr(l.value,n,e,r);break;case"va\
238
+ riables":i.variables=(0,g.getLinkedVariableList)(l,r);break;case"services":i.services=
239
+ (0,g.getLinkedServiceList)(l,e,r);break}if(!Ft(i)){r.push(new G([...s],c));continue}
240
+ if(t[n.name]){r.push(new g.DuplicateServiceError(n.name,c));continue}Nt(i,r,c),t[n.
241
+ name]=i}return{services:t,errors:r}},"getHttpServices"),Ft=p(e=>!!e.name&&!!e.routes&&
242
+ !!e.extras,"isValidService"),Nt=p((e,t,r)=>{for(let o of e.routes){let n=o.handler.
243
+ provider;if(n?.services){e.services||(e.services={});for(let i in n.services){let s=e.
244
+ services[i],c=n.services[i];if(!s){e.services[i]=c;continue}s!==c&&t.push(new K(
245
+ i,r))}}}},"assignProviderServices");var lt=p(e=>we(e)?e.name:null,"getLinkedService");var mt=!1,Bt=p(()=>{mt||((0,at.registerTriggers)(),(0,ut.registerTriggers)(),(0,ft.createTrigger)(
246
+ "@ez4/gateway",{"metadata:getServices":yr,"metadata:getLinkedService":lt}),mt=!0)},
247
+ "registerTriggers");var Ze=require("@ez4/common/library");var X=class extends Ze.InvalidTypeError{static{p(this,"InvalidDefaultsTypeError")}constructor(t){
248
+ super("Invalid defaults",void 0,"Http.Defaults",t)}},Z=class extends Ze.IncorrectTypeError{constructor(r,o){
249
+ super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}static{p(this,
250
+ "IncorrectDefaultsTypeError")}};var _e=require("@ez4/common/library");var Y=class extends _e.InvalidTypeError{static{p(this,"InvalidPreferencesTypeErr\
251
+ or")}constructor(t){super("Invalid preferences",void 0,"Http.Preferences",t)}},W=class extends _e.IncorrectTypeError{constructor(r,o){
252
+ super("Incorrect preferences",r,"Http.Preferences",o);this.preferencesType=r}static{
253
+ p(this,"IncorrectPreferencesTypeError")}};0&&(module.exports={IncompleteAccessError,IncompleteAuthorizerError,IncompleteCacheError,
254
+ IncompleteCorsError,IncompleteHandlerError,IncompleteProviderError,IncompleteRouteError,
255
+ IncompleteServiceError,IncorrectAccessTypeError,IncorrectBodyTypeError,IncorrectCacheTypeError,
256
+ IncorrectCorsTypeError,IncorrectDefaultsTypeError,IncorrectHeadersTypeError,IncorrectIdentityTypeError,
257
+ IncorrectParameterTypeError,IncorrectPreferencesTypeError,IncorrectQueryTypeError,
258
+ IncorrectRequestTypeError,IncorrectResponseTypeError,InvalidAccessTypeError,InvalidBodyTypeError,
223
259
  InvalidCacheTypeError,InvalidCorsTypeError,InvalidDefaultsTypeError,InvalidHeadersTypeError,
224
- InvalidIdentityTypeError,InvalidParameterTypeError,InvalidPreferencesTypeError,InvalidQueryTypeError,
225
- InvalidRequestTypeError,InvalidResponseTypeError,InvalidRouteErrorTypeError,ServiceType,
226
- getHttpAuthRequest,getHttpAuthResponse,getHttpAuthorizer,getHttpBody,getHttpCache,
227
- getHttpCors,getHttpHandler,getHttpHandlerRequest,getHttpHandlerResponse,getHttpHeaders,
228
- getHttpIdentity,getHttpParameters,getHttpQuery,getHttpRoutes,getHttpServices,isHttpService,
229
- registerTriggers});
260
+ InvalidIdentityTypeError,InvalidParameterTypeError,InvalidPreferencesTypeError,InvalidProviderTypeError,
261
+ InvalidQueryTypeError,InvalidRequestTypeError,InvalidResponseTypeError,InvalidRouteErrorTypeError,
262
+ ServiceCollisionError,ServiceType,getHttpAuthRequest,getHttpAuthResponse,getHttpAuthorizer,
263
+ getHttpBody,getHttpCache,getHttpCors,getHttpHandler,getHttpHandlerRequest,getHttpHandlerResponse,
264
+ getHttpHeaders,getHttpIdentity,getHttpParameters,getHttpQuery,getHttpRoutes,getHttpServices,
265
+ isHttpService,registerTriggers});
230
266
  //# sourceMappingURL=library.cjs.map