@ez4/gateway 0.34.0 → 0.35.1
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/authorization.d.ts +6 -0
- package/dist/client/operations.d.ts +3 -1
- package/dist/errors/authorization.d.ts +11 -0
- package/dist/library.cjs +277 -256
- package/dist/library.d.ts +3 -12
- package/dist/library.mjs +270 -249
- package/dist/main.cjs +18 -17
- package/dist/main.d.ts +2 -1
- package/dist/main.mjs +13 -13
- package/dist/metadata/authorization.d.ts +3 -0
- package/dist/metadata/schema.d.ts +2 -1
- package/dist/metadata/utils.d.ts +1 -0
- package/dist/services/access.d.ts +9 -0
- package/dist/services/authorization.d.ts +25 -0
- package/dist/services/cache.d.ts +9 -0
- package/dist/services/client.d.ts +71 -27
- package/dist/services/common.d.ts +23 -98
- package/dist/services/contract.d.ts +56 -92
- package/dist/services/cors.d.ts +29 -0
- package/dist/services/defaults.d.ts +31 -0
- package/dist/services/preferences.d.ts +10 -0
- package/dist/services/provider.d.ts +11 -0
- package/dist/services/route.d.ts +56 -0
- package/dist/services/utils.d.ts +3 -3
- package/dist/types/common.d.ts +7 -0
- package/dist/types/import.d.ts +2 -1
- package/dist/utils/body.d.ts +6 -1
- package/dist/utils/client.d.ts +9 -5
- package/dist/utils/parameters.d.ts +1 -0
- package/dist/utils/query.d.ts +3 -4
- package/dist/utils.cjs +52 -48
- package/dist/utils.mjs +53 -49
- package/package.json +8 -8
- package/dist/errors/context.d.ts +0 -8
- package/dist/metadata/context.d.ts +0 -3
- package/dist/utils/request.d.ts +0 -6
package/dist/main.cjs
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
typeof e=="object"||typeof e=="function")for(let
|
|
3
|
-
|
|
4
|
-
HttpInternalServerError:()=>
|
|
5
|
-
HttpUnprocessableEntityError:()=>
|
|
6
|
-
exports=v(
|
|
7
|
-
|
|
8
|
-
super(400,e||"Bad request",t)}},
|
|
9
|
-
dError")}constructor(e,t){super(401,e||"Unauthorized",t)}},
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ed media type",t)}},
|
|
14
|
-
r")}constructor(e,t){super(422,e||"Unprocessable entity",t)}},
|
|
15
|
-
|
|
16
|
-
error",t)}};0&&(module.exports={Http,HttpBadRequestError,HttpError,HttpForbiddenError,
|
|
17
|
-
HttpNotFoundError,HttpUnauthorizedError,HttpUnprocessableEntityError,
|
|
1
|
+
"use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var o=(r,e)=>a(r,"name",{value:e,configurable:!0});var A=(r,e)=>{for(var t in e)a(r,t,{get:e[t],enumerable:!0})},S=(r,e,t,n)=>{if(e&&
|
|
2
|
+
typeof e=="object"||typeof e=="function")for(let p of f(e))!T.call(r,p)&&p!==t&&
|
|
3
|
+
a(r,p,{get:()=>e[p],enumerable:!(n=h(e,p))||n.enumerable});return r};var g=r=>S(a({},"__esModule",{value:!0}),r);var v={};A(v,{AuthorizationType:()=>c,Http:()=>H,HttpBadRequestError:()=>i,HttpError:()=>s,
|
|
4
|
+
HttpForbiddenError:()=>y,HttpInternalServerError:()=>l,HttpNotFoundError:()=>d,HttpUnauthorizedError:()=>u,
|
|
5
|
+
HttpUnprocessableEntityError:()=>m,HttpUnsupportedMediaTypeError:()=>x});module.
|
|
6
|
+
exports=g(v);var c=(e=>(e.Bearer="bearer",e))(c||{});var H;(r=>{})(H||={});var R=require("@ez4/common");var s=class extends R.ServiceError{constructor(t,n,p){super(n,p);this.status=t}static{
|
|
7
|
+
o(this,"HttpError")}},i=class extends s{static{o(this,"HttpBadRequestError")}constructor(e,t){
|
|
8
|
+
super(400,e||"Bad request",t)}},u=class extends s{static{o(this,"HttpUnauthorize\
|
|
9
|
+
dError")}constructor(e,t){super(401,e||"Unauthorized",t)}},y=class extends s{static{
|
|
10
|
+
o(this,"HttpForbiddenError")}constructor(e,t){super(403,e||"Forbidden",t)}},d=class extends s{static{
|
|
11
|
+
o(this,"HttpNotFoundError")}constructor(e,t){super(404,e||"Not found",t)}},x=class extends s{static{
|
|
12
|
+
o(this,"HttpUnsupportedMediaTypeError")}constructor(e,t){super(415,e||"Unsupport\
|
|
13
|
+
ed media type",t)}},m=class extends s{static{o(this,"HttpUnprocessableEntityErro\
|
|
14
|
+
r")}constructor(e,t){super(422,e||"Unprocessable entity",t)}},l=class extends s{static{
|
|
15
|
+
o(this,"HttpInternalServerError")}constructor(e,t){super(500,e||"Internal server\
|
|
16
|
+
error",t)}};0&&(module.exports={AuthorizationType,Http,HttpBadRequestError,HttpError,HttpForbiddenError,
|
|
17
|
+
HttpInternalServerError,HttpNotFoundError,HttpUnauthorizedError,HttpUnprocessableEntityError,
|
|
18
|
+
HttpUnsupportedMediaTypeError});
|
|
18
19
|
//# sourceMappingURL=main.cjs.map
|
package/dist/main.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { Client, ClientRequest, ClientResponse } from './services/client';
|
|
2
|
+
export { AuthorizationType } from './services/authorization';
|
|
1
3
|
export * from './services/contract';
|
|
2
4
|
export * from './services/errors';
|
|
3
|
-
export { Client, ClientRequest, ClientResponse } from './services/client';
|
package/dist/main.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
"HttpError")}},
|
|
3
|
-
super(400,e||"Bad request",t)}},
|
|
4
|
-
dError")}constructor(e,t){super(401,e||"Unauthorized",t)}},c=class extends
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ed media type",t)}},
|
|
9
|
-
r")}constructor(e,t){super(422,e||"Unprocessable entity",t)}},
|
|
10
|
-
|
|
11
|
-
error",t)}};export{H as Http,
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var l=Object.defineProperty;var s=(r,e)=>l(r,"name",{value:e,configurable:!0});var p=(e=>(e.Bearer="bearer",e))(p||{});var H;(r=>{})(H||={});import{ServiceError as R}from"@ez4/common";var o=class extends R{constructor(t,x,m){super(x,m);this.status=t}static{s(this,
|
|
2
|
+
"HttpError")}},n=class extends o{static{s(this,"HttpBadRequestError")}constructor(e,t){
|
|
3
|
+
super(400,e||"Bad request",t)}},a=class extends o{static{s(this,"HttpUnauthorize\
|
|
4
|
+
dError")}constructor(e,t){super(401,e||"Unauthorized",t)}},c=class extends o{static{
|
|
5
|
+
s(this,"HttpForbiddenError")}constructor(e,t){super(403,e||"Forbidden",t)}},i=class extends o{static{
|
|
6
|
+
s(this,"HttpNotFoundError")}constructor(e,t){super(404,e||"Not found",t)}},u=class extends o{static{
|
|
7
|
+
s(this,"HttpUnsupportedMediaTypeError")}constructor(e,t){super(415,e||"Unsupport\
|
|
8
|
+
ed media type",t)}},y=class extends o{static{s(this,"HttpUnprocessableEntityErro\
|
|
9
|
+
r")}constructor(e,t){super(422,e||"Unprocessable entity",t)}},d=class extends o{static{
|
|
10
|
+
s(this,"HttpInternalServerError")}constructor(e,t){super(500,e||"Internal server\
|
|
11
|
+
error",t)}};export{p as AuthorizationType,H as Http,n as HttpBadRequestError,o as HttpError,
|
|
12
|
+
c as HttpForbiddenError,d as HttpInternalServerError,i as HttpNotFoundError,a as HttpUnauthorizedError,
|
|
13
|
+
y as HttpUnprocessableEntityError,u as HttpUnsupportedMediaTypeError};
|
|
14
14
|
//# sourceMappingURL=main.mjs.map
|
|
@@ -0,0 +1,3 @@
|
|
|
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,2 +1,3 @@
|
|
|
1
1
|
import type { SourceMap, TypeIntersection, TypeModel, TypeObject } from '@ez4/reflection';
|
|
2
|
-
export declare const
|
|
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;
|
package/dist/metadata/utils.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare const isHttpHandlerRequest: (type: TypeModel) => boolean;
|
|
|
10
10
|
export declare const isHttpAuthorizerResponse: (type: TypeModel) => boolean;
|
|
11
11
|
export declare const isHttpHandlerResponse: (type: TypeModel) => boolean;
|
|
12
12
|
export declare const isHttpDefaults: (type: TypeModel) => boolean;
|
|
13
|
+
export declare const isHttpAuthorization: (type: TypeModel) => boolean;
|
|
13
14
|
export declare const isHttpPreferences: (type: TypeModel) => boolean;
|
|
14
15
|
export declare const isHttpHeaders: (type: TypeModel) => boolean;
|
|
15
16
|
export declare const isHttpIdentity: (type: TypeModel) => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP authorization types.
|
|
3
|
+
*/
|
|
4
|
+
export declare const enum AuthorizationType {
|
|
5
|
+
Bearer = "bearer"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* HTTP authorization configuration.
|
|
9
|
+
*/
|
|
10
|
+
export interface HttpAuthorization {
|
|
11
|
+
/**
|
|
12
|
+
* Determines the HTTP authorization type.
|
|
13
|
+
* Default is: `AuthorizationType.Bearer`
|
|
14
|
+
*/
|
|
15
|
+
readonly type?: AuthorizationType;
|
|
16
|
+
/**
|
|
17
|
+
* Determines the authorization header name.
|
|
18
|
+
* Default is: `authorization`
|
|
19
|
+
*/
|
|
20
|
+
readonly header?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Determines the HTTP authorization value.
|
|
23
|
+
*/
|
|
24
|
+
readonly value: string;
|
|
25
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { AnyObject, Prettify } from '@ez4/utils';
|
|
1
|
+
import type { AnyObject, IsObjectEmpty, OptionalProperties, Prettify } from '@ez4/utils';
|
|
2
2
|
import type { Http } from './contract';
|
|
3
3
|
/**
|
|
4
4
|
* HTTP client.
|
|
5
5
|
*/
|
|
6
|
-
export type Client<T extends Http.Service
|
|
6
|
+
export type Client<T extends Http.Service | Http.Import<any>> = {
|
|
7
7
|
[P in ClientRoutes<T> as P extends {
|
|
8
8
|
name: infer N;
|
|
9
9
|
} ? (N extends string ? N : never) : never]: P extends {
|
|
10
10
|
handler: infer H;
|
|
11
11
|
authorizer: infer A;
|
|
12
|
-
} ? AuthorizedClientOperation<H, A
|
|
12
|
+
} ? AuthorizedClientOperation<H, A, AuthorizationHeaderName<T>> : P extends {
|
|
13
13
|
handler: infer H;
|
|
14
14
|
} ? ClientOperation<H> : never;
|
|
15
15
|
};
|
|
@@ -17,51 +17,95 @@ export type Client<T extends Http.Service> = {
|
|
|
17
17
|
* Default HTTP client request.
|
|
18
18
|
*/
|
|
19
19
|
export type ClientRequest = RequestOptions & {
|
|
20
|
-
headers?: Record<string, string>;
|
|
21
|
-
parameters?: Record<string, string>;
|
|
22
|
-
query?: Record<string, unknown>;
|
|
23
|
-
body?: string | AnyObject;
|
|
20
|
+
readonly headers?: Record<string, string>;
|
|
21
|
+
readonly parameters?: Record<string, string>;
|
|
22
|
+
readonly query?: Record<string, unknown>;
|
|
23
|
+
readonly body?: string | AnyObject;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
26
|
* Default HTTP response.
|
|
27
27
|
*/
|
|
28
28
|
export type ClientResponse = {
|
|
29
|
-
status: number;
|
|
30
|
-
headers?: Record<string, string | undefined>;
|
|
31
|
-
body?: unknown;
|
|
29
|
+
readonly status: number;
|
|
30
|
+
readonly headers?: Record<string, string | undefined>;
|
|
31
|
+
readonly body?: unknown;
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
|
-
* Given a HTTP service `
|
|
34
|
+
* Given a HTTP service `H`, it produces a union type containing all gateway routes.
|
|
35
35
|
*/
|
|
36
|
-
type ClientRoutes<
|
|
36
|
+
type ClientRoutes<H extends Http.Service> = H extends {
|
|
37
37
|
routes: (infer R)[];
|
|
38
38
|
} ? R : never;
|
|
39
39
|
/**
|
|
40
|
-
* Given a handler type `
|
|
40
|
+
* Given a handler type `H`, it produces a callback to invoke the operation.
|
|
41
41
|
*/
|
|
42
|
-
type ClientOperation<
|
|
42
|
+
type ClientOperation<H> = H extends (...args: any) => any ? (request: OperationRequest<H>) => OperationResponse<H> : never;
|
|
43
43
|
/**
|
|
44
|
-
* Given a handler type `
|
|
44
|
+
* Given a handler type `H`, it produces a request type.
|
|
45
45
|
*/
|
|
46
|
-
type OperationRequest<
|
|
46
|
+
type OperationRequest<H extends (...args: any) => any> = Prettify<RequestSchema<Parameters<H>[0], never> & RequestOptions>;
|
|
47
47
|
/**
|
|
48
|
-
* Given a
|
|
48
|
+
* Given a service type `T`, it returns the authorization header name.
|
|
49
49
|
*/
|
|
50
|
-
type
|
|
50
|
+
type AuthorizationHeaderName<T extends Http.Service | Http.Import<any>> = T extends {
|
|
51
|
+
authorization: infer A;
|
|
52
|
+
} ? A extends {
|
|
53
|
+
header: infer H;
|
|
54
|
+
} ? H : 'authorization' : never;
|
|
51
55
|
/**
|
|
52
|
-
* Given a handler type `
|
|
56
|
+
* Given a handler type `H` and an authorizer type `A`, it produces a callback to invoke the authorized operation.
|
|
53
57
|
*/
|
|
54
|
-
type
|
|
58
|
+
type AuthorizedClientOperation<H, A, N extends string> = H extends (...args: any) => any ? A extends (...args: any) => any ? (request: AuthorizedOperationRequest<H, A, N>) => OperationResponse<H> : never : never;
|
|
55
59
|
/**
|
|
56
|
-
* Given a handler type `
|
|
60
|
+
* Given a handler type `H` and an authorized type `A`, it produces a request type for the authorized request.
|
|
57
61
|
*/
|
|
58
|
-
type
|
|
62
|
+
type AuthorizedOperationRequest<H extends (...args: any) => any, A extends (...args: any) => any, N extends string> = Prettify<RequestSchema<Parameters<H>[0], never> & RequestSchema<Parameters<A>[0], N> & RequestOptions>;
|
|
59
63
|
/**
|
|
60
|
-
* Given a
|
|
64
|
+
* Given a handler type `H`, it produces a response type.
|
|
61
65
|
*/
|
|
62
|
-
type
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
type OperationResponse<H extends (...args: any) => any> = Promise<Awaited<ReturnType<H>>>;
|
|
67
|
+
/**
|
|
68
|
+
* Given a request type `R`, it produces a request schema containing only valid parameters.
|
|
69
|
+
*/
|
|
70
|
+
type RequestSchema<R, H extends string> = R extends AnyObject ? RequestHeaders<R, H> & RequestParameters<R> & RequestQuery<R> & RequestBody<R> : never;
|
|
71
|
+
/**
|
|
72
|
+
* Given a request type `R`, it produces a request headers type.
|
|
73
|
+
*/
|
|
74
|
+
type RequestHeaders<R, H extends string> = R extends {
|
|
75
|
+
headers: infer T;
|
|
76
|
+
} ? IsObjectEmpty<Omit<T, H>> extends false ? {
|
|
77
|
+
readonly headers: Prettify<Omit<T, H>>;
|
|
78
|
+
} : {} : {};
|
|
79
|
+
/**
|
|
80
|
+
* Given a request type `R`, it produces a request parameters type.
|
|
81
|
+
*/
|
|
82
|
+
type RequestParameters<R> = R extends {
|
|
83
|
+
parameters: infer T;
|
|
84
|
+
} ? IsObjectEmpty<Omit<T, OptionalProperties<NonNullable<T>>>> extends true ? {
|
|
85
|
+
readonly parameters?: T;
|
|
86
|
+
} : {
|
|
87
|
+
readonly parameters: T;
|
|
88
|
+
} : {};
|
|
89
|
+
/**
|
|
90
|
+
* Given a request type `R`, it produces a request query type.
|
|
91
|
+
*/
|
|
92
|
+
type RequestQuery<R> = R extends {
|
|
93
|
+
query: infer T;
|
|
94
|
+
} ? IsObjectEmpty<Omit<T, OptionalProperties<NonNullable<T>>>> extends true ? {
|
|
95
|
+
readonly query?: T;
|
|
96
|
+
} : {
|
|
97
|
+
readonly query: T;
|
|
98
|
+
} : {};
|
|
99
|
+
/**
|
|
100
|
+
* Given a request type `R`, it produces a request body type.
|
|
101
|
+
*/
|
|
102
|
+
type RequestBody<R> = R extends {
|
|
103
|
+
body: infer T;
|
|
104
|
+
} ? IsObjectEmpty<Omit<T, OptionalProperties<NonNullable<T>>>> extends true ? {
|
|
105
|
+
readonly body?: T;
|
|
106
|
+
} : {
|
|
107
|
+
readonly body: T;
|
|
108
|
+
} : {};
|
|
65
109
|
/**
|
|
66
110
|
* All request options.
|
|
67
111
|
*/
|
|
@@ -69,6 +113,6 @@ type RequestOptions = {
|
|
|
69
113
|
/**
|
|
70
114
|
* Maximum wait time for a response.
|
|
71
115
|
*/
|
|
72
|
-
timeout?: number;
|
|
116
|
+
readonly timeout?: number;
|
|
73
117
|
};
|
|
74
118
|
export {};
|
|
@@ -1,63 +1,6 @@
|
|
|
1
|
-
import type { LinkedVariables } from '@ez4/project/library';
|
|
2
|
-
import type { NamingStyle } from '@ez4/schema';
|
|
3
1
|
import type { Service } from '@ez4/common';
|
|
2
|
+
import type { HttpProvider } from './provider';
|
|
4
3
|
import type { Http } from './contract';
|
|
5
|
-
/**
|
|
6
|
-
* Contract for HTTP preferences.
|
|
7
|
-
*/
|
|
8
|
-
export interface HttpPreferences {
|
|
9
|
-
/**
|
|
10
|
-
* Determines the naming style for the query strings and body payloads.
|
|
11
|
-
*/
|
|
12
|
-
namingStyle?: NamingStyle;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* HTTP CORS configuration.
|
|
16
|
-
*/
|
|
17
|
-
export interface HttpCors {
|
|
18
|
-
/**
|
|
19
|
-
* List of allowed origins.
|
|
20
|
-
*/
|
|
21
|
-
allowOrigins: string[];
|
|
22
|
-
/**
|
|
23
|
-
* List of allowed methods.
|
|
24
|
-
*/
|
|
25
|
-
allowMethods?: string[];
|
|
26
|
-
/**
|
|
27
|
-
* Determines whether or not requests can be made with credentials.
|
|
28
|
-
*/
|
|
29
|
-
allowCredentials?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* List of allowed headers.
|
|
32
|
-
*/
|
|
33
|
-
allowHeaders?: string[];
|
|
34
|
-
/**
|
|
35
|
-
* List of exposed headers.
|
|
36
|
-
*/
|
|
37
|
-
exposeHeaders?: string[];
|
|
38
|
-
/**
|
|
39
|
-
* Determines how long the preflight result can be cached.
|
|
40
|
-
*/
|
|
41
|
-
maxAge?: number;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* HTTP cache configuration.
|
|
45
|
-
*/
|
|
46
|
-
export interface HttpCache {
|
|
47
|
-
/**
|
|
48
|
-
* Default TTL (in seconds) for cached authorizations.
|
|
49
|
-
*/
|
|
50
|
-
authorizerTTL: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* HTTP access configuration.
|
|
54
|
-
*/
|
|
55
|
-
export interface HttpAccess {
|
|
56
|
-
/**
|
|
57
|
-
* Log retention (in days) for the access log.
|
|
58
|
-
*/
|
|
59
|
-
logRetention: number;
|
|
60
|
-
}
|
|
61
4
|
/**
|
|
62
5
|
* Request headers.
|
|
63
6
|
*/
|
|
@@ -91,22 +34,18 @@ export type HttpRawBody = string;
|
|
|
91
34
|
* Authorizer request.
|
|
92
35
|
*/
|
|
93
36
|
export interface HttpAuthRequest {
|
|
94
|
-
/**
|
|
95
|
-
* Auth request preferences.
|
|
96
|
-
*/
|
|
97
|
-
preferences?: HttpPreferences;
|
|
98
37
|
/**
|
|
99
38
|
* Expected HTTP headers.
|
|
100
39
|
*/
|
|
101
|
-
headers?: HttpHeaders;
|
|
40
|
+
readonly headers?: HttpHeaders;
|
|
102
41
|
/**
|
|
103
42
|
* Expected HTTP path parameters.
|
|
104
43
|
*/
|
|
105
|
-
parameters?: HttpPathParameters;
|
|
44
|
+
readonly parameters?: HttpPathParameters;
|
|
106
45
|
/**
|
|
107
46
|
* Expected HTTP query strings.
|
|
108
47
|
*/
|
|
109
|
-
query?: HttpQueryStrings;
|
|
48
|
+
readonly query?: HttpQueryStrings;
|
|
110
49
|
}
|
|
111
50
|
/**
|
|
112
51
|
* Authorizer response.
|
|
@@ -115,67 +54,49 @@ export interface HttpAuthResponse {
|
|
|
115
54
|
/**
|
|
116
55
|
* Authorization identity.
|
|
117
56
|
*/
|
|
118
|
-
identity?: HttpIdentity;
|
|
57
|
+
readonly identity?: HttpIdentity;
|
|
119
58
|
}
|
|
120
59
|
/**
|
|
121
60
|
* HTTP request.
|
|
122
61
|
*/
|
|
123
62
|
export interface HttpRequest {
|
|
124
|
-
/**
|
|
125
|
-
* Request preferences.
|
|
126
|
-
*/
|
|
127
|
-
preferences?: HttpPreferences;
|
|
128
63
|
/**
|
|
129
64
|
* Expected identity.
|
|
130
65
|
*/
|
|
131
|
-
identity?: HttpIdentity;
|
|
66
|
+
readonly identity?: HttpIdentity;
|
|
132
67
|
/**
|
|
133
68
|
* Expected HTTP headers.
|
|
134
69
|
*/
|
|
135
|
-
headers?: HttpHeaders;
|
|
70
|
+
readonly headers?: HttpHeaders;
|
|
136
71
|
/**
|
|
137
72
|
* Expected HTTP path parameters.
|
|
138
73
|
*/
|
|
139
|
-
parameters?: HttpPathParameters;
|
|
74
|
+
readonly parameters?: HttpPathParameters;
|
|
140
75
|
/**
|
|
141
76
|
* Expected HTTP query strings.
|
|
142
77
|
*/
|
|
143
|
-
query?: HttpQueryStrings;
|
|
78
|
+
readonly query?: HttpQueryStrings;
|
|
144
79
|
/**
|
|
145
80
|
* Expected HTTP body payload.
|
|
146
81
|
*/
|
|
147
|
-
body?: HttpJsonBody | HttpRawBody;
|
|
82
|
+
readonly body?: HttpJsonBody | HttpRawBody;
|
|
148
83
|
}
|
|
149
84
|
/**
|
|
150
85
|
* HTTP response.
|
|
151
86
|
*/
|
|
152
87
|
export interface HttpResponse {
|
|
153
|
-
/**
|
|
154
|
-
* Response preferences.
|
|
155
|
-
*/
|
|
156
|
-
preferences?: HttpPreferences;
|
|
157
88
|
/**
|
|
158
89
|
* HTTP status code.
|
|
159
90
|
*/
|
|
160
|
-
status: number;
|
|
91
|
+
readonly status: number;
|
|
161
92
|
/**
|
|
162
93
|
* HTTP headers.
|
|
163
94
|
*/
|
|
164
|
-
headers?: HttpHeaders;
|
|
95
|
+
readonly headers?: HttpHeaders;
|
|
165
96
|
/**
|
|
166
97
|
* HTTP body payload.
|
|
167
98
|
*/
|
|
168
|
-
body?: HttpJsonBody | HttpRawBody;
|
|
169
|
-
}
|
|
170
|
-
export interface HttpProvider {
|
|
171
|
-
/**
|
|
172
|
-
* Variables associated to the provider.
|
|
173
|
-
*/
|
|
174
|
-
variables?: LinkedVariables;
|
|
175
|
-
/**
|
|
176
|
-
* All services associated to the provider.
|
|
177
|
-
*/
|
|
178
|
-
services: Record<string, unknown>;
|
|
99
|
+
readonly body?: HttpJsonBody | HttpRawBody;
|
|
179
100
|
}
|
|
180
101
|
/**
|
|
181
102
|
* Incoming request.
|
|
@@ -184,23 +105,27 @@ export type HttpIncoming<T extends HttpRequest | HttpAuthRequest> = T & {
|
|
|
184
105
|
/**
|
|
185
106
|
* Request tracking Id.
|
|
186
107
|
*/
|
|
187
|
-
requestId: string;
|
|
108
|
+
readonly requestId: string;
|
|
188
109
|
/**
|
|
189
110
|
* Determines whether request is base64 encoded or not.
|
|
190
111
|
*/
|
|
191
|
-
encoded?: boolean;
|
|
112
|
+
readonly encoded?: boolean;
|
|
192
113
|
/**
|
|
193
114
|
* Request timestamp.
|
|
194
115
|
*/
|
|
195
|
-
timestamp: Date;
|
|
116
|
+
readonly timestamp: Date;
|
|
196
117
|
/**
|
|
197
118
|
* Request method.
|
|
198
119
|
*/
|
|
199
|
-
method: string;
|
|
120
|
+
readonly method: string;
|
|
200
121
|
/**
|
|
201
122
|
* Request path.
|
|
202
123
|
*/
|
|
203
|
-
path: string;
|
|
124
|
+
readonly path: string;
|
|
125
|
+
/**
|
|
126
|
+
* Raw body data (when provided in the request).
|
|
127
|
+
*/
|
|
128
|
+
readonly data?: string;
|
|
204
129
|
};
|
|
205
130
|
/**
|
|
206
131
|
* Request listener.
|
|
@@ -218,5 +143,5 @@ export type HttpHandler<T extends HttpRequest> = (request: HttpIncoming<T> | T,
|
|
|
218
143
|
* HTTP errors.
|
|
219
144
|
*/
|
|
220
145
|
export type HttpErrors = {
|
|
221
|
-
[code: number]: Error[];
|
|
146
|
+
[code: number]: readonly Error[];
|
|
222
147
|
};
|