Skip to content

Commit

Permalink
text blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Jun 20, 2023
1 parent fb4eabb commit e1e48c4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,16 @@ static void writeClientCommandBlobPayloadInputType(
writer.addImport("BlobTypes", null, TypeScriptDependency.AWS_SDK_TYPES);

writer.writeDocs("@public");
writer.openBlock("export type $LType = Omit<$T, $S> & {", "};",
writer.write(
"""
export type $LType = Omit<$T, $S> & {
$L: BlobTypes;
};
""",
typeName,
containerSymbol,
memberName,
() -> {
writer.write("$1L$2L: BlobTypes;", memberName, optionalSuffix);
}
memberName + optionalSuffix
);

writer.writeDocs("@public\n\nThe input for {@link " + commandName + "}.");
Expand All @@ -233,13 +236,16 @@ static void writeClientCommandBlobPayloadOutputType(
writer.addDependency(TypeScriptDependency.UTIL_STREAM);

writer.writeDocs("@public");
writer.openBlock("export type $LType = Omit<$T, $S> & {", "};",
writer.write(
"""
export type $LType = Omit<$T, $S> & {
$L: Uint8ArrayBlobAdapter;
};
""",
typeName,
containerSymbol,
memberName,
() -> {
writer.write("$1L$2L: Uint8ArrayBlobAdapter;", memberName, optionalSuffix);
}
memberName + optionalSuffix
);

writer.writeDocs("@public\n\nThe output of {@link " + commandName + "}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public void generateSharedComponents(GenerationContext context) {
generateDocumentBodyShapeSerializers(context, serializingDocumentShapes);
generateDocumentBodyShapeDeserializers(context, deserializingDocumentShapes);
HttpProtocolGeneratorUtils.generateMetadataDeserializer(context, getApplicationProtocol().getResponseType());
HttpProtocolGeneratorUtils.generateCollectBody(context);
HttpProtocolGeneratorUtils.generateCollectBodyString(context);
HttpProtocolGeneratorUtils.generateHttpBindingUtils(context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,26 +247,15 @@ static void generateMetadataDeserializer(GenerationContext context, SymbolRefere
writer.write("");
}

/**
* Imports a response body stream collector. This function converts the low-level response body stream to
* Uint8Array binary data.
*
* @param context The generation context.
*/
static void generateCollectBody(GenerationContext context) {
TypeScriptWriter writer = context.getWriter();
writer.addImport("collectBody", null, TypeScriptDependency.AWS_SMITHY_CLIENT);
}

/**
* Writes a function converting the low-level response body stream to utf-8 encoded string. It depends on
* response body stream collector {@link #generateCollectBody(GenerationContext)}.
* response body stream collector.
*
* @param context The generation context
*/
static void generateCollectBodyString(GenerationContext context) {
TypeScriptWriter writer = context.getWriter();

writer.addImport("collectBody", null, TypeScriptDependency.AWS_SMITHY_CLIENT);
writer.addImport("SerdeContext", "__SerdeContext", TypeScriptDependency.SMITHY_TYPES);
writer.write("// Encode Uint8Array data into string with utf-8.");
writer.write("const collectBodyString = (streamBody: any, context: __SerdeContext): Promise<string> => "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ public void generateSharedComponents(GenerationContext context) {
generateDocumentBodyShapeSerializers(context, serializingDocumentShapes);
generateDocumentBodyShapeDeserializers(context, deserializingDocumentShapes);
HttpProtocolGeneratorUtils.generateMetadataDeserializer(context, getApplicationProtocol().getResponseType());
HttpProtocolGeneratorUtils.generateCollectBody(context);
HttpProtocolGeneratorUtils.generateCollectBodyString(context);

TypeScriptWriter writer = context.getWriter();
Expand Down

0 comments on commit e1e48c4

Please sign in to comment.