From f0662d429dc3ae95ebe11556bb57a55f32b0725b Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Fri, 25 Aug 2023 12:17:26 +0000 Subject: [PATCH 01/23] chore(ci): update tsconfig --- .gitignore | 5 +- .npmignore | 3 +- packages/commons/package.json | 2 +- packages/commons/tsconfig-dev.json | 31 ------- packages/commons/tsconfig.json | 31 ++----- packages/tracer/package.json | 2 +- packages/tracer/tests/tsconfig.json | 10 +++ packages/tracer/tests/unit/Tracer.test.ts | 5 +- packages/tracer/tsconfig.es.json | 31 ------- packages/tracer/tsconfig.json | 33 ++----- tsconfig.json | 105 ++++++++++++++++------ 11 files changed, 108 insertions(+), 150 deletions(-) delete mode 100644 packages/commons/tsconfig-dev.json create mode 100644 packages/tracer/tests/tsconfig.json delete mode 100644 packages/tracer/tsconfig.es.json 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/packages/commons/package.json b/packages/commons/package.json index b47028a343..513042f44e 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -15,7 +15,7 @@ "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", 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..77db56af90 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", /* Specify an output folder for all emitted files. */ + "rootDir": "./src", /* Specify the root folder within your source files. */ + // "baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ }, "include": [ "src/**/*" ], - "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/package.json b/packages/tracer/package.json index 5fb5298b13..6926ac1a6f 100644 --- a/packages/tracer/package.json +++ b/packages/tracer/package.json @@ -17,7 +17,7 @@ "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", diff --git a/packages/tracer/tests/tsconfig.json b/packages/tracer/tests/tsconfig.json new file mode 100644 index 0000000000..b8b3dec2fb --- /dev/null +++ b/packages/tracer/tests/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "rootDir": "." + }, + "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..8220a03675 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, 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..b8081b0a8a 100644 --- a/packages/tracer/tsconfig.json +++ b/packages/tracer/tsconfig.json @@ -1,32 +1,11 @@ { + "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", /* Specify an output folder for all emitted files. */ + "rootDir": "./src", /* Specify the root folder within your source files. */ + "paths": { + "@aws-lambda-powertools/commons": ["../../commons"], + } }, "include": [ "src/**/*" ], - "exclude": [ "./node_modules"], - "watchOptions": { - "watchFile": "useFsEvents", - "watchDirectory": "useFsEvents", - "fallbackPolling": "dynamicPriority" - }, - "lib": [ "es2020" ], - "types": [ - "jest", - "node" - ] } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 5fefd1f535..49c2425516 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,29 +1,78 @@ { - "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" - ] -} \ No newline at end of file + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + + /* Modules */ + "module": "commonjs", /* Specify what module code is generated. */ + // "rootDir": "./", /* Specify the root folder within your source files. */ + "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "src/", /* Specify the base directory to resolve non-relative module names. */ + // "traceResolution": true, /* Enable tracing of the name resolution process. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + + /* Emit */ + "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "removeComments": true, /* Disable emitting comments. */ + // "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. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + + /* Output Formatting */ + "pretty": true, /* Enable pretty formatting for output messages. */ + }, + // "include": [ "packages" ], + "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" }, + ] +} From 28bbc0b641abbbaffc3e46329d5efb412f886fd9 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Fri, 25 Aug 2023 15:19:08 +0200 Subject: [PATCH 02/23] wip --- .../src/config/EnvironmentVariablesService.ts | 2 +- packages/commons/src/middleware/constants.ts | 2 +- .../samples/resources/contexts/hello-world.ts | 2 +- .../src/utils/lambda/LambdaInterface.ts | 2 +- packages/commons/tests/tsconfig.json | 10 ++ packages/logger/package.json | 4 +- packages/logger/tsconfig-dev.json | 30 ----- packages/logger/tsconfig.es.json | 30 ----- packages/logger/tsconfig.json | 32 +---- tsconfig.json | 115 +++++++----------- 10 files changed, 69 insertions(+), 160 deletions(-) create mode 100644 packages/commons/tests/tsconfig.json delete mode 100644 packages/logger/tsconfig-dev.json delete mode 100644 packages/logger/tsconfig.es.json 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..63dac727a0 --- /dev/null +++ b/packages/commons/tests/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "rootDir": "../" + }, + "include": [ + "../src/**/*", + "./**/*", + ] +} \ No newline at end of file diff --git a/packages/logger/package.json b/packages/logger/package.json index 321648326c..5e47002be6 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -17,7 +17,7 @@ "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", @@ -58,4 +58,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file 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..0819286624 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/tsconfig.json b/tsconfig.json index 49c2425516..c4d7e58f90 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,78 +1,57 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Projects */ - "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ - "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ - "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - - /* Modules */ - "module": "commonjs", /* Specify what module code is generated. */ - // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ - // "baseUrl": "src/", /* Specify the base directory to resolve non-relative module names. */ - // "traceResolution": true, /* Enable tracing of the name resolution process. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - - /* Emit */ - "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "removeComments": true, /* Disable emitting comments. */ + "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 + "paths": { + "@aws-lambda-powertools/*": [ + "packages/*/" + ], + }, + "declaration": true, + "removeComments": true, + // TODO: experiment with this & move to tslib instead // "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. */ - - /* Interop Constraints */ + // TODO: check if this is needed // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ - "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ - "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - "strict": true, /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ - // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - "skipLibCheck": true, /* Skip type checking all .d.ts files. */ - - /* Output Formatting */ - "pretty": true, /* Enable pretty formatting for output messages. */ + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "pretty": true, /* Enable pretty formatting for output messages. */ }, - // "include": [ "packages" ], "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" }, + { + "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 From 9d83ddc8624095858ea8106440ceffaa9b78087d Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 15:28:06 +0200 Subject: [PATCH 03/23] wip --- packages/tracer/src/Tracer.ts | 17 ++++++++++------- packages/tracer/src/TracerInterface.ts | 4 ++-- packages/tracer/src/helpers.ts | 2 +- packages/tracer/src/types/Tracer.ts | 6 +++--- packages/tracer/tests/tsconfig.json | 2 +- packages/tracer/tests/unit/Tracer.test.ts | 8 -------- packages/tracer/tsconfig.json | 11 +++++------ tsconfig.json | 11 ++++++----- 8 files changed, 28 insertions(+), 33 deletions(-) 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/tsconfig.json b/packages/tracer/tests/tsconfig.json index b8b3dec2fb..336209e739 100644 --- a/packages/tracer/tests/tsconfig.json +++ b/packages/tracer/tests/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.json", + "extends": "../tsconfig.json", "compilerOptions": { "rootDir": "." }, diff --git a/packages/tracer/tests/unit/Tracer.test.ts b/packages/tracer/tests/unit/Tracer.test.ts index 8220a03675..983764f65f 100644 --- a/packages/tracer/tests/unit/Tracer.test.ts +++ b/packages/tracer/tests/unit/Tracer.test.ts @@ -534,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, @@ -574,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, @@ -613,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, @@ -660,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.json b/packages/tracer/tsconfig.json index b8081b0a8a..1cb9d72773 100644 --- a/packages/tracer/tsconfig.json +++ b/packages/tracer/tsconfig.json @@ -1,11 +1,10 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "./lib", /* Specify an output folder for all emitted files. */ - "rootDir": "./src", /* Specify the root folder within your source files. */ - "paths": { - "@aws-lambda-powertools/commons": ["../../commons"], - } + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], + "include": [ + "./src/**/*" + ], } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index c4d7e58f90..b559c211aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,11 @@ "moduleResolution": "node", // TODO: experiment with bundler & esnext "baseUrl": ".", // "traceResolution": true, // Enable this to debug module resolution issues - "paths": { - "@aws-lambda-powertools/*": [ - "packages/*/" - ], - }, + // "paths": { + // "@aws-lambda-powertools/*": [ + // "packages/*/" + // ], + // }, "declaration": true, "removeComments": true, // TODO: experiment with this & move to tslib instead @@ -21,6 +21,7 @@ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ // TODO: check if this is needed // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + "declarationMap": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, From 9bc0d2f3721a4bdbece7171865a7da2702220274 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 15:56:57 +0200 Subject: [PATCH 04/23] chore: tsconfig batch --- packages/batch/package.json | 2 +- packages/batch/src/constants.ts | 6 ++- packages/batch/src/types.ts | 2 +- packages/batch/tests/tsconfig.json | 11 ++++++ .../tests/unit/AsyncBatchProcessor.test.ts | 2 +- .../batch/tests/unit/BatchProcessor.test.ts | 2 +- .../unit/asyncProcessPartialResponse.test.ts | 4 +- .../tests/unit/processPartialResponse.test.ts | 4 +- packages/batch/tsconfig-dev.json | 11 ------ packages/batch/tsconfig.es.json | 11 ------ packages/batch/tsconfig.json | 37 +++++-------------- 11 files changed, 33 insertions(+), 59 deletions(-) create mode 100644 packages/batch/tests/tsconfig.json delete mode 100644 packages/batch/tsconfig-dev.json delete mode 100644 packages/batch/tsconfig.es.json 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 From 804d4d4e8769c2dd25bf758977368773ea59d59e Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 15:57:55 +0200 Subject: [PATCH 05/23] chore: tsconfig commons --- packages/commons/tests/tsconfig.json | 5 +++-- packages/commons/tests/unit/LambdaInterface.test.ts | 4 ---- packages/commons/tsconfig.json | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/commons/tests/tsconfig.json b/packages/commons/tests/tsconfig.json index 63dac727a0..5654b3e15f 100644 --- a/packages/commons/tests/tsconfig.json +++ b/packages/commons/tests/tsconfig.json @@ -1,7 +1,8 @@ { - "extends": "../../../tsconfig.json", + "extends": "../tsconfig.json", "compilerOptions": { - "rootDir": "../" + "rootDir": "../", + "noEmit": true }, "include": [ "../src/**/*", 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.json b/packages/commons/tsconfig.json index 77db56af90..1cb9d72773 100644 --- a/packages/commons/tsconfig.json +++ b/packages/commons/tsconfig.json @@ -1,10 +1,10 @@ { "extends": "../../tsconfig.json", "compilerOptions": { - "outDir": "./lib", /* Specify an output folder for all emitted files. */ - "rootDir": "./src", /* Specify the root folder within your source files. */ - // "baseUrl": "./src", /* Specify the base directory to resolve non-relative module names. */ - // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + "outDir": "./lib", + "rootDir": "./src", }, - "include": [ "src/**/*" ], + "include": [ + "./src/**/*" + ], } \ No newline at end of file From 673d4693989efd77b7bf3d46316c91de29d914bc Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 15:59:06 +0200 Subject: [PATCH 06/23] chore: tsconfig commons --- packages/commons/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/commons/package.json b/packages/commons/package.json index 513042f44e..2bcdbcb0c7 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -22,8 +22,7 @@ "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.ts": "npm run lint-fix", - "*.js": "npm run lint-fix" + "*.{ts, js}": "npm run lint-fix" }, "homepage": "https://github.com/aws-powertools/powertools-lambda-typescript/tree/main/packages/metrics#readme", "license": "MIT-0", From 048f70e3562f58767bff7be020d149092f015f1a Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:01:08 +0200 Subject: [PATCH 07/23] chore: tsconfig idempotency --- packages/idempotency/package.json | 5 ++-- packages/idempotency/tests/tsconfig.json | 11 +++++++ packages/idempotency/tsconfig-dev.json | 11 ------- packages/idempotency/tsconfig.es.json | 11 ------- packages/idempotency/tsconfig.json | 37 ++++++------------------ 5 files changed, 22 insertions(+), 53 deletions(-) create mode 100644 packages/idempotency/tests/tsconfig.json delete mode 100644 packages/idempotency/tsconfig-dev.json delete mode 100644 packages/idempotency/tsconfig.es.json diff --git a/packages/idempotency/package.json b/packages/idempotency/package.json index 5ed19121b3..19bf9453b6 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" + "*.{ts, js}": "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 From 6426db0f1f12ae9a9ce89b38aeb5ebbcd97bd86e Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:04:05 +0200 Subject: [PATCH 08/23] chore: tsconfig testing --- packages/testing/package.json | 2 +- packages/testing/tests/tsconfig.json | 11 +++++++++ packages/testing/tsconfig.json | 34 +++++----------------------- 3 files changed, 18 insertions(+), 29 deletions(-) create mode 100644 packages/testing/tests/tsconfig.json 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.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 From eb5b33aac06dc6d7b31886400f0a7f95a0a50a61 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:04:55 +0200 Subject: [PATCH 09/23] chore: tsconfig tracer --- packages/tracer/package.json | 3 +-- .../tests/e2e/allFeatures.decorator.test.functionCode.ts | 2 +- .../tracer/tests/e2e/allFeatures.manual.test.functionCode.ts | 2 +- .../tracer/tests/e2e/allFeatures.middy.test.functionCode.ts | 2 +- .../tests/e2e/asyncHandler.decorator.test.functionCode.ts | 2 +- packages/tracer/tests/tsconfig.json | 3 ++- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/tracer/package.json b/packages/tracer/package.json index 6926ac1a6f..6e9c6dae66 100644 --- a/packages/tracer/package.json +++ b/packages/tracer/package.json @@ -24,8 +24,7 @@ "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/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 index 336209e739..5654b3e15f 100644 --- a/packages/tracer/tests/tsconfig.json +++ b/packages/tracer/tests/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "rootDir": "." + "rootDir": "../", + "noEmit": true }, "include": [ "../src/**/*", From 13617647d99ee17cce9ba6b7d8904ca2c3bbf6fe Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:39:10 +0200 Subject: [PATCH 10/23] chore: tsconfig parameters --- packages/parameters/package.json | 5 +-- ...pConfigProvider.class.test.functionCode.ts | 10 ++--- ...ynamoDBProvider.class.test.functionCode.ts | 10 ++--- ...secretsProvider.class.test.functionCode.ts | 6 +-- .../ssmProvider.class.test.functionCode.ts | 10 ++--- .../helpers/sdkMiddlewareRequestCounter.ts | 41 ++++++++++++------- packages/parameters/tests/tsconfig.json | 11 +++++ packages/parameters/tsconfig.json | 32 +++------------ 8 files changed, 64 insertions(+), 61 deletions(-) create mode 100644 packages/parameters/tests/tsconfig.json 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/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.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 From fbf9172770693afa25a0047617be1dd4be801b7a Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:39:42 +0200 Subject: [PATCH 11/23] chore: tsconfig metrics --- packages/metrics/package.json | 7 ++-- packages/metrics/src/Metrics.ts | 7 ++-- .../src/config/EnvironmentVariablesService.ts | 2 +- packages/metrics/src/types/Metrics.ts | 4 +-- ...sicFeatures.decorator.test.functionCode.ts | 4 +-- .../basicFeatures.manual.test.functionCode.ts | 2 +- packages/metrics/tests/tsconfig.json | 11 ++++++ packages/metrics/tests/unit/Metrics.test.ts | 2 -- .../tests/unit/middleware/middy.test.ts | 4 +-- packages/metrics/tsconfig.es.json | 31 ----------------- packages/metrics/tsconfig.json | 34 ++++--------------- 11 files changed, 33 insertions(+), 75 deletions(-) create mode 100644 packages/metrics/tests/tsconfig.json delete mode 100644 packages/metrics/tsconfig.es.json 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 From df90449957535cd4613ad67e1dcdf3f2656e65f5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:39:53 +0200 Subject: [PATCH 12/23] chore: tsconfig logger --- packages/logger/package.json | 3 +-- packages/logger/tests/tsconfig.json | 11 +++++++++++ packages/logger/tests/unit/Logger.test.ts | 22 +--------------------- packages/logger/tsconfig.json | 2 +- 4 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 packages/logger/tests/tsconfig.json diff --git a/packages/logger/package.json b/packages/logger/package.json index 5e47002be6..0d2aceaa24 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -24,8 +24,7 @@ "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", 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.json b/packages/logger/tsconfig.json index 0819286624..1cb9d72773 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -5,6 +5,6 @@ "rootDir": "./src", }, "include": [ - "src/**/*" + "./src/**/*" ], } \ No newline at end of file From 44f1e1616b03e01f613ba59a6af796f7c9b2666d Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:40:07 +0200 Subject: [PATCH 13/23] chore: main tsconfig --- packages/commons/package.json | 2 +- packages/idempotency/package.json | 2 +- tsconfig.json | 5 ----- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/commons/package.json b/packages/commons/package.json index 2bcdbcb0c7..a7bbde3aeb 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -22,7 +22,7 @@ "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.{ts, 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/idempotency/package.json b/packages/idempotency/package.json index 19bf9453b6..059588447d 100644 --- a/packages/idempotency/package.json +++ b/packages/idempotency/package.json @@ -24,7 +24,7 @@ "prepack": "node ../../.github/scripts/release_patch_package_json.js ." }, "lint-staged": { - "*.{ts, 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/tsconfig.json b/tsconfig.json index b559c211aa..113e770930 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,11 +8,6 @@ "moduleResolution": "node", // TODO: experiment with bundler & esnext "baseUrl": ".", // "traceResolution": true, // Enable this to debug module resolution issues - // "paths": { - // "@aws-lambda-powertools/*": [ - // "packages/*/" - // ], - // }, "declaration": true, "removeComments": true, // TODO: experiment with this & move to tslib instead From 161a28cd544e3eb88a32cc9f9b61f916b158d8c5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:42:42 +0200 Subject: [PATCH 14/23] chore: tsconfig layers --- layers/package.json | 3 +-- layers/tests/tsconfig.json | 11 +++++++++++ layers/tsconfig.es.json | 31 ------------------------------ layers/tsconfig.json | 39 ++++++++++---------------------------- 4 files changed, 22 insertions(+), 62 deletions(-) create mode 100644 layers/tests/tsconfig.json delete mode 100644 layers/tsconfig.es.json 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..5654b3e15f --- /dev/null +++ b/layers/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/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..468dd83447 100644 --- a/layers/tsconfig.json +++ b/layers/tsconfig.json @@ -1,30 +1,11 @@ { - "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": "./", + }, + "include": [ + "./src/**/*", + "./bin/**/*" + ], +} \ No newline at end of file From 8a518ccbcad196288c8343eb34289ab4b927eab2 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:45:06 +0200 Subject: [PATCH 15/23] chore: tsconfig docs --- docs/snippets/tsconfig.json | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) 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"] + } } From 46787ce2f1ef970a2e3f212c8c5b2bbd0c8cc292 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:49:38 +0200 Subject: [PATCH 16/23] chore: add resolveJsonModules to layers --- layers/tests/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/layers/tests/tsconfig.json b/layers/tests/tsconfig.json index 5654b3e15f..abc27d8bc5 100644 --- a/layers/tests/tsconfig.json +++ b/layers/tests/tsconfig.json @@ -2,10 +2,12 @@ "extends": "../tsconfig.json", "compilerOptions": { "rootDir": "../", - "noEmit": true + "noEmit": true, + "resolveJsonModule": true }, "include": [ "../src/**/*", + "../package.json", "./**/*", ] } \ No newline at end of file From 7ee92bab6cad5983550ab479a0edb0331bf517fe Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 16:57:37 +0200 Subject: [PATCH 17/23] chore: add comments to tsconfig --- tsconfig.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 113e770930..953342aef1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,18 +10,18 @@ // "traceResolution": true, // Enable this to debug module resolution issues "declaration": true, "removeComments": true, - // TODO: experiment with this & move to tslib instead + // 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: check if this is needed - // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // 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. */ + "pretty": true, // Enable pretty formatting for output messages. }, "files": [], "references": [ From cdcb6363348adc3e1907761cf47d0d46e491d1a4 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 2 Sep 2023 17:06:21 +0200 Subject: [PATCH 18/23] chore: add resolveJsonModules to layers --- layers/tests/tsconfig.json | 3 +-- layers/tsconfig.json | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layers/tests/tsconfig.json b/layers/tests/tsconfig.json index abc27d8bc5..a07fdb8a65 100644 --- a/layers/tests/tsconfig.json +++ b/layers/tests/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../tsconfig.json", "compilerOptions": { "rootDir": "../", - "noEmit": true, - "resolveJsonModule": true + "noEmit": true }, "include": [ "../src/**/*", diff --git a/layers/tsconfig.json b/layers/tsconfig.json index 468dd83447..4acbde11be 100644 --- a/layers/tsconfig.json +++ b/layers/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "outDir": "./lib", "rootDir": "./", + "resolveJsonModule": true }, "include": [ "./src/**/*", From 2ed3d7d033bc94f4b030795b4efd7548170fbae5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sun, 3 Sep 2023 10:56:57 +0200 Subject: [PATCH 19/23] chore: rebase --- packages/parameters/tests/helpers/resources.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index 4b29d66e32..9a9e447a83 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -48,18 +48,16 @@ class TestSecureStringParameter extends Construct { }, extraProps: ExtraTestProps ) { - super( - testStack.stack, - concatenateResourceName({ - testName: testStack.testName, - resourceName: randomUUID(), - }) - ); + const parameterId = concatenateResourceName({ + testName: testStack.testName, + resourceName: randomUUID(), + }); + + super(testStack.stack, parameterId); const { value } = props; const name = `/secure/${getRuntimeKey()}/${randomUUID()}`; - const secureStringCreator = new AwsCustomResource( testStack.stack, `create-${randomUUID()}`, From 6364b0e2603e6fcb297ce7dde2bb128b8d19f81a Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sun, 3 Sep 2023 11:11:29 +0200 Subject: [PATCH 20/23] fix: test --- packages/parameters/tests/helpers/resources.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/parameters/tests/helpers/resources.ts b/packages/parameters/tests/helpers/resources.ts index 9a9e447a83..7067f608fd 100644 --- a/packages/parameters/tests/helpers/resources.ts +++ b/packages/parameters/tests/helpers/resources.ts @@ -48,12 +48,13 @@ class TestSecureStringParameter extends Construct { }, extraProps: ExtraTestProps ) { - const parameterId = concatenateResourceName({ - testName: testStack.testName, - resourceName: randomUUID(), - }); - - super(testStack.stack, parameterId); + super( + testStack.stack, + concatenateResourceName({ + testName: testStack.testName, + resourceName: randomUUID(), + }) + ); const { value } = props; From 5e9a3e1169c20a6063692323eb5d2a14b05fb2c5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Mon, 4 Sep 2023 11:26:11 +0200 Subject: [PATCH 21/23] chore: removed orphaned configs --- packages/parameters/tsconfig-dev.json | 30 -------------------------- packages/parameters/tsconfig.es.json | 30 -------------------------- packages/testing/tsconfig.es.json | 31 --------------------------- 3 files changed, 91 deletions(-) delete mode 100644 packages/parameters/tsconfig-dev.json delete mode 100644 packages/parameters/tsconfig.es.json delete mode 100644 packages/testing/tsconfig.es.json 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/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 From dfd0a1e55904a343e154757327dbb244bd27aacc Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Mon, 4 Sep 2023 11:27:04 +0200 Subject: [PATCH 22/23] test: workspace build --- .github/actions/cached-node-modules/action.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/actions/cached-node-modules/action.yml b/.github/actions/cached-node-modules/action.yml index d86c8d7b10..af78ce18af 100644 --- a/.github/actions/cached-node-modules/action.yml +++ b/.github/actions/cached-node-modules/action.yml @@ -34,12 +34,5 @@ runs: # even though we could just run `npm run build` in the root folder and build them in # sequence, but still in the correct order. run: | - npm run build -w packages/commons - npm run build -w packages/logger & \ - npm run build -w packages/tracer & \ - npm run build -w packages/metrics & \ - npm run build -w packages/parameters & \ - npm run build -w packages/idempotency & \ - npm run build -w packages/batch & \ - npm run build -w packages/testing + npm run build -ws shell: bash \ No newline at end of file From 72725283a522171de4a728bb93745b319e6ddef5 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Mon, 4 Sep 2023 11:50:35 +0200 Subject: [PATCH 23/23] revert workspace build --- .github/actions/cached-node-modules/action.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/actions/cached-node-modules/action.yml b/.github/actions/cached-node-modules/action.yml index af78ce18af..d86c8d7b10 100644 --- a/.github/actions/cached-node-modules/action.yml +++ b/.github/actions/cached-node-modules/action.yml @@ -34,5 +34,12 @@ runs: # even though we could just run `npm run build` in the root folder and build them in # sequence, but still in the correct order. run: | - npm run build -ws + npm run build -w packages/commons + npm run build -w packages/logger & \ + npm run build -w packages/tracer & \ + npm run build -w packages/metrics & \ + npm run build -w packages/parameters & \ + npm run build -w packages/idempotency & \ + npm run build -w packages/batch & \ + npm run build -w packages/testing shell: bash \ No newline at end of file