diff --git a/.gitignore b/.gitignore index eab53c4c25..3f1196546a 100644 --- a/.gitignore +++ b/.gitignore @@ -46,4 +46,7 @@ site !/examples/sam/src/handlers/COPY_LAMBDA_FUNCTIONS_HERE # Layer temp files -tmp \ No newline at end of file +tmp + +# TS build files +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/.npmignore b/.npmignore index d055233733..ec8c75c6f9 100644 --- a/.npmignore +++ b/.npmignore @@ -18,4 +18,5 @@ jest.config.js .eslintignore .huskyrc.js .eslintrc.json -examples \ No newline at end of file +examples +tsconfig.tsbuildinfo \ No newline at end of file diff --git a/docs/snippets/tsconfig.json b/docs/snippets/tsconfig.json index 2d76b059c1..1a3fe8b171 100644 --- a/docs/snippets/tsconfig.json +++ b/docs/snippets/tsconfig.json @@ -1,21 +1,9 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "esModuleInterop": true, - "allowJs": true, + "rootDir": "./", "baseUrl": ".", + "noEmit": true, "paths": { "@aws-lambda-powertools/parameters/ssm": [ "../../packages/parameters/lib/ssm" @@ -41,13 +29,5 @@ ], "@aws-lambda-powertools/batch": ["../../packages/batch/lib"] } - }, - "exclude": ["./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": ["ES2020"], - "types": ["node"] + } } diff --git a/layers/package.json b/layers/package.json index ce626f56f8..80115a55cb 100644 --- a/layers/package.json +++ b/layers/package.json @@ -17,8 +17,7 @@ "test:e2e": "jest --group=e2e" }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "repository": { "type": "git", diff --git a/layers/tests/tsconfig.json b/layers/tests/tsconfig.json new file mode 100644 index 0000000000..a07fdb8a65 --- /dev/null +++ b/layers/tests/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "../package.json", + "./**/*", + ] +} \ No newline at end of file diff --git a/layers/tsconfig.es.json b/layers/tsconfig.es.json deleted file mode 100644 index 7743a7b77d..0000000000 --- a/layers/tsconfig.es.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2019", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2019" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/layers/tsconfig.json b/layers/tsconfig.json index ce59f26c4a..4acbde11be 100644 --- a/layers/tsconfig.json +++ b/layers/tsconfig.json @@ -1,30 +1,12 @@ { - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2019", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true -}, -"include": [ "src/**/*" ], -"exclude": [ "./node_modules", "cdk.out"], -"watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" -}, -"lib": [ "es2019" ], -"types": [ - "jest", - "node" -] -} + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "rootDir": "./", + "resolveJsonModule": true + }, + "include": [ + "./src/**/*", + "./bin/**/*" + ], +} \ No newline at end of file diff --git a/packages/batch/package.json b/packages/batch/package.json index 2c7932df74..9e046c15bc 100644 --- a/packages/batch/package.json +++ b/packages/batch/package.json @@ -17,7 +17,7 @@ "test:e2e:nodejs18x": "echo 'Not Implemented'", "test:e2e": "echo 'Not Implemented'", "watch": "jest --watch", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", diff --git a/packages/batch/src/constants.ts b/packages/batch/src/constants.ts index 02437e356c..d06d5a8872 100644 --- a/packages/batch/src/constants.ts +++ b/packages/batch/src/constants.ts @@ -1,4 +1,8 @@ -import { DynamoDBRecord, KinesisStreamRecord, SQSRecord } from 'aws-lambda'; +import type { + DynamoDBRecord, + KinesisStreamRecord, + SQSRecord, +} from 'aws-lambda'; import type { PartialItemFailureResponse, EventSourceDataClassTypes, diff --git a/packages/batch/src/types.ts b/packages/batch/src/types.ts index 17ce3633c7..5033ce6f5a 100644 --- a/packages/batch/src/types.ts +++ b/packages/batch/src/types.ts @@ -1,4 +1,4 @@ -import { +import type { Context, DynamoDBRecord, KinesisStreamRecord, diff --git a/packages/batch/tests/tsconfig.json b/packages/batch/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/batch/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/batch/tests/unit/AsyncBatchProcessor.test.ts b/packages/batch/tests/unit/AsyncBatchProcessor.test.ts index 0bccdd6d07..127bae2705 100644 --- a/packages/batch/tests/unit/AsyncBatchProcessor.test.ts +++ b/packages/batch/tests/unit/AsyncBatchProcessor.test.ts @@ -4,7 +4,7 @@ * @group unit/batch/class/asyncBatchProcessor */ import type { Context } from 'aws-lambda'; -import { helloworldContext as dummyContext } from '../../../commons/src/samples/resources/contexts'; +import { helloworldContext as dummyContext } from '@aws-lambda-powertools/commons/lib/samples/resources/contexts'; import { AsyncBatchProcessor } from '../../src/AsyncBatchProcessor'; import { EventType } from '../../src/constants'; import { BatchProcessingError, FullBatchFailureError } from '../../src/errors'; diff --git a/packages/batch/tests/unit/BatchProcessor.test.ts b/packages/batch/tests/unit/BatchProcessor.test.ts index 97f50b7d11..0f928b4bc7 100644 --- a/packages/batch/tests/unit/BatchProcessor.test.ts +++ b/packages/batch/tests/unit/BatchProcessor.test.ts @@ -4,7 +4,7 @@ * @group unit/batch/class/batchprocessor */ import type { Context } from 'aws-lambda'; -import { helloworldContext as dummyContext } from '../../../commons/src/samples/resources/contexts'; +import { helloworldContext as dummyContext } from '@aws-lambda-powertools/commons/lib/samples/resources/contexts'; import { BatchProcessor } from '../../src/BatchProcessor'; import { EventType } from '../../src/constants'; import { BatchProcessingError, FullBatchFailureError } from '../../src/errors'; diff --git a/packages/batch/tests/unit/asyncProcessPartialResponse.test.ts b/packages/batch/tests/unit/asyncProcessPartialResponse.test.ts index aef38f33ec..c7e98edca4 100644 --- a/packages/batch/tests/unit/asyncProcessPartialResponse.test.ts +++ b/packages/batch/tests/unit/asyncProcessPartialResponse.test.ts @@ -9,8 +9,8 @@ import type { KinesisStreamEvent, SQSEvent, } from 'aws-lambda'; -import { helloworldContext as dummyContext } from '../../../commons/src/samples/resources/contexts'; -import { Custom as dummyEvent } from '../../../commons/src/samples/resources/events'; +import { helloworldContext as dummyContext } from '@aws-lambda-powertools/commons/lib/samples/resources/contexts'; +import { Custom as dummyEvent } from '@aws-lambda-powertools/commons/lib/samples/resources/events'; import { AsyncBatchProcessor, asyncProcessPartialResponse } from '../../src'; import { EventType } from '../../src/constants'; import type { diff --git a/packages/batch/tests/unit/processPartialResponse.test.ts b/packages/batch/tests/unit/processPartialResponse.test.ts index f33caa6f06..5fba12f88e 100644 --- a/packages/batch/tests/unit/processPartialResponse.test.ts +++ b/packages/batch/tests/unit/processPartialResponse.test.ts @@ -9,8 +9,8 @@ import type { KinesisStreamEvent, SQSEvent, } from 'aws-lambda'; -import { helloworldContext as dummyContext } from '../../../commons/src/samples/resources/contexts'; -import { Custom as dummyEvent } from '../../../commons/src/samples/resources/events'; +import { helloworldContext as dummyContext } from '@aws-lambda-powertools/commons/lib/samples/resources/contexts'; +import { Custom as dummyEvent } from '@aws-lambda-powertools/commons/lib/samples/resources/events'; import { BatchProcessor, processPartialResponse } from '../../src'; import { EventType } from '../../src/constants'; import type { diff --git a/packages/batch/tsconfig-dev.json b/packages/batch/tsconfig-dev.json deleted file mode 100644 index 6f766859ea..0000000000 --- a/packages/batch/tsconfig-dev.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "declarationMap": true, - "esModuleInterop": false - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "types": [ - "jest" - ] -} \ No newline at end of file diff --git a/packages/batch/tsconfig.es.json b/packages/batch/tsconfig.es.json deleted file mode 100644 index 6f766859ea..0000000000 --- a/packages/batch/tsconfig.es.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "declarationMap": true, - "esModuleInterop": false - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "types": [ - "jest" - ] -} \ No newline at end of file diff --git a/packages/batch/tsconfig.json b/packages/batch/tsconfig.json index 09df4b9ba4..1cb9d72773 100644 --- a/packages/batch/tsconfig.json +++ b/packages/batch/tsconfig.json @@ -1,29 +1,10 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true - }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "node" - ] +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "rootDir": "./src", + }, + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/commons/package.json b/packages/commons/package.json index b47028a343..a7bbde3aeb 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -15,15 +15,14 @@ "test:e2e": "echo 'Not Applicable'", "watch": "jest --watch", "generateVersionFile": "echo \"// this file is auto generated, do not modify\nexport const PT_VERSION = '$(jq -r '.version' package.json)';\" > src/version.ts", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/metrics#readme", "license": "MIT-0", diff --git a/packages/commons/src/config/EnvironmentVariablesService.ts b/packages/commons/src/config/EnvironmentVariablesService.ts index 72f2e81306..3e1be7af6c 100644 --- a/packages/commons/src/config/EnvironmentVariablesService.ts +++ b/packages/commons/src/config/EnvironmentVariablesService.ts @@ -1,4 +1,4 @@ -import { ConfigService } from '.'; +import { ConfigService } from './ConfigService'; /** * Class EnvironmentVariablesService diff --git a/packages/commons/src/middleware/constants.ts b/packages/commons/src/middleware/constants.ts index 9f9b30bcb6..cf38261995 100644 --- a/packages/commons/src/middleware/constants.ts +++ b/packages/commons/src/middleware/constants.ts @@ -9,4 +9,4 @@ const METRICS_KEY = `${PREFIX}.metrics`; const LOGGER_KEY = `${PREFIX}.logger`; const IDEMPOTENCY_KEY = `${PREFIX}.idempotency`; -export { TRACER_KEY, METRICS_KEY, LOGGER_KEY, IDEMPOTENCY_KEY }; +export { PREFIX, TRACER_KEY, METRICS_KEY, LOGGER_KEY, IDEMPOTENCY_KEY }; diff --git a/packages/commons/src/samples/resources/contexts/hello-world.ts b/packages/commons/src/samples/resources/contexts/hello-world.ts index 0f26aed05f..2dccd0cc8b 100644 --- a/packages/commons/src/samples/resources/contexts/hello-world.ts +++ b/packages/commons/src/samples/resources/contexts/hello-world.ts @@ -1,4 +1,4 @@ -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; const helloworldContext: Context = { callbackWaitsForEmptyEventLoop: true, diff --git a/packages/commons/src/utils/lambda/LambdaInterface.ts b/packages/commons/src/utils/lambda/LambdaInterface.ts index fc2e95ffb7..0871d433f9 100644 --- a/packages/commons/src/utils/lambda/LambdaInterface.ts +++ b/packages/commons/src/utils/lambda/LambdaInterface.ts @@ -1,4 +1,4 @@ -import { Handler } from 'aws-lambda'; +import type { Handler } from 'aws-lambda'; export type SyncHandler = ( event: Parameters[0], diff --git a/packages/commons/tests/tsconfig.json b/packages/commons/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/commons/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/commons/tests/unit/LambdaInterface.test.ts b/packages/commons/tests/unit/LambdaInterface.test.ts index 7fb7f0e389..52049aadc0 100644 --- a/packages/commons/tests/unit/LambdaInterface.test.ts +++ b/packages/commons/tests/unit/LambdaInterface.test.ts @@ -128,8 +128,6 @@ describe('LambdaInterface with decorator', () => { // WHEN class LambdaFunction implements LambdaInterface { @dummyModule.dummyDecorator() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: unknown, context: Context @@ -147,8 +145,6 @@ describe('LambdaInterface with decorator', () => { // WHEN class LambdaFunction implements LambdaInterface { @dummyModule.dummyDecorator() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public handler( _event: unknown, context: Context, diff --git a/packages/commons/tsconfig-dev.json b/packages/commons/tsconfig-dev.json deleted file mode 100644 index 802f18e8f9..0000000000 --- a/packages/commons/tsconfig-dev.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/commons/tsconfig.json b/packages/commons/tsconfig.json index cbd9922f32..1cb9d72773 100644 --- a/packages/commons/tsconfig.json +++ b/packages/commons/tsconfig.json @@ -1,31 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/idempotency/package.json b/packages/idempotency/package.json index 5ed19121b3..059588447d 100644 --- a/packages/idempotency/package.json +++ b/packages/idempotency/package.json @@ -17,15 +17,14 @@ "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --watch", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/idempotency#readme", "license": "MIT-0", diff --git a/packages/idempotency/tests/tsconfig.json b/packages/idempotency/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/idempotency/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/idempotency/tsconfig-dev.json b/packages/idempotency/tsconfig-dev.json deleted file mode 100644 index 6f766859ea..0000000000 --- a/packages/idempotency/tsconfig-dev.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "declarationMap": true, - "esModuleInterop": false - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "types": [ - "jest" - ] -} \ No newline at end of file diff --git a/packages/idempotency/tsconfig.es.json b/packages/idempotency/tsconfig.es.json deleted file mode 100644 index 6f766859ea..0000000000 --- a/packages/idempotency/tsconfig.es.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "declarationMap": true, - "esModuleInterop": false - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "types": [ - "jest" - ] -} \ No newline at end of file diff --git a/packages/idempotency/tsconfig.json b/packages/idempotency/tsconfig.json index 09df4b9ba4..1cb9d72773 100644 --- a/packages/idempotency/tsconfig.json +++ b/packages/idempotency/tsconfig.json @@ -1,29 +1,10 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true - }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "node" - ] +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "./lib", + "rootDir": "./src", + }, + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/logger/package.json b/packages/logger/package.json index 321648326c..0d2aceaa24 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -17,15 +17,14 @@ "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --watch --group=unit", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/logger#readme", "license": "MIT-0", @@ -58,4 +57,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file diff --git a/packages/logger/tests/tsconfig.json b/packages/logger/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/logger/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/logger/tests/unit/Logger.test.ts b/packages/logger/tests/unit/Logger.test.ts index 61424c04c1..5e56ae83c6 100644 --- a/packages/logger/tests/unit/Logger.test.ts +++ b/packages/logger/tests/unit/Logger.test.ts @@ -18,7 +18,7 @@ import { LogLevelThresholds, LogLevel, } from '../../src/types'; -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import { Console } from 'console'; const mockDate = new Date(1466424490000); @@ -1050,8 +1050,6 @@ describe('Class: Logger', () => { .mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1097,8 +1095,6 @@ describe('Class: Logger', () => { .mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1153,8 +1149,6 @@ describe('Class: Logger', () => { .mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1215,8 +1209,6 @@ describe('Class: Logger', () => { jest.spyOn(logger['console'], 'debug').mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext({ clearState: true }) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1263,8 +1255,6 @@ describe('Class: Logger', () => { jest.spyOn(logger['console'], 'debug').mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext({ clearState: true }) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1309,8 +1299,6 @@ describe('Class: Logger', () => { .mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext({ logEvent: true }) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1361,8 +1349,6 @@ describe('Class: Logger', () => { class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1418,8 +1404,6 @@ describe('Class: Logger', () => { } @logger.injectLambdaContext() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context @@ -1473,8 +1457,6 @@ describe('Class: Logger', () => { .mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: unknown, _context: unknown @@ -1517,8 +1499,6 @@ describe('Class: Logger', () => { .mockImplementation(); class LambdaFunction implements LambdaInterface { @logger.injectLambdaContext({ clearState: true, logEvent: true }) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( event: { foo: string }, _context: unknown diff --git a/packages/logger/tsconfig-dev.json b/packages/logger/tsconfig-dev.json deleted file mode 100644 index 4ea999b37f..0000000000 --- a/packages/logger/tsconfig-dev.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/logger/tsconfig.es.json b/packages/logger/tsconfig.es.json deleted file mode 100644 index 4ea999b37f..0000000000 --- a/packages/logger/tsconfig.es.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json index 20da6e39a9..1cb9d72773 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -1,30 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/metrics/package.json b/packages/metrics/package.json index 6c75003d8b..6215132367 100644 --- a/packages/metrics/package.json +++ b/packages/metrics/package.json @@ -17,15 +17,14 @@ "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --group=unit --watch ", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/metrics#readme", "license": "MIT-0", @@ -58,4 +57,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file diff --git a/packages/metrics/src/Metrics.ts b/packages/metrics/src/Metrics.ts index 0a236db877..b2a1c1e34e 100644 --- a/packages/metrics/src/Metrics.ts +++ b/packages/metrics/src/Metrics.ts @@ -1,7 +1,10 @@ -import { Callback, Context, Handler } from 'aws-lambda'; +import type { Callback, Context, Handler } from 'aws-lambda'; import { Utility } from '@aws-lambda-powertools/commons'; import type { MetricsInterface } from './MetricsInterface'; -import { ConfigServiceInterface, EnvironmentVariablesService } from './config'; +import { + type ConfigServiceInterface, + EnvironmentVariablesService, +} from './config'; import { MAX_DIMENSION_COUNT, MAX_METRICS_SIZE, diff --git a/packages/metrics/src/config/EnvironmentVariablesService.ts b/packages/metrics/src/config/EnvironmentVariablesService.ts index 6105759e4d..907036092d 100644 --- a/packages/metrics/src/config/EnvironmentVariablesService.ts +++ b/packages/metrics/src/config/EnvironmentVariablesService.ts @@ -1,4 +1,4 @@ -import { ConfigServiceInterface } from './ConfigServiceInterface'; +import type { ConfigServiceInterface } from './ConfigServiceInterface'; import { EnvironmentVariablesService as CommonEnvironmentVariablesService } from '@aws-lambda-powertools/commons'; class EnvironmentVariablesService diff --git a/packages/metrics/src/types/Metrics.ts b/packages/metrics/src/types/Metrics.ts index afdda1d9ef..ef5e7d5454 100644 --- a/packages/metrics/src/types/Metrics.ts +++ b/packages/metrics/src/types/Metrics.ts @@ -1,5 +1,5 @@ -import { Handler } from 'aws-lambda'; -import { +import type { Handler } from 'aws-lambda'; +import type { LambdaInterface, AsyncHandler, SyncHandler, diff --git a/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts b/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts index 5a8f104843..9016a01cbe 100644 --- a/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts +++ b/packages/metrics/tests/e2e/basicFeatures.decorator.test.functionCode.ts @@ -1,6 +1,6 @@ import { Metrics, MetricUnits } from '../../src'; -import { Context } from 'aws-lambda'; -import { LambdaInterface } from '@aws-lambda-powertools/commons'; +import type { Context } from 'aws-lambda'; +import type { LambdaInterface } from '@aws-lambda-powertools/commons'; const namespace = process.env.EXPECTED_NAMESPACE ?? 'CdkExample'; const serviceName = diff --git a/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts b/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts index eae2c1a842..67ea224083 100644 --- a/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts +++ b/packages/metrics/tests/e2e/basicFeatures.manual.test.functionCode.ts @@ -1,5 +1,5 @@ import { Metrics, MetricUnits } from '../../src'; -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; const namespace = process.env.EXPECTED_NAMESPACE ?? 'CdkExample'; const serviceName = diff --git a/packages/metrics/tests/tsconfig.json b/packages/metrics/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/metrics/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/metrics/tests/unit/Metrics.test.ts b/packages/metrics/tests/unit/Metrics.test.ts index 42c5f2ded8..81808a0f5c 100644 --- a/packages/metrics/tests/unit/Metrics.test.ts +++ b/packages/metrics/tests/unit/Metrics.test.ts @@ -1213,8 +1213,6 @@ describe('Class: Metrics', () => { const errorMessage = 'Unexpected error occurred!'; class LambdaFunction implements LambdaInterface { @metrics.logMetrics() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public async handler( _event: TEvent, _context: Context diff --git a/packages/metrics/tests/unit/middleware/middy.test.ts b/packages/metrics/tests/unit/middleware/middy.test.ts index fe2268a78a..5713bcbe9c 100644 --- a/packages/metrics/tests/unit/middleware/middy.test.ts +++ b/packages/metrics/tests/unit/middleware/middy.test.ts @@ -12,8 +12,8 @@ import { import middy from '@middy/core'; import { ExtraOptions } from '../../../src/types'; import { cleanupMiddlewares } from '@aws-lambda-powertools/commons/lib/middleware'; -import { helloworldContext as dummyContext } from '../../../../commons/src/samples/resources/contexts/hello-world'; -import { CustomEvent as dummyEvent } from '../../../../commons/src/samples/resources/events/custom/index'; +import { helloworldContext as dummyContext } from '@aws-lambda-powertools/commons/lib/samples/resources/contexts/hello-world'; +import { CustomEvent as dummyEvent } from '@aws-lambda-powertools/commons/lib/samples/resources/events/custom/index'; const consoleSpy = jest.spyOn(console, 'log').mockImplementation(); const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation(); diff --git a/packages/metrics/tsconfig.es.json b/packages/metrics/tsconfig.es.json deleted file mode 100644 index d28abaa6d5..0000000000 --- a/packages/metrics/tsconfig.es.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/metrics/tsconfig.json b/packages/metrics/tsconfig.json index 582618277f..1cb9d72773 100644 --- a/packages/metrics/tsconfig.json +++ b/packages/metrics/tsconfig.json @@ -1,32 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*"], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/parameters/package.json b/packages/parameters/package.json index e73696355b..d39ac6599c 100644 --- a/packages/parameters/package.json +++ b/packages/parameters/package.json @@ -17,15 +17,14 @@ "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --watch", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/parameters#readme", "license": "MIT-0", diff --git a/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts index ece202a259..48735b703b 100644 --- a/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/appConfigProvider.class.test.functionCode.ts @@ -1,4 +1,4 @@ -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import { Transform } from '../../src'; import { AppConfigProvider } from '../../src/appconfig'; import { AppConfigGetOptions } from '../../src/types/AppConfigProvider'; @@ -56,7 +56,7 @@ const _call_get = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -99,7 +99,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-cached', - error: err.message, + error: (err as Error).message, }); } @@ -119,7 +119,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-forced', - error: err.message, + error: (err as Error).message, }); } // Test 7 @@ -152,7 +152,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-expired', - error: err.message, + error: (err as Error).message, }); } }; diff --git a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts index 18df7bb21e..88f1eccd20 100644 --- a/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/dynamoDBProvider.class.test.functionCode.ts @@ -1,4 +1,4 @@ -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import { Transform } from '../../src'; import { DynamoDBProvider } from '../../src/dynamodb'; import { @@ -67,7 +67,7 @@ const _call_get = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -88,7 +88,7 @@ const _call_get_multiple = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -147,7 +147,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-cached', - error: err.message, + error: (err as Error).message, }); } @@ -165,7 +165,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-forced', - error: err.message, + error: (err as Error).message, }); } }; diff --git a/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts index a52eeea586..e7526fdefc 100644 --- a/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/secretsProvider.class.test.functionCode.ts @@ -41,7 +41,7 @@ const _call_get = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -76,7 +76,7 @@ export const handler = async ( } catch (err) { logger.log({ test: secretNamePlainChached, - error: err.message, + error: (err as Error).message, }); } // Test 5 @@ -95,7 +95,7 @@ export const handler = async ( } catch (err) { logger.log({ test: secretNamePlainChached, - error: err.message, + error: (err as Error).message, }); } }; diff --git a/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts b/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts index 49aefa90bd..a8915c2779 100644 --- a/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts +++ b/packages/parameters/tests/e2e/ssmProvider.class.test.functionCode.ts @@ -51,7 +51,7 @@ const _call_get = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -77,7 +77,7 @@ const _call_get_multiple = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -103,7 +103,7 @@ const _call_get_parameters_by_name = async ( } catch (err) { logger.log({ test: testName, - error: err.message, + error: (err as Error).message, }); } }; @@ -176,7 +176,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-cached', - error: err.message, + error: (err as Error).message, }); } @@ -194,7 +194,7 @@ export const handler = async ( } catch (err) { logger.log({ test: 'get-forced', - error: err.message, + error: (err as Error).message, }); } }; diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index 4b29d66e32..7067f608fd 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -59,7 +59,6 @@ class TestSecureStringParameter extends Construct { const { value } = props; const name = `/secure/${getRuntimeKey()}/${randomUUID()}`; - const secureStringCreator = new AwsCustomResource( testStack.stack, `create-${randomUUID()}`, diff --git a/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts b/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts index 76cea93cc3..e8addbf68a 100644 --- a/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts +++ b/packages/parameters/tests/helpers/sdkMiddlewareRequestCounter.ts @@ -1,3 +1,10 @@ +import type { + InitializeHandler, + HandlerExecutionContext, + InitializeHandlerArguments, + MiddlewareStack, +} from '@aws-sdk/types'; + /** * Middleware to count the number of API calls made by the SDK. * @@ -14,23 +21,29 @@ export const middleware = { // counter: 0, - applyToStack: (stack) => { + applyToStack: ( + stack: MiddlewareStack + ) => { // Middleware added to mark start and end of an complete API call. stack.add( - (next, context) => async (args) => { - // We only want to count API calls to retrieve data, - // not the StartConfigurationSessionCommand - if ( - context.clientName !== 'AppConfigDataClient' || - context.commandName !== 'StartConfigurationSessionCommand' - ) { - // Increment counter - middleware.counter++; - } + ( + next: InitializeHandler, + context: HandlerExecutionContext + ) => + async (args: InitializeHandlerArguments) => { + // We only want to count API calls to retrieve data, + // not the StartConfigurationSessionCommand + if ( + context.clientName !== 'AppConfigDataClient' || + context.commandName !== 'StartConfigurationSessionCommand' + ) { + // Increment counter + middleware.counter++; + } - // Call next middleware - return await next(args); - }, + // Call next middleware + return await next(args); + }, { tags: ['ROUND_TRIP'] } ); }, diff --git a/packages/parameters/tests/tsconfig.json b/packages/parameters/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/parameters/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/parameters/tsconfig-dev.json b/packages/parameters/tsconfig-dev.json deleted file mode 100644 index 4ea999b37f..0000000000 --- a/packages/parameters/tsconfig-dev.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/parameters/tsconfig.es.json b/packages/parameters/tsconfig.es.json deleted file mode 100644 index 4ea999b37f..0000000000 --- a/packages/parameters/tsconfig.es.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "examples/**/*", "**/tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/parameters/tsconfig.json b/packages/parameters/tsconfig.json index 20da6e39a9..1cb9d72773 100644 --- a/packages/parameters/tsconfig.json +++ b/packages/parameters/tsconfig.json @@ -1,30 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/testing/package.json b/packages/testing/package.json index 375374f9ef..5b922f4ab2 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -12,7 +12,7 @@ "test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", "test:e2e": "echo 'Not implemented'", "watch": "jest --watch", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", diff --git a/packages/testing/tests/tsconfig.json b/packages/testing/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/testing/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/testing/tsconfig.es.json b/packages/testing/tsconfig.es.json deleted file mode 100644 index 802f18e8f9..0000000000 --- a/packages/testing/tsconfig.es.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/testing/tsconfig.json b/packages/testing/tsconfig.json index 8b93f8c299..1cb9d72773 100644 --- a/packages/testing/tsconfig.json +++ b/packages/testing/tsconfig.json @@ -1,32 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/packages/tracer/package.json b/packages/tracer/package.json index 5fb5298b13..6e9c6dae66 100644 --- a/packages/tracer/package.json +++ b/packages/tracer/package.json @@ -17,15 +17,14 @@ "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e": "jest --group=e2e", "watch": "jest --watch", - "build": "tsc", + "build": "tsc --build --force", "lint": "eslint --ext .ts,.js --no-error-on-unmatched-pattern .", "lint-fix": "eslint --fix --ext .ts,.js --no-error-on-unmatched-pattern .", "prebuild": "rimraf ./lib", "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{js,ts}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/tracer#readme", "license": "MIT-0", diff --git a/packages/tracer/src/Tracer.ts b/packages/tracer/src/Tracer.ts index 52e687e11f..c780ef6f48 100644 --- a/packages/tracer/src/Tracer.ts +++ b/packages/tracer/src/Tracer.ts @@ -1,20 +1,23 @@ -import { Handler } from 'aws-lambda'; +import type { Handler } from 'aws-lambda'; import { - AsyncHandler, - SyncHandler, + type AsyncHandler, + type SyncHandler, Utility, } from '@aws-lambda-powertools/commons'; -import { TracerInterface } from '.'; -import { ConfigServiceInterface, EnvironmentVariablesService } from './config'; +import type { TracerInterface } from '.'; import { + type ConfigServiceInterface, + EnvironmentVariablesService, +} from './config'; +import type { HandlerMethodDecorator, TracerOptions, MethodDecorator, CaptureLambdaHandlerOptions, CaptureMethodOptions, } from './types'; -import { ProviderService, ProviderServiceInterface } from './provider'; -import { Segment, Subsegment } from 'aws-xray-sdk-core'; +import { ProviderService, type ProviderServiceInterface } from './provider'; +import { type Segment, Subsegment } from 'aws-xray-sdk-core'; /** * ## Intro diff --git a/packages/tracer/src/TracerInterface.ts b/packages/tracer/src/TracerInterface.ts index 65d7d4a10a..b346af0f73 100644 --- a/packages/tracer/src/TracerInterface.ts +++ b/packages/tracer/src/TracerInterface.ts @@ -1,10 +1,10 @@ -import { +import type { CaptureLambdaHandlerOptions, CaptureMethodOptions, HandlerMethodDecorator, MethodDecorator, } from './types'; -import { Segment, Subsegment } from 'aws-xray-sdk-core'; +import type { Segment, Subsegment } from 'aws-xray-sdk-core'; interface TracerInterface { addErrorAsMetadata(error: Error, remote?: boolean): void; diff --git a/packages/tracer/src/helpers.ts b/packages/tracer/src/helpers.ts index ff198f88f5..485475c07c 100644 --- a/packages/tracer/src/helpers.ts +++ b/packages/tracer/src/helpers.ts @@ -1,5 +1,5 @@ import { Tracer } from '.'; -import { TracerOptions } from './types'; +import type { TracerOptions } from './types'; const createTracer = (options: TracerOptions = {}): Tracer => new Tracer(options); diff --git a/packages/tracer/src/types/Tracer.ts b/packages/tracer/src/types/Tracer.ts index eea9113326..e31c06c4e7 100644 --- a/packages/tracer/src/types/Tracer.ts +++ b/packages/tracer/src/types/Tracer.ts @@ -1,6 +1,6 @@ -import { ConfigServiceInterface } from '../config'; -import { Handler } from 'aws-lambda'; -import { +import type { ConfigServiceInterface } from '../config'; +import type { Handler } from 'aws-lambda'; +import type { AsyncHandler, LambdaInterface, SyncHandler, diff --git a/packages/tracer/tests/e2e/allFeatures.decorator.test.functionCode.ts b/packages/tracer/tests/e2e/allFeatures.decorator.test.functionCode.ts index 6522cb3bff..90480bc3cd 100644 --- a/packages/tracer/tests/e2e/allFeatures.decorator.test.functionCode.ts +++ b/packages/tracer/tests/e2e/allFeatures.decorator.test.functionCode.ts @@ -1,5 +1,5 @@ import { Tracer } from '../../src'; -import { Callback, Context } from 'aws-lambda'; +import type { Callback, Context } from 'aws-lambda'; import AWS from 'aws-sdk'; import axios from 'axios'; diff --git a/packages/tracer/tests/e2e/allFeatures.manual.test.functionCode.ts b/packages/tracer/tests/e2e/allFeatures.manual.test.functionCode.ts index e878fdee08..f7bd2cda64 100644 --- a/packages/tracer/tests/e2e/allFeatures.manual.test.functionCode.ts +++ b/packages/tracer/tests/e2e/allFeatures.manual.test.functionCode.ts @@ -1,5 +1,5 @@ import { Tracer } from '../../src'; -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import axios from 'axios'; import AWS from 'aws-sdk'; import type { Subsegment } from 'aws-xray-sdk-core'; diff --git a/packages/tracer/tests/e2e/allFeatures.middy.test.functionCode.ts b/packages/tracer/tests/e2e/allFeatures.middy.test.functionCode.ts index 1b768052d9..2dd55050da 100644 --- a/packages/tracer/tests/e2e/allFeatures.middy.test.functionCode.ts +++ b/packages/tracer/tests/e2e/allFeatures.middy.test.functionCode.ts @@ -1,6 +1,6 @@ import middy from '@middy/core'; import { captureLambdaHandler, Tracer } from '../../src'; -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import { DynamoDBClient, PutItemCommand } from '@aws-sdk/client-dynamodb'; import axios from 'axios'; diff --git a/packages/tracer/tests/e2e/asyncHandler.decorator.test.functionCode.ts b/packages/tracer/tests/e2e/asyncHandler.decorator.test.functionCode.ts index d4cca85893..98ee23cbf1 100644 --- a/packages/tracer/tests/e2e/asyncHandler.decorator.test.functionCode.ts +++ b/packages/tracer/tests/e2e/asyncHandler.decorator.test.functionCode.ts @@ -1,5 +1,5 @@ import { Tracer } from '../../src'; -import { Context } from 'aws-lambda'; +import type { Context } from 'aws-lambda'; import { DynamoDBClient } from '@aws-sdk/client-dynamodb'; import { DynamoDBDocumentClient, PutCommand } from '@aws-sdk/lib-dynamodb'; import axios from 'axios'; diff --git a/packages/tracer/tests/tsconfig.json b/packages/tracer/tests/tsconfig.json new file mode 100644 index 0000000000..5654b3e15f --- /dev/null +++ b/packages/tracer/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "rootDir": "../", + "noEmit": true + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/tracer/tests/unit/Tracer.test.ts b/packages/tracer/tests/unit/Tracer.test.ts index 7aef53a05f..983764f65f 100644 --- a/packages/tracer/tests/unit/Tracer.test.ts +++ b/packages/tracer/tests/unit/Tracer.test.ts @@ -3,14 +3,13 @@ * * @group unit/tracer/all */ - import { ContextExamples as dummyContext, Events as dummyEvent, LambdaInterface, } from '@aws-lambda-powertools/commons'; -import { Tracer } from '../../src'; -import { Callback, Context } from 'aws-lambda/handler'; +import { Tracer } from './../../src'; +import type { Callback, Context } from 'aws-lambda/handler'; import { Segment, setContextMissingStrategy, @@ -535,8 +534,6 @@ describe('Class: Tracer', () => { class Lambda implements LambdaInterface { @tracer.captureLambdaHandler() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public handler( _event: TEvent, _context: Context, @@ -575,8 +572,6 @@ describe('Class: Tracer', () => { class Lambda implements LambdaInterface { @tracer.captureLambdaHandler({ captureResponse: false }) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public handler( _event: TEvent, _context: Context, @@ -614,8 +609,6 @@ describe('Class: Tracer', () => { class Lambda implements LambdaInterface { @tracer.captureLambdaHandler({ captureResponse: true }) - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public handler( _event: TEvent, _context: Context, @@ -661,8 +654,6 @@ describe('Class: Tracer', () => { class Lambda implements LambdaInterface { @tracer.captureLambdaHandler() - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore public handler( _event: TEvent, _context: Context, diff --git a/packages/tracer/tsconfig.es.json b/packages/tracer/tsconfig.es.json deleted file mode 100644 index 802f18e8f9..0000000000 --- a/packages/tracer/tsconfig.es.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ] - }, - "include": [ "src/**/*", "tests/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] -} \ No newline at end of file diff --git a/packages/tracer/tsconfig.json b/packages/tracer/tsconfig.json index 8b93f8c299..1cb9d72773 100644 --- a/packages/tracer/tsconfig.json +++ b/packages/tracer/tsconfig.json @@ -1,32 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "declarationMap": true, - "outDir": "lib", - "removeComments": false, - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 5fefd1f535..953342aef1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,53 @@ { - "compilerOptions": { - "experimentalDecorators": true, - "noImplicitAny": true, - "target": "ES2020", - "module": "commonjs", - "declaration": true, - "outDir": "lib", - "strict": true, - "inlineSourceMap": true, - "moduleResolution": "node", - "resolveJsonModule": true, - "pretty": true, - "baseUrl": "src/", - "rootDirs": [ "src/" ], - "esModuleInterop": true - }, - "include": [ "packages" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "node" - ] + "compilerOptions": { + "incremental": true, + "composite": true, + "target": "ES2020", // Node.js 14 + "experimentalDecorators": true, // TODO: remove this once we move to TypeScript 5.x + "module": "commonjs", + "moduleResolution": "node", // TODO: experiment with bundler & esnext + "baseUrl": ".", + // "traceResolution": true, // Enable this to debug module resolution issues + "declaration": true, + "removeComments": true, + // TODO: experiment with this & move to tslib in v2 + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // TODO: see if this can introduced in v2 (requires breaking changes in exports) + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + "declarationMap": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "pretty": true, // Enable pretty formatting for output messages. + }, + "files": [], + "references": [ + { + "path": "./packages/commons" + }, + { + "path": "./packages/tracer" + }, + { + "path": "./packages/metrics" + }, + { + "path": "./packages/logger" + }, + { + "path": "./packages/parameters" + }, + { + "path": "./packages/idempotency" + }, + { + "path": "./packages/batch" + }, + { + "path": "./packages/testing" + }, + ] } \ No newline at end of file