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