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