Skip to content

Commit 8fc2114

Browse files
committed
update ts pkg
1 parent 48a1f1e commit 8fc2114

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

packages/smithy-client/src/command.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,45 @@ export abstract class Command<
4040
middlewareQueue: [] as Pluggable<any, any>[],
4141
commandName: "",
4242
clientName: "",
43-
service: "",
44-
operation: "",
43+
smithyContext: {},
4544
inputFilterSensitiveLog: () => {},
4645
outputFilterSensitiveLog: () => {},
4746
};
4847
return {
48+
/**
49+
* Add any number of middleware.
50+
*/
4951
m(...middleware: Pluggable<any, any>[]) {
5052
args.middlewareQueue.push(...middleware);
5153
return this;
5254
},
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) {
5466
args.clientName = clientName;
5567
args.commandName = commandName;
56-
args.service = service;
57-
args.operation = operation;
5868
return this;
5969
},
70+
/**
71+
* Set the input and output sensistive log filters.
72+
*/
6073
f(inputFilter: (_: any) => any = (_) => _, outputFilter: (_: any) => any = (_) => _) {
6174
args.inputFilterSensitiveLog = inputFilter;
6275
args.outputFilterSensitiveLog = outputFilter;
6376
return this;
6477
},
65-
build() {
78+
/**
79+
* @returns the implementation of the built resolveMiddleware function.
80+
*/
81+
build: () => {
6682
return (
6783
clientStack: IMiddlewareStack<ClientInput, ClientOutput>,
6884
configuration: ResolvedClientConfiguration & {
@@ -71,7 +87,7 @@ export abstract class Command<
7187
},
7288
options: any
7389
) => {
74-
this.__resolveMiddleware(clientStack, configuration, options, args);
90+
return this.__resolveMiddleware(clientStack, configuration, options, args);
7591
};
7692
},
7793
};
@@ -88,10 +104,9 @@ export abstract class Command<
88104
middlewareQueue,
89105
clientName,
90106
commandName,
91-
service,
92-
operation,
93107
inputFilterSensitiveLog,
94108
outputFilterSensitiveLog,
109+
smithyContext,
95110
}: ResolveMiddlewareContextArgs
96111
) {
97112
for (const mw of middlewareQueue) {
@@ -106,8 +121,7 @@ export abstract class Command<
106121
inputFilterSensitiveLog,
107122
outputFilterSensitiveLog,
108123
[SMITHY_CONTEXT_KEY]: {
109-
service,
110-
operation,
124+
...smithyContext,
111125
},
112126
};
113127
const { requestHandler } = configuration;
@@ -126,8 +140,7 @@ type ResolveMiddlewareContextArgs = {
126140
middlewareQueue: Pluggable<any, any>[];
127141
clientName: string;
128142
commandName: string;
129-
service: string;
130-
operation: string;
143+
smithyContext: Record<string, unknown>;
131144
inputFilterSensitiveLog: (_: any) => any;
132145
outputFilterSensitiveLog: (_: any) => any;
133146
};

0 commit comments

Comments
 (0)