@ez4/gateway 0.24.0 → 0.26.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 +74 -73
- package/dist/library.mjs +134 -133
- package/dist/utils/body.d.ts +1 -1
- package/dist/utils.cjs +10 -10
- package/dist/utils.mjs +10 -10
- package/package.json +9 -9
- package/dist/services/types.d.ts +0 -9
package/dist/library.cjs
CHANGED
|
@@ -9,13 +9,13 @@ IncorrectRequestTypeError:()=>pe,IncorrectResponseTypeError:()=>X,InvalidBodyTyp
|
|
|
9
9
|
InvalidCacheTypeError:()=>de,InvalidCorsTypeError:()=>ue,InvalidDefaultsTypeError:()=>J,
|
|
10
10
|
InvalidHeadersTypeError:()=>$,InvalidIdentityTypeError:()=>Z,InvalidParameterTypeError:()=>se,
|
|
11
11
|
InvalidPreferencesTypeError:()=>V,InvalidQueryTypeError:()=>ce,InvalidRequestTypeError:()=>ne,
|
|
12
|
-
InvalidResponseTypeError:()=>W,InvalidRouteErrorTypeError:()=>
|
|
13
|
-
getHttpAuthRequest:()=>Ge,getHttpAuthResponse:()=>
|
|
12
|
+
InvalidResponseTypeError:()=>W,InvalidRouteErrorTypeError:()=>P,ServiceType:()=>Me,
|
|
13
|
+
getHttpAuthRequest:()=>Ge,getHttpAuthResponse:()=>Ne,getHttpAuthorizer:()=>We,getHttpBody:()=>oe,
|
|
14
14
|
getHttpCache:()=>Le,getHttpCors:()=>_e,getHttpHandler:()=>Xe,getHttpHandlerRequest:()=>Ke,
|
|
15
|
-
getHttpHandlerResponse:()=>Ve,getHttpHeaders:()=>ee,getHttpIdentity:()=>
|
|
15
|
+
getHttpHandlerResponse:()=>Ve,getHttpHeaders:()=>ee,getHttpIdentity:()=>w,getHttpParameters:()=>Qe,
|
|
16
16
|
getHttpQuery:()=>Je,getHttpRoutes:()=>Ze,getHttpServices:()=>er,isHttpService:()=>Lr,
|
|
17
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
|
|
18
|
+
super("Incomplete service",r,t)}};var d=require("@ez4/common/library"),j=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
19
|
r]=e.split(" ",2);return et.has(r)},"isHttpPath"),or=p(e=>(0,a.isClassDeclaration)(
|
|
20
20
|
e)&&(0,a.hasHeritageType)(e,"Http.Service"),"isHttpService"),nr=p(e=>(0,a.isModelDeclaration)(
|
|
21
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)(
|
|
@@ -25,103 +25,104 @@ HttpIdentity"),lr=p(e=>(0,a.hasHeritageType)(e,"Http.QueryStrings"),"isHttpQuery
|
|
|
25
25
|
mr=p(e=>(0,a.hasHeritageType)(e,"Http.PathParameters"),"isHttpParameters"),ar=p(
|
|
26
26
|
e=>(0,a.hasHeritageType)(e,"Http.JsonBody"),"isJsonBody"),ur=p(e=>(0,a.hasHeritageType)(
|
|
27
27
|
e,"Http.Cors"),"isHttpCors"),fr=p(e=>(0,a.hasHeritageType)(e,"Http.Cache"),"isHt\
|
|
28
|
-
tpCache"),yr=p(e=>(0,
|
|
29
|
-
izer"),dr=p(e=>(0,
|
|
30
|
-
e,t);if(n)return Tr(n,r,o)},"getHttpPreferences"),Tr=p((e,r,t)=>{if((0,
|
|
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
31
|
e))return gr(r,(0,M.getObjectMembers)(e),t);if(!(0,M.isModelDeclaration)(e)){t.push(
|
|
32
32
|
new V(r.file));return}if(!sr(e)){t.push(new Q(e.name,r.file));return}return gr(r,
|
|
33
33
|
(0,M.getModelMembers)(e),t)},"getTypePreferences"),gr=p((e,r,t)=>{let o={};for(let n of r)
|
|
34
|
-
if((0,
|
|
34
|
+
if((0,R.isModelProperty)(n))switch(n.name){default:t.push(new M.InvalidServicePropertyError(
|
|
35
35
|
e.name,n.name,e.file));break;case"namingStyle":o.namingStyle=(0,M.getPropertyStringIn)(
|
|
36
|
-
n,[
|
|
37
|
-
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)(
|
|
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
38
|
e,t);return n?Mr(n,r,t,o):null},"getHttpErrors"),Mr=p((e,r,t,o)=>(0,x.isTypeObject)(
|
|
39
39
|
e)?rt(e,r,(0,S.getObjectMembers)(e),t,o):null,"getTypeErrors"),rt=p((e,r,t,o,n)=>{
|
|
40
40
|
let s={};for(let i of t){if(!(0,x.isModelProperty)(i)||i.inherited)continue;let c=parseInt(
|
|
41
41
|
i.name,10);(0,be.isAnyNumber)(c)||n.push(new S.InvalidServicePropertyError(r.name,
|
|
42
42
|
i.name,e.file));let l=tt(i,c,r,o,n);l&&Object.assign(s,l)}return(0,be.isEmptyObject)(
|
|
43
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
|
|
44
|
+
e)??[],i={};for(let c of s){if(!(0,x.isTypeReference)(c)){n.push(new P(t.file));
|
|
45
45
|
continue}let l=(0,S.getReferenceType)(c,o);if(!l||!(0,x.isTypeClass)(l)){n.push(
|
|
46
|
-
new
|
|
47
|
-
e,t);return n?Hr(n,r,t,o):null},"getHttpDefaults"),Hr=p((e,r,t,o)=>(0,
|
|
48
|
-
e)?br(r,(0,
|
|
46
|
+
new P(t.file));continue}i[l.name]=r}return i},"getErrorClasses");var hr=p((e,r,t,o)=>{if(!(0,j.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,j.isTypeObject)(
|
|
48
|
+
e)?br(r,(0,d.getObjectMembers)(e),t,o):(0,d.isModelDeclaration)(e)?pr(e)?br(r,(0,d.getModelMembers)(
|
|
49
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,
|
|
51
|
-
s)||s.inherited))switch(s.name){default:o.push(new
|
|
50
|
+
eDefaults"),br=p((e,r,t,o)=>{let n={};for(let s of r)if(!(!(0,j.isModelProperty)(
|
|
51
|
+
s)||s.inherited))switch(s.name){default:o.push(new d.InvalidServicePropertyError(
|
|
52
52
|
e.name,s.name,e.file));break;case"httpErrors":n.httpErrors=he(s.value,e,t,o);break;case"\
|
|
53
53
|
preferences":n.preferences=He(s.value,e,t,o);break;case"memory":case"logRetentio\
|
|
54
|
-
n":case"timeout":n[s.name]=(0,
|
|
55
|
-
(0,
|
|
56
|
-
super("Incomplete gateway route",r,t)}},
|
|
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
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"),
|
|
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
59
|
sponse",void 0,t,o);this.baseType=t}static{p(this,"InvalidResponseTypeError")}},
|
|
60
60
|
X=class extends xe.IncorrectTypeError{constructor(t,o,n){super("Incorrect route \
|
|
61
61
|
response",t,o,n);this.responseType=t;this.baseType=o}static{p(this,"IncorrectRes\
|
|
62
|
-
ponseTypeError")}};var h=require("@ez4/reflection"),
|
|
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
63
|
super("Invalid identity",void 0,"Http.Identity",r)}},_=class extends Ie.IncorrectTypeError{constructor(t,o){
|
|
64
64
|
super("Incorrect identity",t,"Http.Identity",o);this.identityType=t}static{p(this,
|
|
65
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
|
|
67
|
-
e))return xr(e,r,t,o);let n=(0,
|
|
66
|
+
t)?t:null},"getSchemaFromType");var w=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
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,
|
|
69
|
+
r,t,o);if((0,h.isTypeObject)(e)||(0,h.isTypeIntersection)(e))return f(e,t);if(!(0,ve.isModelDeclaration)(
|
|
70
70
|
e))return o.push(new Z(r.file)),null;if(!cr(e))return o.push(new _(e.name,r.file)),
|
|
71
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=
|
|
72
|
+
"getTypeIdentity"),ot=p((e,r,t,o)=>{let n=[];for(let s of e){let i=w(s,r,t,o);i&&
|
|
73
73
|
n.push(i)}return n.length>1?(0,Ir.createUnionSchema)({elements:n}):n[0]},"getIde\
|
|
74
|
-
ntityFromUnion");var
|
|
75
|
-
super("Invalid headers",void 0,"Http.Headers",r)}},L=class extends
|
|
74
|
+
ntityFromUnion");var O=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
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,
|
|
78
|
-
e,t);return n?Er(n,r,t,o):null},"getHttpHeaders"),Er=p((e,r,t,o)=>(0,
|
|
79
|
-
e)||(0,
|
|
80
|
-
(o.push(new L(e.name,r.file)),null):(o.push(new $(r.file)),null),"getTypeHeaders");var
|
|
77
|
+
IncorrectHeadersTypeError")}};var ee=p((e,r,t,o)=>{if(!(0,O.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,O.isTypeObject)(
|
|
79
|
+
e)||(0,O.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 z=require("@ez4/schema/library"),je=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
81
|
super("Invalid body",void 0,"Http.JsonBody",r)}},te=class extends Pe.IncorrectTypeError{constructor(t,o){
|
|
82
82
|
super("Incorrect body",t,"Http.JsonBody",o);this.bodyType=t}static{p(this,"Incor\
|
|
83
|
-
rectBodyTypeError")}};var oe=p((e,r,t,o)=>
|
|
84
|
-
if((0,
|
|
85
|
-
let o=(0,je.getReferenceType)(e,r);return o?t(o):null},"getTypeBody"),Fe=p(e=>(0,
|
|
86
|
-
e)?(0,
|
|
87
|
-
e)?nt(e.elements,t,n=>Fe(n)??Be(n,r,t,o)):(0,
|
|
88
|
-
n)??Be(n,r,t,o)):(0,
|
|
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,je.getReferenceType)(e,r);return o?t(o):null},"getTypeBody"),Fe=p(e=>(0,y.isTypeScalar)(
|
|
86
|
+
e)?(0,z.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,je.isModelDeclaration)(
|
|
89
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=[];for(let n of e){
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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,z.createUnionSchema)(o):null},"getUnionTypeB\
|
|
93
|
+
ody"),pt=p((e,r,t)=>{let o=Ue(e,r,t);return o?(0,z.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},
|
|
94
95
|
"getHttpAuthResponse"),Ve=p((e,r,t,o)=>{let n=Pr(e,r,t,o,"Http.Response");return n&&
|
|
95
|
-
it(n)?n:null},"getHttpHandlerResponse"),Pr=p((e,r,t,o,n)=>{if(!(0,
|
|
96
|
-
e))return
|
|
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):
|
|
97
98
|
null},"getHttpResponse"),st=p(e=>!!e.identity,"isValidAuthResponse"),it=p(e=>(0,Rr.isAnyNumber)(
|
|
98
|
-
e.status),"isValidHandlerResponse"),
|
|
99
|
+
e.status),"isValidHandlerResponse"),vr=p((e,r,t,o,n)=>(0,C.isTypeObject)(e)?Ar(e,
|
|
99
100
|
r,(0,T.getObjectMembers)(e),t,o):(0,T.isModelDeclaration)(e)?(0,T.hasHeritageType)(
|
|
100
|
-
e,n)?
|
|
101
|
-
(o.push(new W(n,r.file)),null),"getTypeResponse"),
|
|
102
|
-
if(!(!(0,
|
|
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(
|
|
103
104
|
r.name,i.name,e.file));break;case"status":s.status=(0,T.getPropertyNumber)(i);break;case"\
|
|
104
105
|
headers":{s.headers=ee(i.value,e,o,n),s.headers&&i.description&&(s.headers.description=
|
|
105
|
-
i.description);break}case"identity":{s.identity=
|
|
106
|
+
i.description);break}case"identity":{s.identity=w(i.value,e,o,n),s.identity&&i.description&&
|
|
106
107
|
(s.identity.description=i.description);break}case"body":{s.body=oe(i.value,e,o,n),
|
|
107
108
|
s.body&&i.description&&(s.body.description=i.description);break}}return s},"getT\
|
|
108
109
|
ypeFromMembers");var I=require("@ez4/reflection"),H=require("@ez4/common/library");var we=require("@ez4/common/library");var ne=class extends we.InvalidTypeError{constructor(t,o){super("Invalid route r\
|
|
109
110
|
equest",void 0,t,o);this.baseType=t}static{p(this,"InvalidRequestTypeError")}},pe=class extends we.IncorrectTypeError{constructor(t,o,n){
|
|
110
111
|
super("Incorrect route request",t,o,n);this.requestType=t;this.baseType=o}static{
|
|
111
|
-
p(this,"IncorrectRequestTypeError")}};var
|
|
112
|
+
p(this,"IncorrectRequestTypeError")}};var k=require("@ez4/reflection"),ze=require("@ez4/common/library");var Oe=require("@ez4/common/library");var se=class extends Oe.InvalidTypeError{static{p(this,"InvalidParameterTypeErro\
|
|
112
113
|
r")}constructor(r){super("Invalid request parameters",void 0,"Http.PathParameter\
|
|
113
114
|
s",r)}},ie=class extends Oe.IncorrectTypeError{constructor(t,o){super("Incorrect\
|
|
114
115
|
request parameters",t,"Http.PathParameters",o);this.parametersType=t}static{p(this,
|
|
115
|
-
"IncorrectParameterTypeError")}};var Qe=p((e,r,t,o)=>{if(!(0,
|
|
116
|
-
e,t);return n?jr(n,r,t,o):null},"getHttpParameters"),jr=p((e,r,t,o)=>(0,
|
|
117
|
-
e)||(0,
|
|
116
|
+
"IncorrectParameterTypeError")}};var Qe=p((e,r,t,o)=>{if(!(0,k.isTypeReference)(e))return jr(e,r,t,o);let n=(0,ze.getReferenceType)(
|
|
117
|
+
e,t);return n?jr(n,r,t,o):null},"getHttpParameters"),jr=p((e,r,t,o)=>(0,k.isTypeObject)(
|
|
118
|
+
e)||(0,k.isTypeIntersection)(e)?f(e,t):(0,ze.isModelDeclaration)(e)?mr(e)?f(e,t):
|
|
118
119
|
(o.push(new ie(e.name,e.file)),null):(o.push(new se(r.file)),null),"getTypeParam\
|
|
119
|
-
eter");var
|
|
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){
|
|
120
121
|
super("Invalid request query strings",void 0,"Http.QueryStrings",r)}},le=class extends Ce.IncorrectTypeError{constructor(t,o){
|
|
121
122
|
super("Incorrect request query strings",t,"Http.QueryStrings",o);this.queryType=
|
|
122
|
-
t}static{p(this,"IncorrectQueryTypeError")}};var Je=p((e,r,t,o)=>{if(!(0,
|
|
123
|
-
e,t);return n?wr(n,r,t,o):null},"getHttpQuery"),wr=p((e,r,t,o)=>(0,
|
|
124
|
-
e)||(0,
|
|
123
|
+
t}static{p(this,"IncorrectQueryTypeError")}};var Je=p((e,r,t,o)=>{if(!(0,q.isTypeReference)(e))return wr(e,r,t,o);let n=(0,ke.getReferenceType)(
|
|
124
|
+
e,t);return n?wr(n,r,t,o):null},"getHttpQuery"),wr=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):
|
|
125
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(
|
|
126
127
|
e,r,t,o,"Http.Request"),"getHttpHandlerRequest"),Ye=p((e,r,t,o,n)=>{if((0,I.isTypeIntersection)(
|
|
127
128
|
e)&&e.elements.length>0)return Ye(e.elements[0],r,t,o,n);if(!(0,I.isTypeReference)(
|
|
@@ -133,7 +134,7 @@ getTypeRequest"),zr=p((e,r,t,o,n)=>{let s={};for(let i of t)if(!(!(0,I.isModelPr
|
|
|
133
134
|
i)||i.inherited))switch(i.name){default:n.push(new H.InvalidServicePropertyError(
|
|
134
135
|
r.name,i.name,e.file));break;case"headers":{s.headers=ee(i.value,e,o,n),s.headers&&
|
|
135
136
|
i.description&&(s.headers.description=i.description);break}case"identity":{s.identity=
|
|
136
|
-
|
|
137
|
+
w(i.value,e,o,n),s.identity&&i.description&&(s.identity.description=i.description);
|
|
137
138
|
break}case"query":{s.query=Je(i.value,e,o,n),s.query&&i.description&&(s.query.description=
|
|
138
139
|
i.description);break}case"parameters":{s.parameters=Qe(i.value,e,o,n),s.parameters&&
|
|
139
140
|
i.description&&(s.parameters.description=i.description);break}case"body":{s.body=
|
|
@@ -141,7 +142,7 @@ oe(i.value,e,o,n),s.body&&i.description&&(s.body.description=i.description);brea
|
|
|
141
142
|
return s},"getTypeFromMembers");var We=p((e,r,t,o)=>{if(!yr(e))return null;let{description:n,module:s}=e,i={...n&&
|
|
142
143
|
{description:n},...s&&{module:s}},c=new Set(["name","file"]);if((i.name=e.name)&&
|
|
143
144
|
c.delete("name"),(i.file=e.file)&&c.delete("file"),e.parameters){let[{value:l}]=e.
|
|
144
|
-
parameters;i.request=Ge(l,r,t,o)}return e.return&&(i.response=
|
|
145
|
+
parameters;i.request=Ge(l,r,t,o)}return e.return&&(i.response=Ne(e.return,r,t,o)),
|
|
145
146
|
ct(i)?i:(o.push(new Y([...c],e.file)),null)},"getHttpAuthorizer"),ct=p(e=>!!e.name&&
|
|
146
147
|
!!e.file,"isValidAuthorizer");var Cr=require("@ez4/common/library");var me=class extends Cr.IncompleteTypeError{static{p(this,"IncompleteHandlerErro\
|
|
147
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&&
|
|
@@ -166,33 +167,33 @@ o,n);break;case"preferences":s.preferences=He(c.value,r,o,n);break;case"memory":
|
|
|
166
167
|
logRetention":case"timeout":s[c.name]=(0,m.getPropertyNumber)(c);break;case"cors":
|
|
167
168
|
s.cors=(0,m.getPropertyBoolean)(c);break;case"listener":s.listener=(0,m.getServiceListener)(
|
|
168
169
|
c.value,n);break;case"variables":s.variables=(0,m.getLinkedVariableList)(c,n);break}
|
|
169
|
-
return at(s)?s:(n.push(new K([...i],e.file)),null)},"getTypeFromMembers");var u=require("@ez4/common/library"),
|
|
170
|
-
super("Incomplete HTTP CORS",r,t)}},ue=class extends
|
|
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(
|
|
171
172
|
this,"InvalidCorsTypeError")}constructor(r){super("Invalid HTTP CORS type",void 0,
|
|
172
|
-
"Http.Cors",r)}},fe=class extends
|
|
173
|
+
"Http.Cors",r)}},fe=class extends D.IncorrectTypeError{constructor(t,o){super("I\
|
|
173
174
|
ncorrect HTTP CORS type",t,"Http.Cors",o);this.fallbackType=t}static{p(this,"Inc\
|
|
174
|
-
orrectCorsTypeError")}};var _e=p((e,r,t,o)=>{if(!(0,
|
|
175
|
+
orrectCorsTypeError")}};var _e=p((e,r,t,o)=>{if(!(0,F.isTypeReference)(e))return Fr(e,r,o);let n=(0,u.getReferenceType)(
|
|
175
176
|
e,t);return n?Fr(n,r,o):null},"getHttpCors"),ut=p(e=>!!e.allowOrigins?.length,"i\
|
|
176
|
-
sValidCors"),Fr=p((e,r,t)=>(0,
|
|
177
|
+
sValidCors"),Fr=p((e,r,t)=>(0,F.isTypeObject)(e)?Br(e,r,(0,u.getObjectMembers)(e),
|
|
177
178
|
t):(0,u.isModelDeclaration)(e)?ur(e)?Br(e,r,(0,u.getModelMembers)(e),t):(t.push(
|
|
178
179
|
new fe(e.name,e.file)),null):(t.push(new ue(r.file)),null),"getTypeCors"),Br=p((e,r,t,o)=>{
|
|
179
|
-
let n={},s=new Set(["allowOrigins"]);for(let i of t)if(!(!(0,
|
|
180
|
+
let n={},s=new Set(["allowOrigins"]);for(let i of t)if(!(!(0,F.isModelProperty)(
|
|
180
181
|
i)||i.inherited))switch(i.name){default:o.push(new u.InvalidServicePropertyError(
|
|
181
182
|
r.name,i.name,e.file));break;case"allowOrigins":case"allowMethods":case"allowHea\
|
|
182
183
|
ders":case"exposeHeaders":n[i.name]=(0,u.getPropertyStringList)(i);break;case"al\
|
|
183
184
|
lowCredentials":n.allowCredentials=(0,u.getPropertyBoolean)(i);break;case"maxAge":
|
|
184
185
|
n.maxAge=(0,u.getPropertyNumber)(i);break}return ut(n)?n:(o.push(new ae([...s],e.
|
|
185
|
-
file)),null)},"getTypeFromMembers");var b=require("@ez4/common/library"),
|
|
186
|
-
super("Incomplete gateway cache",r,t)}},de=class extends
|
|
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{
|
|
187
188
|
p(this,"InvalidCacheTypeError")}constructor(r){super("Invalid gateway cache type",
|
|
188
|
-
void 0,"Http.Cache",r)}},Te=class extends
|
|
189
|
+
void 0,"Http.Cache",r)}},Te=class extends B.IncorrectTypeError{constructor(t,o){
|
|
189
190
|
super("Incorrect gateway cache type",t,"Http.Cache",o);this.cacheType=t}static{p(
|
|
190
|
-
this,"IncorrectCacheTypeError")}};var Le=p((e,r,t,o)=>{if(!(0,
|
|
191
|
-
e,t);return n?
|
|
192
|
-
"isValidCache"),
|
|
193
|
-
e),t):(0,b.isModelDeclaration)(e)?fr(e)?
|
|
194
|
-
new Te(e.name,e.file)),null):(t.push(new de(r.file)),null),"getTypeCache"),
|
|
195
|
-
(e,r,t,o)=>{let n={},s=new Set(["authorizerTTL"]);for(let i of t)if(!(!(0,
|
|
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)(
|
|
196
197
|
i)||i.inherited))switch(i.name){default:o.push(new b.InvalidServicePropertyError(
|
|
197
198
|
r.name,i.name,e.file));break;case"authorizerTTL":{let c=(0,b.getPropertyNumber)(
|
|
198
199
|
i);(0,$e.isAnyNumber)(c)&&(n[i.name]=c,s.delete(i.name));break}}return ft(n)?n:(o.
|
package/dist/library.mjs
CHANGED
|
@@ -1,95 +1,96 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Le=Object.defineProperty;var p=(e,t)=>Le(e,"name",{value:t,configurable:!0});import{registerTriggers as cn}from"@ez4/common/library";import{registerTriggers as ln}from"@ez4/schema/library";
|
|
2
2
|
import{createTrigger as mn}from"@ez4/project/library";import{DuplicateServiceError as $o,isExternalDeclaration as Lo,getLinkedServiceList as en,
|
|
3
3
|
getLinkedVariableList as rn,getModelMembers as tn,getPropertyString as on,InvalidServicePropertyError as nn}from"@ez4/common/library";
|
|
4
|
-
import{isModelProperty as pn}from"@ez4/reflection";var Y="@ez4/http",Tn=p(e=>e.type===Y,"isHttpService");import{IncompleteTypeError as
|
|
5
|
-
super("Incomplete service",t,r)}};import{InvalidServicePropertyError as
|
|
6
|
-
getObjectMembers as
|
|
7
|
-
import{isModelProperty as
|
|
8
|
-
getModelMembers as
|
|
9
|
-
import{isModelProperty as
|
|
10
|
-
import{isTypeCallback as $,isTypeFunction as L}from"@ez4/reflection";var
|
|
11
|
-
t]=e.split(" ",2);return
|
|
12
|
-
ce"),"isHttpService"),te=p(e=>
|
|
4
|
+
import{isModelProperty as pn}from"@ez4/reflection";var Y="@ez4/http",Tn=p(e=>e.type===Y,"isHttpService");import{IncompleteTypeError as er}from"@ez4/common/library";var d=class extends er{static{p(this,"IncompleteServiceError")}constructor(t,r){
|
|
5
|
+
super("Incomplete service",t,r)}};import{InvalidServicePropertyError as xr,isModelDeclaration as Ir,getPropertyNumber as Er,
|
|
6
|
+
getObjectMembers as vr,getModelMembers as Ar,getServiceListener as Rr,getReferenceType as Pr}from"@ez4/common/library";
|
|
7
|
+
import{isModelProperty as jr,isTypeObject as wr,isTypeReference as Or}from"@ez4/reflection";import{InvalidServicePropertyError as nr,isModelDeclaration as pr,getObjectMembers as sr,
|
|
8
|
+
getModelMembers as ir,getReferenceType as cr,getPropertyStringIn as lr}from"@ez4/common/library";
|
|
9
|
+
import{isModelProperty as mr,isTypeObject as ar,isTypeReference as ur}from"@ez4/reflection";import{hasHeritageType as a,isClassDeclaration as rr,isModelDeclaration as tr}from"@ez4/common/library";
|
|
10
|
+
import{isTypeCallback as $,isTypeFunction as L}from"@ez4/reflection";var or=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),ee=p(e=>{let[
|
|
11
|
+
t]=e.split(" ",2);return or.has(t)},"isHttpPath"),re=p(e=>rr(e)&&a(e,"Http.Servi\
|
|
12
|
+
ce"),"isHttpService"),te=p(e=>tr(e)&&a(e,"Http.Route"),"isHttpRoute");var oe=p(e=>a(e,"Http.Defaults"),"isHttpDefaults"),ne=p(e=>a(e,"Http.Preferences"),
|
|
13
13
|
"isHttpPreferences"),pe=p(e=>a(e,"Http.Headers"),"isHttpHeaders"),se=p(e=>a(e,"H\
|
|
14
14
|
ttp.Identity"),"isHttpIdentity"),ie=p(e=>a(e,"Http.QueryStrings"),"isHttpQuery"),
|
|
15
15
|
ce=p(e=>a(e,"Http.PathParameters"),"isHttpParameters"),le=p(e=>a(e,"Http.JsonBod\
|
|
16
16
|
y"),"isJsonBody"),me=p(e=>a(e,"Http.Cors"),"isHttpCors"),ae=p(e=>a(e,"Http.Cache"),
|
|
17
17
|
"isHttpCache"),ue=p(e=>$(e)||L(e),"isHttpAuthorizer"),fe=p(e=>$(e)||L(e),"isHttp\
|
|
18
|
-
Handler");import{NamingStyle as
|
|
19
|
-
o)},"getHttpPreferences"),ye=p((e,t,r)=>{if(
|
|
18
|
+
Handler");import{NamingStyle as u}from"@ez4/schema";var T=p((e,t,r,o)=>{if(!ur(e))return ye(e,t,o);let n=cr(e,r);if(n)return ye(n,t,
|
|
19
|
+
o)},"getHttpPreferences"),ye=p((e,t,r)=>{if(ar(e))return de(t,sr(e),r);if(!pr(e)){
|
|
20
20
|
r.push(new g(t.file));return}if(!ne(e)){r.push(new M(e.name,t.file));return}return de(
|
|
21
|
-
t,
|
|
22
|
-
switch(n.name){default:r.push(new
|
|
23
|
-
le":o.namingStyle=
|
|
24
|
-
return o},"getTypeFromMembers");import{InvalidServicePropertyError as
|
|
25
|
-
getReferenceType as ge}from"@ez4/common/library";import{isAnyNumber as
|
|
26
|
-
import{isModelProperty as
|
|
27
|
-
o):null},"getHttpErrors"),Te=p((e,t,r,o)=>
|
|
28
|
-
rrors"),
|
|
29
|
-
let c=parseInt(i.name,10);
|
|
30
|
-
c,t,o,n);l&&Object.assign(s,l)}return
|
|
31
|
-
let s=
|
|
32
|
-
c,o);if(!l||!
|
|
33
|
-
orClasses");var he=p((e,t,r,o)=>{if(!
|
|
34
|
-
r,o):null},"getHttpDefaults"),He=p((e,t,r,o)=>
|
|
21
|
+
t,ir(e),r)},"getTypePreferences"),de=p((e,t,r)=>{let o={};for(let n of t)if(mr(n))
|
|
22
|
+
switch(n.name){default:r.push(new nr(e.name,n.name,e.file));break;case"namingSty\
|
|
23
|
+
le":o.namingStyle=lr(n,[u.Preserve,u.CamelCase,u.PascalCase,u.SnakeCase,u.KebabCase]);
|
|
24
|
+
break}return o},"getTypeFromMembers");import{InvalidServicePropertyError as fr,getObjectMembers as yr,getPropertyTuple as dr,
|
|
25
|
+
getReferenceType as ge}from"@ez4/common/library";import{isAnyNumber as Tr,isEmptyObject as gr}from"@ez4/utils";
|
|
26
|
+
import{isModelProperty as Mr,isTypeClass as Hr,isTypeObject as br,isTypeReference as Me}from"@ez4/reflection";var H=p((e,t,r,o)=>{if(!Me(e))return Te(e,t,r,o);let n=ge(e,r);return n?Te(n,t,r,
|
|
27
|
+
o):null},"getHttpErrors"),Te=p((e,t,r,o)=>br(e)?hr(e,t,yr(e),r,o):null,"getTypeE\
|
|
28
|
+
rrors"),hr=p((e,t,r,o,n)=>{let s={};for(let i of r){if(!Mr(i)||i.inherited)continue;
|
|
29
|
+
let c=parseInt(i.name,10);Tr(c)||n.push(new fr(t.name,i.name,e.file));let l=Sr(i,
|
|
30
|
+
c,t,o,n);l&&Object.assign(s,l)}return gr(s)?null:s},"getTypeFromMembers"),Sr=p((e,t,r,o,n)=>{
|
|
31
|
+
let s=dr(e)??[],i={};for(let c of s){if(!Me(c)){n.push(new f(r.file));continue}let l=ge(
|
|
32
|
+
c,o);if(!l||!Hr(l)){n.push(new f(r.file));continue}i[l.name]=t}return i},"getErr\
|
|
33
|
+
orClasses");var he=p((e,t,r,o)=>{if(!Or(e))return He(e,t,r,o);let n=Pr(e,r);return n?He(n,t,
|
|
34
|
+
r,o):null},"getHttpDefaults"),He=p((e,t,r,o)=>wr(e)?be(t,vr(e),r,o):Ir(e)?oe(e)?
|
|
35
35
|
be(t,Ar(e),r,o):(o.push(new h(e.name,t.file)),null):(o.push(new b(t.file)),null),
|
|
36
|
-
"getTypeDefaults"),be=p((e,t,r,o)=>{let n={};for(let s of t)if(!(!
|
|
37
|
-
switch(s.name){default:o.push(new
|
|
36
|
+
"getTypeDefaults"),be=p((e,t,r,o)=>{let n={};for(let s of t)if(!(!jr(s)||s.inherited))
|
|
37
|
+
switch(s.name){default:o.push(new xr(e.name,s.name,e.file));break;case"httpError\
|
|
38
38
|
s":n.httpErrors=H(s.value,e,r,o);break;case"preferences":n.preferences=T(s.value,
|
|
39
|
-
e,r,o);break;case"memory":case"logRetention":case"timeout":n[s.name]=
|
|
40
|
-
listener":n.listener=
|
|
39
|
+
e,r,o);break;case"memory":case"logRetention":case"timeout":n[s.name]=Er(s);break;case"\
|
|
40
|
+
listener":n.listener=Rr(s.value,o);break}return n},"getTypeFromMembers");import{isModelProperty as io,isTypeObject as co,isTypeReference as lo,isTypeTuple as mo}from"@ez4/reflection";
|
|
41
41
|
import{InvalidServicePropertyError as ao,getLinkedVariableList as uo,getPropertyBoolean as fo,
|
|
42
42
|
getPropertyNumber as yo,getPropertyString as To,getObjectMembers as go,getModelMembers as Mo,
|
|
43
|
-
getServiceListener as Ho,getReferenceType as bo,getPropertyTuple as ho}from"@ez4/common/library";import{IncompleteTypeError as
|
|
44
|
-
"Incomplete gateway route",t,r)}},
|
|
45
|
-
ErrorTypeError")}constructor(t){super("Invalid route error type.",t)}};import{IncompleteTypeError as
|
|
43
|
+
getServiceListener as Ho,getReferenceType as bo,getPropertyTuple as ho}from"@ez4/common/library";import{IncompleteTypeError as zr,TypeError as Cr}from"@ez4/common/library";var S=class extends zr{static{p(this,"IncompleteRouteError")}constructor(t,r){super(
|
|
44
|
+
"Incomplete gateway route",t,r)}},f=class extends Cr{static{p(this,"InvalidRoute\
|
|
45
|
+
ErrorTypeError")}constructor(t){super("Invalid route error type.",t)}};import{IncompleteTypeError as kr}from"@ez4/common/library";var x=class extends kr{static{p(this,"IncompleteAuthorizerError")}constructor(t,r){
|
|
46
46
|
super("Incomplete route authorizer",t,r)}};import{InvalidServicePropertyError as Ht,isModelDeclaration as bt,hasHeritageType as ht,
|
|
47
47
|
getModelMembers as St,getObjectMembers as xt,getPropertyNumber as It,getReferenceType as Et}from"@ez4/common/library";
|
|
48
|
-
import{isModelProperty as
|
|
49
|
-
import{isAnyNumber as Pt}from"@ez4/utils";import{IncorrectTypeError as
|
|
50
|
-
o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},E=class extends
|
|
48
|
+
import{isModelProperty as vt,isTypeObject as At,isTypeReference as Rt}from"@ez4/reflection";
|
|
49
|
+
import{isAnyNumber as Pt}from"@ez4/utils";import{IncorrectTypeError as qr,InvalidTypeError as Dr}from"@ez4/common/library";var I=class extends Dr{constructor(r,o){super("Invalid route response",void 0,r,
|
|
50
|
+
o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},E=class extends qr{constructor(r,o,n){
|
|
51
51
|
super("Incorrect route response",r,o,n);this.responseType=r;this.baseType=o}static{
|
|
52
|
-
p(this,"IncorrectResponseTypeError")}};import{isTypeIntersection as
|
|
53
|
-
isTypeUnion as
|
|
54
|
-
import{createUnionSchema as
|
|
55
|
-
super("Invalid identity",void 0,"Http.Identity",t)}},
|
|
52
|
+
p(this,"IncorrectResponseTypeError")}};import{isTypeIntersection as Vr,isTypeObject as Qr,isTypeReference as Jr,isTypeUndefined as Gr,
|
|
53
|
+
isTypeUnion as Kr}from"@ez4/reflection";import{getReferenceType as Yr,isModelDeclaration as Wr}from"@ez4/common/library";
|
|
54
|
+
import{createUnionSchema as Xr}from"@ez4/schema/library";import{IncorrectTypeError as Fr,InvalidTypeError as Br}from"@ez4/common/library";var v=class extends Br{static{p(this,"InvalidIdentityTypeError")}constructor(t){
|
|
55
|
+
super("Invalid identity",void 0,"Http.Identity",t)}},A=class extends Fr{constructor(r,o){
|
|
56
56
|
super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}static{p(this,
|
|
57
|
-
"IncorrectIdentityTypeError")}};import{getObjectSchema as
|
|
58
|
-
r);return n?Se(n,t,r,o):null},"getHttpIdentity"),Se=p((e,t,r,o)=>{if(
|
|
59
|
-
e.elements,t,r,o);if(
|
|
60
|
-
file)),null;if(!se(e))return o.push(new
|
|
61
|
-
(n.definitions={...n.definitions,extensible:!0}),n},"getTypeIdentity"),
|
|
62
|
-
let n=[];for(let s of e){let i=
|
|
63
|
-
n[0]},"getIdentityFromUnion");import{isTypeIntersection as
|
|
64
|
-
import{getReferenceType as
|
|
65
|
-
"Invalid headers",void 0,"Http.Headers",t)}},P=class extends
|
|
57
|
+
"IncorrectIdentityTypeError")}};import{getObjectSchema as Ur,isObjectSchema as Nr}from"@ez4/schema/library";var m=p((e,t)=>{let r=Ur(e,t);return r&&Nr(r)?r:null},"getSchemaFromType");var y=p((e,t,r,o)=>{if(Gr(e))return null;if(!Jr(e))return Se(e,t,r,o);let n=Yr(e,
|
|
58
|
+
r);return n?Se(n,t,r,o):null},"getHttpIdentity"),Se=p((e,t,r,o)=>{if(Kr(e))return Zr(
|
|
59
|
+
e.elements,t,r,o);if(Qr(e)||Vr(e))return m(e,r);if(!Wr(e))return o.push(new v(t.
|
|
60
|
+
file)),null;if(!se(e))return o.push(new A(e.name,t.file)),null;let n=m(e,r);return n&&
|
|
61
|
+
(n.definitions={...n.definitions,extensible:!0}),n},"getTypeIdentity"),Zr=p((e,t,r,o)=>{
|
|
62
|
+
let n=[];for(let s of e){let i=y(s,t,r,o);i&&n.push(i)}return n.length>1?Xr({elements:n}):
|
|
63
|
+
n[0]},"getIdentityFromUnion");import{isTypeIntersection as Lr,isTypeObject as et,isTypeReference as rt}from"@ez4/reflection";
|
|
64
|
+
import{getReferenceType as tt,isModelDeclaration as ot}from"@ez4/common/library";import{IncorrectTypeError as _r,InvalidTypeError as $r}from"@ez4/common/library";var R=class extends $r{static{p(this,"InvalidHeadersTypeError")}constructor(t){super(
|
|
65
|
+
"Invalid headers",void 0,"Http.Headers",t)}},P=class extends _r{constructor(r,o){
|
|
66
66
|
super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}static{p(this,"\
|
|
67
|
-
IncorrectHeadersTypeError")}};var j=p((e,t,r,o)=>{if(!
|
|
68
|
-
o):null},"getHttpHeaders"),xe=p((e,t,r,o)=>
|
|
69
|
-
(o.push(new P(e.name,t.file)),null):(o.push(new R(t.file)),null),"getTypeHeaders");import{createUnionSchema as
|
|
70
|
-
import{getReferenceType as
|
|
71
|
-
import{isTypeArray as
|
|
72
|
-
isTypeScalar as
|
|
73
|
-
"Invalid body",void 0,"Http.JsonBody",t)}},O=class extends
|
|
67
|
+
IncorrectHeadersTypeError")}};var j=p((e,t,r,o)=>{if(!rt(e))return xe(e,t,r,o);let n=tt(e,r);return n?xe(n,t,r,
|
|
68
|
+
o):null},"getHttpHeaders"),xe=p((e,t,r,o)=>et(e)||Lr(e)?m(e,r):ot(e)?pe(e)?m(e,r):
|
|
69
|
+
(o.push(new P(e.name,t.file)),null):(o.push(new R(t.file)),null),"getTypeHeaders");import{createUnionSchema as st,getScalarSchema as it,createArraySchema as ct}from"@ez4/schema/library";
|
|
70
|
+
import{getReferenceType as lt,isModelDeclaration as mt}from"@ez4/common/library";
|
|
71
|
+
import{isTypeArray as at,isTypeIntersection as ut,isTypeObject as ft,isTypeReference as yt,
|
|
72
|
+
isTypeScalar as dt,isTypeUndefined as Ie,isTypeUnion as Tt}from"@ez4/reflection";import{IncorrectTypeError as nt,InvalidTypeError as pt}from"@ez4/common/library";var w=class extends pt{static{p(this,"InvalidBodyTypeError")}constructor(t){super(
|
|
73
|
+
"Invalid body",void 0,"Http.JsonBody",t)}},O=class extends nt{constructor(r,o){super(
|
|
74
74
|
"Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}static{p(this,"IncorrectBo\
|
|
75
|
-
dyTypeError")}};var z=p((e,t,r,o)=>Z(e,r,n=>W(n)??X(n,t,r,o)),"getHttpBody"),Z=p((e,t,r)=>{if(
|
|
76
|
-
e))return null;if(!
|
|
77
|
-
ody"),W=p(e=>
|
|
78
|
-
r,n=>W(n)??X(n,t,r,o)):
|
|
79
|
-
e,r):
|
|
80
|
-
null),"getCompoundTypeBody"),gt=p((e,t,r)=>{let o=[];for(let n of e){
|
|
81
|
-
r);s&&o.push(s)}return o.
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
e
|
|
89
|
-
|
|
75
|
+
dyTypeError")}};var z=p((e,t,r,o)=>Z(e,r,n=>W(n)??X(n,t,r,o)),"getHttpBody"),Z=p((e,t,r)=>{if(Ie(
|
|
76
|
+
e))return null;if(!yt(e))return r(e);let o=lt(e,t);return o?r(o):null},"getTypeB\
|
|
77
|
+
ody"),W=p(e=>dt(e)?it(e):null,"getScalarTypeBody"),X=p((e,t,r,o)=>Tt(e)?gt(e.elements,
|
|
78
|
+
r,n=>W(n)??X(n,t,r,o)):at(e)?Mt(e.element,r,n=>W(n)??X(n,t,r,o)):ft(e)||ut(e)?m(
|
|
79
|
+
e,r):mt(e)?le(e)?m(e,r):(o.push(new O(e.name,e.file)),null):(o.push(new w(t.file)),
|
|
80
|
+
null),"getCompoundTypeBody"),gt=p((e,t,r)=>{let o={optional:!1,elements:[]};for(let n of e){
|
|
81
|
+
if(Ie(n)){o.optional=!0;continue}let s=Z(n,t,r);s&&o.elements.push(s)}return o.elements.
|
|
82
|
+
length?st(o):null},"getUnionTypeBody"),Mt=p((e,t,r)=>{let o=Z(e,t,r);return o?ct(
|
|
83
|
+
{element:o}):null},"getArrayTypeBody");var Ae=p((e,t,r,o)=>{let n=Pe(e,t,r,o,"Http.AuthResponse");return n&&jt(n)?n:null},
|
|
84
|
+
"getHttpAuthResponse"),Re=p((e,t,r,o)=>{let n=Pe(e,t,r,o,"Http.Response");return n&&
|
|
85
|
+
wt(n)?n:null},"getHttpHandlerResponse"),Pe=p((e,t,r,o,n)=>{if(!Rt(e))return Ee(e,
|
|
86
|
+
t,r,o,n);let s=Et(e,r);return s?Ee(s,t,r,o,n):null},"getHttpResponse"),jt=p(e=>!!e.
|
|
87
|
+
identity,"isValidAuthResponse"),wt=p(e=>Pt(e.status),"isValidHandlerResponse"),Ee=p(
|
|
88
|
+
(e,t,r,o,n)=>At(e)?ve(e,t,xt(e),r,o):bt(e)?ht(e,n)?ve(e,t,St(e),r,o):(o.push(new E(
|
|
89
|
+
e.name,n,e.file)),null):(o.push(new I(n,t.file)),null),"getTypeResponse"),ve=p((e,t,r,o,n)=>{
|
|
90
|
+
let s={};for(let i of r)if(!(!vt(i)||i.inherited))switch(i.name){default:n.push(
|
|
90
91
|
new Ht(t.name,i.name,e.file));break;case"status":s.status=It(i);break;case"heade\
|
|
91
92
|
rs":{s.headers=j(i.value,e,o,n),s.headers&&i.description&&(s.headers.description=
|
|
92
|
-
i.description);break}case"identity":{s.identity=
|
|
93
|
+
i.description);break}case"identity":{s.identity=y(i.value,e,o,n),s.identity&&i.description&&
|
|
93
94
|
(s.identity.description=i.description);break}case"body":{s.body=z(i.value,e,o,n),
|
|
94
95
|
s.body&&i.description&&(s.body.description=i.description);break}}return s},"getT\
|
|
95
96
|
ypeFromMembers");import{isModelProperty as Wt,isTypeIntersection as Xt,isTypeObject as Zt,isTypeReference as _t}from"@ez4/reflection";
|
|
@@ -98,113 +99,113 @@ getObjectMembers as ro,getModelMembers as to,getReferenceType as oo}from"@ez4/co
|
|
|
98
99
|
this.baseType=r}static{p(this,"InvalidRequestTypeError")}},k=class extends Ot{constructor(r,o,n){
|
|
99
100
|
super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}static{
|
|
100
101
|
p(this,"IncorrectRequestTypeError")}};import{isTypeIntersection as qt,isTypeObject as Dt,isTypeReference as Ft}from"@ez4/reflection";
|
|
101
|
-
import{getReferenceType as Bt,isModelDeclaration as
|
|
102
|
+
import{getReferenceType as Bt,isModelDeclaration as Ut}from"@ez4/common/library";import{IncorrectTypeError as Ct,InvalidTypeError as kt}from"@ez4/common/library";var q=class extends kt{static{p(this,"InvalidParameterTypeError")}constructor(t){
|
|
102
103
|
super("Invalid request parameters",void 0,"Http.PathParameters",t)}},D=class extends Ct{constructor(r,o){
|
|
103
104
|
super("Incorrect request parameters",r,"Http.PathParameters",o);this.parametersType=
|
|
104
|
-
r}static{p(this,"IncorrectParameterTypeError")}};var
|
|
105
|
-
r,o):null},"getHttpParameters"),
|
|
105
|
+
r}static{p(this,"IncorrectParameterTypeError")}};var we=p((e,t,r,o)=>{if(!Ft(e))return je(e,t,r,o);let n=Bt(e,r);return n?je(n,t,
|
|
106
|
+
r,o):null},"getHttpParameters"),je=p((e,t,r,o)=>Dt(e)||qt(e)?m(e,r):Ut(e)?ce(e)?
|
|
106
107
|
m(e,r):(o.push(new D(e.name,e.file)),null):(o.push(new q(t.file)),null),"getType\
|
|
107
108
|
Parameter");import{isTypeIntersection as Qt,isTypeObject as Jt,isTypeReference as Gt}from"@ez4/reflection";
|
|
108
|
-
import{getReferenceType as Kt,isModelDeclaration as Yt}from"@ez4/common/library";import{IncorrectTypeError as
|
|
109
|
-
"Invalid request query strings",void 0,"Http.QueryStrings",t)}},B=class extends
|
|
109
|
+
import{getReferenceType as Kt,isModelDeclaration as Yt}from"@ez4/common/library";import{IncorrectTypeError as Nt,InvalidTypeError as Vt}from"@ez4/common/library";var F=class extends Vt{static{p(this,"InvalidQueryTypeError")}constructor(t){super(
|
|
110
|
+
"Invalid request query strings",void 0,"Http.QueryStrings",t)}},B=class extends Nt{constructor(r,o){
|
|
110
111
|
super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
|
|
111
|
-
r}static{p(this,"IncorrectQueryTypeError")}};var
|
|
112
|
-
r,o):null},"getHttpQuery"),
|
|
113
|
-
(o.push(new B(e.name,t.file)),null):(o.push(new F(t.file)),null),"getTypeQuery");var
|
|
112
|
+
r}static{p(this,"IncorrectQueryTypeError")}};var ze=p((e,t,r,o)=>{if(!Gt(e))return Oe(e,t,r,o);let n=Kt(e,r);return n?Oe(n,t,
|
|
113
|
+
r,o):null},"getHttpQuery"),Oe=p((e,t,r,o)=>Jt(e)||Qt(e)?m(e,r):Yt(e)?ie(e)?m(e,r):
|
|
114
|
+
(o.push(new B(e.name,t.file)),null):(o.push(new F(t.file)),null),"getTypeQuery");var qe=p((e,t,r,o)=>_(e,t,r,o,"Http.AuthRequest"),"getHttpAuthRequest"),De=p((e,t,r,o)=>_(
|
|
114
115
|
e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),_=p((e,t,r,o,n)=>{if(Xt(e)&&e.elements.
|
|
115
|
-
length>0)return _(e.elements[0],t,r,o,n);if(!_t(e))return
|
|
116
|
-
e,r);return s?
|
|
117
|
-
t,ro(e),r,o):Lt(e)?eo(e,n)?
|
|
118
|
-
(o.push(new C(n,t.file)),null),"getTypeRequest"),
|
|
116
|
+
length>0)return _(e.elements[0],t,r,o,n);if(!_t(e))return Ce(e,t,r,o,n);let s=oo(
|
|
117
|
+
e,r);return s?Ce(s,t,r,o,n):null},"getHttpRequest"),Ce=p((e,t,r,o,n)=>Zt(e)?ke(e,
|
|
118
|
+
t,ro(e),r,o):Lt(e)?eo(e,n)?ke(e,t,to(e),r,o):(o.push(new k(e.name,n,e.file)),null):
|
|
119
|
+
(o.push(new C(n,t.file)),null),"getTypeRequest"),ke=p((e,t,r,o,n)=>{let s={};for(let i of r)
|
|
119
120
|
if(!(!Wt(i)||i.inherited))switch(i.name){default:n.push(new $t(t.name,i.name,e.file));
|
|
120
121
|
break;case"headers":{s.headers=j(i.value,e,o,n),s.headers&&i.description&&(s.headers.
|
|
121
|
-
description=i.description);break}case"identity":{s.identity=
|
|
122
|
+
description=i.description);break}case"identity":{s.identity=y(i.value,e,o,n),s.identity&&
|
|
122
123
|
i.description&&(s.identity.description=i.description);break}case"query":{s.query=
|
|
123
|
-
|
|
124
|
-
parameters":{s.parameters=
|
|
124
|
+
ze(i.value,e,o,n),s.query&&i.description&&(s.query.description=i.description);break}case"\
|
|
125
|
+
parameters":{s.parameters=we(i.value,e,o,n),s.parameters&&i.description&&(s.parameters.
|
|
125
126
|
description=i.description);break}case"body":{s.body=z(i.value,e,o,n),s.body&&i.description&&
|
|
126
|
-
(s.body.description=i.description);break}}return s},"getTypeFromMembers");var
|
|
127
|
+
(s.body.description=i.description);break}}return s},"getTypeFromMembers");var Fe=p((e,t,r,o)=>{if(!ue(e))return null;let{description:n,module:s}=e,i={...n&&
|
|
127
128
|
{description:n},...s&&{module:s}},c=new Set(["name","file"]);if((i.name=e.name)&&
|
|
128
129
|
c.delete("name"),(i.file=e.file)&&c.delete("file"),e.parameters){let[{value:l}]=e.
|
|
129
|
-
parameters;i.request=
|
|
130
|
+
parameters;i.request=qe(l,t,r,o)}return e.return&&(i.response=Ae(e.return,t,r,o)),
|
|
130
131
|
no(i)?i:(o.push(new x([...c],e.file)),null)},"getHttpAuthorizer"),no=p(e=>!!e.name&&
|
|
131
|
-
!!e.file,"isValidAuthorizer");import{IncompleteTypeError as po}from"@ez4/common/library";var
|
|
132
|
-
super("Incomplete route handler",t,r)}};var
|
|
132
|
+
!!e.file,"isValidAuthorizer");import{IncompleteTypeError as po}from"@ez4/common/library";var U=class extends po{static{p(this,"IncompleteHandlerError")}constructor(t,r){
|
|
133
|
+
super("Incomplete route handler",t,r)}};var Be=p((e,t,r,o)=>{if(!fe(e))return null;let{description:n,module:s}=e,i={...n&&
|
|
133
134
|
{description:n},...s&&{module:s}},c=new Set(["name","file","response"]);if((i.name=
|
|
134
135
|
e.name)&&c.delete("name"),(i.file=e.file)&&c.delete("file"),e.parameters){let[{value:l}]=e.
|
|
135
|
-
parameters;i.request=
|
|
136
|
-
l,c.delete("response"))}return so(i)?i:(o.push(new
|
|
137
|
-
HttpHandler"),so=p(e=>!!e.name&&!!e.file&&!!e.response,"isValidHandler");var
|
|
136
|
+
parameters;i.request=De(l,t,r,o)}if(e.return){let l=Re(e.return,t,r,o);l&&(i.response=
|
|
137
|
+
l,c.delete("response"))}return so(i)?i:(o.push(new U([...c],e.file)),null)},"get\
|
|
138
|
+
HttpHandler"),so=p(e=>!!e.name&&!!e.file&&!!e.response,"isValidHandler");var Ve=p((e,t,r,o)=>{let n=ho(t)??[];return Qe(n,e,r,o)},"getHttpRoutes"),Qe=p((e,t,r,o)=>{
|
|
138
139
|
let n=[];for(let s of e){let i=So(s,t,r,o);Array.isArray(i)?n.push(...i):i&&n.push(
|
|
139
|
-
i)}return n},"getRouteFromTuple"),So=p((e,t,r,o)=>{if(!lo(e))return
|
|
140
|
-
let n=bo(e,r);return n?
|
|
141
|
-
handler,"isValidRoute"),
|
|
142
|
-
e),r,o):mo(e)&&e.spread?
|
|
140
|
+
i)}return n},"getRouteFromTuple"),So=p((e,t,r,o)=>{if(!lo(e))return Ue(e,t,r,o);
|
|
141
|
+
let n=bo(e,r);return n?Ue(n,t,r,o):null},"getTypeFromRoute"),xo=p(e=>!!e.path&&!!e.
|
|
142
|
+
handler,"isValidRoute"),Ue=p((e,t,r,o)=>te(e)?Ne(e,t,Mo(e),r,o):co(e)?Ne(e,t,go(
|
|
143
|
+
e),r,o):mo(e)&&e.spread?Qe(e.elements,t,r,o):null,"getRouteType"),Ne=p((e,t,r,o,n)=>{
|
|
143
144
|
let s={},i=new Set(["path","handler"]);for(let c of r)if(!(!io(c)||c.inherited))
|
|
144
145
|
switch(c.name){default:n.push(new ao(t.name,c.name,e.file));break;case"path":{let l=To(
|
|
145
|
-
c);l&&ee(l)&&(i.delete(c.name),s.path=l);break}case"handler":(s.handler=
|
|
146
|
-
t,o,n))&&i.delete(c.name);break;case"authorizer":s.authorizer=
|
|
146
|
+
c);l&&ee(l)&&(i.delete(c.name),s.path=l);break}case"handler":(s.handler=Be(c.value,
|
|
147
|
+
t,o,n))&&i.delete(c.name);break;case"authorizer":s.authorizer=Fe(c.value,t,o,n);
|
|
147
148
|
break;case"httpErrors":s.httpErrors=H(c.value,t,o,n);break;case"preferences":s.preferences=
|
|
148
149
|
T(c.value,t,o,n);break;case"memory":case"logRetention":case"timeout":s[c.name]=yo(
|
|
149
150
|
c);break;case"cors":s.cors=fo(c);break;case"listener":s.listener=Ho(c.value,n);break;case"\
|
|
150
151
|
variables":s.variables=uo(c,n);break}return xo(s)?s:(n.push(new S([...i],e.file)),
|
|
151
|
-
null)},"getTypeFromMembers");import{InvalidServicePropertyError as
|
|
152
|
+
null)},"getTypeFromMembers");import{InvalidServicePropertyError as Ao,isModelDeclaration as Ro,getModelMembers as Po,
|
|
152
153
|
getObjectMembers as jo,getPropertyBoolean as wo,getPropertyStringList as Oo,getPropertyNumber as zo,
|
|
153
154
|
getReferenceType as Co}from"@ez4/common/library";import{isModelProperty as ko,isTypeObject as qo,
|
|
154
|
-
isTypeReference as Do}from"@ez4/reflection";import{IncompleteTypeError as Io,IncorrectTypeError as Eo,InvalidTypeError as
|
|
155
|
-
"Incomplete HTTP CORS",t,r)}},V=class extends
|
|
155
|
+
isTypeReference as Do}from"@ez4/reflection";import{IncompleteTypeError as Io,IncorrectTypeError as Eo,InvalidTypeError as vo}from"@ez4/common/library";var N=class extends Io{static{p(this,"IncompleteCorsError")}constructor(t,r){super(
|
|
156
|
+
"Incomplete HTTP CORS",t,r)}},V=class extends vo{static{p(this,"InvalidCorsTypeE\
|
|
156
157
|
rror")}constructor(t){super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},Q=class extends Eo{constructor(r,o){
|
|
157
158
|
super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}static{p(this,
|
|
158
|
-
"IncorrectCorsTypeError")}};var
|
|
159
|
-
null},"getHttpCors"),Fo=p(e=>!!e.allowOrigins?.length,"isValidCors"),
|
|
160
|
-
e)?
|
|
161
|
-
(r.push(new V(t.file)),null),"getTypeCors"),
|
|
159
|
+
"IncorrectCorsTypeError")}};var Ke=p((e,t,r,o)=>{if(!Do(e))return Je(e,t,o);let n=Co(e,r);return n?Je(n,t,o):
|
|
160
|
+
null},"getHttpCors"),Fo=p(e=>!!e.allowOrigins?.length,"isValidCors"),Je=p((e,t,r)=>qo(
|
|
161
|
+
e)?Ge(e,t,jo(e),r):Ro(e)?me(e)?Ge(e,t,Po(e),r):(r.push(new Q(e.name,e.file)),null):
|
|
162
|
+
(r.push(new V(t.file)),null),"getTypeCors"),Ge=p((e,t,r,o)=>{let n={},s=new Set(
|
|
162
163
|
["allowOrigins"]);for(let i of r)if(!(!ko(i)||i.inherited))switch(i.name){default:
|
|
163
|
-
o.push(new
|
|
164
|
+
o.push(new Ao(t.name,i.name,e.file));break;case"allowOrigins":case"allowMethods":case"\
|
|
164
165
|
allowHeaders":case"exposeHeaders":n[i.name]=Oo(i);break;case"allowCredentials":n.
|
|
165
166
|
allowCredentials=wo(i);break;case"maxAge":n.maxAge=zo(i);break}return Fo(n)?n:(o.
|
|
166
|
-
push(new
|
|
167
|
+
push(new N([...s],e.file)),null)},"getTypeFromMembers");import{InvalidServicePropertyError as Vo,isModelDeclaration as Qo,getModelMembers as Jo,
|
|
167
168
|
getObjectMembers as Go,getPropertyNumber as Ko,getReferenceType as Yo}from"@ez4/common/library";
|
|
168
169
|
import{isModelProperty as Wo,isTypeObject as Xo,isTypeReference as Zo}from"@ez4/reflection";
|
|
169
|
-
import{isAnyNumber as
|
|
170
|
-
"Incomplete gateway cache",t,r)}},G=class extends
|
|
170
|
+
import{isAnyNumber as Xe}from"@ez4/utils";import{IncompleteTypeError as Bo,IncorrectTypeError as Uo,InvalidTypeError as No}from"@ez4/common/library";var J=class extends Bo{static{p(this,"IncompleteCacheError")}constructor(t,r){super(
|
|
171
|
+
"Incomplete gateway cache",t,r)}},G=class extends No{static{p(this,"InvalidCache\
|
|
171
172
|
TypeError")}constructor(t){super("Invalid gateway cache type",void 0,"Http.Cache",
|
|
172
|
-
t)}},K=class extends
|
|
173
|
-
"Http.Cache",o);this.cacheType=r}static{p(this,"IncorrectCacheTypeError")}};var
|
|
174
|
-
null},"getHttpCache"),_o=p(e=>
|
|
175
|
-
e)?
|
|
176
|
-
(r.push(new G(t.file)),null),"getTypeCache"),
|
|
173
|
+
t)}},K=class extends Uo{constructor(r,o){super("Incorrect gateway cache type",r,
|
|
174
|
+
"Http.Cache",o);this.cacheType=r}static{p(this,"IncorrectCacheTypeError")}};var Ze=p((e,t,r,o)=>{if(!Zo(e))return Ye(e,t,o);let n=Yo(e,r);return n?Ye(n,t,o):
|
|
175
|
+
null},"getHttpCache"),_o=p(e=>Xe(e.authorizerTTL),"isValidCache"),Ye=p((e,t,r)=>Xo(
|
|
176
|
+
e)?We(e,t,Go(e),r):Qo(e)?ae(e)?We(e,t,Jo(e),r):(r.push(new K(e.name,e.file)),null):
|
|
177
|
+
(r.push(new G(t.file)),null),"getTypeCache"),We=p((e,t,r,o)=>{let n={},s=new Set(
|
|
177
178
|
["authorizerTTL"]);for(let i of r)if(!(!Wo(i)||i.inherited))switch(i.name){default:
|
|
178
|
-
o.push(new Vo(t.name,i.name,e.file));break;case"authorizerTTL":{let c=Ko(i);
|
|
179
|
+
o.push(new Vo(t.name,i.name,e.file));break;case"authorizerTTL":{let c=Ko(i);Xe(c)&&
|
|
179
180
|
(n[i.name]=c,s.delete(i.name));break}}return _o(n)?n:(o.push(new J([...s],e.file)),
|
|
180
|
-
null)},"getTypeFromMembers");var
|
|
181
|
+
null)},"getTypeFromMembers");var _e=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!re(n)||Lo(n))continue;
|
|
181
182
|
let s={type:Y,extras:{}},i=new Set(["routes"]),c=n.file;s.name=n.name,n.description&&
|
|
182
183
|
(s.description=n.description);for(let l of tn(n))if(!(!pn(l)||l.inherited))switch(l.
|
|
183
|
-
name){default:r.push(new nn(s.name,l.name,c));break;case"routes":(s.routes=
|
|
184
|
+
name){default:r.push(new nn(s.name,l.name,c));break;case"routes":(s.routes=Ve(n,
|
|
184
185
|
l,e,r))&&i.delete(l.name);break;case"name":s.displayName=on(l);break;case"defaul\
|
|
185
|
-
ts":s.defaults=he(l.value,n,e,r);break;case"cache":s.cache=
|
|
186
|
-
cors":s.cors=
|
|
187
|
-
services":s.services=en(l,e,r);break}if(!sn(s)){r.push(new
|
|
186
|
+
ts":s.defaults=he(l.value,n,e,r);break;case"cache":s.cache=Ze(l.value,n,e,r);break;case"\
|
|
187
|
+
cors":s.cors=Ke(l.value,n,e,r);break;case"variables":s.variables=rn(l,r);break;case"\
|
|
188
|
+
services":s.services=en(l,e,r);break}if(!sn(s)){r.push(new d([...i],c));continue}
|
|
188
189
|
if(t[n.name]){r.push(new $o(n.name,c));continue}t[n.name]=s}return{services:t,errors:r}},
|
|
189
|
-
"getHttpServices"),sn=p(e=>!!e.name&&!!e.routes&&!!e.extras,"isValidService");var
|
|
190
|
-
|
|
190
|
+
"getHttpServices"),sn=p(e=>!!e.name&&!!e.routes&&!!e.extras,"isValidService");var $e=!1,ji=p(()=>{$e||(cn(),ln(),mn("@ez4/gateway",{"metadata:getServices":_e}),
|
|
191
|
+
$e=!0)},"registerTriggers");import{IncorrectTypeError as an,InvalidTypeError as un}from"@ez4/common/library";var b=class extends un{static{p(this,"InvalidDefaultsTypeError")}constructor(t){
|
|
191
192
|
super("Invalid defaults",void 0,"Http.Defaults",t)}},h=class extends an{constructor(r,o){
|
|
192
193
|
super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}static{p(this,
|
|
193
194
|
"IncorrectDefaultsTypeError")}};import{IncorrectTypeError as fn,InvalidTypeError as yn}from"@ez4/common/library";var g=class extends yn{static{p(this,"InvalidPreferencesTypeError")}constructor(t){
|
|
194
195
|
super("Invalid preferences",void 0,"Http.Preferences",t)}},M=class extends fn{constructor(r,o){
|
|
195
196
|
super("Incorrect preferences",r,"Http.Preferences",o);this.preferencesType=r}static{
|
|
196
|
-
p(this,"IncorrectPreferencesTypeError")}};export{x as IncompleteAuthorizerError,J as IncompleteCacheError,
|
|
197
|
-
|
|
197
|
+
p(this,"IncorrectPreferencesTypeError")}};export{x as IncompleteAuthorizerError,J as IncompleteCacheError,N as IncompleteCorsError,
|
|
198
|
+
U as IncompleteHandlerError,S as IncompleteRouteError,d as IncompleteServiceError,
|
|
198
199
|
O as IncorrectBodyTypeError,K as IncorrectCacheTypeError,Q as IncorrectCorsTypeError,
|
|
199
|
-
h as IncorrectDefaultsTypeError,P as IncorrectHeadersTypeError,
|
|
200
|
+
h as IncorrectDefaultsTypeError,P as IncorrectHeadersTypeError,A as IncorrectIdentityTypeError,
|
|
200
201
|
D as IncorrectParameterTypeError,M as IncorrectPreferencesTypeError,B as IncorrectQueryTypeError,
|
|
201
202
|
k as IncorrectRequestTypeError,E as IncorrectResponseTypeError,w as InvalidBodyTypeError,
|
|
202
203
|
G as InvalidCacheTypeError,V as InvalidCorsTypeError,b as InvalidDefaultsTypeError,
|
|
203
|
-
R as InvalidHeadersTypeError,
|
|
204
|
+
R as InvalidHeadersTypeError,v as InvalidIdentityTypeError,q as InvalidParameterTypeError,
|
|
204
205
|
g as InvalidPreferencesTypeError,F as InvalidQueryTypeError,C as InvalidRequestTypeError,
|
|
205
|
-
I as InvalidResponseTypeError,
|
|
206
|
-
Ae as getHttpAuthResponse,
|
|
207
|
-
|
|
208
|
-
j as getHttpHeaders,
|
|
209
|
-
|
|
206
|
+
I as InvalidResponseTypeError,f as InvalidRouteErrorTypeError,Y as ServiceType,qe as getHttpAuthRequest,
|
|
207
|
+
Ae as getHttpAuthResponse,Fe as getHttpAuthorizer,z as getHttpBody,Ze as getHttpCache,
|
|
208
|
+
Ke as getHttpCors,Be as getHttpHandler,De as getHttpHandlerRequest,Re as getHttpHandlerResponse,
|
|
209
|
+
j as getHttpHeaders,y as getHttpIdentity,we as getHttpParameters,ze as getHttpQuery,
|
|
210
|
+
Ve as getHttpRoutes,_e as getHttpServices,Tn as isHttpService,ji as registerTriggers};
|
|
210
211
|
//# sourceMappingURL=library.mjs.map
|
package/dist/utils/body.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { AnySchema } from '@ez4/schema';
|
|
2
2
|
import type { Http } from '../services/contract.js';
|
|
3
|
-
export declare const getRequestBody: <T extends Http.JsonBody | Http.RawBody>(input: T, schema: AnySchema, preferences?: Http.Preferences | null) => Promise<T>;
|
|
3
|
+
export declare const getRequestBody: <T extends Http.JsonBody | Http.RawBody>(input: T | undefined, schema: AnySchema, preferences?: Http.Preferences | null) => Promise<T>;
|
|
4
4
|
export declare const getResponseBody: (body: unknown, schema: AnySchema, preferences?: Http.Preferences) => unknown;
|
package/dist/utils.cjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var n=(e,t)=>d(e,"name",{value:t,configurable:!0});var b=(e,t)=>{for(var r in t)d(e,r,{get:t[r],enumerable:!0})},z=(e,t,r,o)=>{if(t&&
|
|
2
2
|
typeof t=="object"||typeof t=="function")for(let a of C(t))!P.call(e,a)&&a!==r&&
|
|
3
3
|
d(e,a,{get:()=>t[a],enumerable:!(o=q(t,a))||o.enumerable});return e};var M=e=>z(d({},"__esModule",{value:!0}),e);var A={};b(A,{getHeaders:()=>O,getIdentity:()=>R,getJsonError:()=>$,getPathParameters:()=>j,
|
|
4
4
|
getQueryStrings:()=>B,getRequestBody:()=>U,getResponseBody:()=>V});module.exports=
|
|
5
|
-
M(A);var l=require("@ez4/transform"),
|
|
6
|
-
o=await(0,
|
|
7
|
-
length){let a=(0,
|
|
8
|
-
alformed path parameters.",a)}return r},"getPathParameters");var g=require("@ez4/transform"),m=require("@ez4/validator"),w=require("@ez4/gateway");var B=
|
|
5
|
+
M(A);var l=require("@ez4/transform"),s=require("@ez4/validator"),H=require("@ez4/gateway");var j=n(async(e,t)=>{let r=(0,l.transform)(e,t,(0,l.createTransformContext)({convert:!1})),
|
|
6
|
+
o=await(0,s.validate)(r,t,(0,s.createValidatorContext)({property:"$path"}));if(o.
|
|
7
|
+
length){let a=(0,s.getUniqueErrorMessages)(o);throw new H.HttpBadRequestError("M\
|
|
8
|
+
alformed path parameters.",a)}return r},"getPathParameters");var g=require("@ez4/transform"),m=require("@ez4/validator"),w=require("@ez4/gateway");var B=n(async(e,t,r)=>{let o=r?.namingStyle,a=(0,g.createTransformContext)({convert:!0,
|
|
9
9
|
inputStyle:o}),y=(0,g.transform)(e,t,a),x=(0,m.createValidatorContext)({property:"\
|
|
10
10
|
$query"}),u=await(0,m.validate)(y,t,x);if(u.length){let T=(0,m.getUniqueErrorMessages)(
|
|
11
11
|
u);throw new w.HttpBadRequestError("Malformed query strings.",T)}return y},"getQ\
|
|
12
|
-
ueryStrings");var h=require("@ez4/transform"),p=require("@ez4/validator"),S=require("@ez4/gateway");var O=
|
|
12
|
+
ueryStrings");var h=require("@ez4/transform"),p=require("@ez4/validator"),S=require("@ez4/gateway");var O=n(async(e,t)=>{let r=(0,h.transform)(e,t,(0,h.createTransformContext)({convert:!1})),
|
|
13
13
|
o=await(0,p.validate)(r,t,(0,p.createValidatorContext)({property:"$header"}));if(o.
|
|
14
14
|
length){let a=(0,p.getUniqueErrorMessages)(o);throw new S.HttpBadRequestError("M\
|
|
15
|
-
alformed request headers.",a)}return r},"getHeaders");var i=require("@ez4/validator"),v=require("@ez4/gateway");var R=
|
|
15
|
+
alformed request headers.",a)}return r},"getHeaders");var i=require("@ez4/validator"),v=require("@ez4/gateway");var R=n(async(e,t)=>{let r=await(0,i.validate)(e,t,(0,i.createValidatorContext)(
|
|
16
16
|
{property:"$identity"}));if(r.length){let o=(0,i.getUniqueErrorMessages)(r);throw new v.HttpBadRequestError(
|
|
17
|
-
"Malformed authorizer identity.",o)}return e},"getIdentity");var c=require("@ez4/transform"),f=require("@ez4/validator"),E=require("@ez4/gateway");var U=
|
|
17
|
+
"Malformed authorizer identity.",o)}return e},"getIdentity");var c=require("@ez4/transform"),f=require("@ez4/validator"),E=require("@ez4/gateway");var U=n(async(e,t,r)=>{let o=r?.namingStyle,a=(0,f.createValidatorContext)({property:"\
|
|
18
18
|
$body",inputStyle:o}),y=await(0,f.validate)(e,t,a);if(y.length){let T=(0,f.getUniqueErrorMessages)(
|
|
19
19
|
y);throw new E.HttpBadRequestError("Malformed body payload.",T)}let x=(0,c.createTransformContext)(
|
|
20
|
-
{convert:!1,inputStyle:o});return(0,c.transform)(e,t,x)},"getRequestBody"),V=
|
|
20
|
+
{convert:!1,inputStyle:o});return(0,c.transform)(e,t,x)},"getRequestBody"),V=n((e,t,r)=>{
|
|
21
21
|
let o=r?.namingStyle,a=(0,c.createTransformContext)({convert:!1,outputStyle:o});
|
|
22
|
-
return(0,c.transform)(e,t,a)},"getResponseBody");var $=
|
|
22
|
+
return(0,c.transform)(e,t,a)},"getResponseBody");var $=n(({status:e,message:t,details:r})=>({status:e,body:{message:t,details:r}}),
|
|
23
23
|
"getJsonError");0&&(module.exports={getHeaders,getIdentity,getJsonError,getPathParameters,getQueryStrings,
|
|
24
24
|
getRequestBody,getResponseBody});
|
|
25
25
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.mjs
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
var y=Object.defineProperty;var a=(e,t)=>y(e,"name",{value:t,configurable:!0});import{createTransformContext as d,transform as l}from"@ez4/transform";import{validate as g,
|
|
2
2
|
getUniqueErrorMessages as h,createValidatorContext as x}from"@ez4/validator";import{
|
|
3
3
|
HttpBadRequestError as u}from"@ez4/gateway";var D=a(async(e,t)=>{let r=l(e,t,d({convert:!1})),o=await g(r,t,x({property:"$pa\
|
|
4
|
-
th"}));if(o.length){let
|
|
4
|
+
th"}));if(o.length){let n=h(o);throw new u("Malformed path parameters.",n)}return r},
|
|
5
5
|
"getPathParameters");import{createTransformContext as T,transform as H}from"@ez4/transform";import{validate as w,
|
|
6
6
|
createValidatorContext as S,getUniqueErrorMessages as v}from"@ez4/validator";import{
|
|
7
|
-
HttpBadRequestError as E}from"@ez4/gateway";var W=a(async(e,t,r)=>{let o=r?.namingStyle,
|
|
8
|
-
t,
|
|
9
|
-
"Malformed query strings.",i)}return
|
|
7
|
+
HttpBadRequestError as E}from"@ez4/gateway";var W=a(async(e,t,r)=>{let o=r?.namingStyle,n=T({convert:!0,inputStyle:o}),s=H(e,
|
|
8
|
+
t,n),m=S({property:"$query"}),p=await w(s,t,m);if(p.length){let i=v(p);throw new E(
|
|
9
|
+
"Malformed query strings.",i)}return s},"getQueryStrings");import{createTransformContext as q,transform as C}from"@ez4/transform";import{validate as P,
|
|
10
10
|
createValidatorContext as b,getUniqueErrorMessages as z}from"@ez4/validator";import{
|
|
11
11
|
HttpBadRequestError as M}from"@ez4/gateway";var et=a(async(e,t)=>{let r=C(e,t,q({convert:!1})),o=await P(r,t,b({property:"$h\
|
|
12
|
-
eader"}));if(o.length){let
|
|
12
|
+
eader"}));if(o.length){let n=z(o);throw new M("Malformed request headers.",n)}return r},
|
|
13
13
|
"getHeaders");import{validate as j,createValidatorContext as B,getUniqueErrorMessages as O}from"@ez4/validator";
|
|
14
|
-
import{HttpBadRequestError as R}from"@ez4/gateway";var
|
|
14
|
+
import{HttpBadRequestError as R}from"@ez4/gateway";var st=a(async(e,t)=>{let r=await j(e,t,B({property:"$identity"}));if(r.length){
|
|
15
15
|
let o=O(r);throw new R("Malformed authorizer identity.",o)}return e},"getIdentit\
|
|
16
16
|
y");import{createTransformContext as c,transform as f}from"@ez4/transform";import{validate as U,
|
|
17
17
|
createValidatorContext as V,getUniqueErrorMessages as $}from"@ez4/validator";import{
|
|
18
|
-
HttpBadRequestError as A}from"@ez4/gateway";var yt=a(async(e,t,r)=>{let o=r?.namingStyle,
|
|
19
|
-
|
|
18
|
+
HttpBadRequestError as A}from"@ez4/gateway";var yt=a(async(e,t,r)=>{let o=r?.namingStyle,n=V({property:"$body",inputStyle:o}),
|
|
19
|
+
s=await U(e,t,n);if(s.length){let i=$(s);throw new A("Malformed body payload.",i)}
|
|
20
20
|
let m=c({convert:!1,inputStyle:o});return f(e,t,m)},"getRequestBody"),dt=a((e,t,r)=>{
|
|
21
|
-
let o=r?.namingStyle,
|
|
21
|
+
let o=r?.namingStyle,n=c({convert:!1,outputStyle:o});return f(e,t,n)},"getRespon\
|
|
22
22
|
seBody");var ht=a(({status:e,message:t,details:r})=>({status:e,body:{message:t,details:r}}),
|
|
23
|
-
"getJsonError");export{et as getHeaders,
|
|
23
|
+
"getJsonError");export{et as getHeaders,st as getIdentity,ht as getJsonError,D as getPathParameters,
|
|
24
24
|
W as getQueryStrings,yt as getRequestBody,dt as getResponseBody};
|
|
25
25
|
//# sourceMappingURL=utils.mjs.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ez4/gateway",
|
|
3
3
|
"description": "EZ4: Components to build gateway services",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"test:types": "npm run build && tsc -p tsconfig.test.json",
|
|
46
46
|
"local:publish": "npm run build && npm run clean:registry && npm publish --registry http://localhost:4873",
|
|
47
47
|
"clean:registry": "rm -rf ../../.registry/@ez4/gateway",
|
|
48
|
-
"live:publish": "npm run
|
|
48
|
+
"live:publish": "npm run build && npm publish --access public"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ez4/common": "^0.
|
|
52
|
-
"@ez4/project": "^0.
|
|
53
|
-
"@ez4/reflection": "^0.
|
|
54
|
-
"@ez4/schema": "^0.
|
|
55
|
-
"@ez4/transform": "^0.
|
|
56
|
-
"@ez4/utils": "^0.
|
|
57
|
-
"@ez4/validator": "^0.
|
|
51
|
+
"@ez4/common": "^0.26.0",
|
|
52
|
+
"@ez4/project": "^0.26.0",
|
|
53
|
+
"@ez4/reflection": "^0.26.0",
|
|
54
|
+
"@ez4/schema": "^0.26.0",
|
|
55
|
+
"@ez4/transform": "^0.26.0",
|
|
56
|
+
"@ez4/utils": "^0.26.0",
|
|
57
|
+
"@ez4/validator": "^0.26.0"
|
|
58
58
|
}
|
|
59
59
|
}
|