1 | import {
|
2 | APIGatewayEventDefaultAuthorizerContext,
|
3 | APIGatewayEventRequestContextWithAuthorizer,
|
4 | } from "../common/api-gateway";
|
5 | import { Callback, Handler } from "../handler";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export type APIGatewayProxyHandler = Handler<APIGatewayProxyEvent, APIGatewayProxyResult>;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export type APIGatewayProxyCallback = Callback<APIGatewayProxyResult>;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | export type APIGatewayProxyHandlerV2<T = never> = Handler<APIGatewayProxyEventV2, APIGatewayProxyResultV2<T>>;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export type APIGatewayProxyCallbackV2 = Callback<APIGatewayProxyResultV2>;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export type APIGatewayProxyEvent = APIGatewayProxyEventBase<APIGatewayEventDefaultAuthorizerContext>;
|
34 |
|
35 | export type APIGatewayProxyWithLambdaAuthorizerHandler<TAuthorizerContext> =
|
36 | Handler<APIGatewayProxyWithLambdaAuthorizerEvent<TAuthorizerContext>, APIGatewayProxyResult>;
|
37 |
|
38 | export type APIGatewayProxyWithCognitoAuthorizerHandler =
|
39 | Handler<APIGatewayProxyWithCognitoAuthorizerEvent, APIGatewayProxyResult>;
|
40 |
|
41 | export type APIGatewayProxyWithLambdaAuthorizerEvent<TAuthorizerContext> =
|
42 | APIGatewayProxyEventBase<APIGatewayEventLambdaAuthorizerContext<TAuthorizerContext>>;
|
43 |
|
44 | export type APIGatewayProxyWithLambdaAuthorizerEventRequestContext<TAuthorizerContext> =
|
45 | APIGatewayEventRequestContextWithAuthorizer<APIGatewayEventLambdaAuthorizerContext<TAuthorizerContext>>;
|
46 |
|
47 |
|
48 |
|
49 | export type APIGatewayEventLambdaAuthorizerContext<TAuthorizerContext> = {
|
50 | [P in keyof TAuthorizerContext]: TAuthorizerContext[P] extends null ? null : string;
|
51 | } & {
|
52 | principalId: string;
|
53 | integrationLatency: number;
|
54 | };
|
55 |
|
56 | export type APIGatewayProxyWithCognitoAuthorizerEvent = APIGatewayProxyEventBase<APIGatewayProxyCognitoAuthorizer>;
|
57 |
|
58 |
|
59 | export interface APIGatewayProxyCognitoAuthorizer {
|
60 | claims: {
|
61 | [name: string]: string;
|
62 | };
|
63 | }
|
64 |
|
65 | export interface APIGatewayProxyEventHeaders {
|
66 | [name: string]: string | undefined;
|
67 | }
|
68 |
|
69 | export interface APIGatewayProxyEventMultiValueHeaders {
|
70 | [name: string]: string[] | undefined;
|
71 | }
|
72 |
|
73 | export interface APIGatewayProxyEventPathParameters {
|
74 | [name: string]: string | undefined;
|
75 | }
|
76 |
|
77 | export interface APIGatewayProxyEventQueryStringParameters {
|
78 | [name: string]: string | undefined;
|
79 | }
|
80 |
|
81 | export interface APIGatewayProxyEventMultiValueQueryStringParameters {
|
82 | [name: string]: string[] | undefined;
|
83 | }
|
84 |
|
85 | export interface APIGatewayProxyEventStageVariables {
|
86 | [name: string]: string | undefined;
|
87 | }
|
88 |
|
89 | export interface APIGatewayProxyEventBase<TAuthorizerContext> {
|
90 | body: string | null;
|
91 | headers: APIGatewayProxyEventHeaders;
|
92 | multiValueHeaders: APIGatewayProxyEventMultiValueHeaders;
|
93 | httpMethod: string;
|
94 | isBase64Encoded: boolean;
|
95 | path: string;
|
96 | pathParameters: APIGatewayProxyEventPathParameters | null;
|
97 | queryStringParameters: APIGatewayProxyEventQueryStringParameters | null;
|
98 | multiValueQueryStringParameters: APIGatewayProxyEventMultiValueQueryStringParameters | null;
|
99 | stageVariables: APIGatewayProxyEventStageVariables | null;
|
100 | requestContext: APIGatewayEventRequestContextWithAuthorizer<TAuthorizerContext>;
|
101 | resource: string;
|
102 | }
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | export interface APIGatewayProxyResult {
|
109 | statusCode: number;
|
110 | headers?: {
|
111 | [header: string]: boolean | number | string;
|
112 | } | undefined;
|
113 | multiValueHeaders?: {
|
114 | [header: string]: Array<boolean | number | string>;
|
115 | } | undefined;
|
116 | body: string;
|
117 | isBase64Encoded?: boolean | undefined;
|
118 | }
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 | export interface APIGatewayProxyEventV2 {
|
125 | version: string;
|
126 | routeKey: string;
|
127 | rawPath: string;
|
128 | rawQueryString: string;
|
129 | cookies?: string[] | undefined;
|
130 | headers: APIGatewayProxyEventHeaders;
|
131 | queryStringParameters?: APIGatewayProxyEventQueryStringParameters | undefined;
|
132 | requestContext: {
|
133 | accountId: string;
|
134 | apiId: string;
|
135 | authorizer?: {
|
136 | jwt: {
|
137 | claims: { [name: string]: string | number | boolean | string[] };
|
138 | scopes: string[];
|
139 | };
|
140 | } | undefined;
|
141 | domainName: string;
|
142 | domainPrefix: string;
|
143 | http: {
|
144 | method: string;
|
145 | path: string;
|
146 | protocol: string;
|
147 | sourceIp: string;
|
148 | userAgent: string;
|
149 | };
|
150 | requestId: string;
|
151 | routeKey: string;
|
152 | stage: string;
|
153 | time: string;
|
154 | timeEpoch: number;
|
155 | };
|
156 | body?: string | undefined;
|
157 | pathParameters?: APIGatewayProxyEventPathParameters | undefined;
|
158 | isBase64Encoded: boolean;
|
159 | stageVariables?: APIGatewayProxyEventStageVariables | undefined;
|
160 | }
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | export type APIGatewayProxyResultV2<T = never> = APIGatewayProxyStructuredResultV2 | string | T;
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | export interface APIGatewayProxyStructuredResultV2 {
|
174 | statusCode?: number | undefined;
|
175 | headers?: {
|
176 | [header: string]: boolean | number | string;
|
177 | } | undefined;
|
178 | body?: string | undefined;
|
179 | isBase64Encoded?: boolean | undefined;
|
180 | cookies?: string[] | undefined;
|
181 | }
|
182 |
|
183 |
|
184 | export type ProxyHandler = APIGatewayProxyHandler;
|
185 | export type ProxyCallback = APIGatewayProxyCallback;
|
186 | export type APIGatewayEvent = APIGatewayProxyEvent;
|
187 | export type ProxyResult = APIGatewayProxyResult;
|