Skip to content

Commit

Permalink
Remove AWS-specfic default user agent (#234)
Browse files Browse the repository at this point in the history
Current default user agent string is AWS specific. So the customization
is moved to AWS JS SDK.
  • Loading branch information
AllanZhengYP authored Dec 15, 2020
1 parent 5778e41 commit 23d5953
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ final class RuntimeConfigGenerator {
writer.addImport("toUtf8", "toUtf8",
TypeScriptDependency.AWS_SDK_UTIL_UTF8_NODE.packageName);
writer.write("utf8Encoder: toUtf8,");
},
"defaultUserAgent", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_UTIL_USER_AGENT_NODE);
writer.addImport("defaultUserAgent", "defaultUserAgent",
TypeScriptDependency.AWS_SDK_UTIL_USER_AGENT_NODE.packageName);
writer.addDefaultImport("packageInfo", "./package.json");
writer.write("defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),");
}
);
private final Map<String, Consumer<TypeScriptWriter>> browserRuntimeConfigDefaults = MapUtils.of(
Expand Down Expand Up @@ -157,13 +150,6 @@ final class RuntimeConfigGenerator {
writer.addImport("toUtf8", "toUtf8",
TypeScriptDependency.AWS_SDK_UTIL_UTF8_BROWSER.packageName);
writer.write("utf8Encoder: toUtf8,");
},
"defaultUserAgent", writer -> {
writer.addDependency(TypeScriptDependency.AWS_SDK_UTIL_USER_AGENT_BROWSER);
writer.addImport("defaultUserAgent", "defaultUserAgent",
TypeScriptDependency.AWS_SDK_UTIL_USER_AGENT_BROWSER.packageName);
writer.addDefaultImport("packageInfo", "./package.json");
writer.write("defaultUserAgent: defaultUserAgent(packageInfo.name, packageInfo.version),");
}
);
private final Map<String, Consumer<TypeScriptWriter>> reactNativeRuntimeConfigDefaults = MapUtils.of(
Expand All @@ -178,11 +164,6 @@ final class RuntimeConfigGenerator {
writer.addImport("parseUrl", "parseUrl",
TypeScriptDependency.AWS_SDK_URL_PARSER_NODE.packageName);
writer.write("urlParser: parseUrl,");
},
"defaultUserAgent", writer -> {
writer.addDefaultImport("packageInfo", "./package.json");
writer.write("defaultUserAgent: "
+ "`aws-sdk-js-v3-react-native-$${packageInfo.name}/$${packageInfo.version}`,");
}
);
private final Map<String, Consumer<TypeScriptWriter>> sharedRuntimeConfigDefaults = MapUtils.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,6 @@ private void generateClientDefaults() {
writer.writeDocs("The function that will be used to convert binary data to a UTF-8 encoded string");
writer.write("utf8Encoder?: __Encoder;\n");

writer.writeDocs("The string that will be used to populate default value in 'User-Agent' header");
writer.write("defaultUserAgent?: string;\n");

writer.writeDocs("The runtime environment");
writer.write("runtime?: string;\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public enum TypeScriptDependency implements SymbolDependencyContainer {
AWS_SDK_UTIL_BODY_LENGTH_BROWSER("dependencies", "@aws-sdk/util-body-length-browser", "1.0.0-rc.0", true),
AWS_SDK_UTIL_BODY_LENGTH_NODE("dependencies", "@aws-sdk/util-body-length-node", "1.0.0-rc.0", true),

AWS_SDK_UTIL_USER_AGENT_BROWSER("dependencies", "@aws-sdk/util-user-agent-browser", "1.0.0-rc.0", true),
AWS_SDK_UTIL_USER_AGENT_NODE("dependencies", "@aws-sdk/util-user-agent-node", "1.0.0-rc.0", true),

AWS_SDK_UTIL_UTF8_BROWSER("dependencies", "@aws-sdk/util-utf8-browser", "1.0.0-rc.0", true),
AWS_SDK_UTIL_UTF8_NODE("dependencies", "@aws-sdk/util-utf8-node", "1.0.0-rc.0", true),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,20 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(

// Does the runtimeConfig.ts file expand the template properties properly?
String runtimeConfigContents = manifest.getFileString("runtimeConfig.ts").get();
assertThat(runtimeConfigContents, containsString("import packageInfo from \"./package.json\""));
assertThat(runtimeConfigContents,
containsString("import { ClientDefaults } from \"./ExampleClient\";"));
assertThat(runtimeConfigContents, containsString("syn: 'ack2',"));
assertThat(runtimeConfigSharedContents, containsString("foo: 'bar',"));

// Does the runtimeConfig.browser.ts file expand the template properties properly?
String runtimeConfigBrowserContents = manifest.getFileString("runtimeConfig.browser.ts").get();
assertThat(runtimeConfigContents, containsString("import packageInfo from \"./package.json\""));
assertThat(runtimeConfigBrowserContents,
containsString("import { ClientDefaults } from \"./ExampleClient\";"));
assertThat(runtimeConfigContents, containsString("syn: 'ack2',"));
assertThat(runtimeConfigSharedContents, containsString("foo: 'bar',"));

// Does the runtimeConfig.native.ts file expand the browser template properties properly?
String runtimeConfigNativeContents = manifest.getFileString("runtimeConfig.native.ts").get();
assertThat(runtimeConfigContents, containsString("import packageInfo from \"./package.json\""));
assertThat(runtimeConfigNativeContents,
containsString("import { ClientDefaults } from \"./ExampleClient\";"));
assertThat(runtimeConfigNativeContents,
Expand Down

0 comments on commit 23d5953

Please sign in to comment.