@@ -40,29 +40,45 @@ export abstract class Command<
40
40
middlewareQueue : [ ] as Pluggable < any , any > [ ] ,
41
41
commandName : "" ,
42
42
clientName : "" ,
43
- service : "" ,
44
- operation : "" ,
43
+ smithyContext : { } ,
45
44
inputFilterSensitiveLog : ( ) => { } ,
46
45
outputFilterSensitiveLog : ( ) => { } ,
47
46
} ;
48
47
return {
48
+ /**
49
+ * Add any number of middleware.
50
+ */
49
51
m ( ...middleware : Pluggable < any , any > [ ] ) {
50
52
args . middlewareQueue . push ( ...middleware ) ;
51
53
return this ;
52
54
} ,
53
- n ( clientName : string , commandName : string , service : string , operation : string ) {
55
+ /**
56
+ * Set the Smithy context record.
57
+ */
58
+ sc ( smithyContext : Record < string , unknown > ) {
59
+ args . smithyContext = smithyContext ;
60
+ return this ;
61
+ } ,
62
+ /**
63
+ * Set constant string identifiers for the operation.
64
+ */
65
+ n ( clientName : string , commandName : string ) {
54
66
args . clientName = clientName ;
55
67
args . commandName = commandName ;
56
- args . service = service ;
57
- args . operation = operation ;
58
68
return this ;
59
69
} ,
70
+ /**
71
+ * Set the input and output sensistive log filters.
72
+ */
60
73
f ( inputFilter : ( _ : any ) => any = ( _ ) => _ , outputFilter : ( _ : any ) => any = ( _ ) => _ ) {
61
74
args . inputFilterSensitiveLog = inputFilter ;
62
75
args . outputFilterSensitiveLog = outputFilter ;
63
76
return this ;
64
77
} ,
65
- build ( ) {
78
+ /**
79
+ * @returns the implementation of the built resolveMiddleware function.
80
+ */
81
+ build : ( ) => {
66
82
return (
67
83
clientStack : IMiddlewareStack < ClientInput , ClientOutput > ,
68
84
configuration : ResolvedClientConfiguration & {
@@ -71,7 +87,7 @@ export abstract class Command<
71
87
} ,
72
88
options : any
73
89
) => {
74
- this . __resolveMiddleware ( clientStack , configuration , options , args ) ;
90
+ return this . __resolveMiddleware ( clientStack , configuration , options , args ) ;
75
91
} ;
76
92
} ,
77
93
} ;
@@ -88,10 +104,9 @@ export abstract class Command<
88
104
middlewareQueue,
89
105
clientName,
90
106
commandName,
91
- service,
92
- operation,
93
107
inputFilterSensitiveLog,
94
108
outputFilterSensitiveLog,
109
+ smithyContext,
95
110
} : ResolveMiddlewareContextArgs
96
111
) {
97
112
for ( const mw of middlewareQueue ) {
@@ -106,8 +121,7 @@ export abstract class Command<
106
121
inputFilterSensitiveLog,
107
122
outputFilterSensitiveLog,
108
123
[ SMITHY_CONTEXT_KEY ] : {
109
- service,
110
- operation,
124
+ ...smithyContext ,
111
125
} ,
112
126
} ;
113
127
const { requestHandler } = configuration ;
@@ -126,8 +140,7 @@ type ResolveMiddlewareContextArgs = {
126
140
middlewareQueue : Pluggable < any , any > [ ] ;
127
141
clientName : string ;
128
142
commandName : string ;
129
- service : string ;
130
- operation : string ;
143
+ smithyContext : Record < string , unknown > ;
131
144
inputFilterSensitiveLog : ( _ : any ) => any ;
132
145
outputFilterSensitiveLog : ( _ : any ) => any ;
133
146
} ;
0 commit comments