5
5
MetadataBearer ,
6
6
MiddlewareStack ,
7
7
Pluggable ,
8
+ Provider ,
8
9
RequestSerializer ,
9
10
ResponseDeserializer ,
10
11
SerializeHandlerOptions ,
@@ -30,22 +31,22 @@ export const serializerMiddlewareOption: SerializeHandlerOptions = {
30
31
31
32
// Type the modifies the EndpointBearer to make it compatible with Endpoints 2.0 change.
32
33
// Must be removed after all clients has been onboard the Endpoints 2.0
33
- export type V1OrV2Endpoint < T extends EndpointBearer > = T & {
34
+ export type V1OrV2Endpoint = {
35
+ // for v2
34
36
urlParser ?: UrlParser ;
37
+
38
+ // for v1
39
+ endpoint ?: Provider < Endpoint > ;
35
40
} ;
36
41
37
- export function getSerdePlugin <
38
- InputType extends object ,
39
- SerDeContext extends EndpointBearer ,
40
- OutputType extends MetadataBearer
41
- > (
42
- config : V1OrV2Endpoint < SerDeContext > ,
43
- serializer : RequestSerializer < any , SerDeContext > ,
42
+ export function getSerdePlugin < InputType extends object , SerDeContext , OutputType extends MetadataBearer > (
43
+ config : V1OrV2Endpoint ,
44
+ serializer : RequestSerializer < any , SerDeContext & EndpointBearer > ,
44
45
deserializer : ResponseDeserializer < OutputType , any , SerDeContext >
45
46
) : Pluggable < InputType , OutputType > {
46
47
return {
47
48
applyToStack : ( commandStack : MiddlewareStack < InputType , OutputType > ) => {
48
- commandStack . add ( deserializerMiddleware ( config , deserializer ) , deserializerMiddlewareOption ) ;
49
+ commandStack . add ( deserializerMiddleware ( config as SerDeContext , deserializer ) , deserializerMiddlewareOption ) ;
49
50
commandStack . add ( serializerMiddleware ( config , serializer ) , serializerMiddlewareOption ) ;
50
51
} ,
51
52
} ;
0 commit comments