@ez4/gateway 0.15.0 → 0.16.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 +151 -149
- package/dist/library.mjs +157 -151
- package/dist/metadata/authorizer.d.ts +2 -2
- package/dist/metadata/body.d.ts +1 -1
- package/dist/metadata/cors.d.ts +2 -4
- package/dist/metadata/defaults.d.ts +2 -2
- package/dist/metadata/handler.d.ts +2 -2
- package/dist/metadata/request.d.ts +3 -5
- package/dist/metadata/response.d.ts +3 -5
- package/dist/metadata/route.d.ts +2 -2
- package/dist/types/common.d.ts +3 -3
- package/package.json +7 -7
- package/dist/metadata/catcher.d.ts +0 -3
- package/dist/services/cors.d.ts +0 -29
- package/dist/services/helpers.d.ts +0 -7
- package/dist/services/http.d.ts +0 -106
- package/dist/services/request.d.ts +0 -43
- package/dist/services/response.d.ts +0 -27
- package/dist/types/authorizer.d.ts +0 -9
- package/dist/types/cors.d.ts +0 -8
- package/dist/types/handler.d.ts +0 -9
- package/dist/types/path.d.ts +0 -9
- package/dist/types/request.d.ts +0 -13
- package/dist/types/response.d.ts +0 -9
- package/dist/types/route.d.ts +0 -13
package/dist/library.mjs
CHANGED
|
@@ -1,151 +1,157 @@
|
|
|
1
|
-
import{registerTriggers as
|
|
2
|
-
import{createTrigger as
|
|
3
|
-
getLinkedVariableList as
|
|
4
|
-
import{isModelProperty as
|
|
5
|
-
super("Incomplete service",
|
|
6
|
-
getServiceListener as Je}from"@ez4/common/library";
|
|
7
|
-
|
|
8
|
-
import{isTypeCallback as
|
|
9
|
-
["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),
|
|
10
|
-
2);return
|
|
11
|
-
K=e=>
|
|
12
|
-
nBody"),Z=e=>B(e)&&
|
|
13
|
-
L=(e,
|
|
14
|
-
null):(
|
|
15
|
-
|
|
16
|
-
name]=
|
|
17
|
-
import{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
super("Incomplete route
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
e
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
o)
|
|
38
|
-
|
|
39
|
-
C(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
status
|
|
62
|
-
e,t,
|
|
63
|
-
|
|
64
|
-
p.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"Http.
|
|
80
|
-
|
|
81
|
-
t,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
n.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
n.
|
|
92
|
-
|
|
93
|
-
p.
|
|
94
|
-
|
|
95
|
-
(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
e
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
t,r)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
n
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
name
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
1
|
+
import{registerTriggers as lo}from"@ez4/common/library";import{registerTriggers as mo}from"@ez4/schema/library";
|
|
2
|
+
import{createTrigger as uo}from"@ez4/project/library";import{DuplicateServiceError as $t,isExternalStatement as Lt,getLinkedServiceList as eo,
|
|
3
|
+
getLinkedVariableList as ro,getModelMembers as to,getPropertyString as oo,getPropertyTuple as no,
|
|
4
|
+
InvalidServicePropertyError as so}from"@ez4/common/library";import{isModelProperty as po}from"@ez4/reflection";var q="@ez4/http",yo=e=>e.type===q;import{IncompleteTypeError as Ce}from"@ez4/common/library";var u=class extends Ce{constructor(t,r){
|
|
5
|
+
super("Incomplete service",t,r)}};import{InvalidServicePropertyError as Ue,isModelDeclaration as Ve,getPropertyNumber as Fe,
|
|
6
|
+
getObjectMembers as Ne,getModelMembers as Qe,getServiceListener as Je,getReferenceType as Ge}from"@ez4/common/library";
|
|
7
|
+
import{isModelProperty as Ye,isTypeObject as Ke,isTypeReference as We}from"@ez4/reflection";import{hasHeritageType as l,isClassDeclaration as De,isModelDeclaration as B}from"@ez4/common/library";
|
|
8
|
+
import{isTypeCallback as U,isTypeFunction as V}from"@ez4/reflection";var Be=new Set(
|
|
9
|
+
["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),F=e=>{let[t]=e.split(" ",
|
|
10
|
+
2);return Be.has(t)},N=e=>De(e)&&l(e,"Http.Service"),Q=e=>B(e)&&l(e,"Http.Route");var J=e=>l(e,"Http.Defaults"),G=e=>l(e,"Http.Headers"),Y=e=>l(e,"Http.Identity"),
|
|
11
|
+
K=e=>l(e,"Http.QueryStrings"),W=e=>l(e,"Http.PathParameters"),X=e=>l(e,"Http.Jso\
|
|
12
|
+
nBody"),Z=e=>B(e)&&l(e,"Http.Cors"),_=e=>U(e)||V(e),$=e=>U(e)||V(e);var re=(e,t,r,n)=>{if(!We(e))return L(e,t,n);let o=Ge(e,r);return o?L(o,t,n):null},
|
|
13
|
+
L=(e,t,r)=>Ke(e)?ee(t,Ne(e),r):Ve(e)?J(e)?ee(t,Qe(e),r):(r.push(new f(e.name,t.file)),
|
|
14
|
+
null):(r.push(new a(t.file)),null),ee=(e,t,r)=>{let n={};for(let o of t)if(!(!Ye(
|
|
15
|
+
o)||o.inherited))switch(o.name){default:r.push(new Ue(e.name,o.name,e.file));break;case"\
|
|
16
|
+
memory":case"timeout":n[o.name]=Fe(o);break;case"listener":n.listener=Je(o.value,
|
|
17
|
+
r);break}return n};import{isModelProperty as St,isTypeObject as xt,isTypeReference as At}from"@ez4/reflection";
|
|
18
|
+
import{InvalidServicePropertyError as It,getLinkedVariableList as vt,getPropertyBoolean as Rt,
|
|
19
|
+
getPropertyNumber as Et,getPropertyString as jt,getObjectMembers as Ot,getModelMembers as Pt,
|
|
20
|
+
getServiceListener as wt,getReferenceType as zt}from"@ez4/common/library";import{IncompleteTypeError as Xe}from"@ez4/common/library";var d=class extends Xe{constructor(t,r){
|
|
21
|
+
super("Incomplete service route",t,r)}};import{IncompleteTypeError as Ze}from"@ez4/common/library";var y=class extends Ze{constructor(t,r){
|
|
22
|
+
super("Incomplete route authorizer",t,r)}};import{InvalidServicePropertyError as zr,isModelDeclaration as kr,hasHeritageType as qr,
|
|
23
|
+
getModelMembers as Cr,getObjectMembers as Dr,getPropertyNumber as Br,getReferenceType as Ur}from"@ez4/common/library";
|
|
24
|
+
import{isModelProperty as Vr,isTypeObject as Fr,isTypeReference as Nr}from"@ez4/reflection";
|
|
25
|
+
import{isAnyNumber as Qr}from"@ez4/utils";import{IncorrectTypeError as _e,InvalidTypeError as $e}from"@ez4/common/library";
|
|
26
|
+
var T=class extends $e{constructor(r,n){super("Invalid route response",void 0,r,
|
|
27
|
+
n);this.baseType=r}},g=class extends _e{constructor(r,n,o){super("Incorrect rout\
|
|
28
|
+
e response",r,n,o);this.responseType=r;this.baseType=n}};import{getReferenceType as rr,isModelDeclaration as tr}from"@ez4/common/library";
|
|
29
|
+
import{isObjectSchema as or,createUnionSchema as nr,getObjectSchema as sr,getScalarSchema as pr}from"@ez4/schema/library";
|
|
30
|
+
import{isTypeObject as ir,isTypeReference as cr,isTypeScalar as lr,isTypeUndefined as mr,
|
|
31
|
+
isTypeUnion as ur}from"@ez4/reflection";import{IncorrectTypeError as Le,InvalidTypeError as er}from"@ez4/common/library";
|
|
32
|
+
var H=class extends er{constructor(t){super("Invalid body",void 0,"Http.JsonBody",
|
|
33
|
+
t)}},M=class extends Le{constructor(r,n){super("Incorrect body",r,"Http.JsonBody",
|
|
34
|
+
n);this.bodyType=r}};var oe=(e,t,r,n)=>C(e,t,r,(o,s)=>D(o,s,r,n)),ne=(e,t,r,n)=>C(e,t,r,(o,s)=>se(o)??
|
|
35
|
+
D(o,s,r,n)),C=(e,t,r,n)=>{if(mr(e))return null;if(!cr(e))return n(e,t);let o=rr(
|
|
36
|
+
e,r);return o?n(o,t):null},se=e=>lr(e)?pr(e):null,D=(e,t,r,n)=>ur(e)?ar(e.elements,
|
|
37
|
+
t,r,(o,s)=>se(o)??D(o,s,r,n)):ir(e)?te(e,r):tr(e)?X(e)?te(e,r):(n.push(new M(e.name,
|
|
38
|
+
e.file)),null):(n.push(new H(t.file)),null),ar=(e,t,r,n)=>{let o=[];for(let s of e){
|
|
39
|
+
let p=C(s,t,r,n);p&&o.push(p)}return o.length?nr({elements:o}):null},te=(e,t)=>{
|
|
40
|
+
let r=sr(e,t);return r&&or(r)?r:null};import{isTypeObject as yr,isTypeReference as Tr,isTypeUndefined as gr,isTypeUnion as Hr}from"@ez4/reflection";
|
|
41
|
+
import{createUnionSchema as Mr,getObjectSchema as br,isObjectSchema as hr}from"@ez4/schema/library";
|
|
42
|
+
import{getReferenceType as Sr,isModelDeclaration as xr}from"@ez4/common/library";import{IncorrectTypeError as fr,InvalidTypeError as dr}from"@ez4/common/library";
|
|
43
|
+
var b=class extends dr{constructor(t){super("Invalid identity",void 0,"Http.Iden\
|
|
44
|
+
tity",t)}},h=class extends fr{constructor(r,n){super("Incorrect identity",r,"Htt\
|
|
45
|
+
p.Identity",n);this.identityType=r}};var m=(e,t,r,n)=>{if(gr(e))return null;if(!Tr(e))return pe(e,t,r,n);let o=Sr(e,r);
|
|
46
|
+
return o?pe(o,t,r,n):null},pe=(e,t,r,n)=>{if(Hr(e))return Ar(e.elements,t,r,n);if(yr(
|
|
47
|
+
e))return ie(e,r);if(!xr(e))return n.push(new b(t.file)),null;if(!Y(e))return n.
|
|
48
|
+
push(new h(e.name,t.file)),null;let o=ie(e,r);return o&&(o.definitions={...o.definitions,
|
|
49
|
+
extensible:!0}),o},Ar=(e,t,r,n)=>{let o=[];for(let s of e){let p=m(s,t,r,n);p&&o.
|
|
50
|
+
push(p)}return o.length>1?Mr({elements:o}):o[0]},ie=(e,t)=>{let r=br(e,t);return r&&
|
|
51
|
+
hr(r)?r:null};import{getReferenceType as Rr,isModelDeclaration as Er}from"@ez4/common/library";
|
|
52
|
+
import{getObjectSchema as jr,isObjectSchema as Or}from"@ez4/schema/library";import{
|
|
53
|
+
isTypeObject as Pr,isTypeReference as wr}from"@ez4/reflection";import{IncorrectTypeError as Ir,InvalidTypeError as vr}from"@ez4/common/library";
|
|
54
|
+
var S=class extends vr{constructor(t){super("Invalid headers",void 0,"Http.Heade\
|
|
55
|
+
rs",t)}},x=class extends Ir{constructor(r,n){super("Incorrect headers",r,"Http.H\
|
|
56
|
+
eaders",n);this.headersType=r}};var A=(e,t,r,n)=>{if(!wr(e))return ce(e,t,r,n);let o=Rr(e,r);return o?ce(o,t,r,n):
|
|
57
|
+
null},ce=(e,t,r,n)=>Pr(e)?le(e,r):Er(e)?G(e)?le(e,r):(n.push(new x(e.name,t.file)),
|
|
58
|
+
null):(n.push(new S(t.file)),null),le=(e,t)=>{let r=jr(e,t);return r&&Or(r)?r:null};var ae=(e,t,r,n)=>{let o=de(e,t,r,n,"Http.AuthResponse");return o&&Jr(o)?o:null},
|
|
59
|
+
fe=(e,t,r,n)=>{let o=de(e,t,r,n,"Http.Response");return o&&Gr(o)?o:null},de=(e,t,r,n,o)=>{
|
|
60
|
+
if(!Nr(e))return me(e,t,r,n,o);let s=Ur(e,r);return s?me(s,t,r,n,o):null},Jr=e=>!!e.
|
|
61
|
+
identity,Gr=e=>Qr(e.status),me=(e,t,r,n,o)=>Fr(e)?ue(e,t,Dr(e),r,n):kr(e)?qr(e,o)?
|
|
62
|
+
ue(e,t,Cr(e),r,n):(n.push(new g(e.name,o,e.file)),null):(n.push(new T(o,t.file)),
|
|
63
|
+
null),ue=(e,t,r,n,o)=>{let s={};for(let p of r)if(!(!Vr(p)||p.inherited))switch(p.
|
|
64
|
+
name){default:o.push(new zr(t.name,p.name,e.file));break;case"status":s.status=Br(
|
|
65
|
+
p);break;case"headers":{s.headers=A(p.value,e,n,o),s.headers&&p.description&&(s.
|
|
66
|
+
headers.description=p.description);break}case"identity":{s.identity=m(p.value,e,
|
|
67
|
+
n,o),s.identity&&p.description&&(s.identity.description=p.description);break}case"\
|
|
68
|
+
body":{s.body=ne(p.value,e,n,o),s.body&&p.description&&(s.body.description=p.description);
|
|
69
|
+
break}}return s};import{InvalidServicePropertyError as mt,isModelDeclaration as ut,hasHeritageType as at,
|
|
70
|
+
getModelMembers as ft,getObjectMembers as dt,getReferenceType as yt}from"@ez4/common/library";
|
|
71
|
+
import{isModelProperty as Tt,isTypeObject as gt,isTypeReference as Ht}from"@ez4/reflection";import{IncorrectTypeError as Yr,InvalidTypeError as Kr}from"@ez4/common/library";
|
|
72
|
+
var I=class extends Kr{constructor(r,n){super("Invalid route request",void 0,r,n);
|
|
73
|
+
this.baseType=r}},v=class extends Yr{constructor(r,n,o){super("Incorrect route r\
|
|
74
|
+
equest",r,n,o);this.requestType=r;this.baseType=n}};import{getReferenceType as Zr,isModelDeclaration as _r}from"@ez4/common/library";
|
|
75
|
+
import{getObjectSchema as $r,isObjectSchema as Lr}from"@ez4/schema/library";import{
|
|
76
|
+
isTypeObject as et,isTypeReference as rt}from"@ez4/reflection";import{IncorrectTypeError as Wr,InvalidTypeError as Xr}from"@ez4/common/library";
|
|
77
|
+
var R=class extends Xr{constructor(t){super("Invalid request parameters",void 0,
|
|
78
|
+
"Http.PathParameters",t)}},E=class extends Wr{constructor(r,n){super("Incorrect \
|
|
79
|
+
request parameters",r,"Http.PathParameters",n);this.parametersType=r}};var ge=(e,t,r,n)=>{if(!rt(e))return ye(e,t,r,n);let o=Zr(e,r);return o?ye(o,t,r,
|
|
80
|
+
n):null},ye=(e,t,r,n)=>et(e)?Te(e,r):_r(e)?W(e)?Te(e,r):(n.push(new E(e.name,e.file)),
|
|
81
|
+
null):(n.push(new R(t.file)),null),Te=(e,t)=>{let r=$r(e,t);return r&&Lr(r)?r:null};import{getReferenceType as nt,isModelDeclaration as st}from"@ez4/common/library";
|
|
82
|
+
import{getObjectSchema as pt,isObjectSchema as it}from"@ez4/schema/library";import{
|
|
83
|
+
isTypeObject as ct,isTypeReference as lt}from"@ez4/reflection";import{IncorrectTypeError as tt,InvalidTypeError as ot}from"@ez4/common/library";
|
|
84
|
+
var j=class extends ot{constructor(t){super("Invalid request query strings",void 0,
|
|
85
|
+
"Http.QueryStrings",t)}},O=class extends tt{constructor(r,n){super("Incorrect re\
|
|
86
|
+
quest query strings",r,"Http.QueryStrings",n);this.queryType=r}};var be=(e,t,r,n)=>{if(!lt(e))return He(e,t,r,n);let o=nt(e,r);return o?He(o,t,r,
|
|
87
|
+
n):null},He=(e,t,r,n)=>ct(e)?Me(e,r):st(e)?K(e)?Me(e,r):(n.push(new O(e.name,t.file)),
|
|
88
|
+
null):(n.push(new j(t.file)),null),Me=(e,t)=>{let r=pt(e,t);return r&&it(r)?r:null};var xe=(e,t,r,n)=>Ie(e,t,r,n,"Http.AuthRequest"),Ae=(e,t,r,n)=>Ie(e,t,r,n,"Http.\
|
|
89
|
+
Request"),Ie=(e,t,r,n,o)=>{if(!Ht(e))return he(e,t,r,n,o);let s=yt(e,r);return s?
|
|
90
|
+
he(s,t,r,n,o):null},he=(e,t,r,n,o)=>gt(e)?Se(e,t,dt(e),r,n):ut(e)?at(e,o)?Se(e,t,
|
|
91
|
+
ft(e),r,n):(n.push(new v(e.name,o,e.file)),null):(n.push(new I(o,t.file)),null),
|
|
92
|
+
Se=(e,t,r,n,o)=>{let s={};for(let p of r)if(!(!Tt(p)||p.inherited))switch(p.name){default:
|
|
93
|
+
o.push(new mt(t.name,p.name,e.file));break;case"headers":{s.headers=A(p.value,e,
|
|
94
|
+
n,o),s.headers&&p.description&&(s.headers.description=p.description);break}case"\
|
|
95
|
+
identity":{s.identity=m(p.value,e,n,o),s.identity&&p.description&&(s.identity.description=
|
|
96
|
+
p.description);break}case"query":{s.query=be(p.value,e,n,o),s.query&&p.description&&
|
|
97
|
+
(s.query.description=p.description);break}case"parameters":{s.parameters=ge(p.value,
|
|
98
|
+
e,n,o),s.parameters&&p.description&&(s.parameters.description=p.description);break}case"\
|
|
99
|
+
body":{s.body=oe(p.value,e,n,o),s.body&&p.description&&(s.body.description=p.description);
|
|
100
|
+
break}}return s};var ve=(e,t,r,n)=>{if(!_(e))return null;let o={},s=new Set(["name","file"]);if(e.
|
|
101
|
+
description&&(o.description=e.description),(o.name=e.name)&&s.delete("name"),(o.
|
|
102
|
+
file=e.file)&&s.delete("file"),e.parameters){let[{value:p}]=e.parameters;o.request=
|
|
103
|
+
xe(p,t,r,n)}return e.return&&(o.response=ae(e.return,t,r,n)),Mt(o)?o:(n.push(new y(
|
|
104
|
+
[...s],e.file)),null)},Mt=e=>!!e.name&&!!e.file;import{IncompleteTypeError as bt}from"@ez4/common/library";var P=class extends bt{constructor(t,r){
|
|
105
|
+
super("Incomplete route handler",t,r)}};var Re=(e,t,r,n)=>{if(!$(e))return null;let o={},s=new Set(["name","file","respo\
|
|
106
|
+
nse"]);if(e.description&&(o.description=e.description),(o.name=e.name)&&s.delete(
|
|
107
|
+
"name"),(o.file=e.file)&&s.delete("file"),e.parameters){let[{value:p}]=e.parameters;
|
|
108
|
+
o.request=Ae(p,t,r,n)}if(e.return){let p=fe(e.return,t,r,n);p&&(o.response=p,s.delete(
|
|
109
|
+
"response"))}return ht(o)?o:(n.push(new P([...s],e.file)),null)},ht=e=>!!e.name&&
|
|
110
|
+
!!e.file&&!!e.response;var Oe=(e,t,r,n)=>{if(!At(e))return Ee(e,t,r,n);let o=zt(e,r);return o?Ee(o,t,r,
|
|
111
|
+
n):null},kt=e=>!!e.path&&!!e.handler,Ee=(e,t,r,n)=>Q(e)?je(e,t,Pt(e),r,n):xt(e)?
|
|
112
|
+
je(e,t,Ot(e),r,n):null,je=(e,t,r,n,o)=>{let s={},p=new Set(["path","handler"]);for(let i of r)
|
|
113
|
+
if(!(!St(i)||i.inherited))switch(i.name){default:o.push(new It(t.name,i.name,e.file));
|
|
114
|
+
break;case"path":{let c=jt(i);c&&F(c)&&(p.delete(i.name),s.path=c);break}case"ha\
|
|
115
|
+
ndler":(s.handler=Re(i.value,t,n,o))&&p.delete(i.name);break;case"timeout":case"\
|
|
116
|
+
memory":s[i.name]=Et(i);break;case"cors":s.cors=Rt(i);break;case"authorizer":s.authorizer=
|
|
117
|
+
ve(i.value,t,n,o);break;case"listener":s.listener=wt(i.value,o);break;case"varia\
|
|
118
|
+
bles":s.variables=vt(i,o);break}return kt(s)?s:(o.push(new d([...p],e.file)),null)};import{InvalidServicePropertyError as Bt,isModelDeclaration as Ut,getLiteralString as Vt,
|
|
119
|
+
getModelMembers as Ft,getObjectMembers as Nt,getPropertyBoolean as Qt,getPropertyNumber as Jt,
|
|
120
|
+
getPropertyTuple as Gt,getReferenceType as Yt}from"@ez4/common/library";import{isModelProperty as Kt,
|
|
121
|
+
isTypeObject as Wt,isTypeReference as Xt}from"@ez4/reflection";import{IncompleteTypeError as qt,IncorrectTypeError as Ct,InvalidTypeError as Dt}from"@ez4/common/library";
|
|
122
|
+
var w=class extends qt{constructor(t,r){super("Incomplete HTTP CORS",t,r)}},z=class extends Dt{constructor(t){
|
|
123
|
+
super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},k=class extends Ct{constructor(r,n){
|
|
124
|
+
super("Incorrect HTTP CORS type",r,"Http.Cors",n);this.fallbackType=r}};var ze=(e,t,r,n)=>{if(!Xt(e))return Pe(e,t,n);let o=Yt(e,r);return o?Pe(o,t,n):null},
|
|
125
|
+
Zt=e=>!!e.allowOrigins?.length,Pe=(e,t,r)=>Wt(e)?we(e,t,Nt(e),r):Ut(e)?Z(e)?we(e,
|
|
126
|
+
t,Ft(e),r):(r.push(new k(e.name,e.file)),null):(r.push(new z(t.file)),null),we=(e,t,r,n)=>{
|
|
127
|
+
let o={},s=new Set(["allowOrigins"]);for(let p of r)if(!(!Kt(p)||p.inherited))switch(p.
|
|
128
|
+
name){default:n.push(new Bt(t.name,p.name,e.file));break;case"allowOrigins":case"\
|
|
129
|
+
allowMethods":case"allowHeaders":case"exposeHeaders":o[p.name]=_t(p);break;case"\
|
|
130
|
+
allowCredentials":o.allowCredentials=Qt(p);break;case"maxAge":o.maxAge=Jt(p);break}
|
|
131
|
+
return Zt(o)?o:(n.push(new w([...s],e.file)),null)},_t=e=>{let t=Gt(e)??[],r=[];
|
|
132
|
+
for(let n of t){let o=Vt(n);o&&r.push(o)}return r};var ke=e=>{let t={},r=[];for(let n in e){let o=e[n];if(!N(o)||Lt(o))continue;let s={
|
|
133
|
+
type:q,extras:{}},p=new Set(["routes"]),i=o.file;s.name=o.name,o.description&&(s.
|
|
134
|
+
description=o.description);for(let c of to(o))if(!(!po(c)||c.inherited))switch(c.
|
|
135
|
+
name){default:r.push(new so(s.name,c.name,i));break;case"routes":(s.routes=co(o,
|
|
136
|
+
c,e,r))&&p.delete(c.name);break;case"name":s.displayName=oo(c);break;case"defaul\
|
|
137
|
+
ts":s.defaults=re(c.value,o,e,r);break;case"cors":s.cors=ze(c.value,o,e,r);break;case"\
|
|
138
|
+
variables":s.variables=ro(c,r);break;case"services":s.services=eo(c,e,r);break}if(!io(
|
|
139
|
+
s)){r.push(new u([...p],i));continue}if(t[o.name]){r.push(new $t(o.name,i));continue}
|
|
140
|
+
t[o.name]=s}return{services:t,errors:r}},io=e=>!!e.name&&!!e.routes&&!!e.extras,
|
|
141
|
+
co=(e,t,r,n)=>{let o=no(t)??[],s=[];for(let p of o){let i=Oe(p,e,r,n);i&&s.push(
|
|
142
|
+
i)}return s};var qe=!1,As=()=>{qe||(lo(),mo(),uo("@ez4/gateway",{"metadata:getServices":ke}),
|
|
143
|
+
qe=!1)};import{IncorrectTypeError as ao,InvalidTypeError as fo}from"@ez4/common/library";
|
|
144
|
+
var a=class extends fo{constructor(t){super("Invalid defaults",void 0,"Http.Defa\
|
|
145
|
+
ults",t)}},f=class extends ao{constructor(r,n){super("Incorrect defaults",r,"Htt\
|
|
146
|
+
p.Defaults",n);this.defaultsType=r}};export{y as IncompleteAuthorizerError,w as IncompleteCorsError,P as IncompleteHandlerError,
|
|
147
|
+
d as IncompleteRouteError,u as IncompleteServiceError,M as IncorrectBodyTypeError,
|
|
148
|
+
k as IncorrectCorsTypeError,f as IncorrectDefaultsTypeError,x as IncorrectHeadersTypeError,
|
|
149
|
+
h as IncorrectIdentityTypeError,E as IncorrectParameterTypeError,O as IncorrectQueryTypeError,
|
|
150
|
+
v as IncorrectRequestTypeError,g as IncorrectResponseTypeError,H as InvalidBodyTypeError,
|
|
151
|
+
z as InvalidCorsTypeError,a as InvalidDefaultsTypeError,S as InvalidHeadersTypeError,
|
|
152
|
+
b as InvalidIdentityTypeError,R as InvalidParameterTypeError,j as InvalidQueryTypeError,
|
|
153
|
+
I as InvalidRequestTypeError,T as InvalidResponseTypeError,q as ServiceType,xe as getHttpAuthRequest,
|
|
154
|
+
ae as getHttpAuthResponse,ve as getHttpAuthorizer,ze as getHttpCors,Re as getHttpHandler,
|
|
155
|
+
Ae as getHttpHandlerRequest,fe as getHttpHandlerResponse,A as getHttpHeaders,m as getHttpIdentity,
|
|
156
|
+
ge as getHttpParameters,be as getHttpQuery,oe as getHttpRequestBody,ne as getHttpResponseBody,
|
|
157
|
+
Oe as getHttpRoute,ke as getHttpServices,yo as isHttpService,As as registerTriggers};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType, SourceMap } from '@ez4/reflection';
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { HttpAuthorizer } from '../types/common.js';
|
|
3
|
-
export declare const getHttpAuthorizer: (type: AllType, reflection: SourceMap, errorList: Error[]) => HttpAuthorizer | null;
|
|
3
|
+
export declare const getHttpAuthorizer: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpAuthorizer | null;
|
package/dist/metadata/body.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { AllType, SourceMap, TypeModel, TypeObject } from '@ez4/reflection'
|
|
|
2
2
|
import type { ObjectSchema, UnionSchema } from '@ez4/schema/library';
|
|
3
3
|
type TypeParent = TypeObject | TypeModel;
|
|
4
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[]) => ObjectSchema | UnionSchema | import("@ez4/schema/library").
|
|
5
|
+
export declare const getHttpResponseBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | UnionSchema | import("@ez4/schema/library").BooleanSchema | import("@ez4/schema/library").NumberSchema | import("@ez4/schema/library").StringSchema | null;
|
|
6
6
|
export {};
|
package/dist/metadata/cors.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { AllType, SourceMap, TypeModel
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { HttpCors } from '../types/common.js';
|
|
3
|
-
type
|
|
4
|
-
export declare const getHttpCors: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => HttpCors | null;
|
|
5
|
-
export {};
|
|
3
|
+
export declare const getHttpCors: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpCors | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType, SourceMap, TypeModel
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { HttpDefaults } from '../types/common.js';
|
|
3
|
-
export declare const getHttpDefaults: (type: AllType, parent:
|
|
3
|
+
export declare const getHttpDefaults: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpDefaults | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType, SourceMap } from '@ez4/reflection';
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { HttpHandler } from '../types/common.js';
|
|
3
|
-
export declare const getHttpHandler: (type: AllType, reflection: SourceMap, errorList: Error[]) => HttpHandler | null;
|
|
3
|
+
export declare const getHttpHandler: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpHandler | null;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
1
2
|
import type { HttpAuthRequest, HttpRequest } from '../types/common.js';
|
|
2
|
-
|
|
3
|
-
type
|
|
4
|
-
export declare const getHttpAuthRequest: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => (HttpAuthRequest & HttpRequest) | null;
|
|
5
|
-
export declare const getHttpHandlerRequest: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => (HttpAuthRequest & HttpRequest) | null;
|
|
6
|
-
export {};
|
|
3
|
+
export declare const getHttpAuthRequest: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => (HttpAuthRequest & HttpRequest) | null;
|
|
4
|
+
export declare const getHttpHandlerRequest: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => (HttpAuthRequest & HttpRequest) | null;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
1
2
|
import type { Incomplete } from '@ez4/utils';
|
|
2
3
|
import type { HttpAuthResponse, HttpResponse } from '../types/common.js';
|
|
3
|
-
|
|
4
|
-
type
|
|
5
|
-
export declare const getHttpAuthResponse: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => Incomplete<HttpAuthResponse & HttpResponse> | null;
|
|
6
|
-
export declare const getHttpHandlerResponse: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => HttpResponse | null;
|
|
7
|
-
export {};
|
|
4
|
+
export declare const getHttpAuthResponse: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => Incomplete<HttpAuthResponse & HttpResponse> | null;
|
|
5
|
+
export declare const getHttpHandlerResponse: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpResponse | null;
|
package/dist/metadata/route.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AllType, SourceMap } from '@ez4/reflection';
|
|
1
|
+
import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { HttpRoute } from '../types/common.js';
|
|
3
|
-
export declare const getHttpRoute: (type: AllType, reflection: SourceMap, errorList: Error[]) => HttpRoute | null;
|
|
3
|
+
export declare const getHttpRoute: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpRoute | null;
|
package/dist/types/common.d.ts
CHANGED
|
@@ -48,9 +48,9 @@ export type HttpRoute = {
|
|
|
48
48
|
cors?: boolean;
|
|
49
49
|
};
|
|
50
50
|
export type HttpDefaults = {
|
|
51
|
-
listener?: ServiceListener;
|
|
52
|
-
timeout?: number;
|
|
53
|
-
memory?: number;
|
|
51
|
+
listener?: ServiceListener | null;
|
|
52
|
+
timeout?: number | null;
|
|
53
|
+
memory?: number | null;
|
|
54
54
|
};
|
|
55
55
|
export type HttpCors = {
|
|
56
56
|
allowOrigins: 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.16.0",
|
|
5
5
|
"author": "Silas B.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"directory": "packages/gateway"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=22.3.0"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
@@ -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.16.0",
|
|
46
|
+
"@ez4/project": "^0.16.0",
|
|
47
|
+
"@ez4/reflection": "^0.16.0",
|
|
48
|
+
"@ez4/schema": "^0.16.0",
|
|
49
|
+
"@ez4/utils": "^0.16.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/dist/services/cors.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP CORS configuration.
|
|
3
|
-
*/
|
|
4
|
-
export interface HttpCors {
|
|
5
|
-
/**
|
|
6
|
-
* List of allowed origins.
|
|
7
|
-
*/
|
|
8
|
-
allowOrigins: string[];
|
|
9
|
-
/**
|
|
10
|
-
* List of allowed methods.
|
|
11
|
-
*/
|
|
12
|
-
allowMethods?: string[];
|
|
13
|
-
/**
|
|
14
|
-
* Determines whether or not requests can be made with credentials.
|
|
15
|
-
*/
|
|
16
|
-
allowCredentials?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* List of allowed headers.
|
|
19
|
-
*/
|
|
20
|
-
allowHeaders?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* List of exposed headers.
|
|
23
|
-
*/
|
|
24
|
-
exposeHeaders?: string[];
|
|
25
|
-
/**
|
|
26
|
-
* Determines how long the preflight result can be cached.
|
|
27
|
-
*/
|
|
28
|
-
maxAge?: number;
|
|
29
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ArrayRest, IsArrayEmpty, IsAny } from '@ez4/utils';
|
|
2
|
-
import type { Http } from './http.js';
|
|
3
|
-
/**
|
|
4
|
-
* Given an array of requests `T` and a union of responses `U`, it returns a union of
|
|
5
|
-
* `Http.Route` for each request.
|
|
6
|
-
*/
|
|
7
|
-
export type RouteTypes<T extends Http.Request[]> = IsAny<T> extends true ? any : IsArrayEmpty<T> extends true ? Http.Route<Http.Request> : Http.Route<T[0]> | RouteTypes<ArrayRest<T>>;
|