@ez4/gateway 0.18.0 → 0.20.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.
@@ -1,4 +1,7 @@
1
- import { IncompleteTypeError } from '@ez4/common/library';
1
+ import { IncompleteTypeError, TypeError } from '@ez4/common/library';
2
2
  export declare class IncompleteRouteError extends IncompleteTypeError {
3
3
  constructor(properties: string[], fileName?: string);
4
4
  }
5
+ export declare class InvalidRouteErrorTypeError extends TypeError {
6
+ constructor(fileName?: string);
7
+ }
package/dist/library.cjs CHANGED
@@ -1,178 +1,189 @@
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){
80
- super("Incorrect request parameters",r,"Http.PathParameters",n);this.parametersType=
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){
87
- super("Incorrect request query strings",r,"Http.QueryStrings",n);this.queryType=
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(
1
+ "use strict";var je=Object.defineProperty;var Dr=Object.getOwnPropertyDescriptor;var Fr=Object.getOwnPropertyNames;var Br=Object.prototype.hasOwnProperty;var Nr=(e,t)=>{for(var r in t)je(e,r,{get:t[r],enumerable:!0})},Ur=(e,t,r,o)=>{if(t&&
2
+ typeof t=="object"||typeof t=="function")for(let n of Fr(t))!Br.call(e,n)&&n!==r&&
3
+ je(e,n,{get:()=>t[n],enumerable:!(o=Dr(t,n))||o.enumerable});return e};var Vr=e=>Ur(je({},"__esModule",{value:!0}),e);var st={};Nr(st,{IncompleteAuthorizerError:()=>U,IncompleteCacheError:()=>ie,IncompleteCorsError:()=>ne,
4
+ IncompleteHandlerError:()=>oe,IncompleteRouteError:()=>N,IncompleteServiceError:()=>D,
5
+ IncorrectBodyTypeError:()=>G,IncorrectCacheTypeError:()=>le,IncorrectCorsTypeError:()=>se,
6
+ IncorrectDefaultsTypeError:()=>B,IncorrectHeadersTypeError:()=>X,IncorrectIdentityTypeError:()=>K,
7
+ IncorrectParameterTypeError:()=>ee,IncorrectQueryTypeError:()=>te,IncorrectRequestTypeError:()=>$,
8
+ IncorrectResponseTypeError:()=>Q,InvalidBodyTypeError:()=>J,InvalidCacheTypeError:()=>ce,
9
+ InvalidCorsTypeError:()=>pe,InvalidDefaultsTypeError:()=>F,InvalidHeadersTypeError:()=>W,
10
+ InvalidIdentityTypeError:()=>Y,InvalidParameterTypeError:()=>L,InvalidQueryTypeError:()=>re,
11
+ InvalidRequestTypeError:()=>_,InvalidResponseTypeError:()=>V,InvalidRouteErrorTypeError:()=>A,
12
+ ServiceType:()=>me,getHttpAuthRequest:()=>Fe,getHttpAuthResponse:()=>Ce,getHttpAuthorizer:()=>Ue,
13
+ getHttpCache:()=>Ye,getHttpCors:()=>Je,getHttpHandler:()=>Ve,getHttpHandlerRequest:()=>Be,
14
+ getHttpHandlerResponse:()=>ke,getHttpHeaders:()=>Z,getHttpIdentity:()=>R,getHttpParameters:()=>qe,
15
+ getHttpQuery:()=>De,getHttpRequestBody:()=>Oe,getHttpResponseBody:()=>ze,getHttpRoutes:()=>Qe,
16
+ getHttpServices:()=>Ke,isHttpService:()=>Qr,registerTriggers:()=>pt});module.exports=
17
+ Vr(st);var Cr=require("@ez4/common/library"),kr=require("@ez4/schema/library"),qr=require("@ez4/project/library");var T=require("@ez4/common/library"),Or=require("@ez4/reflection");var me="@ez4/http",Qr=e=>e.type===me;var We=require("@ez4/common/library"),D=class extends We.IncompleteTypeError{constructor(t,r){
18
+ super("Incomplete service",t,r)}};var f=require("@ez4/common/library"),E=require("@ez4/reflection");var a=require("@ez4/common/library"),I=require("@ez4/reflection"),Jr=new Set(["A\
19
+ NY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),Xe=e=>{let[t]=e.split(" ",2);
20
+ return Jr.has(t)},Ze=e=>(0,a.isClassDeclaration)(e)&&(0,a.hasHeritageType)(e,"Ht\
21
+ tp.Service"),_e=e=>(0,a.isModelDeclaration)(e)&&(0,a.hasHeritageType)(e,"Http.Ro\
22
+ ute");var $e=e=>(0,a.hasHeritageType)(e,"Http.Defaults"),Le=e=>(0,a.hasHeritageType)(e,
23
+ "Http.Headers"),er=e=>(0,a.hasHeritageType)(e,"Http.Identity"),rr=e=>(0,a.hasHeritageType)(
24
+ e,"Http.QueryStrings"),tr=e=>(0,a.hasHeritageType)(e,"Http.PathParameters"),or=e=>(0,a.hasHeritageType)(
25
+ e,"Http.JsonBody"),nr=e=>(0,a.hasHeritageType)(e,"Http.Cors"),pr=e=>(0,a.hasHeritageType)(
26
+ e,"Http.Cache"),sr=e=>(0,I.isTypeCallback)(e)||(0,I.isTypeFunction)(e),ir=e=>(0,I.isTypeCallback)(
27
+ e)||(0,I.isTypeFunction)(e);var h=require("@ez4/common/library"),ae=require("@ez4/utils"),b=require("@ez4/reflection");var ue=(e,t,r,o)=>{if(!(0,b.isTypeReference)(e))return cr(e,t,r,o);let n=(0,h.getReferenceType)(
28
+ e,r);return n?cr(n,t,r,o):null},cr=(e,t,r,o)=>(0,b.isTypeObject)(e)?Gr(e,t,(0,h.getObjectMembers)(
29
+ e),r,o):null,Gr=(e,t,r,o,n)=>{let p={};for(let s of r){if(!(0,b.isModelProperty)(
30
+ s)||s.inherited)continue;let i=parseInt(s.name,10);(0,ae.isAnyNumber)(i)||n.push(
31
+ new h.InvalidServicePropertyError(t.name,s.name,e.file));let c=Yr(s,i,t,o,n);c&&
32
+ Object.assign(p,c)}return(0,ae.isEmptyObject)(p)?null:p},Yr=(e,t,r,o,n)=>{let p=(0,h.getPropertyTuple)(
33
+ e)??[],s={};for(let i of p){if(!(0,b.isTypeReference)(i)){n.push(new A(r.file));
34
+ continue}let c=(0,h.getReferenceType)(i,o);if(!c||!(0,b.isTypeClass)(c)){n.push(
35
+ new A(r.file));continue}s[c.name]=t}return s};var ar=(e,t,r,o)=>{if(!(0,E.isTypeReference)(e))return lr(e,t,r,o);let n=(0,f.getReferenceType)(
36
+ e,r);return n?lr(n,t,r,o):null},lr=(e,t,r,o)=>(0,E.isTypeObject)(e)?mr(t,(0,f.getObjectMembers)(
37
+ e),r,o):(0,f.isModelDeclaration)(e)?$e(e)?mr(t,(0,f.getModelMembers)(e),r,o):(o.
38
+ push(new B(e.name,t.file)),null):(o.push(new F(t.file)),null),mr=(e,t,r,o)=>{let n={};
39
+ for(let p of t)if(!(!(0,E.isModelProperty)(p)||p.inherited))switch(p.name){default:
40
+ o.push(new f.InvalidServicePropertyError(e.name,p.name,e.file));break;case"httpE\
41
+ rrors":n.httpErrors=ue(p.value,e,r,o);break;case"memory":case"logRetention":case"\
42
+ timeout":n[p.name]=(0,f.getPropertyNumber)(p);break;case"listener":n.listener=(0,f.getServiceListener)(
43
+ p.value,o);break}return n};var x=require("@ez4/reflection"),l=require("@ez4/common/library");var fe=require("@ez4/common/library"),N=class extends fe.IncompleteTypeError{constructor(t,r){
44
+ super("Incomplete gateway route",t,r)}},A=class extends fe.TypeError{constructor(t){
45
+ super("Invalid route error type.",t)}};var ur=require("@ez4/common/library"),U=class extends ur.IncompleteTypeError{constructor(t,r){
46
+ super("Incomplete route authorizer",t,r)}};var d=require("@ez4/common/library"),j=require("@ez4/reflection"),Mr=require("@ez4/utils");var ye=require("@ez4/common/library"),V=class extends ye.InvalidTypeError{constructor(r,o){
47
+ super("Invalid route response",void 0,r,o);this.baseType=r}},Q=class extends ye.IncorrectTypeError{constructor(r,o,n){
48
+ super("Incorrect route response",r,o,n);this.responseType=r;this.baseType=o}};var v=require("@ez4/schema/library"),Me=require("@ez4/common/library"),y=require("@ez4/reflection");var de=require("@ez4/common/library"),J=class extends de.InvalidTypeError{constructor(t){
49
+ super("Invalid body",void 0,"Http.JsonBody",t)}},G=class extends de.IncorrectTypeError{constructor(r,o){
50
+ super("Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}};var Te=require("@ez4/schema/library"),u=(e,t)=>{let r=(0,Te.getObjectSchema)(e,t);
51
+ return r&&(0,Te.isObjectSchema)(r)?r:null};var Oe=(e,t,r,o)=>He(e,r,n=>ge(n,t,r,o)),ze=(e,t,r,o)=>He(e,r,n=>we(n)??ge(n,t,r,
52
+ o)),He=(e,t,r)=>{if((0,y.isTypeUndefined)(e))return null;if(!(0,y.isTypeReference)(
53
+ e))return r(e);let o=(0,Me.getReferenceType)(e,t);return o?r(o):null},we=e=>(0,y.isTypeScalar)(
54
+ e)?(0,v.getScalarSchema)(e):null,ge=(e,t,r,o)=>(0,y.isTypeUnion)(e)?Kr(e.elements,
55
+ r,n=>we(n)??ge(n,t,r,o)):(0,y.isTypeArray)(e)?Wr(e.element,r,n=>we(n)??ge(n,t,r,
56
+ o)):(0,y.isTypeObject)(e)||(0,y.isTypeIntersection)(e)?u(e,r):(0,Me.isModelDeclaration)(
57
+ e)?or(e)?u(e,r):(o.push(new G(e.name,e.file)),null):(o.push(new J(t.file)),null),
58
+ Kr=(e,t,r)=>{let o=[];for(let n of e){let p=He(n,t,r);p&&o.push(p)}return o.length?
59
+ (0,v.createUnionSchema)({elements:o}):null},Wr=(e,t,r)=>{let o=He(e,t,r);return o?
60
+ (0,v.createArraySchema)({element:o}):null};var H=require("@ez4/reflection"),be=require("@ez4/common/library"),yr=require("@ez4/schema/library");var he=require("@ez4/common/library"),Y=class extends he.InvalidTypeError{constructor(t){
61
+ super("Invalid identity",void 0,"Http.Identity",t)}},K=class extends he.IncorrectTypeError{constructor(r,o){
62
+ super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}};var R=(e,t,r,o)=>{if((0,H.isTypeUndefined)(e))return null;if(!(0,H.isTypeReference)(
63
+ e))return fr(e,t,r,o);let n=(0,be.getReferenceType)(e,r);return n?fr(n,t,r,o):null},
64
+ fr=(e,t,r,o)=>{if((0,H.isTypeUnion)(e))return Xr(e.elements,t,r,o);if((0,H.isTypeObject)(
65
+ e)||(0,H.isTypeIntersection)(e))return u(e,r);if(!(0,be.isModelDeclaration)(e))return o.
66
+ push(new Y(t.file)),null;if(!er(e))return o.push(new K(e.name,t.file)),null;let n=u(
67
+ e,r);return n&&(n.definitions={...n.definitions,extensible:!0}),n},Xr=(e,t,r,o)=>{
68
+ let n=[];for(let p of e){let s=R(p,t,r,o);s&&n.push(s)}return n.length>1?(0,yr.createUnionSchema)(
69
+ {elements:n}):n[0]};var P=require("@ez4/reflection"),xe=require("@ez4/common/library");var Se=require("@ez4/common/library"),W=class extends Se.InvalidTypeError{constructor(t){
70
+ super("Invalid headers",void 0,"Http.Headers",t)}},X=class extends Se.IncorrectTypeError{constructor(r,o){
71
+ super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}};var Z=(e,t,r,o)=>{if(!(0,P.isTypeReference)(e))return dr(e,t,r,o);let n=(0,xe.getReferenceType)(
72
+ e,r);return n?dr(n,t,r,o):null},dr=(e,t,r,o)=>(0,P.isTypeObject)(e)||(0,P.isTypeIntersection)(
73
+ e)?u(e,r):(0,xe.isModelDeclaration)(e)?Le(e)?u(e,r):(o.push(new X(e.name,t.file)),
74
+ null):(o.push(new W(t.file)),null);var Ce=(e,t,r,o)=>{let n=Hr(e,t,r,o,"Http.AuthResponse");return n&&Zr(n)?n:null},
75
+ ke=(e,t,r,o)=>{let n=Hr(e,t,r,o,"Http.Response");return n&&_r(n)?n:null},Hr=(e,t,r,o,n)=>{
76
+ if(!(0,j.isTypeReference)(e))return Tr(e,t,r,o,n);let p=(0,d.getReferenceType)(e,
77
+ r);return p?Tr(p,t,r,o,n):null},Zr=e=>!!e.identity,_r=e=>(0,Mr.isAnyNumber)(e.status),
78
+ Tr=(e,t,r,o,n)=>(0,j.isTypeObject)(e)?gr(e,t,(0,d.getObjectMembers)(e),r,o):(0,d.isModelDeclaration)(
79
+ e)?(0,d.hasHeritageType)(e,n)?gr(e,t,(0,d.getModelMembers)(e),r,o):(o.push(new Q(
80
+ e.name,n,e.file)),null):(o.push(new V(n,t.file)),null),gr=(e,t,r,o,n)=>{let p={};
81
+ for(let s of r)if(!(!(0,j.isModelProperty)(s)||s.inherited))switch(s.name){default:
82
+ n.push(new d.InvalidServicePropertyError(t.name,s.name,e.file));break;case"statu\
83
+ s":p.status=(0,d.getPropertyNumber)(s);break;case"headers":{p.headers=Z(s.value,
84
+ e,o,n),p.headers&&s.description&&(p.headers.description=s.description);break}case"\
85
+ identity":{p.identity=R(s.value,e,o,n),p.identity&&s.description&&(p.identity.description=
86
+ s.description);break}case"body":{p.body=ze(s.value,e,o,n),p.body&&s.description&&
87
+ (p.body.description=s.description);break}}return p};var S=require("@ez4/reflection"),g=require("@ez4/common/library");var Ie=require("@ez4/common/library"),_=class extends Ie.InvalidTypeError{constructor(r,o){
88
+ super("Invalid route request",void 0,r,o);this.baseType=r}},$=class extends Ie.IncorrectTypeError{constructor(r,o,n){
89
+ super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}};var w=require("@ez4/reflection"),Ee=require("@ez4/common/library");var Ae=require("@ez4/common/library"),L=class extends Ae.InvalidTypeError{constructor(t){
90
+ super("Invalid request parameters",void 0,"Http.PathParameters",t)}},ee=class extends Ae.IncorrectTypeError{constructor(r,o){
91
+ super("Incorrect request parameters",r,"Http.PathParameters",o);this.parametersType=
92
+ r}};var qe=(e,t,r,o)=>{if(!(0,w.isTypeReference)(e))return hr(e,t,r,o);let n=(0,Ee.getReferenceType)(
93
+ e,r);return n?hr(n,t,r,o):null},hr=(e,t,r,o)=>(0,w.isTypeObject)(e)||(0,w.isTypeIntersection)(
94
+ e)?u(e,r):(0,Ee.isModelDeclaration)(e)?tr(e)?u(e,r):(o.push(new ee(e.name,e.file)),
95
+ null):(o.push(new L(t.file)),null);var O=require("@ez4/reflection"),Re=require("@ez4/common/library");var ve=require("@ez4/common/library"),re=class extends ve.InvalidTypeError{constructor(t){
96
+ super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},te=class extends ve.IncorrectTypeError{constructor(r,o){
97
+ super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
98
+ r}};var De=(e,t,r,o)=>{if(!(0,O.isTypeReference)(e))return br(e,t,r,o);let n=(0,Re.getReferenceType)(
99
+ e,r);return n?br(n,t,r,o):null},br=(e,t,r,o)=>(0,O.isTypeObject)(e)||(0,O.isTypeIntersection)(
100
+ e)?u(e,r):(0,Re.isModelDeclaration)(e)?rr(e)?u(e,r):(o.push(new te(e.name,t.file)),
101
+ null):(o.push(new re(t.file)),null);var Fe=(e,t,r,o)=>Ne(e,t,r,o,"Http.AuthRequest"),Be=(e,t,r,o)=>Ne(e,t,r,o,"Http.\
102
+ Request"),Ne=(e,t,r,o,n)=>{if((0,S.isTypeIntersection)(e)&&e.elements.length>0)return Ne(
103
+ e.elements[0],t,r,o,n);if(!(0,S.isTypeReference)(e))return Sr(e,t,r,o,n);let p=(0,g.getReferenceType)(
104
+ e,r);return p?Sr(p,t,r,o,n):null},Sr=(e,t,r,o,n)=>(0,S.isTypeObject)(e)?xr(e,t,(0,g.getObjectMembers)(
105
+ e),r,o):(0,g.isModelDeclaration)(e)?(0,g.hasHeritageType)(e,n)?xr(e,t,(0,g.getModelMembers)(
106
+ e),r,o):(o.push(new $(e.name,n,e.file)),null):(o.push(new _(n,t.file)),null),xr=(e,t,r,o,n)=>{
107
+ let p={};for(let s of r)if(!(!(0,S.isModelProperty)(s)||s.inherited))switch(s.name){default:
108
+ n.push(new g.InvalidServicePropertyError(t.name,s.name,e.file));break;case"heade\
109
+ rs":{p.headers=Z(s.value,e,o,n),p.headers&&s.description&&(p.headers.description=
110
+ s.description);break}case"identity":{p.identity=R(s.value,e,o,n),p.identity&&s.description&&
111
+ (p.identity.description=s.description);break}case"query":{p.query=De(s.value,e,o,
112
+ n),p.query&&s.description&&(p.query.description=s.description);break}case"parame\
113
+ ters":{p.parameters=qe(s.value,e,o,n),p.parameters&&s.description&&(p.parameters.
114
+ description=s.description);break}case"body":{p.body=Oe(s.value,e,o,n),p.body&&s.
115
+ description&&(p.body.description=s.description);break}}return p};var Ue=(e,t,r,o)=>{if(!sr(e))return null;let n={},p=new Set(["name","file"]);if(e.
116
+ description&&(n.description=e.description),(n.name=e.name)&&p.delete("name"),(n.
117
+ file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;n.request=
118
+ Fe(s,t,r,o)}return e.return&&(n.response=Ce(e.return,t,r,o)),$r(n)?n:(o.push(new U(
119
+ [...p],e.file)),null)},$r=e=>!!e.name&&!!e.file;var Ir=require("@ez4/common/library"),oe=class extends Ir.IncompleteTypeError{constructor(t,r){
120
+ super("Incomplete route handler",t,r)}};var Ve=(e,t,r,o)=>{if(!ir(e))return null;let n={},p=new Set(["name","file","resp\
121
+ onse"]);if(e.description&&(n.description=e.description),(n.name=e.name)&&p.delete(
122
+ "name"),(n.file=e.file)&&p.delete("file"),e.parameters){let[{value:s}]=e.parameters;
123
+ n.request=Be(s,t,r,o)}if(e.return){let s=ke(e.return,t,r,o);s&&(n.response=s,p.delete(
124
+ "response"))}return Lr(n)?n:(o.push(new oe([...p],e.file)),null)},Lr=e=>!!e.name&&
125
+ !!e.file&&!!e.response;var Qe=(e,t,r,o)=>{let n=(0,l.getPropertyTuple)(t)??[];return vr(n,e,r,o)},vr=(e,t,r,o)=>{
126
+ let n=[];for(let p of e){let s=et(p,t,r,o);Array.isArray(s)?n.push(...s):s&&n.push(
127
+ s)}return n},et=(e,t,r,o)=>{if(!(0,x.isTypeReference)(e))return Ar(e,t,r,o);let n=(0,l.getReferenceType)(
128
+ e,r);return n?Ar(n,t,r,o):null},rt=e=>!!e.path&&!!e.handler,Ar=(e,t,r,o)=>_e(e)?
129
+ Er(e,t,(0,l.getModelMembers)(e),r,o):(0,x.isTypeObject)(e)?Er(e,t,(0,l.getObjectMembers)(
130
+ e),r,o):(0,x.isTypeTuple)(e)&&e.spread?vr(e.elements,t,r,o):null,Er=(e,t,r,o,n)=>{
131
+ let p={},s=new Set(["path","handler"]);for(let i of r)if(!(!(0,x.isModelProperty)(
132
+ i)||i.inherited))switch(i.name){default:n.push(new l.InvalidServicePropertyError(
133
+ t.name,i.name,e.file));break;case"path":{let c=(0,l.getPropertyString)(i);c&&Xe(
134
+ c)&&(s.delete(i.name),p.path=c);break}case"handler":(p.handler=Ve(i.value,t,o,n))&&
135
+ s.delete(i.name);break;case"authorizer":p.authorizer=Ue(i.value,t,o,n);break;case"\
136
+ httpErrors":p.httpErrors=ue(i.value,t,o,n);break;case"memory":case"logRetention":case"\
137
+ timeout":p[i.name]=(0,l.getPropertyNumber)(i);break;case"cors":p.cors=(0,l.getPropertyBoolean)(
138
+ i);break;case"listener":p.listener=(0,l.getServiceListener)(i.value,n);break;case"\
139
+ variables":p.variables=(0,l.getLinkedVariableList)(i,n);break}return rt(p)?p:(n.
140
+ push(new N([...s],e.file)),null)};var m=require("@ez4/common/library"),C=require("@ez4/reflection");var z=require("@ez4/common/library"),ne=class extends z.IncompleteTypeError{constructor(t,r){
141
+ super("Incomplete HTTP CORS",t,r)}},pe=class extends z.InvalidTypeError{constructor(t){
142
+ super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},se=class extends z.IncorrectTypeError{constructor(r,o){
143
+ super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}};var Je=(e,t,r,o)=>{if(!(0,C.isTypeReference)(e))return Rr(e,t,o);let n=(0,m.getReferenceType)(
144
+ e,r);return n?Rr(n,t,o):null},tt=e=>!!e.allowOrigins?.length,Rr=(e,t,r)=>(0,C.isTypeObject)(
145
+ e)?Pr(e,t,(0,m.getObjectMembers)(e),r):(0,m.isModelDeclaration)(e)?nr(e)?Pr(e,t,
146
+ (0,m.getModelMembers)(e),r):(r.push(new se(e.name,e.file)),null):(r.push(new pe(
147
+ t.file)),null),Pr=(e,t,r,o)=>{let n={},p=new Set(["allowOrigins"]);for(let s of r)
148
+ if(!(!(0,C.isModelProperty)(s)||s.inherited))switch(s.name){default:o.push(new m.InvalidServicePropertyError(
138
149
  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,
150
+ ders":case"exposeHeaders":n[s.name]=(0,m.getPropertyStringList)(s);break;case"al\
151
+ lowCredentials":n.allowCredentials=(0,m.getPropertyBoolean)(s);break;case"maxAge":
152
+ n.maxAge=(0,m.getPropertyNumber)(s);break}return tt(n)?n:(o.push(new ne([...p],e.
153
+ file)),null)};var M=require("@ez4/common/library"),q=require("@ez4/reflection"),Ge=require("@ez4/utils");var k=require("@ez4/common/library"),ie=class extends k.IncompleteTypeError{constructor(t,r){
154
+ super("Incomplete gateway cache",t,r)}},ce=class extends k.InvalidTypeError{constructor(t){
155
+ super("Invalid gateway cache type",void 0,"Http.Cache",t)}},le=class extends k.IncorrectTypeError{constructor(r,o){
156
+ super("Incorrect gateway cache type",r,"Http.Cache",o);this.cacheType=r}};var Ye=(e,t,r,o)=>{if(!(0,q.isTypeReference)(e))return jr(e,t,o);let n=(0,M.getReferenceType)(
157
+ e,r);return n?jr(n,t,o):null},ot=e=>(0,Ge.isAnyNumber)(e.authorizerTTL),jr=(e,t,r)=>(0,q.isTypeObject)(
158
+ e)?wr(e,t,(0,M.getObjectMembers)(e),r):(0,M.isModelDeclaration)(e)?pr(e)?wr(e,t,
159
+ (0,M.getModelMembers)(e),r):(r.push(new le(e.name,e.file)),null):(r.push(new ce(
160
+ t.file)),null),wr=(e,t,r,o)=>{let n={},p=new Set(["authorizerTTL"]);for(let s of r)
161
+ if(!(!(0,q.isModelProperty)(s)||s.inherited))switch(s.name){default:o.push(new M.InvalidServicePropertyError(
162
+ t.name,s.name,e.file));break;case"authorizerTTL":{let i=(0,M.getPropertyNumber)(
163
+ s);(0,Ge.isAnyNumber)(i)&&(n[s.name]=i,p.delete(s.name));break}}return ot(n)?n:(o.
164
+ push(new ie([...p],e.file)),null)};var Ke=e=>{let t={},r=[];for(let o in e){let n=e[o];if(!Ze(n)||(0,T.isExternalDeclaration)(
165
+ n))continue;let p={type:me,extras:{}},s=new Set(["routes"]),i=n.file;p.name=n.name,
166
+ n.description&&(p.description=n.description);for(let c of(0,T.getModelMembers)(n))
167
+ if(!(!(0,Or.isModelProperty)(c)||c.inherited))switch(c.name){default:r.push(new T.InvalidServicePropertyError(
168
+ p.name,c.name,i));break;case"routes":(p.routes=Qe(n,c,e,r))&&s.delete(c.name);break;case"\
169
+ name":p.displayName=(0,T.getPropertyString)(c);break;case"defaults":p.defaults=ar(
170
+ c.value,n,e,r);break;case"cache":p.cache=Ye(c.value,n,e,r);break;case"cors":p.cors=
171
+ Je(c.value,n,e,r);break;case"variables":p.variables=(0,T.getLinkedVariableList)(
172
+ c,r);break;case"services":p.services=(0,T.getLinkedServiceList)(c,e,r);break}if(!nt(
173
+ p)){r.push(new D([...s],i));continue}if(t[n.name]){r.push(new T.DuplicateServiceError(
174
+ n.name,i));continue}t[n.name]=p}return{services:t,errors:r}},nt=e=>!!e.name&&!!e.
175
+ routes&&!!e.extras;var zr=!1,pt=()=>{zr||((0,Cr.registerTriggers)(),(0,kr.registerTriggers)(),(0,qr.createTrigger)(
176
+ "@ez4/gateway",{"metadata:getServices":Ke}),zr=!1)};var Pe=require("@ez4/common/library"),F=class extends Pe.InvalidTypeError{constructor(t){
177
+ super("Invalid defaults",void 0,"Http.Defaults",t)}},B=class extends Pe.IncorrectTypeError{constructor(r,o){
178
+ super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}};0&&(module.exports={IncompleteAuthorizerError,IncompleteCacheError,IncompleteCorsError,
168
179
  IncompleteHandlerError,IncompleteRouteError,IncompleteServiceError,IncorrectBodyTypeError,
169
180
  IncorrectCacheTypeError,IncorrectCorsTypeError,IncorrectDefaultsTypeError,IncorrectHeadersTypeError,
170
181
  IncorrectIdentityTypeError,IncorrectParameterTypeError,IncorrectQueryTypeError,IncorrectRequestTypeError,
171
182
  IncorrectResponseTypeError,InvalidBodyTypeError,InvalidCacheTypeError,InvalidCorsTypeError,
172
183
  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});
184
+ InvalidQueryTypeError,InvalidRequestTypeError,InvalidResponseTypeError,InvalidRouteErrorTypeError,
185
+ ServiceType,getHttpAuthRequest,getHttpAuthResponse,getHttpAuthorizer,getHttpCache,
186
+ getHttpCors,getHttpHandler,getHttpHandlerRequest,getHttpHandlerResponse,getHttpHeaders,
187
+ getHttpIdentity,getHttpParameters,getHttpQuery,getHttpRequestBody,getHttpResponseBody,
188
+ getHttpRoutes,getHttpServices,isHttpService,registerTriggers});
178
189
  //# sourceMappingURL=library.cjs.map