Skip to content

Commit a2538ab

Browse files
committed
chore(codegen): add react-native-get-random-values polyfill
WIP as TypeScript asks for declaration file for module 'react-native-get-random-values'
1 parent 54012f2 commit a2538ab

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsDependency.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public enum AwsDependency implements SymbolDependencyContainer {
5555
XML_PARSER(NORMAL_DEPENDENCY, "fast-xml-parser", "3.19.0"),
5656
UUID_GENERATOR(NORMAL_DEPENDENCY, "uuid", "^8.3.2"),
5757
UUID_GENERATOR_TYPES(DEV_DEPENDENCY, "@types/uuid", "^8.3.0"),
58+
REACT_NATIVE_GET_RANDOM_VALUES(NORMAL_DEPENDENCY, "react-native-get-random-values", "^1.6.0"),
5859
MIDDLEWARE_EVENTSTREAM(NORMAL_DEPENDENCY, "@aws-sdk/middleware-eventstream", "^1.0.0-rc.1"),
5960
AWS_SDK_EVENTSTREAM_HANDLER_NODE(NORMAL_DEPENDENCY, "@aws-sdk/eventstream-handler-node", "^1.0.0-rc.1"),
6061
TRANSCRIBE_STREAMING_MIDDLEWARE(NORMAL_DEPENDENCY, "@aws-sdk/middleware-sdk-transcribe-streaming",

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsProtocolUtils.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ static void addItempotencyAutofillImport(GenerationContext context) {
230230
// Include the uuid package and import the v4 function as our more clearly named alias.
231231
writer.addDependency(AwsDependency.UUID_GENERATOR);
232232
writer.addDependency(AwsDependency.UUID_GENERATOR_TYPES);
233+
// Polyfill for react-native https://github.com/uuidjs/uuid#getrandomvalues-not-supported
234+
writer.addDependency(AwsDependency.REACT_NATIVE_GET_RANDOM_VALUES);
235+
writer.addImport("getRandomValues", "getRandomValues", "react-native-get-random-values");
233236
writer.addImport("v4", "generateIdempotencyToken", "uuid");
234237
});
235238
}

0 commit comments

Comments
 (0)