Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support type definitions which are not available in v3 #315

Merged
merged 31 commits into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
efc22af
Add basic test for api-unavailable-type
trivikr Jan 5, 2023
b40f426
Add examples for native types and arrays
trivikr Jan 5, 2023
992bb01
Add structure arrays
trivikr Jan 5, 2023
7bb465c
Add blog array
trivikr Jan 5, 2023
ccde09b
Rename word unavailable to redundant in test folder name
trivikr Jan 5, 2023
0e3377c
Add tests for Maps
trivikr Jan 5, 2023
7be42f9
Add Date
trivikr Jan 6, 2023
1ba3a45
Add test for nested arrays
trivikr Jan 6, 2023
36ffc3e
Added tests for nested arrays and maps
trivikr Jan 6, 2023
cfbd8dc
Create utility getV3ClientTypesCount
trivikr Jan 6, 2023
7fe69fd
WIP implementation to getV3ClientTypeReference
trivikr Jan 6, 2023
6882482
Create utility getTypeRefForString which returns a string
trivikr Jan 6, 2023
85dfd37
Return type for number and boolean
trivikr Jan 6, 2023
a7a9ab7
Add type creation for Date/Uint8Array
trivikr Jan 6, 2023
411ce75
Process values for non native types in getV3ClientTypesCount
trivikr Jan 6, 2023
bd83efd
Remove comments past variables in api-redundant-type
trivikr Jan 6, 2023
1ac580d
Use Array instead of brackets
trivikr Jan 6, 2023
c0d768b
Add support for array type
trivikr Jan 6, 2023
46ff6ae
Return identifier with v3clientDefaultLocalName
trivikr Jan 6, 2023
915ce22
Add support for Record
trivikr Jan 6, 2023
270f884
Undo changes in transformer.spec.ts
trivikr Jan 6, 2023
c55da5b
yarn changeset
trivikr Jan 6, 2023
fc3c0a4
Add test api-redundant-type/service-import
trivikr Jan 6, 2023
6c471fb
Add test api-redundant-type/service-import-deep
trivikr Jan 6, 2023
09715d0
Add test api-redundant-type/global-require
trivikr Jan 6, 2023
3898aa8
Add test api-redundant-type/service-require
trivikr Jan 6, 2023
7270676
Add test api-redundant-type/service-require-deep
trivikr Jan 6, 2023
68a0bf7
Add test api-redundant-type/global-import-equals
trivikr Jan 6, 2023
e4d2b13
Add default import equals only if v3 client types are present
trivikr Jan 6, 2023
51e7ce7
Add test api-redundant-type/service-import-equals
trivikr Jan 6, 2023
b88da6a
Simplify code for addV3Client functions
trivikr Jan 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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