@@ -111,6 +111,33 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
111111 .orElse ("" );
112112 String awsQueryCompat = settings .getService (model ).hasTrait (AwsQueryCompatibleTrait .class ) ? "true" : "false" ;
113113
114+ Consumer <TypeScriptWriter > typeScriptWriterConsumer = (TypeScriptWriter writer ) -> {
115+ writer .openBlock ("""
116+ {
117+ defaultNamespace: $S,""" ,
118+ """
119+ }""" ,
120+ namespace ,
121+ () -> {
122+ if (!xmlns .isEmpty ()) {
123+ writer .write ("xmlNamespace: $S," , xmlns );
124+ }
125+ String version = settings .getService (model ).getVersion ();
126+ if (!version .isEmpty ()) {
127+ writer .write ("version: $S," , version );
128+ }
129+ writer .write ("serviceTarget: $S," , rpcTarget );
130+ if (awsQueryCompat .equals ("true" )) {
131+ writer .write ("awsQueryCompat: $L," , awsQueryCompat );
132+ }
133+
134+ if (CUSTOMIZATIONS .containsKey (settings .getService ())) {
135+ CUSTOMIZATIONS .get (settings .getService ()).accept (writer );
136+ }
137+ }
138+ );
139+ };
140+
114141 switch (target ) {
115142 case SHARED :
116143 if (Objects .equals (settings .getProtocol (), RestXmlTrait .ID )) {
@@ -119,61 +146,37 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
119146 writer .addImportSubmodule (
120147 "AwsRestXmlProtocol" , null ,
121148 AwsDependency .AWS_SDK_CORE , "/protocols" );
122- writer .write ("""
123- new AwsRestXmlProtocol({
124- defaultNamespace: $S,
125- xmlNamespace: $S,
126- })""" ,
127- namespace ,
128- xmlns
129- );
130- }
149+ writer .write ("AwsRestXmlProtocol" );
150+ },
151+ "protocolSettings" , typeScriptWriterConsumer
131152 );
132153 } else if (Objects .equals (settings .getProtocol (), AwsQueryTrait .ID )) {
133154 return MapUtils .of (
134155 "protocol" , writer -> {
135156 writer .addImportSubmodule (
136157 "AwsQueryProtocol" , null ,
137158 AwsDependency .AWS_SDK_CORE , "/protocols" );
138- writer .write (
139- """
140- new AwsQueryProtocol({
141- defaultNamespace: $S,
142- xmlNamespace: $S,
143- version: $S,
144- })""" ,
145- namespace ,
146- xmlns ,
147- settings .getService (model ).getVersion ()
148- );
149- }
159+ writer .write ("AwsQueryProtocol" );
160+ },
161+ "protocolSettings" , typeScriptWriterConsumer
150162 );
151163 } else if (Objects .equals (settings .getProtocol (), Ec2QueryTrait .ID )) {
152164 return MapUtils .of (
153165 "protocol" , writer -> {
154166 writer .addImportSubmodule (
155167 "AwsEc2QueryProtocol" , null ,
156168 AwsDependency .AWS_SDK_CORE , "/protocols" );
157- writer .write (
158- """
159- new AwsEc2QueryProtocol({
160- defaultNamespace: $S,
161- xmlNamespace: $S,
162- version: $S,
163- })""" ,
164- namespace ,
165- xmlns ,
166- settings .getService (model ).getVersion ()
167- );
168- }
169+ writer .write ("AwsEc2QueryProtocol" );
170+ },
171+ "protocolSettings" , typeScriptWriterConsumer
169172 );
170173 } else if (Objects .equals (settings .getProtocol (), RestJson1Trait .ID )) {
171174 return MapUtils .of (
172175 "protocol" , writer -> {
173176 writer .addImportSubmodule (
174177 "AwsRestJsonProtocol" , null ,
175178 AwsDependency .AWS_SDK_CORE , "/protocols" );
176- writer .write ("new AwsRestJsonProtocol({ defaultNamespace: $S })" , namespace );
179+ writer .write ("AwsRestJsonProtocol" );
177180 }
178181 );
179182 } else if (Objects .equals (settings .getProtocol (), AwsJson1_0Trait .ID )) {
@@ -182,49 +185,19 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
182185 writer .addImportSubmodule (
183186 "AwsJson1_0Protocol" , null ,
184187 AwsDependency .AWS_SDK_CORE , "/protocols" );
185- writer .openBlock (
186- """
187- new AwsJson1_0Protocol({
188- defaultNamespace: $S,
189- serviceTarget: $S,
190- awsQueryCompatible: $L,""" ,
191- """
192- })""" ,
193- namespace ,
194- rpcTarget ,
195- awsQueryCompat ,
196- () -> {
197- if (CUSTOMIZATIONS .containsKey (settings .getService ())) {
198- CUSTOMIZATIONS .get (settings .getService ()).accept (writer );
199- }
200- }
201- );
202- }
188+ writer .write ("AwsJson1_0Protocol" );
189+ },
190+ "protocolSettings" , typeScriptWriterConsumer
203191 );
204192 } else if (Objects .equals (settings .getProtocol (), AwsJson1_1Trait .ID )) {
205193 return MapUtils .of (
206194 "protocol" , writer -> {
207195 writer .addImportSubmodule (
208196 "AwsJson1_1Protocol" , null ,
209197 AwsDependency .AWS_SDK_CORE , "/protocols" );
210- writer .openBlock (
211- """
212- new AwsJson1_1Protocol({
213- defaultNamespace: $S,
214- serviceTarget: $S,
215- awsQueryCompatible: $L,""" ,
216- """
217- })""" ,
218- namespace ,
219- rpcTarget ,
220- awsQueryCompat ,
221- () -> {
222- if (CUSTOMIZATIONS .containsKey (settings .getService ())) {
223- CUSTOMIZATIONS .get (settings .getService ()).accept (writer );
224- }
225- }
226- );
227- }
198+ writer .write ("AwsJson1_1Protocol" );
199+ },
200+ "protocolSettings" , typeScriptWriterConsumer
228201 );
229202 } else if (Objects .equals (settings .getProtocol (), Rpcv2CborTrait .ID )) {
230203 return MapUtils .of (
@@ -234,14 +207,10 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
234207 AwsDependency .AWS_SDK_CORE , "/protocols" );
235208 writer .write (
236209 """
237- new AwsSmithyRpcV2CborProtocol({
238- defaultNamespace: $S,
239- awsQueryCompatible: $L,
240- })""" ,
241- namespace ,
242- awsQueryCompat
210+ AwsSmithyRpcV2CborProtocol"""
243211 );
244- }
212+ },
213+ "protocolSettings" , typeScriptWriterConsumer
245214 );
246215 }
247216 case BROWSER :
0 commit comments