@@ -111,6 +111,29 @@ 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+ xmlNamespace: $S,
119+ version: $S,
120+ serviceTarget: $S,
121+ awsQueryCompatible: $L,""" ,
122+ """
123+ }""" ,
124+ namespace ,
125+ xmlns ,
126+ settings .getService (model ).getVersion (),
127+ rpcTarget ,
128+ awsQueryCompat ,
129+ () -> {
130+ if (CUSTOMIZATIONS .containsKey (settings .getService ())) {
131+ CUSTOMIZATIONS .get (settings .getService ()).accept (writer );
132+ }
133+ }
134+ );
135+ };
136+
114137 switch (target ) {
115138 case SHARED :
116139 if (Objects .equals (settings .getProtocol (), RestXmlTrait .ID )) {
@@ -119,61 +142,37 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
119142 writer .addImportSubmodule (
120143 "AwsRestXmlProtocol" , null ,
121144 AwsDependency .AWS_SDK_CORE , "/protocols" );
122- writer .write ("""
123- new AwsRestXmlProtocol({
124- defaultNamespace: $S,
125- xmlNamespace: $S,
126- })""" ,
127- namespace ,
128- xmlns
129- );
130- }
145+ writer .write ("AwsRestXmlProtocol" );
146+ },
147+ "protocolSettings" , typeScriptWriterConsumer
131148 );
132149 } else if (Objects .equals (settings .getProtocol (), AwsQueryTrait .ID )) {
133150 return MapUtils .of (
134151 "protocol" , writer -> {
135152 writer .addImportSubmodule (
136153 "AwsQueryProtocol" , null ,
137154 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- }
155+ writer .write ("AwsQueryProtocol" );
156+ },
157+ "protocolSettings" , typeScriptWriterConsumer
150158 );
151159 } else if (Objects .equals (settings .getProtocol (), Ec2QueryTrait .ID )) {
152160 return MapUtils .of (
153161 "protocol" , writer -> {
154162 writer .addImportSubmodule (
155163 "AwsEc2QueryProtocol" , null ,
156164 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- }
165+ writer .write ("AwsEc2QueryProtocol" );
166+ },
167+ "protocolSettings" , typeScriptWriterConsumer
169168 );
170169 } else if (Objects .equals (settings .getProtocol (), RestJson1Trait .ID )) {
171170 return MapUtils .of (
172171 "protocol" , writer -> {
173172 writer .addImportSubmodule (
174173 "AwsRestJsonProtocol" , null ,
175174 AwsDependency .AWS_SDK_CORE , "/protocols" );
176- writer .write ("new AwsRestJsonProtocol({ defaultNamespace: $S })" , namespace );
175+ writer .write ("AwsRestJsonProtocol" );
177176 }
178177 );
179178 } else if (Objects .equals (settings .getProtocol (), AwsJson1_0Trait .ID )) {
@@ -182,49 +181,19 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
182181 writer .addImportSubmodule (
183182 "AwsJson1_0Protocol" , null ,
184183 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- }
184+ writer .write ("AwsJson1_0Protocol" );
185+ },
186+ "protocolSettings" , typeScriptWriterConsumer
203187 );
204188 } else if (Objects .equals (settings .getProtocol (), AwsJson1_1Trait .ID )) {
205189 return MapUtils .of (
206190 "protocol" , writer -> {
207191 writer .addImportSubmodule (
208192 "AwsJson1_1Protocol" , null ,
209193 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- }
194+ writer .write ("AwsJson1_1Protocol" );
195+ },
196+ "protocolSettings" , typeScriptWriterConsumer
228197 );
229198 } else if (Objects .equals (settings .getProtocol (), Rpcv2CborTrait .ID )) {
230199 return MapUtils .of (
@@ -234,14 +203,10 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
234203 AwsDependency .AWS_SDK_CORE , "/protocols" );
235204 writer .write (
236205 """
237- new AwsSmithyRpcV2CborProtocol({
238- defaultNamespace: $S,
239- awsQueryCompatible: $L,
240- })""" ,
241- namespace ,
242- awsQueryCompat
206+ AwsSmithyRpcV2CborProtocol"""
243207 );
244- }
208+ },
209+ "protocolSettings" , typeScriptWriterConsumer
245210 );
246211 }
247212 case BROWSER :
0 commit comments