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