Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: install
run: yarn
- name: lint+format
run: biome ci src
run: biome ci
- name: build
run: yarn build
- name: test
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"scripts": {
"build": "tsc",
"format": "biome format --write .",
"lint": "biome lint --write src",
"lint": "biome lint --write .",
"release": "yarn build && changeset publish",
"test": "vitest"
},
Expand Down
14 changes: 7 additions & 7 deletions scripts/generateClientTypesMap/getClientReqRespTypesMap.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import jscodeshift, {
Identifier,
TSFunctionType,
TSQualifiedName,
TSTypeReference,
type Identifier,
type TSFunctionType,
type TSQualifiedName,
type TSTypeReference,
} from "jscodeshift";

import { getTypesSource } from "./getTypesSource";
Expand Down Expand Up @@ -35,7 +35,7 @@ export const getClientReqRespTypesMap = async (
if (!params.typeAnnotation) return;
if (!params.typeAnnotation.typeAnnotation) return;
if (params.typeAnnotation.typeAnnotation.type !== "TSTypeReference") return;
const paramsTypeRef = params.typeAnnotation!.typeAnnotation! as TSTypeReference;
const paramsTypeRef = params.typeAnnotation.typeAnnotation as TSTypeReference;

if (!paramsTypeRef.typeName) return;
if (paramsTypeRef.typeName.type !== "TSQualifiedName") return;
Expand All @@ -55,7 +55,7 @@ export const getClientReqRespTypesMap = async (
if (!callback.typeAnnotation) return;
if (!callback.typeAnnotation.typeAnnotation) return;
if (callback.typeAnnotation.typeAnnotation.type !== "TSFunctionType") return;
const callbackTypeRef = callback.typeAnnotation!.typeAnnotation! as TSFunctionType;
const callbackTypeRef = callback.typeAnnotation.typeAnnotation as TSFunctionType;

if (!callbackTypeRef.parameters) return;
if (callbackTypeRef.parameters.length !== 2) return;
Expand All @@ -66,7 +66,7 @@ export const getClientReqRespTypesMap = async (
if (responseType.typeAnnotation.type !== "TSTypeAnnotation") return;
if (!responseType.typeAnnotation.typeAnnotation) return;
if (responseType.typeAnnotation.typeAnnotation.type !== "TSTypeReference") return;
const responseTypeRef = responseType.typeAnnotation!.typeAnnotation! as TSTypeReference;
const responseTypeRef = responseType.typeAnnotation.typeAnnotation as TSTypeReference;

if (!responseTypeRef.typeName) return;
if (responseTypeRef.typeName.type !== "TSQualifiedName") return;
Expand Down
7 changes: 6 additions & 1 deletion scripts/generateClientTypesMap/getClientTypesMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import jscodeshift, { Identifier, TSArrayType, TSTypeLiteral, TSTypeReference } from "jscodeshift";
import jscodeshift, {
type Identifier,
type TSArrayType,
type TSTypeLiteral,
type TSTypeReference,
} from "jscodeshift";

import { CLIENT_NAMES_MAP, DOCUMENT_CLIENT } from "../../src/transforms/v2-to-v3/config";
import { getClientTypesMapWithKeysRemovedFromValues } from "./getClientTypesMapWithKeysRemovedFromValues";
Expand Down
8 changes: 4 additions & 4 deletions scripts/generateClientTypesMap/getTypesSource.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { readFileSync } from "fs";
import { join } from "path";
import { JSCodeshift } from "jscodeshift";
import { readFileSync } from "node:fs";
import { join } from "node:path";
import type { JSCodeshift } from "jscodeshift";
import { DOCUMENT_CLIENT } from "../../src/transforms/v2-to-v3/config";

export const getTypesSource = (j: JSCodeshift, clientName: string) => {
const typesPath =
clientName === DOCUMENT_CLIENT
? join("node_modules", "aws-sdk", "lib", "dynamodb", `document_client.d.ts`)
? join("node_modules", "aws-sdk", "lib", "dynamodb", "document_client.d.ts")
: join("node_modules", "aws-sdk", "clients", `${clientName.toLowerCase()}.d.ts`);
const relativeTypesPath = join(__dirname, "..", "..", typesPath);

Expand Down
10 changes: 5 additions & 5 deletions scripts/generateClientTypesMap/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { writeFile } from "fs/promises";
import { join } from "path";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { format } from "prettier";

import {
Expand All @@ -24,8 +24,8 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes

let fileContent = codegenComment;

fileContent += `\n\n/* eslint-disable @typescript-eslint/naming-convention */`;
fileContent += `\nexport const ${mapName}: Record<string, Record<string, string>> = `;
fileContent += "\n\n\n";
fileContent += `export const ${mapName}: Record<string, Record<string, string>> = `;

const clientTypesMap = {};

Expand All @@ -37,7 +37,7 @@ const codegenComment = `// This file is generated by scripts/generateClientTypes
}

fileContent += JSON.stringify(clientTypesMap);
fileContent += `;\n`;
fileContent += ";\n";

await writeFile(
relativeFilePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CLIENTS_TO_TEST } from "./config";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getGlobalImportEqualsInput = () => {
let content = ``;
let content = "";

content += `import AWS = require("aws-sdk");\n\n`;
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST, `AWS.`);
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST, "AWS.");

return content;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportEqualsCode } from "./getV3PackageImportEqualsCode";

export const getGlobalImportEqualsOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportEqualsCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST));
content += "\n";
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getGlobalImportInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CLIENT_NAMES } from "../../src/transforms/v2-to-v3/config";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getGlobalImportInput = () => {
let content = ``;
let content = "";

content += `import AWS from "aws-sdk";\n\n`;
content += getV2ClientsNewExpressionCode(CLIENT_NAMES, `AWS.`);
content += getV2ClientsNewExpressionCode(CLIENT_NAMES, "AWS.");

return content;
};
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getGlobalImportOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportsCode } from "./getV3PackageImportsCode";

export const getGlobalImportOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportsCode(getClientNamesSortedByPackageName(CLIENT_NAMES));
content += `\n`;
content += "\n";
content += getV3ClientsNewExpressionCode(CLIENT_NAMES);

return content;
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getGlobalImportStarInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CLIENTS_TO_TEST } from "./config";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getGlobalImportStarInput = () => {
let content = ``;
let content = "";

content += `import * as AWS from "aws-sdk";\n\n`;
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST, `AWS.`);
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST, "AWS.");

return content;
};
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getGlobalImportStarOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportsCode } from "./getV3PackageImportsCode";

export const getGlobalImportStarOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportsCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST));
content += `\n`;
content += "\n";
content += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getGlobalRequireInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CLIENTS_TO_TEST } from "./config";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getGlobalRequireInput = () => {
let content = ``;
let content = "";

content += `const AWS = require("aws-sdk");\n\n`;
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST, `AWS.`);
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST, "AWS.");

return content;
};
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getGlobalRequireOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageRequiresCode } from "./getV3PackageRequiresCode";

export const getGlobalRequireOutput = () => {
let content = `\n\n`;
let content = "\n\n";

content += getV3PackageRequiresCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST));
content += `\n`;
content += "\n";
content += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { CLIENTS_TO_TEST } from "./config";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getGlobalRequirePropertyInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
content += `const ${clientName} = require("aws-sdk").${clientName};\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getGlobalRequirePropertyWithNameInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
const importName = getClientNameWithLocalSuffix(clientName);
content += `const ${importName} = require("aws-sdk").${clientName};\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix));

return content;
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getServiceImportDeepInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { getClientDeepImportPath } from "./getClientDeepImportPath";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportDeepInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
content += `import ${clientName} from "${getClientDeepImportPath(clientName)}";\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportsCode } from "./getV3PackageImportsCode";

export const getServiceImportDeepOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportsCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST));
content += `\n`;
content += "\n";
content += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { getClientDeepImportPath } from "./getClientDeepImportPath";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportDeepStarInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
content += `import * as ${clientName} from "${getClientDeepImportPath(clientName)}";\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportDeepStarWithNameInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
const importName = getClientNameWithLocalSuffix(clientName);
content += `import * as ${importName} from "${getClientDeepImportPath(clientName)}";\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix));

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportDeepWithNameInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
const importName = getClientNameWithLocalSuffix(clientName);
content += `import ${importName} from "${getClientDeepImportPath(clientName)}";\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix));

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportsCode } from "./getV3PackageImportsCode";

export const getServiceImportDeepWithNameOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportsCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST), {
useLocalSuffix: true,
});
content += `\n`;
content += "\n";
content += getV3ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix));

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { getClientDeepImportPath } from "./getClientDeepImportPath";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportEqualsInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
content += `import ${clientName} = require("${getClientDeepImportPath(clientName)}");\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportEqualsCode } from "./getV3PackageImportEqualsCode";

export const getServiceImportEqualsOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportEqualsCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST));
content += "\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { getClientNameWithLocalSuffix } from "./getClientNameWithLocalSuffix";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportEqualsWithNameInput = () => {
let content = ``;
let content = "";

for (const clientName of CLIENTS_TO_TEST) {
const importName = getClientNameWithLocalSuffix(clientName);
content += `import ${importName} = require("${getClientDeepImportPath(clientName)}");\n`;
}
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST.map(getClientNameWithLocalSuffix));

return content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getV3ClientsNewExpressionCode } from "./getV3ClientsNewExpressionCode";
import { getV3PackageImportEqualsCode } from "./getV3PackageImportEqualsCode";

export const getServiceImportEqualsWithNameOutput = () => {
let content = ``;
let content = "";

content += getV3PackageImportEqualsCode(getClientNamesSortedByPackageName(CLIENTS_TO_TEST), {
useLocalSuffix: true,
Expand Down
4 changes: 2 additions & 2 deletions scripts/generateNewClientTests/getServiceImportInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { CLIENTS_TO_TEST } from "./config";
import { getV2ClientsNewExpressionCode } from "./getV2ClientsNewExpressionCode";

export const getServiceImportInput = (path?: string) => {
let content = ``;
let content = "";

content += `import { ${CLIENTS_TO_TEST.join(", ")} } from "${path ? path : "aws-sdk"}";\n`;
content += `\n`;
content += "\n";
content += getV2ClientsNewExpressionCode(CLIENTS_TO_TEST);

return content;
Expand Down
Loading