@ez4/gateway 0.21.0 → 0.23.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 +203 -175
- package/dist/library.mjs +196 -182
- package/dist/main.cjs +16 -13
- package/dist/main.mjs +13 -10
- package/dist/utils/body.d.ts +4 -0
- package/dist/utils/errors.d.ts +13 -0
- package/dist/utils/headers.d.ts +3 -0
- package/dist/utils/identity.d.ts +3 -0
- package/dist/utils/parameters.d.ts +3 -0
- package/dist/utils/query.d.ts +3 -0
- package/dist/utils.cjs +23 -0
- package/dist/utils.d.ts +6 -0
- package/dist/utils.mjs +19 -0
- package/package.json +12 -7
package/dist/library.cjs
CHANGED
|
@@ -1,179 +1,207 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof t=="object"||typeof t=="function")for(let n of
|
|
3
|
-
|
|
4
|
-
IncompleteHandlerError:()=>
|
|
5
|
-
IncorrectBodyTypeError:()=>
|
|
6
|
-
IncorrectDefaultsTypeError:()=>
|
|
7
|
-
IncorrectParameterTypeError:()=>
|
|
8
|
-
IncorrectResponseTypeError:()=>
|
|
9
|
-
InvalidCorsTypeError:()=>
|
|
10
|
-
InvalidIdentityTypeError:()=>
|
|
11
|
-
InvalidRequestTypeError:()
|
|
12
|
-
ServiceType:()=>
|
|
13
|
-
getHttpBody:()
|
|
14
|
-
getHttpHandlerResponse:()=>
|
|
15
|
-
getHttpQuery:()=>
|
|
16
|
-
registerTriggers:()=>
|
|
17
|
-
super("Incomplete service",t,r)}};var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
e,"Http.
|
|
26
|
-
|
|
27
|
-
e,
|
|
28
|
-
e),r,o):null,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
e)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
o.push(new
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
super("
|
|
47
|
-
super("
|
|
48
|
-
super("
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
e
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
e
|
|
69
|
-
e)?
|
|
70
|
-
null):(o.push(new
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if(!(0,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
s
|
|
82
|
-
e,o,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
1
|
+
"use strict";var ue=Object.defineProperty;var Dr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var Br=Object.prototype.hasOwnProperty;var p=(e,t)=>ue(e,"name",{value:t,configurable:!0});var Nr=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Ur=(e,t,r,o)=>{if(t&&
|
|
2
|
+
typeof t=="object"||typeof t=="function")for(let n of Fr(t))!Br.call(e,n)&&n!==r&&
|
|
3
|
+
ue(e,n,{get:()=>t[n],enumerable:!(o=Dr(t,n))||o.enumerable});return e};var Vr=e=>Ur(ue({},"__esModule",{value:!0}),e);var st={};Nr(st,{IncompleteAuthorizerError:()=>V,IncompleteCacheError:()=>le,IncompleteCorsError:()=>se,
|
|
4
|
+
IncompleteHandlerError:()=>pe,IncompleteRouteError:()=>U,IncompleteServiceError:()=>F,
|
|
5
|
+
IncorrectBodyTypeError:()=>_,IncorrectCacheTypeError:()=>ae,IncorrectCorsTypeError:()=>ce,
|
|
6
|
+
IncorrectDefaultsTypeError:()=>N,IncorrectHeadersTypeError:()=>W,IncorrectIdentityTypeError:()=>Y,
|
|
7
|
+
IncorrectParameterTypeError:()=>te,IncorrectQueryTypeError:()=>ne,IncorrectRequestTypeError:()=>ee,
|
|
8
|
+
IncorrectResponseTypeError:()=>J,InvalidBodyTypeError:()=>Z,InvalidCacheTypeError:()=>me,
|
|
9
|
+
InvalidCorsTypeError:()=>ie,InvalidDefaultsTypeError:()=>B,InvalidHeadersTypeError:()=>K,
|
|
10
|
+
InvalidIdentityTypeError:()=>G,InvalidParameterTypeError:()=>re,InvalidQueryTypeError:()=>oe,
|
|
11
|
+
InvalidRequestTypeError:()=>L,InvalidResponseTypeError:()=>Q,InvalidRouteErrorTypeError:()=>E,
|
|
12
|
+
ServiceType:()=>fe,getHttpAuthRequest:()=>Fe,getHttpAuthResponse:()=>Ce,getHttpAuthorizer:()=>Ue,
|
|
13
|
+
getHttpBody:()=>$,getHttpCache:()=>Ye,getHttpCors:()=>Je,getHttpHandler:()=>Ve,getHttpHandlerRequest:()=>Be,
|
|
14
|
+
getHttpHandlerResponse:()=>ke,getHttpHeaders:()=>X,getHttpIdentity:()=>R,getHttpParameters:()=>qe,
|
|
15
|
+
getHttpQuery:()=>De,getHttpRoutes:()=>Qe,getHttpServices:()=>Ke,isHttpService:()=>Qr,
|
|
16
|
+
registerTriggers:()=>pt});module.exports=Vr(st);var Cr=require("@ez4/common/library"),kr=require("@ez4/schema/library"),qr=require("@ez4/project/library");var g=require("@ez4/common/library"),Or=require("@ez4/reflection");var fe="@ez4/http",Qr=p(e=>e.type===fe,"isHttpService");var We=require("@ez4/common/library");var F=class extends We.IncompleteTypeError{static{p(this,"IncompleteServiceError")}constructor(t,r){
|
|
17
|
+
super("Incomplete service",t,r)}};var y=require("@ez4/common/library"),v=require("@ez4/reflection");var u=require("@ez4/common/library"),A=require("@ez4/reflection");var Jr=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),Xe=p(e=>{let[
|
|
18
|
+
t]=e.split(" ",2);return Jr.has(t)},"isHttpPath"),Ze=p(e=>(0,u.isClassDeclaration)(
|
|
19
|
+
e)&&(0,u.hasHeritageType)(e,"Http.Service"),"isHttpService"),_e=p(e=>(0,u.isModelDeclaration)(
|
|
20
|
+
e)&&(0,u.hasHeritageType)(e,"Http.Route"),"isHttpRoute");var $e=p(e=>(0,u.hasHeritageType)(e,"Http.Defaults"),"isHttpDefaults"),Le=p(e=>(0,u.hasHeritageType)(
|
|
21
|
+
e,"Http.Headers"),"isHttpHeaders"),er=p(e=>(0,u.hasHeritageType)(e,"Http.Identit\
|
|
22
|
+
y"),"isHttpIdentity"),rr=p(e=>(0,u.hasHeritageType)(e,"Http.QueryStrings"),"isHt\
|
|
23
|
+
tpQuery"),tr=p(e=>(0,u.hasHeritageType)(e,"Http.PathParameters"),"isHttpParamete\
|
|
24
|
+
rs"),or=p(e=>(0,u.hasHeritageType)(e,"Http.JsonBody"),"isJsonBody"),nr=p(e=>(0,u.hasHeritageType)(
|
|
25
|
+
e,"Http.Cors"),"isHttpCors"),pr=p(e=>(0,u.hasHeritageType)(e,"Http.Cache"),"isHt\
|
|
26
|
+
tpCache"),sr=p(e=>(0,A.isTypeCallback)(e)||(0,A.isTypeFunction)(e),"isHttpAuthor\
|
|
27
|
+
izer"),ir=p(e=>(0,A.isTypeCallback)(e)||(0,A.isTypeFunction)(e),"isHttpHandler");var b=require("@ez4/common/library"),ye=require("@ez4/utils"),S=require("@ez4/reflection");var de=p((e,t,r,o)=>{if(!(0,S.isTypeReference)(e))return cr(e,t,r,o);let n=(0,b.getReferenceType)(
|
|
28
|
+
e,r);return n?cr(n,t,r,o):null},"getHttpErrors"),cr=p((e,t,r,o)=>(0,S.isTypeObject)(
|
|
29
|
+
e)?Gr(e,t,(0,b.getObjectMembers)(e),r,o):null,"getTypeErrors"),Gr=p((e,t,r,o,n)=>{
|
|
30
|
+
let s={};for(let i of r){if(!(0,S.isModelProperty)(i)||i.inherited)continue;let c=parseInt(
|
|
31
|
+
i.name,10);(0,ye.isAnyNumber)(c)||n.push(new b.InvalidServicePropertyError(t.name,
|
|
32
|
+
i.name,e.file));let l=Yr(i,c,t,o,n);l&&Object.assign(s,l)}return(0,ye.isEmptyObject)(
|
|
33
|
+
s)?null:s},"getTypeFromMembers"),Yr=p((e,t,r,o,n)=>{let s=(0,b.getPropertyTuple)(
|
|
34
|
+
e)??[],i={};for(let c of s){if(!(0,S.isTypeReference)(c)){n.push(new E(r.file));
|
|
35
|
+
continue}let l=(0,b.getReferenceType)(c,o);if(!l||!(0,S.isTypeClass)(l)){n.push(
|
|
36
|
+
new E(r.file));continue}i[l.name]=t}return i},"getErrorClasses");var ar=p((e,t,r,o)=>{if(!(0,v.isTypeReference)(e))return lr(e,t,r,o);let n=(0,y.getReferenceType)(
|
|
37
|
+
e,r);return n?lr(n,t,r,o):null},"getHttpDefaults"),lr=p((e,t,r,o)=>(0,v.isTypeObject)(
|
|
38
|
+
e)?mr(t,(0,y.getObjectMembers)(e),r,o):(0,y.isModelDeclaration)(e)?$e(e)?mr(t,(0,y.getModelMembers)(
|
|
39
|
+
e),r,o):(o.push(new N(e.name,t.file)),null):(o.push(new B(t.file)),null),"getTyp\
|
|
40
|
+
eDefaults"),mr=p((e,t,r,o)=>{let n={};for(let s of t)if(!(!(0,v.isModelProperty)(
|
|
41
|
+
s)||s.inherited))switch(s.name){default:o.push(new y.InvalidServicePropertyError(
|
|
42
|
+
e.name,s.name,e.file));break;case"httpErrors":n.httpErrors=de(s.value,e,r,o);break;case"\
|
|
43
|
+
memory":case"logRetention":case"timeout":n[s.name]=(0,y.getPropertyNumber)(s);break;case"\
|
|
44
|
+
listener":n.listener=(0,y.getServiceListener)(s.value,o);break}return n},"getTyp\
|
|
45
|
+
eFromMembers");var I=require("@ez4/reflection"),m=require("@ez4/common/library");var Te=require("@ez4/common/library");var U=class extends Te.IncompleteTypeError{static{p(this,"IncompleteRouteError")}constructor(t,r){
|
|
46
|
+
super("Incomplete gateway route",t,r)}},E=class extends Te.TypeError{static{p(this,
|
|
47
|
+
"InvalidRouteErrorTypeError")}constructor(t){super("Invalid route error type.",t)}};var ur=require("@ez4/common/library");var V=class extends ur.IncompleteTypeError{static{p(this,"IncompleteAuthorizerEr\
|
|
48
|
+
ror")}constructor(t,r){super("Incomplete route authorizer",t,r)}};var T=require("@ez4/common/library"),w=require("@ez4/reflection"),Mr=require("@ez4/utils");var ge=require("@ez4/common/library");var Q=class extends ge.InvalidTypeError{constructor(r,o){super("Invalid route re\
|
|
49
|
+
sponse",void 0,r,o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},
|
|
50
|
+
J=class extends ge.IncorrectTypeError{constructor(r,o,n){super("Incorrect route \
|
|
51
|
+
response",r,o,n);this.responseType=r;this.baseType=o}static{p(this,"IncorrectRes\
|
|
52
|
+
ponseTypeError")}};var h=require("@ez4/reflection"),he=require("@ez4/common/library"),yr=require("@ez4/schema/library");var Me=require("@ez4/common/library");var G=class extends Me.InvalidTypeError{static{p(this,"InvalidIdentityTypeError")}constructor(t){
|
|
53
|
+
super("Invalid identity",void 0,"Http.Identity",t)}},Y=class extends Me.IncorrectTypeError{constructor(r,o){
|
|
54
|
+
super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}static{p(this,
|
|
55
|
+
"IncorrectIdentityTypeError")}};var He=require("@ez4/schema/library");var f=p((e,t)=>{let r=(0,He.getObjectSchema)(e,t);return r&&(0,He.isObjectSchema)(
|
|
56
|
+
r)?r:null},"getSchemaFromType");var R=p((e,t,r,o)=>{if((0,h.isTypeUndefined)(e))return null;if(!(0,h.isTypeReference)(
|
|
57
|
+
e))return fr(e,t,r,o);let n=(0,he.getReferenceType)(e,r);return n?fr(n,t,r,o):null},
|
|
58
|
+
"getHttpIdentity"),fr=p((e,t,r,o)=>{if((0,h.isTypeUnion)(e))return Kr(e.elements,
|
|
59
|
+
t,r,o);if((0,h.isTypeObject)(e)||(0,h.isTypeIntersection)(e))return f(e,r);if(!(0,he.isModelDeclaration)(
|
|
60
|
+
e))return o.push(new G(t.file)),null;if(!er(e))return o.push(new Y(e.name,t.file)),
|
|
61
|
+
null;let n=f(e,r);return n&&(n.definitions={...n.definitions,extensible:!0}),n},
|
|
62
|
+
"getTypeIdentity"),Kr=p((e,t,r,o)=>{let n=[];for(let s of e){let i=R(s,t,r,o);i&&
|
|
63
|
+
n.push(i)}return n.length>1?(0,yr.createUnionSchema)({elements:n}):n[0]},"getIde\
|
|
64
|
+
ntityFromUnion");var P=require("@ez4/reflection"),Se=require("@ez4/common/library");var be=require("@ez4/common/library");var K=class extends be.InvalidTypeError{static{p(this,"InvalidHeadersTypeError")}constructor(t){
|
|
65
|
+
super("Invalid headers",void 0,"Http.Headers",t)}},W=class extends be.IncorrectTypeError{constructor(r,o){
|
|
66
|
+
super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}static{p(this,"\
|
|
67
|
+
IncorrectHeadersTypeError")}};var X=p((e,t,r,o)=>{if(!(0,P.isTypeReference)(e))return dr(e,t,r,o);let n=(0,Se.getReferenceType)(
|
|
68
|
+
e,r);return n?dr(n,t,r,o):null},"getHttpHeaders"),dr=p((e,t,r,o)=>(0,P.isTypeObject)(
|
|
69
|
+
e)||(0,P.isTypeIntersection)(e)?f(e,r):(0,Se.isModelDeclaration)(e)?Le(e)?f(e,r):
|
|
70
|
+
(o.push(new W(e.name,t.file)),null):(o.push(new K(t.file)),null),"getTypeHeaders");var j=require("@ez4/schema/library"),Ie=require("@ez4/common/library"),d=require("@ez4/reflection");var xe=require("@ez4/common/library");var Z=class extends xe.InvalidTypeError{static{p(this,"InvalidBodyTypeError")}constructor(t){
|
|
71
|
+
super("Invalid body",void 0,"Http.JsonBody",t)}},_=class extends xe.IncorrectTypeError{constructor(r,o){
|
|
72
|
+
super("Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}static{p(this,"Incor\
|
|
73
|
+
rectBodyTypeError")}};var $=p((e,t,r,o)=>ze(e,r,n=>we(n)??Oe(n,t,r,o)),"getHttpBody"),ze=p((e,t,r)=>{if((0,d.isTypeUndefined)(
|
|
74
|
+
e))return null;if(!(0,d.isTypeReference)(e))return r(e);let o=(0,Ie.getReferenceType)(
|
|
75
|
+
e,t);return o?r(o):null},"getTypeBody"),we=p(e=>(0,d.isTypeScalar)(e)?(0,j.getScalarSchema)(
|
|
76
|
+
e):null,"getScalarTypeBody"),Oe=p((e,t,r,o)=>(0,d.isTypeUnion)(e)?Wr(e.elements,
|
|
77
|
+
r,n=>we(n)??Oe(n,t,r,o)):(0,d.isTypeArray)(e)?Xr(e.element,r,n=>we(n)??Oe(n,t,r,
|
|
78
|
+
o)):(0,d.isTypeObject)(e)||(0,d.isTypeIntersection)(e)?f(e,r):(0,Ie.isModelDeclaration)(
|
|
79
|
+
e)?or(e)?f(e,r):(o.push(new _(e.name,e.file)),null):(o.push(new Z(t.file)),null),
|
|
80
|
+
"getCompoundTypeBody"),Wr=p((e,t,r)=>{let o=[];for(let n of e){let s=ze(n,t,r);s&&
|
|
81
|
+
o.push(s)}return o.length?(0,j.createUnionSchema)({elements:o}):null},"getUnionT\
|
|
82
|
+
ypeBody"),Xr=p((e,t,r)=>{let o=ze(e,t,r);return o?(0,j.createArraySchema)({element:o}):
|
|
83
|
+
null},"getArrayTypeBody");var Ce=p((e,t,r,o)=>{let n=Hr(e,t,r,o,"Http.AuthResponse");return n&&Zr(n)?n:null},
|
|
84
|
+
"getHttpAuthResponse"),ke=p((e,t,r,o)=>{let n=Hr(e,t,r,o,"Http.Response");return n&&
|
|
85
|
+
_r(n)?n:null},"getHttpHandlerResponse"),Hr=p((e,t,r,o,n)=>{if(!(0,w.isTypeReference)(
|
|
86
|
+
e))return Tr(e,t,r,o,n);let s=(0,T.getReferenceType)(e,r);return s?Tr(s,t,r,o,n):
|
|
87
|
+
null},"getHttpResponse"),Zr=p(e=>!!e.identity,"isValidAuthResponse"),_r=p(e=>(0,Mr.isAnyNumber)(
|
|
88
|
+
e.status),"isValidHandlerResponse"),Tr=p((e,t,r,o,n)=>(0,w.isTypeObject)(e)?gr(e,
|
|
89
|
+
t,(0,T.getObjectMembers)(e),r,o):(0,T.isModelDeclaration)(e)?(0,T.hasHeritageType)(
|
|
90
|
+
e,n)?gr(e,t,(0,T.getModelMembers)(e),r,o):(o.push(new J(e.name,n,e.file)),null):
|
|
91
|
+
(o.push(new Q(n,t.file)),null),"getTypeResponse"),gr=p((e,t,r,o,n)=>{let s={};for(let i of r)
|
|
92
|
+
if(!(!(0,w.isModelProperty)(i)||i.inherited))switch(i.name){default:n.push(new T.InvalidServicePropertyError(
|
|
93
|
+
t.name,i.name,e.file));break;case"status":s.status=(0,T.getPropertyNumber)(i);break;case"\
|
|
94
|
+
headers":{s.headers=X(i.value,e,o,n),s.headers&&i.description&&(s.headers.description=
|
|
95
|
+
i.description);break}case"identity":{s.identity=R(i.value,e,o,n),s.identity&&i.description&&
|
|
96
|
+
(s.identity.description=i.description);break}case"body":{s.body=$(i.value,e,o,n),
|
|
97
|
+
s.body&&i.description&&(s.body.description=i.description);break}}return s},"getT\
|
|
98
|
+
ypeFromMembers");var x=require("@ez4/reflection"),M=require("@ez4/common/library");var Ae=require("@ez4/common/library");var L=class extends Ae.InvalidTypeError{constructor(r,o){super("Invalid route re\
|
|
99
|
+
quest",void 0,r,o);this.baseType=r}static{p(this,"InvalidRequestTypeError")}},ee=class extends Ae.IncorrectTypeError{constructor(r,o,n){
|
|
100
|
+
super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}static{
|
|
101
|
+
p(this,"IncorrectRequestTypeError")}};var O=require("@ez4/reflection"),ve=require("@ez4/common/library");var Ee=require("@ez4/common/library");var re=class extends Ee.InvalidTypeError{static{p(this,"InvalidParameterTypeErro\
|
|
102
|
+
r")}constructor(t){super("Invalid request parameters",void 0,"Http.PathParameter\
|
|
103
|
+
s",t)}},te=class extends Ee.IncorrectTypeError{constructor(r,o){super("Incorrect\
|
|
104
|
+
request parameters",r,"Http.PathParameters",o);this.parametersType=r}static{p(this,
|
|
105
|
+
"IncorrectParameterTypeError")}};var qe=p((e,t,r,o)=>{if(!(0,O.isTypeReference)(e))return hr(e,t,r,o);let n=(0,ve.getReferenceType)(
|
|
106
|
+
e,r);return n?hr(n,t,r,o):null},"getHttpParameters"),hr=p((e,t,r,o)=>(0,O.isTypeObject)(
|
|
107
|
+
e)||(0,O.isTypeIntersection)(e)?f(e,r):(0,ve.isModelDeclaration)(e)?tr(e)?f(e,r):
|
|
108
|
+
(o.push(new te(e.name,e.file)),null):(o.push(new re(t.file)),null),"getTypeParam\
|
|
109
|
+
eter");var z=require("@ez4/reflection"),Pe=require("@ez4/common/library");var Re=require("@ez4/common/library");var oe=class extends Re.InvalidTypeError{static{p(this,"InvalidQueryTypeError")}constructor(t){
|
|
110
|
+
super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},ne=class extends Re.IncorrectTypeError{constructor(r,o){
|
|
95
111
|
super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
|
|
96
|
-
r}};var
|
|
97
|
-
e,r);return n?
|
|
98
|
-
e)?
|
|
99
|
-
null):(o.push(new
|
|
100
|
-
Request"),
|
|
101
|
-
e.elements[0],t,r,o,n);if(!(0,
|
|
102
|
-
e
|
|
103
|
-
|
|
104
|
-
e),r,o):(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
(
|
|
110
|
-
n),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
t
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
(0,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
t
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
p
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
n.name,i));
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
112
|
+
r}static{p(this,"IncorrectQueryTypeError")}};var De=p((e,t,r,o)=>{if(!(0,z.isTypeReference)(e))return br(e,t,r,o);let n=(0,Pe.getReferenceType)(
|
|
113
|
+
e,r);return n?br(n,t,r,o):null},"getHttpQuery"),br=p((e,t,r,o)=>(0,z.isTypeObject)(
|
|
114
|
+
e)||(0,z.isTypeIntersection)(e)?f(e,r):(0,Pe.isModelDeclaration)(e)?rr(e)?f(e,r):
|
|
115
|
+
(o.push(new ne(e.name,t.file)),null):(o.push(new oe(t.file)),null),"getTypeQuery");var Fe=p((e,t,r,o)=>Ne(e,t,r,o,"Http.AuthRequest"),"getHttpAuthRequest"),Be=p((e,t,r,o)=>Ne(
|
|
116
|
+
e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),Ne=p((e,t,r,o,n)=>{if((0,x.isTypeIntersection)(
|
|
117
|
+
e)&&e.elements.length>0)return Ne(e.elements[0],t,r,o,n);if(!(0,x.isTypeReference)(
|
|
118
|
+
e))return Sr(e,t,r,o,n);let s=(0,M.getReferenceType)(e,r);return s?Sr(s,t,r,o,n):
|
|
119
|
+
null},"getHttpRequest"),Sr=p((e,t,r,o,n)=>(0,x.isTypeObject)(e)?xr(e,t,(0,M.getObjectMembers)(
|
|
120
|
+
e),r,o):(0,M.isModelDeclaration)(e)?(0,M.hasHeritageType)(e,n)?xr(e,t,(0,M.getModelMembers)(
|
|
121
|
+
e),r,o):(o.push(new ee(e.name,n,e.file)),null):(o.push(new L(n,t.file)),null),"g\
|
|
122
|
+
etTypeRequest"),xr=p((e,t,r,o,n)=>{let s={};for(let i of r)if(!(!(0,x.isModelProperty)(
|
|
123
|
+
i)||i.inherited))switch(i.name){default:n.push(new M.InvalidServicePropertyError(
|
|
124
|
+
t.name,i.name,e.file));break;case"headers":{s.headers=X(i.value,e,o,n),s.headers&&
|
|
125
|
+
i.description&&(s.headers.description=i.description);break}case"identity":{s.identity=
|
|
126
|
+
R(i.value,e,o,n),s.identity&&i.description&&(s.identity.description=i.description);
|
|
127
|
+
break}case"query":{s.query=De(i.value,e,o,n),s.query&&i.description&&(s.query.description=
|
|
128
|
+
i.description);break}case"parameters":{s.parameters=qe(i.value,e,o,n),s.parameters&&
|
|
129
|
+
i.description&&(s.parameters.description=i.description);break}case"body":{s.body=
|
|
130
|
+
$(i.value,e,o,n),s.body&&i.description&&(s.body.description=i.description);break}}
|
|
131
|
+
return s},"getTypeFromMembers");var Ue=p((e,t,r,o)=>{if(!sr(e))return null;let n={},s=new Set(["name","file"]);if(e.
|
|
132
|
+
description&&(n.description=e.description),(n.name=e.name)&&s.delete("name"),(n.
|
|
133
|
+
file=e.file)&&s.delete("file"),e.parameters){let[{value:i}]=e.parameters;n.request=
|
|
134
|
+
Fe(i,t,r,o)}return e.return&&(n.response=Ce(e.return,t,r,o)),$r(n)?n:(o.push(new V(
|
|
135
|
+
[...s],e.file)),null)},"getHttpAuthorizer"),$r=p(e=>!!e.name&&!!e.file,"isValidA\
|
|
136
|
+
uthorizer");var Ir=require("@ez4/common/library");var pe=class extends Ir.IncompleteTypeError{static{p(this,"IncompleteHandlerErro\
|
|
137
|
+
r")}constructor(t,r){super("Incomplete route handler",t,r)}};var Ve=p((e,t,r,o)=>{if(!ir(e))return null;let n={},s=new Set(["name","file","re\
|
|
138
|
+
sponse"]);if(e.description&&(n.description=e.description),(n.name=e.name)&&s.delete(
|
|
139
|
+
"name"),(n.file=e.file)&&s.delete("file"),e.parameters){let[{value:i}]=e.parameters;
|
|
140
|
+
n.request=Be(i,t,r,o)}if(e.return){let i=ke(e.return,t,r,o);i&&(n.response=i,s.delete(
|
|
141
|
+
"response"))}return Lr(n)?n:(o.push(new pe([...s],e.file)),null)},"getHttpHandle\
|
|
142
|
+
r"),Lr=p(e=>!!e.name&&!!e.file&&!!e.response,"isValidHandler");var Qe=p((e,t,r,o)=>{let n=(0,m.getPropertyTuple)(t)??[];return vr(n,e,r,o)},"ge\
|
|
143
|
+
tHttpRoutes"),vr=p((e,t,r,o)=>{let n=[];for(let s of e){let i=et(s,t,r,o);Array.
|
|
144
|
+
isArray(i)?n.push(...i):i&&n.push(i)}return n},"getRouteFromTuple"),et=p((e,t,r,o)=>{
|
|
145
|
+
if(!(0,I.isTypeReference)(e))return Ar(e,t,r,o);let n=(0,m.getReferenceType)(e,r);
|
|
146
|
+
return n?Ar(n,t,r,o):null},"getTypeFromRoute"),rt=p(e=>!!e.path&&!!e.handler,"is\
|
|
147
|
+
ValidRoute"),Ar=p((e,t,r,o)=>_e(e)?Er(e,t,(0,m.getModelMembers)(e),r,o):(0,I.isTypeObject)(
|
|
148
|
+
e)?Er(e,t,(0,m.getObjectMembers)(e),r,o):(0,I.isTypeTuple)(e)&&e.spread?vr(e.elements,
|
|
149
|
+
t,r,o):null,"getRouteType"),Er=p((e,t,r,o,n)=>{let s={},i=new Set(["path","handl\
|
|
150
|
+
er"]);for(let c of r)if(!(!(0,I.isModelProperty)(c)||c.inherited))switch(c.name){default:
|
|
151
|
+
n.push(new m.InvalidServicePropertyError(t.name,c.name,e.file));break;case"path":{
|
|
152
|
+
let l=(0,m.getPropertyString)(c);l&&Xe(l)&&(i.delete(c.name),s.path=l);break}case"\
|
|
153
|
+
handler":(s.handler=Ve(c.value,t,o,n))&&i.delete(c.name);break;case"authorizer":
|
|
154
|
+
s.authorizer=Ue(c.value,t,o,n);break;case"httpErrors":s.httpErrors=de(c.value,t,
|
|
155
|
+
o,n);break;case"memory":case"logRetention":case"timeout":s[c.name]=(0,m.getPropertyNumber)(
|
|
156
|
+
c);break;case"cors":s.cors=(0,m.getPropertyBoolean)(c);break;case"listener":s.listener=
|
|
157
|
+
(0,m.getServiceListener)(c.value,n);break;case"variables":s.variables=(0,m.getLinkedVariableList)(
|
|
158
|
+
c,n);break}return rt(s)?s:(n.push(new U([...i],e.file)),null)},"getTypeFromMembe\
|
|
159
|
+
rs");var a=require("@ez4/common/library"),k=require("@ez4/reflection");var C=require("@ez4/common/library");var se=class extends C.IncompleteTypeError{static{p(this,"IncompleteCorsError")}constructor(t,r){
|
|
160
|
+
super("Incomplete HTTP CORS",t,r)}},ie=class extends C.InvalidTypeError{static{p(
|
|
161
|
+
this,"InvalidCorsTypeError")}constructor(t){super("Invalid HTTP CORS type",void 0,
|
|
162
|
+
"Http.Cors",t)}},ce=class extends C.IncorrectTypeError{constructor(r,o){super("I\
|
|
163
|
+
ncorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}static{p(this,"Inc\
|
|
164
|
+
orrectCorsTypeError")}};var Je=p((e,t,r,o)=>{if(!(0,k.isTypeReference)(e))return Rr(e,t,o);let n=(0,a.getReferenceType)(
|
|
165
|
+
e,r);return n?Rr(n,t,o):null},"getHttpCors"),tt=p(e=>!!e.allowOrigins?.length,"i\
|
|
166
|
+
sValidCors"),Rr=p((e,t,r)=>(0,k.isTypeObject)(e)?Pr(e,t,(0,a.getObjectMembers)(e),
|
|
167
|
+
r):(0,a.isModelDeclaration)(e)?nr(e)?Pr(e,t,(0,a.getModelMembers)(e),r):(r.push(
|
|
168
|
+
new ce(e.name,e.file)),null):(r.push(new ie(t.file)),null),"getTypeCors"),Pr=p((e,t,r,o)=>{
|
|
169
|
+
let n={},s=new Set(["allowOrigins"]);for(let i of r)if(!(!(0,k.isModelProperty)(
|
|
170
|
+
i)||i.inherited))switch(i.name){default:o.push(new a.InvalidServicePropertyError(
|
|
171
|
+
t.name,i.name,e.file));break;case"allowOrigins":case"allowMethods":case"allowHea\
|
|
172
|
+
ders":case"exposeHeaders":n[i.name]=(0,a.getPropertyStringList)(i);break;case"al\
|
|
173
|
+
lowCredentials":n.allowCredentials=(0,a.getPropertyBoolean)(i);break;case"maxAge":
|
|
174
|
+
n.maxAge=(0,a.getPropertyNumber)(i);break}return tt(n)?n:(o.push(new se([...s],e.
|
|
175
|
+
file)),null)},"getTypeFromMembers");var H=require("@ez4/common/library"),D=require("@ez4/reflection"),Ge=require("@ez4/utils");var q=require("@ez4/common/library");var le=class extends q.IncompleteTypeError{static{p(this,"IncompleteCacheError")}constructor(t,r){
|
|
176
|
+
super("Incomplete gateway cache",t,r)}},me=class extends q.InvalidTypeError{static{
|
|
177
|
+
p(this,"InvalidCacheTypeError")}constructor(t){super("Invalid gateway cache type",
|
|
178
|
+
void 0,"Http.Cache",t)}},ae=class extends q.IncorrectTypeError{constructor(r,o){
|
|
179
|
+
super("Incorrect gateway cache type",r,"Http.Cache",o);this.cacheType=r}static{p(
|
|
180
|
+
this,"IncorrectCacheTypeError")}};var Ye=p((e,t,r,o)=>{if(!(0,D.isTypeReference)(e))return jr(e,t,o);let n=(0,H.getReferenceType)(
|
|
181
|
+
e,r);return n?jr(n,t,o):null},"getHttpCache"),ot=p(e=>(0,Ge.isAnyNumber)(e.authorizerTTL),
|
|
182
|
+
"isValidCache"),jr=p((e,t,r)=>(0,D.isTypeObject)(e)?wr(e,t,(0,H.getObjectMembers)(
|
|
183
|
+
e),r):(0,H.isModelDeclaration)(e)?pr(e)?wr(e,t,(0,H.getModelMembers)(e),r):(r.push(
|
|
184
|
+
new ae(e.name,e.file)),null):(r.push(new me(t.file)),null),"getTypeCache"),wr=p(
|
|
185
|
+
(e,t,r,o)=>{let n={},s=new Set(["authorizerTTL"]);for(let i of r)if(!(!(0,D.isModelProperty)(
|
|
186
|
+
i)||i.inherited))switch(i.name){default:o.push(new H.InvalidServicePropertyError(
|
|
187
|
+
t.name,i.name,e.file));break;case"authorizerTTL":{let c=(0,H.getPropertyNumber)(
|
|
188
|
+
i);(0,Ge.isAnyNumber)(c)&&(n[i.name]=c,s.delete(i.name));break}}return ot(n)?n:(o.
|
|
189
|
+
push(new le([...s],e.file)),null)},"getTypeFromMembers");var Ke=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!Ze(n)||(0,g.isExternalDeclaration)(
|
|
190
|
+
n))continue;let s={type:fe,extras:{}},i=new Set(["routes"]),c=n.file;s.name=n.name,
|
|
191
|
+
n.description&&(s.description=n.description);for(let l of(0,g.getModelMembers)(n))
|
|
192
|
+
if(!(!(0,Or.isModelProperty)(l)||l.inherited))switch(l.name){default:r.push(new g.InvalidServicePropertyError(
|
|
193
|
+
s.name,l.name,c));break;case"routes":(s.routes=Qe(n,l,e,r))&&i.delete(l.name);break;case"\
|
|
194
|
+
name":s.displayName=(0,g.getPropertyString)(l);break;case"defaults":s.defaults=ar(
|
|
195
|
+
l.value,n,e,r);break;case"cache":s.cache=Ye(l.value,n,e,r);break;case"cors":s.cors=
|
|
196
|
+
Je(l.value,n,e,r);break;case"variables":s.variables=(0,g.getLinkedVariableList)(
|
|
197
|
+
l,r);break;case"services":s.services=(0,g.getLinkedServiceList)(l,e,r);break}if(!nt(
|
|
198
|
+
s)){r.push(new F([...i],c));continue}if(t[n.name]){r.push(new g.DuplicateServiceError(
|
|
199
|
+
n.name,c));continue}t[n.name]=s}return{services:t,errors:r}},"getHttpServices"),
|
|
200
|
+
nt=p(e=>!!e.name&&!!e.routes&&!!e.extras,"isValidService");var zr=!1,pt=p(()=>{zr||((0,Cr.registerTriggers)(),(0,kr.registerTriggers)(),(0,qr.createTrigger)(
|
|
201
|
+
"@ez4/gateway",{"metadata:getServices":Ke}),zr=!0)},"registerTriggers");var je=require("@ez4/common/library");var B=class extends je.InvalidTypeError{static{p(this,"InvalidDefaultsTypeError")}constructor(t){
|
|
202
|
+
super("Invalid defaults",void 0,"Http.Defaults",t)}},N=class extends je.IncorrectTypeError{constructor(r,o){
|
|
203
|
+
super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}static{p(this,
|
|
204
|
+
"IncorrectDefaultsTypeError")}};0&&(module.exports={IncompleteAuthorizerError,IncompleteCacheError,IncompleteCorsError,
|
|
177
205
|
IncompleteHandlerError,IncompleteRouteError,IncompleteServiceError,IncorrectBodyTypeError,
|
|
178
206
|
IncorrectCacheTypeError,IncorrectCorsTypeError,IncorrectDefaultsTypeError,IncorrectHeadersTypeError,
|
|
179
207
|
IncorrectIdentityTypeError,IncorrectParameterTypeError,IncorrectQueryTypeError,IncorrectRequestTypeError,
|