@ez4/gateway 0.20.0 → 0.21.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 +150 -152
- package/dist/library.mjs +172 -172
- package/dist/main.cjs +12 -12
- package/dist/main.mjs +9 -9
- package/dist/metadata/body.d.ts +1 -2
- package/dist/services/common.d.ts +24 -16
- package/dist/services/contract.d.ts +9 -1
- package/dist/services/utils.d.ts +24 -0
- package/dist/types/common.d.ts +1 -1
- package/package.json +6 -6
package/dist/library.cjs
CHANGED
|
@@ -1,180 +1,178 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof t=="object"||typeof t=="function")for(let n of
|
|
3
|
-
|
|
4
|
-
IncompleteHandlerError:()=>
|
|
5
|
-
IncorrectBodyTypeError:()=>
|
|
6
|
-
IncorrectDefaultsTypeError:()=>B,IncorrectHeadersTypeError:()=>
|
|
7
|
-
IncorrectParameterTypeError:()=>
|
|
8
|
-
IncorrectResponseTypeError:()=>Q,InvalidBodyTypeError:()=>
|
|
9
|
-
InvalidCorsTypeError:()=>
|
|
10
|
-
InvalidIdentityTypeError:()=>
|
|
11
|
-
InvalidRequestTypeError:()
|
|
12
|
-
ServiceType:()=>
|
|
13
|
-
getHttpCache:()=>
|
|
14
|
-
getHttpHandlerResponse:()=>
|
|
15
|
-
getHttpQuery:()=>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"Http.
|
|
24
|
-
e,"Http.
|
|
25
|
-
e,"Http.
|
|
26
|
-
e,
|
|
27
|
-
e
|
|
28
|
-
e
|
|
29
|
-
|
|
30
|
-
s
|
|
31
|
-
|
|
32
|
-
Object.assign(p,c)}return(0,ae.isEmptyObject)(p)?null:p},Yr=(e,t,r,o,n)=>{let p=(0,h.getPropertyTuple)(
|
|
1
|
+
"use strict";var Pe=Object.defineProperty;var qr=Object.getOwnPropertyDescriptor;var Dr=Object.getOwnPropertyNames;var Fr=Object.prototype.hasOwnProperty;var Br=(e,t)=>{for(var r in t)Pe(e,r,{get:t[r],enumerable:!0})},Nr=(e,t,r,o)=>{if(t&&
|
|
2
|
+
typeof t=="object"||typeof t=="function")for(let n of Dr(t))!Fr.call(e,n)&&n!==r&&
|
|
3
|
+
Pe(e,n,{get:()=>t[n],enumerable:!(o=qr(t,n))||o.enumerable});return e};var Ur=e=>Nr(Pe({},"__esModule",{value:!0}),e);var pt={};Br(pt,{IncompleteAuthorizerError:()=>U,IncompleteCacheError:()=>ce,IncompleteCorsError:()=>pe,
|
|
4
|
+
IncompleteHandlerError:()=>ne,IncompleteRouteError:()=>N,IncompleteServiceError:()=>D,
|
|
5
|
+
IncorrectBodyTypeError:()=>Z,IncorrectCacheTypeError:()=>me,IncorrectCorsTypeError:()=>ie,
|
|
6
|
+
IncorrectDefaultsTypeError:()=>B,IncorrectHeadersTypeError:()=>K,IncorrectIdentityTypeError:()=>G,
|
|
7
|
+
IncorrectParameterTypeError:()=>re,IncorrectQueryTypeError:()=>oe,IncorrectRequestTypeError:()=>L,
|
|
8
|
+
IncorrectResponseTypeError:()=>Q,InvalidBodyTypeError:()=>X,InvalidCacheTypeError:()=>le,
|
|
9
|
+
InvalidCorsTypeError:()=>se,InvalidDefaultsTypeError:()=>F,InvalidHeadersTypeError:()=>Y,
|
|
10
|
+
InvalidIdentityTypeError:()=>J,InvalidParameterTypeError:()=>ee,InvalidQueryTypeError:()=>te,
|
|
11
|
+
InvalidRequestTypeError:()=>$,InvalidResponseTypeError:()=>V,InvalidRouteErrorTypeError:()=>A,
|
|
12
|
+
ServiceType:()=>ae,getHttpAuthRequest:()=>De,getHttpAuthResponse:()=>ze,getHttpAuthorizer:()=>Ne,
|
|
13
|
+
getHttpBody:()=>_,getHttpCache:()=>Ge,getHttpCors:()=>Qe,getHttpHandler:()=>Ue,getHttpHandlerRequest:()=>Fe,
|
|
14
|
+
getHttpHandlerResponse:()=>Ce,getHttpHeaders:()=>W,getHttpIdentity:()=>v,getHttpParameters:()=>ke,
|
|
15
|
+
getHttpQuery:()=>qe,getHttpRoutes:()=>Ve,getHttpServices:()=>Ye,isHttpService:()=>Vr,
|
|
16
|
+
registerTriggers:()=>nt});module.exports=Ur(pt);var zr=require("@ez4/common/library"),Cr=require("@ez4/schema/library"),kr=require("@ez4/project/library");var T=require("@ez4/common/library"),wr=require("@ez4/reflection");var ae="@ez4/http",Vr=e=>e.type===ae;var Ke=require("@ez4/common/library"),D=class extends Ke.IncompleteTypeError{constructor(t,r){
|
|
17
|
+
super("Incomplete service",t,r)}};var f=require("@ez4/common/library"),E=require("@ez4/reflection");var a=require("@ez4/common/library"),I=require("@ez4/reflection"),Qr=new Set(["A\
|
|
18
|
+
NY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),We=e=>{let[t]=e.split(" ",2);
|
|
19
|
+
return Qr.has(t)},Xe=e=>(0,a.isClassDeclaration)(e)&&(0,a.hasHeritageType)(e,"Ht\
|
|
20
|
+
tp.Service"),Ze=e=>(0,a.isModelDeclaration)(e)&&(0,a.hasHeritageType)(e,"Http.Ro\
|
|
21
|
+
ute");var _e=e=>(0,a.hasHeritageType)(e,"Http.Defaults"),$e=e=>(0,a.hasHeritageType)(e,
|
|
22
|
+
"Http.Headers"),Le=e=>(0,a.hasHeritageType)(e,"Http.Identity"),er=e=>(0,a.hasHeritageType)(
|
|
23
|
+
e,"Http.QueryStrings"),rr=e=>(0,a.hasHeritageType)(e,"Http.PathParameters"),tr=e=>(0,a.hasHeritageType)(
|
|
24
|
+
e,"Http.JsonBody"),or=e=>(0,a.hasHeritageType)(e,"Http.Cors"),nr=e=>(0,a.hasHeritageType)(
|
|
25
|
+
e,"Http.Cache"),pr=e=>(0,I.isTypeCallback)(e)||(0,I.isTypeFunction)(e),sr=e=>(0,I.isTypeCallback)(
|
|
26
|
+
e)||(0,I.isTypeFunction)(e);var h=require("@ez4/common/library"),ue=require("@ez4/utils"),b=require("@ez4/reflection");var fe=(e,t,r,o)=>{if(!(0,b.isTypeReference)(e))return ir(e,t,r,o);let n=(0,h.getReferenceType)(
|
|
27
|
+
e,r);return n?ir(n,t,r,o):null},ir=(e,t,r,o)=>(0,b.isTypeObject)(e)?Jr(e,t,(0,h.getObjectMembers)(
|
|
28
|
+
e),r,o):null,Jr=(e,t,r,o,n)=>{let p={};for(let s of r){if(!(0,b.isModelProperty)(
|
|
29
|
+
s)||s.inherited)continue;let i=parseInt(s.name,10);(0,ue.isAnyNumber)(i)||n.push(
|
|
30
|
+
new h.InvalidServicePropertyError(t.name,s.name,e.file));let c=Gr(s,i,t,o,n);c&&
|
|
31
|
+
Object.assign(p,c)}return(0,ue.isEmptyObject)(p)?null:p},Gr=(e,t,r,o,n)=>{let p=(0,h.getPropertyTuple)(
|
|
33
32
|
e)??[],s={};for(let i of p){if(!(0,b.isTypeReference)(i)){n.push(new A(r.file));
|
|
34
33
|
continue}let c=(0,h.getReferenceType)(i,o);if(!c||!(0,b.isTypeClass)(c)){n.push(
|
|
35
|
-
new A(r.file));continue}s[c.name]=t}return s};var
|
|
36
|
-
e,r);return n?
|
|
37
|
-
e),r,o):(0,f.isModelDeclaration)(e)
|
|
38
|
-
push(new B(e.name,t.file)),null):(o.push(new F(t.file)),null),
|
|
34
|
+
new A(r.file));continue}s[c.name]=t}return s};var mr=(e,t,r,o)=>{if(!(0,E.isTypeReference)(e))return cr(e,t,r,o);let n=(0,f.getReferenceType)(
|
|
35
|
+
e,r);return n?cr(n,t,r,o):null},cr=(e,t,r,o)=>(0,E.isTypeObject)(e)?lr(t,(0,f.getObjectMembers)(
|
|
36
|
+
e),r,o):(0,f.isModelDeclaration)(e)?_e(e)?lr(t,(0,f.getModelMembers)(e),r,o):(o.
|
|
37
|
+
push(new B(e.name,t.file)),null):(o.push(new F(t.file)),null),lr=(e,t,r,o)=>{let n={};
|
|
39
38
|
for(let p of t)if(!(!(0,E.isModelProperty)(p)||p.inherited))switch(p.name){default:
|
|
40
39
|
o.push(new f.InvalidServicePropertyError(e.name,p.name,e.file));break;case"httpE\
|
|
41
|
-
rrors":n.httpErrors=
|
|
40
|
+
rrors":n.httpErrors=fe(p.value,e,r,o);break;case"memory":case"logRetention":case"\
|
|
42
41
|
timeout":n[p.name]=(0,f.getPropertyNumber)(p);break;case"listener":n.listener=(0,f.getServiceListener)(
|
|
43
|
-
p.value,o);break}return n};var x=require("@ez4/reflection"),l=require("@ez4/common/library");var
|
|
44
|
-
super("Incomplete gateway route",t,r)}},A=class extends
|
|
45
|
-
super("Invalid route error type.",t)}};var
|
|
46
|
-
super("Incomplete route authorizer",t,r)}};var d=require("@ez4/common/library"),j=require("@ez4/reflection"),
|
|
47
|
-
super("Invalid route response",void 0,r,o);this.baseType=r}},Q=class extends
|
|
48
|
-
super("Incorrect route response",r,o,n);this.responseType=r;this.baseType=o}};var
|
|
49
|
-
super("Invalid
|
|
50
|
-
super("Incorrect
|
|
51
|
-
return r&&(0,
|
|
52
|
-
|
|
53
|
-
e
|
|
54
|
-
e)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
(0,
|
|
60
|
-
(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
e,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
e)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
e
|
|
80
|
-
e.name,n,e.file)),null):(o.push(new V(n,t.file)),null),gr=(e,t,r,o,n)=>{let p={};
|
|
42
|
+
p.value,o);break}return n};var x=require("@ez4/reflection"),l=require("@ez4/common/library");var ye=require("@ez4/common/library"),N=class extends ye.IncompleteTypeError{constructor(t,r){
|
|
43
|
+
super("Incomplete gateway route",t,r)}},A=class extends ye.TypeError{constructor(t){
|
|
44
|
+
super("Invalid route error type.",t)}};var ar=require("@ez4/common/library"),U=class extends ar.IncompleteTypeError{constructor(t,r){
|
|
45
|
+
super("Incomplete route authorizer",t,r)}};var d=require("@ez4/common/library"),j=require("@ez4/reflection"),gr=require("@ez4/utils");var de=require("@ez4/common/library"),V=class extends de.InvalidTypeError{constructor(r,o){
|
|
46
|
+
super("Invalid route response",void 0,r,o);this.baseType=r}},Q=class extends de.IncorrectTypeError{constructor(r,o,n){
|
|
47
|
+
super("Incorrect route response",r,o,n);this.responseType=r;this.baseType=o}};var H=require("@ez4/reflection"),Me=require("@ez4/common/library"),fr=require("@ez4/schema/library");var Te=require("@ez4/common/library"),J=class extends Te.InvalidTypeError{constructor(t){
|
|
48
|
+
super("Invalid identity",void 0,"Http.Identity",t)}},G=class extends Te.IncorrectTypeError{constructor(r,o){
|
|
49
|
+
super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}};var ge=require("@ez4/schema/library"),u=(e,t)=>{let r=(0,ge.getObjectSchema)(e,t);
|
|
50
|
+
return r&&(0,ge.isObjectSchema)(r)?r:null};var v=(e,t,r,o)=>{if((0,H.isTypeUndefined)(e))return null;if(!(0,H.isTypeReference)(
|
|
51
|
+
e))return ur(e,t,r,o);let n=(0,Me.getReferenceType)(e,r);return n?ur(n,t,r,o):null},
|
|
52
|
+
ur=(e,t,r,o)=>{if((0,H.isTypeUnion)(e))return Yr(e.elements,t,r,o);if((0,H.isTypeObject)(
|
|
53
|
+
e)||(0,H.isTypeIntersection)(e))return u(e,r);if(!(0,Me.isModelDeclaration)(e))return o.
|
|
54
|
+
push(new J(t.file)),null;if(!Le(e))return o.push(new G(e.name,t.file)),null;let n=u(
|
|
55
|
+
e,r);return n&&(n.definitions={...n.definitions,extensible:!0}),n},Yr=(e,t,r,o)=>{
|
|
56
|
+
let n=[];for(let p of e){let s=v(p,t,r,o);s&&n.push(s)}return n.length>1?(0,fr.createUnionSchema)(
|
|
57
|
+
{elements:n}):n[0]};var R=require("@ez4/reflection"),he=require("@ez4/common/library");var He=require("@ez4/common/library"),Y=class extends He.InvalidTypeError{constructor(t){
|
|
58
|
+
super("Invalid headers",void 0,"Http.Headers",t)}},K=class extends He.IncorrectTypeError{constructor(r,o){
|
|
59
|
+
super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}};var W=(e,t,r,o)=>{if(!(0,R.isTypeReference)(e))return yr(e,t,r,o);let n=(0,he.getReferenceType)(
|
|
60
|
+
e,r);return n?yr(n,t,r,o):null},yr=(e,t,r,o)=>(0,R.isTypeObject)(e)||(0,R.isTypeIntersection)(
|
|
61
|
+
e)?u(e,r):(0,he.isModelDeclaration)(e)?$e(e)?u(e,r):(o.push(new K(e.name,t.file)),
|
|
62
|
+
null):(o.push(new Y(t.file)),null);var P=require("@ez4/schema/library"),Se=require("@ez4/common/library"),y=require("@ez4/reflection");var be=require("@ez4/common/library"),X=class extends be.InvalidTypeError{constructor(t){
|
|
63
|
+
super("Invalid body",void 0,"Http.JsonBody",t)}},Z=class extends be.IncorrectTypeError{constructor(r,o){
|
|
64
|
+
super("Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}};var _=(e,t,r,o)=>Oe(e,r,n=>je(n)??we(n,t,r,o)),Oe=(e,t,r)=>{if((0,y.isTypeUndefined)(
|
|
65
|
+
e))return null;if(!(0,y.isTypeReference)(e))return r(e);let o=(0,Se.getReferenceType)(
|
|
66
|
+
e,t);return o?r(o):null},je=e=>(0,y.isTypeScalar)(e)?(0,P.getScalarSchema)(e):null,
|
|
67
|
+
we=(e,t,r,o)=>(0,y.isTypeUnion)(e)?Kr(e.elements,r,n=>je(n)??we(n,t,r,o)):(0,y.isTypeArray)(
|
|
68
|
+
e)?Wr(e.element,r,n=>je(n)??we(n,t,r,o)):(0,y.isTypeObject)(e)||(0,y.isTypeIntersection)(
|
|
69
|
+
e)?u(e,r):(0,Se.isModelDeclaration)(e)?tr(e)?u(e,r):(o.push(new Z(e.name,e.file)),
|
|
70
|
+
null):(o.push(new X(t.file)),null),Kr=(e,t,r)=>{let o=[];for(let n of e){let p=Oe(
|
|
71
|
+
n,t,r);p&&o.push(p)}return o.length?(0,P.createUnionSchema)({elements:o}):null},
|
|
72
|
+
Wr=(e,t,r)=>{let o=Oe(e,t,r);return o?(0,P.createArraySchema)({element:o}):null};var ze=(e,t,r,o)=>{let n=Mr(e,t,r,o,"Http.AuthResponse");return n&&Xr(n)?n:null},
|
|
73
|
+
Ce=(e,t,r,o)=>{let n=Mr(e,t,r,o,"Http.Response");return n&&Zr(n)?n:null},Mr=(e,t,r,o,n)=>{
|
|
74
|
+
if(!(0,j.isTypeReference)(e))return dr(e,t,r,o,n);let p=(0,d.getReferenceType)(e,
|
|
75
|
+
r);return p?dr(p,t,r,o,n):null},Xr=e=>!!e.identity,Zr=e=>(0,gr.isAnyNumber)(e.status),
|
|
76
|
+
dr=(e,t,r,o,n)=>(0,j.isTypeObject)(e)?Tr(e,t,(0,d.getObjectMembers)(e),r,o):(0,d.isModelDeclaration)(
|
|
77
|
+
e)?(0,d.hasHeritageType)(e,n)?Tr(e,t,(0,d.getModelMembers)(e),r,o):(o.push(new Q(
|
|
78
|
+
e.name,n,e.file)),null):(o.push(new V(n,t.file)),null),Tr=(e,t,r,o,n)=>{let p={};
|
|
81
79
|
for(let s of r)if(!(!(0,j.isModelProperty)(s)||s.inherited))switch(s.name){default:
|
|
82
80
|
n.push(new d.InvalidServicePropertyError(t.name,s.name,e.file));break;case"statu\
|
|
83
|
-
s":p.status=(0,d.getPropertyNumber)(s);break;case"headers":{p.headers=
|
|
81
|
+
s":p.status=(0,d.getPropertyNumber)(s);break;case"headers":{p.headers=W(s.value,
|
|
84
82
|
e,o,n),p.headers&&s.description&&(p.headers.description=s.description);break}case"\
|
|
85
|
-
identity":{p.identity=
|
|
86
|
-
s.description);break}case"body":{p.body=
|
|
87
|
-
(p.body.description=s.description);break}}return p};var S=require("@ez4/reflection"),g=require("@ez4/common/library");var
|
|
88
|
-
super("Invalid route request",void 0,r,o);this.baseType=r}}
|
|
89
|
-
super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}};var w=require("@ez4/reflection"),
|
|
90
|
-
super("Invalid request parameters",void 0,"Http.PathParameters",t)}},
|
|
83
|
+
identity":{p.identity=v(s.value,e,o,n),p.identity&&s.description&&(p.identity.description=
|
|
84
|
+
s.description);break}case"body":{p.body=_(s.value,e,o,n),p.body&&s.description&&
|
|
85
|
+
(p.body.description=s.description);break}}return p};var S=require("@ez4/reflection"),g=require("@ez4/common/library");var xe=require("@ez4/common/library"),$=class extends xe.InvalidTypeError{constructor(r,o){
|
|
86
|
+
super("Invalid route request",void 0,r,o);this.baseType=r}},L=class extends xe.IncorrectTypeError{constructor(r,o,n){
|
|
87
|
+
super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}};var w=require("@ez4/reflection"),Ae=require("@ez4/common/library");var Ie=require("@ez4/common/library"),ee=class extends Ie.InvalidTypeError{constructor(t){
|
|
88
|
+
super("Invalid request parameters",void 0,"Http.PathParameters",t)}},re=class extends Ie.IncorrectTypeError{constructor(r,o){
|
|
91
89
|
super("Incorrect request parameters",r,"Http.PathParameters",o);this.parametersType=
|
|
92
|
-
r}};var
|
|
93
|
-
e,r);return n?
|
|
94
|
-
e)?u(e,r):(0,
|
|
95
|
-
null):(o.push(new
|
|
96
|
-
super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},
|
|
90
|
+
r}};var ke=(e,t,r,o)=>{if(!(0,w.isTypeReference)(e))return Hr(e,t,r,o);let n=(0,Ae.getReferenceType)(
|
|
91
|
+
e,r);return n?Hr(n,t,r,o):null},Hr=(e,t,r,o)=>(0,w.isTypeObject)(e)||(0,w.isTypeIntersection)(
|
|
92
|
+
e)?u(e,r):(0,Ae.isModelDeclaration)(e)?rr(e)?u(e,r):(o.push(new re(e.name,e.file)),
|
|
93
|
+
null):(o.push(new ee(t.file)),null);var O=require("@ez4/reflection"),ve=require("@ez4/common/library");var Ee=require("@ez4/common/library"),te=class extends Ee.InvalidTypeError{constructor(t){
|
|
94
|
+
super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},oe=class extends Ee.IncorrectTypeError{constructor(r,o){
|
|
97
95
|
super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
|
|
98
|
-
r}};var
|
|
99
|
-
e,r);return n?
|
|
100
|
-
e)?u(e,r):(0,
|
|
101
|
-
null):(o.push(new
|
|
102
|
-
Request"),
|
|
103
|
-
e.elements[0],t,r,o,n);if(!(0,S.isTypeReference)(e))return
|
|
104
|
-
e,r);return p?
|
|
105
|
-
e),r,o):(0,g.isModelDeclaration)(e)?(0,g.hasHeritageType)(e,n)?
|
|
106
|
-
e),r,o):(o.push(new
|
|
96
|
+
r}};var qe=(e,t,r,o)=>{if(!(0,O.isTypeReference)(e))return hr(e,t,r,o);let n=(0,ve.getReferenceType)(
|
|
97
|
+
e,r);return n?hr(n,t,r,o):null},hr=(e,t,r,o)=>(0,O.isTypeObject)(e)||(0,O.isTypeIntersection)(
|
|
98
|
+
e)?u(e,r):(0,ve.isModelDeclaration)(e)?er(e)?u(e,r):(o.push(new oe(e.name,t.file)),
|
|
99
|
+
null):(o.push(new te(t.file)),null);var De=(e,t,r,o)=>Be(e,t,r,o,"Http.AuthRequest"),Fe=(e,t,r,o)=>Be(e,t,r,o,"Http.\
|
|
100
|
+
Request"),Be=(e,t,r,o,n)=>{if((0,S.isTypeIntersection)(e)&&e.elements.length>0)return Be(
|
|
101
|
+
e.elements[0],t,r,o,n);if(!(0,S.isTypeReference)(e))return br(e,t,r,o,n);let p=(0,g.getReferenceType)(
|
|
102
|
+
e,r);return p?br(p,t,r,o,n):null},br=(e,t,r,o,n)=>(0,S.isTypeObject)(e)?Sr(e,t,(0,g.getObjectMembers)(
|
|
103
|
+
e),r,o):(0,g.isModelDeclaration)(e)?(0,g.hasHeritageType)(e,n)?Sr(e,t,(0,g.getModelMembers)(
|
|
104
|
+
e),r,o):(o.push(new L(e.name,n,e.file)),null):(o.push(new $(n,t.file)),null),Sr=(e,t,r,o,n)=>{
|
|
107
105
|
let p={};for(let s of r)if(!(!(0,S.isModelProperty)(s)||s.inherited))switch(s.name){default:
|
|
108
106
|
n.push(new g.InvalidServicePropertyError(t.name,s.name,e.file));break;case"heade\
|
|
109
|
-
rs":{p.headers=
|
|
110
|
-
s.description);break}case"identity":{p.identity=
|
|
111
|
-
(p.identity.description=s.description);break}case"query":{p.query=
|
|
107
|
+
rs":{p.headers=W(s.value,e,o,n),p.headers&&s.description&&(p.headers.description=
|
|
108
|
+
s.description);break}case"identity":{p.identity=v(s.value,e,o,n),p.identity&&s.description&&
|
|
109
|
+
(p.identity.description=s.description);break}case"query":{p.query=qe(s.value,e,o,
|
|
112
110
|
n),p.query&&s.description&&(p.query.description=s.description);break}case"parame\
|
|
113
|
-
ters":{p.parameters=
|
|
114
|
-
description=s.description);break}case"body":{p.body=
|
|
115
|
-
|
|
111
|
+
ters":{p.parameters=ke(s.value,e,o,n),p.parameters&&s.description&&(p.parameters.
|
|
112
|
+
description=s.description);break}case"body":{p.body=_(s.value,e,o,n),p.body&&s.description&&
|
|
113
|
+
(p.body.description=s.description);break}}return p};var Ne=(e,t,r,o)=>{if(!pr(e))return null;let n={},p=new Set(["name","file"]);if(e.
|
|
116
114
|
description&&(n.description=e.description),(n.name=e.name)&&p.delete("name"),(n.
|
|
117
115
|
file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;n.request=
|
|
118
|
-
|
|
119
|
-
[...p],e.file)),null)}
|
|
120
|
-
super("Incomplete route handler",t,r)}};var
|
|
116
|
+
De(s,t,r,o)}return e.return&&(n.response=ze(e.return,t,r,o)),_r(n)?n:(o.push(new U(
|
|
117
|
+
[...p],e.file)),null)},_r=e=>!!e.name&&!!e.file;var xr=require("@ez4/common/library"),ne=class extends xr.IncompleteTypeError{constructor(t,r){
|
|
118
|
+
super("Incomplete route handler",t,r)}};var Ue=(e,t,r,o)=>{if(!sr(e))return null;let n={},p=new Set(["name","file","resp\
|
|
121
119
|
onse"]);if(e.description&&(n.description=e.description),(n.name=e.name)&&p.delete(
|
|
122
120
|
"name"),(n.file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;
|
|
123
|
-
n.request=
|
|
124
|
-
"response"))}return
|
|
125
|
-
!!e.file&&!!e.response;var
|
|
126
|
-
let n=[];for(let p of e){let s=
|
|
127
|
-
s)}return n},
|
|
128
|
-
e,r);return n?
|
|
129
|
-
|
|
130
|
-
e),r,o):(0,x.isTypeTuple)(e)&&e.spread?
|
|
121
|
+
n.request=Fe(s,t,r,o)}if(e.return){let s=Ce(e.return,t,r,o);s&&(n.response=s,p.delete(
|
|
122
|
+
"response"))}return $r(n)?n:(o.push(new ne([...p],e.file)),null)},$r=e=>!!e.name&&
|
|
123
|
+
!!e.file&&!!e.response;var Ve=(e,t,r,o)=>{let n=(0,l.getPropertyTuple)(t)??[];return Er(n,e,r,o)},Er=(e,t,r,o)=>{
|
|
124
|
+
let n=[];for(let p of e){let s=Lr(p,t,r,o);Array.isArray(s)?n.push(...s):s&&n.push(
|
|
125
|
+
s)}return n},Lr=(e,t,r,o)=>{if(!(0,x.isTypeReference)(e))return Ir(e,t,r,o);let n=(0,l.getReferenceType)(
|
|
126
|
+
e,r);return n?Ir(n,t,r,o):null},et=e=>!!e.path&&!!e.handler,Ir=(e,t,r,o)=>Ze(e)?
|
|
127
|
+
Ar(e,t,(0,l.getModelMembers)(e),r,o):(0,x.isTypeObject)(e)?Ar(e,t,(0,l.getObjectMembers)(
|
|
128
|
+
e),r,o):(0,x.isTypeTuple)(e)&&e.spread?Er(e.elements,t,r,o):null,Ar=(e,t,r,o,n)=>{
|
|
131
129
|
let p={},s=new Set(["path","handler"]);for(let i of r)if(!(!(0,x.isModelProperty)(
|
|
132
130
|
i)||i.inherited))switch(i.name){default:n.push(new l.InvalidServicePropertyError(
|
|
133
|
-
t.name,i.name,e.file));break;case"path":{let c=(0,l.getPropertyString)(i);c&&
|
|
134
|
-
c)&&(s.delete(i.name),p.path=c);break}case"handler":(p.handler=
|
|
135
|
-
s.delete(i.name);break;case"authorizer":p.authorizer=
|
|
136
|
-
httpErrors":p.httpErrors=
|
|
131
|
+
t.name,i.name,e.file));break;case"path":{let c=(0,l.getPropertyString)(i);c&&We(
|
|
132
|
+
c)&&(s.delete(i.name),p.path=c);break}case"handler":(p.handler=Ue(i.value,t,o,n))&&
|
|
133
|
+
s.delete(i.name);break;case"authorizer":p.authorizer=Ne(i.value,t,o,n);break;case"\
|
|
134
|
+
httpErrors":p.httpErrors=fe(i.value,t,o,n);break;case"memory":case"logRetention":case"\
|
|
137
135
|
timeout":p[i.name]=(0,l.getPropertyNumber)(i);break;case"cors":p.cors=(0,l.getPropertyBoolean)(
|
|
138
136
|
i);break;case"listener":p.listener=(0,l.getServiceListener)(i.value,n);break;case"\
|
|
139
|
-
variables":p.variables=(0,l.getLinkedVariableList)(i,n);break}return
|
|
140
|
-
push(new N([...s],e.file)),null)};var m=require("@ez4/common/library"),C=require("@ez4/reflection");var z=require("@ez4/common/library"),
|
|
141
|
-
super("Incomplete HTTP CORS",t,r)}},
|
|
142
|
-
super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},
|
|
143
|
-
super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}};var
|
|
144
|
-
e,r);return n?
|
|
145
|
-
e)?
|
|
146
|
-
(0,m.getModelMembers)(e),r):(r.push(new
|
|
147
|
-
t.file)),null),
|
|
137
|
+
variables":p.variables=(0,l.getLinkedVariableList)(i,n);break}return et(p)?p:(n.
|
|
138
|
+
push(new N([...s],e.file)),null)};var m=require("@ez4/common/library"),C=require("@ez4/reflection");var z=require("@ez4/common/library"),pe=class extends z.IncompleteTypeError{constructor(t,r){
|
|
139
|
+
super("Incomplete HTTP CORS",t,r)}},se=class extends z.InvalidTypeError{constructor(t){
|
|
140
|
+
super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},ie=class extends z.IncorrectTypeError{constructor(r,o){
|
|
141
|
+
super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}};var Qe=(e,t,r,o)=>{if(!(0,C.isTypeReference)(e))return vr(e,t,o);let n=(0,m.getReferenceType)(
|
|
142
|
+
e,r);return n?vr(n,t,o):null},rt=e=>!!e.allowOrigins?.length,vr=(e,t,r)=>(0,C.isTypeObject)(
|
|
143
|
+
e)?Rr(e,t,(0,m.getObjectMembers)(e),r):(0,m.isModelDeclaration)(e)?or(e)?Rr(e,t,
|
|
144
|
+
(0,m.getModelMembers)(e),r):(r.push(new ie(e.name,e.file)),null):(r.push(new se(
|
|
145
|
+
t.file)),null),Rr=(e,t,r,o)=>{let n={},p=new Set(["allowOrigins"]);for(let s of r)
|
|
148
146
|
if(!(!(0,C.isModelProperty)(s)||s.inherited))switch(s.name){default:o.push(new m.InvalidServicePropertyError(
|
|
149
147
|
t.name,s.name,e.file));break;case"allowOrigins":case"allowMethods":case"allowHea\
|
|
150
148
|
ders":case"exposeHeaders":n[s.name]=(0,m.getPropertyStringList)(s);break;case"al\
|
|
151
149
|
lowCredentials":n.allowCredentials=(0,m.getPropertyBoolean)(s);break;case"maxAge":
|
|
152
|
-
n.maxAge=(0,m.getPropertyNumber)(s);break}return
|
|
153
|
-
file)),null)};var M=require("@ez4/common/library"),q=require("@ez4/reflection"),
|
|
154
|
-
super("Incomplete gateway cache",t,r)}},
|
|
155
|
-
super("Invalid gateway cache type",void 0,"Http.Cache",t)}},
|
|
156
|
-
super("Incorrect gateway cache type",r,"Http.Cache",o);this.cacheType=r}};var
|
|
157
|
-
e,r);return n?
|
|
158
|
-
e)?
|
|
159
|
-
(0,M.getModelMembers)(e),r):(r.push(new
|
|
160
|
-
t.file)),null),
|
|
150
|
+
n.maxAge=(0,m.getPropertyNumber)(s);break}return rt(n)?n:(o.push(new pe([...p],e.
|
|
151
|
+
file)),null)};var M=require("@ez4/common/library"),q=require("@ez4/reflection"),Je=require("@ez4/utils");var k=require("@ez4/common/library"),ce=class extends k.IncompleteTypeError{constructor(t,r){
|
|
152
|
+
super("Incomplete gateway cache",t,r)}},le=class extends k.InvalidTypeError{constructor(t){
|
|
153
|
+
super("Invalid gateway cache type",void 0,"Http.Cache",t)}},me=class extends k.IncorrectTypeError{constructor(r,o){
|
|
154
|
+
super("Incorrect gateway cache type",r,"Http.Cache",o);this.cacheType=r}};var Ge=(e,t,r,o)=>{if(!(0,q.isTypeReference)(e))return Pr(e,t,o);let n=(0,M.getReferenceType)(
|
|
155
|
+
e,r);return n?Pr(n,t,o):null},tt=e=>(0,Je.isAnyNumber)(e.authorizerTTL),Pr=(e,t,r)=>(0,q.isTypeObject)(
|
|
156
|
+
e)?jr(e,t,(0,M.getObjectMembers)(e),r):(0,M.isModelDeclaration)(e)?nr(e)?jr(e,t,
|
|
157
|
+
(0,M.getModelMembers)(e),r):(r.push(new me(e.name,e.file)),null):(r.push(new le(
|
|
158
|
+
t.file)),null),jr=(e,t,r,o)=>{let n={},p=new Set(["authorizerTTL"]);for(let s of r)
|
|
161
159
|
if(!(!(0,q.isModelProperty)(s)||s.inherited))switch(s.name){default:o.push(new M.InvalidServicePropertyError(
|
|
162
160
|
t.name,s.name,e.file));break;case"authorizerTTL":{let i=(0,M.getPropertyNumber)(
|
|
163
|
-
s);(0,
|
|
164
|
-
push(new
|
|
165
|
-
n))continue;let p={type:
|
|
161
|
+
s);(0,Je.isAnyNumber)(i)&&(n[s.name]=i,p.delete(s.name));break}}return tt(n)?n:(o.
|
|
162
|
+
push(new ce([...p],e.file)),null)};var Ye=e=>{let t={},r=[];for(let o in e){let n=e[o];if(!Xe(n)||(0,T.isExternalDeclaration)(
|
|
163
|
+
n))continue;let p={type:ae,extras:{}},s=new Set(["routes"]),i=n.file;p.name=n.name,
|
|
166
164
|
n.description&&(p.description=n.description);for(let c of(0,T.getModelMembers)(n))
|
|
167
|
-
if(!(!(0,
|
|
168
|
-
p.name,c.name,i));break;case"routes":(p.routes=
|
|
169
|
-
name":p.displayName=(0,T.getPropertyString)(c);break;case"defaults":p.defaults=
|
|
170
|
-
c.value,n,e,r);break;case"cache":p.cache=
|
|
171
|
-
|
|
172
|
-
c,r);break;case"services":p.services=(0,T.getLinkedServiceList)(c,e,r);break}if(!
|
|
165
|
+
if(!(!(0,wr.isModelProperty)(c)||c.inherited))switch(c.name){default:r.push(new T.InvalidServicePropertyError(
|
|
166
|
+
p.name,c.name,i));break;case"routes":(p.routes=Ve(n,c,e,r))&&s.delete(c.name);break;case"\
|
|
167
|
+
name":p.displayName=(0,T.getPropertyString)(c);break;case"defaults":p.defaults=mr(
|
|
168
|
+
c.value,n,e,r);break;case"cache":p.cache=Ge(c.value,n,e,r);break;case"cors":p.cors=
|
|
169
|
+
Qe(c.value,n,e,r);break;case"variables":p.variables=(0,T.getLinkedVariableList)(
|
|
170
|
+
c,r);break;case"services":p.services=(0,T.getLinkedServiceList)(c,e,r);break}if(!ot(
|
|
173
171
|
p)){r.push(new D([...s],i));continue}if(t[n.name]){r.push(new T.DuplicateServiceError(
|
|
174
|
-
n.name,i));continue}t[n.name]=p}return{services:t,errors:r}},
|
|
175
|
-
routes&&!!e.extras;var
|
|
176
|
-
"@ez4/gateway",{"metadata:getServices":
|
|
177
|
-
super("Invalid defaults",void 0,"Http.Defaults",t)}},B=class extends
|
|
172
|
+
n.name,i));continue}t[n.name]=p}return{services:t,errors:r}},ot=e=>!!e.name&&!!e.
|
|
173
|
+
routes&&!!e.extras;var Or=!1,nt=()=>{Or||((0,zr.registerTriggers)(),(0,Cr.registerTriggers)(),(0,kr.createTrigger)(
|
|
174
|
+
"@ez4/gateway",{"metadata:getServices":Ye}),Or=!1)};var Re=require("@ez4/common/library"),F=class extends Re.InvalidTypeError{constructor(t){
|
|
175
|
+
super("Invalid defaults",void 0,"Http.Defaults",t)}},B=class extends Re.IncorrectTypeError{constructor(r,o){
|
|
178
176
|
super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}};0&&(module.exports={IncompleteAuthorizerError,IncompleteCacheError,IncompleteCorsError,
|
|
179
177
|
IncompleteHandlerError,IncompleteRouteError,IncompleteServiceError,IncorrectBodyTypeError,
|
|
180
178
|
IncorrectCacheTypeError,IncorrectCorsTypeError,IncorrectDefaultsTypeError,IncorrectHeadersTypeError,
|
|
@@ -182,8 +180,8 @@ IncorrectIdentityTypeError,IncorrectParameterTypeError,IncorrectQueryTypeError,I
|
|
|
182
180
|
IncorrectResponseTypeError,InvalidBodyTypeError,InvalidCacheTypeError,InvalidCorsTypeError,
|
|
183
181
|
InvalidDefaultsTypeError,InvalidHeadersTypeError,InvalidIdentityTypeError,InvalidParameterTypeError,
|
|
184
182
|
InvalidQueryTypeError,InvalidRequestTypeError,InvalidResponseTypeError,InvalidRouteErrorTypeError,
|
|
185
|
-
ServiceType,getHttpAuthRequest,getHttpAuthResponse,getHttpAuthorizer,
|
|
186
|
-
getHttpCors,getHttpHandler,getHttpHandlerRequest,getHttpHandlerResponse,
|
|
187
|
-
getHttpIdentity,getHttpParameters,getHttpQuery,
|
|
188
|
-
|
|
183
|
+
ServiceType,getHttpAuthRequest,getHttpAuthResponse,getHttpAuthorizer,getHttpBody,
|
|
184
|
+
getHttpCache,getHttpCors,getHttpHandler,getHttpHandlerRequest,getHttpHandlerResponse,
|
|
185
|
+
getHttpHeaders,getHttpIdentity,getHttpParameters,getHttpQuery,getHttpRoutes,getHttpServices,
|
|
186
|
+
isHttpService,registerTriggers});
|
|
189
187
|
//# sourceMappingURL=library.cjs.map
|
package/dist/library.mjs
CHANGED
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
import{registerTriggers as
|
|
2
|
-
import{createTrigger as
|
|
3
|
-
getLinkedVariableList as
|
|
4
|
-
import{isModelProperty as
|
|
5
|
-
super("Incomplete service",t,r)}};import{InvalidServicePropertyError as
|
|
6
|
-
getObjectMembers as
|
|
7
|
-
import{isModelProperty as
|
|
8
|
-
import{isTypeCallback as
|
|
9
|
-
["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),
|
|
10
|
-
2);return
|
|
11
|
-
|
|
12
|
-
JsonBody"),
|
|
13
|
-
e)||
|
|
14
|
-
getReferenceType as
|
|
15
|
-
import{isModelProperty as
|
|
16
|
-
null},
|
|
17
|
-
if(!
|
|
18
|
-
name,s.name,e.file));let c=
|
|
19
|
-
p},
|
|
20
|
-
r.file));continue}let c=
|
|
21
|
-
name]=t}return s};var
|
|
22
|
-
o):null},
|
|
23
|
-
new T(e.name,t.file)),null):(o.push(new d(t.file)),null),
|
|
24
|
-
for(let p of t)if(!(!
|
|
1
|
+
import{registerTriggers as Qo}from"@ez4/common/library";import{registerTriggers as Jo}from"@ez4/schema/library";
|
|
2
|
+
import{createTrigger as Go}from"@ez4/project/library";import{DuplicateServiceError as Co,isExternalDeclaration as ko,getLinkedServiceList as qo,
|
|
3
|
+
getLinkedVariableList as Do,getModelMembers as Fo,getPropertyString as Bo,InvalidServicePropertyError as No}from"@ez4/common/library";
|
|
4
|
+
import{isModelProperty as Uo}from"@ez4/reflection";var V="@ez4/http",Wo=e=>e.type===V;import{IncompleteTypeError as Je}from"@ez4/common/library";var f=class extends Je{constructor(t,r){
|
|
5
|
+
super("Incomplete service",t,r)}};import{InvalidServicePropertyError as nr,isModelDeclaration as pr,getPropertyNumber as sr,
|
|
6
|
+
getObjectMembers as ir,getModelMembers as cr,getServiceListener as lr,getReferenceType as mr}from"@ez4/common/library";
|
|
7
|
+
import{isModelProperty as ar,isTypeObject as ur,isTypeReference as fr}from"@ez4/reflection";import{hasHeritageType as m,isClassDeclaration as Ge,isModelDeclaration as Ye}from"@ez4/common/library";
|
|
8
|
+
import{isTypeCallback as K,isTypeFunction as W}from"@ez4/reflection";var Ke=new Set(
|
|
9
|
+
["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),X=e=>{let[t]=e.split(" ",
|
|
10
|
+
2);return Ke.has(t)},Z=e=>Ge(e)&&m(e,"Http.Service"),_=e=>Ye(e)&&m(e,"Http.Route");var $=e=>m(e,"Http.Defaults"),L=e=>m(e,"Http.Headers"),ee=e=>m(e,"Http.Identity"),
|
|
11
|
+
re=e=>m(e,"Http.QueryStrings"),te=e=>m(e,"Http.PathParameters"),oe=e=>m(e,"Http.\
|
|
12
|
+
JsonBody"),ne=e=>m(e,"Http.Cors"),pe=e=>m(e,"Http.Cache"),se=e=>K(e)||W(e),ie=e=>K(
|
|
13
|
+
e)||W(e);import{InvalidServicePropertyError as We,getObjectMembers as Xe,getPropertyTuple as Ze,
|
|
14
|
+
getReferenceType as le}from"@ez4/common/library";import{isAnyNumber as _e,isEmptyObject as $e}from"@ez4/utils";
|
|
15
|
+
import{isModelProperty as Le,isTypeClass as er,isTypeObject as rr,isTypeReference as me}from"@ez4/reflection";var y=(e,t,r,o)=>{if(!me(e))return ce(e,t,r,o);let n=le(e,r);return n?ce(n,t,r,o):
|
|
16
|
+
null},ce=(e,t,r,o)=>rr(e)?tr(e,t,Xe(e),r,o):null,tr=(e,t,r,o,n)=>{let p={};for(let s of r){
|
|
17
|
+
if(!Le(s)||s.inherited)continue;let i=parseInt(s.name,10);_e(i)||n.push(new We(t.
|
|
18
|
+
name,s.name,e.file));let c=or(s,i,t,o,n);c&&Object.assign(p,c)}return $e(p)?null:
|
|
19
|
+
p},or=(e,t,r,o,n)=>{let p=Ze(e)??[],s={};for(let i of p){if(!me(i)){n.push(new a(
|
|
20
|
+
r.file));continue}let c=le(i,o);if(!c||!er(c)){n.push(new a(r.file));continue}s[c.
|
|
21
|
+
name]=t}return s};var fe=(e,t,r,o)=>{if(!fr(e))return ae(e,t,r,o);let n=mr(e,r);return n?ae(n,t,r,
|
|
22
|
+
o):null},ae=(e,t,r,o)=>ur(e)?ue(t,ir(e),r,o):pr(e)?$(e)?ue(t,cr(e),r,o):(o.push(
|
|
23
|
+
new T(e.name,t.file)),null):(o.push(new d(t.file)),null),ue=(e,t,r,o)=>{let n={};
|
|
24
|
+
for(let p of t)if(!(!ar(p)||p.inherited))switch(p.name){default:o.push(new nr(e.
|
|
25
25
|
name,p.name,e.file));break;case"httpErrors":n.httpErrors=y(p.value,e,r,o);break;case"\
|
|
26
|
-
memory":case"logRetention":case"timeout":n[p.name]=
|
|
27
|
-
listener=
|
|
28
|
-
import{InvalidServicePropertyError as
|
|
29
|
-
getPropertyNumber as
|
|
30
|
-
getServiceListener as
|
|
31
|
-
super("Incomplete gateway route",t,r)}},a=class extends
|
|
32
|
-
"Invalid route error type.",t)}};import{IncompleteTypeError as
|
|
33
|
-
super("Incomplete route authorizer",t,r)}};import{InvalidServicePropertyError as
|
|
34
|
-
getModelMembers as
|
|
35
|
-
import{isModelProperty as
|
|
36
|
-
import{isAnyNumber as
|
|
37
|
-
var H=class extends
|
|
38
|
-
o);this.baseType=r}},h=class extends
|
|
39
|
-
e response",r,o,n);this.responseType=r;this.baseType=o}};import{
|
|
40
|
-
import{getReferenceType as
|
|
41
|
-
import{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
null},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if(!
|
|
71
|
-
identity,
|
|
72
|
-
|
|
73
|
-
null),
|
|
74
|
-
name){default:n.push(new
|
|
75
|
-
s);break;case"headers":{p.headers=
|
|
26
|
+
memory":case"logRetention":case"timeout":n[p.name]=sr(p);break;case"listener":n.
|
|
27
|
+
listener=lr(p.value,o);break}return n};import{isModelProperty as Qt,isTypeObject as Jt,isTypeReference as Gt,isTypeTuple as Yt}from"@ez4/reflection";
|
|
28
|
+
import{InvalidServicePropertyError as Kt,getLinkedVariableList as Wt,getPropertyBoolean as Xt,
|
|
29
|
+
getPropertyNumber as Zt,getPropertyString as _t,getObjectMembers as $t,getModelMembers as Lt,
|
|
30
|
+
getServiceListener as eo,getReferenceType as ro,getPropertyTuple as to}from"@ez4/common/library";import{IncompleteTypeError as yr,TypeError as dr}from"@ez4/common/library";var g=class extends yr{constructor(t,r){
|
|
31
|
+
super("Incomplete gateway route",t,r)}},a=class extends dr{constructor(t){super(
|
|
32
|
+
"Invalid route error type.",t)}};import{IncompleteTypeError as Tr}from"@ez4/common/library";var M=class extends Tr{constructor(t,r){
|
|
33
|
+
super("Incomplete route authorizer",t,r)}};import{InvalidServicePropertyError as rt,isModelDeclaration as tt,hasHeritageType as ot,
|
|
34
|
+
getModelMembers as nt,getObjectMembers as pt,getPropertyNumber as st,getReferenceType as it}from"@ez4/common/library";
|
|
35
|
+
import{isModelProperty as ct,isTypeObject as lt,isTypeReference as mt}from"@ez4/reflection";
|
|
36
|
+
import{isAnyNumber as at}from"@ez4/utils";import{IncorrectTypeError as gr,InvalidTypeError as Mr}from"@ez4/common/library";
|
|
37
|
+
var H=class extends Mr{constructor(r,o){super("Invalid route response",void 0,r,
|
|
38
|
+
o);this.baseType=r}},h=class extends gr{constructor(r,o,n){super("Incorrect rout\
|
|
39
|
+
e response",r,o,n);this.responseType=r;this.baseType=o}};import{isTypeIntersection as xr,isTypeObject as Ir,isTypeReference as Ar,isTypeUndefined as Er,
|
|
40
|
+
isTypeUnion as vr}from"@ez4/reflection";import{getReferenceType as Rr,isModelDeclaration as Pr}from"@ez4/common/library";
|
|
41
|
+
import{createUnionSchema as jr}from"@ez4/schema/library";import{IncorrectTypeError as Hr,InvalidTypeError as hr}from"@ez4/common/library";
|
|
42
|
+
var b=class extends hr{constructor(t){super("Invalid identity",void 0,"Http.Iden\
|
|
43
|
+
tity",t)}},S=class extends Hr{constructor(r,o){super("Incorrect identity",r,"Htt\
|
|
44
|
+
p.Identity",o);this.identityType=r}};import{getObjectSchema as br,isObjectSchema as Sr}from"@ez4/schema/library";var l=(e,t)=>{
|
|
45
|
+
let r=br(e,t);return r&&Sr(r)?r:null};var u=(e,t,r,o)=>{if(Er(e))return null;if(!Ar(e))return ye(e,t,r,o);let n=Rr(e,r);
|
|
46
|
+
return n?ye(n,t,r,o):null},ye=(e,t,r,o)=>{if(vr(e))return wr(e.elements,t,r,o);if(Ir(
|
|
47
|
+
e)||xr(e))return l(e,r);if(!Pr(e))return o.push(new b(t.file)),null;if(!ee(e))return o.
|
|
48
|
+
push(new S(e.name,t.file)),null;let n=l(e,r);return n&&(n.definitions={...n.definitions,
|
|
49
|
+
extensible:!0}),n},wr=(e,t,r,o)=>{let n=[];for(let p of e){let s=u(p,t,r,o);s&&n.
|
|
50
|
+
push(s)}return n.length>1?jr({elements:n}):n[0]};import{isTypeIntersection as Cr,isTypeObject as kr,isTypeReference as qr}from"@ez4/reflection";
|
|
51
|
+
import{getReferenceType as Dr,isModelDeclaration as Fr}from"@ez4/common/library";import{IncorrectTypeError as Or,InvalidTypeError as zr}from"@ez4/common/library";
|
|
52
|
+
var x=class extends zr{constructor(t){super("Invalid headers",void 0,"Http.Heade\
|
|
53
|
+
rs",t)}},I=class extends Or{constructor(r,o){super("Incorrect headers",r,"Http.H\
|
|
54
|
+
eaders",o);this.headersType=r}};var A=(e,t,r,o)=>{if(!qr(e))return de(e,t,r,o);let n=Dr(e,r);return n?de(n,t,r,o):
|
|
55
|
+
null},de=(e,t,r,o)=>kr(e)||Cr(e)?l(e,r):Fr(e)?L(e)?l(e,r):(o.push(new I(e.name,t.
|
|
56
|
+
file)),null):(o.push(new x(t.file)),null);import{createUnionSchema as Ur,getScalarSchema as Vr,createArraySchema as Qr}from"@ez4/schema/library";
|
|
57
|
+
import{getReferenceType as Jr,isModelDeclaration as Gr}from"@ez4/common/library";
|
|
58
|
+
import{isTypeArray as Yr,isTypeIntersection as Kr,isTypeObject as Wr,isTypeReference as Xr,
|
|
59
|
+
isTypeScalar as Zr,isTypeUndefined as _r,isTypeUnion as $r}from"@ez4/reflection";import{IncorrectTypeError as Br,InvalidTypeError as Nr}from"@ez4/common/library";
|
|
60
|
+
var E=class extends Nr{constructor(t){super("Invalid body",void 0,"Http.JsonBody",
|
|
61
|
+
t)}},v=class extends Br{constructor(r,o){super("Incorrect body",r,"Http.JsonBody",
|
|
62
|
+
o);this.bodyType=r}};var R=(e,t,r,o)=>G(e,r,n=>Q(n)??J(n,t,r,o)),G=(e,t,r)=>{if(_r(e))return null;if(!Xr(
|
|
63
|
+
e))return r(e);let o=Jr(e,t);return o?r(o):null},Q=e=>Zr(e)?Vr(e):null,J=(e,t,r,o)=>$r(
|
|
64
|
+
e)?Lr(e.elements,r,n=>Q(n)??J(n,t,r,o)):Yr(e)?et(e.element,r,n=>Q(n)??J(n,t,r,o)):
|
|
65
|
+
Wr(e)||Kr(e)?l(e,r):Gr(e)?oe(e)?l(e,r):(o.push(new v(e.name,e.file)),null):(o.push(
|
|
66
|
+
new E(t.file)),null),Lr=(e,t,r)=>{let o=[];for(let n of e){let p=G(n,t,r);p&&o.push(
|
|
67
|
+
p)}return o.length?Ur({elements:o}):null},et=(e,t,r)=>{let o=G(e,t,r);return o?Qr(
|
|
68
|
+
{element:o}):null};var Me=(e,t,r,o)=>{let n=he(e,t,r,o,"Http.AuthResponse");return n&&ut(n)?n:null},
|
|
69
|
+
He=(e,t,r,o)=>{let n=he(e,t,r,o,"Http.Response");return n&&ft(n)?n:null},he=(e,t,r,o,n)=>{
|
|
70
|
+
if(!mt(e))return Te(e,t,r,o,n);let p=it(e,r);return p?Te(p,t,r,o,n):null},ut=e=>!!e.
|
|
71
|
+
identity,ft=e=>at(e.status),Te=(e,t,r,o,n)=>lt(e)?ge(e,t,pt(e),r,o):tt(e)?ot(e,n)?
|
|
72
|
+
ge(e,t,nt(e),r,o):(o.push(new h(e.name,n,e.file)),null):(o.push(new H(n,t.file)),
|
|
73
|
+
null),ge=(e,t,r,o,n)=>{let p={};for(let s of r)if(!(!ct(s)||s.inherited))switch(s.
|
|
74
|
+
name){default:n.push(new rt(t.name,s.name,e.file));break;case"status":p.status=st(
|
|
75
|
+
s);break;case"headers":{p.headers=A(s.value,e,o,n),p.headers&&s.description&&(p.
|
|
76
76
|
headers.description=s.description);break}case"identity":{p.identity=u(s.value,e,
|
|
77
77
|
o,n),p.identity&&s.description&&(p.identity.description=s.description);break}case"\
|
|
78
|
-
body":{p.body=
|
|
79
|
-
break}}return p};import{isModelProperty as
|
|
80
|
-
import{InvalidServicePropertyError as
|
|
81
|
-
getObjectMembers as
|
|
82
|
-
var
|
|
83
|
-
this.baseType=r}},
|
|
84
|
-
equest",r,o,n);this.requestType=r;this.baseType=o}};import{isTypeIntersection as
|
|
85
|
-
import{getReferenceType as
|
|
86
|
-
var
|
|
87
|
-
"Http.PathParameters",t)}},
|
|
88
|
-
request parameters",r,"Http.PathParameters",o);this.parametersType=r}};var
|
|
89
|
-
o):null},
|
|
90
|
-
e.file)),null):(o.push(new
|
|
91
|
-
import{getReferenceType as
|
|
92
|
-
var
|
|
93
|
-
"Http.QueryStrings",t)}},
|
|
94
|
-
quest query strings",r,"Http.QueryStrings",o);this.queryType=r}};var
|
|
95
|
-
o):null},
|
|
96
|
-
t.file)),null):(o.push(new
|
|
97
|
-
quest"),
|
|
98
|
-
o,n);if(!
|
|
99
|
-
e)?
|
|
100
|
-
null):(o.push(new
|
|
101
|
-
s)||s.inherited))switch(s.name){default:n.push(new
|
|
102
|
-
headers":{p.headers=
|
|
78
|
+
body":{p.body=R(s.value,e,o,n),p.body&&s.description&&(p.body.description=s.description);
|
|
79
|
+
break}}return p};import{isModelProperty as jt,isTypeIntersection as wt,isTypeObject as Ot,isTypeReference as zt}from"@ez4/reflection";
|
|
80
|
+
import{InvalidServicePropertyError as Ct,isModelDeclaration as kt,hasHeritageType as qt,
|
|
81
|
+
getObjectMembers as Dt,getModelMembers as Ft,getReferenceType as Bt}from"@ez4/common/library";import{IncorrectTypeError as yt,InvalidTypeError as dt}from"@ez4/common/library";
|
|
82
|
+
var P=class extends dt{constructor(r,o){super("Invalid route request",void 0,r,o);
|
|
83
|
+
this.baseType=r}},j=class extends yt{constructor(r,o,n){super("Incorrect route r\
|
|
84
|
+
equest",r,o,n);this.requestType=r;this.baseType=o}};import{isTypeIntersection as Mt,isTypeObject as Ht,isTypeReference as ht}from"@ez4/reflection";
|
|
85
|
+
import{getReferenceType as bt,isModelDeclaration as St}from"@ez4/common/library";import{IncorrectTypeError as Tt,InvalidTypeError as gt}from"@ez4/common/library";
|
|
86
|
+
var w=class extends gt{constructor(t){super("Invalid request parameters",void 0,
|
|
87
|
+
"Http.PathParameters",t)}},O=class extends Tt{constructor(r,o){super("Incorrect \
|
|
88
|
+
request parameters",r,"Http.PathParameters",o);this.parametersType=r}};var Se=(e,t,r,o)=>{if(!ht(e))return be(e,t,r,o);let n=bt(e,r);return n?be(n,t,r,
|
|
89
|
+
o):null},be=(e,t,r,o)=>Ht(e)||Mt(e)?l(e,r):St(e)?te(e)?l(e,r):(o.push(new O(e.name,
|
|
90
|
+
e.file)),null):(o.push(new w(t.file)),null);import{isTypeIntersection as At,isTypeObject as Et,isTypeReference as vt}from"@ez4/reflection";
|
|
91
|
+
import{getReferenceType as Rt,isModelDeclaration as Pt}from"@ez4/common/library";import{IncorrectTypeError as xt,InvalidTypeError as It}from"@ez4/common/library";
|
|
92
|
+
var z=class extends It{constructor(t){super("Invalid request query strings",void 0,
|
|
93
|
+
"Http.QueryStrings",t)}},C=class extends xt{constructor(r,o){super("Incorrect re\
|
|
94
|
+
quest query strings",r,"Http.QueryStrings",o);this.queryType=r}};var Ie=(e,t,r,o)=>{if(!vt(e))return xe(e,t,r,o);let n=Rt(e,r);return n?xe(n,t,r,
|
|
95
|
+
o):null},xe=(e,t,r,o)=>Et(e)||At(e)?l(e,r):Pt(e)?re(e)?l(e,r):(o.push(new C(e.name,
|
|
96
|
+
t.file)),null):(o.push(new z(t.file)),null);var ve=(e,t,r,o)=>Y(e,t,r,o,"Http.AuthRequest"),Re=(e,t,r,o)=>Y(e,t,r,o,"Http.Re\
|
|
97
|
+
quest"),Y=(e,t,r,o,n)=>{if(wt(e)&&e.elements.length>0)return Y(e.elements[0],t,r,
|
|
98
|
+
o,n);if(!zt(e))return Ae(e,t,r,o,n);let p=Bt(e,r);return p?Ae(p,t,r,o,n):null},Ae=(e,t,r,o,n)=>Ot(
|
|
99
|
+
e)?Ee(e,t,Dt(e),r,o):kt(e)?qt(e,n)?Ee(e,t,Ft(e),r,o):(o.push(new j(e.name,n,e.file)),
|
|
100
|
+
null):(o.push(new P(n,t.file)),null),Ee=(e,t,r,o,n)=>{let p={};for(let s of r)if(!(!jt(
|
|
101
|
+
s)||s.inherited))switch(s.name){default:n.push(new Ct(t.name,s.name,e.file));break;case"\
|
|
102
|
+
headers":{p.headers=A(s.value,e,o,n),p.headers&&s.description&&(p.headers.description=
|
|
103
103
|
s.description);break}case"identity":{p.identity=u(s.value,e,o,n),p.identity&&s.description&&
|
|
104
|
-
(p.identity.description=s.description);break}case"query":{p.query=
|
|
104
|
+
(p.identity.description=s.description);break}case"query":{p.query=Ie(s.value,e,o,
|
|
105
105
|
n),p.query&&s.description&&(p.query.description=s.description);break}case"parame\
|
|
106
|
-
ters":{p.parameters=
|
|
107
|
-
description=s.description);break}case"body":{p.body=
|
|
108
|
-
|
|
106
|
+
ters":{p.parameters=Se(s.value,e,o,n),p.parameters&&s.description&&(p.parameters.
|
|
107
|
+
description=s.description);break}case"body":{p.body=R(s.value,e,o,n),p.body&&s.description&&
|
|
108
|
+
(p.body.description=s.description);break}}return p};var Pe=(e,t,r,o)=>{if(!se(e))return null;let n={},p=new Set(["name","file"]);if(e.
|
|
109
109
|
description&&(n.description=e.description),(n.name=e.name)&&p.delete("name"),(n.
|
|
110
110
|
file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;n.request=
|
|
111
|
-
|
|
112
|
-
[...p],e.file)),null)},
|
|
113
|
-
super("Incomplete route handler",t,r)}};var
|
|
111
|
+
ve(s,t,r,o)}return e.return&&(n.response=Me(e.return,t,r,o)),Nt(n)?n:(o.push(new M(
|
|
112
|
+
[...p],e.file)),null)},Nt=e=>!!e.name&&!!e.file;import{IncompleteTypeError as Ut}from"@ez4/common/library";var k=class extends Ut{constructor(t,r){
|
|
113
|
+
super("Incomplete route handler",t,r)}};var je=(e,t,r,o)=>{if(!ie(e))return null;let n={},p=new Set(["name","file","resp\
|
|
114
114
|
onse"]);if(e.description&&(n.description=e.description),(n.name=e.name)&&p.delete(
|
|
115
115
|
"name"),(n.file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;
|
|
116
|
-
n.request=
|
|
117
|
-
"response"))}return
|
|
118
|
-
!!e.file&&!!e.response;var
|
|
119
|
-
let s=
|
|
120
|
-
if(!
|
|
121
|
-
path&&!!e.handler,
|
|
122
|
-
e)&&e.spread?
|
|
123
|
-
h","handler"]);for(let i of r)if(!(!
|
|
124
|
-
push(new
|
|
125
|
-
i.name),p.path=c);break}case"handler":(p.handler=
|
|
126
|
-
name);break;case"authorizer":p.authorizer=
|
|
116
|
+
n.request=Re(s,t,r,o)}if(e.return){let s=He(e.return,t,r,o);s&&(n.response=s,p.delete(
|
|
117
|
+
"response"))}return Vt(n)?n:(o.push(new k([...p],e.file)),null)},Vt=e=>!!e.name&&
|
|
118
|
+
!!e.file&&!!e.response;var ze=(e,t,r,o)=>{let n=to(t)??[];return Ce(n,e,r,o)},Ce=(e,t,r,o)=>{let n=[];for(let p of e){
|
|
119
|
+
let s=oo(p,t,r,o);Array.isArray(s)?n.push(...s):s&&n.push(s)}return n},oo=(e,t,r,o)=>{
|
|
120
|
+
if(!Gt(e))return we(e,t,r,o);let n=ro(e,r);return n?we(n,t,r,o):null},no=e=>!!e.
|
|
121
|
+
path&&!!e.handler,we=(e,t,r,o)=>_(e)?Oe(e,t,Lt(e),r,o):Jt(e)?Oe(e,t,$t(e),r,o):Yt(
|
|
122
|
+
e)&&e.spread?Ce(e.elements,t,r,o):null,Oe=(e,t,r,o,n)=>{let p={},s=new Set(["pat\
|
|
123
|
+
h","handler"]);for(let i of r)if(!(!Qt(i)||i.inherited))switch(i.name){default:n.
|
|
124
|
+
push(new Kt(t.name,i.name,e.file));break;case"path":{let c=_t(i);c&&X(c)&&(s.delete(
|
|
125
|
+
i.name),p.path=c);break}case"handler":(p.handler=je(i.value,t,o,n))&&s.delete(i.
|
|
126
|
+
name);break;case"authorizer":p.authorizer=Pe(i.value,t,o,n);break;case"httpError\
|
|
127
127
|
s":p.httpErrors=y(i.value,t,o,n);break;case"memory":case"logRetention":case"time\
|
|
128
|
-
out":p[i.name]=
|
|
129
|
-
|
|
130
|
-
push(new g([...s],e.file)),null)};import{InvalidServicePropertyError as
|
|
131
|
-
getObjectMembers as
|
|
132
|
-
getReferenceType as
|
|
133
|
-
isTypeReference as
|
|
134
|
-
var
|
|
135
|
-
super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},
|
|
136
|
-
super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}};var
|
|
137
|
-
|
|
138
|
-
e,t,
|
|
139
|
-
let n={},p=new Set(["allowOrigins"]);for(let s of r)if(!(!
|
|
140
|
-
name){default:o.push(new
|
|
141
|
-
allowMethods":case"allowHeaders":case"exposeHeaders":n[s.name]=
|
|
142
|
-
allowCredentials":n.allowCredentials=
|
|
143
|
-
return
|
|
144
|
-
getObjectMembers as
|
|
145
|
-
import{isModelProperty as
|
|
146
|
-
import{isAnyNumber as
|
|
147
|
-
var
|
|
148
|
-
|
|
149
|
-
p.Cache",t)}},
|
|
150
|
-
type",r,"Http.Cache",o);this.cacheType=r}};var
|
|
151
|
-
|
|
152
|
-
e),r):(r.push(new
|
|
153
|
-
let n={},p=new Set(["authorizerTTL"]);for(let s of r)if(!(!
|
|
154
|
-
name){default:o.push(new
|
|
155
|
-
s);
|
|
156
|
-
e.file)),null)};var
|
|
157
|
-
type:
|
|
158
|
-
description=n.description);for(let c of
|
|
159
|
-
name){default:r.push(new
|
|
160
|
-
c,e,r))&&s.delete(c.name);break;case"name":p.displayName=
|
|
161
|
-
ts":p.defaults=
|
|
162
|
-
cors":p.cors=
|
|
163
|
-
services":p.services=
|
|
164
|
-
if(t[n.name]){r.push(new
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
var d=class extends
|
|
168
|
-
ults",t)}},T=class extends
|
|
169
|
-
p.Defaults",o);this.defaultsType=r}};export{M as IncompleteAuthorizerError,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
T as IncorrectDefaultsTypeError,
|
|
173
|
-
|
|
174
|
-
h as IncorrectResponseTypeError,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
128
|
+
out":p[i.name]=Zt(i);break;case"cors":p.cors=Xt(i);break;case"listener":p.listener=
|
|
129
|
+
eo(i.value,n);break;case"variables":p.variables=Wt(i,n);break}return no(p)?p:(n.
|
|
130
|
+
push(new g([...s],e.file)),null)};import{InvalidServicePropertyError as co,isModelDeclaration as lo,getModelMembers as mo,
|
|
131
|
+
getObjectMembers as ao,getPropertyBoolean as uo,getPropertyStringList as fo,getPropertyNumber as yo,
|
|
132
|
+
getReferenceType as To}from"@ez4/common/library";import{isModelProperty as go,isTypeObject as Mo,
|
|
133
|
+
isTypeReference as Ho}from"@ez4/reflection";import{IncompleteTypeError as po,IncorrectTypeError as so,InvalidTypeError as io}from"@ez4/common/library";
|
|
134
|
+
var q=class extends po{constructor(t,r){super("Incomplete HTTP CORS",t,r)}},D=class extends io{constructor(t){
|
|
135
|
+
super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},F=class extends so{constructor(r,o){
|
|
136
|
+
super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}};var De=(e,t,r,o)=>{if(!Ho(e))return ke(e,t,o);let n=To(e,r);return n?ke(n,t,o):null},
|
|
137
|
+
ho=e=>!!e.allowOrigins?.length,ke=(e,t,r)=>Mo(e)?qe(e,t,ao(e),r):lo(e)?ne(e)?qe(
|
|
138
|
+
e,t,mo(e),r):(r.push(new F(e.name,e.file)),null):(r.push(new D(t.file)),null),qe=(e,t,r,o)=>{
|
|
139
|
+
let n={},p=new Set(["allowOrigins"]);for(let s of r)if(!(!go(s)||s.inherited))switch(s.
|
|
140
|
+
name){default:o.push(new co(t.name,s.name,e.file));break;case"allowOrigins":case"\
|
|
141
|
+
allowMethods":case"allowHeaders":case"exposeHeaders":n[s.name]=fo(s);break;case"\
|
|
142
|
+
allowCredentials":n.allowCredentials=uo(s);break;case"maxAge":n.maxAge=yo(s);break}
|
|
143
|
+
return ho(n)?n:(o.push(new q([...p],e.file)),null)};import{InvalidServicePropertyError as Io,isModelDeclaration as Ao,getModelMembers as Eo,
|
|
144
|
+
getObjectMembers as vo,getPropertyNumber as Ro,getReferenceType as Po}from"@ez4/common/library";
|
|
145
|
+
import{isModelProperty as jo,isTypeObject as wo,isTypeReference as Oo}from"@ez4/reflection";
|
|
146
|
+
import{isAnyNumber as Ne}from"@ez4/utils";import{IncompleteTypeError as bo,IncorrectTypeError as So,InvalidTypeError as xo}from"@ez4/common/library";
|
|
147
|
+
var B=class extends bo{constructor(t,r){super("Incomplete gateway cache",t,r)}},
|
|
148
|
+
N=class extends xo{constructor(t){super("Invalid gateway cache type",void 0,"Htt\
|
|
149
|
+
p.Cache",t)}},U=class extends So{constructor(r,o){super("Incorrect gateway cache\
|
|
150
|
+
type",r,"Http.Cache",o);this.cacheType=r}};var Ue=(e,t,r,o)=>{if(!Oo(e))return Fe(e,t,o);let n=Po(e,r);return n?Fe(n,t,o):null},
|
|
151
|
+
zo=e=>Ne(e.authorizerTTL),Fe=(e,t,r)=>wo(e)?Be(e,t,vo(e),r):Ao(e)?pe(e)?Be(e,t,Eo(
|
|
152
|
+
e),r):(r.push(new U(e.name,e.file)),null):(r.push(new N(t.file)),null),Be=(e,t,r,o)=>{
|
|
153
|
+
let n={},p=new Set(["authorizerTTL"]);for(let s of r)if(!(!jo(s)||s.inherited))switch(s.
|
|
154
|
+
name){default:o.push(new Io(t.name,s.name,e.file));break;case"authorizerTTL":{let i=Ro(
|
|
155
|
+
s);Ne(i)&&(n[s.name]=i,p.delete(s.name));break}}return zo(n)?n:(o.push(new B([...p],
|
|
156
|
+
e.file)),null)};var Ve=e=>{let t={},r=[];for(let o in e){let n=e[o];if(!Z(n)||ko(n))continue;let p={
|
|
157
|
+
type:V,extras:{}},s=new Set(["routes"]),i=n.file;p.name=n.name,n.description&&(p.
|
|
158
|
+
description=n.description);for(let c of Fo(n))if(!(!Uo(c)||c.inherited))switch(c.
|
|
159
|
+
name){default:r.push(new No(p.name,c.name,i));break;case"routes":(p.routes=ze(n,
|
|
160
|
+
c,e,r))&&s.delete(c.name);break;case"name":p.displayName=Bo(c);break;case"defaul\
|
|
161
|
+
ts":p.defaults=fe(c.value,n,e,r);break;case"cache":p.cache=Ue(c.value,n,e,r);break;case"\
|
|
162
|
+
cors":p.cors=De(c.value,n,e,r);break;case"variables":p.variables=Do(c,r);break;case"\
|
|
163
|
+
services":p.services=qo(c,e,r);break}if(!Vo(p)){r.push(new f([...s],i));continue}
|
|
164
|
+
if(t[n.name]){r.push(new Co(n.name,i));continue}t[n.name]=p}return{services:t,errors:r}},
|
|
165
|
+
Vo=e=>!!e.name&&!!e.routes&&!!e.extras;var Qe=!1,xs=()=>{Qe||(Qo(),Jo(),Go("@ez4/gateway",{"metadata:getServices":Ve}),
|
|
166
|
+
Qe=!1)};import{IncorrectTypeError as Yo,InvalidTypeError as Ko}from"@ez4/common/library";
|
|
167
|
+
var d=class extends Ko{constructor(t){super("Invalid defaults",void 0,"Http.Defa\
|
|
168
|
+
ults",t)}},T=class extends Yo{constructor(r,o){super("Incorrect defaults",r,"Htt\
|
|
169
|
+
p.Defaults",o);this.defaultsType=r}};export{M as IncompleteAuthorizerError,B as IncompleteCacheError,q as IncompleteCorsError,
|
|
170
|
+
k as IncompleteHandlerError,g as IncompleteRouteError,f as IncompleteServiceError,
|
|
171
|
+
v as IncorrectBodyTypeError,U as IncorrectCacheTypeError,F as IncorrectCorsTypeError,
|
|
172
|
+
T as IncorrectDefaultsTypeError,I as IncorrectHeadersTypeError,S as IncorrectIdentityTypeError,
|
|
173
|
+
O as IncorrectParameterTypeError,C as IncorrectQueryTypeError,j as IncorrectRequestTypeError,
|
|
174
|
+
h as IncorrectResponseTypeError,E as InvalidBodyTypeError,N as InvalidCacheTypeError,
|
|
175
|
+
D as InvalidCorsTypeError,d as InvalidDefaultsTypeError,x as InvalidHeadersTypeError,
|
|
176
|
+
b as InvalidIdentityTypeError,w as InvalidParameterTypeError,z as InvalidQueryTypeError,
|
|
177
|
+
P as InvalidRequestTypeError,H as InvalidResponseTypeError,a as InvalidRouteErrorTypeError,
|
|
178
|
+
V as ServiceType,ve as getHttpAuthRequest,Me as getHttpAuthResponse,Pe as getHttpAuthorizer,
|
|
179
|
+
R as getHttpBody,Ue as getHttpCache,De as getHttpCors,je as getHttpHandler,Re as getHttpHandlerRequest,
|
|
180
|
+
He as getHttpHandlerResponse,A as getHttpHeaders,u as getHttpIdentity,Se as getHttpParameters,
|
|
181
|
+
Ie as getHttpQuery,ze as getHttpRoutes,Ve as getHttpServices,Wo as isHttpService,
|
|
182
|
+
xs as registerTriggers};
|
|
183
183
|
//# sourceMappingURL=library.mjs.map
|
package/dist/main.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";var n=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var
|
|
2
|
-
typeof t=="object"||typeof t=="function")for(let p of
|
|
3
|
-
n(
|
|
4
|
-
HttpInternalServerError:()=>
|
|
5
|
-
HttpUnprocessableEntityError:()=>
|
|
6
|
-
exports=q
|
|
7
|
-
o;this.details=p}},u=class extends
|
|
8
|
-
e)}},i=class extends
|
|
9
|
-
super(403,t||"Forbidden",e)}},
|
|
10
|
-
ot found",e)}},x=class extends
|
|
11
|
-
a type",e)}},
|
|
12
|
-
ty",e)}},
|
|
1
|
+
"use strict";var n=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var h=(s,t)=>{for(var e in t)n(s,e,{get:t[e],enumerable:!0})},g=(s,t,e,o)=>{if(t&&
|
|
2
|
+
typeof t=="object"||typeof t=="function")for(let p of R(t))!l.call(s,p)&&p!==e&&
|
|
3
|
+
n(s,p,{get:()=>t[p],enumerable:!(o=H(t,p))||o.enumerable});return s};var S=s=>g(n({},"__esModule",{value:!0}),s);var q={};h(q,{Http:()=>m,HttpBadRequestError:()=>u,HttpError:()=>r,HttpForbiddenError:()=>c,
|
|
4
|
+
HttpInternalServerError:()=>d,HttpNotFoundError:()=>a,HttpUnauthorizedError:()=>i,
|
|
5
|
+
HttpUnprocessableEntityError:()=>y,HttpUnsupportedMediaTypeError:()=>x});module.
|
|
6
|
+
exports=S(q);var m;(s=>{})(m||={});var r=class extends Error{constructor(e,o,p){super(o);this.status=e;this.message=
|
|
7
|
+
o;this.details=p}},u=class extends r{constructor(t,e){super(400,t||"Bad request",
|
|
8
|
+
e)}},i=class extends r{constructor(t,e){super(401,t||"Unauthorized",e)}},c=class extends r{constructor(t,e){
|
|
9
|
+
super(403,t||"Forbidden",e)}},a=class extends r{constructor(t,e){super(404,t||"N\
|
|
10
|
+
ot found",e)}},x=class extends r{constructor(t,e){super(415,t||"Unsupported medi\
|
|
11
|
+
a type",e)}},y=class extends r{constructor(t,e){super(422,t||"Unprocessable enti\
|
|
12
|
+
ty",e)}},d=class extends r{constructor(t,e){super(500,t||"Internal server error",
|
|
13
13
|
e)}};0&&(module.exports={Http,HttpBadRequestError,HttpError,HttpForbiddenError,HttpInternalServerError,
|
|
14
14
|
HttpNotFoundError,HttpUnauthorizedError,HttpUnprocessableEntityError,HttpUnsupportedMediaTypeError});
|
|
15
15
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
x;this.details=
|
|
3
|
-
e)}},o=class extends
|
|
4
|
-
super(403,t||"Forbidden",e)}},u=class extends
|
|
5
|
-
ot found",e)}},i=class extends
|
|
6
|
-
a type",e)}},
|
|
7
|
-
ty",e)}},
|
|
8
|
-
e)}};export{
|
|
9
|
-
|
|
1
|
+
var y;(r=>{})(y||={});var s=class extends Error{constructor(e,x,d){super(x);this.status=e;this.message=
|
|
2
|
+
x;this.details=d}},p=class extends s{constructor(t,e){super(400,t||"Bad request",
|
|
3
|
+
e)}},o=class extends s{constructor(t,e){super(401,t||"Unauthorized",e)}},n=class extends s{constructor(t,e){
|
|
4
|
+
super(403,t||"Forbidden",e)}},u=class extends s{constructor(t,e){super(404,t||"N\
|
|
5
|
+
ot found",e)}},i=class extends s{constructor(t,e){super(415,t||"Unsupported medi\
|
|
6
|
+
a type",e)}},c=class extends s{constructor(t,e){super(422,t||"Unprocessable enti\
|
|
7
|
+
ty",e)}},a=class extends s{constructor(t,e){super(500,t||"Internal server error",
|
|
8
|
+
e)}};export{y as Http,p as HttpBadRequestError,s as HttpError,n as HttpForbiddenError,
|
|
9
|
+
a as HttpInternalServerError,u as HttpNotFoundError,o as HttpUnauthorizedError,c as HttpUnprocessableEntityError,
|
|
10
10
|
i as HttpUnsupportedMediaTypeError};
|
|
11
11
|
//# sourceMappingURL=main.mjs.map
|
package/dist/metadata/body.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { AllType, SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
2
|
import type { ArraySchema, ObjectSchema, UnionSchema } from '@ez4/schema/library';
|
|
3
3
|
type TypeParent = TypeObject | TypeModel | TypeIntersection;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const getHttpResponseBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | UnionSchema | ArraySchema | import("@ez4/schema/library").BooleanSchema | import("@ez4/schema/library").NumberSchema | import("@ez4/schema/library").StringSchema | null;
|
|
4
|
+
export declare const getHttpBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | UnionSchema | ArraySchema | import("@ez4/schema/library").BooleanSchema | import("@ez4/schema/library").NumberSchema | import("@ez4/schema/library").StringSchema | null;
|
|
6
5
|
export {};
|
|
@@ -59,24 +59,28 @@ export interface HttpPathParameters {
|
|
|
59
59
|
export interface HttpQueryStrings {
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
62
|
+
* Json body payload.
|
|
63
63
|
*/
|
|
64
64
|
export interface HttpJsonBody {
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Raw body payload.
|
|
68
|
+
*/
|
|
69
|
+
export type HttpRawBody = string;
|
|
66
70
|
/**
|
|
67
71
|
* Authorizer request.
|
|
68
72
|
*/
|
|
69
73
|
export interface HttpAuthRequest {
|
|
70
74
|
/**
|
|
71
|
-
* Expected headers.
|
|
75
|
+
* Expected HTTP headers.
|
|
72
76
|
*/
|
|
73
77
|
headers?: HttpHeaders;
|
|
74
78
|
/**
|
|
75
|
-
* Expected path parameters.
|
|
79
|
+
* Expected HTTP path parameters.
|
|
76
80
|
*/
|
|
77
81
|
parameters?: HttpPathParameters;
|
|
78
82
|
/**
|
|
79
|
-
* Expected query strings.
|
|
83
|
+
* Expected HTTP query strings.
|
|
80
84
|
*/
|
|
81
85
|
query?: HttpQueryStrings;
|
|
82
86
|
}
|
|
@@ -93,43 +97,43 @@ export interface HttpAuthResponse {
|
|
|
93
97
|
* HTTP request.
|
|
94
98
|
*/
|
|
95
99
|
export interface HttpRequest {
|
|
96
|
-
/**
|
|
97
|
-
* Expected headers.
|
|
98
|
-
*/
|
|
99
|
-
headers?: HttpHeaders;
|
|
100
100
|
/**
|
|
101
101
|
* Expected identity.
|
|
102
102
|
*/
|
|
103
103
|
identity?: HttpIdentity;
|
|
104
104
|
/**
|
|
105
|
-
* Expected
|
|
105
|
+
* Expected HTTP headers.
|
|
106
|
+
*/
|
|
107
|
+
headers?: HttpHeaders;
|
|
108
|
+
/**
|
|
109
|
+
* Expected HTTP path parameters.
|
|
106
110
|
*/
|
|
107
111
|
parameters?: HttpPathParameters;
|
|
108
112
|
/**
|
|
109
|
-
* Expected query strings.
|
|
113
|
+
* Expected HTTP query strings.
|
|
110
114
|
*/
|
|
111
115
|
query?: HttpQueryStrings;
|
|
112
116
|
/**
|
|
113
|
-
* Expected
|
|
117
|
+
* Expected HTTP body payload.
|
|
114
118
|
*/
|
|
115
|
-
body?: HttpJsonBody;
|
|
119
|
+
body?: HttpJsonBody | HttpRawBody;
|
|
116
120
|
}
|
|
117
121
|
/**
|
|
118
122
|
* HTTP response.
|
|
119
123
|
*/
|
|
120
124
|
export interface HttpResponse {
|
|
121
125
|
/**
|
|
122
|
-
*
|
|
126
|
+
* HTTP status code.
|
|
123
127
|
*/
|
|
124
128
|
status: number;
|
|
125
129
|
/**
|
|
126
|
-
*
|
|
130
|
+
* HTTP headers.
|
|
127
131
|
*/
|
|
128
132
|
headers?: HttpHeaders;
|
|
129
133
|
/**
|
|
130
|
-
*
|
|
134
|
+
* HTTP body payload.
|
|
131
135
|
*/
|
|
132
|
-
body?: HttpJsonBody;
|
|
136
|
+
body?: HttpJsonBody | HttpRawBody;
|
|
133
137
|
}
|
|
134
138
|
export interface HttpProvider {
|
|
135
139
|
/**
|
|
@@ -145,6 +149,10 @@ export type HttpIncoming<T extends HttpRequest | HttpAuthRequest> = T & {
|
|
|
145
149
|
* Request tracking Id.
|
|
146
150
|
*/
|
|
147
151
|
requestId: string;
|
|
152
|
+
/**
|
|
153
|
+
* Determines whether request is base64 encoded or not.
|
|
154
|
+
*/
|
|
155
|
+
encoded?: boolean;
|
|
148
156
|
/**
|
|
149
157
|
* Request timestamp.
|
|
150
158
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Service } from '@ez4/common';
|
|
2
2
|
import type { LinkedVariables } from '@ez4/project/library';
|
|
3
3
|
import type { HttpPath } from '../types/common.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { HttpSuccessStatuses, HttpEmptySuccessResponse, HttpSuccessResponse } from './utils.js';
|
|
5
|
+
import type { HttpHeaders, HttpIdentity, HttpPathParameters, HttpQueryStrings, HttpJsonBody, HttpRawBody, HttpAuthRequest, HttpAuthResponse, HttpRequest, HttpResponse, HttpErrors, HttpProvider, HttpIncoming, HttpListener, HttpAuthorizer, HttpHandler, HttpCache, HttpCors } from './common.js';
|
|
5
6
|
/**
|
|
6
7
|
* Provide all contracts for a self-managed HTTP service.
|
|
7
8
|
*/
|
|
@@ -11,6 +12,7 @@ export declare namespace Http {
|
|
|
11
12
|
type PathParameters = HttpPathParameters;
|
|
12
13
|
type QueryStrings = HttpQueryStrings;
|
|
13
14
|
type JsonBody = HttpJsonBody;
|
|
15
|
+
type RawBody = HttpRawBody;
|
|
14
16
|
type AuthRequest = HttpAuthRequest;
|
|
15
17
|
type Request = HttpRequest;
|
|
16
18
|
type AuthResponse = HttpAuthResponse;
|
|
@@ -24,6 +26,8 @@ export declare namespace Http {
|
|
|
24
26
|
type Authorizer<T extends AuthRequest> = HttpAuthorizer<T>;
|
|
25
27
|
type Handler<T extends Request> = HttpHandler<T>;
|
|
26
28
|
type ServiceEvent<T extends Request | AuthRequest = Request> = Service.Event<Incoming<T>>;
|
|
29
|
+
type EmptySuccessResponse<S extends HttpSuccessStatuses = 204> = HttpEmptySuccessResponse<S>;
|
|
30
|
+
type SuccessResponse<S extends HttpSuccessStatuses, T extends HttpRawBody | HttpJsonBody> = HttpSuccessResponse<S, T>;
|
|
27
31
|
/**
|
|
28
32
|
* HTTP route.
|
|
29
33
|
*/
|
|
@@ -44,6 +48,10 @@ export declare namespace Http {
|
|
|
44
48
|
* Route handler.
|
|
45
49
|
*/
|
|
46
50
|
handler: Handler<T>;
|
|
51
|
+
/**
|
|
52
|
+
* Default log retention (in days) for the handlers.
|
|
53
|
+
*/
|
|
54
|
+
logRetention?: number;
|
|
47
55
|
/**
|
|
48
56
|
* Map status codes and errors for all known exceptions.
|
|
49
57
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpResponse, HttpJsonBody, HttpRawBody } from './common.js';
|
|
2
|
+
export type HttpSuccessStatuses = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208;
|
|
3
|
+
/**
|
|
4
|
+
* Common HTTP success response without a response body.
|
|
5
|
+
*/
|
|
6
|
+
export declare class HttpEmptySuccessResponse<S extends HttpSuccessStatuses> implements HttpResponse {
|
|
7
|
+
/**
|
|
8
|
+
* HTTP status code.
|
|
9
|
+
*/
|
|
10
|
+
status: S;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Common HTTP success response.
|
|
14
|
+
*/
|
|
15
|
+
export declare class HttpSuccessResponse<S extends HttpSuccessStatuses, T extends HttpJsonBody | HttpRawBody> implements HttpResponse {
|
|
16
|
+
/**
|
|
17
|
+
* HTTP status code.
|
|
18
|
+
*/
|
|
19
|
+
status: S;
|
|
20
|
+
/**
|
|
21
|
+
* HTTP response payload.
|
|
22
|
+
*/
|
|
23
|
+
body: T;
|
|
24
|
+
}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export type HttpRequest = {
|
|
|
16
16
|
identity?: ObjectSchema | UnionSchema | null;
|
|
17
17
|
parameters?: ObjectSchema | null;
|
|
18
18
|
query?: ObjectSchema | null;
|
|
19
|
-
body?: ObjectSchema | UnionSchema | ArraySchema | null;
|
|
19
|
+
body?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema | null;
|
|
20
20
|
};
|
|
21
21
|
export type HttpResponse = {
|
|
22
22
|
status: number;
|
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.21.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"live:publish": "npm run test && npm publish --access public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@ez4/common": "^0.
|
|
46
|
-
"@ez4/project": "^0.
|
|
47
|
-
"@ez4/reflection": "^0.
|
|
48
|
-
"@ez4/schema": "^0.
|
|
49
|
-
"@ez4/utils": "^0.
|
|
45
|
+
"@ez4/common": "^0.21.0",
|
|
46
|
+
"@ez4/project": "^0.21.0",
|
|
47
|
+
"@ez4/reflection": "^0.21.0",
|
|
48
|
+
"@ez4/schema": "^0.21.0",
|
|
49
|
+
"@ez4/utils": "^0.21.0"
|
|
50
50
|
}
|
|
51
51
|
}
|