|
15 | 15 |
|
16 | 16 | package software.amazon.smithy.aws.typescript.codegen;
|
17 | 17 |
|
| 18 | +import static software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin.Convention; |
| 19 | + |
18 | 20 | import java.util.List;
|
19 |
| -import software.amazon.smithy.codegen.core.Symbol; |
20 |
| -import software.amazon.smithy.codegen.core.SymbolReference; |
21 | 21 | import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin;
|
22 | 22 | import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
|
23 | 23 | import software.amazon.smithy.utils.ListUtils;
|
|
27 | 27 | */
|
28 | 28 | public class AddBuiltinPlugins implements TypeScriptIntegration {
|
29 | 29 |
|
| 30 | + private static final String CONFIG_RESOLVER_VERSION = "^0.1.0-preview.5"; |
| 31 | + |
30 | 32 | @Override
|
31 | 33 | public List<RuntimeClientPlugin> getClientPlugins() {
|
| 34 | + // Note that order is significant because configurations might |
| 35 | + // rely on previously resolved values. |
32 | 36 | return ListUtils.of(
|
33 |
| - generatePlugin("Region", "@aws-sdk/config-resolver"), |
34 |
| - generatePlugin("AwsAuth", "@aws-sdk/signing-middleware"), |
35 |
| - generatePlugin("Endpoints", "@aws-sdk/config-resolver"), |
36 |
| - generatePlugin("Retry", "@aws-sdk/retry-middleware"), |
37 |
| - generatePlugin("UserAgent", "@aws-sdk/middleware-user-agent") |
| 37 | + RuntimeClientPlugin.builder() |
| 38 | + .withConventions("@aws-sdk/config-resolver", CONFIG_RESOLVER_VERSION, "Region", |
| 39 | + Convention.HAS_CONFIG) |
| 40 | + .build(), |
| 41 | + RuntimeClientPlugin.builder() |
| 42 | + .withConventions("@aws-sdk/middleware-signing", "^0.1.0-preview.7", "AwsAuth") |
| 43 | + .build(), |
| 44 | + RuntimeClientPlugin.builder() |
| 45 | + .withConventions("@aws-sdk/config-resolver", CONFIG_RESOLVER_VERSION, "Endpoints", |
| 46 | + Convention.HAS_CONFIG) |
| 47 | + .build(), |
| 48 | + RuntimeClientPlugin.builder() |
| 49 | + .withConventions("@aws-sdk/middleware-retry", "^0.1.0-preview.5", "Retry") |
| 50 | + .build(), |
| 51 | + RuntimeClientPlugin.builder() |
| 52 | + .withConventions("@aws-sdk/middleware-user-agent", "^0.1.0-preview.1", "UserAgent") |
| 53 | + .build(), |
| 54 | + RuntimeClientPlugin.builder() |
| 55 | + .withConventions("@aws-sdk/middleware-content-length", "^0.1.0-preview.5", "ContentLength", |
| 56 | + Convention.HAS_MIDDLEWARE) |
| 57 | + .build() |
38 | 58 | );
|
39 | 59 | }
|
40 |
| - |
41 |
| - private static RuntimeClientPlugin generatePlugin(String symbolName, String symbolNamespace) { |
42 |
| - SymbolReference symbolReference = SymbolReference.builder() |
43 |
| - .symbol(Symbol.builder().name(symbolName).namespace(symbolNamespace, "/").build()) |
44 |
| - .build(); |
45 |
| - return new RuntimeClientPlugin() { |
46 |
| - @Override |
47 |
| - public SymbolReference getSymbol() { |
48 |
| - return symbolReference; |
49 |
| - } |
50 |
| - |
51 |
| - @Override |
52 |
| - public boolean hasConfig() { |
53 |
| - return true; |
54 |
| - } |
55 |
| - |
56 |
| - @Override |
57 |
| - public boolean hasMiddleware() { |
58 |
| - return true; |
59 |
| - } |
60 |
| - }; |
61 |
| - } |
62 | 60 | }
|
0 commit comments