Skip to content

Commit

Permalink
Support type definitions which are not available in v3 (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Jan 6, 2023
1 parent ac605d5 commit 915dcfe
Show file tree
Hide file tree
Showing 28 changed files with 995 additions and 96 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-apricots-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": minor
---

Support type definitions which are not available in v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import AWS = require("aws-sdk");

// Native types
const stringType: AWS.S3.AccountId = "string";
const booleanType: AWS.S3.BucketKeyEnabled = true;
const numberType: AWS.S3.ContentLength = 123;

// Date
const dateType: AWS.S3.CreationDate = new Date();

// Uint8Array
const blobType: AWS.RDSDataService._Blob = new Uint8Array();

// Arrays
const stringArray: AWS.S3.AllowedHeaders = ["string1", "string2"];
const booleanArray: AWS.RDSDataService.BooleanArray = [true, false];
const numberArray: AWS.RDSDataService.LongArray = [123, 456];
const blobArray: AWS.IoTFleetWise.NetworkFilesList = [new Uint8Array()];
const enumArray: AWS.S3.ChecksumAlgorithmList = ["CRC32"];
const structureArray: AWS.S3.Buckets = [{ Name: "bucketName" }];

// Maps
const stringMap: AWS.S3.Metadata = { key: "value" };
const booleanMap: AWS.APIGateway.MapOfStringToBoolean = { key: true };
const numberMap: AWS.SSM.AssociationStatusAggregatedCount = { key: 123 };
const structureMap: AWS.APIGateway.MapOfMethodSnapshot = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: AWS.SageMakerGeospatial.LinearRing = [[1, 2], [3, 4]];
const arrayNestedThrice: AWS.SageMakerGeospatial.LinearRings = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: AWS.SageMakerGeospatial.LinearRingsList = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: AWS.LexModelsV2.ConditionMap = { key: stringMap };
const mapNestedTwiceStruct: AWS.APIGateway.PathToMapOfMethodSnapshot = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: AWS.NetworkManager.FilterMap = { key: ["value"] };
const mapOfMapOfArrays: AWS.SecurityLake.AllDimensionsMap = { key: mapOfArrays };
const mapOfArrayOfMaps: AWS.DynamoDB.BatchGetResponseMap = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: AWS.APIGateway.MapOfKeyUsages = { key: [[1], [2]] };
const arrayOfMaps: AWS.SSM.InventoryItemEntryList = [stringMap];
const arrayOfMapOfArrays: AWS.SSM.TargetMaps = [mapOfArrays];
const arrayOfMapOfMapOfArrays: AWS.SecurityLake.RegionSourceTypesAccountsList = [mapOfMapOfArrays];
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import AWS_APIGateway = require("@aws-sdk/client-api-gateway");
import AWS_DynamoDB = require("@aws-sdk/client-dynamodb");
import AWS_S3 = require("@aws-sdk/client-s3");

// Native types
const stringType: string = "string";
const booleanType: boolean = true;
const numberType: number = 123;

// Date
const dateType: Date = new Date();

// Uint8Array
const blobType: Uint8Array = new Uint8Array();

// Arrays
const stringArray: Array<string> = ["string1", "string2"];
const booleanArray: Array<boolean> = [true, false];
const numberArray: Array<number> = [123, 456];
const blobArray: Array<Uint8Array> = [new Uint8Array()];
const enumArray: Array<AWS_S3.ChecksumAlgorithm> = ["CRC32"];
const structureArray: Array<AWS_S3.Bucket> = [{ Name: "bucketName" }];

// Maps
const stringMap: Record<string, string> = { key: "value" };
const booleanMap: Record<string, boolean> = { key: true };
const numberMap: Record<string, number> = { key: 123 };
const structureMap: Record<string, AWS_APIGateway.MethodSnapshot> = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: Array<Array<number>> = [[1, 2], [3, 4]];
const arrayNestedThrice: Array<Array<Array<number>>> = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: Array<Array<Array<Array<number>>>> = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: Record<string, Record<string, string>> = { key: stringMap };
const mapNestedTwiceStruct: Record<string, Record<string, AWS_APIGateway.MethodSnapshot>> = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: Record<string, Array<string>> = { key: ["value"] };
const mapOfMapOfArrays: Record<string, Record<string, Array<string>>> = { key: mapOfArrays };
const mapOfArrayOfMaps: Record<string, Array<Record<string, AWS_DynamoDB.AttributeValue>>> = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: Record<string, Array<Array<number>>> = { key: [[1], [2]] };
const arrayOfMaps: Array<Record<string, string>> = [stringMap];
const arrayOfMapOfArrays: Array<Record<string, Array<string>>> = [mapOfArrays];
const arrayOfMapOfMapOfArrays: Array<Record<string, Record<string, Array<string>>>> = [mapOfMapOfArrays];
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import AWS from "aws-sdk";

// Native types
const stringType: AWS.S3.AccountId = "string";
const booleanType: AWS.S3.BucketKeyEnabled = true;
const numberType: AWS.S3.ContentLength = 123;

// Date
const dateType: AWS.S3.CreationDate = new Date();

// Uint8Array
const blobType: AWS.RDSDataService._Blob = new Uint8Array();

// Arrays
const stringArray: AWS.S3.AllowedHeaders = ["string1", "string2"];
const booleanArray: AWS.RDSDataService.BooleanArray = [true, false];
const numberArray: AWS.RDSDataService.LongArray = [123, 456];
const blobArray: AWS.IoTFleetWise.NetworkFilesList = [new Uint8Array()];
const enumArray: AWS.S3.ChecksumAlgorithmList = ["CRC32"];
const structureArray: AWS.S3.Buckets = [{ Name: "bucketName" }];

// Maps
const stringMap: AWS.S3.Metadata = { key: "value" };
const booleanMap: AWS.APIGateway.MapOfStringToBoolean = { key: true };
const numberMap: AWS.SSM.AssociationStatusAggregatedCount = { key: 123 };
const structureMap: AWS.APIGateway.MapOfMethodSnapshot = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: AWS.SageMakerGeospatial.LinearRing = [[1, 2], [3, 4]];
const arrayNestedThrice: AWS.SageMakerGeospatial.LinearRings = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: AWS.SageMakerGeospatial.LinearRingsList = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: AWS.LexModelsV2.ConditionMap = { key: stringMap };
const mapNestedTwiceStruct: AWS.APIGateway.PathToMapOfMethodSnapshot = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: AWS.NetworkManager.FilterMap = { key: ["value"] };
const mapOfMapOfArrays: AWS.SecurityLake.AllDimensionsMap = { key: mapOfArrays };
const mapOfArrayOfMaps: AWS.DynamoDB.BatchGetResponseMap = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: AWS.APIGateway.MapOfKeyUsages = { key: [[1], [2]] };
const arrayOfMaps: AWS.SSM.InventoryItemEntryList = [stringMap];
const arrayOfMapOfArrays: AWS.SSM.TargetMaps = [mapOfArrays];
const arrayOfMapOfMapOfArrays: AWS.SecurityLake.RegionSourceTypesAccountsList = [mapOfMapOfArrays];
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import AWS_APIGateway from "@aws-sdk/client-api-gateway";
import AWS_DynamoDB from "@aws-sdk/client-dynamodb";
import AWS_S3 from "@aws-sdk/client-s3";

// Native types
const stringType: string = "string";
const booleanType: boolean = true;
const numberType: number = 123;

// Date
const dateType: Date = new Date();

// Uint8Array
const blobType: Uint8Array = new Uint8Array();

// Arrays
const stringArray: Array<string> = ["string1", "string2"];
const booleanArray: Array<boolean> = [true, false];
const numberArray: Array<number> = [123, 456];
const blobArray: Array<Uint8Array> = [new Uint8Array()];
const enumArray: Array<AWS_S3.ChecksumAlgorithm> = ["CRC32"];
const structureArray: Array<AWS_S3.Bucket> = [{ Name: "bucketName" }];

// Maps
const stringMap: Record<string, string> = { key: "value" };
const booleanMap: Record<string, boolean> = { key: true };
const numberMap: Record<string, number> = { key: 123 };
const structureMap: Record<string, AWS_APIGateway.MethodSnapshot> = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: Array<Array<number>> = [[1, 2], [3, 4]];
const arrayNestedThrice: Array<Array<Array<number>>> = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: Array<Array<Array<Array<number>>>> = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: Record<string, Record<string, string>> = { key: stringMap };
const mapNestedTwiceStruct: Record<string, Record<string, AWS_APIGateway.MethodSnapshot>> = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: Record<string, Array<string>> = { key: ["value"] };
const mapOfMapOfArrays: Record<string, Record<string, Array<string>>> = { key: mapOfArrays };
const mapOfArrayOfMaps: Record<string, Array<Record<string, AWS_DynamoDB.AttributeValue>>> = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: Record<string, Array<Array<number>>> = { key: [[1], [2]] };
const arrayOfMaps: Array<Record<string, string>> = [stringMap];
const arrayOfMapOfArrays: Array<Record<string, Array<string>>> = [mapOfArrays];
const arrayOfMapOfMapOfArrays: Array<Record<string, Record<string, Array<string>>>> = [mapOfMapOfArrays];
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const AWS = require("aws-sdk");

// Native types
const stringType: AWS.S3.AccountId = "string";
const booleanType: AWS.S3.BucketKeyEnabled = true;
const numberType: AWS.S3.ContentLength = 123;

// Date
const dateType: AWS.S3.CreationDate = new Date();

// Uint8Array
const blobType: AWS.RDSDataService._Blob = new Uint8Array();

// Arrays
const stringArray: AWS.S3.AllowedHeaders = ["string1", "string2"];
const booleanArray: AWS.RDSDataService.BooleanArray = [true, false];
const numberArray: AWS.RDSDataService.LongArray = [123, 456];
const blobArray: AWS.IoTFleetWise.NetworkFilesList = [new Uint8Array()];
const enumArray: AWS.S3.ChecksumAlgorithmList = ["CRC32"];
const structureArray: AWS.S3.Buckets = [{ Name: "bucketName" }];

// Maps
const stringMap: AWS.S3.Metadata = { key: "value" };
const booleanMap: AWS.APIGateway.MapOfStringToBoolean = { key: true };
const numberMap: AWS.SSM.AssociationStatusAggregatedCount = { key: 123 };
const structureMap: AWS.APIGateway.MapOfMethodSnapshot = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: AWS.SageMakerGeospatial.LinearRing = [[1, 2], [3, 4]];
const arrayNestedThrice: AWS.SageMakerGeospatial.LinearRings = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: AWS.SageMakerGeospatial.LinearRingsList = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: AWS.LexModelsV2.ConditionMap = { key: stringMap };
const mapNestedTwiceStruct: AWS.APIGateway.PathToMapOfMethodSnapshot = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: AWS.NetworkManager.FilterMap = { key: ["value"] };
const mapOfMapOfArrays: AWS.SecurityLake.AllDimensionsMap = { key: mapOfArrays };
const mapOfArrayOfMaps: AWS.DynamoDB.BatchGetResponseMap = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: AWS.APIGateway.MapOfKeyUsages = { key: [[1], [2]] };
const arrayOfMaps: AWS.SSM.InventoryItemEntryList = [stringMap];
const arrayOfMapOfArrays: AWS.SSM.TargetMaps = [mapOfArrays];
const arrayOfMapOfMapOfArrays: AWS.SecurityLake.RegionSourceTypesAccountsList = [mapOfMapOfArrays];
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const AWS_APIGateway = require("@aws-sdk/client-api-gateway"), AWS_DynamoDB = require("@aws-sdk/client-dynamodb"), AWS_S3 = require("@aws-sdk/client-s3");

// Native types
const stringType: string = "string";
const booleanType: boolean = true;
const numberType: number = 123;

// Date
const dateType: Date = new Date();

// Uint8Array
const blobType: Uint8Array = new Uint8Array();

// Arrays
const stringArray: Array<string> = ["string1", "string2"];
const booleanArray: Array<boolean> = [true, false];
const numberArray: Array<number> = [123, 456];
const blobArray: Array<Uint8Array> = [new Uint8Array()];
const enumArray: Array<AWS_S3.ChecksumAlgorithm> = ["CRC32"];
const structureArray: Array<AWS_S3.Bucket> = [{ Name: "bucketName" }];

// Maps
const stringMap: Record<string, string> = { key: "value" };
const booleanMap: Record<string, boolean> = { key: true };
const numberMap: Record<string, number> = { key: 123 };
const structureMap: Record<string, AWS_APIGateway.MethodSnapshot> = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: Array<Array<number>> = [[1, 2], [3, 4]];
const arrayNestedThrice: Array<Array<Array<number>>> = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: Array<Array<Array<Array<number>>>> = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: Record<string, Record<string, string>> = { key: stringMap };
const mapNestedTwiceStruct: Record<string, Record<string, AWS_APIGateway.MethodSnapshot>> = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: Record<string, Array<string>> = { key: ["value"] };
const mapOfMapOfArrays: Record<string, Record<string, Array<string>>> = { key: mapOfArrays };
const mapOfArrayOfMaps: Record<string, Array<Record<string, AWS_DynamoDB.AttributeValue>>> = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: Record<string, Array<Array<number>>> = { key: [[1], [2]] };
const arrayOfMaps: Array<Record<string, string>> = [stringMap];
const arrayOfMapOfArrays: Array<Record<string, Array<string>>> = [mapOfArrays];
const arrayOfMapOfMapOfArrays: Array<Record<string, Record<string, Array<string>>>> = [mapOfMapOfArrays];
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import APIGateway from "aws-sdk/clients/apigateway";
import DynamoDB from "aws-sdk/clients/dynamodb";
import IoTFleetWise from "aws-sdk/clients/iotfleetwise";
import LexModelsV2 from "aws-sdk/clients/lexmodelsv2";
import NetworkManager from "aws-sdk/clients/networkmanager";
import RDSDataService from "aws-sdk/clients/rdsdataservice";
import S3 from "aws-sdk/clients/s3";
import SageMakerGeospatial from "aws-sdk/clients/sagemakergeospatial";
import SecurityLake from "aws-sdk/clients/securitylake";
import SSM from "aws-sdk/clients/ssm";

// Native types
const stringType: S3.AccountId = "string";
const booleanType: S3.BucketKeyEnabled = true;
const numberType: S3.ContentLength = 123;

// Date
const dateType: S3.CreationDate = new Date();

// Uint8Array
const blobType: RDSDataService._Blob = new Uint8Array();

// Arrays
const stringArray: S3.AllowedHeaders = ["string1", "string2"];
const booleanArray: RDSDataService.BooleanArray = [true, false];
const numberArray: RDSDataService.LongArray = [123, 456];
const blobArray: IoTFleetWise.NetworkFilesList = [new Uint8Array()];
const enumArray: S3.ChecksumAlgorithmList = ["CRC32"];
const structureArray: S3.Buckets = [{ Name: "bucketName" }];

// Maps
const stringMap: S3.Metadata = { key: "value" };
const booleanMap: APIGateway.MapOfStringToBoolean = { key: true };
const numberMap: SSM.AssociationStatusAggregatedCount = { key: 123 };
const structureMap: APIGateway.MapOfMethodSnapshot = { key: { apiKeyRequired: true } };

// Nested arrays
const arrayNestedTwice: SageMakerGeospatial.LinearRing = [[1, 2], [3, 4]];
const arrayNestedThrice: SageMakerGeospatial.LinearRings = [[[1, 2], [3, 4]], [[4, 5], [6, 7]]];
const arrayNestedFour: SageMakerGeospatial.LinearRingsList = [
[[[1], [2]], [[3], [4]]],
[[[5], [6]], [[7], [8]]]
];

// Nested maps
const mapNestedTwice: LexModelsV2.ConditionMap = { key: stringMap };
const mapNestedTwiceStruct: APIGateway.PathToMapOfMethodSnapshot = { key: structureMap };

// Nested arrays and maps
const mapOfArrays: NetworkManager.FilterMap = { key: ["value"] };
const mapOfMapOfArrays: SecurityLake.AllDimensionsMap = { key: mapOfArrays };
const mapOfArrayOfMaps: DynamoDB.BatchGetResponseMap = { key: [{ key: { S:"A" }}] };
const mapOfArrayOfArrays: APIGateway.MapOfKeyUsages = { key: [[1], [2]] };
const arrayOfMaps: SSM.InventoryItemEntryList = [stringMap];
const arrayOfMapOfArrays: SSM.TargetMaps = [mapOfArrays];
const arrayOfMapOfMapOfArrays: SecurityLake.RegionSourceTypesAccountsList = [mapOfMapOfArrays];
Loading

0 comments on commit 915dcfe

Please sign in to comment.