Skip to content

Commit

Permalink
fix: add uuid types when adding uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe committed Oct 8, 2024
1 parent 205cefb commit 86e6785
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public enum TypeScriptDependency implements Dependency {

NODE_CONFIG_PROVIDER("dependencies", "@smithy/node-config-provider", false),

UUID_TYPES("dependencies", "@types/uuid", "^9.0.1", false),
UUID("dependencies", "uuid", "^9.0.1", false),

// Conditionally added when httpChecksumRequired trait exists
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,9 @@ private void writeRequestQueryParam(

boolean isIdempotencyToken = binding.getMember().hasTrait(IdempotencyTokenTrait.class);
if (isIdempotencyToken) {
writer.addImport("v4", "generateIdempotencyToken", TypeScriptDependency.UUID);
writer
.addDependency(TypeScriptDependency.UUID_TYPES)
.addImport("v4", "generateIdempotencyToken", TypeScriptDependency.UUID);
}
boolean isRequired = binding.getMember().isRequired();
String idempotencyComponent = (isIdempotencyToken && !isRequired) ? " ?? generateIdempotencyToken()" : "";
Expand Down Expand Up @@ -1013,6 +1015,7 @@ private void writeNormalHeader(GenerationContext context, HttpBinding binding) {
boolean isIdempotencyToken = binding.getMember().hasTrait(IdempotencyTokenTrait.class);
if (isIdempotencyToken) {
context.getWriter()
.addDependency(TypeScriptDependency.UUID_TYPES)
.addImport("v4", "generateIdempotencyToken", TypeScriptDependency.UUID);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ protected void serializeStructure(ProtocolGenerator.GenerationContext context, S
boolean isUnaryCall = UnaryFunctionCall.check(valueExpression);

if (memberShape.hasTrait(IdempotencyTokenTrait.class)) {
writer.addImport("v4", "generateIdempotencyToken", TypeScriptDependency.UUID);
writer
.addDependency(TypeScriptDependency.UUID_TYPES)
.addImport("v4", "generateIdempotencyToken", TypeScriptDependency.UUID);

writer.write("'$L': [true, _ => _ ?? generateIdempotencyToken()],", memberName);
} else {
Expand Down

0 comments on commit 86e6785

Please sign in to comment.