@ez4/gateway 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/library.mjs CHANGED
@@ -1,183 +1,197 @@
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
- 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]=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
- headers.description=s.description);break}case"identity":{p.identity=u(s.value,e,
77
- o,n),p.identity&&s.description&&(p.identity.description=s.description);break}case"\
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
- 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=Ie(s.value,e,o,
105
- n),p.query&&s.description&&(p.query.description=s.description);break}case"parame\
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
- description&&(n.description=e.description),(n.name=e.name)&&p.delete("name"),(n.
110
- file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;n.request=
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
- onse"]);if(e.description&&(n.description=e.description),(n.name=e.name)&&p.delete(
115
- "name"),(n.file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;
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
- s":p.httpErrors=y(i.value,t,o,n);break;case"memory":case"logRetention":case"time\
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};
1
+ var Ge=Object.defineProperty;var p=(e,t)=>Ge(e,"name",{value:t,configurable:!0});import{registerTriggers as Go}from"@ez4/common/library";import{registerTriggers as Yo}from"@ez4/schema/library";
2
+ import{createTrigger as Ko}from"@ez4/project/library";import{DuplicateServiceError as qo,isExternalDeclaration as Do,getLinkedServiceList as Fo,
3
+ getLinkedVariableList as Bo,getModelMembers as No,getPropertyString as Uo,InvalidServicePropertyError as Vo}from"@ez4/common/library";
4
+ import{isModelProperty as Qo}from"@ez4/reflection";var Q="@ez4/http",_o=p(e=>e.type===Q,"isHttpService");import{IncompleteTypeError as Ye}from"@ez4/common/library";var y=class extends Ye{static{p(this,"IncompleteServiceError")}constructor(t,r){
5
+ super("Incomplete service",t,r)}};import{InvalidServicePropertyError as sr,isModelDeclaration as ir,getPropertyNumber as cr,
6
+ getObjectMembers as lr,getModelMembers as mr,getServiceListener as ar,getReferenceType as ur}from"@ez4/common/library";
7
+ import{isModelProperty as fr,isTypeObject as yr,isTypeReference as dr}from"@ez4/reflection";import{hasHeritageType as a,isClassDeclaration as Ke,isModelDeclaration as We}from"@ez4/common/library";
8
+ import{isTypeCallback as W,isTypeFunction as X}from"@ez4/reflection";var Xe=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),Z=p(e=>{let[
9
+ t]=e.split(" ",2);return Xe.has(t)},"isHttpPath"),_=p(e=>Ke(e)&&a(e,"Http.Servic\
10
+ e"),"isHttpService"),$=p(e=>We(e)&&a(e,"Http.Route"),"isHttpRoute");var L=p(e=>a(e,"Http.Defaults"),"isHttpDefaults"),ee=p(e=>a(e,"Http.Headers"),"i\
11
+ sHttpHeaders"),re=p(e=>a(e,"Http.Identity"),"isHttpIdentity"),te=p(e=>a(e,"Http.\
12
+ QueryStrings"),"isHttpQuery"),oe=p(e=>a(e,"Http.PathParameters"),"isHttpParamete\
13
+ rs"),ne=p(e=>a(e,"Http.JsonBody"),"isJsonBody"),pe=p(e=>a(e,"Http.Cors"),"isHttp\
14
+ Cors"),se=p(e=>a(e,"Http.Cache"),"isHttpCache"),ie=p(e=>W(e)||X(e),"isHttpAuthor\
15
+ izer"),ce=p(e=>W(e)||X(e),"isHttpHandler");import{InvalidServicePropertyError as Ze,getObjectMembers as _e,getPropertyTuple as $e,
16
+ getReferenceType as me}from"@ez4/common/library";import{isAnyNumber as Le,isEmptyObject as er}from"@ez4/utils";
17
+ import{isModelProperty as rr,isTypeClass as tr,isTypeObject as or,isTypeReference as ae}from"@ez4/reflection";var d=p((e,t,r,o)=>{if(!ae(e))return le(e,t,r,o);let n=me(e,r);return n?le(n,t,r,
18
+ o):null},"getHttpErrors"),le=p((e,t,r,o)=>or(e)?nr(e,t,_e(e),r,o):null,"getTypeE\
19
+ rrors"),nr=p((e,t,r,o,n)=>{let s={};for(let i of r){if(!rr(i)||i.inherited)continue;
20
+ let c=parseInt(i.name,10);Le(c)||n.push(new Ze(t.name,i.name,e.file));let l=pr(i,
21
+ c,t,o,n);l&&Object.assign(s,l)}return er(s)?null:s},"getTypeFromMembers"),pr=p((e,t,r,o,n)=>{
22
+ let s=$e(e)??[],i={};for(let c of s){if(!ae(c)){n.push(new u(r.file));continue}let l=me(
23
+ c,o);if(!l||!tr(l)){n.push(new u(r.file));continue}i[l.name]=t}return i},"getErr\
24
+ orClasses");var ye=p((e,t,r,o)=>{if(!dr(e))return ue(e,t,r,o);let n=ur(e,r);return n?ue(n,t,
25
+ r,o):null},"getHttpDefaults"),ue=p((e,t,r,o)=>yr(e)?fe(t,lr(e),r,o):ir(e)?L(e)?fe(
26
+ t,mr(e),r,o):(o.push(new g(e.name,t.file)),null):(o.push(new T(t.file)),null),"g\
27
+ etTypeDefaults"),fe=p((e,t,r,o)=>{let n={};for(let s of t)if(!(!fr(s)||s.inherited))
28
+ switch(s.name){default:o.push(new sr(e.name,s.name,e.file));break;case"httpError\
29
+ s":n.httpErrors=d(s.value,e,r,o);break;case"memory":case"logRetention":case"time\
30
+ out":n[s.name]=cr(s);break;case"listener":n.listener=ar(s.value,o);break}return n},
31
+ "getTypeFromMembers");import{isModelProperty as Gt,isTypeObject as Yt,isTypeReference as Kt,isTypeTuple as Wt}from"@ez4/reflection";
32
+ import{InvalidServicePropertyError as Xt,getLinkedVariableList as Zt,getPropertyBoolean as _t,
33
+ getPropertyNumber as $t,getPropertyString as Lt,getObjectMembers as eo,getModelMembers as ro,
34
+ getServiceListener as to,getReferenceType as oo,getPropertyTuple as no}from"@ez4/common/library";import{IncompleteTypeError as Tr,TypeError as gr}from"@ez4/common/library";var M=class extends Tr{static{p(this,"IncompleteRouteError")}constructor(t,r){super(
35
+ "Incomplete gateway route",t,r)}},u=class extends gr{static{p(this,"InvalidRoute\
36
+ ErrorTypeError")}constructor(t){super("Invalid route error type.",t)}};import{IncompleteTypeError as Mr}from"@ez4/common/library";var H=class extends Mr{static{p(this,"IncompleteAuthorizerError")}constructor(t,r){
37
+ super("Incomplete route authorizer",t,r)}};import{InvalidServicePropertyError as ot,isModelDeclaration as nt,hasHeritageType as pt,
38
+ getModelMembers as st,getObjectMembers as it,getPropertyNumber as ct,getReferenceType as lt}from"@ez4/common/library";
39
+ import{isModelProperty as mt,isTypeObject as at,isTypeReference as ut}from"@ez4/reflection";
40
+ import{isAnyNumber as ft}from"@ez4/utils";import{IncorrectTypeError as Hr,InvalidTypeError as hr}from"@ez4/common/library";var h=class extends hr{constructor(r,o){super("Invalid route response",void 0,r,
41
+ o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},b=class extends Hr{constructor(r,o,n){
42
+ super("Incorrect route response",r,o,n);this.responseType=r;this.baseType=o}static{
43
+ p(this,"IncorrectResponseTypeError")}};import{isTypeIntersection as Ar,isTypeObject as Er,isTypeReference as vr,isTypeUndefined as Rr,
44
+ isTypeUnion as Pr}from"@ez4/reflection";import{getReferenceType as jr,isModelDeclaration as wr}from"@ez4/common/library";
45
+ import{createUnionSchema as Or}from"@ez4/schema/library";import{IncorrectTypeError as br,InvalidTypeError as Sr}from"@ez4/common/library";var S=class extends Sr{static{p(this,"InvalidIdentityTypeError")}constructor(t){
46
+ super("Invalid identity",void 0,"Http.Identity",t)}},x=class extends br{constructor(r,o){
47
+ super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}static{p(this,
48
+ "IncorrectIdentityTypeError")}};import{getObjectSchema as xr,isObjectSchema as Ir}from"@ez4/schema/library";var m=p((e,t)=>{let r=xr(e,t);return r&&Ir(r)?r:null},"getSchemaFromType");var f=p((e,t,r,o)=>{if(Rr(e))return null;if(!vr(e))return de(e,t,r,o);let n=jr(e,
49
+ r);return n?de(n,t,r,o):null},"getHttpIdentity"),de=p((e,t,r,o)=>{if(Pr(e))return zr(
50
+ e.elements,t,r,o);if(Er(e)||Ar(e))return m(e,r);if(!wr(e))return o.push(new S(t.
51
+ file)),null;if(!re(e))return o.push(new x(e.name,t.file)),null;let n=m(e,r);return n&&
52
+ (n.definitions={...n.definitions,extensible:!0}),n},"getTypeIdentity"),zr=p((e,t,r,o)=>{
53
+ let n=[];for(let s of e){let i=f(s,t,r,o);i&&n.push(i)}return n.length>1?Or({elements:n}):
54
+ n[0]},"getIdentityFromUnion");import{isTypeIntersection as qr,isTypeObject as Dr,isTypeReference as Fr}from"@ez4/reflection";
55
+ import{getReferenceType as Br,isModelDeclaration as Nr}from"@ez4/common/library";import{IncorrectTypeError as Cr,InvalidTypeError as kr}from"@ez4/common/library";var I=class extends kr{static{p(this,"InvalidHeadersTypeError")}constructor(t){super(
56
+ "Invalid headers",void 0,"Http.Headers",t)}},A=class extends Cr{constructor(r,o){
57
+ super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}static{p(this,"\
58
+ IncorrectHeadersTypeError")}};var E=p((e,t,r,o)=>{if(!Fr(e))return Te(e,t,r,o);let n=Br(e,r);return n?Te(n,t,r,
59
+ o):null},"getHttpHeaders"),Te=p((e,t,r,o)=>Dr(e)||qr(e)?m(e,r):Nr(e)?ee(e)?m(e,r):
60
+ (o.push(new A(e.name,t.file)),null):(o.push(new I(t.file)),null),"getTypeHeaders");import{createUnionSchema as Qr,getScalarSchema as Jr,createArraySchema as Gr}from"@ez4/schema/library";
61
+ import{getReferenceType as Yr,isModelDeclaration as Kr}from"@ez4/common/library";
62
+ import{isTypeArray as Wr,isTypeIntersection as Xr,isTypeObject as Zr,isTypeReference as _r,
63
+ isTypeScalar as $r,isTypeUndefined as Lr,isTypeUnion as et}from"@ez4/reflection";import{IncorrectTypeError as Ur,InvalidTypeError as Vr}from"@ez4/common/library";var v=class extends Vr{static{p(this,"InvalidBodyTypeError")}constructor(t){super(
64
+ "Invalid body",void 0,"Http.JsonBody",t)}},R=class extends Ur{constructor(r,o){super(
65
+ "Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}static{p(this,"IncorrectBo\
66
+ dyTypeError")}};var P=p((e,t,r,o)=>Y(e,r,n=>J(n)??G(n,t,r,o)),"getHttpBody"),Y=p((e,t,r)=>{if(Lr(
67
+ e))return null;if(!_r(e))return r(e);let o=Yr(e,t);return o?r(o):null},"getTypeB\
68
+ ody"),J=p(e=>$r(e)?Jr(e):null,"getScalarTypeBody"),G=p((e,t,r,o)=>et(e)?rt(e.elements,
69
+ r,n=>J(n)??G(n,t,r,o)):Wr(e)?tt(e.element,r,n=>J(n)??G(n,t,r,o)):Zr(e)||Xr(e)?m(
70
+ e,r):Kr(e)?ne(e)?m(e,r):(o.push(new R(e.name,e.file)),null):(o.push(new v(t.file)),
71
+ null),"getCompoundTypeBody"),rt=p((e,t,r)=>{let o=[];for(let n of e){let s=Y(n,t,
72
+ r);s&&o.push(s)}return o.length?Qr({elements:o}):null},"getUnionTypeBody"),tt=p(
73
+ (e,t,r)=>{let o=Y(e,t,r);return o?Gr({element:o}):null},"getArrayTypeBody");var He=p((e,t,r,o)=>{let n=be(e,t,r,o,"Http.AuthResponse");return n&&yt(n)?n:null},
74
+ "getHttpAuthResponse"),he=p((e,t,r,o)=>{let n=be(e,t,r,o,"Http.Response");return n&&
75
+ dt(n)?n:null},"getHttpHandlerResponse"),be=p((e,t,r,o,n)=>{if(!ut(e))return ge(e,
76
+ t,r,o,n);let s=lt(e,r);return s?ge(s,t,r,o,n):null},"getHttpResponse"),yt=p(e=>!!e.
77
+ identity,"isValidAuthResponse"),dt=p(e=>ft(e.status),"isValidHandlerResponse"),ge=p(
78
+ (e,t,r,o,n)=>at(e)?Me(e,t,it(e),r,o):nt(e)?pt(e,n)?Me(e,t,st(e),r,o):(o.push(new b(
79
+ e.name,n,e.file)),null):(o.push(new h(n,t.file)),null),"getTypeResponse"),Me=p((e,t,r,o,n)=>{
80
+ let s={};for(let i of r)if(!(!mt(i)||i.inherited))switch(i.name){default:n.push(
81
+ new ot(t.name,i.name,e.file));break;case"status":s.status=ct(i);break;case"heade\
82
+ rs":{s.headers=E(i.value,e,o,n),s.headers&&i.description&&(s.headers.description=
83
+ i.description);break}case"identity":{s.identity=f(i.value,e,o,n),s.identity&&i.description&&
84
+ (s.identity.description=i.description);break}case"body":{s.body=P(i.value,e,o,n),
85
+ s.body&&i.description&&(s.body.description=i.description);break}}return s},"getT\
86
+ ypeFromMembers");import{isModelProperty as Ot,isTypeIntersection as zt,isTypeObject as Ct,isTypeReference as kt}from"@ez4/reflection";
87
+ import{InvalidServicePropertyError as qt,isModelDeclaration as Dt,hasHeritageType as Ft,
88
+ getObjectMembers as Bt,getModelMembers as Nt,getReferenceType as Ut}from"@ez4/common/library";import{IncorrectTypeError as Tt,InvalidTypeError as gt}from"@ez4/common/library";var j=class extends gt{constructor(r,o){super("Invalid route request",void 0,r,o);
89
+ this.baseType=r}static{p(this,"InvalidRequestTypeError")}},w=class extends Tt{constructor(r,o,n){
90
+ super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}static{
91
+ p(this,"IncorrectRequestTypeError")}};import{isTypeIntersection as ht,isTypeObject as bt,isTypeReference as St}from"@ez4/reflection";
92
+ import{getReferenceType as xt,isModelDeclaration as It}from"@ez4/common/library";import{IncorrectTypeError as Mt,InvalidTypeError as Ht}from"@ez4/common/library";var O=class extends Ht{static{p(this,"InvalidParameterTypeError")}constructor(t){
93
+ super("Invalid request parameters",void 0,"Http.PathParameters",t)}},z=class extends Mt{constructor(r,o){
94
+ super("Incorrect request parameters",r,"Http.PathParameters",o);this.parametersType=
95
+ r}static{p(this,"IncorrectParameterTypeError")}};var xe=p((e,t,r,o)=>{if(!St(e))return Se(e,t,r,o);let n=xt(e,r);return n?Se(n,t,
96
+ r,o):null},"getHttpParameters"),Se=p((e,t,r,o)=>bt(e)||ht(e)?m(e,r):It(e)?oe(e)?
97
+ m(e,r):(o.push(new z(e.name,e.file)),null):(o.push(new O(t.file)),null),"getType\
98
+ Parameter");import{isTypeIntersection as vt,isTypeObject as Rt,isTypeReference as Pt}from"@ez4/reflection";
99
+ import{getReferenceType as jt,isModelDeclaration as wt}from"@ez4/common/library";import{IncorrectTypeError as At,InvalidTypeError as Et}from"@ez4/common/library";var C=class extends Et{static{p(this,"InvalidQueryTypeError")}constructor(t){super(
100
+ "Invalid request query strings",void 0,"Http.QueryStrings",t)}},k=class extends At{constructor(r,o){
101
+ super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
102
+ r}static{p(this,"IncorrectQueryTypeError")}};var Ae=p((e,t,r,o)=>{if(!Pt(e))return Ie(e,t,r,o);let n=jt(e,r);return n?Ie(n,t,
103
+ r,o):null},"getHttpQuery"),Ie=p((e,t,r,o)=>Rt(e)||vt(e)?m(e,r):wt(e)?te(e)?m(e,r):
104
+ (o.push(new k(e.name,t.file)),null):(o.push(new C(t.file)),null),"getTypeQuery");var Re=p((e,t,r,o)=>K(e,t,r,o,"Http.AuthRequest"),"getHttpAuthRequest"),Pe=p((e,t,r,o)=>K(
105
+ e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),K=p((e,t,r,o,n)=>{if(zt(e)&&e.elements.
106
+ length>0)return K(e.elements[0],t,r,o,n);if(!kt(e))return Ee(e,t,r,o,n);let s=Ut(
107
+ e,r);return s?Ee(s,t,r,o,n):null},"getHttpRequest"),Ee=p((e,t,r,o,n)=>Ct(e)?ve(e,
108
+ t,Bt(e),r,o):Dt(e)?Ft(e,n)?ve(e,t,Nt(e),r,o):(o.push(new w(e.name,n,e.file)),null):
109
+ (o.push(new j(n,t.file)),null),"getTypeRequest"),ve=p((e,t,r,o,n)=>{let s={};for(let i of r)
110
+ if(!(!Ot(i)||i.inherited))switch(i.name){default:n.push(new qt(t.name,i.name,e.file));
111
+ break;case"headers":{s.headers=E(i.value,e,o,n),s.headers&&i.description&&(s.headers.
112
+ description=i.description);break}case"identity":{s.identity=f(i.value,e,o,n),s.identity&&
113
+ i.description&&(s.identity.description=i.description);break}case"query":{s.query=
114
+ Ae(i.value,e,o,n),s.query&&i.description&&(s.query.description=i.description);break}case"\
115
+ parameters":{s.parameters=xe(i.value,e,o,n),s.parameters&&i.description&&(s.parameters.
116
+ description=i.description);break}case"body":{s.body=P(i.value,e,o,n),s.body&&i.description&&
117
+ (s.body.description=i.description);break}}return s},"getTypeFromMembers");var je=p((e,t,r,o)=>{if(!ie(e))return null;let n={},s=new Set(["name","file"]);if(e.
118
+ description&&(n.description=e.description),(n.name=e.name)&&s.delete("name"),(n.
119
+ file=e.file)&&s.delete("file"),e.parameters){let[{value:i}]=e.parameters;n.request=
120
+ Re(i,t,r,o)}return e.return&&(n.response=He(e.return,t,r,o)),Vt(n)?n:(o.push(new H(
121
+ [...s],e.file)),null)},"getHttpAuthorizer"),Vt=p(e=>!!e.name&&!!e.file,"isValidA\
122
+ uthorizer");import{IncompleteTypeError as Qt}from"@ez4/common/library";var q=class extends Qt{static{p(this,"IncompleteHandlerError")}constructor(t,r){
123
+ super("Incomplete route handler",t,r)}};var we=p((e,t,r,o)=>{if(!ce(e))return null;let n={},s=new Set(["name","file","re\
124
+ sponse"]);if(e.description&&(n.description=e.description),(n.name=e.name)&&s.delete(
125
+ "name"),(n.file=e.file)&&s.delete("file"),e.parameters){let[{value:i}]=e.parameters;
126
+ n.request=Pe(i,t,r,o)}if(e.return){let i=he(e.return,t,r,o);i&&(n.response=i,s.delete(
127
+ "response"))}return Jt(n)?n:(o.push(new q([...s],e.file)),null)},"getHttpHandler"),
128
+ Jt=p(e=>!!e.name&&!!e.file&&!!e.response,"isValidHandler");var Ce=p((e,t,r,o)=>{let n=no(t)??[];return ke(n,e,r,o)},"getHttpRoutes"),ke=p((e,t,r,o)=>{
129
+ let n=[];for(let s of e){let i=po(s,t,r,o);Array.isArray(i)?n.push(...i):i&&n.push(
130
+ i)}return n},"getRouteFromTuple"),po=p((e,t,r,o)=>{if(!Kt(e))return Oe(e,t,r,o);
131
+ let n=oo(e,r);return n?Oe(n,t,r,o):null},"getTypeFromRoute"),so=p(e=>!!e.path&&!!e.
132
+ handler,"isValidRoute"),Oe=p((e,t,r,o)=>$(e)?ze(e,t,ro(e),r,o):Yt(e)?ze(e,t,eo(e),
133
+ r,o):Wt(e)&&e.spread?ke(e.elements,t,r,o):null,"getRouteType"),ze=p((e,t,r,o,n)=>{
134
+ let s={},i=new Set(["path","handler"]);for(let c of r)if(!(!Gt(c)||c.inherited))
135
+ switch(c.name){default:n.push(new Xt(t.name,c.name,e.file));break;case"path":{let l=Lt(
136
+ c);l&&Z(l)&&(i.delete(c.name),s.path=l);break}case"handler":(s.handler=we(c.value,
137
+ t,o,n))&&i.delete(c.name);break;case"authorizer":s.authorizer=je(c.value,t,o,n);
138
+ break;case"httpErrors":s.httpErrors=d(c.value,t,o,n);break;case"memory":case"log\
139
+ Retention":case"timeout":s[c.name]=$t(c);break;case"cors":s.cors=_t(c);break;case"\
140
+ listener":s.listener=to(c.value,n);break;case"variables":s.variables=Zt(c,n);break}
141
+ return so(s)?s:(n.push(new M([...i],e.file)),null)},"getTypeFromMembers");import{InvalidServicePropertyError as mo,isModelDeclaration as ao,getModelMembers as uo,
142
+ getObjectMembers as fo,getPropertyBoolean as yo,getPropertyStringList as To,getPropertyNumber as go,
143
+ getReferenceType as Mo}from"@ez4/common/library";import{isModelProperty as Ho,isTypeObject as ho,
144
+ isTypeReference as bo}from"@ez4/reflection";import{IncompleteTypeError as io,IncorrectTypeError as co,InvalidTypeError as lo}from"@ez4/common/library";var D=class extends io{static{p(this,"IncompleteCorsError")}constructor(t,r){super(
145
+ "Incomplete HTTP CORS",t,r)}},F=class extends lo{static{p(this,"InvalidCorsTypeE\
146
+ rror")}constructor(t){super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},B=class extends co{constructor(r,o){
147
+ super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}static{p(this,
148
+ "IncorrectCorsTypeError")}};var Fe=p((e,t,r,o)=>{if(!bo(e))return qe(e,t,o);let n=Mo(e,r);return n?qe(n,t,o):
149
+ null},"getHttpCors"),So=p(e=>!!e.allowOrigins?.length,"isValidCors"),qe=p((e,t,r)=>ho(
150
+ e)?De(e,t,fo(e),r):ao(e)?pe(e)?De(e,t,uo(e),r):(r.push(new B(e.name,e.file)),null):
151
+ (r.push(new F(t.file)),null),"getTypeCors"),De=p((e,t,r,o)=>{let n={},s=new Set(
152
+ ["allowOrigins"]);for(let i of r)if(!(!Ho(i)||i.inherited))switch(i.name){default:
153
+ o.push(new mo(t.name,i.name,e.file));break;case"allowOrigins":case"allowMethods":case"\
154
+ allowHeaders":case"exposeHeaders":n[i.name]=To(i);break;case"allowCredentials":n.
155
+ allowCredentials=yo(i);break;case"maxAge":n.maxAge=go(i);break}return So(n)?n:(o.
156
+ push(new D([...s],e.file)),null)},"getTypeFromMembers");import{InvalidServicePropertyError as Eo,isModelDeclaration as vo,getModelMembers as Ro,
157
+ getObjectMembers as Po,getPropertyNumber as jo,getReferenceType as wo}from"@ez4/common/library";
158
+ import{isModelProperty as Oo,isTypeObject as zo,isTypeReference as Co}from"@ez4/reflection";
159
+ import{isAnyNumber as Ue}from"@ez4/utils";import{IncompleteTypeError as xo,IncorrectTypeError as Io,InvalidTypeError as Ao}from"@ez4/common/library";var N=class extends xo{static{p(this,"IncompleteCacheError")}constructor(t,r){super(
160
+ "Incomplete gateway cache",t,r)}},U=class extends Ao{static{p(this,"InvalidCache\
161
+ TypeError")}constructor(t){super("Invalid gateway cache type",void 0,"Http.Cache",
162
+ t)}},V=class extends Io{constructor(r,o){super("Incorrect gateway cache type",r,
163
+ "Http.Cache",o);this.cacheType=r}static{p(this,"IncorrectCacheTypeError")}};var Ve=p((e,t,r,o)=>{if(!Co(e))return Be(e,t,o);let n=wo(e,r);return n?Be(n,t,o):
164
+ null},"getHttpCache"),ko=p(e=>Ue(e.authorizerTTL),"isValidCache"),Be=p((e,t,r)=>zo(
165
+ e)?Ne(e,t,Po(e),r):vo(e)?se(e)?Ne(e,t,Ro(e),r):(r.push(new V(e.name,e.file)),null):
166
+ (r.push(new U(t.file)),null),"getTypeCache"),Ne=p((e,t,r,o)=>{let n={},s=new Set(
167
+ ["authorizerTTL"]);for(let i of r)if(!(!Oo(i)||i.inherited))switch(i.name){default:
168
+ o.push(new Eo(t.name,i.name,e.file));break;case"authorizerTTL":{let c=jo(i);Ue(c)&&
169
+ (n[i.name]=c,s.delete(i.name));break}}return ko(n)?n:(o.push(new N([...s],e.file)),
170
+ null)},"getTypeFromMembers");var Qe=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!_(n)||Do(n))continue;let s={
171
+ type:Q,extras:{}},i=new Set(["routes"]),c=n.file;s.name=n.name,n.description&&(s.
172
+ description=n.description);for(let l of No(n))if(!(!Qo(l)||l.inherited))switch(l.
173
+ name){default:r.push(new Vo(s.name,l.name,c));break;case"routes":(s.routes=Ce(n,
174
+ l,e,r))&&i.delete(l.name);break;case"name":s.displayName=Uo(l);break;case"defaul\
175
+ ts":s.defaults=ye(l.value,n,e,r);break;case"cache":s.cache=Ve(l.value,n,e,r);break;case"\
176
+ cors":s.cors=Fe(l.value,n,e,r);break;case"variables":s.variables=Bo(l,r);break;case"\
177
+ services":s.services=Fo(l,e,r);break}if(!Jo(s)){r.push(new y([...i],c));continue}
178
+ if(t[n.name]){r.push(new qo(n.name,c));continue}t[n.name]=s}return{services:t,errors:r}},
179
+ "getHttpServices"),Jo=p(e=>!!e.name&&!!e.routes&&!!e.extras,"isValidService");var Je=!1,oi=p(()=>{Je||(Go(),Yo(),Ko("@ez4/gateway",{"metadata:getServices":Qe}),
180
+ Je=!0)},"registerTriggers");import{IncorrectTypeError as Wo,InvalidTypeError as Xo}from"@ez4/common/library";var T=class extends Xo{static{p(this,"InvalidDefaultsTypeError")}constructor(t){
181
+ super("Invalid defaults",void 0,"Http.Defaults",t)}},g=class extends Wo{constructor(r,o){
182
+ super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}static{p(this,
183
+ "IncorrectDefaultsTypeError")}};export{H as IncompleteAuthorizerError,N as IncompleteCacheError,D as IncompleteCorsError,
184
+ q as IncompleteHandlerError,M as IncompleteRouteError,y as IncompleteServiceError,
185
+ R as IncorrectBodyTypeError,V as IncorrectCacheTypeError,B as IncorrectCorsTypeError,
186
+ g as IncorrectDefaultsTypeError,A as IncorrectHeadersTypeError,x as IncorrectIdentityTypeError,
187
+ z as IncorrectParameterTypeError,k as IncorrectQueryTypeError,w as IncorrectRequestTypeError,
188
+ b as IncorrectResponseTypeError,v as InvalidBodyTypeError,U as InvalidCacheTypeError,
189
+ F as InvalidCorsTypeError,T as InvalidDefaultsTypeError,I as InvalidHeadersTypeError,
190
+ S as InvalidIdentityTypeError,O as InvalidParameterTypeError,C as InvalidQueryTypeError,
191
+ j as InvalidRequestTypeError,h as InvalidResponseTypeError,u as InvalidRouteErrorTypeError,
192
+ Q as ServiceType,Re as getHttpAuthRequest,He as getHttpAuthResponse,je as getHttpAuthorizer,
193
+ P as getHttpBody,Ve as getHttpCache,Fe as getHttpCors,we as getHttpHandler,Pe as getHttpHandlerRequest,
194
+ he as getHttpHandlerResponse,E as getHttpHeaders,f as getHttpIdentity,xe as getHttpParameters,
195
+ Ae as getHttpQuery,Ce as getHttpRoutes,Qe as getHttpServices,_o as isHttpService,
196
+ oi as registerTriggers};
183
197
  //# sourceMappingURL=library.mjs.map
package/dist/main.cjs CHANGED
@@ -1,15 +1,18 @@
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
- e)}};0&&(module.exports={Http,HttpBadRequestError,HttpError,HttpForbiddenError,HttpInternalServerError,
1
+ "use strict";var u=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var p=(s,t)=>u(s,"name",{value:t,configurable:!0});var g=(s,t)=>{for(var e in t)u(s,e,{get:t[e],enumerable:!0})},S=(s,t,e,n)=>{if(t&&
2
+ typeof t=="object"||typeof t=="function")for(let o of l(t))!h.call(s,o)&&o!==e&&
3
+ u(s,o,{get:()=>t[o],enumerable:!(n=R(t,o))||n.enumerable});return s};var q=s=>S(u({},"__esModule",{value:!0}),s);var b={};g(b,{Http:()=>H,HttpBadRequestError:()=>i,HttpError:()=>r,HttpForbiddenError:()=>a,
4
+ HttpInternalServerError:()=>m,HttpNotFoundError:()=>x,HttpUnauthorizedError:()=>c,
5
+ HttpUnprocessableEntityError:()=>d,HttpUnsupportedMediaTypeError:()=>y});module.
6
+ exports=q(b);var H;(s=>{})(H||={});var r=class extends Error{constructor(e,n,o){super(n);this.status=e;this.message=
7
+ n;this.details=o}static{p(this,"HttpError")}},i=class extends r{static{p(this,"H\
8
+ ttpBadRequestError")}constructor(t,e){super(400,t||"Bad request",e)}},c=class extends r{static{
9
+ p(this,"HttpUnauthorizedError")}constructor(t,e){super(401,t||"Unauthorized",e)}},
10
+ a=class extends r{static{p(this,"HttpForbiddenError")}constructor(t,e){super(403,
11
+ t||"Forbidden",e)}},x=class extends r{static{p(this,"HttpNotFoundError")}constructor(t,e){
12
+ super(404,t||"Not found",e)}},y=class extends r{static{p(this,"HttpUnsupportedMe\
13
+ diaTypeError")}constructor(t,e){super(415,t||"Unsupported media type",e)}},d=class extends r{static{
14
+ p(this,"HttpUnprocessableEntityError")}constructor(t,e){super(422,t||"Unprocessa\
15
+ ble entity",e)}},m=class extends r{static{p(this,"HttpInternalServerError")}constructor(t,e){
16
+ super(500,t||"Internal server error",e)}};0&&(module.exports={Http,HttpBadRequestError,HttpError,HttpForbiddenError,HttpInternalServerError,
14
17
  HttpNotFoundError,HttpUnauthorizedError,HttpUnprocessableEntityError,HttpUnsupportedMediaTypeError});
15
18
  //# sourceMappingURL=main.cjs.map
package/dist/main.mjs CHANGED
@@ -1,11 +1,14 @@
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
- i as HttpUnsupportedMediaTypeError};
1
+ var d=Object.defineProperty;var r=(s,t)=>d(s,"name",{value:t,configurable:!0});var m;(s=>{})(m||={});var p=class extends Error{constructor(e,y,H){super(y);this.status=e;this.message=
2
+ y;this.details=H}static{r(this,"HttpError")}},o=class extends p{static{r(this,"H\
3
+ ttpBadRequestError")}constructor(t,e){super(400,t||"Bad request",e)}},n=class extends p{static{
4
+ r(this,"HttpUnauthorizedError")}constructor(t,e){super(401,t||"Unauthorized",e)}},
5
+ u=class extends p{static{r(this,"HttpForbiddenError")}constructor(t,e){super(403,
6
+ t||"Forbidden",e)}},i=class extends p{static{r(this,"HttpNotFoundError")}constructor(t,e){
7
+ super(404,t||"Not found",e)}},c=class extends p{static{r(this,"HttpUnsupportedMe\
8
+ diaTypeError")}constructor(t,e){super(415,t||"Unsupported media type",e)}},a=class extends p{static{
9
+ r(this,"HttpUnprocessableEntityError")}constructor(t,e){super(422,t||"Unprocessa\
10
+ ble entity",e)}},x=class extends p{static{r(this,"HttpInternalServerError")}constructor(t,e){
11
+ super(500,t||"Internal server error",e)}};export{m as Http,o as HttpBadRequestError,p as HttpError,u as HttpForbiddenError,
12
+ x as HttpInternalServerError,i as HttpNotFoundError,n as HttpUnauthorizedError,a as HttpUnprocessableEntityError,
13
+ c as HttpUnsupportedMediaTypeError};
11
14
  //# sourceMappingURL=main.mjs.map
@@ -0,0 +1,4 @@
1
+ import type { AnySchema } from '@ez4/schema';
2
+ import type { Http } from '../services/contract.js';
3
+ export declare const getRequestBody: <T extends Http.JsonBody | Http.RawBody>(input: T, schema: AnySchema) => Promise<T>;
4
+ export declare const getResponseBody: (body: unknown, schema: AnySchema) => unknown;
@@ -0,0 +1,13 @@
1
+ import type { HttpError } from '@ez4/gateway';
2
+ /**
3
+ * Get a JSON error response for the given HTTP error.
4
+ *
5
+ * @returns Returns an error response containing `status`, `message` and `details`.
6
+ */
7
+ export declare const getJsonError: ({ status, message, details }: HttpError) => {
8
+ status: number;
9
+ body: {
10
+ message: string;
11
+ details: string[] | undefined;
12
+ };
13
+ };
@@ -0,0 +1,3 @@
1
+ import type { ObjectSchema } from '@ez4/schema';
2
+ import type { Http } from '@ez4/gateway';
3
+ export declare const getHeaders: <T extends Http.Headers>(input: T, schema: ObjectSchema) => Promise<T>;
@@ -0,0 +1,3 @@
1
+ import type { ObjectSchema, UnionSchema } from '@ez4/schema';
2
+ import type { Http } from '@ez4/gateway';
3
+ export declare const getIdentity: <T extends Http.Identity>(input: T, schema: ObjectSchema | UnionSchema) => Promise<T>;
@@ -0,0 +1,3 @@
1
+ import type { ObjectSchema } from '@ez4/schema';
2
+ import type { Http } from '@ez4/gateway';
3
+ export declare const getPathParameters: <T extends Http.PathParameters>(input: T, schema: ObjectSchema) => Promise<T>;
@@ -0,0 +1,3 @@
1
+ import type { ObjectSchema } from '@ez4/schema';
2
+ import type { Http } from '@ez4/gateway';
3
+ export declare const getQueryStrings: <T extends Http.QueryStrings>(input: T, schema: ObjectSchema) => Promise<T>;