in codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/DocumentClientCommandGenerator.java [106:195]
public void run() {
Path servicePath = Paths.get(".", DocumentClientUtils.CLIENT_NAME);
String configType = DocumentClientUtils.CLIENT_CONFIG_NAME;
// Note: using addImport would register these dependencies on the dynamodb client, which must be avoided.
writer.write("""
import { %s as %s } from "%s";
""".formatted(
clientCommandClassName,
clientCommandLocalName,
AwsDependency.CLIENT_DYNAMODB_PEER.getPackageName()
)
);
// Add required imports.
writer.addRelativeImport(configType, configType, servicePath);
writer.addImport(
"DynamoDBDocumentClientCommand",
"DynamoDBDocumentClientCommand",
"./baseCommand/DynamoDBDocumentClientCommand"
);
writer.addImport("Command", "$Command", TypeScriptDependency.AWS_SMITHY_CLIENT);
writer.writeDocs("@public");
writer.write("export { DynamoDBDocumentClientCommand, $$Command };");
generateInputAndOutputTypes();
String ioTypes = String.join(", ", new String[]{
inputTypeName,
outputTypeName,
"__" + originalInputTypeName,
"__" + originalOutputTypeName
});
String name = DocumentClientUtils.getModifiedName(symbol.getName());
writer.writeDocs(DocumentClientUtils.getCommandDocs(symbol.getName())
+ "\n\n@public"
);
writer.openBlock(
"export class $L extends DynamoDBDocumentClientCommand<" + ioTypes + ", $L> {",
"}",
name,
configType,
() -> {
// Section for adding custom command properties.
writer.pushState(COMMAND_PROPERTIES_SECTION);
writer.openBlock("protected readonly $L = {", "};", COMMAND_INPUT_KEYNODES, () -> {
writeKeyNodes(inputMembersWithAttr);
});
writer.openBlock("protected readonly $L = {", "};", COMMAND_OUTPUT_KEYNODES, () -> {
writeKeyNodes(outputMembersWithAttr);
});
writer.popState();
writer.write("");
writer.write("protected readonly clientCommand: $L;", clientCommandLocalName);
writer.write(
"public readonly middlewareStack: MiddlewareStack<$L>;",
inputTypeName + " | __" + originalInputTypeName
+ ", \n" + outputTypeName + " | __" + originalOutputTypeName
);
writer.write("");
generateCommandConstructor();
writer.write("");
generateCommandMiddlewareResolver(configType);
// Hook for adding more methods to the command.
writer.pushState(COMMAND_BODY_EXTRA_SECTION).popState();
}
);
// Note: using addImport would register these dependencies on the dynamodb client, which must be avoided.
writer.write("");
orderedUncheckedImports.forEach((dep, symbols) -> {
writer.openBlock("import type {", """
} from "%s";
""".formatted(dep), () -> {
symbols.forEach((externalName, localName) -> {
if (externalName.equals(localName)) {
writer.writeInline(localName).write(",");
} else {
writer.write("""
%s as %s,
""".formatted(externalName, localName));
}
});
});
});