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