-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove reference to non-existent types from CLIENT_TYPES_MAP records (#…
…318)
- Loading branch information
Showing
6 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"aws-sdk-js-codemod": patch | ||
--- | ||
|
||
Remove reference to non-existent types from CLIENT_TYPES_MAP records |
12 changes: 8 additions & 4 deletions
12
scripts/generateClientTypesMap/getClientTypesMapWithKeysRemovedFromValues.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
scripts/generateClientTypesMap/hasKeyReferenceInClientTypesMap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { hasKeyReferenceInValue } from "./hasKeyReferenceinValue"; | ||
|
||
/** | ||
* Checks if any of the values in the clientTypesMap has a reference to any of the keys. | ||
*/ | ||
export const hasKeyReferenceInClientTypesMap = (clientTypesMap: Record<string, string>) => { | ||
const keys = Object.keys(clientTypesMap); | ||
for (const value of Object.values(clientTypesMap)) { | ||
if (keys.some((key) => hasKeyReferenceInValue(key, value))) { | ||
// console.log({ keys, value }); | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Returns true if value contains reference to key. | ||
* | ||
* Reference is defined as key name inside brackets in Array/Record type | ||
* i.e. `Array<key>` or `Record<string, key>` for `key`. | ||
*/ | ||
export const hasKeyReferenceInValue = (key: string, value: string) => | ||
value.includes(`Array<${key}>`) || value.includes(`Record<string, ${key}>`); |
13 changes: 0 additions & 13 deletions
13
scripts/generateClientTypesMap/hasReferenceToKeysInValues.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters