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