@ez4/gateway 0.35.1 → 0.37.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.
Files changed (142) hide show
  1. package/README.md +120 -2
  2. package/dist/client/authorization.d.ts +1 -1
  3. package/dist/client/operations.d.ts +1 -2
  4. package/dist/errors/auth/authorizer.d.ts +4 -0
  5. package/dist/errors/{identity.d.ts → auth/identity.d.ts} +4 -2
  6. package/dist/errors/body.d.ts +4 -2
  7. package/dist/errors/defaults.d.ts +4 -2
  8. package/dist/errors/headers.d.ts +4 -2
  9. package/dist/errors/{authorization.d.ts → http/authorization.d.ts} +4 -2
  10. package/dist/errors/{cache.d.ts → http/cache.d.ts} +4 -2
  11. package/dist/errors/{cors.d.ts → http/cors.d.ts} +5 -3
  12. package/dist/errors/parameters.d.ts +9 -3
  13. package/dist/errors/preferences.d.ts +4 -2
  14. package/dist/errors/query.d.ts +4 -2
  15. package/dist/errors/ws/event.d.ts +10 -0
  16. package/dist/errors/{authorizer.d.ts → ws/target.d.ts} +1 -1
  17. package/dist/library.cjs +464 -310
  18. package/dist/library.d.ts +17 -14
  19. package/dist/library.mjs +445 -293
  20. package/dist/main.cjs +15 -14
  21. package/dist/main.d.ts +5 -3
  22. package/dist/main.mjs +8 -6
  23. package/dist/metadata/auth/handler.d.ts +4 -0
  24. package/dist/metadata/auth/identity.d.ts +6 -0
  25. package/dist/metadata/auth/request.d.ts +4 -0
  26. package/dist/metadata/auth/response.d.ts +4 -0
  27. package/dist/metadata/auth/types.d.ts +20 -0
  28. package/dist/metadata/body.d.ts +4 -3
  29. package/dist/metadata/headers.d.ts +3 -2
  30. package/dist/metadata/http/access.d.ts +4 -0
  31. package/dist/metadata/http/authorization.d.ts +4 -0
  32. package/dist/metadata/http/cache.d.ts +4 -0
  33. package/dist/metadata/http/cors.d.ts +4 -0
  34. package/dist/metadata/http/defaults.d.ts +4 -0
  35. package/dist/metadata/http/errors.d.ts +4 -0
  36. package/dist/metadata/http/handler.d.ts +4 -0
  37. package/dist/metadata/http/import.d.ts +7 -0
  38. package/dist/metadata/http/request.d.ts +4 -0
  39. package/dist/metadata/http/response.d.ts +4 -0
  40. package/dist/metadata/http/routes.d.ts +5 -0
  41. package/dist/metadata/http/service.d.ts +7 -0
  42. package/dist/metadata/http/types.d.ts +117 -0
  43. package/dist/metadata/parameters.d.ts +3 -2
  44. package/dist/metadata/preferences.d.ts +4 -3
  45. package/dist/metadata/provider.d.ts +4 -3
  46. package/dist/metadata/query.d.ts +3 -2
  47. package/dist/metadata/types.d.ts +4 -0
  48. package/dist/metadata/utils/name.d.ts +2 -0
  49. package/dist/metadata/utils/path.d.ts +2 -0
  50. package/dist/metadata/utils/provider.d.ts +4 -0
  51. package/dist/metadata/utils/schema.d.ts +3 -0
  52. package/dist/metadata/utils/validator.d.ts +5 -0
  53. package/dist/metadata/ws/connection.d.ts +4 -0
  54. package/dist/metadata/ws/defaults.d.ts +5 -0
  55. package/dist/metadata/ws/event.d.ts +4 -0
  56. package/dist/metadata/ws/handlers.d.ts +4 -0
  57. package/dist/metadata/ws/message.d.ts +4 -0
  58. package/dist/metadata/ws/request.d.ts +4 -0
  59. package/dist/metadata/ws/response.d.ts +4 -0
  60. package/dist/metadata/ws/service.d.ts +7 -0
  61. package/dist/metadata/ws/types.d.ts +83 -0
  62. package/dist/services/auth/cache.d.ts +9 -0
  63. package/dist/services/auth/handler.d.ts +9 -0
  64. package/dist/services/auth/identity.d.ts +5 -0
  65. package/dist/services/auth/incoming.d.ts +22 -0
  66. package/dist/services/auth/provider.d.ts +11 -0
  67. package/dist/services/auth/request.d.ts +20 -0
  68. package/dist/services/auth/response.d.ts +10 -0
  69. package/dist/services/body.d.ts +13 -0
  70. package/dist/services/defaults.d.ts +7 -16
  71. package/dist/services/errors.d.ts +6 -0
  72. package/dist/services/headers.d.ts +10 -0
  73. package/dist/services/{client.d.ts → http/client.d.ts} +3 -3
  74. package/dist/services/{contract.d.ts → http/contract.d.ts} +45 -31
  75. package/dist/services/http/defaults.d.ts +17 -0
  76. package/dist/services/http/errors.d.ts +6 -0
  77. package/dist/services/http/handler.d.ts +10 -0
  78. package/dist/services/http/incoming.d.ts +30 -0
  79. package/dist/services/http/listener.d.ts +9 -0
  80. package/dist/services/http/path.d.ts +2 -0
  81. package/dist/services/http/request.d.ts +30 -0
  82. package/dist/services/http/response.d.ts +19 -0
  83. package/dist/services/http/route.d.ts +45 -0
  84. package/dist/services/{utils.d.ts → http/utils.d.ts} +13 -5
  85. package/dist/services/parameters.d.ts +5 -0
  86. package/dist/services/preferences.d.ts +2 -2
  87. package/dist/services/query.d.ts +5 -0
  88. package/dist/services/target.d.ts +27 -0
  89. package/dist/services/ws/client.d.ts +19 -0
  90. package/dist/services/ws/connect.d.ts +23 -0
  91. package/dist/services/ws/contract.d.ts +110 -0
  92. package/dist/services/ws/defaults.d.ts +13 -0
  93. package/dist/services/ws/disconnect.d.ts +17 -0
  94. package/dist/services/ws/event.d.ts +20 -0
  95. package/dist/services/ws/handler.d.ts +10 -0
  96. package/dist/services/ws/incoming.d.ts +19 -0
  97. package/dist/services/ws/listener.d.ts +9 -0
  98. package/dist/services/ws/message.d.ts +17 -0
  99. package/dist/services/ws/request.d.ts +15 -0
  100. package/dist/services/ws/response.d.ts +10 -0
  101. package/dist/services/ws/utils.d.ts +11 -0
  102. package/dist/utils/body.d.ts +4 -3
  103. package/dist/utils/client.d.ts +4 -4
  104. package/dist/utils/errors.d.ts +1 -0
  105. package/dist/utils/headers.d.ts +3 -2
  106. package/dist/utils/identity.d.ts +3 -2
  107. package/dist/utils/parameters.d.ts +3 -2
  108. package/dist/utils/query.d.ts +3 -2
  109. package/dist/utils/validation.d.ts +2 -0
  110. package/dist/utils.cjs +62 -55
  111. package/dist/utils.d.ts +2 -1
  112. package/dist/utils.mjs +54 -52
  113. package/package.json +8 -8
  114. package/dist/metadata/access.d.ts +0 -3
  115. package/dist/metadata/authorization.d.ts +0 -3
  116. package/dist/metadata/authorizer.d.ts +0 -3
  117. package/dist/metadata/cache.d.ts +0 -3
  118. package/dist/metadata/cors.d.ts +0 -3
  119. package/dist/metadata/defaults.d.ts +0 -3
  120. package/dist/metadata/errors.d.ts +0 -4
  121. package/dist/metadata/handler.d.ts +0 -3
  122. package/dist/metadata/identity.d.ts +0 -5
  123. package/dist/metadata/import.d.ts +0 -6
  124. package/dist/metadata/request.d.ts +0 -4
  125. package/dist/metadata/response.d.ts +0 -4
  126. package/dist/metadata/route.d.ts +0 -4
  127. package/dist/metadata/schema.d.ts +0 -3
  128. package/dist/metadata/service.d.ts +0 -6
  129. package/dist/metadata/utils.d.ts +0 -24
  130. package/dist/services/cache.d.ts +0 -9
  131. package/dist/services/common.d.ts +0 -147
  132. package/dist/services/route.d.ts +0 -56
  133. package/dist/types/common.d.ts +0 -95
  134. package/dist/types/import.d.ts +0 -14
  135. package/dist/types/service.d.ts +0 -14
  136. /package/dist/errors/{access.d.ts → http/access.d.ts} +0 -0
  137. /package/dist/errors/{provider.d.ts → http/provider.d.ts} +0 -0
  138. /package/dist/errors/{route.d.ts → http/route.d.ts} +0 -0
  139. /package/dist/services/{access.d.ts → http/access.d.ts} +0 -0
  140. /package/dist/services/{authorization.d.ts → http/authorization.d.ts} +0 -0
  141. /package/dist/services/{cors.d.ts → http/cors.d.ts} +0 -0
  142. /package/dist/services/{provider.d.ts → http/provider.d.ts} +0 -0
package/dist/utils.mjs CHANGED
@@ -1,54 +1,56 @@
1
- var P=Object.defineProperty;var s=(e,t)=>P(e,"name",{value:t,configurable:!0});import{HttpBadRequestError as v}from"@ez4/gateway";import{createTransformContext as x,
2
- transform as H}from"@ez4/transform";import{validate as O,createValidatorContext as U,
3
- getUniqueErrorMessages as z}from"@ez4/validator";import{base64Encode as A,isNotNullish as B,
4
- isNullish as M}from"@ez4/utils";import{getSchemaProperty as N,isArraySchema as $}from"@ez4/schema";var T=s((e,t,r)=>{if(!t)return g(e);let o=x({inputStyle:r?.namingStyle,convert:!1}),
5
- n=H(e,t,o);return g(n,t)},"prepareQueryStrings"),xt=s(async(e,t,r)=>{let o=r?.namingStyle,
6
- n=x({convert:!0,inputStyle:o}),a=H(e,t,n),p=U({property:"$query",pathStyle:o}),c=await O(
7
- a,t,p);if(c.length){let i=z(c);throw new v("Malformed query strings.",i)}return a},
8
- "getQueryStrings"),g=s((e,t)=>{let r=[];for(let o in e){let n=t&&N(t,o),a=w(e[o],
9
- n);a&&r.push(`${o}=${encodeURIComponent(a)}`)}if(r.length)return r.join("&")},"s\
10
- erializeQueryStrings"),w=s((e,t)=>{if(!M(e))return e instanceof Date?e.toISOString():
11
- e instanceof Array&&(!t||!$(t)||!t.definitions?.encoded)?e.map(n=>w(n,t)).filter(
12
- n=>B(n)).join(","):e instanceof Object?A(JSON.stringify(e)):`${e}`},"serializeQu\
13
- eryStringValue");import{createTransformContext as u,transform as f}from"@ez4/transform";import{validate as Q,
1
+ var P=Object.defineProperty;var a=(e,t)=>P(e,"name",{value:t,configurable:!0});import{createTransformContext as x,transform as H}from"@ez4/transform";import{validate as V,
2
+ createValidatorContext as z,getUniqueErrorMessages as O}from"@ez4/validator";import{
3
+ base64Encode as A,isNotNullish as U,isNullish as B}from"@ez4/utils";import{getSchemaProperty as N,
4
+ isArraySchema as $}from"@ez4/schema";import{HttpBadRequestError as M}from"@ez4/gateway";var C=a((e,t,r)=>{if(!t)return g(e);let o=x({inputStyle:r?.namingStyle,convert:!1}),
5
+ n=H(e,t,o);return g(n,t)},"prepareQueryStrings"),vt=a(async(e,t,r,o)=>{let n=r?.
6
+ namingStyle,s=x({convert:!0,inputStyle:n}),i=H(e,t,s),m=z({property:"$query",pathStyle:n,
7
+ onCustomValidation:o}),p=await V(i,t,m);if(p.length){let l=O(p);throw new M("Mal\
8
+ formed query strings.",l)}return i},"resolveQueryStrings"),g=a((e,t)=>{let r=[];
9
+ for(let o in e){let n=t&&N(t,o),s=v(e[o],n);s&&r.push(`${o}=${encodeURIComponent(
10
+ s)}`)}if(r.length)return r.join("&")},"serializeQueryStrings"),v=a((e,t)=>{if(!B(
11
+ e))return e instanceof Date?e.toISOString():e instanceof Array&&(!t||!$(t)||!t.definitions?.
12
+ encoded)?e.map(n=>v(n,t)).filter(n=>U(n)).join(","):e instanceof Object?A(JSON.stringify(
13
+ e)):`${e}`},"serializeQueryStringValue");import{createTransformContext as f,transform as y}from"@ez4/transform";import{validate as Q,
14
14
  createValidatorContext as I,getUniqueErrorMessages as J}from"@ez4/validator";import{
15
- isScalarSchema as q,NamingStyle as V}from"@ez4/schema";import{HttpBadRequestError as k}from"@ez4/gateway";var b=s((e,t,r)=>{if(!t||q(t))return{body:e.toString(),json:!1};let o=u({outputStyle:r?.
16
- namingStyle,convert:!1}),n=f(e,t,o);return{body:JSON.stringify(n),json:!0}},"pre\
17
- pareRequestBody"),Ct=s(async(e,t,r)=>{let o=r?.namingStyle,n=I({property:"$body",
18
- inputStyle:o}),a=await Q(e,t,n);if(a.length){let i=J(a);throw new k("Malformed b\
19
- ody payload.",i)}let p=u({convert:!1,inputStyle:o});return f(e,t,p)},"getRequest\
20
- Body"),R=s((e,t,r)=>{if(!t||q(t))return e;let o=JSON.parse(e),n=u({outputStyle:V.
21
- Preserve,inputStyle:r?.namingStyle,convert:!1});return f(o,t,n)},"prepareRespons\
22
- eBody"),Et=s((e,t,r)=>{let o=r?.namingStyle,n=u({convert:!1,outputStyle:o});return f(
23
- e,t,n)},"getResponseBody");import{createTransformContext as F,transform as D}from"@ez4/transform";import{validate as _,
24
- getUniqueErrorMessages as G,createValidatorContext as K}from"@ez4/validator";import{
25
- HttpBadRequestError as L}from"@ez4/gateway";var C=s((e,t)=>e.replaceAll(/\{(\w+)\}/g,(r,o)=>o in t?`${t[o]}`:`{${o}}`),"prep\
26
- arePathParameters"),zt=s(async(e,t)=>{let r=D(e,t,F({convert:!1})),o=await _(r,t,
27
- K({property:"$path"}));if(o.length){let n=G(o);throw new L("Malformed path param\
28
- eters.",n)}return r},"getPathParameters");import{HttpBadRequestError as W,HttpUnauthorizedError as X,HttpForbiddenError as Y,
29
- HttpNotFoundError as Z,HttpUnsupportedMediaTypeError as tt,HttpUnprocessableEntityError as et,
30
- HttpError as rt}from"@ez4/gateway";var Nt=s(({status:e,message:t,details:r})=>({status:e,body:{message:t,details:r}}),
31
- "getJsonError"),E=s((e,t,r)=>{switch(e){case 400:return new W(t,r);case 401:return new X(
32
- t,r);case 403:return new Y(t,r);case 404:return new Z(t,r);case 415:return new tt(
33
- t,r);case 422:return new et(t,r);default:return new rt(e,t,r)}},"getHttpExceptio\
34
- n");var Ft=s((e,t,r)=>{let{parameters:o,query:n,querySchema:a,namingStyle:p}=r,c=o?C(
35
- t,o):t,i=n&&T(n,a,{namingStyle:p}),m=[e];return c&&m.push(c),i&&m.push("?",i),m.
36
- join("")},"getClientRequestUrl"),Dt=s(async(e,t,r)=>{let{authorization:o,headers:n,
37
- body:a,bodySchema:p,responseSchema:c,namingStyle:i,timeout:m=20}=r,d=a?b(a,p,{namingStyle:i}):
38
- void 0,l=new AbortController,j=setTimeout(()=>l?.abort("Request timed out"),m*1e3),
39
- y=await fetch(e,{signal:l?.signal,body:d?.body,method:t,headers:{...n,...o&&{[o.
40
- header]:o.value},...d?.json&&{"content-type":"application/json"}}});if(clearTimeout(
41
- j),!y.ok){let h=await y.json();throw E(y.status,h.message,h.details)}let S=await y.
42
- text();return{status:y.status,...S&&{body:R(S,c,{namingStyle:i})}}},"sendClientR\
43
- equest");import{createTransformContext as ot,transform as nt}from"@ez4/transform";import{
44
- validate as st,createValidatorContext as at,getUniqueErrorMessages as it}from"@ez4/validator";
45
- import{HttpBadRequestError as ct}from"@ez4/gateway";var Xt=s(async(e,t)=>{let r=nt(e,t,ot({convert:!1})),o=await st(r,t,at({property:"\
46
- $header"}));if(o.length){let n=it(o);throw new ct("Malformed request headers.",n)}
47
- return r},"getHeaders");import{validate as pt,createValidatorContext as mt,getUniqueErrorMessages as yt}from"@ez4/validator";
48
- import{HttpBadRequestError as ut}from"@ez4/gateway";var re=s(async(e,t)=>{let r=await pt(e,t,mt({property:"$identity"}));if(r.length){
49
- let o=yt(r);throw new ut("Malformed authorizer identity.",o)}return e},"getIdent\
50
- ity");export{Ft as getClientRequestUrl,Xt as getHeaders,E as getHttpException,re as getIdentity,
51
- Nt as getJsonError,zt as getPathParameters,xt as getQueryStrings,Ct as getRequestBody,
52
- Et as getResponseBody,C as preparePathParameters,T as prepareQueryStrings,b as prepareRequestBody,
53
- R as prepareResponseBody,Dt as sendClientRequest};
15
+ isScalarSchema as w,NamingStyle as k}from"@ez4/schema";import{isAnyArray as F,isAnyObject as D}from"@ez4/utils";
16
+ import{HttpBadRequestError as _}from"@ez4/gateway";var T=a((e,t,r)=>{if(!t||w(t))return{body:e.toString(),json:!1};let o=f({outputStyle:r?.
17
+ namingStyle,convert:!1}),n=y(e,t,o);return{body:JSON.stringify(n),json:!0}},"pre\
18
+ pareRequestBody"),Pt=a(async(e,t,r,o)=>{let n=r?.namingStyle,s=f({convert:!1,inputStyle:n}),
19
+ m=I({onCustomValidation:a((c,d)=>D(c)||F(c)?o?.(y(c,d.schema,s),d):o?.(c,d),"use\
20
+ CustomValidation"),property:"$body",inputStyle:n}),p=await Q(e,t,m);if(p.length){
21
+ let c=J(p);throw new _("Malformed body payload.",c)}return y(e,t,s)},"resolveReq\
22
+ uestBody"),b=a((e,t,r)=>{if(!t||w(t))return e;let o=JSON.parse(e),n=f({outputStyle:k.
23
+ Preserve,inputStyle:r?.namingStyle,convert:!1});return y(o,t,n)},"prepareRespons\
24
+ eBody"),Vt=a((e,t,r)=>{let o=r?.namingStyle,n=f({convert:!1,outputStyle:o});return y(
25
+ e,t,n)},"resolveResponseBody");import{createTransformContext as G,transform as K}from"@ez4/transform";import{validate as L,
26
+ getUniqueErrorMessages as W,createValidatorContext as X}from"@ez4/validator";import{
27
+ HttpBadRequestError as Y}from"@ez4/gateway";var q=a((e,t)=>e.replaceAll(/\{(\w+)\}/g,(r,o)=>o in t?`${t[o]}`:`{${o}}`),"prep\
28
+ arePathParameters"),Nt=a(async(e,t,r)=>{let o=K(e,t,G({convert:!1})),n=X({property:"\
29
+ $path",onCustomValidation:r}),s=await L(o,t,n);if(s.length){let i=W(s);throw new Y(
30
+ "Malformed path parameters.",i)}return o},"resolvePathParameters");import{HttpBadRequestError as Z,HttpUnauthorizedError as tt,HttpForbiddenError as et,
31
+ HttpNotFoundError as rt,HttpUnsupportedMediaTypeError as ot,HttpUnprocessableEntityError as nt,
32
+ HttpError as at}from"@ez4/gateway";var It=a(({status:e,message:t,details:r})=>({status:e,body:{type:"error",message:t,
33
+ details:r}}),"getJsonError"),R=a((e,t,r)=>{switch(e){case 400:return new Z(t,r);case 401:
34
+ return new tt(t,r);case 403:return new et(t,r);case 404:return new rt(t,r);case 415:
35
+ return new ot(t,r);case 422:return new nt(t,r);default:return new at(e,t,r)}},"g\
36
+ etHttpException");var Kt=a((e,t,r)=>{let{parameters:o,query:n,querySchema:s,namingStyle:i}=r,m=o?q(
37
+ t,o):t,p=n&&C(n,s,{namingStyle:i}),l=[e];return m&&l.push(m),p&&l.push("?",p),l.
38
+ join("")},"getClientRequestUrl"),Lt=a(async(e,t,r)=>{let{authorization:o,headers:n,
39
+ body:s,bodySchema:i,responseSchema:m,namingStyle:p,timeout:l=20}=r,c=s?T(s,i,{namingStyle:p}):
40
+ void 0,d=new AbortController,j=setTimeout(()=>d?.abort("Request timed out"),l*1e3),
41
+ u=await fetch(e,{signal:d?.signal,body:c?.body,method:t,headers:{...n,...o&&{[o.
42
+ header]:o.value},...c?.json&&{"content-type":"application/json"}}});if(clearTimeout(
43
+ j),!u.ok){let h=await u.json();throw R(u.status,h.message,h.details)}let S=await u.
44
+ text();return{status:u.status,...S&&{body:b(S,m,{namingStyle:p})}}},"sendClientR\
45
+ equest");import{createTransformContext as st,transform as it}from"@ez4/transform";import{
46
+ validate as pt,createValidatorContext as ct,getUniqueErrorMessages as mt}from"@ez4/validator";
47
+ import{HttpBadRequestError as lt}from"@ez4/gateway";var ee=a(async(e,t,r)=>{let o=it(e,t,st({convert:!1})),n=ct({property:"$header",
48
+ onCustomValidation:r}),s=await pt(o,t,n);if(s.length){let i=mt(s);throw new lt("\
49
+ Malformed request headers.",i)}return o},"resolveHeaders");import{validate as dt,createValidatorContext as ut,getUniqueErrorMessages as yt}from"@ez4/validator";
50
+ import{HttpBadRequestError as ft}from"@ez4/gateway";var se=a(async(e,t,r)=>{let o=ut({property:"$identity",onCustomValidation:r}),n=await dt(
51
+ e,t,o);if(n.length){let s=yt(n);throw new ft("Malformed authorizer identity.",s)}
52
+ return e},"resolveIdentity");var E=a(e=>`@${e}`,"getValidatorName");var de=a(async(e,t,r)=>{let o=t[E(r)];o&&await o.validate(e)},"resolveValidation");export{Kt as getClientRequestUrl,R as getHttpException,It as getJsonError,q as preparePathParameters,
53
+ C as prepareQueryStrings,T as prepareRequestBody,b as prepareResponseBody,ee as resolveHeaders,
54
+ se as resolveIdentity,Nt as resolvePathParameters,vt as resolveQueryStrings,Pt as resolveRequestBody,
55
+ Vt as resolveResponseBody,de as resolveValidation,Lt as sendClientRequest};
54
56
  //# sourceMappingURL=utils.mjs.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ez4/gateway",
3
3
  "description": "EZ4: Components to build gateway services",
4
- "version": "0.35.1",
4
+ "version": "0.37.0",
5
5
  "author": "Silas B.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -51,12 +51,12 @@
51
51
  "live:publish": "npm run build && npm publish --access public"
52
52
  },
53
53
  "dependencies": {
54
- "@ez4/common": "^0.35.0",
55
- "@ez4/project": "^0.35.0",
56
- "@ez4/reflection": "^0.35.0",
57
- "@ez4/schema": "^0.35.0",
58
- "@ez4/transform": "^0.35.0",
59
- "@ez4/utils": "^0.35.0",
60
- "@ez4/validator": "^0.35.0"
54
+ "@ez4/common": "^0.37.0",
55
+ "@ez4/project": "^0.37.0",
56
+ "@ez4/reflection": "^0.37.0",
57
+ "@ez4/schema": "^0.37.0",
58
+ "@ez4/transform": "^0.37.0",
59
+ "@ez4/utils": "^0.37.0",
60
+ "@ez4/validator": "^0.37.0"
61
61
  }
62
62
  }
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpAccess } from '../types/common';
3
- export declare const getHttpAccess: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpAccess | undefined;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpAuthorization } from '../types/common';
3
- export declare const getHttpAuthorization: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpAuthorization | undefined;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpAuthorizer } from '../types/common';
3
- export declare const getHttpAuthorizer: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpAuthorizer | undefined;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpCache } from '../types/common';
3
- export declare const getHttpCache: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpCache | undefined;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpCors } from '../types/common';
3
- export declare const getHttpCors: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpCors | undefined;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpDefaults } from '../types/common';
3
- export declare const getHttpDefaults: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpDefaults | undefined;
@@ -1,4 +0,0 @@
1
- import type { AllType, ModelProperty, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpErrors } from '../types/common';
3
- export declare const getHttpErrors: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpErrors | undefined;
4
- export declare const getErrorClasses: (member: ModelProperty, errorCode: number, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpErrors;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpHandler } from '../types/common';
3
- export declare const getHttpHandler: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[], external: boolean) => HttpHandler | undefined;
@@ -1,5 +0,0 @@
1
- import type { AllType, SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
2
- import type { ObjectSchema, UnionSchema } from '@ez4/schema/library';
3
- type TypeParent = TypeObject | TypeModel | TypeIntersection;
4
- export declare const getHttpIdentity: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | UnionSchema | undefined;
5
- export {};
@@ -1,6 +0,0 @@
1
- import type { SourceMap } from '@ez4/reflection';
2
- import type { HttpImport } from '../types/import';
3
- export declare const getHttpImports: (reflection: SourceMap) => {
4
- services: Record<string, HttpImport>;
5
- errors: Error[];
6
- };
@@ -1,4 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpAuthRequest, HttpRequest } from '../types/common';
3
- export declare const getHttpAuthRequest: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => (HttpAuthRequest & HttpRequest) | undefined;
4
- export declare const getHttpHandlerRequest: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => (HttpAuthRequest & HttpRequest) | undefined;
@@ -1,4 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpAuthResponse, HttpResponse } from '../types/common';
3
- export declare const getHttpAuthResponse: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpAuthResponse | undefined;
4
- export declare const getHttpHandlerResponse: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpResponse | undefined;
@@ -1,4 +0,0 @@
1
- import type { ModelProperty, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpRoute } from '../types/common';
3
- export declare const getHttpLocalRoutes: (parent: TypeModel, member: ModelProperty, reflection: SourceMap, errorList: Error[]) => HttpRoute[] | undefined;
4
- export declare const getHttpRemoteRoutes: (parent: TypeModel, member: ModelProperty, reflection: SourceMap, errorList: Error[]) => HttpRoute[] | undefined;
@@ -1,3 +0,0 @@
1
- import type { SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
2
- export declare const getSchemaFromIntersection: (type: TypeObject | TypeModel | TypeIntersection, reflection: SourceMap) => import("@ez4/schema").ObjectSchema | undefined;
3
- export declare const getSchemaFromObject: (type: TypeObject | TypeModel | TypeIntersection, reflection: SourceMap) => import("@ez4/schema").ObjectSchema | undefined;
@@ -1,6 +0,0 @@
1
- import type { SourceMap } from '@ez4/reflection';
2
- import type { HttpService } from '../types/service';
3
- export declare const getHttpServices: (reflection: SourceMap) => {
4
- services: Record<string, HttpService>;
5
- errors: Error[];
6
- };
@@ -1,24 +0,0 @@
1
- import type { AllType, TypeCallback, TypeClass, TypeFunction, TypeModel } from '@ez4/reflection';
2
- import type { HttpPath } from '../types/common';
3
- export declare const isHttpPath: (path: string) => path is HttpPath;
4
- export declare const isHttpService: (type: AllType) => type is TypeClass;
5
- export declare const isHttpImport: (type: AllType) => type is TypeClass;
6
- export declare const isHttpProvider: (type: AllType) => type is TypeModel;
7
- export declare const isHttpRoute: (type: AllType) => type is TypeModel;
8
- export declare const isHttpAuthorizerRequest: (type: TypeModel) => boolean;
9
- export declare const isHttpHandlerRequest: (type: TypeModel) => boolean;
10
- export declare const isHttpAuthorizerResponse: (type: TypeModel) => boolean;
11
- export declare const isHttpHandlerResponse: (type: TypeModel) => boolean;
12
- export declare const isHttpDefaults: (type: TypeModel) => boolean;
13
- export declare const isHttpAuthorization: (type: TypeModel) => boolean;
14
- export declare const isHttpPreferences: (type: TypeModel) => boolean;
15
- export declare const isHttpHeaders: (type: TypeModel) => boolean;
16
- export declare const isHttpIdentity: (type: TypeModel) => boolean;
17
- export declare const isHttpQuery: (type: TypeModel) => boolean;
18
- export declare const isHttpParameters: (type: TypeModel) => boolean;
19
- export declare const isJsonBody: (type: TypeModel) => boolean;
20
- export declare const isHttpCache: (type: TypeModel) => boolean;
21
- export declare const isHttpAccess: (type: TypeModel) => boolean;
22
- export declare const isHttpCors: (type: TypeModel) => boolean;
23
- export declare const isHttpAuthorizer: (type: AllType) => type is TypeCallback | TypeFunction;
24
- export declare const isHttpHandler: (type: AllType) => type is TypeCallback | TypeFunction;
@@ -1,9 +0,0 @@
1
- /**
2
- * HTTP cache configuration.
3
- */
4
- export interface HttpCache {
5
- /**
6
- * Default TTL (in seconds) for cached authorizations.
7
- */
8
- readonly authorizerTTL: number;
9
- }
@@ -1,147 +0,0 @@
1
- import type { Service } from '@ez4/common';
2
- import type { HttpProvider } from './provider';
3
- import type { Http } from './contract';
4
- /**
5
- * Request headers.
6
- */
7
- export interface HttpHeaders {
8
- }
9
- /**
10
- * Request Identity payload.
11
- */
12
- export interface HttpIdentity {
13
- }
14
- /**
15
- * Request path parameters.
16
- */
17
- export interface HttpPathParameters {
18
- }
19
- /**
20
- * Request query strings.
21
- */
22
- export interface HttpQueryStrings {
23
- }
24
- /**
25
- * Json body payload.
26
- */
27
- export interface HttpJsonBody {
28
- }
29
- /**
30
- * Raw body payload.
31
- */
32
- export type HttpRawBody = string;
33
- /**
34
- * Authorizer request.
35
- */
36
- export interface HttpAuthRequest {
37
- /**
38
- * Expected HTTP headers.
39
- */
40
- readonly headers?: HttpHeaders;
41
- /**
42
- * Expected HTTP path parameters.
43
- */
44
- readonly parameters?: HttpPathParameters;
45
- /**
46
- * Expected HTTP query strings.
47
- */
48
- readonly query?: HttpQueryStrings;
49
- }
50
- /**
51
- * Authorizer response.
52
- */
53
- export interface HttpAuthResponse {
54
- /**
55
- * Authorization identity.
56
- */
57
- readonly identity?: HttpIdentity;
58
- }
59
- /**
60
- * HTTP request.
61
- */
62
- export interface HttpRequest {
63
- /**
64
- * Expected identity.
65
- */
66
- readonly identity?: HttpIdentity;
67
- /**
68
- * Expected HTTP headers.
69
- */
70
- readonly headers?: HttpHeaders;
71
- /**
72
- * Expected HTTP path parameters.
73
- */
74
- readonly parameters?: HttpPathParameters;
75
- /**
76
- * Expected HTTP query strings.
77
- */
78
- readonly query?: HttpQueryStrings;
79
- /**
80
- * Expected HTTP body payload.
81
- */
82
- readonly body?: HttpJsonBody | HttpRawBody;
83
- }
84
- /**
85
- * HTTP response.
86
- */
87
- export interface HttpResponse {
88
- /**
89
- * HTTP status code.
90
- */
91
- readonly status: number;
92
- /**
93
- * HTTP headers.
94
- */
95
- readonly headers?: HttpHeaders;
96
- /**
97
- * HTTP body payload.
98
- */
99
- readonly body?: HttpJsonBody | HttpRawBody;
100
- }
101
- /**
102
- * Incoming request.
103
- */
104
- export type HttpIncoming<T extends HttpRequest | HttpAuthRequest> = T & {
105
- /**
106
- * Request tracking Id.
107
- */
108
- readonly requestId: string;
109
- /**
110
- * Determines whether request is base64 encoded or not.
111
- */
112
- readonly encoded?: boolean;
113
- /**
114
- * Request timestamp.
115
- */
116
- readonly timestamp: Date;
117
- /**
118
- * Request method.
119
- */
120
- readonly method: string;
121
- /**
122
- * Request path.
123
- */
124
- readonly path: string;
125
- /**
126
- * Raw body data (when provided in the request).
127
- */
128
- readonly data?: string;
129
- };
130
- /**
131
- * Request listener.
132
- */
133
- export type HttpListener<T extends HttpRequest | HttpAuthRequest> = (event: Service.AnyEvent<HttpIncoming<T>>, context: Service.Context<Http.Service | HttpProvider>) => Promise<void> | void;
134
- /**
135
- * Request authorizer.
136
- */
137
- export type HttpAuthorizer<T extends HttpAuthRequest> = (request: HttpIncoming<T> | T, context: Service.Context<Http.Service | HttpProvider>) => Promise<HttpAuthResponse> | HttpAuthResponse;
138
- /**
139
- * Request handler.
140
- */
141
- export type HttpHandler<T extends HttpRequest> = (request: HttpIncoming<T> | T, context: Service.Context<Http.Service | HttpProvider>) => Promise<HttpResponse> | HttpResponse;
142
- /**
143
- * HTTP errors.
144
- */
145
- export type HttpErrors = {
146
- [code: number]: readonly Error[];
147
- };
@@ -1,56 +0,0 @@
1
- import type { LinkedVariables } from '@ez4/project/library';
2
- import type { HttpPath } from '../types/common';
3
- import type { HttpAuthorizer, HttpAuthRequest, HttpErrors, HttpHandler, HttpListener, HttpRequest } from './common';
4
- /**
5
- * HTTP route.
6
- */
7
- export interface HttpRoute<T extends HttpRequest, U extends HttpAuthRequest> {
8
- /**
9
- * Route name.
10
- */
11
- readonly name?: string;
12
- /**
13
- * Route path.
14
- */
15
- readonly path: HttpPath;
16
- /**
17
- * Route listener.
18
- */
19
- readonly listener?: HttpListener<T | U>;
20
- /**
21
- * Route authorizer.
22
- */
23
- readonly authorizer?: HttpAuthorizer<U>;
24
- /**
25
- * Route handler.
26
- */
27
- readonly handler: HttpHandler<T>;
28
- /**
29
- * Map status codes and errors for all known exceptions.
30
- */
31
- readonly httpErrors?: HttpErrors;
32
- /**
33
- * Default log retention (in days) for the handlers.
34
- */
35
- readonly logRetention?: number;
36
- /**
37
- * Variables associated to the route.
38
- */
39
- readonly variables?: LinkedVariables;
40
- /**
41
- * Max execution time (in seconds) for the route.
42
- */
43
- readonly timeout?: number;
44
- /**
45
- * Amount of memory available for the handler.
46
- */
47
- readonly memory?: number;
48
- /**
49
- * Determines whether or not CORS is enabled for the route.
50
- */
51
- readonly cors?: boolean;
52
- /**
53
- * Determines whether or not the route is disabled.
54
- */
55
- readonly disabled?: boolean;
56
- }
@@ -1,95 +0,0 @@
1
- import type { ArraySchema, NamingStyle, ObjectSchema, ScalarSchema, UnionSchema } from '@ez4/schema';
2
- import type { LinkedServices, LinkedVariables } from '@ez4/project/library';
3
- import type { ServiceListener } from '@ez4/common/library';
4
- import type { AuthorizationType } from '../services/authorization';
5
- export type HttpVerb = 'ANY' | 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
6
- export type HttpPath = `${HttpVerb} /${string}`;
7
- export type HttpPreferences = {
8
- namingStyle?: NamingStyle;
9
- };
10
- export type HttpAuthorization = {
11
- type: AuthorizationType;
12
- header: string;
13
- value: string;
14
- };
15
- export type HttpAuthRequest = {
16
- headers?: ObjectSchema;
17
- parameters?: ObjectSchema;
18
- query?: ObjectSchema;
19
- };
20
- export type HttpAuthResponse = {
21
- identity?: ObjectSchema | UnionSchema;
22
- };
23
- export type HttpRequest = {
24
- identity?: ObjectSchema | UnionSchema;
25
- headers?: ObjectSchema;
26
- parameters?: ObjectSchema;
27
- query?: ObjectSchema;
28
- body?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
29
- };
30
- export type HttpResponse = {
31
- status: number | number[];
32
- headers?: ObjectSchema;
33
- body?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
34
- };
35
- export type HttpHandler = {
36
- name: string;
37
- file: string;
38
- module?: string;
39
- description?: string;
40
- response: HttpResponse;
41
- request?: HttpRequest;
42
- provider?: HttpProvider;
43
- };
44
- export type HttpAuthorizer = {
45
- name: string;
46
- module?: string;
47
- file: string;
48
- description?: string;
49
- response?: HttpAuthResponse;
50
- request?: HttpAuthRequest;
51
- };
52
- export type HttpErrors = {
53
- [name: string]: number;
54
- };
55
- export type HttpRoute = {
56
- name?: string;
57
- path: HttpPath;
58
- handler: HttpHandler;
59
- listener?: ServiceListener;
60
- authorizer?: HttpAuthorizer;
61
- variables?: LinkedVariables;
62
- httpErrors?: HttpErrors;
63
- preferences?: HttpPreferences;
64
- logRetention?: number;
65
- timeout?: number;
66
- memory?: number;
67
- cors?: boolean;
68
- disabled?: boolean;
69
- };
70
- export type HttpDefaults = {
71
- listener?: ServiceListener;
72
- httpErrors?: HttpErrors;
73
- preferences?: HttpPreferences;
74
- logRetention?: number;
75
- timeout?: number;
76
- memory?: number;
77
- };
78
- export type HttpCache = {
79
- authorizerTTL?: number;
80
- };
81
- export type HttpAccess = {
82
- logRetention: number;
83
- };
84
- export type HttpCors = {
85
- allowOrigins: string[];
86
- allowMethods?: string[];
87
- allowCredentials?: boolean;
88
- exposeHeaders?: string[];
89
- allowHeaders?: string[];
90
- maxAge?: number;
91
- };
92
- export type HttpProvider = {
93
- variables?: LinkedVariables;
94
- services?: LinkedServices;
95
- };
@@ -1,14 +0,0 @@
1
- import type { ServiceMetadata } from '@ez4/project/library';
2
- import type { HttpRoute, HttpDefaults, HttpAuthorization } from './common';
3
- export declare const ImportType = "@ez4/import:http";
4
- export type HttpImport = ServiceMetadata & {
5
- type: typeof ImportType;
6
- reference: string;
7
- project: string;
8
- displayName?: string;
9
- description?: string;
10
- defaults?: HttpDefaults;
11
- authorization?: HttpAuthorization;
12
- routes: HttpRoute[];
13
- };
14
- export declare const isHttpImport: (service: ServiceMetadata) => service is HttpImport;
@@ -1,14 +0,0 @@
1
- import type { ServiceMetadata } from '@ez4/project/library';
2
- import type { HttpRoute, HttpCors, HttpDefaults, HttpCache, HttpAccess } from './common';
3
- export declare const ServiceType = "@ez4/http";
4
- export type HttpService = ServiceMetadata & {
5
- type: typeof ServiceType;
6
- displayName?: string;
7
- description?: string;
8
- defaults?: HttpDefaults;
9
- routes: HttpRoute[];
10
- cache?: HttpCache;
11
- access?: HttpAccess;
12
- cors?: HttpCors;
13
- };
14
- export declare const isHttpService: (service: ServiceMetadata) => service is HttpService;
File without changes
File without changes
File without changes
File without changes