@ez4/gateway 0.17.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.
- package/dist/errors/cache.d.ts +11 -0
- package/dist/library.cjs +175 -158
- package/dist/library.d.ts +2 -0
- package/dist/library.mjs +174 -156
- package/dist/main.cjs +3 -3
- package/dist/metadata/body.d.ts +1 -1
- package/dist/metadata/cache.d.ts +3 -0
- package/dist/metadata/route.d.ts +2 -2
- package/dist/metadata/utils.d.ts +2 -1
- package/dist/services/common.d.ts +9 -0
- package/dist/services/contract.d.ts +16 -7
- package/dist/types/common.d.ts +5 -0
- package/dist/types/service.d.ts +2 -1
- package/package.json +6 -6
|
@@ -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,161 +1,178 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof t=="object"||typeof t=="function")for(let o of
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
e,"Http.
|
|
24
|
-
|
|
25
|
-
e)
|
|
26
|
-
e,
|
|
27
|
-
e
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
super("
|
|
35
|
-
super("
|
|
36
|
-
super("Invalid
|
|
37
|
-
super("Incorrect
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
e)?
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
e,t
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
e))return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
o
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
r)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
e
|
|
68
|
-
|
|
69
|
-
o.push(new
|
|
70
|
-
s
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(s.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
super("Invalid request
|
|
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
|
|
80
|
-
e,r);return o?
|
|
81
|
-
e)?
|
|
82
|
-
|
|
83
|
-
r:null};var
|
|
84
|
-
super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},
|
|
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
|
|
87
|
-
e,r);return o?
|
|
88
|
-
e)?
|
|
89
|
-
|
|
90
|
-
r:null};var
|
|
91
|
-
Request"),
|
|
92
|
-
e,r);return
|
|
93
|
-
e),r,n):(0,y.isModelDeclaration)(e)?(0,y.hasHeritageType)(e,o)?
|
|
94
|
-
e),r,n):(n.push(new
|
|
95
|
-
let
|
|
96
|
-
o.push(new y.InvalidServicePropertyError(t.name,
|
|
97
|
-
rs":{
|
|
98
|
-
|
|
99
|
-
(
|
|
100
|
-
o),
|
|
101
|
-
ters":{
|
|
102
|
-
description=
|
|
103
|
-
description&&(
|
|
104
|
-
description&&(o.description=e.description),(o.name=e.name)&&
|
|
105
|
-
file=e.file)&&
|
|
106
|
-
|
|
107
|
-
[...
|
|
108
|
-
super("Incomplete route handler",t,r)}};var
|
|
109
|
-
onse"]);if(e.description&&(o.description=e.description),(o.name=e.name)&&
|
|
110
|
-
"name"),(o.file=e.file)&&
|
|
111
|
-
o.request=
|
|
112
|
-
"response"))}return
|
|
113
|
-
!!e.file&&!!e.response;var
|
|
114
|
-
e
|
|
115
|
-
|
|
116
|
-
e),r,n):null,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
i);break;case"
|
|
122
|
-
|
|
123
|
-
i.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
(0,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
o.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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});
|
|
161
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,158 +1,176 @@
|
|
|
1
|
-
import{registerTriggers as
|
|
2
|
-
import{createTrigger as
|
|
3
|
-
getLinkedVariableList as
|
|
4
|
-
|
|
5
|
-
super("Incomplete service",t,r)}};import{InvalidServicePropertyError as
|
|
6
|
-
getObjectMembers as
|
|
7
|
-
import{isModelProperty as
|
|
8
|
-
import{isTypeCallback as
|
|
9
|
-
["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),
|
|
10
|
-
2);return
|
|
11
|
-
|
|
12
|
-
nBody")
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
super("Incomplete route
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
import{
|
|
42
|
-
import{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
push(new h(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
import{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
null
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
import{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
n)
|
|
81
|
-
|
|
82
|
-
import{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
n)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
"
|
|
108
|
-
o.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
if(!(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
t,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
p
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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};
|
|
158
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
|
|
2
|
-
typeof e=="object"||typeof e=="function")for(let n of H(e))!
|
|
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={};
|
|
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=
|
package/dist/metadata/body.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import type { AllType, SourceMap, TypeModel, TypeObject } from '@ez4/reflection'
|
|
|
2
2
|
import type { ObjectSchema, UnionSchema } from '@ez4/schema/library';
|
|
3
3
|
type TypeParent = TypeObject | TypeModel;
|
|
4
4
|
export declare const getHttpRequestBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | UnionSchema | null;
|
|
5
|
-
export declare const getHttpResponseBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) =>
|
|
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 {};
|
package/dist/metadata/route.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModelProperty, SourceMap, TypeModel } from '@ez4/reflection';
|
|
2
2
|
import type { HttpRoute } from '../types/common.js';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const getHttpRoutes: (parent: TypeModel, member: ModelProperty, reflection: SourceMap, errorList: Error[]) => HttpRoute[];
|
package/dist/metadata/utils.d.ts
CHANGED
|
@@ -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:
|
|
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
|
|
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
|
|
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
|
-
*
|
|
104
|
+
* Cache configuration.
|
|
96
105
|
*/
|
|
97
|
-
|
|
106
|
+
cache?: Cache;
|
|
98
107
|
/**
|
|
99
|
-
*
|
|
108
|
+
* Variables associated to all routes.
|
|
100
109
|
*/
|
|
101
|
-
|
|
110
|
+
variables?: LinkedVariables;
|
|
102
111
|
/**
|
|
103
112
|
* Service client.
|
|
104
113
|
*/
|
package/dist/types/common.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/dist/types/service.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
46
|
-
"@ez4/project": "^0.
|
|
47
|
-
"@ez4/reflection": "^0.
|
|
48
|
-
"@ez4/schema": "^0.
|
|
49
|
-
"@ez4/utils": "^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
|
}
|