@ez4/gateway 0.31.1 → 0.31.2
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/client/operations.d.ts +2 -0
- package/dist/library.cjs +71 -70
- package/dist/library.mjs +70 -69
- package/dist/metadata/body.d.ts +1 -1
- package/dist/services/client.d.ts +1 -1
- package/dist/utils/body.d.ts +0 -4
- package/dist/utils/client.d.ts +8 -3
- package/dist/utils/parameters.d.ts +0 -1
- package/dist/utils/query.d.ts +3 -2
- package/dist/utils.cjs +49 -44
- package/dist/utils.mjs +49 -45
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@ import type { ArraySchema, NamingStyle, ObjectSchema, ScalarSchema, UnionSchema
|
|
|
2
2
|
import type { HttpImport, HttpService } from '@ez4/gateway/library';
|
|
3
3
|
export type ClientOperation = {
|
|
4
4
|
namingStyle?: NamingStyle;
|
|
5
|
+
bodySchema?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
|
|
5
6
|
responseSchema?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
|
|
7
|
+
querySchema?: ObjectSchema;
|
|
6
8
|
method: string;
|
|
7
9
|
path: string;
|
|
8
10
|
};
|
package/dist/library.cjs
CHANGED
|
@@ -6,33 +6,33 @@ IncompleteProviderError:()=>he,IncompleteRouteError:()=>re,IncompleteServiceErro
|
|
|
6
6
|
IncorrectAccessTypeError:()=>Ee,IncorrectBodyTypeError:()=>ue,IncorrectCacheTypeError:()=>Ie,
|
|
7
7
|
IncorrectCorsTypeError:()=>we,IncorrectDefaultsTypeError:()=>ee,IncorrectHeadersTypeError:()=>ce,
|
|
8
8
|
IncorrectIdentityTypeError:()=>se,IncorrectParameterTypeError:()=>Te,IncorrectPreferencesTypeError:()=>$,
|
|
9
|
-
IncorrectQueryTypeError:()=>Me,IncorrectRequestTypeError:()=>
|
|
9
|
+
IncorrectQueryTypeError:()=>Me,IncorrectRequestTypeError:()=>fe,IncorrectResponseTypeError:()=>ne,
|
|
10
10
|
InvalidAccessTypeError:()=>Ae,InvalidBodyTypeError:()=>ae,InvalidCacheTypeError:()=>ve,
|
|
11
11
|
InvalidCorsTypeError:()=>Re,InvalidDefaultsTypeError:()=>L,InvalidHeadersTypeError:()=>ie,
|
|
12
12
|
InvalidIdentityTypeError:()=>pe,InvalidParameterTypeError:()=>ye,InvalidPreferencesTypeError:()=>_,
|
|
13
|
-
InvalidProviderTypeError:()=>be,InvalidQueryTypeError:()=>ge,InvalidRequestTypeError:()=>
|
|
14
|
-
InvalidResponseTypeError:()=>oe,InvalidRouteErrorTypeError:()=>
|
|
15
|
-
ServiceType:()=>
|
|
16
|
-
getHttpAuthorizer:()=>
|
|
13
|
+
InvalidProviderTypeError:()=>be,InvalidQueryTypeError:()=>ge,InvalidRequestTypeError:()=>de,
|
|
14
|
+
InvalidResponseTypeError:()=>oe,InvalidRouteErrorTypeError:()=>q,ServiceCollisionError:()=>Z,
|
|
15
|
+
ServiceType:()=>j,getClientOperations:()=>$t,getHttpAuthRequest:()=>ur,getHttpAuthResponse:()=>ir,
|
|
16
|
+
getHttpAuthorizer:()=>fr,getHttpBody:()=>le,getHttpCache:()=>br,getHttpCors:()=>Sr,
|
|
17
17
|
getHttpHandler:()=>yr,getHttpHandlerRequest:()=>lr,getHttpHandlerResponse:()=>cr,
|
|
18
18
|
getHttpHeaders:()=>me,getHttpIdentity:()=>N,getHttpLocalRoutes:()=>gr,getHttpParameters:()=>mr,
|
|
19
19
|
getHttpQuery:()=>ar,getHttpRemoteRoutes:()=>Mr,getHttpServices:()=>vr,isHttpImport:()=>Rt,
|
|
20
|
-
isHttpService:()=>wt,registerTriggers:()=>_t});module.exports=Pt(Lt);var ht=require("@ez4/common/library"),St=require("@ez4/schema/library"),Ir=require("@ez4/project/library");var O="@ez4/import:http",Rt=p(e=>e.type===O,"isHttpImport");var
|
|
21
|
-
super("Incomplete service",t,r)}},Z=class extends
|
|
22
|
-
this,"ServiceCollisionError")}constructor(t,r){super("Service error",t,r)}};var T=require("@ez4/common/library"),
|
|
23
|
-
t]=e.split(" ",2);return Ot.has(t)},"isHttpPath"),
|
|
20
|
+
isHttpService:()=>wt,registerTriggers:()=>_t});module.exports=Pt(Lt);var ht=require("@ez4/common/library"),St=require("@ez4/schema/library"),Ir=require("@ez4/project/library");var O="@ez4/import:http",Rt=p(e=>e.type===O,"isHttpImport");var j="@ez4/http",wt=p(e=>e.type===j,"isHttpService");var g=require("@ez4/common/library"),Tt=require("@ez4/reflection");var je=require("@ez4/common/library");var w=class extends je.IncompleteTypeError{static{p(this,"IncompleteServiceError")}constructor(t,r){
|
|
21
|
+
super("Incomplete service",t,r)}},Z=class extends je.TypeCollisionError{static{p(
|
|
22
|
+
this,"ServiceCollisionError")}constructor(t,r){super("Service error",t,r)}};var T=require("@ez4/common/library"),D=require("@ez4/reflection");var H=require("@ez4/common/library"),C=require("@ez4/reflection");var u=require("@ez4/common/library"),k=require("@ez4/reflection");var Ot=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),Ar=p(e=>{let[
|
|
23
|
+
t]=e.split(" ",2);return Ot.has(t)},"isHttpPath"),ke=p(e=>(0,u.isClassDeclaration)(
|
|
24
24
|
e)&&(0,u.hasHeritageType)(e,"Http.Service"),"isHttpService"),ze=p(e=>(0,u.isClassDeclaration)(
|
|
25
25
|
e)&&(0,u.hasHeritageType)(e,"Http.Import"),"isHttpImport");var Er=p(e=>(0,u.isModelDeclaration)(e)&&(0,u.hasHeritageType)(e,"Http.Route"),"\
|
|
26
26
|
isHttpRoute");var Pr=p(e=>(0,u.hasHeritageType)(e,"Http.Defaults"),"isHttpDefaults"),Rr=p(e=>(0,u.hasHeritageType)(
|
|
27
27
|
e,"Http.Preferences"),"isHttpPreferences"),wr=p(e=>(0,u.hasHeritageType)(e,"Http\
|
|
28
28
|
.Headers"),"isHttpHeaders"),Or=p(e=>(0,u.hasHeritageType)(e,"Http.Identity"),"is\
|
|
29
|
-
HttpIdentity"),
|
|
30
|
-
|
|
29
|
+
HttpIdentity"),jr=p(e=>(0,u.hasHeritageType)(e,"Http.QueryStrings"),"isHttpQuery"),
|
|
30
|
+
kr=p(e=>(0,u.hasHeritageType)(e,"Http.PathParameters"),"isHttpParameters"),zr=p(
|
|
31
31
|
e=>(0,u.hasHeritageType)(e,"Http.JsonBody"),"isJsonBody"),Cr=p(e=>(0,u.hasHeritageType)(
|
|
32
|
-
e,"Http.Cache"),"isHttpCache"),
|
|
33
|
-
sHttpAccess"),
|
|
34
|
-
e)||(0,
|
|
35
|
-
(0,
|
|
32
|
+
e,"Http.Cache"),"isHttpCache"),qr=p(e=>(0,u.hasHeritageType)(e,"Http.Access"),"i\
|
|
33
|
+
sHttpAccess"),Dr=p(e=>(0,u.hasHeritageType)(e,"Http.Cors"),"isHttpCors"),Nr=p(e=>(0,k.isTypeCallback)(
|
|
34
|
+
e)||(0,k.isTypeFunction)(e),"isHttpAuthorizer"),Fr=p(e=>(0,k.isTypeCallback)(e)||
|
|
35
|
+
(0,k.isTypeFunction)(e),"isHttpHandler");var z=require("@ez4/schema");var Ce=p((e,t,r,o)=>{if(!(0,C.isTypeReference)(e))return Ur(e,t,o);let n=(0,H.getReferenceType)(
|
|
36
36
|
e,r);if(n)return Ur(n,t,o)},"getHttpPreferences"),Ur=p((e,t,r)=>{if((0,C.isTypeObject)(
|
|
37
37
|
e))return Br(t,(0,H.getObjectMembers)(e),r);if(!(0,H.isModelDeclaration)(e)){r.push(
|
|
38
38
|
new _(t.file));return}if(!Rr(e)){r.push(new $(e.name,t.file));return}return Br(t,
|
|
@@ -40,26 +40,26 @@ new _(t.file));return}if(!Rr(e)){r.push(new $(e.name,t.file));return}return Br(t
|
|
|
40
40
|
if((0,C.isModelProperty)(n))switch(n.name){default:r.push(new H.InvalidServicePropertyError(
|
|
41
41
|
e.name,n.name,e.file));break;case"namingStyle":o.namingStyle=(0,H.getPropertyStringIn)(
|
|
42
42
|
n,[z.NamingStyle.Preserve,z.NamingStyle.CamelCase,z.NamingStyle.PascalCase,z.NamingStyle.
|
|
43
|
-
SnakeCase,z.NamingStyle.KebabCase]);break}return o},"getTypeFromMembers");var A=require("@ez4/common/library"),
|
|
43
|
+
SnakeCase,z.NamingStyle.KebabCase]);break}return o},"getTypeFromMembers");var A=require("@ez4/common/library"),qe=require("@ez4/utils"),E=require("@ez4/reflection");var De=p((e,t,r,o)=>{if(!(0,E.isTypeReference)(e))return Vr(e,t,r,o);let n=(0,A.getReferenceType)(
|
|
44
44
|
e,r);if(n)return Vr(n,t,r,o)},"getHttpErrors"),Vr=p((e,t,r,o)=>{if((0,E.isTypeObject)(
|
|
45
|
-
e))return
|
|
45
|
+
e))return jt(e,t,(0,A.getObjectMembers)(e),r,o)},"getTypeErrors"),jt=p((e,t,r,o,n)=>{
|
|
46
46
|
let s={};for(let i of r){if(!(0,E.isModelProperty)(i)||i.inherited)continue;let m=parseInt(
|
|
47
|
-
i.name,10);(0,
|
|
48
|
-
i.name,e.file));let c=
|
|
49
|
-
s))return s},"getTypeFromMembers"),
|
|
50
|
-
e)??[],i={};for(let m of s){if(!(0,E.isTypeReference)(m)){n.push(new
|
|
47
|
+
i.name,10);(0,qe.isAnyNumber)(m)||n.push(new A.InvalidServicePropertyError(t.name,
|
|
48
|
+
i.name,e.file));let c=kt(i,m,t,o,n);c&&Object.assign(s,c)}if(!(0,qe.isEmptyObject)(
|
|
49
|
+
s))return s},"getTypeFromMembers"),kt=p((e,t,r,o,n)=>{let s=(0,A.getPropertyTuple)(
|
|
50
|
+
e)??[],i={};for(let m of s){if(!(0,E.isTypeReference)(m)){n.push(new q(r.file));
|
|
51
51
|
continue}let c=(0,A.getReferenceType)(m,o);if(!c||!(0,E.isTypeClass)(c)){n.push(
|
|
52
|
-
new
|
|
53
|
-
e,r);if(n)return Qr(n,t,r,o)},"getHttpDefaults"),Qr=p((e,t,r,o)=>{if((0,
|
|
52
|
+
new q(r.file));continue}i[c.name]=t}return i},"getErrorClasses");var Ne=p((e,t,r,o)=>{if(!(0,D.isTypeReference)(e))return Qr(e,t,r,o);let n=(0,T.getReferenceType)(
|
|
53
|
+
e,r);if(n)return Qr(n,t,r,o)},"getHttpDefaults"),Qr=p((e,t,r,o)=>{if((0,D.isTypeObject)(
|
|
54
54
|
e))return Jr(t,(0,T.getObjectMembers)(e),r,o);if(!(0,T.isModelDeclaration)(e)){o.
|
|
55
55
|
push(new L(t.file));return}if(!Pr(e)){o.push(new ee(e.name,t.file));return}return Jr(
|
|
56
56
|
t,(0,T.getModelMembers)(e),r,o)},"getTypeDefaults"),Jr=p((e,t,r,o)=>{let n={};for(let s of t)
|
|
57
|
-
if(!(!(0,
|
|
58
|
-
e.name,s.name,e.file));break;case"httpErrors":n.httpErrors=
|
|
57
|
+
if(!(!(0,D.isModelProperty)(s)||s.inherited))switch(s.name){default:o.push(new T.InvalidServicePropertyError(
|
|
58
|
+
e.name,s.name,e.file));break;case"httpErrors":n.httpErrors=De(s.value,e,r,o);break;case"\
|
|
59
59
|
preferences":n.preferences=Ce(s.value,e,r,o);break;case"memory":case"logRetentio\
|
|
60
60
|
n":case"timeout":n[s.name]=(0,T.getPropertyNumber)(s);break;case"listener":n.listener=
|
|
61
61
|
(0,T.getServiceListener)(s.value,o);break}return n},"getTypeFromMembers");var x=require("@ez4/reflection"),a=require("@ez4/common/library");var Fe=require("@ez4/common/library");var re=class extends Fe.IncompleteTypeError{static{p(this,"IncompleteRouteError")}constructor(t,r){
|
|
62
|
-
super("Incomplete gateway route",t,r)}},
|
|
62
|
+
super("Incomplete gateway route",t,r)}},q=class extends Fe.TypeError{static{p(this,
|
|
63
63
|
"InvalidRouteErrorTypeError")}constructor(t){super("Invalid route error type.",t)}};var Gr=require("@ez4/common/library");var te=class extends Gr.IncompleteTypeError{static{p(this,"IncompleteAuthorizerE\
|
|
64
64
|
rror")}constructor(t,r){super("Incomplete route authorizer",t,r)}};var l=require("@ez4/common/library"),B=require("@ez4/reflection"),_r=require("@ez4/utils");var Ue=require("@ez4/common/library");var oe=class extends Ue.InvalidTypeError{constructor(r,o){super("Invalid route r\
|
|
65
65
|
esponse",void 0,r,o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},
|
|
@@ -68,13 +68,13 @@ ne=class extends Ue.IncorrectTypeError{constructor(r,o,n){super("Incorrect route
|
|
|
68
68
|
sponseTypeError")}};var v=require("@ez4/reflection"),Qe=require("@ez4/common/library"),Yr=require("@ez4/schema/library");var Be=require("@ez4/common/library");var pe=class extends Be.InvalidTypeError{static{p(this,"InvalidIdentityTypeError")}constructor(t){
|
|
69
69
|
super("Invalid identity",void 0,"Http.Identity",t)}},se=class extends Be.IncorrectTypeError{constructor(r,o){
|
|
70
70
|
super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}static{p(this,
|
|
71
|
-
"IncorrectIdentityTypeError")}};var Ve=require("@ez4/schema/library");var
|
|
71
|
+
"IncorrectIdentityTypeError")}};var Ve=require("@ez4/schema/library");var f=p((e,t)=>{let r=(0,Ve.getObjectSchema)(e,t);if(r&&(0,Ve.isObjectSchema)(r))
|
|
72
72
|
return r},"getSchemaFromType");var N=p((e,t,r,o)=>{if((0,v.isTypeUndefined)(e))return;if(!(0,v.isTypeReference)(
|
|
73
73
|
e))return Kr(e,t,r,o);let n=(0,Qe.getReferenceType)(e,r);if(n)return Kr(n,t,r,o)},
|
|
74
74
|
"getHttpIdentity"),Kr=p((e,t,r,o)=>{if((0,v.isTypeUnion)(e))return zt(e.elements,
|
|
75
|
-
t,r,o);if((0,v.isTypeObject)(e)||(0,v.isTypeIntersection)(e))return
|
|
75
|
+
t,r,o);if((0,v.isTypeObject)(e)||(0,v.isTypeIntersection)(e))return f(e,r);if(!(0,Qe.isModelDeclaration)(
|
|
76
76
|
e)){o.push(new pe(t.file));return}if(!Or(e)){o.push(new se(e.name,t.file));return}
|
|
77
|
-
let n=
|
|
77
|
+
let n=f(e,r);return n&&(n.definitions={...n.definitions,extensible:!0}),n},"getT\
|
|
78
78
|
ypeIdentity"),zt=p((e,t,r,o)=>{let n=[];for(let s of e){let i=N(s,t,r,o);i&&n.push(
|
|
79
79
|
i)}return n.length>1?(0,Yr.createUnionSchema)({elements:n}):n[0]},"getIdentityFr\
|
|
80
80
|
omUnion");var F=require("@ez4/reflection"),Ge=require("@ez4/common/library");var Je=require("@ez4/common/library");var ie=class extends Je.InvalidTypeError{static{p(this,"InvalidHeadersTypeError")}constructor(t){
|
|
@@ -82,8 +82,8 @@ super("Invalid headers",void 0,"Http.Headers",t)}},ce=class extends Je.Incorrect
|
|
|
82
82
|
super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}static{p(this,"\
|
|
83
83
|
IncorrectHeadersTypeError")}};var me=p((e,t,r,o)=>{if(!(0,F.isTypeReference)(e))return Wr(e,t,r,o);let n=(0,Ge.getReferenceType)(
|
|
84
84
|
e,r);if(n)return Wr(n,t,r,o)},"getHttpHeaders"),Wr=p((e,t,r,o)=>{if((0,F.isTypeObject)(
|
|
85
|
-
e)||(0,F.isTypeIntersection)(e))return
|
|
86
|
-
o.push(new ie(t.file));return}if(!wr(e)){o.push(new ce(e.name,t.file));return}return
|
|
85
|
+
e)||(0,F.isTypeIntersection)(e))return f(e,r);if(!(0,Ge.isModelDeclaration)(e)){
|
|
86
|
+
o.push(new ie(t.file));return}if(!wr(e)){o.push(new ce(e.name,t.file));return}return f(
|
|
87
87
|
e,r)},"getTypeHeaders");var U=require("@ez4/schema/library"),Ye=require("@ez4/common/library"),y=require("@ez4/reflection");var Ke=require("@ez4/common/library");var ae=class extends Ke.InvalidTypeError{static{p(this,"InvalidBodyTypeError")}constructor(t){
|
|
88
88
|
super("Invalid body",void 0,"Http.JsonBody",t)}},ue=class extends Ke.IncorrectTypeError{constructor(r,o){
|
|
89
89
|
super("Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}static{p(this,"Incor\
|
|
@@ -91,18 +91,18 @@ rectBodyTypeError")}};var le=p((e,t,r,o)=>sr(e,r,n=>nr(n)??pr(n,t,r,o)),"getHttp
|
|
|
91
91
|
if(!(0,y.isTypeUndefined)(e)){if(!(0,y.isTypeReference)(e))return r(e);let o=(0,Ye.getReferenceType)(
|
|
92
92
|
e,t);if(o)return r(o)}},"getTypeBody"),nr=p(e=>{if((0,y.isTypeScalar)(e))return(0,U.getScalarSchema)(
|
|
93
93
|
e)},"getScalarTypeBody"),pr=p((e,t,r,o)=>{if((0,y.isTypeUnion)(e))return Ct(e.elements,
|
|
94
|
-
r,n=>nr(n)??pr(n,t,r,o));if((0,y.isTypeArray)(e))return
|
|
95
|
-
pr(n,t,r,o));if((0,y.isTypeObject)(e)||(0,y.isTypeIntersection)(e))return
|
|
94
|
+
r,n=>nr(n)??pr(n,t,r,o));if((0,y.isTypeArray)(e))return qt(e.element,r,n=>nr(n)??
|
|
95
|
+
pr(n,t,r,o));if((0,y.isTypeObject)(e)||(0,y.isTypeIntersection)(e))return f(e,r);
|
|
96
96
|
if(!(0,Ye.isModelDeclaration)(e)){o.push(new ae(t.file));return}if(!zr(e)){o.push(
|
|
97
|
-
new ue(e.name,e.file));return}return
|
|
97
|
+
new ue(e.name,e.file));return}return f(e,r)},"getCompoundTypeBody"),Ct=p((e,t,r)=>{
|
|
98
98
|
let o={optional:!1,elements:[]};for(let n of e){if((0,y.isTypeUndefined)(n)){o.optional=
|
|
99
99
|
!0;continue}let s=sr(n,t,r);s&&o.elements.push(s)}if(o.elements.length)return(0,U.createUnionSchema)(
|
|
100
|
-
o)},"getUnionTypeBody"),
|
|
101
|
-
{element:o})},"getArrayTypeBody");var ir=p((e,t,r,o)=>{let n=$r(e,t,r,o,"Http.AuthResponse");if(n&&
|
|
100
|
+
o)},"getUnionTypeBody"),qt=p((e,t,r)=>{let o=sr(e,t,r);if(o)return(0,U.createArraySchema)(
|
|
101
|
+
{element:o})},"getArrayTypeBody");var ir=p((e,t,r,o)=>{let n=$r(e,t,r,o,"Http.AuthResponse");if(n&&Dt(n))return n},
|
|
102
102
|
"getHttpAuthResponse"),cr=p((e,t,r,o)=>{let n=$r(e,t,r,o,"Http.Response");if(n&&
|
|
103
103
|
Nt(n))return n},"getHttpHandlerResponse"),$r=p((e,t,r,o,n)=>{if(!(0,B.isTypeReference)(
|
|
104
104
|
e))return Xr(e,t,r,o,n);let s=(0,l.getReferenceType)(e,r);if(s)return Xr(s,t,r,o,
|
|
105
|
-
n)},"getHttpResponse"),
|
|
105
|
+
n)},"getHttpResponse"),Dt=p(e=>!!e.identity,"isValidAuthResponse"),Nt=p(e=>(0,_r.isAnyNumber)(
|
|
106
106
|
e.status)||Array.isArray(e.status),"isValidHandlerResponse"),Xr=p((e,t,r,o,n)=>{
|
|
107
107
|
if((0,B.isTypeObject)(e))return Zr(e,t,(0,l.getObjectMembers)(e),r,o);if(!(0,l.isModelDeclaration)(
|
|
108
108
|
e)){o.push(new oe(n,t.file));return}if(!(0,l.hasHeritageType)(e,n)){o.push(new ne(
|
|
@@ -114,8 +114,8 @@ i);break;case"headers":{s.headers=me(i.value,e,o,n),s.headers&&i.description&&(s
|
|
|
114
114
|
headers.description=i.description);break}case"identity":{s.identity=N(i.value,e,
|
|
115
115
|
o,n),s.identity&&i.description&&(s.identity.description=i.description);break}case"\
|
|
116
116
|
body":{s.body=le(i.value,e,o,n),s.body&&i.description&&(s.body.description=i.description);
|
|
117
|
-
break}}return s},"getTypeFromMembers");var R=require("@ez4/reflection"),b=require("@ez4/common/library");var We=require("@ez4/common/library");var
|
|
118
|
-
equest",void 0,r,o);this.baseType=r}static{p(this,"InvalidRequestTypeError")}},
|
|
117
|
+
break}}return s},"getTypeFromMembers");var R=require("@ez4/reflection"),b=require("@ez4/common/library");var We=require("@ez4/common/library");var de=class extends We.InvalidTypeError{constructor(r,o){super("Invalid route r\
|
|
118
|
+
equest",void 0,r,o);this.baseType=r}static{p(this,"InvalidRequestTypeError")}},fe=class extends We.IncorrectTypeError{constructor(r,o,n){
|
|
119
119
|
super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}static{
|
|
120
120
|
p(this,"IncorrectRequestTypeError")}};var V=require("@ez4/reflection"),Ze=require("@ez4/common/library");var Xe=require("@ez4/common/library");var ye=class extends Xe.InvalidTypeError{static{p(this,"InvalidParameterTypeErro\
|
|
121
121
|
r")}constructor(t){super("Invalid request parameters",void 0,"Http.PathParameter\
|
|
@@ -123,22 +123,22 @@ s",t)}},Te=class extends Xe.IncorrectTypeError{constructor(r,o){super("Incorrect
|
|
|
123
123
|
request parameters",r,"Http.PathParameters",o);this.parametersType=r}static{p(this,
|
|
124
124
|
"IncorrectParameterTypeError")}};var mr=p((e,t,r,o)=>{if(!(0,V.isTypeReference)(e))return Lr(e,t,r,o);let n=(0,Ze.getReferenceType)(
|
|
125
125
|
e,r);if(n)return Lr(n,t,r,o)},"getHttpParameters"),Lr=p((e,t,r,o)=>{if((0,V.isTypeObject)(
|
|
126
|
-
e)||(0,V.isTypeIntersection)(e))return
|
|
127
|
-
o.push(new ye(t.file));return}if(!
|
|
126
|
+
e)||(0,V.isTypeIntersection)(e))return f(e,r);if(!(0,Ze.isModelDeclaration)(e)){
|
|
127
|
+
o.push(new ye(t.file));return}if(!kr(e)){o.push(new Te(e.name,e.file));return}return f(
|
|
128
128
|
e,r)},"getTypeParameter");var Q=require("@ez4/reflection"),$e=require("@ez4/common/library");var _e=require("@ez4/common/library");var ge=class extends _e.InvalidTypeError{static{p(this,"InvalidQueryTypeError")}constructor(t){
|
|
129
129
|
super("Invalid request query strings",void 0,"Http.QueryStrings",t)}},Me=class extends _e.IncorrectTypeError{constructor(r,o){
|
|
130
130
|
super("Incorrect request query strings",r,"Http.QueryStrings",o);this.queryType=
|
|
131
131
|
r}static{p(this,"IncorrectQueryTypeError")}};var ar=p((e,t,r,o)=>{if(!(0,Q.isTypeReference)(e))return et(e,t,r,o);let n=(0,$e.getReferenceType)(
|
|
132
132
|
e,r);if(n)return et(n,t,r,o)},"getHttpQuery"),et=p((e,t,r,o)=>{if((0,Q.isTypeObject)(
|
|
133
|
-
e)||(0,Q.isTypeIntersection)(e))return
|
|
134
|
-
o.push(new ge(t.file));return}if(!
|
|
135
|
-
e,r)},"getTypeQuery");var ur=p((e,t,r,o)=>
|
|
136
|
-
e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),
|
|
137
|
-
e)&&e.elements.length>0)return
|
|
133
|
+
e)||(0,Q.isTypeIntersection)(e))return f(e,r);if(!(0,$e.isModelDeclaration)(e)){
|
|
134
|
+
o.push(new ge(t.file));return}if(!jr(e)){o.push(new Me(e.name,t.file));return}return f(
|
|
135
|
+
e,r)},"getTypeQuery");var ur=p((e,t,r,o)=>dr(e,t,r,o,"Http.AuthRequest"),"getHttpAuthRequest"),lr=p((e,t,r,o)=>dr(
|
|
136
|
+
e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),dr=p((e,t,r,o,n)=>{if((0,R.isTypeIntersection)(
|
|
137
|
+
e)&&e.elements.length>0)return dr(e.elements[0],t,r,o,n);if(!(0,R.isTypeReference)(
|
|
138
138
|
e))return rt(e,t,r,o,n);let s=(0,b.getReferenceType)(e,r);if(s)return rt(s,t,r,o,
|
|
139
139
|
n)},"getHttpRequest"),rt=p((e,t,r,o,n)=>{if((0,R.isTypeObject)(e))return tt(e,t,
|
|
140
|
-
(0,b.getObjectMembers)(e),r,o);if(!(0,b.isModelDeclaration)(e)){o.push(new
|
|
141
|
-
t.file));return}if(!(0,b.hasHeritageType)(e,n)){o.push(new
|
|
140
|
+
(0,b.getObjectMembers)(e),r,o);if(!(0,b.isModelDeclaration)(e)){o.push(new de(n,
|
|
141
|
+
t.file));return}if(!(0,b.hasHeritageType)(e,n)){o.push(new fe(e.name,n,e.file));
|
|
142
142
|
return}return tt(e,t,(0,b.getModelMembers)(e),r,o)},"getTypeRequest"),tt=p((e,t,r,o,n)=>{
|
|
143
143
|
let s={};for(let i of r)if(!(!(0,R.isModelProperty)(i)||i.inherited))switch(i.name){default:
|
|
144
144
|
n.push(new b.InvalidServicePropertyError(t.name,i.name,e.file));break;case"heade\
|
|
@@ -149,7 +149,7 @@ n),s.query&&i.description&&(s.query.description=i.description);break}case"parame
|
|
|
149
149
|
ters":{s.parameters=mr(i.value,e,o,n),s.parameters&&i.description&&(s.parameters.
|
|
150
150
|
description=i.description);break}case"body":{s.body=le(i.value,e,o,n),s.body&&i.
|
|
151
151
|
description&&(s.body.description=i.description);break}}return s},"getTypeFromMem\
|
|
152
|
-
bers");var
|
|
152
|
+
bers");var fr=p((e,t,r,o)=>{if(!Nr(e))return;let{description:n,module:s}=e,i={...n&&{description:n},
|
|
153
153
|
...s&&{module:s}},m=new Set(["name","file"]);if((i.name=e.name)&&m.delete("name"),
|
|
154
154
|
(i.file=e.file)&&m.delete("file"),e.parameters){let[{value:c}]=e.parameters;i.request=
|
|
155
155
|
ur(c,t,r,o)}if(e.return&&(i.response=ir(e.return,t,r,o)),Ft(i))return i;o.push(new te(
|
|
@@ -187,8 +187,8 @@ return Tr(e.elements,t,r,o,n)},"getRouteType"),it=p((e,t,r,o,n,s)=>{let i={},m=n
|
|
|
187
187
|
switch(c.name){default:n.push(new a.InvalidServicePropertyError(t.name,c.name,e.
|
|
188
188
|
file));break;case"name":i.name=(0,a.getPropertyString)(c);break;case"path":{let P=(0,a.getPropertyString)(
|
|
189
189
|
c);P&&Ar(P)&&(m.delete(c.name),i.path=P);break}case"handler":(i.handler=yr(c.value,
|
|
190
|
-
t,o,n,s))&&m.delete(c.name);break;case"authorizer":i.authorizer=
|
|
191
|
-
break;case"httpErrors":i.httpErrors=
|
|
190
|
+
t,o,n,s))&&m.delete(c.name);break;case"authorizer":i.authorizer=fr(c.value,t,o,n);
|
|
191
|
+
break;case"httpErrors":i.httpErrors=De(c.value,t,o,n);break;case"preferences":i.
|
|
192
192
|
preferences=Ce(c.value,t,o,n);break;case"memory":case"logRetention":case"timeout":
|
|
193
193
|
i[c.name]=(0,a.getPropertyNumber)(c);break;case"cors":i.cors=(0,a.getPropertyBoolean)(
|
|
194
194
|
c);break;case"listener":i.listener=(0,a.getServiceListener)(c.value,n);break;case"\
|
|
@@ -212,39 +212,39 @@ super("Incomplete gateway access",t,r)}},Ae=class extends K.InvalidTypeError{sta
|
|
|
212
212
|
p(this,"InvalidAccessTypeError")}constructor(t){super("Invalid gateway access ty\
|
|
213
213
|
pe",void 0,"Http.Access",t)}},Ee=class extends K.IncorrectTypeError{constructor(r,o){
|
|
214
214
|
super("Incorrect gateway access type",r,"Http.Access",o);this.cacheType=r}static{
|
|
215
|
-
p(this,"IncorrectAccessTypeError")}};var
|
|
215
|
+
p(this,"IncorrectAccessTypeError")}};var dt=p((e,t,r,o)=>{if(!(0,Y.isTypeReference)(e))return ut(e,t,o);let n=(0,S.getReferenceType)(
|
|
216
216
|
e,r);if(n)return ut(n,t,o)},"getHttpAccess"),Kt=p(e=>(0,hr.isAnyNumber)(e.logRetention),
|
|
217
217
|
"isValidAccess"),ut=p((e,t,r)=>{if((0,Y.isTypeObject)(e))return lt(e,t,(0,S.getObjectMembers)(
|
|
218
|
-
e),r);if(!(0,S.isModelDeclaration)(e)){r.push(new Ae(t.file));return}if(!
|
|
218
|
+
e),r);if(!(0,S.isModelDeclaration)(e)){r.push(new Ae(t.file));return}if(!qr(e)){
|
|
219
219
|
r.push(new Ee(e.name,e.file));return}return lt(e,t,(0,S.getModelMembers)(e),r)},
|
|
220
220
|
"getTypeAccess"),lt=p((e,t,r,o)=>{let n={},s=new Set(["logRetention"]);for(let i of r)
|
|
221
221
|
if(!(!(0,Y.isModelProperty)(i)||i.inherited))switch(i.name){default:o.push(new S.InvalidServicePropertyError(
|
|
222
222
|
t.name,i.name,e.file));break;case"logRetention":{let m=(0,S.getPropertyNumber)(i);
|
|
223
223
|
(0,hr.isAnyNumber)(m)&&(n[i.name]=m,s.delete(i.name));break}}if(Kt(n))return n;o.
|
|
224
|
-
push(new xe([...s],e.file))},"getTypeFromMembers");var
|
|
224
|
+
push(new xe([...s],e.file))},"getTypeFromMembers");var d=require("@ez4/common/library"),X=require("@ez4/reflection");var W=require("@ez4/common/library");var Pe=class extends W.IncompleteTypeError{static{p(this,"IncompleteCorsError")}constructor(t,r){
|
|
225
225
|
super("Incomplete HTTP CORS",t,r)}},Re=class extends W.InvalidTypeError{static{p(
|
|
226
226
|
this,"InvalidCorsTypeError")}constructor(t){super("Invalid HTTP CORS type",void 0,
|
|
227
227
|
"Http.Cors",t)}},we=class extends W.IncorrectTypeError{constructor(r,o){super("I\
|
|
228
228
|
ncorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}static{p(this,"Inc\
|
|
229
|
-
orrectCorsTypeError")}};var Sr=p((e,t,r,o)=>{if(!(0,X.isTypeReference)(e))return
|
|
230
|
-
e,r);if(n)return
|
|
231
|
-
alidCors"),
|
|
232
|
-
e),r);if(!(0,
|
|
233
|
-
r.push(new we(e.name,e.file));return}return yt(e,t,(0,
|
|
229
|
+
orrectCorsTypeError")}};var Sr=p((e,t,r,o)=>{if(!(0,X.isTypeReference)(e))return ft(e,t,o);let n=(0,d.getReferenceType)(
|
|
230
|
+
e,r);if(n)return ft(n,t,o)},"getHttpCors"),Yt=p(e=>!!e.allowOrigins?.length,"isV\
|
|
231
|
+
alidCors"),ft=p((e,t,r)=>{if((0,X.isTypeObject)(e))return yt(e,t,(0,d.getObjectMembers)(
|
|
232
|
+
e),r);if(!(0,d.isModelDeclaration)(e)){r.push(new Re(t.file));return}if(!Dr(e)){
|
|
233
|
+
r.push(new we(e.name,e.file));return}return yt(e,t,(0,d.getModelMembers)(e),r)},
|
|
234
234
|
"getTypeCors"),yt=p((e,t,r,o)=>{let n={},s=new Set(["allowOrigins"]);for(let i of r)
|
|
235
|
-
if(!(!(0,X.isModelProperty)(i)||i.inherited))switch(i.name){default:o.push(new
|
|
235
|
+
if(!(!(0,X.isModelProperty)(i)||i.inherited))switch(i.name){default:o.push(new d.InvalidServicePropertyError(
|
|
236
236
|
t.name,i.name,e.file));break;case"allowOrigins":case"allowMethods":case"allowHea\
|
|
237
|
-
ders":case"exposeHeaders":n[i.name]=(0,
|
|
238
|
-
lowCredentials":n.allowCredentials=(0,
|
|
239
|
-
n.maxAge=(0,
|
|
240
|
-
e.file))},"getTypeFromMembers");var vr=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!
|
|
241
|
-
n))continue;let s={type:
|
|
237
|
+
ders":case"exposeHeaders":n[i.name]=(0,d.getPropertyStringList)(i);break;case"al\
|
|
238
|
+
lowCredentials":n.allowCredentials=(0,d.getPropertyBoolean)(i);break;case"maxAge":
|
|
239
|
+
n.maxAge=(0,d.getPropertyNumber)(i);break}if(Yt(n))return n;o.push(new Pe([...s],
|
|
240
|
+
e.file))},"getTypeFromMembers");var vr=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!ke(n)||(0,g.isExternalDeclaration)(
|
|
241
|
+
n))continue;let s={type:j,context:{}},i=new Set(["routes"]),m=n.file;s.name=n.name,
|
|
242
242
|
n.description&&(s.description=n.description);for(let c of(0,g.getModelMembers)(n))
|
|
243
243
|
if(!(!(0,Tt.isModelProperty)(c)||c.inherited))switch(c.name){default:r.push(new g.InvalidServicePropertyError(
|
|
244
244
|
s.name,c.name,m));break;case"routes":(s.routes=gr(n,c,e,r))&&i.delete(c.name);break;case"\
|
|
245
245
|
name":s.displayName=(0,g.getPropertyString)(c);break;case"defaults":s.defaults=Ne(
|
|
246
246
|
c.value,n,e,r);break;case"cache":s.cache=br(c.value,n,e,r);break;case"access":s.
|
|
247
|
-
access=
|
|
247
|
+
access=dt(c.value,n,e,r);break;case"cors":s.cors=Sr(c.value,n,e,r);break;case"va\
|
|
248
248
|
riables":s.variables=(0,g.getLinkedVariableList)(c,r);break;case"services":s.services=
|
|
249
249
|
(0,g.getLinkedServiceList)(c,e,r);break}if(!Wt(s)){r.push(new w([...i],m));continue}
|
|
250
250
|
if(t[n.name]){r.push(new g.DuplicateServiceError(n.name,m));continue}Xt(s,r,m),t[n.
|
|
@@ -264,14 +264,15 @@ inherited&&(s.displayName=(0,M.getPropertyString)(c,e));break;case"defaults":c.i
|
|
|
264
264
|
(s.defaults=Ne(c.value,n,e,r));break}if(!Zt(s)){r.push(new w([...i],m));continue}
|
|
265
265
|
if(t[n.name]){r.push(new M.DuplicateServiceError(n.name,m));continue}t[n.name]=s}
|
|
266
266
|
return{services:t,errors:r}},"getHttpImports"),Zt=p(e=>!!e.name&&!!e.reference&&
|
|
267
|
-
!!e.project&&!!e.routes,"isValidImport");var Mt=p(e=>
|
|
267
|
+
!!e.project&&!!e.routes,"isValidImport");var Mt=p(e=>ke(e)?e.name:null,"getLinkedService"),Ht=p(e=>ze(e)?e.name:null,"get\
|
|
268
268
|
LinkedImport");var bt=!1,_t=p(()=>{bt||((0,ht.registerTriggers)(),(0,St.registerTriggers)(),(0,Ir.createTrigger)(
|
|
269
|
-
|
|
269
|
+
j,{"metadata:getServices":vr,"metadata:getLinkedService":Mt}),(0,Ir.createTrigger)(
|
|
270
270
|
O,{"metadata:getServices":gt,"metadata:getLinkedService":Ht}),bt=!0)},"registerT\
|
|
271
271
|
riggers");var $t=p(e=>{let t={},r=e.defaults?.preferences?.namingStyle;for(let o of e.routes){
|
|
272
272
|
if(!o.name)continue;let[n,s]=o.path.split(" ",2);t[o.name]={namingStyle:o.preferences?.
|
|
273
|
-
namingStyle??r,responseSchema:o.handler.response.
|
|
274
|
-
|
|
273
|
+
namingStyle??r,bodySchema:o.handler.request?.body,responseSchema:o.handler.response.
|
|
274
|
+
body,querySchema:o.handler.request?.query,method:n,path:s}}return t},"getClientO\
|
|
275
|
+
perations");var tr=require("@ez4/common/library");var L=class extends tr.InvalidTypeError{static{p(this,"InvalidDefaultsTypeError")}constructor(t){
|
|
275
276
|
super("Invalid defaults",void 0,"Http.Defaults",t)}},ee=class extends tr.IncorrectTypeError{constructor(r,o){
|
|
276
277
|
super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}static{p(this,
|
|
277
278
|
"IncorrectDefaultsTypeError")}};var or=require("@ez4/common/library");var _=class extends or.InvalidTypeError{static{p(this,"InvalidPreferencesTypeErr\
|
package/dist/library.mjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
var Pr=Object.defineProperty;var p=(e,t)=>Pr(e,"name",{value:t,configurable:!0});import{registerTriggers as
|
|
2
|
-
import{createTrigger as Ar}from"@ez4/project/library";var
|
|
1
|
+
var Pr=Object.defineProperty;var p=(e,t)=>Pr(e,"name",{value:t,configurable:!0});import{registerTriggers as dp}from"@ez4/common/library";import{registerTriggers as fp}from"@ez4/schema/library";
|
|
2
|
+
import{createTrigger as Ar}from"@ez4/project/library";var f="@ez4/import:http",bp=p(e=>e.type===f,"isHttpImport");var y="@ez4/http",vp=p(e=>e.type===y,"isHttpService");import{DuplicateServiceError as Xn,isExternalDeclaration as Zn,getLinkedServiceList as _n,
|
|
3
3
|
getLinkedVariableList as $n,getModelMembers as Ln,getPropertyString as ep,InvalidServicePropertyError as rp}from"@ez4/common/library";
|
|
4
|
-
import{isModelProperty as tp}from"@ez4/reflection";import{IncompleteTypeError as Rr,TypeCollisionError as wr}from"@ez4/common/library";var
|
|
4
|
+
import{isModelProperty as tp}from"@ez4/reflection";import{IncompleteTypeError as Rr,TypeCollisionError as wr}from"@ez4/common/library";var d=class extends Rr{static{p(this,"IncompleteServiceError")}constructor(t,r){
|
|
5
5
|
super("Incomplete service",t,r)}},H=class extends wr{static{p(this,"ServiceColli\
|
|
6
6
|
sionError")}constructor(t,r){super("Service error",t,r)}};import{InvalidServicePropertyError as $r,isModelDeclaration as Lr,getPropertyNumber as et,
|
|
7
7
|
getObjectMembers as rt,getModelMembers as tt,getServiceListener as ot,getReferenceType as nt}from"@ez4/common/library";
|
|
8
|
-
import{isModelProperty as pt,isTypeObject as st,isTypeReference as it}from"@ez4/reflection";import{InvalidServicePropertyError as
|
|
9
|
-
getModelMembers as
|
|
8
|
+
import{isModelProperty as pt,isTypeObject as st,isTypeReference as it}from"@ez4/reflection";import{InvalidServicePropertyError as kr,isModelDeclaration as zr,getObjectMembers as Cr,
|
|
9
|
+
getModelMembers as qr,getReferenceType as Dr,getPropertyStringIn as Nr}from"@ez4/common/library";
|
|
10
10
|
import{isModelProperty as Fr,isTypeObject as Ur,isTypeReference as Br}from"@ez4/reflection";import{hasHeritageType as u,isClassDeclaration as ue,isModelDeclaration as Or}from"@ez4/common/library";
|
|
11
|
-
import{isTypeCallback as le,isTypeFunction as
|
|
12
|
-
t]=e.split(" ",2);return
|
|
11
|
+
import{isTypeCallback as le,isTypeFunction as de}from"@ez4/reflection";var jr=new Set(["ANY","GET","POST","PUT","PATCH","DELETE","OPTIONS"]),fe=p(e=>{let[
|
|
12
|
+
t]=e.split(" ",2);return jr.has(t)},"isHttpPath"),b=p(e=>ue(e)&&u(e,"Http.Servic\
|
|
13
13
|
e"),"isHttpService"),h=p(e=>ue(e)&&u(e,"Http.Import"),"isHttpImport");var ye=p(e=>Or(e)&&u(e,"Http.Route"),"isHttpRoute");var Te=p(e=>u(e,"Http.Defaults"),"isHttpDefaults"),ge=p(e=>u(e,"Http.Preferences"),
|
|
14
14
|
"isHttpPreferences"),Me=p(e=>u(e,"Http.Headers"),"isHttpHeaders"),He=p(e=>u(e,"H\
|
|
15
15
|
ttp.Identity"),"isHttpIdentity"),be=p(e=>u(e,"Http.QueryStrings"),"isHttpQuery"),
|
|
16
16
|
he=p(e=>u(e,"Http.PathParameters"),"isHttpParameters"),Se=p(e=>u(e,"Http.JsonBod\
|
|
17
17
|
y"),"isJsonBody"),ve=p(e=>u(e,"Http.Cache"),"isHttpCache"),Ie=p(e=>u(e,"Http.Acc\
|
|
18
|
-
ess"),"isHttpAccess"),xe=p(e=>u(e,"Http.Cors"),"isHttpCors"),Ae=p(e=>le(e)||
|
|
19
|
-
"isHttpAuthorizer"),Ee=p(e=>le(e)||
|
|
18
|
+
ess"),"isHttpAccess"),xe=p(e=>u(e,"Http.Cors"),"isHttpCors"),Ae=p(e=>le(e)||de(e),
|
|
19
|
+
"isHttpAuthorizer"),Ee=p(e=>le(e)||de(e),"isHttpHandler");import{NamingStyle as T}from"@ez4/schema";var S=p((e,t,r,o)=>{if(!Br(e))return Pe(e,t,o);let n=Dr(e,r);if(n)return Pe(n,t,
|
|
20
20
|
o)},"getHttpPreferences"),Pe=p((e,t,r)=>{if(Ur(e))return Re(t,Cr(e),r);if(!zr(e)){
|
|
21
21
|
r.push(new v(t.file));return}if(!ge(e)){r.push(new I(e.name,t.file));return}return Re(
|
|
22
|
-
t,
|
|
23
|
-
switch(n.name){default:r.push(new
|
|
22
|
+
t,qr(e),r)},"getTypePreferences"),Re=p((e,t,r)=>{let o={};for(let n of t)if(Fr(n))
|
|
23
|
+
switch(n.name){default:r.push(new kr(e.name,n.name,e.file));break;case"namingSty\
|
|
24
24
|
le":o.namingStyle=Nr(n,[T.Preserve,T.CamelCase,T.PascalCase,T.SnakeCase,T.KebabCase]);
|
|
25
25
|
break}return o},"getTypeFromMembers");import{InvalidServicePropertyError as Vr,getObjectMembers as Qr,getPropertyTuple as Jr,
|
|
26
26
|
getReferenceType as Oe}from"@ez4/common/library";import{isAnyNumber as Gr,isEmptyObject as Kr}from"@ez4/utils";
|
|
27
|
-
import{isModelProperty as Yr,isTypeClass as Wr,isTypeObject as Xr,isTypeReference as
|
|
27
|
+
import{isModelProperty as Yr,isTypeClass as Wr,isTypeObject as Xr,isTypeReference as je}from"@ez4/reflection";var x=p((e,t,r,o)=>{if(!je(e))return we(e,t,r,o);let n=Oe(e,r);if(n)return we(n,
|
|
28
28
|
t,r,o)},"getHttpErrors"),we=p((e,t,r,o)=>{if(Xr(e))return Zr(e,t,Qr(e),r,o)},"ge\
|
|
29
29
|
tTypeErrors"),Zr=p((e,t,r,o,n)=>{let s={};for(let i of r){if(!Yr(i)||i.inherited)
|
|
30
30
|
continue;let m=parseInt(i.name,10);Gr(m)||n.push(new Vr(t.name,i.name,e.file));let c=_r(
|
|
31
31
|
i,m,t,o,n);c&&Object.assign(s,c)}if(!Kr(s))return s},"getTypeFromMembers"),_r=p(
|
|
32
|
-
(e,t,r,o,n)=>{let s=Jr(e)??[],i={};for(let m of s){if(!
|
|
32
|
+
(e,t,r,o,n)=>{let s=Jr(e)??[],i={};for(let m of s){if(!je(m)){n.push(new g(r.file));
|
|
33
33
|
continue}let c=Oe(m,o);if(!c||!Wr(c)){n.push(new g(r.file));continue}i[c.name]=t}
|
|
34
|
-
return i},"getErrorClasses");var A=p((e,t,r,o)=>{if(!it(e))return
|
|
35
|
-
t,r,o)},"getHttpDefaults"),
|
|
34
|
+
return i},"getErrorClasses");var A=p((e,t,r,o)=>{if(!it(e))return ke(e,t,r,o);let n=nt(e,r);if(n)return ke(n,
|
|
35
|
+
t,r,o)},"getHttpDefaults"),ke=p((e,t,r,o)=>{if(st(e))return ze(t,rt(e),r,o);if(!Lr(
|
|
36
36
|
e)){o.push(new E(t.file));return}if(!Te(e)){o.push(new P(e.name,t.file));return}
|
|
37
37
|
return ze(t,tt(e),r,o)},"getTypeDefaults"),ze=p((e,t,r,o)=>{let n={};for(let s of t)
|
|
38
38
|
if(!(!pt(s)||s.inherited))switch(s.name){default:o.push(new $r(e.name,s.name,e.file));
|
|
@@ -49,57 +49,57 @@ super("Incomplete route authorizer",t,r)}};import{InvalidServicePropertyError as
|
|
|
49
49
|
getModelMembers as _t,getObjectMembers as $t,getPropertyNumber as Lt,getPropertyNumberList as eo,
|
|
50
50
|
getReferenceType as ro}from"@ez4/common/library";import{isModelProperty as to,isTypeObject as oo,
|
|
51
51
|
isTypeReference as no}from"@ez4/reflection";import{isAnyNumber as po}from"@ez4/utils";import{IncorrectTypeError as ut,InvalidTypeError as lt}from"@ez4/common/library";var O=class extends lt{constructor(r,o){super("Invalid route response",void 0,r,
|
|
52
|
-
o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},
|
|
52
|
+
o);this.baseType=r}static{p(this,"InvalidResponseTypeError")}},j=class extends ut{constructor(r,o,n){
|
|
53
53
|
super("Incorrect route response",r,o,n);this.responseType=r;this.baseType=o}static{
|
|
54
54
|
p(this,"IncorrectResponseTypeError")}};import{isTypeIntersection as gt,isTypeObject as Mt,isTypeReference as Ht,isTypeUndefined as bt,
|
|
55
55
|
isTypeUnion as ht}from"@ez4/reflection";import{getReferenceType as St,isModelDeclaration as vt}from"@ez4/common/library";
|
|
56
|
-
import{createUnionSchema as It}from"@ez4/schema/library";import{IncorrectTypeError as
|
|
57
|
-
super("Invalid identity",void 0,"Http.Identity",t)}},z=class extends
|
|
56
|
+
import{createUnionSchema as It}from"@ez4/schema/library";import{IncorrectTypeError as dt,InvalidTypeError as ft}from"@ez4/common/library";var k=class extends ft{static{p(this,"InvalidIdentityTypeError")}constructor(t){
|
|
57
|
+
super("Invalid identity",void 0,"Http.Identity",t)}},z=class extends dt{constructor(r,o){
|
|
58
58
|
super("Incorrect identity",r,"Http.Identity",o);this.identityType=r}static{p(this,
|
|
59
59
|
"IncorrectIdentityTypeError")}};import{getObjectSchema as yt,isObjectSchema as Tt}from"@ez4/schema/library";var a=p((e,t)=>{let r=yt(e,t);if(r&&Tt(r))return r},"getSchemaFromType");var M=p((e,t,r,o)=>{if(bt(e))return;if(!Ht(e))return Ce(e,t,r,o);let n=St(e,r);if(n)
|
|
60
60
|
return Ce(n,t,r,o)},"getHttpIdentity"),Ce=p((e,t,r,o)=>{if(ht(e))return xt(e.elements,
|
|
61
|
-
t,r,o);if(Mt(e)||gt(e))return a(e,r);if(!vt(e)){o.push(new
|
|
61
|
+
t,r,o);if(Mt(e)||gt(e))return a(e,r);if(!vt(e)){o.push(new k(t.file));return}if(!He(
|
|
62
62
|
e)){o.push(new z(e.name,t.file));return}let n=a(e,r);return n&&(n.definitions={...n.
|
|
63
63
|
definitions,extensible:!0}),n},"getTypeIdentity"),xt=p((e,t,r,o)=>{let n=[];for(let s of e){
|
|
64
64
|
let i=M(s,t,r,o);i&&n.push(i)}return n.length>1?It({elements:n}):n[0]},"getIdent\
|
|
65
65
|
ityFromUnion");import{isTypeIntersection as Pt,isTypeObject as Rt,isTypeReference as wt}from"@ez4/reflection";
|
|
66
|
-
import{getReferenceType as Ot,isModelDeclaration as
|
|
67
|
-
"Invalid headers",void 0,"Http.Headers",t)}},
|
|
66
|
+
import{getReferenceType as Ot,isModelDeclaration as jt}from"@ez4/common/library";import{IncorrectTypeError as At,InvalidTypeError as Et}from"@ez4/common/library";var C=class extends Et{static{p(this,"InvalidHeadersTypeError")}constructor(t){super(
|
|
67
|
+
"Invalid headers",void 0,"Http.Headers",t)}},q=class extends At{constructor(r,o){
|
|
68
68
|
super("Incorrect headers",r,"Http.Headers",o);this.headersType=r}static{p(this,"\
|
|
69
|
-
IncorrectHeadersTypeError")}};var
|
|
70
|
-
t,r,o)},"getHttpHeaders"),
|
|
71
|
-
e)){o.push(new C(t.file));return}if(!Me(e)){o.push(new
|
|
72
|
-
return a(e,r)},"getTypeHeaders");import{createUnionSchema as Ct,getScalarSchema as
|
|
69
|
+
IncorrectHeadersTypeError")}};var D=p((e,t,r,o)=>{if(!wt(e))return qe(e,t,r,o);let n=Ot(e,r);if(n)return qe(n,
|
|
70
|
+
t,r,o)},"getHttpHeaders"),qe=p((e,t,r,o)=>{if(Rt(e)||Pt(e))return a(e,r);if(!jt(
|
|
71
|
+
e)){o.push(new C(t.file));return}if(!Me(e)){o.push(new q(e.name,t.file));return}
|
|
72
|
+
return a(e,r)},"getTypeHeaders");import{createUnionSchema as Ct,getScalarSchema as qt,createArraySchema as Dt}from"@ez4/schema/library";
|
|
73
73
|
import{getReferenceType as Nt,isModelDeclaration as Ft}from"@ez4/common/library";
|
|
74
74
|
import{isTypeArray as Ut,isTypeIntersection as Bt,isTypeObject as Vt,isTypeReference as Qt,
|
|
75
|
-
isTypeScalar as Jt,isTypeUndefined as
|
|
76
|
-
"Invalid body",void 0,"Http.JsonBody",t)}},F=class extends
|
|
75
|
+
isTypeScalar as Jt,isTypeUndefined as De,isTypeUnion as Gt}from"@ez4/reflection";import{IncorrectTypeError as kt,InvalidTypeError as zt}from"@ez4/common/library";var N=class extends zt{static{p(this,"InvalidBodyTypeError")}constructor(t){super(
|
|
76
|
+
"Invalid body",void 0,"Http.JsonBody",t)}},F=class extends kt{constructor(r,o){super(
|
|
77
77
|
"Incorrect body",r,"Http.JsonBody",o);this.bodyType=r}static{p(this,"IncorrectBo\
|
|
78
|
-
dyTypeError")}};var U=p((e,t,r,o)=>ie(e,r,n=>pe(n)??se(n,t,r,o)),"getHttpBody"),ie=p((e,t,r)=>{if(!
|
|
78
|
+
dyTypeError")}};var U=p((e,t,r,o)=>ie(e,r,n=>pe(n)??se(n,t,r,o)),"getHttpBody"),ie=p((e,t,r)=>{if(!De(
|
|
79
79
|
e)){if(!Qt(e))return r(e);let o=Nt(e,t);if(o)return r(o)}},"getTypeBody"),pe=p(e=>{
|
|
80
|
-
if(Jt(e))return
|
|
80
|
+
if(Jt(e))return qt(e)},"getScalarTypeBody"),se=p((e,t,r,o)=>{if(Gt(e))return Kt(
|
|
81
81
|
e.elements,r,n=>pe(n)??se(n,t,r,o));if(Ut(e))return Yt(e.element,r,n=>pe(n)??se(
|
|
82
82
|
n,t,r,o));if(Vt(e)||Bt(e))return a(e,r);if(!Ft(e)){o.push(new N(t.file));return}
|
|
83
83
|
if(!Se(e)){o.push(new F(e.name,e.file));return}return a(e,r)},"getCompoundTypeBo\
|
|
84
|
-
dy"),Kt=p((e,t,r)=>{let o={optional:!1,elements:[]};for(let n of e){if(
|
|
84
|
+
dy"),Kt=p((e,t,r)=>{let o={optional:!1,elements:[]};for(let n of e){if(De(n)){o.
|
|
85
85
|
optional=!0;continue}let s=ie(n,t,r);s&&o.elements.push(s)}if(o.elements.length)
|
|
86
|
-
return Ct(o)},"getUnionTypeBody"),Yt=p((e,t,r)=>{let o=ie(e,t,r);if(o)return
|
|
86
|
+
return Ct(o)},"getUnionTypeBody"),Yt=p((e,t,r)=>{let o=ie(e,t,r);if(o)return Dt(
|
|
87
87
|
{element:o})},"getArrayTypeBody");var Ue=p((e,t,r,o)=>{let n=Ve(e,t,r,o,"Http.AuthResponse");if(n&&so(n))return n},
|
|
88
88
|
"getHttpAuthResponse"),Be=p((e,t,r,o)=>{let n=Ve(e,t,r,o,"Http.Response");if(n&&
|
|
89
89
|
io(n))return n},"getHttpHandlerResponse"),Ve=p((e,t,r,o,n)=>{if(!no(e))return Ne(
|
|
90
90
|
e,t,r,o,n);let s=ro(e,r);if(s)return Ne(s,t,r,o,n)},"getHttpResponse"),so=p(e=>!!e.
|
|
91
91
|
identity,"isValidAuthResponse"),io=p(e=>po(e.status)||Array.isArray(e.status),"i\
|
|
92
92
|
sValidHandlerResponse"),Ne=p((e,t,r,o,n)=>{if(oo(e))return Fe(e,t,$t(e),r,o);if(!Xt(
|
|
93
|
-
e)){o.push(new O(n,t.file));return}if(!Zt(e,n)){o.push(new
|
|
93
|
+
e)){o.push(new O(n,t.file));return}if(!Zt(e,n)){o.push(new j(e.name,n,e.file));return}
|
|
94
94
|
return Fe(e,t,_t(e),r,o)},"getTypeResponse"),Fe=p((e,t,r,o,n)=>{let s={};for(let i of r)
|
|
95
95
|
if(!(!to(i)||i.inherited))switch(i.name){default:n.push(new Wt(t.name,i.name,e.file));
|
|
96
|
-
break;case"status":s.status=Lt(i)??eo(i);break;case"headers":{s.headers=
|
|
96
|
+
break;case"status":s.status=Lt(i)??eo(i);break;case"headers":{s.headers=D(i.value,
|
|
97
97
|
e,o,n),s.headers&&i.description&&(s.headers.description=i.description);break}case"\
|
|
98
98
|
identity":{s.identity=M(i.value,e,o,n),s.identity&&i.description&&(s.identity.description=
|
|
99
99
|
i.description);break}case"body":{s.body=U(i.value,e,o,n),s.body&&i.description&&
|
|
100
100
|
(s.body.description=i.description);break}}return s},"getTypeFromMembers");import{isModelProperty as xo,isTypeIntersection as Ao,isTypeObject as Eo,isTypeReference as Po}from"@ez4/reflection";
|
|
101
101
|
import{InvalidServicePropertyError as Ro,isModelDeclaration as wo,hasHeritageType as Oo,
|
|
102
|
-
getObjectMembers as
|
|
102
|
+
getObjectMembers as jo,getModelMembers as ko,getReferenceType as zo}from"@ez4/common/library";import{IncorrectTypeError as co,InvalidTypeError as mo}from"@ez4/common/library";var B=class extends mo{constructor(r,o){super("Invalid route request",void 0,r,o);
|
|
103
103
|
this.baseType=r}static{p(this,"InvalidRequestTypeError")}},V=class extends co{constructor(r,o,n){
|
|
104
104
|
super("Incorrect route request",r,o,n);this.requestType=r;this.baseType=o}static{
|
|
105
105
|
p(this,"IncorrectRequestTypeError")}};import{isTypeIntersection as lo,isTypeObject as fo,isTypeReference as yo}from"@ez4/reflection";
|
|
@@ -120,10 +120,10 @@ e,r)},"getTypeQuery");var Xe=p((e,t,r,o)=>ce(e,t,r,o,"Http.AuthRequest"),"getHtt
|
|
|
120
120
|
e,t,r,o,"Http.Request"),"getHttpHandlerRequest"),ce=p((e,t,r,o,n)=>{if(Ao(e)&&e.
|
|
121
121
|
elements.length>0)return ce(e.elements[0],t,r,o,n);if(!Po(e))return Ye(e,t,r,o,n);
|
|
122
122
|
let s=zo(e,r);if(s)return Ye(s,t,r,o,n)},"getHttpRequest"),Ye=p((e,t,r,o,n)=>{if(Eo(
|
|
123
|
-
e))return We(e,t,
|
|
124
|
-
o.push(new V(e.name,n,e.file));return}return We(e,t,
|
|
123
|
+
e))return We(e,t,jo(e),r,o);if(!wo(e)){o.push(new B(n,t.file));return}if(!Oo(e,n)){
|
|
124
|
+
o.push(new V(e.name,n,e.file));return}return We(e,t,ko(e),r,o)},"getTypeRequest"),
|
|
125
125
|
We=p((e,t,r,o,n)=>{let s={};for(let i of r)if(!(!xo(i)||i.inherited))switch(i.name){default:
|
|
126
|
-
n.push(new Ro(t.name,i.name,e.file));break;case"headers":{s.headers=
|
|
126
|
+
n.push(new Ro(t.name,i.name,e.file));break;case"headers":{s.headers=D(i.value,e,
|
|
127
127
|
o,n),s.headers&&i.description&&(s.headers.description=i.description);break}case"\
|
|
128
128
|
identity":{s.identity=M(i.value,e,o,n),s.identity&&i.description&&(s.identity.description=
|
|
129
129
|
i.description);break}case"query":{s.query=Ke(i.value,e,o,n),s.query&&i.description&&
|
|
@@ -135,11 +135,11 @@ break}}return s},"getTypeFromMembers");var _e=p((e,t,r,o)=>{if(!Ae(e))return;let
|
|
|
135
135
|
(i.file=e.file)&&m.delete("file"),e.parameters){let[{value:c}]=e.parameters;i.request=
|
|
136
136
|
Xe(c,t,r,o)}if(e.return&&(i.response=Ue(e.return,t,r,o)),Co(i))return i;o.push(new w(
|
|
137
137
|
[...m],e.file))},"getHttpAuthorizer"),Co=p(e=>!!e.name&&!!e.file,"isValidAuthori\
|
|
138
|
-
zer");import{IncompleteTypeError as
|
|
138
|
+
zer");import{IncompleteTypeError as qo}from"@ez4/common/library";var Y=class extends qo{static{p(this,"IncompleteHandlerError")}constructor(t,r){
|
|
139
139
|
super("Incomplete route handler",t,r)}};import{isModelDeclaration as Fo,getModelMembers as Uo,getReferenceType as Bo,getLinkedServiceList as Vo,
|
|
140
140
|
getLinkedVariableList as Qo}from"@ez4/common/library";import{isModelProperty as Jo,
|
|
141
|
-
isTypeReference as Go}from"@ez4/reflection";import{IncompleteTypeError as
|
|
142
|
-
o);this.baseType=r}static{p(this,"InvalidProviderTypeError")}},X=class extends
|
|
141
|
+
isTypeReference as Go}from"@ez4/reflection";import{IncompleteTypeError as Do,InvalidTypeError as No}from"@ez4/common/library";var W=class extends No{constructor(r,o){super("Invalid route provider",void 0,r,
|
|
142
|
+
o);this.baseType=r}static{p(this,"InvalidProviderTypeError")}},X=class extends Do{static{
|
|
143
143
|
p(this,"IncompleteProviderError")}constructor(t,r){super("Incomplete route provi\
|
|
144
144
|
der",t,r)}};var Le=p((e,t,r,o)=>{if(!Go(e))return $e(e,t,r,o,"Http.Provider");let n=Bo(e,r);
|
|
145
145
|
if(n)return $e(n,t,r,o,"Http.Provider")},"getHttpProvider"),Ko=p(e=>!!e.services,
|
|
@@ -165,46 +165,46 @@ e))return or(e,t,tn(e),r,o,n);if(Zo(e))return or(e,t,rn(e),r,o,n);if(pr(e)&&e.sp
|
|
|
165
165
|
return me(e.elements,t,r,o,n)},"getRouteType"),or=p((e,t,r,o,n,s)=>{let i={},m=new Set(
|
|
166
166
|
["path","handler"]);for(let c of r)if(!(!Xo(c)||c.inherited))switch(c.name){default:
|
|
167
167
|
n.push(new _o(t.name,c.name,e.file));break;case"name":i.name=rr(c);break;case"pa\
|
|
168
|
-
th":{let l=rr(c);l&&
|
|
168
|
+
th":{let l=rr(c);l&&fe(l)&&(m.delete(c.name),i.path=l);break}case"handler":(i.handler=
|
|
169
169
|
er(c.value,t,o,n,s))&&m.delete(c.name);break;case"authorizer":i.authorizer=_e(c.
|
|
170
170
|
value,t,o,n);break;case"httpErrors":i.httpErrors=x(c.value,t,o,n);break;case"pre\
|
|
171
171
|
ferences":i.preferences=S(c.value,t,o,n);break;case"memory":case"logRetention":case"\
|
|
172
172
|
timeout":i[c.name]=en(c);break;case"cors":i.cors=Lo(c);break;case"listener":i.listener=
|
|
173
173
|
on(c.value,n);break;case"variables":i.variables=$o(c,n);break}if(sn(i))return i;
|
|
174
|
-
n.push(new R([...m],e.file))},"getTypeFromMembers");import{InvalidServicePropertyError as un,isModelDeclaration as ln,getModelMembers as
|
|
175
|
-
getObjectMembers as
|
|
174
|
+
n.push(new R([...m],e.file))},"getTypeFromMembers");import{InvalidServicePropertyError as un,isModelDeclaration as ln,getModelMembers as dn,
|
|
175
|
+
getObjectMembers as fn,getPropertyNumber as yn,getReferenceType as Tn}from"@ez4/common/library";
|
|
176
176
|
import{isModelProperty as gn,isTypeObject as Mn,isTypeReference as Hn}from"@ez4/reflection";
|
|
177
177
|
import{isAnyNumber as lr}from"@ez4/utils";import{IncompleteTypeError as cn,IncorrectTypeError as mn,InvalidTypeError as an}from"@ez4/common/library";var Z=class extends cn{static{p(this,"IncompleteCacheError")}constructor(t,r){super(
|
|
178
178
|
"Incomplete gateway cache",t,r)}},_=class extends an{static{p(this,"InvalidCache\
|
|
179
179
|
TypeError")}constructor(t){super("Invalid gateway cache type",void 0,"Http.Cache",
|
|
180
180
|
t)}},$=class extends mn{constructor(r,o){super("Incorrect gateway cache type",r,
|
|
181
|
-
"Http.Cache",o);this.cacheType=r}static{p(this,"IncorrectCacheTypeError")}};var
|
|
181
|
+
"Http.Cache",o);this.cacheType=r}static{p(this,"IncorrectCacheTypeError")}};var dr=p((e,t,r,o)=>{if(!Hn(e))return ar(e,t,o);let n=Tn(e,r);if(n)return ar(n,t,
|
|
182
182
|
o)},"getHttpCache"),bn=p(e=>lr(e.authorizerTTL),"isValidCache"),ar=p((e,t,r)=>{if(Mn(
|
|
183
|
-
e))return ur(e,t,
|
|
184
|
-
new $(e.name,e.file));return}return ur(e,t,
|
|
183
|
+
e))return ur(e,t,fn(e),r);if(!ln(e)){r.push(new _(t.file));return}if(!ve(e)){r.push(
|
|
184
|
+
new $(e.name,e.file));return}return ur(e,t,dn(e),r)},"getTypeCache"),ur=p((e,t,r,o)=>{
|
|
185
185
|
let n={},s=new Set(["authorizerTTL"]);for(let i of r)if(!(!gn(i)||i.inherited))switch(i.
|
|
186
186
|
name){default:o.push(new un(t.name,i.name,e.file));break;case"authorizerTTL":{let m=yn(
|
|
187
187
|
i);lr(m)&&(n[i.name]=m,s.delete(i.name));break}}if(bn(n))return n;o.push(new Z([
|
|
188
188
|
...s],e.file))},"getTypeFromMembers");import{InvalidServicePropertyError as In,isModelDeclaration as xn,getModelMembers as An,
|
|
189
189
|
getObjectMembers as En,getPropertyNumber as Pn,getReferenceType as Rn}from"@ez4/common/library";
|
|
190
|
-
import{isModelProperty as wn,isTypeObject as On,isTypeReference as
|
|
190
|
+
import{isModelProperty as wn,isTypeObject as On,isTypeReference as jn}from"@ez4/reflection";
|
|
191
191
|
import{isAnyNumber as Tr}from"@ez4/utils";import{IncompleteTypeError as hn,IncorrectTypeError as Sn,InvalidTypeError as vn}from"@ez4/common/library";var L=class extends hn{static{p(this,"IncompleteAccessError")}constructor(t,r){super(
|
|
192
192
|
"Incomplete gateway access",t,r)}},ee=class extends vn{static{p(this,"InvalidAcc\
|
|
193
193
|
essTypeError")}constructor(t){super("Invalid gateway access type",void 0,"Http.A\
|
|
194
194
|
ccess",t)}},re=class extends Sn{constructor(r,o){super("Incorrect gateway access\
|
|
195
195
|
type",r,"Http.Access",o);this.cacheType=r}static{p(this,"IncorrectAccessTypeErr\
|
|
196
|
-
or")}};var gr=p((e,t,r,o)=>{if(!
|
|
197
|
-
o)},"getHttpAccess"),
|
|
196
|
+
or")}};var gr=p((e,t,r,o)=>{if(!jn(e))return fr(e,t,o);let n=Rn(e,r);if(n)return fr(n,t,
|
|
197
|
+
o)},"getHttpAccess"),kn=p(e=>Tr(e.logRetention),"isValidAccess"),fr=p((e,t,r)=>{
|
|
198
198
|
if(On(e))return yr(e,t,En(e),r);if(!xn(e)){r.push(new ee(t.file));return}if(!Ie(
|
|
199
199
|
e)){r.push(new re(e.name,e.file));return}return yr(e,t,An(e),r)},"getTypeAccess"),
|
|
200
200
|
yr=p((e,t,r,o)=>{let n={},s=new Set(["logRetention"]);for(let i of r)if(!(!wn(i)||
|
|
201
201
|
i.inherited))switch(i.name){default:o.push(new In(t.name,i.name,e.file));break;case"\
|
|
202
|
-
logRetention":{let m=Pn(i);Tr(m)&&(n[i.name]=m,s.delete(i.name));break}}if(
|
|
203
|
-
return n;o.push(new L([...s],e.file))},"getTypeFromMembers");import{InvalidServicePropertyError as
|
|
202
|
+
logRetention":{let m=Pn(i);Tr(m)&&(n[i.name]=m,s.delete(i.name));break}}if(kn(n))
|
|
203
|
+
return n;o.push(new L([...s],e.file))},"getTypeFromMembers");import{InvalidServicePropertyError as Dn,isModelDeclaration as Nn,getModelMembers as Fn,
|
|
204
204
|
getObjectMembers as Un,getPropertyBoolean as Bn,getPropertyStringList as Vn,getPropertyNumber as Qn,
|
|
205
205
|
getReferenceType as Jn}from"@ez4/common/library";import{isModelProperty as Gn,isTypeObject as Kn,
|
|
206
|
-
isTypeReference as Yn}from"@ez4/reflection";import{IncompleteTypeError as zn,IncorrectTypeError as Cn,InvalidTypeError as
|
|
207
|
-
"Incomplete HTTP CORS",t,r)}},oe=class extends
|
|
206
|
+
isTypeReference as Yn}from"@ez4/reflection";import{IncompleteTypeError as zn,IncorrectTypeError as Cn,InvalidTypeError as qn}from"@ez4/common/library";var te=class extends zn{static{p(this,"IncompleteCorsError")}constructor(t,r){super(
|
|
207
|
+
"Incomplete HTTP CORS",t,r)}},oe=class extends qn{static{p(this,"InvalidCorsType\
|
|
208
208
|
Error")}constructor(t){super("Invalid HTTP CORS type",void 0,"Http.Cors",t)}},ne=class extends Cn{constructor(r,o){
|
|
209
209
|
super("Incorrect HTTP CORS type",r,"Http.Cors",o);this.fallbackType=r}static{p(this,
|
|
210
210
|
"IncorrectCorsTypeError")}};var br=p((e,t,r,o)=>{if(!Yn(e))return Mr(e,t,o);let n=Jn(e,r);if(n)return Mr(n,t,
|
|
@@ -212,7 +212,7 @@ o)},"getHttpCors"),Wn=p(e=>!!e.allowOrigins?.length,"isValidCors"),Mr=p((e,t,r)=
|
|
|
212
212
|
if(Kn(e))return Hr(e,t,Un(e),r);if(!Nn(e)){r.push(new oe(t.file));return}if(!xe(
|
|
213
213
|
e)){r.push(new ne(e.name,e.file));return}return Hr(e,t,Fn(e),r)},"getTypeCors"),
|
|
214
214
|
Hr=p((e,t,r,o)=>{let n={},s=new Set(["allowOrigins"]);for(let i of r)if(!(!Gn(i)||
|
|
215
|
-
i.inherited))switch(i.name){default:o.push(new
|
|
215
|
+
i.inherited))switch(i.name){default:o.push(new Dn(t.name,i.name,e.file));break;case"\
|
|
216
216
|
allowOrigins":case"allowMethods":case"allowHeaders":case"exposeHeaders":n[i.name]=
|
|
217
217
|
Vn(i);break;case"allowCredentials":n.allowCredentials=Bn(i);break;case"maxAge":n.
|
|
218
218
|
maxAge=Qn(i);break}if(Wn(n))return n;o.push(new te([...s],e.file))},"getTypeFrom\
|
|
@@ -221,10 +221,10 @@ type:y,context:{}},i=new Set(["routes"]),m=n.file;s.name=n.name,n.description&&(
|
|
|
221
221
|
description=n.description);for(let c of Ln(n))if(!(!tp(c)||c.inherited))switch(c.
|
|
222
222
|
name){default:r.push(new rp(s.name,c.name,m));break;case"routes":(s.routes=ir(n,
|
|
223
223
|
c,e,r))&&i.delete(c.name);break;case"name":s.displayName=ep(c);break;case"defaul\
|
|
224
|
-
ts":s.defaults=A(c.value,n,e,r);break;case"cache":s.cache=
|
|
224
|
+
ts":s.defaults=A(c.value,n,e,r);break;case"cache":s.cache=dr(c.value,n,e,r);break;case"\
|
|
225
225
|
access":s.access=gr(c.value,n,e,r);break;case"cors":s.cors=br(c.value,n,e,r);break;case"\
|
|
226
226
|
variables":s.variables=$n(c,r);break;case"services":s.services=_n(c,e,r);break}if(!op(
|
|
227
|
-
s)){r.push(new
|
|
227
|
+
s)){r.push(new d([...i],m));continue}if(t[n.name]){r.push(new Xn(n.name,m));continue}
|
|
228
228
|
np(s,r,m),t[n.name]=s}return{services:t,errors:r}},"getHttpServices"),op=p(e=>!!e.
|
|
229
229
|
name&&!!e.routes&&!!e.context,"isValidService"),np=p((e,t,r)=>{for(let o of e.routes){
|
|
230
230
|
let n=o.handler.provider;if(n?.services){e.services||(e.services={});for(let s in n.
|
|
@@ -232,42 +232,43 @@ services){let i=e.services[s],m=n.services[s];if(!i){e.services[s]=m;continue}i!
|
|
|
232
232
|
m&&t.push(new H(s,r))}}}},"assignProviderServices");import{DuplicateServiceError as pp,InvalidServicePropertyError as sp,isExternalDeclaration as ip,
|
|
233
233
|
getModelMembers as cp,getPropertyString as Sr,getReferenceName as mp}from"@ez4/common/library";
|
|
234
234
|
import{isModelProperty as ap,isTypeReference as up}from"@ez4/reflection";var vr=p(e=>{let t={},r=[];for(let o in e){let n=e[o];if(!h(n)||ip(n))continue;let s={
|
|
235
|
-
type:
|
|
235
|
+
type:f},i=new Set(["reference","project","routes"]),m=n.file;s.name=n.name,n.description&&
|
|
236
236
|
(s.description=n.description);for(let c of cp(n,!0))if(ap(c))switch(c.name){default:
|
|
237
237
|
c.inherited||r.push(new sp(s.name,c.name,m));break;case"reference":c.inherited&&
|
|
238
238
|
up(c.value)&&(s[c.name]=mp(c.value),i.delete(c.name));break;case"project":!c.inherited&&
|
|
239
239
|
(s.project=Sr(c))&&i.delete(c.name);break;case"routes":c.inherited&&(s.routes=cr(
|
|
240
240
|
n,c,e,r))&&i.delete(c.name);break;case"name":c.inherited&&(s.displayName=Sr(c,e));
|
|
241
241
|
break;case"defaults":c.inherited&&(s.defaults=A(c.value,n,e,r));break}if(!lp(s)){
|
|
242
|
-
r.push(new
|
|
242
|
+
r.push(new d([...i],m));continue}if(t[n.name]){r.push(new pp(n.name,m));continue}
|
|
243
243
|
t[n.name]=s}return{services:t,errors:r}},"getHttpImports"),lp=p(e=>!!e.name&&!!e.
|
|
244
244
|
reference&&!!e.project&&!!e.routes,"isValidImport");var Ir=p(e=>b(e)?e.name:null,"getLinkedService"),xr=p(e=>h(e)?e.name:null,"getLi\
|
|
245
|
-
nkedImport");var Er=!1,Hm=p(()=>{Er||(
|
|
246
|
-
LinkedService":Ir}),Ar(
|
|
245
|
+
nkedImport");var Er=!1,Hm=p(()=>{Er||(dp(),fp(),Ar(y,{"metadata:getServices":hr,"metadata:get\
|
|
246
|
+
LinkedService":Ir}),Ar(f,{"metadata:getServices":vr,"metadata:getLinkedService":xr}),
|
|
247
247
|
Er=!0)},"registerTriggers");var Sm=p(e=>{let t={},r=e.defaults?.preferences?.namingStyle;for(let o of e.routes){
|
|
248
248
|
if(!o.name)continue;let[n,s]=o.path.split(" ",2);t[o.name]={namingStyle:o.preferences?.
|
|
249
|
-
namingStyle??r,responseSchema:o.handler.response.
|
|
250
|
-
|
|
249
|
+
namingStyle??r,bodySchema:o.handler.request?.body,responseSchema:o.handler.response.
|
|
250
|
+
body,querySchema:o.handler.request?.query,method:n,path:s}}return t},"getClientO\
|
|
251
|
+
perations");import{IncorrectTypeError as yp,InvalidTypeError as Tp}from"@ez4/common/library";var E=class extends Tp{static{p(this,"InvalidDefaultsTypeError")}constructor(t){
|
|
251
252
|
super("Invalid defaults",void 0,"Http.Defaults",t)}},P=class extends yp{constructor(r,o){
|
|
252
253
|
super("Incorrect defaults",r,"Http.Defaults",o);this.defaultsType=r}static{p(this,
|
|
253
254
|
"IncorrectDefaultsTypeError")}};import{IncorrectTypeError as gp,InvalidTypeError as Mp}from"@ez4/common/library";var v=class extends Mp{static{p(this,"InvalidPreferencesTypeError")}constructor(t){
|
|
254
255
|
super("Invalid preferences",void 0,"Http.Preferences",t)}},I=class extends gp{constructor(r,o){
|
|
255
256
|
super("Incorrect preferences",r,"Http.Preferences",o);this.preferencesType=r}static{
|
|
256
|
-
p(this,"IncorrectPreferencesTypeError")}};export{
|
|
257
|
+
p(this,"IncorrectPreferencesTypeError")}};export{f as ImportType,L as IncompleteAccessError,w as IncompleteAuthorizerError,
|
|
257
258
|
Z as IncompleteCacheError,te as IncompleteCorsError,Y as IncompleteHandlerError,
|
|
258
|
-
X as IncompleteProviderError,R as IncompleteRouteError,
|
|
259
|
+
X as IncompleteProviderError,R as IncompleteRouteError,d as IncompleteServiceError,
|
|
259
260
|
re as IncorrectAccessTypeError,F as IncorrectBodyTypeError,$ as IncorrectCacheTypeError,
|
|
260
|
-
ne as IncorrectCorsTypeError,P as IncorrectDefaultsTypeError,
|
|
261
|
+
ne as IncorrectCorsTypeError,P as IncorrectDefaultsTypeError,q as IncorrectHeadersTypeError,
|
|
261
262
|
z as IncorrectIdentityTypeError,J as IncorrectParameterTypeError,I as IncorrectPreferencesTypeError,
|
|
262
|
-
K as IncorrectQueryTypeError,V as IncorrectRequestTypeError,
|
|
263
|
+
K as IncorrectQueryTypeError,V as IncorrectRequestTypeError,j as IncorrectResponseTypeError,
|
|
263
264
|
ee as InvalidAccessTypeError,N as InvalidBodyTypeError,_ as InvalidCacheTypeError,
|
|
264
265
|
oe as InvalidCorsTypeError,E as InvalidDefaultsTypeError,C as InvalidHeadersTypeError,
|
|
265
|
-
|
|
266
|
+
k as InvalidIdentityTypeError,Q as InvalidParameterTypeError,v as InvalidPreferencesTypeError,
|
|
266
267
|
W as InvalidProviderTypeError,G as InvalidQueryTypeError,B as InvalidRequestTypeError,
|
|
267
268
|
O as InvalidResponseTypeError,g as InvalidRouteErrorTypeError,H as ServiceCollisionError,
|
|
268
269
|
y as ServiceType,Sm as getClientOperations,Xe as getHttpAuthRequest,Ue as getHttpAuthResponse,
|
|
269
|
-
_e as getHttpAuthorizer,U as getHttpBody,
|
|
270
|
-
Ze as getHttpHandlerRequest,Be as getHttpHandlerResponse,
|
|
270
|
+
_e as getHttpAuthorizer,U as getHttpBody,dr as getHttpCache,br as getHttpCors,er as getHttpHandler,
|
|
271
|
+
Ze as getHttpHandlerRequest,Be as getHttpHandlerResponse,D as getHttpHeaders,M as getHttpIdentity,
|
|
271
272
|
ir as getHttpLocalRoutes,Je as getHttpParameters,Ke as getHttpQuery,cr as getHttpRemoteRoutes,
|
|
272
273
|
hr as getHttpServices,bp as isHttpImport,vp as isHttpService,Hm as registerTriggers};
|
|
273
274
|
//# sourceMappingURL=library.mjs.map
|
package/dist/metadata/body.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AllType, SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
2
|
import type { ArraySchema, ObjectSchema, UnionSchema } from '@ez4/schema/library';
|
|
3
3
|
type TypeParent = TypeObject | TypeModel | TypeIntersection;
|
|
4
|
-
export declare const getHttpBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema |
|
|
4
|
+
export declare const getHttpBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | import("@ez4/schema").BooleanSchema | import("@ez4/schema").NumberSchema | import("@ez4/schema").StringSchema | UnionSchema | ArraySchema | undefined;
|
|
5
5
|
export {};
|
|
@@ -19,7 +19,7 @@ export type Client<T extends Http.Service> = {
|
|
|
19
19
|
export type ClientRequest = RequestOptions & {
|
|
20
20
|
headers?: Record<string, string>;
|
|
21
21
|
parameters?: Record<string, string>;
|
|
22
|
-
query?: Record<string,
|
|
22
|
+
query?: Record<string, unknown>;
|
|
23
23
|
body?: string | AnyObject;
|
|
24
24
|
};
|
|
25
25
|
/**
|
package/dist/utils/body.d.ts
CHANGED
|
@@ -2,7 +2,3 @@ import type { AnySchema } from '@ez4/schema';
|
|
|
2
2
|
import type { Http } from '../services/contract';
|
|
3
3
|
export declare const getRequestBody: <T extends Http.JsonBody | Http.RawBody>(input: T | undefined, schema: AnySchema, preferences?: Http.Preferences | null) => Promise<T>;
|
|
4
4
|
export declare const getResponseBody: (body: unknown, schema: AnySchema, preferences?: Http.Preferences) => unknown;
|
|
5
|
-
export declare const prepareBodyRequest: (body: unknown) => {
|
|
6
|
-
body: string;
|
|
7
|
-
json: boolean;
|
|
8
|
-
};
|
package/dist/utils/client.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ArraySchema, NamingStyle, ObjectSchema, ScalarSchema, UnionSchema } from '@ez4/schema';
|
|
2
2
|
import type { ClientRequest, ClientResponse } from '../services/client';
|
|
3
|
-
export
|
|
3
|
+
export type ClientRequestUrl = ClientRequest & {
|
|
4
|
+
querySchema?: ObjectSchema;
|
|
5
|
+
namingStyle?: NamingStyle;
|
|
6
|
+
};
|
|
7
|
+
export declare const getClientRequestUrl: (host: string, path: string, request: ClientRequestUrl) => string;
|
|
4
8
|
export type SendClientRequest = ClientRequest & {
|
|
5
|
-
|
|
9
|
+
bodySchema?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
|
|
10
|
+
responseSchema?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
|
|
6
11
|
namingStyle?: NamingStyle;
|
|
7
12
|
};
|
|
8
13
|
export declare const sendClientRequest: (url: string, method: string, request: SendClientRequest) => Promise<ClientResponse>;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { ObjectSchema } from '@ez4/schema';
|
|
2
2
|
import type { Http } from '../services/contract';
|
|
3
3
|
export declare const getPathParameters: <T extends Http.PathParameters>(input: T, schema: ObjectSchema) => Promise<T>;
|
|
4
|
-
export declare const preparePathParameters: (path: string, parameters: Record<string, string>) => string;
|
package/dist/utils/query.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ObjectSchema } from '@ez4/schema';
|
|
1
|
+
import type { AnySchema, ObjectSchema } from '@ez4/schema';
|
|
2
2
|
import type { Http } from '../services/contract';
|
|
3
3
|
export declare const getQueryStrings: <T extends Http.QueryStrings>(input: T, schema: ObjectSchema, preferences?: Http.Preferences | null) => Promise<T>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const serializeQueryStrings: <T extends Http.QueryStrings>(query: T, schema?: ObjectSchema) => string | undefined;
|
|
5
|
+
export declare const serializeQueryStringValue: (value: unknown, schema?: AnySchema) => string | undefined;
|
package/dist/utils.cjs
CHANGED
|
@@ -1,48 +1,53 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof t=="object"||typeof t=="function")for(let n of
|
|
3
|
-
|
|
4
|
-
getIdentity:()=>
|
|
5
|
-
getRequestBody:()=>
|
|
6
|
-
|
|
7
|
-
"
|
|
1
|
+
"use strict";var b=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var s=(e,t)=>b(e,"name",{value:t,configurable:!0});var J=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},k=(e,t,r,o)=>{if(t&&
|
|
2
|
+
typeof t=="object"||typeof t=="function")for(let n of V(t))!I.call(e,n)&&n!==r&&
|
|
3
|
+
b(e,n,{get:()=>t[n],enumerable:!(o=Q(t,n))||o.enumerable});return e};var F=e=>k(b({},"__esModule",{value:!0}),e);var nt={};J(nt,{getClientRequestUrl:()=>G,getHeaders:()=>tt,getHttpException:()=>q,
|
|
4
|
+
getIdentity:()=>et,getJsonError:()=>_,getPathParameters:()=>Z,getQueryStrings:()=>D,
|
|
5
|
+
getRequestBody:()=>rt,getResponseBody:()=>ot,sendClientRequest:()=>K,serializeQueryStringValue:()=>E,
|
|
6
|
+
serializeQueryStrings:()=>C});module.exports=F(nt);var p=require("@ez4/transform"),O=require("@ez4/schema");var U=require("@ez4/gateway"),H=require("@ez4/transform"),y=require("@ez4/validator"),
|
|
7
|
+
T=require("@ez4/schema"),w=require("@ez4/utils");var D=s(async(e,t,r)=>{let o=r?.namingStyle,n=(0,H.createTransformContext)({convert:!0,
|
|
8
|
+
inputStyle:o}),i=(0,H.transform)(e,t,n),f=(0,y.createValidatorContext)({property:"\
|
|
9
|
+
$query",pathStyle:o}),c=await(0,y.validate)(i,t,f);if(c.length){let m=(0,y.getUniqueErrorMessages)(
|
|
10
|
+
c);throw new U.HttpBadRequestError("Malformed query strings.",m)}return i},"getQ\
|
|
11
|
+
ueryStrings"),C=s((e,t)=>{let r=[];for(let o in e){let n=t&&(0,T.getSchemaProperty)(
|
|
12
|
+
t,o),i=E(e[o],n);i&&r.push(`${o}=${encodeURIComponent(i)}`)}if(r.length)return r.
|
|
13
|
+
join("&")},"serializeQueryStrings"),E=s((e,t)=>{if(!(0,w.isNullish)(e))return e instanceof
|
|
14
|
+
Date?e.toISOString():e instanceof Array&&(!t||!(0,T.isArraySchema)(t)||!t.definitions?.
|
|
15
|
+
encoded)?e.map(n=>E(n,t)).filter(n=>(0,w.isNotNullish)(n)).join(","):e instanceof
|
|
16
|
+
Object?Buffer.from(JSON.stringify(e)).toString("base64"):`${e}`},"serializeQuery\
|
|
17
|
+
StringValue");var a=require("@ez4/gateway");var _=s(({status:e,message:t,details:r})=>({status:e,body:{message:t,details:r}}),
|
|
18
|
+
"getJsonError"),q=s((e,t,r)=>{switch(e){case 400:return new a.HttpBadRequestError(
|
|
8
19
|
t,r);case 401:return new a.HttpUnauthorizedError(t,r);case 403:return new a.HttpForbiddenError(
|
|
9
20
|
t,r);case 404:return new a.HttpNotFoundError(t,r);case 415:return new a.HttpUnsupportedMediaTypeError(
|
|
10
21
|
t,r);case 422:return new a.HttpUnprocessableEntityError(t,r);default:return new a.HttpError(
|
|
11
|
-
e,t,r)}},"getHttpException");var
|
|
12
|
-
o=
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
length){let n=(0,l.getUniqueErrorMessages)(o);throw new A.HttpBadRequestError("M\
|
|
43
|
-
alformed request headers.",n)}return r},"getHeaders");var g=require("@ez4/validator"),z=require("@ez4/gateway");var tt=s(async(e,t)=>{let r=await(0,g.validate)(e,t,(0,g.createValidatorContext)(
|
|
44
|
-
{property:"$identity"}));if(r.length){let o=(0,g.getUniqueErrorMessages)(r);throw new z.HttpBadRequestError(
|
|
45
|
-
"Malformed authorizer identity.",o)}return e},"getIdentity");0&&(module.exports={getClientRequestUrl,getHeaders,getHttpException,getIdentity,
|
|
46
|
-
getJsonError,getPathParameters,getQueryStrings,getRequestBody,getResponseBody,prepareBodyRequest,
|
|
47
|
-
preparePathParameters,prepareQueryStrings,sendClientRequest});
|
|
22
|
+
e,t,r)}},"getHttpException");var G=s((e,t,r)=>{let{parameters:o,query:n,querySchema:i,namingStyle:f}=r,c=o?L(
|
|
23
|
+
t,o):t,m=n&&W(n,i,f),l=[e];return c&&l.push(c),m&&l.push("?",m),l.join("")},"get\
|
|
24
|
+
ClientRequestUrl"),K=s(async(e,t,r)=>{let{headers:o,body:n,bodySchema:i,responseSchema:f,
|
|
25
|
+
namingStyle:c,timeout:m=20}=r;console.log(r);let l=n?X(n,i,c):void 0,v=new AbortController,
|
|
26
|
+
$=setTimeout(()=>v?.abort("Request timed out"),m*1e3),x=await fetch(e,{signal:v?.
|
|
27
|
+
signal,body:l?.body,method:t,headers:{...o,...l?.json&&{"content-type":"applicat\
|
|
28
|
+
ion/json"}}});if(clearTimeout($),!x.ok){let P=await x.json();throw q(x.status,P.
|
|
29
|
+
message,P.details)}let A=await x.text();return{status:x.status,...A&&{body:Y(A,f,
|
|
30
|
+
c)}}},"sendClientRequest"),L=s((e,t)=>e.replaceAll(/\{(\w+)\}/g,(r,o)=>o in t?`${t[o]}`:
|
|
31
|
+
`{${o}}`),"getPathParameters"),W=s((e,t,r)=>{if(!t)return C(e);let o=(0,p.createTransformContext)(
|
|
32
|
+
{inputStyle:r,convert:!1}),n=(0,p.transform)(e,t,o);return C(n,t)},"getQueryStri\
|
|
33
|
+
ngs"),X=s((e,t,r)=>{if(!t||(0,O.isScalarSchema)(t))return{body:e.toString(),json:!1};
|
|
34
|
+
let o=(0,p.createTransformContext)({outputStyle:r,convert:!1}),n=(0,p.transform)(
|
|
35
|
+
e,t,o);return{body:JSON.stringify(n),json:!0}},"getRequestBody"),Y=s((e,t,r)=>{if(!t||
|
|
36
|
+
(0,O.isScalarSchema)(t))return e;let o=JSON.parse(e),n=(0,p.createTransformContext)(
|
|
37
|
+
{inputStyle:r,convert:!1});return(0,p.transform)(o,t,n)},"getResponseBody");var R=require("@ez4/transform"),d=require("@ez4/validator"),z=require("@ez4/gateway");var Z=s(async(e,t)=>{let r=(0,R.transform)(e,t,(0,R.createTransformContext)({convert:!1})),
|
|
38
|
+
o=await(0,d.validate)(r,t,(0,d.createValidatorContext)({property:"$path"}));if(o.
|
|
39
|
+
length){let n=(0,d.getUniqueErrorMessages)(o);throw new z.HttpBadRequestError("M\
|
|
40
|
+
alformed path parameters.",n)}return r},"getPathParameters");var j=require("@ez4/transform"),u=require("@ez4/validator"),B=require("@ez4/gateway");var tt=s(async(e,t)=>{let r=(0,j.transform)(e,t,(0,j.createTransformContext)({convert:!1})),
|
|
41
|
+
o=await(0,u.validate)(r,t,(0,u.createValidatorContext)({property:"$header"}));if(o.
|
|
42
|
+
length){let n=(0,u.getUniqueErrorMessages)(o);throw new B.HttpBadRequestError("M\
|
|
43
|
+
alformed request headers.",n)}return r},"getHeaders");var S=require("@ez4/validator"),N=require("@ez4/gateway");var et=s(async(e,t)=>{let r=await(0,S.validate)(e,t,(0,S.createValidatorContext)(
|
|
44
|
+
{property:"$identity"}));if(r.length){let o=(0,S.getUniqueErrorMessages)(r);throw new N.HttpBadRequestError(
|
|
45
|
+
"Malformed authorizer identity.",o)}return e},"getIdentity");var g=require("@ez4/transform"),h=require("@ez4/validator"),M=require("@ez4/gateway");var rt=s(async(e,t,r)=>{let o=r?.namingStyle,n=(0,h.createValidatorContext)({property:"\
|
|
46
|
+
$body",inputStyle:o}),i=await(0,h.validate)(e,t,n);if(i.length){let m=(0,h.getUniqueErrorMessages)(
|
|
47
|
+
i);throw new M.HttpBadRequestError("Malformed body payload.",m)}let f=(0,g.createTransformContext)(
|
|
48
|
+
{convert:!1,inputStyle:o});return(0,g.transform)(e,t,f)},"getRequestBody"),ot=s(
|
|
49
|
+
(e,t,r)=>{let o=r?.namingStyle,n=(0,g.createTransformContext)({convert:!1,outputStyle:o});
|
|
50
|
+
return(0,g.transform)(e,t,n)},"getResponseBody");0&&(module.exports={getClientRequestUrl,getHeaders,getHttpException,getIdentity,
|
|
51
|
+
getJsonError,getPathParameters,getQueryStrings,getRequestBody,getResponseBody,sendClientRequest,
|
|
52
|
+
serializeQueryStringValue,serializeQueryStrings});
|
|
48
53
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.mjs
CHANGED
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
var
|
|
2
|
-
transform as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
var C=Object.defineProperty;var s=(e,t)=>C(e,"name",{value:t,configurable:!0});import{createTransformContext as y,transform as d}from"@ez4/transform";import{isScalarSchema as b}from"@ez4/schema";import{HttpBadRequestError as R}from"@ez4/gateway";import{createTransformContext as j,
|
|
2
|
+
transform as E}from"@ez4/transform";import{validate as q,createValidatorContext as O,
|
|
3
|
+
getUniqueErrorMessages as v}from"@ez4/validator";import{getSchemaProperty as A,isArraySchema as P}from"@ez4/schema";
|
|
4
|
+
import{isNotNullish as U,isNullish as z}from"@ez4/utils";var ht=s(async(e,t,r)=>{let o=r?.namingStyle,n=j({convert:!0,inputStyle:o}),a=E(
|
|
5
|
+
e,t,n),m=O({property:"$query",pathStyle:o}),i=await q(a,t,m);if(i.length){let c=v(
|
|
6
|
+
i);throw new R("Malformed query strings.",c)}return a},"getQueryStrings"),l=s((e,t)=>{
|
|
7
|
+
let r=[];for(let o in e){let n=t&&A(t,o),a=h(e[o],n);a&&r.push(`${o}=${encodeURIComponent(
|
|
8
|
+
a)}`)}if(r.length)return r.join("&")},"serializeQueryStrings"),h=s((e,t)=>{if(!z(
|
|
9
|
+
e))return e instanceof Date?e.toISOString():e instanceof Array&&(!t||!P(t)||!t.definitions?.
|
|
10
|
+
encoded)?e.map(n=>h(n,t)).filter(n=>U(n)).join(","):e instanceof Object?Buffer.from(
|
|
11
|
+
JSON.stringify(e)).toString("base64"):`${e}`},"serializeQueryStringValue");import{HttpBadRequestError as B,HttpUnauthorizedError as N,HttpForbiddenError as M,
|
|
12
|
+
HttpNotFoundError as $,HttpUnsupportedMediaTypeError as Q,HttpUnprocessableEntityError as V,
|
|
13
|
+
HttpError as I}from"@ez4/gateway";var Tt=s(({status:e,message:t,details:r})=>({status:e,body:{message:t,details:r}}),
|
|
14
|
+
"getJsonError"),x=s((e,t,r)=>{switch(e){case 400:return new B(t,r);case 401:return new N(
|
|
15
|
+
t,r);case 403:return new M(t,r);case 404:return new $(t,r);case 415:return new Q(
|
|
16
|
+
t,r);case 422:return new V(t,r);default:return new I(e,t,r)}},"getHttpException");var Ot=s((e,t,r)=>{let{parameters:o,query:n,querySchema:a,namingStyle:m}=r,i=o?J(
|
|
17
|
+
t,o):t,c=n&&k(n,a,m),p=[e];return i&&p.push(i),c&&p.push("?",c),p.join("")},"get\
|
|
18
|
+
ClientRequestUrl"),vt=s(async(e,t,r)=>{let{headers:o,body:n,bodySchema:a,responseSchema:m,
|
|
19
|
+
namingStyle:i,timeout:c=20}=r;console.log(r);let p=n?F(n,a,i):void 0,u=new AbortController,
|
|
20
|
+
w=setTimeout(()=>u?.abort("Request timed out"),c*1e3),f=await fetch(e,{signal:u?.
|
|
21
|
+
signal,body:p?.body,method:t,headers:{...o,...p?.json&&{"content-type":"applicat\
|
|
22
|
+
ion/json"}}});if(clearTimeout(w),!f.ok){let g=await f.json();throw x(f.status,g.
|
|
23
|
+
message,g.details)}let S=await f.text();return{status:f.status,...S&&{body:D(S,m,
|
|
24
|
+
i)}}},"sendClientRequest"),J=s((e,t)=>e.replaceAll(/\{(\w+)\}/g,(r,o)=>o in t?`${t[o]}`:
|
|
25
|
+
`{${o}}`),"getPathParameters"),k=s((e,t,r)=>{if(!t)return l(e);let o=y({inputStyle:r,
|
|
26
|
+
convert:!1}),n=d(e,t,o);return l(n,t)},"getQueryStrings"),F=s((e,t,r)=>{if(!t||b(
|
|
27
|
+
t))return{body:e.toString(),json:!1};let o=y({outputStyle:r,convert:!1}),n=d(e,t,
|
|
28
|
+
o);return{body:JSON.stringify(n),json:!0}},"getRequestBody"),D=s((e,t,r)=>{if(!t||
|
|
29
|
+
b(t))return e;let o=JSON.parse(e),n=y({inputStyle:r,convert:!1});return d(o,t,n)},
|
|
30
|
+
"getResponseBody");import{createTransformContext as _,transform as G}from"@ez4/transform";import{validate as K,
|
|
31
|
+
getUniqueErrorMessages as L,createValidatorContext as W}from"@ez4/validator";import{
|
|
32
|
+
HttpBadRequestError as X}from"@ez4/gateway";var Nt=s(async(e,t)=>{let r=G(e,t,_({convert:!1})),o=await K(r,t,W({property:"$p\
|
|
33
|
+
ath"}));if(o.length){let n=L(o);throw new X("Malformed path parameters.",n)}return r},
|
|
34
|
+
"getPathParameters");import{createTransformContext as Y,transform as Z}from"@ez4/transform";import{validate as tt,
|
|
35
|
+
createValidatorContext as et,getUniqueErrorMessages as rt}from"@ez4/validator";import{
|
|
36
|
+
HttpBadRequestError as ot}from"@ez4/gateway";var Jt=s(async(e,t)=>{let r=Z(e,t,Y({convert:!1})),o=await tt(r,t,et({property:"\
|
|
37
|
+
$header"}));if(o.length){let n=rt(o);throw new ot("Malformed request headers.",n)}
|
|
38
|
+
return r},"getHeaders");import{validate as nt,createValidatorContext as st,getUniqueErrorMessages as at}from"@ez4/validator";
|
|
39
|
+
import{HttpBadRequestError as it}from"@ez4/gateway";var Gt=s(async(e,t)=>{let r=await nt(e,t,st({property:"$identity"}));if(r.length){
|
|
40
|
+
let o=at(r);throw new it("Malformed authorizer identity.",o)}return e},"getIdent\
|
|
41
|
+
ity");import{createTransformContext as H,transform as T}from"@ez4/transform";import{validate as ct,
|
|
42
|
+
createValidatorContext as mt,getUniqueErrorMessages as pt}from"@ez4/validator";import{
|
|
43
|
+
HttpBadRequestError as ft}from"@ez4/gateway";var Zt=s(async(e,t,r)=>{let o=r?.namingStyle,n=mt({property:"$body",inputStyle:o}),
|
|
44
|
+
a=await ct(e,t,n);if(a.length){let c=pt(a);throw new ft("Malformed body payload.",
|
|
45
|
+
c)}let m=H({convert:!1,inputStyle:o});return T(e,t,m)},"getRequestBody"),te=s((e,t,r)=>{
|
|
46
|
+
let o=r?.namingStyle,n=H({convert:!1,outputStyle:o});return T(e,t,n)},"getRespon\
|
|
47
|
+
seBody");export{Ot as getClientRequestUrl,Jt as getHeaders,x as getHttpException,Gt as getIdentity,
|
|
48
|
+
Tt as getJsonError,Nt as getPathParameters,ht as getQueryStrings,Zt as getRequestBody,
|
|
49
|
+
te as getResponseBody,vt as sendClientRequest,h as serializeQueryStringValue,l as serializeQueryStrings};
|
|
46
50
|
//# sourceMappingURL=utils.mjs.map
|