Skip to content

Commit

Permalink
chore: fix codegen region provider and default credential provider in…
Browse files Browse the repository at this point in the history
… browser
  • Loading branch information
AllanZhengYP committed Dec 23, 2020
1 parent 99fcd53 commit 833b3c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,14 @@ private Map<String, Consumer<TypeScriptWriter>> getDefaultConfig(LanguageTarget
return MapUtils.of(
"region", writer -> {
writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY);
writer.addImport("invalidAsyncFunction", "invalidAsyncFunction",
writer.addImport("invalidProvider", "invalidProvider",
TypeScriptDependency.INVALID_DEPENDENCY.packageName);
writer.write("region: invalidAsyncFunction(\"Region is missing\") as any,");
writer.write("region: invalidProvider(\"Region is missing\"),");
},
"credentialDefaultProvider", writer -> {
writer.addDependency(TypeScriptDependency.INVALID_DEPENDENCY);
writer.addImport("invalidAsyncFunction", "invalidAsyncFunction",
TypeScriptDependency.INVALID_DEPENDENCY.packageName);
writer.write(
"credentialDefaultProvider: invalidAsyncFunction(\"Credential"
+ "is missing\") as any,");
"credentialDefaultProvider: (_: unknown) => () => Promise.reject(new Error("
+ "\"Credential is missing\")),");
},
"maxAttempts", writer -> {
writer.addDependency(TypeScriptDependency.MIDDLEWARE_RETRY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private static boolean operationUsesAwsAuth(Model model, ServiceShape service, O
}

private static boolean hasOptionalAuthOperation(Model model, ServiceShape service) {
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
TopDownIndex topDownIndex = TopDownIndex.of(model);
Set<OperationShape> operations = topDownIndex.getContainedOperations(service);
for (OperationShape operation : operations) {
if (operation.getTrait(OptionalAuthTrait.class).isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void addsAwsRuntimeConfigSettings() {

// Check that both the config files were updated.
assertThat(manifest.getFileString("runtimeConfig.ts").get(), containsString("credentialDefaultProvider"));
assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("invalidAsyncFunction"));
assertThat(manifest.getFileString("runtimeConfig.browser.ts").get(), containsString("invalidProvider"));

// Check that the dependency interface was updated.
assertThat(manifest.getFileString("NotSameClient.ts").get(), containsString("credentialDefaultProvider?"));
Expand Down

0 comments on commit 833b3c6

Please sign in to comment.