Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ CHANGELOG.md
**/*.hbs
**/*/report.md
clients/*/src/endpoint/ruleset.ts
packages/nested-clients/src/submodules/*/endpoint/ruleset.ts
**/*.java
packages/nested-clients/src/submodules/*/endpoint/ruleset.ts
7 changes: 3 additions & 4 deletions codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This package is used to build each client in the SDK.

The code generation stack is made up of 3 components:

1. [Smithy](https://github.com/smithy-lang/smithy) - the core libraries for code generation. They are not intended to contain anything specific to TypeScript or AWS SDKs.
2. [Smithy-TypeScript](https://github.com/awslabs/smithy-typescript) - This uses Smithy to generate code for the TypeScript (JavaScript) language runtimes. While this is maintained by AWS, it is not intended to contain anything specific to AWS.
3. [Smithy-AWS-TypeScript](https://github.com/aws/aws-sdk-js-v3/tree/docs/readme/codegen) - This is the component here in the AWS SDK for JavaScript (v3) repository. It uses the two upstream components, Smithy and Smithy-TypeScript, to generate the AWS SDK for JavaScript (v3). Anything specific to AWS should only be found in this package.
1. [Smithy](https://github.com/smithy-lang/smithy) - the core libraries for code generation. They are not intended to contain anything specific to TypeScript or AWS SDKs.
2. [Smithy-TypeScript](https://github.com/awslabs/smithy-typescript) - This uses Smithy to generate code for the TypeScript (JavaScript) language runtimes. While this is maintained by AWS, it is not intended to contain anything specific to AWS.
3. [Smithy-AWS-TypeScript](https://github.com/aws/aws-sdk-js-v3/tree/docs/readme/codegen) - This is the component here in the AWS SDK for JavaScript (v3) repository. It uses the two upstream components, Smithy and Smithy-TypeScript, to generate the AWS SDK for JavaScript (v3). Anything specific to AWS should only be found in this package.

## Building

Expand All @@ -16,7 +16,6 @@ By running `./gradlew :sdk-codegen:build`, this package will:
model that represents a service to generate.

2. Generate a `smithy-build.json` file.

- For each model, a projection is created that uses the filename without
".json" as the name of the projection.
- An `imports` value is added that imports the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@ public void addConfigInterfaceFields(
if (isAwsService(settings, model)) {
ServiceShape service = settings.getService(model);
if (hasAccountIdEndpointParam(service)) {
writer.addImportSubmodule("AccountIdEndpointMode", null,
AwsDependency.AWS_SDK_CORE, "/account-id-endpoint");
writer.writeDocs("Defines if the AWS AccountId will be used for endpoint routing.");
writer.write("accountIdEndpointMode?: AccountIdEndpointMode | "
+ "__Provider<AccountIdEndpointMode>;\n");
writer.addImportSubmodule("resolveAccountIdEndpointModeConfig", null,
AwsDependency.AWS_SDK_CORE, "/account-id-endpoint");
writer.addImportSubmodule(
"AccountIdEndpointMode",
null,
AwsDependency.AWS_SDK_CORE,
"/account-id-endpoint"
);
writer.writeDocs("Defines if the AWS AccountId will be used for endpoint routing.");
writer.write(
"accountIdEndpointMode?: AccountIdEndpointMode | " + "__Provider<AccountIdEndpointMode>;\n"
);
writer.addImportSubmodule(
"resolveAccountIdEndpointModeConfig",
null,
AwsDependency.AWS_SDK_CORE,
"/account-id-endpoint"
);
}
}
}
Expand All @@ -75,21 +84,31 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
switch (target) {
case BROWSER:
runtimeConfigs.put("accountIdEndpointMode", writer -> {
writer.addImportSubmodule("DEFAULT_ACCOUNT_ID_ENDPOINT_MODE", null,
writer.addImportSubmodule(
"DEFAULT_ACCOUNT_ID_ENDPOINT_MODE",
null,
AwsDependency.AWS_SDK_CORE,
"/account-id-endpoint");
"/account-id-endpoint"
);
writer.write("(() => Promise.resolve(DEFAULT_ACCOUNT_ID_ENDPOINT_MODE))");
});
break;
case NODE:
runtimeConfigs.put("accountIdEndpointMode", writer -> {
writer.addImport("loadConfig", "loadNodeConfig",
TypeScriptDependency.NODE_CONFIG_PROVIDER);
writer.addImportSubmodule("NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS",
null, AwsDependency.AWS_SDK_CORE,
"/account-id-endpoint");
writer.addImport(
"loadConfig",
"loadNodeConfig",
TypeScriptDependency.NODE_CONFIG_PROVIDER
);
writer.addImportSubmodule(
"NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS",
null,
AwsDependency.AWS_SDK_CORE,
"/account-id-endpoint"
);
writer.write(
"loadNodeConfig(NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS, loaderConfig)");
"loadNodeConfig(NODE_ACCOUNT_ID_ENDPOINT_MODE_CONFIG_OPTIONS, loaderConfig)"
);
});
break;
default:
Expand All @@ -106,33 +125,27 @@ public Map<String, Consumer<TypeScriptWriter>> getRuntimeConfigWriters(
@Override
public List<RuntimeClientPlugin> getClientPlugins() {
return List.of(
RuntimeClientPlugin.builder()
.inputConfig(
Symbol.builder()
.namespace(
AwsDependency.AWS_SDK_CORE.getPackageName() + "/account-id-endpoint", "/"
)
.name("AccountIdEndpointModeInputConfig")
.build()
)
.resolvedConfig(
Symbol.builder()
.namespace(
AwsDependency.AWS_SDK_CORE.getPackageName() + "/account-id-endpoint", "/"
)
.name("AccountIdEndpointModeResolvedConfig")
.build()
)
.resolveFunction(
Symbol.builder()
.namespace(
AwsDependency.AWS_SDK_CORE.getPackageName() + "/account-id-endpoint", "/"
)
.name("resolveAccountIdEndpointModeConfig")
.build()
)
.servicePredicate((m, s) -> hasAccountIdEndpointParam(s))
.build()
RuntimeClientPlugin.builder()
.inputConfig(
Symbol.builder()
.namespace(AwsDependency.AWS_SDK_CORE.getPackageName() + "/account-id-endpoint", "/")
.name("AccountIdEndpointModeInputConfig")
.build()
)
.resolvedConfig(
Symbol.builder()
.namespace(AwsDependency.AWS_SDK_CORE.getPackageName() + "/account-id-endpoint", "/")
.name("AccountIdEndpointModeResolvedConfig")
.build()
)
.resolveFunction(
Symbol.builder()
.namespace(AwsDependency.AWS_SDK_CORE.getPackageName() + "/account-id-endpoint", "/")
.name("resolveAccountIdEndpointModeConfig")
.build()
)
.servicePredicate((m, s) -> hasAccountIdEndpointParam(s))
.build()
);
}

Expand All @@ -141,7 +154,7 @@ private boolean hasAccountIdEndpointParam(ServiceShape service) {
if (endpointRuleSetTrait.isPresent()) {
RuleSetParameterFinder ruleSetParameterFinder = new RuleSetParameterFinder(service);
if (ruleSetParameterFinder.getBuiltInParams().containsKey("AccountIdEndpointMode")) {
return true;
return true;
}
}
return false;
Expand Down
Loading
Loading