@@ -22,10 +22,8 @@ import {
2222 BuildHandler ,
2323 BuildMiddleware ,
2424 DeserializeHandler ,
25- DeserializeMiddleware ,
2625 Handler ,
2726 FinalizeHandler ,
28- FinalizeRequestMiddleware ,
2927 HandlerExecutionContext ,
3028 MetadataBearer ,
3129 MiddlewareStack ,
@@ -216,30 +214,36 @@ export function recordErrorTelemetry(err: Error, serviceName?: string) {
216214 } )
217215}
218216
219- export const defaultDeserializeMiddleware : DeserializeMiddleware < any , any > =
220- ( next : DeserializeHandler < any , any > , context : HandlerExecutionContext ) =>
221- async ( args : DeserializeHandlerArguments < any > ) =>
222- onDeserialize ( next , context , args )
217+ export function defaultDeserializeMiddleware < Input extends object , Output extends object > (
218+ next : DeserializeHandler < Input , Output > ,
219+ context : HandlerExecutionContext
220+ ) {
221+ return async ( args : DeserializeHandlerArguments < Input > ) => onDeserialize ( next , context , args )
222+ }
223223
224- export const finalizeLoggingMiddleware : FinalizeRequestMiddleware < any , any > =
225- ( next : FinalizeHandler < any , any > ) => async ( args : FinalizeHandlerArguments < any > ) =>
226- logOnFinalize ( next , args )
224+ export function finalizeLoggingMiddleware < Input extends object , Output extends object > (
225+ next : FinalizeHandler < Input , Output >
226+ ) {
227+ return async ( args : FinalizeHandlerArguments < Input > ) => logOnFinalize ( next , args )
228+ }
227229
228- function getEndpointMiddleware ( settings : DevSettings = DevSettings . instance ) : BuildMiddleware < any , any > {
229- return ( next : BuildHandler < any , any > , context : HandlerExecutionContext ) =>
230- async ( args : BuildHandlerArguments < any > ) =>
230+ function getEndpointMiddleware < Input extends object , Output extends object > (
231+ settings : DevSettings = DevSettings . instance
232+ ) : BuildMiddleware < Input , Output > {
233+ return ( next : BuildHandler < Input , Output > , context : HandlerExecutionContext ) =>
234+ async ( args : BuildHandlerArguments < Input > ) =>
231235 overwriteEndpoint ( next , context , settings , args )
232236}
233237
234- const keepAliveMiddleware : BuildMiddleware < any , any > =
235- ( next : BuildHandler < any , any > ) => async ( args : BuildHandlerArguments < any > ) =>
236- addKeepAliveHeader ( next , args )
238+ function keepAliveMiddleware < Input extends object , Output extends object > ( next : BuildHandler < Input , Output > ) {
239+ return async ( args : BuildHandlerArguments < Input > ) => addKeepAliveHeader ( next , args )
240+ }
237241
238- export async function onDeserialize (
239- next : DeserializeHandler < any , any > ,
242+ export async function onDeserialize < Input extends object , Output extends object > (
243+ next : DeserializeHandler < Input , Output > ,
240244 context : HandlerExecutionContext ,
241- args : DeserializeHandlerArguments < any >
242- ) : Promise < DeserializeHandlerOutput < any > > {
245+ args : DeserializeHandlerArguments < Input >
246+ ) : Promise < DeserializeHandlerOutput < Output > > {
243247 const request = args . request
244248 if ( ! HttpRequest . isInstance ( request ) ) {
245249 return next ( args )
@@ -265,7 +269,10 @@ export async function onDeserialize(
265269 }
266270}
267271
268- export async function logOnFinalize ( next : FinalizeHandler < any , any > , args : FinalizeHandlerArguments < any > ) {
272+ export async function logOnFinalize < Input extends object , Output extends object > (
273+ next : FinalizeHandler < Input , Output > ,
274+ args : FinalizeHandlerArguments < Input >
275+ ) {
269276 const request = args . request
270277 if ( HttpRequest . isInstance ( request ) ) {
271278 const { hostname, path } = request
@@ -275,11 +282,11 @@ export async function logOnFinalize(next: FinalizeHandler<any, any>, args: Final
275282 return next ( args )
276283}
277284
278- export function overwriteEndpoint (
279- next : BuildHandler < any , any > ,
285+ export function overwriteEndpoint < Input extends object , Output extends object > (
286+ next : BuildHandler < Input , Output > ,
280287 context : HandlerExecutionContext ,
281288 settings : DevSettings ,
282- args : BuildHandlerArguments < any >
289+ args : BuildHandlerArguments < Input >
283290) {
284291 const request = args . request
285292 if ( HttpRequest . isInstance ( request ) ) {
@@ -301,7 +308,10 @@ export function overwriteEndpoint(
301308 * @param args
302309 * @returns
303310 */
304- export function addKeepAliveHeader ( next : BuildHandler < any , any > , args : BuildHandlerArguments < any > ) {
311+ export function addKeepAliveHeader < Input extends object , Output extends object > (
312+ next : BuildHandler < Input , Output > ,
313+ args : BuildHandlerArguments < Input >
314+ ) {
305315 const request = args . request
306316 if ( HttpRequest . isInstance ( request ) ) {
307317 request . headers [ 'Connection' ] = 'keep-alive'
0 commit comments