File tree Expand file tree Collapse file tree 5 files changed +52
-1
lines changed Expand file tree Collapse file tree 5 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 21
21
"url" : " https://aws.amazon.com/javascript/"
22
22
},
23
23
"license" : " Apache-2.0" ,
24
+ "dependencies" : {
25
+ "@smithy/smithy-client" : " ^2.1.11"
26
+ },
24
27
"devDependencies" : {
25
28
"@tsconfig/recommended" : " 1.0.1" ,
26
29
"concurrently" : " 7.0.0" ,
Original file line number Diff line number Diff line change 1
- export { } ;
1
+ export * from "./protocols/index" ;
Original file line number Diff line number Diff line change
1
+ export * from "./json/awsExpectUnion" ;
Original file line number Diff line number Diff line change
1
+ import { awsExpectUnion } from "./awsExpectUnion" ;
2
+
3
+ describe ( awsExpectUnion . name , ( ) => {
4
+ it ( "ignores the __type field" , ( ) => {
5
+ expect (
6
+ awsExpectUnion ( {
7
+ K : "V" ,
8
+ __type : "X" ,
9
+ } )
10
+ ) . toEqual ( {
11
+ K : "V" ,
12
+ } ) ;
13
+ } ) ;
14
+
15
+ it ( "throws when there are extra keys or no keys" , ( ) => {
16
+ expect ( ( ) =>
17
+ awsExpectUnion ( {
18
+ __type : "X" ,
19
+ } )
20
+ ) . toThrowError ( ) ;
21
+
22
+ expect ( ( ) =>
23
+ awsExpectUnion ( {
24
+ K : "V" ,
25
+ I : "S" ,
26
+ __type : "X" ,
27
+ } )
28
+ ) . toThrowError ( ) ;
29
+ } ) ;
30
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { expectUnion } from "@smithy/smithy-client" ;
2
+
3
+ /**
4
+ * @internal
5
+ *
6
+ * Forwards to Smithy's expectUnion function, but also ignores
7
+ * the `__type` field if it is present.
8
+ */
9
+ export const awsExpectUnion = ( value : unknown ) : Record < string , any > | undefined => {
10
+ if ( value == null ) {
11
+ return undefined ;
12
+ }
13
+ if ( typeof value === "object" && "__type" in value ) {
14
+ delete value . __type ;
15
+ }
16
+ return expectUnion ( value ) ;
17
+ } ;
You can’t perform that action at this time.
0 commit comments