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