@ez4/gateway 0.35.1 → 0.36.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 (145) hide show
  1. package/README.md +121 -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/{authorization.d.ts → http/authorization.d.ts} +4 -2
  7. package/dist/errors/{cache.d.ts → http/cache.d.ts} +4 -2
  8. package/dist/errors/{cors.d.ts → http/cors.d.ts} +5 -3
  9. package/dist/errors/{body.d.ts → web/body.d.ts} +4 -2
  10. package/dist/errors/{defaults.d.ts → web/defaults.d.ts} +4 -2
  11. package/dist/errors/{headers.d.ts → web/headers.d.ts} +4 -2
  12. package/dist/errors/web/parameters.d.ts +14 -0
  13. package/dist/errors/{preferences.d.ts → web/preferences.d.ts} +4 -2
  14. package/dist/errors/{query.d.ts → web/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 +460 -311
  18. package/dist/library.d.ts +26 -23
  19. package/dist/library.mjs +436 -293
  20. package/dist/main.cjs +17 -17
  21. package/dist/main.d.ts +5 -3
  22. package/dist/main.mjs +8 -8
  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 +17 -0
  28. package/dist/metadata/http/access.d.ts +4 -0
  29. package/dist/metadata/http/authorization.d.ts +4 -0
  30. package/dist/metadata/http/cache.d.ts +4 -0
  31. package/dist/metadata/http/cors.d.ts +4 -0
  32. package/dist/metadata/http/defaults.d.ts +4 -0
  33. package/dist/metadata/{errors.d.ts → http/errors.d.ts} +2 -2
  34. package/dist/metadata/http/handler.d.ts +4 -0
  35. package/dist/metadata/http/import.d.ts +7 -0
  36. package/dist/metadata/http/provider.d.ts +4 -0
  37. package/dist/metadata/http/request.d.ts +4 -0
  38. package/dist/metadata/http/response.d.ts +4 -0
  39. package/dist/metadata/{route.d.ts → http/routes.d.ts} +3 -2
  40. package/dist/metadata/http/service.d.ts +7 -0
  41. package/dist/{types/common.d.ts → metadata/http/types.d.ts} +33 -22
  42. package/dist/metadata/utils/path.d.ts +2 -0
  43. package/dist/metadata/utils/type.d.ts +1 -0
  44. package/dist/metadata/web/body.d.ts +6 -0
  45. package/dist/metadata/web/headers.d.ts +5 -0
  46. package/dist/metadata/web/parameters.d.ts +5 -0
  47. package/dist/metadata/web/preferences.d.ts +4 -0
  48. package/dist/metadata/web/query.d.ts +5 -0
  49. package/dist/metadata/web/types.d.ts +4 -0
  50. package/dist/metadata/ws/connection.d.ts +4 -0
  51. package/dist/metadata/ws/defaults.d.ts +5 -0
  52. package/dist/metadata/ws/event.d.ts +4 -0
  53. package/dist/metadata/ws/handlers.d.ts +5 -0
  54. package/dist/metadata/ws/message.d.ts +4 -0
  55. package/dist/metadata/ws/request.d.ts +4 -0
  56. package/dist/metadata/ws/response.d.ts +4 -0
  57. package/dist/metadata/ws/service.d.ts +7 -0
  58. package/dist/metadata/ws/types.d.ts +72 -0
  59. package/dist/services/auth/cache.d.ts +9 -0
  60. package/dist/services/auth/handler.d.ts +9 -0
  61. package/dist/services/auth/identity.d.ts +5 -0
  62. package/dist/services/auth/incoming.d.ts +22 -0
  63. package/dist/services/auth/provider.d.ts +11 -0
  64. package/dist/services/auth/request.d.ts +20 -0
  65. package/dist/services/auth/response.d.ts +10 -0
  66. package/dist/services/{client.d.ts → http/client.d.ts} +3 -3
  67. package/dist/services/{contract.d.ts → http/contract.d.ts} +42 -30
  68. package/dist/services/http/defaults.d.ts +17 -0
  69. package/dist/services/http/errors.d.ts +6 -0
  70. package/dist/services/http/handler.d.ts +10 -0
  71. package/dist/services/http/incoming.d.ts +30 -0
  72. package/dist/services/http/listener.d.ts +9 -0
  73. package/dist/services/http/path.d.ts +2 -0
  74. package/dist/services/http/request.d.ts +30 -0
  75. package/dist/services/http/response.d.ts +19 -0
  76. package/dist/services/http/route.d.ts +45 -0
  77. package/dist/services/{utils.d.ts → http/utils.d.ts} +13 -5
  78. package/dist/services/web/body.d.ts +13 -0
  79. package/dist/services/web/defaults.d.ts +22 -0
  80. package/dist/services/web/headers.d.ts +10 -0
  81. package/dist/services/web/parameters.d.ts +5 -0
  82. package/dist/services/{preferences.d.ts → web/preferences.d.ts} +2 -2
  83. package/dist/services/web/query.d.ts +5 -0
  84. package/dist/services/web/target.d.ts +27 -0
  85. package/dist/services/ws/client.d.ts +19 -0
  86. package/dist/services/ws/connect.d.ts +23 -0
  87. package/dist/services/ws/contract.d.ts +108 -0
  88. package/dist/services/ws/defaults.d.ts +13 -0
  89. package/dist/services/ws/disconnect.d.ts +17 -0
  90. package/dist/services/ws/event.d.ts +20 -0
  91. package/dist/services/ws/handler.d.ts +10 -0
  92. package/dist/services/ws/incoming.d.ts +19 -0
  93. package/dist/services/ws/listener.d.ts +9 -0
  94. package/dist/services/ws/message.d.ts +17 -0
  95. package/dist/services/ws/request.d.ts +15 -0
  96. package/dist/services/ws/response.d.ts +10 -0
  97. package/dist/services/ws/utils.d.ts +11 -0
  98. package/dist/utils/body.d.ts +1 -1
  99. package/dist/utils/client.d.ts +4 -4
  100. package/dist/utils/errors.d.ts +1 -0
  101. package/dist/utils/headers.d.ts +1 -1
  102. package/dist/utils/identity.d.ts +1 -1
  103. package/dist/utils/parameters.d.ts +1 -1
  104. package/dist/utils/query.d.ts +1 -1
  105. package/dist/utils.cjs +2 -2
  106. package/dist/utils.mjs +5 -5
  107. package/package.json +8 -8
  108. package/dist/errors/parameters.d.ts +0 -8
  109. package/dist/metadata/access.d.ts +0 -3
  110. package/dist/metadata/authorization.d.ts +0 -3
  111. package/dist/metadata/authorizer.d.ts +0 -3
  112. package/dist/metadata/body.d.ts +0 -5
  113. package/dist/metadata/cache.d.ts +0 -3
  114. package/dist/metadata/cors.d.ts +0 -3
  115. package/dist/metadata/defaults.d.ts +0 -3
  116. package/dist/metadata/handler.d.ts +0 -3
  117. package/dist/metadata/headers.d.ts +0 -4
  118. package/dist/metadata/identity.d.ts +0 -5
  119. package/dist/metadata/import.d.ts +0 -6
  120. package/dist/metadata/parameters.d.ts +0 -4
  121. package/dist/metadata/preferences.d.ts +0 -3
  122. package/dist/metadata/provider.d.ts +0 -3
  123. package/dist/metadata/query.d.ts +0 -4
  124. package/dist/metadata/request.d.ts +0 -4
  125. package/dist/metadata/response.d.ts +0 -4
  126. package/dist/metadata/service.d.ts +0 -6
  127. package/dist/metadata/utils.d.ts +0 -24
  128. package/dist/services/cache.d.ts +0 -9
  129. package/dist/services/common.d.ts +0 -147
  130. package/dist/services/defaults.d.ts +0 -31
  131. package/dist/services/route.d.ts +0 -56
  132. package/dist/types/import.d.ts +0 -14
  133. package/dist/types/service.d.ts +0 -14
  134. /package/dist/errors/{access.d.ts → http/access.d.ts} +0 -0
  135. /package/dist/errors/{provider.d.ts → http/provider.d.ts} +0 -0
  136. /package/dist/errors/{route.d.ts → http/route.d.ts} +0 -0
  137. /package/dist/errors/{handler.d.ts → web/handler.d.ts} +0 -0
  138. /package/dist/errors/{request.d.ts → web/request.d.ts} +0 -0
  139. /package/dist/errors/{response.d.ts → web/response.d.ts} +0 -0
  140. /package/dist/errors/{service.d.ts → web/service.d.ts} +0 -0
  141. /package/dist/metadata/{schema.d.ts → utils/schema.d.ts} +0 -0
  142. /package/dist/services/{access.d.ts → http/access.d.ts} +0 -0
  143. /package/dist/services/{authorization.d.ts → http/authorization.d.ts} +0 -0
  144. /package/dist/services/{cors.d.ts → http/cors.d.ts} +0 -0
  145. /package/dist/services/{provider.d.ts → http/provider.d.ts} +0 -0
@@ -0,0 +1,10 @@
1
+ import type { Service } from '@ez4/common';
2
+ import type { WsIncoming } from './incoming';
3
+ import type { WsResponse } from './response';
4
+ import type { WsRequest } from './request';
5
+ import type { WsEvent } from './event';
6
+ import type { Ws } from './contract';
7
+ /**
8
+ * WS request handler.
9
+ */
10
+ export type WsHandler<T extends WsRequest | WsEvent> = (request: WsIncoming<T> | T, context: Service.Context<Ws.Service<any>>) => Promise<WsResponse | void> | WsResponse | void;
@@ -0,0 +1,19 @@
1
+ import type { WsRequest } from './request';
2
+ import type { WsEvent } from './event';
3
+ /**
4
+ * Incoming WS event.
5
+ */
6
+ export type WsIncoming<T extends WsRequest | WsEvent> = T & {
7
+ /**
8
+ * Request tracking Id.
9
+ */
10
+ readonly requestId: string;
11
+ /**
12
+ * Request connection Id.
13
+ */
14
+ readonly connectionId: string;
15
+ /**
16
+ * Request timestamp.
17
+ */
18
+ readonly timestamp: Date;
19
+ };
@@ -0,0 +1,9 @@
1
+ import type { Service } from '@ez4/common';
2
+ import type { WsIncoming } from './incoming';
3
+ import type { WsRequest } from './request';
4
+ import type { WsEvent } from './event';
5
+ import type { Ws } from './contract';
6
+ /**
7
+ * WS request listener.
8
+ */
9
+ export type WsListener<T extends WsRequest | WsEvent> = (event: Service.AnyEvent<WsIncoming<T> | T>, context: Service.Context<Ws.Service<any>>) => Promise<void> | void;
@@ -0,0 +1,17 @@
1
+ import type { WebTarget } from '../web/target';
2
+ import type { WsListener } from './listener';
3
+ import type { WsHandler } from './handler';
4
+ import type { WsEvent } from './event';
5
+ /**
6
+ * WS message event.
7
+ */
8
+ export interface WsMessage<T extends WsEvent> extends WebTarget {
9
+ /**
10
+ * Life-cycle listener function for the event.
11
+ */
12
+ readonly listener?: WsListener<T>;
13
+ /**
14
+ * Entry-point handler function for the event.
15
+ */
16
+ readonly handler: WsHandler<T>;
17
+ }
@@ -0,0 +1,15 @@
1
+ import type { AuthIdentity } from '../auth/identity';
2
+ import type { WebBody } from '../web/body';
3
+ /**
4
+ * WS request.
5
+ */
6
+ export interface WsRequest {
7
+ /**
8
+ * Expected identity.
9
+ */
10
+ readonly identity?: AuthIdentity;
11
+ /**
12
+ * Expected event body.
13
+ */
14
+ readonly body?: WebBody;
15
+ }
@@ -0,0 +1,10 @@
1
+ import type { WebBody } from '../web/body';
2
+ /**
3
+ * WS response.
4
+ */
5
+ export interface WsResponse {
6
+ /**
7
+ * WS body payload.
8
+ */
9
+ readonly body?: WebBody;
10
+ }
@@ -0,0 +1,11 @@
1
+ import type { Ws } from './contract';
2
+ /**
3
+ * WS empty request.
4
+ */
5
+ export declare class WsEmptyRequest implements Ws.Request {
6
+ }
7
+ /**
8
+ * WS empty event.
9
+ */
10
+ export declare class WsEmptyEvent implements Ws.Event {
11
+ }
@@ -1,5 +1,5 @@
1
1
  import type { AnySchema } from '@ez4/schema';
2
- import type { Http } from '../services/contract';
2
+ import type { Http } from '../services/http/contract';
3
3
  export declare const prepareRequestBody: <T extends Http.JsonBody | Http.RawBody>(input: T, schema?: AnySchema, preferences?: Http.Preferences) => {
4
4
  body: string;
5
5
  json: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { ArraySchema, ObjectSchema, ScalarSchema, UnionSchema, NamingStyle } from '@ez4/schema';
2
- import type { ClientRequest, ClientResponse } from '../services/client';
3
- export type ClientRequestUrl = ClientRequest & {
2
+ import type { HttpClientRequest, HttpClientResponse } from '../services/http/client';
3
+ export type ClientRequestUrl = HttpClientRequest & {
4
4
  querySchema?: ObjectSchema;
5
5
  namingStyle?: NamingStyle;
6
6
  };
@@ -9,10 +9,10 @@ export type RequestAuthorization = {
9
9
  header: string;
10
10
  value: string;
11
11
  };
12
- export type ClientRequestInput = ClientRequest & {
12
+ export type ClientRequestInput = HttpClientRequest & {
13
13
  authorization?: RequestAuthorization;
14
14
  responseSchema?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
15
15
  bodySchema?: ObjectSchema | UnionSchema | ArraySchema | ScalarSchema;
16
16
  namingStyle?: NamingStyle;
17
17
  };
18
- export declare const sendClientRequest: (url: string, method: string, request: ClientRequestInput) => Promise<ClientResponse>;
18
+ export declare const sendClientRequest: (url: string, method: string, request: ClientRequestInput) => Promise<HttpClientResponse>;
@@ -7,6 +7,7 @@ import { HttpError } from '@ez4/gateway';
7
7
  export declare const getJsonError: ({ status, message, details }: HttpError) => {
8
8
  status: number;
9
9
  body: {
10
+ type: string;
10
11
  message: string;
11
12
  details: string[] | undefined;
12
13
  };
@@ -1,3 +1,3 @@
1
1
  import type { ObjectSchema } from '@ez4/schema';
2
- import type { Http } from '../services/contract';
2
+ import type { Http } from '../services/http/contract';
3
3
  export declare const getHeaders: <T extends Http.Headers>(input: T, schema: ObjectSchema) => Promise<T>;
@@ -1,3 +1,3 @@
1
1
  import type { ObjectSchema, UnionSchema } from '@ez4/schema';
2
- import type { Http } from '../services/contract';
2
+ import type { Http } from '../services/http/contract';
3
3
  export declare const getIdentity: <T extends Http.Identity>(input: T, schema: ObjectSchema | UnionSchema) => Promise<T>;
@@ -1,4 +1,4 @@
1
1
  import type { ObjectSchema } from '@ez4/schema';
2
- import type { Http } from '../services/contract';
2
+ import type { Http } from '../services/http/contract';
3
3
  export declare const preparePathParameters: (path: string, parameters: Record<string, string>) => string;
4
4
  export declare const getPathParameters: <T extends Http.PathParameters>(input: T, schema: ObjectSchema) => Promise<T>;
@@ -1,4 +1,4 @@
1
1
  import type { ObjectSchema } from '@ez4/schema';
2
- import type { Http } from '../services/contract';
2
+ import type { Http } from '../services/http/contract';
3
3
  export declare const prepareQueryStrings: <T extends Http.QueryStrings>(input: T, schema?: ObjectSchema, preferences?: Http.Preferences) => string | undefined;
4
4
  export declare const getQueryStrings: <T extends Http.QueryStrings>(input: T, schema: ObjectSchema, preferences?: Http.Preferences) => Promise<T>;
package/dist/utils.cjs CHANGED
@@ -31,8 +31,8 @@ o,t,n)},"prepareResponseBody"),X=s((e,t,r)=>{let o=r?.namingStyle,n=(0,c.createT
31
31
  arePathParameters"),Y=s(async(e,t)=>{let r=(0,b.transform)(e,t,(0,b.createTransformContext)(
32
32
  {convert:!1})),o=await(0,S.validate)(r,t,(0,S.createValidatorContext)({property:"\
33
33
  $path"}));if(o.length){let n=(0,S.getUniqueErrorMessages)(o);throw new Q.HttpBadRequestError(
34
- "Malformed path parameters.",n)}return r},"getPathParameters");var a=require("@ez4/gateway");var Z=s(({status:e,message:t,details:r})=>({status:e,body:{message:t,details:r}}),
35
- "getJsonError"),v=s((e,t,r)=>{switch(e){case 400:return new a.HttpBadRequestError(
34
+ "Malformed path parameters.",n)}return r},"getPathParameters");var a=require("@ez4/gateway");var Z=s(({status:e,message:t,details:r})=>({status:e,body:{type:"error",message:t,
35
+ details:r}}),"getJsonError"),v=s((e,t,r)=>{switch(e){case 400:return new a.HttpBadRequestError(
36
36
  t,r);case 401:return new a.HttpUnauthorizedError(t,r);case 403:return new a.HttpForbiddenError(
37
37
  t,r);case 404:return new a.HttpNotFoundError(t,r);case 415:return new a.HttpUnsupportedMediaTypeError(
38
38
  t,r);case 422:return new a.HttpUnprocessableEntityError(t,r);default:return new a.HttpError(
package/dist/utils.mjs CHANGED
@@ -27,11 +27,11 @@ arePathParameters"),zt=s(async(e,t)=>{let r=D(e,t,F({convert:!1})),o=await _(r,t
27
27
  K({property:"$path"}));if(o.length){let n=G(o);throw new L("Malformed path param\
28
28
  eters.",n)}return r},"getPathParameters");import{HttpBadRequestError as W,HttpUnauthorizedError as X,HttpForbiddenError as Y,
29
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(
30
+ HttpError as rt}from"@ez4/gateway";var Nt=s(({status:e,message:t,details:r})=>({status:e,body:{type:"error",message:t,
31
+ details:r}}),"getJsonError"),E=s((e,t,r)=>{switch(e){case 400:return new W(t,r);case 401:
32
+ return new X(t,r);case 403:return new Y(t,r);case 404:return new Z(t,r);case 415:
33
+ return new tt(t,r);case 422:return new et(t,r);default:return new rt(e,t,r)}},"g\
34
+ etHttpException");var Ft=s((e,t,r)=>{let{parameters:o,query:n,querySchema:a,namingStyle:p}=r,c=o?C(
35
35
  t,o):t,i=n&&T(n,a,{namingStyle:p}),m=[e];return c&&m.push(c),i&&m.push("?",i),m.
36
36
  join("")},"getClientRequestUrl"),Dt=s(async(e,t,r)=>{let{authorization:o,headers:n,
37
37
  body:a,bodySchema:p,responseSchema:c,namingStyle:i,timeout:m=20}=r,d=a?b(a,p,{namingStyle:i}):
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.36.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.36.0",
55
+ "@ez4/project": "^0.36.0",
56
+ "@ez4/reflection": "^0.36.0",
57
+ "@ez4/schema": "^0.36.0",
58
+ "@ez4/transform": "^0.36.0",
59
+ "@ez4/utils": "^0.36.0",
60
+ "@ez4/validator": "^0.36.0"
61
61
  }
62
62
  }
@@ -1,8 +0,0 @@
1
- import { IncorrectTypeError, InvalidTypeError } from '@ez4/common/library';
2
- export declare class InvalidParameterTypeError extends InvalidTypeError {
3
- constructor(fileName?: string);
4
- }
5
- export declare class IncorrectParameterTypeError extends IncorrectTypeError {
6
- parametersType: string;
7
- constructor(parametersType: string, fileName?: string);
8
- }
@@ -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,5 +0,0 @@
1
- import type { AllType, SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
2
- import type { ArraySchema, ObjectSchema, UnionSchema } from '@ez4/schema/library';
3
- type TypeParent = TypeObject | TypeModel | TypeIntersection;
4
- export declare const getHttpBody: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => ObjectSchema | UnionSchema | ArraySchema | import("@ez4/schema").BooleanSchema | import("@ez4/schema").NumberSchema | import("@ez4/schema").StringSchema | undefined;
5
- export {};
@@ -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,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,4 +0,0 @@
1
- import type { AllType, SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
2
- type TypeParent = TypeObject | TypeModel | TypeIntersection;
3
- export declare const getHttpHeaders: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => import("@ez4/schema").ObjectSchema | undefined;
4
- export {};
@@ -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, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
2
- type TypeParent = TypeObject | TypeModel | TypeIntersection;
3
- export declare const getHttpParameters: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => import("@ez4/schema").ObjectSchema | undefined;
4
- export {};
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpPreferences } from '../types/common';
3
- export declare const getHttpPreferences: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpPreferences | undefined;
@@ -1,3 +0,0 @@
1
- import type { AllType, SourceMap, TypeModel } from '@ez4/reflection';
2
- import type { HttpProvider } from '../types/common';
3
- export declare const getHttpProvider: (type: AllType, parent: TypeModel, reflection: SourceMap, errorList: Error[]) => HttpProvider | undefined;
@@ -1,4 +0,0 @@
1
- import type { AllType, SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
2
- type TypeParent = TypeObject | TypeModel | TypeIntersection;
3
- export declare const getHttpQuery: (type: AllType, parent: TypeParent, reflection: SourceMap, errorList: Error[]) => import("@ez4/schema").ObjectSchema | undefined;
4
- export {};
@@ -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,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,31 +0,0 @@
1
- import type { HttpAuthRequest, HttpErrors, HttpListener, HttpRequest } from './common';
2
- import type { HttpPreferences } from './preferences';
3
- /**
4
- * Default HTTP service parameters.
5
- */
6
- export interface HttpDefaults<T extends HttpRequest | HttpAuthRequest> {
7
- /**
8
- * Default route listener.
9
- */
10
- readonly listener?: HttpListener<T>;
11
- /**
12
- * Status codes for all known exceptions.
13
- */
14
- readonly httpErrors?: HttpErrors;
15
- /**
16
- * Default preferences for all handlers and routes.
17
- */
18
- readonly preferences?: HttpPreferences;
19
- /**
20
- * Default log retention (in days) for the handlers.
21
- */
22
- readonly logRetention?: number;
23
- /**
24
- * Default execution time (in seconds) for handlers and routes.
25
- */
26
- readonly timeout?: number;
27
- /**
28
- * Default amount of memory available for handlers.
29
- */
30
- readonly memory?: number;
31
- }
@@ -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,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;