From c12cddfb53dbab88ba529100049e3706bccc8e71 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Sat, 16 Sep 2023 07:06:22 +0200 Subject: [PATCH] chore(maintenance): bump dependencies & drop nodejs14x (#1687) --- .github/ISSUE_TEMPLATE/bug_report.yml | 12 +- ...sable-run-linting-check-and-unit-tests.yml | 4 +- docs/snippets/package.json | 2 +- examples/cdk/package.json | 2 +- examples/sam/package.json | 2 +- layers/package.json | 2 +- lerna.json | 5 +- package-lock.json | 442 ++++++++++++--- packages/batch/package.json | 2 +- packages/commons/package.json | 2 +- packages/idempotency/package.json | 2 +- packages/logger/package.json | 3 +- .../formatter/PowertoolsLogFormatter.test.ts | 528 ++++++++---------- packages/metrics/package.json | 5 +- packages/parameters/package.json | 4 +- packages/testing/package.json | 2 +- packages/tracer/package.json | 4 +- 17 files changed, 612 insertions(+), 411 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 06af982ec3..3b9c913987 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,14 +1,14 @@ name: Bug report description: Report a reproducible bug to help us improve -title: "Bug: TITLE" -labels: ["type/bug", "triage"] -projects: ["aws-powertools/7"] +title: 'Bug: TITLE' +labels: ['type/bug', 'triage'] +projects: ['aws-powertools/7'] body: - type: markdown attributes: value: | Thank you for submitting a bug report. Before you start, make sure that [the bug hasn't been reported already](https://github.com/aws-powertools/powertools-lambda-typescript/issues). - + Please add as much information as possible to help us reproduce, and remove any potential sensitive data. - type: textarea id: expected_behaviour @@ -58,7 +58,7 @@ body: id: version attributes: label: Powertools for AWS Lambda (TypeScript) version - placeholder: "latest, 1.3.0" + placeholder: 'latest, 2.0.0' value: latest validations: required: true @@ -95,4 +95,4 @@ body: value: | --- - **Disclaimer**: After creating an issue, please wait until it is triaged and confirmed by a maintainer before implementing it. This will reduce amount of rework and the chance that a pull request gets rejected. \ No newline at end of file + **Disclaimer**: After creating an issue, please wait until it is triaged and confirmed by a maintainer before implementing it. This will reduce amount of rework and the chance that a pull request gets rejected. diff --git a/.github/workflows/reusable-run-linting-check-and-unit-tests.yml b/.github/workflows/reusable-run-linting-check-and-unit-tests.yml index ba815e62e2..9f4e61eda8 100644 --- a/.github/workflows/reusable-run-linting-check-and-unit-tests.yml +++ b/.github/workflows/reusable-run-linting-check-and-unit-tests.yml @@ -22,7 +22,7 @@ jobs: uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 with: node-version: ${{ matrix.version }} - cache: "npm" + cache: 'npm' - name: Setup dependencies uses: ./.github/actions/cached-node-modules with: @@ -37,7 +37,7 @@ jobs: NODE_ENV: dev strategy: matrix: - example: ["sam", "cdk"] + example: ['sam', 'cdk'] fail-fast: false defaults: run: diff --git a/docs/snippets/package.json b/docs/snippets/package.json index 82edc6afd3..3de51388b2 100644 --- a/docs/snippets/package.json +++ b/docs/snippets/package.json @@ -1,6 +1,6 @@ { "name": "docs", - "version": "1.9.0", + "version": "2.0.0", "description": "A collection code snippets for the Powertools for AWS Lambda (TypeScript) docs", "author": { "name": "Amazon Web Services", diff --git a/examples/cdk/package.json b/examples/cdk/package.json index 9fe5811678..206b646d60 100644 --- a/examples/cdk/package.json +++ b/examples/cdk/package.json @@ -50,4 +50,4 @@ "phin": "^3.7.0", "source-map-support": "^0.5.21" } -} +} \ No newline at end of file diff --git a/examples/sam/package.json b/examples/sam/package.json index 774b369380..9dda11b666 100644 --- a/examples/sam/package.json +++ b/examples/sam/package.json @@ -41,4 +41,4 @@ "@middy/core": "^4.7.0", "phin": "^3.7.0" } -} +} \ No newline at end of file diff --git a/layers/package.json b/layers/package.json index e87dc85839..f67ce182c4 100644 --- a/layers/package.json +++ b/layers/package.json @@ -43,4 +43,4 @@ "aws-cdk-lib": "^2.123.0", "esbuild": "^0.19.12" } -} +} \ No newline at end of file diff --git a/lerna.json b/lerna.json index 0d5c694d5d..7786f33aa6 100644 --- a/lerna.json +++ b/lerna.json @@ -10,9 +10,10 @@ "packages/testing", "examples/cdk", "examples/sam", - "layers" + "layers", + "docs/snippets" ], "version": "1.18.0", "npmClient": "npm", "message": "chore(release): %s [skip ci]" -} +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e2040576d8..a41e4c580f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,7 @@ }, "docs/snippets": { "name": "docs", - "version": "1.9.0", + "version": "2.0.0", "license": "MIT-0", "devDependencies": { "@aws-sdk/client-appconfigdata": "^3.499.0", @@ -6281,29 +6281,6 @@ "node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0" } }, - "node_modules/aws-sdk/node_modules/buffer": { - "version": "4.9.2", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", - "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", - "dev": true, - "dependencies": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4", - "isarray": "^1.0.0" - } - }, - "node_modules/aws-sdk/node_modules/ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", - "dev": true - }, - "node_modules/aws-sdk/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", - "dev": true - }, "node_modules/aws-sdk/node_modules/uuid": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.0.0.tgz", @@ -6459,8 +6436,7 @@ "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" }, "node_modules/base64-js": { "version": "1.5.1", @@ -6499,11 +6475,47 @@ "readable-stream": "^3.4.0" } }, + "node_modules/bl/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, "node_modules/bowser": { "version": "2.11.0", "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.11.0.tgz", "integrity": "sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==" }, + "node_modules/bplist-parser": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.2.0.tgz", + "integrity": "sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==", + "dev": true, + "dependencies": { + "big-integer": "^1.6.44" + }, + "engines": { + "node": ">= 5.10.0" + } + }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", @@ -6579,27 +6591,14 @@ } }, "node_modules/buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", + "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" + "base64-js": "^1.0.2", + "ieee754": "^1.1.4", + "isarray": "^1.0.0" } }, "node_modules/buffer-from": { @@ -6616,6 +6615,21 @@ "semver": "^7.0.0" } }, + "node_modules/bundle-name": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-3.0.0.tgz", + "integrity": "sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==", + "dev": true, + "dependencies": { + "run-applescript": "^5.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/byte-size": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/byte-size/-/byte-size-8.1.1.tgz", @@ -7163,8 +7177,7 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, "node_modules/concat-stream": { "version": "2.0.0", @@ -7496,6 +7509,150 @@ "node": ">=0.10.0" } }, + "node_modules/default-browser": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/default-browser/-/default-browser-4.0.0.tgz", + "integrity": "sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==", + "dev": true, + "dependencies": { + "bundle-name": "^3.0.0", + "default-browser-id": "^3.0.0", + "execa": "^7.1.1", + "titleize": "^3.0.0" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser-id": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-3.0.0.tgz", + "integrity": "sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==", + "dev": true, + "dependencies": { + "bplist-parser": "^0.2.0", + "untildify": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/execa": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-7.2.0.tgz", + "integrity": "sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.1", + "human-signals": "^4.3.0", + "is-stream": "^3.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^5.1.0", + "onetime": "^6.0.0", + "signal-exit": "^3.0.7", + "strip-final-newline": "^3.0.0" + }, + "engines": { + "node": "^14.18.0 || ^16.14.0 || >=18.0.0" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/default-browser/node_modules/human-signals": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-4.3.1.tgz", + "integrity": "sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==", + "dev": true, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/default-browser/node_modules/is-stream": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-3.0.0.tgz", + "integrity": "sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/mimic-fn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", + "integrity": "sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/npm-run-path": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-5.1.0.tgz", + "integrity": "sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==", + "dev": true, + "dependencies": { + "path-key": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/onetime": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-6.0.0.tgz", + "integrity": "sha512-1FlR+gjXK7X+AsAHso35MnyN5KqGwJRi/31ft6x0M194ht7S+rWAvd7PHss9xSKMzE0asv1pyIHaJYq+BbacAQ==", + "dev": true, + "dependencies": { + "mimic-fn": "^4.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/path-key": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-4.0.0.tgz", + "integrity": "sha512-haREypq7xkM7ErfgIyA0z+Bj4AGKlMSdlQE2jvJo6huWD1EdkKYV+G/T4nq0YEF2vgTT8kqMFKo1uHn950r4SQ==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/default-browser/node_modules/strip-final-newline": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-3.0.0.tgz", + "integrity": "sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/defaults": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", @@ -7588,9 +7745,9 @@ } }, "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", + "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", "dev": true, "engines": { "node": ">=0.3.1" @@ -9215,8 +9372,7 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" }, "node_modules/graphemer": { "version": "1.4.0", @@ -9468,24 +9624,10 @@ } }, "node_modules/ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ] + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", + "dev": true }, "node_modules/ignore": { "version": "5.3.0", @@ -9882,6 +10024,39 @@ "node": ">=0.10.0" } }, + "node_modules/is-inside-container": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz", + "integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==", + "dev": true, + "dependencies": { + "is-docker": "^3.0.0" + }, + "bin": { + "is-inside-container": "cli.js" + }, + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-inside-container/node_modules/is-docker": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", + "integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-interactive": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", @@ -10112,9 +10287,9 @@ } }, "node_modules/isarray": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", - "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", "dev": true }, "node_modules/isexe": { @@ -10930,7 +11105,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", - "dev": true, "dependencies": { "universalify": "^2.0.0" }, @@ -12790,18 +12964,18 @@ "dev": true }, "node_modules/nopt": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.0.tgz", - "integrity": "sha512-CVDtwCdhYIvnAzFoJ6NJ6dX3oga9/HyciQDnG1vQDjSLMeKLJ4A93ZqYKDrgYSr1FBY5/hMYC+2VCi24pgpkGA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-6.0.0.tgz", + "integrity": "sha512-ZwLpbTgdhuZUnZzjd7nb1ZV+4DoiC6/sfiVKok72ym/4Tlf+DFdlHYmT2JPmcNNWV6Pi3SDf1kT+A4r9RTuT9g==", "dev": true, "dependencies": { - "abbrev": "^2.0.0" + "abbrev": "^1.0.0" }, "bin": { "nopt": "bin/nopt.js" }, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/normalize-package-data": { @@ -13008,6 +13182,36 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/npm-pick-manifest/node_modules/hosted-git-info": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-6.1.1.tgz", + "integrity": "sha512-r0EI+HBMcXadMrugk0GCQ+6BQV39PiWAZVfq7oIckeGiN7sjRGyQxPdft3nQekFTCQbYxLBH+/axZMeH8UX6+w==", + "dev": true, + "dependencies": { + "lru-cache": "^7.5.1" + }, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/npm-pick-manifest/node_modules/lru-cache": { + "version": "7.18.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", + "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/npm-pick-manifest/node_modules/npm-normalize-package-bin": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz", + "integrity": "sha512-dMxCf+zZ+3zeQZXKxmyuCKlIDPGuv8EF940xbkC4kQVDTtqoh6rJFO+JTKSA6/Rwi0getWmtuy4Itup0AMcaDQ==", + "dev": true, + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, "node_modules/npm-pick-manifest/node_modules/npm-package-arg": { "version": "11.0.1", "resolved": "https://registry.npmjs.org/npm-package-arg/-/npm-package-arg-11.0.1.tgz", @@ -13345,6 +13549,18 @@ "node": ">=10" } }, + "node_modules/nx/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/nx/node_modules/minimatch": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.5.tgz", @@ -13879,7 +14095,7 @@ "integrity": "sha512-aatBvbL26wVUCLmbWdCpeu9iF5wOyWpagiKkInA+kfws3sWdBrTnsvN2CKcyCYyUrc7rebNBlK6+kteg7ksecg==", "dev": true, "engines": { - "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + "node": ">=12" } }, "node_modules/pacote/node_modules/lru-cache": { @@ -15037,6 +15253,21 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/run-applescript": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-5.0.0.tgz", + "integrity": "sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==", + "dev": true, + "dependencies": { + "execa": "^5.0.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -15096,6 +15327,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/safe-array-concat/node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -16257,6 +16494,15 @@ } } }, + "node_modules/ts-node/node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/tsconfig-paths": { "version": "3.15.0", "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", @@ -16668,6 +16914,15 @@ "node": ">= 10.0.0" } }, + "node_modules/untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/upath": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/upath/-/upath-2.0.1.tgz", @@ -17193,6 +17448,11 @@ } } }, + "packages/idempotency/node_modules/@aws-lambda-powertools/commons": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@aws-lambda-powertools/commons/-/commons-1.12.1.tgz", + "integrity": "sha512-VChNfDUxxcB5KTfQPkJgxYihEZkrmeOzU9/A9FRBc+3v33EEM59T2pIgBkFy0VoINvGi3MoBEln/wyu2jV0ivA==" + }, "packages/logger": { "name": "@aws-lambda-powertools/logger", "version": "1.18.0", @@ -17214,6 +17474,11 @@ } } }, + "packages/logger/node_modules/@aws-lambda-powertools/commons": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@aws-lambda-powertools/commons/-/commons-1.12.1.tgz", + "integrity": "sha512-VChNfDUxxcB5KTfQPkJgxYihEZkrmeOzU9/A9FRBc+3v33EEM59T2pIgBkFy0VoINvGi3MoBEln/wyu2jV0ivA==" + }, "packages/metrics": { "name": "@aws-lambda-powertools/metrics", "version": "1.18.0", @@ -17236,6 +17501,11 @@ } } }, + "packages/metrics/node_modules/@aws-lambda-powertools/commons": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@aws-lambda-powertools/commons/-/commons-1.12.1.tgz", + "integrity": "sha512-VChNfDUxxcB5KTfQPkJgxYihEZkrmeOzU9/A9FRBc+3v33EEM59T2pIgBkFy0VoINvGi3MoBEln/wyu2jV0ivA==" + }, "packages/parameters": { "name": "@aws-lambda-powertools/parameters", "version": "1.18.0", @@ -17282,6 +17552,11 @@ } } }, + "packages/parameters/node_modules/@aws-lambda-powertools/commons": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@aws-lambda-powertools/commons/-/commons-1.12.1.tgz", + "integrity": "sha512-VChNfDUxxcB5KTfQPkJgxYihEZkrmeOzU9/A9FRBc+3v33EEM59T2pIgBkFy0VoINvGi3MoBEln/wyu2jV0ivA==" + }, "packages/testing": { "name": "@aws-lambda-powertools/testing-utils", "version": "1.18.0", @@ -17319,6 +17594,11 @@ "optional": true } } + }, + "packages/tracer/node_modules/@aws-lambda-powertools/commons": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@aws-lambda-powertools/commons/-/commons-1.12.1.tgz", + "integrity": "sha512-VChNfDUxxcB5KTfQPkJgxYihEZkrmeOzU9/A9FRBc+3v33EEM59T2pIgBkFy0VoINvGi3MoBEln/wyu2jV0ivA==" } } -} +} \ No newline at end of file diff --git a/packages/batch/package.json b/packages/batch/package.json index b6013ad1b3..5876184a0f 100644 --- a/packages/batch/package.json +++ b/packages/batch/package.json @@ -51,4 +51,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file diff --git a/packages/commons/package.json b/packages/commons/package.json index 59552cafab..7c29effb74 100644 --- a/packages/commons/package.json +++ b/packages/commons/package.json @@ -46,4 +46,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file diff --git a/packages/idempotency/package.json b/packages/idempotency/package.json index 96d815d25f..eb8d2ecb8e 100644 --- a/packages/idempotency/package.json +++ b/packages/idempotency/package.json @@ -117,4 +117,4 @@ "aws-sdk-client-mock": "^3.0.1", "aws-sdk-client-mock-jest": "^3.0.1" } -} +} \ No newline at end of file diff --git a/packages/logger/package.json b/packages/logger/package.json index c1e0a3b414..f0599eab6c 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -13,7 +13,6 @@ "test": "npm run test:unit", "test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", "jest": "jest --detectOpenHandles --verbose", - "test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e", "test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e", "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x jest --group=e2e", @@ -67,4 +66,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file diff --git a/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts b/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts index 92ce661aab..993321eeac 100644 --- a/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts +++ b/packages/logger/tests/unit/formatter/PowertoolsLogFormatter.test.ts @@ -1,11 +1,13 @@ /** * Test Logger formatter * - * @group unit/logger/all + * @group unit/logger/logFormatter */ -import { AssertionError, strictEqual } from 'assert'; -import { PowertoolsLogFormatter } from '../../../src/formatter'; -import { LogAttributes, UnformattedAttributes } from '../../../src/types'; +import { AssertionError } from 'node:assert'; +import { PowertoolsLogFormatter } from '../../../src/formatter/PowertoolsLogFormatter.js'; +import { LogItem } from '../../../src/index.js'; +import type { UnformattedAttributes } from '../../../src/types/Logger.js'; +import type { LogAttributes } from '../../../src/types/Log.js'; describe('Class: PowertoolsLogFormatter', () => { const mockDate = new Date(1466424490000); @@ -20,7 +22,7 @@ describe('Class: PowertoolsLogFormatter', () => { // Prepare const formatter = new PowertoolsLogFormatter(); const unformattedAttributes: UnformattedAttributes = { - sampleRateValue: undefined, + sampleRateValue: 0, awsRegion: 'eu-west-1', environment: '', serviceName: 'hello-world', @@ -46,11 +48,12 @@ describe('Class: PowertoolsLogFormatter', () => { function_request_id: undefined, level: 'WARN', message: 'This is a WARN log', - sampling_rate: undefined, + sampling_rate: 0, service: 'hello-world', timestamp: '2016-06-20T12:08:10.000Z', xray_trace_id: '1-5759e988-bd862e3fe1be46a994272793', }); + expect(value).toBeInstanceOf(LogItem); }); test('when optional parameters DO have a value set, it returns an object with expected structure and values', () => { @@ -68,7 +71,7 @@ describe('Class: PowertoolsLogFormatter', () => { error: new Error('Something happened!'), lambdaContext: { functionName: 'my-lambda-function', - memoryLimitInMB: 123, + memoryLimitInMB: '123', functionVersion: '1.23.3', coldStart: true, invokedFunctionArn: @@ -88,7 +91,7 @@ describe('Class: PowertoolsLogFormatter', () => { expect(value.getAttributes()).toEqual({ cold_start: true, function_arn: 'arn:aws:lambda:eu-west-1:123456789012:function:Example', - function_memory_size: 123, + function_memory_size: '123', function_name: 'my-lambda-function', function_request_id: 'abcdefg123456789', level: 'WARN', @@ -105,358 +108,277 @@ describe('Class: PowertoolsLogFormatter', () => { test('when an error of type Error is passed, it returns an object with expected structure and values', () => { // Prepare const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - throw new Error('Ouch!'); - }; - // Act - try { - shouldThrow(); - } catch (error) { - // Assess - expect(error).toBeInstanceOf(Error); - const formattedError = formatter.formatError(error); - expect(formattedError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+$/ - ), - message: 'Ouch!', - name: 'Error', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } - - expect(shouldThrow).toThrowError(expect.any(Error)); + // Act & Assess + const formattedError = formatter.formatError(new Error('Ouch!')); + expect(formattedError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+$/ + ), + message: 'Ouch!', + name: 'Error', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), + }); }); test('when an error of type ReferenceError is passed, it returns an object with expected structure and values', () => { // Prepare const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - // This is a reference error purposely to test the formatter - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - doesNotExist; - }; - - // Act - try { - shouldThrow(); - } catch (error) { - // Assess - expect(error).toBeInstanceOf(Error); - const formattedReferenceError = formatter.formatError(error); - expect(formattedReferenceError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+$/ - ), - message: 'doesNotExist is not defined', - name: 'ReferenceError', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } - expect(shouldThrow).toThrowError(expect.any(ReferenceError)); + // Act & Assess + const formattedReferenceError = formatter.formatError( + new ReferenceError('doesNotExist is not defined') + ); + expect(formattedReferenceError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+$/ + ), + message: 'doesNotExist is not defined', + name: 'ReferenceError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), + }); }); test('when an error of type AssertionError is passed, it returns an object with expected structure and values', () => { // Prepare const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - strictEqual(1, 2); - }; - - // Act - try { - shouldThrow(); - } catch (error) { - // Assess - expect(error).toBeInstanceOf(AssertionError); - const formattedAssertionError = formatter.formatError( - error - ); - expect(formattedAssertionError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+/ - ), - message: expect.stringMatching( - /Expected values to be strictly equal/ - ), - name: 'AssertionError', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } - expect(shouldThrow).toThrowError(expect.any(AssertionError)); + // Act & Assess + const formattedAssertionError = formatter.formatError( + new AssertionError({ + message: 'Expected values to be strictly equal', + actual: 1, + expected: 2, + operator: 'strictEqual', + }) + ); + expect(formattedAssertionError).toEqual({ + location: expect.stringMatching( + /(node:)*internal\/assert\/assertion_error(.js)*:[0-9]+$/ + ), + message: expect.stringMatching(/Expected values to be strictly equal/), + name: 'AssertionError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), + }); }); test('when an error of type RangeError is passed, it returns an object with expected structure and values', () => { // Prepare const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - throw new RangeError('The argument must be between 10 and 20'); - }; - // Act - try { - shouldThrow(); - } catch (error) { - // Assess - expect(error).toBeInstanceOf(RangeError); - const formattedRangeError = formatter.formatError(error); - expect(formattedRangeError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+/ - ), - message: 'The argument must be between 10 and 20', - name: 'RangeError', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } + // Act & Assess + const formattedRangeError = formatter.formatError( + new RangeError('The argument must be between 10 and 20') + ); + expect(formattedRangeError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+/ + ), + message: 'The argument must be between 10 and 20', + name: 'RangeError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), + }); + }); - test('when an error of type ReferenceError is passed, it returns an object with expected structure and values', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - - // Act & Assess - const formattedError = formatter.formatError( - new ReferenceError('foo is not defined') - ); - expect(formattedError).toEqual({ - location: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+/ - ), - message: 'foo is not defined', - name: 'ReferenceError', - stack: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); + test('when an error of type ReferenceError is passed, it returns an object with expected structure and values', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); + + // Act & Assess + const formattedError = formatter.formatError( + new ReferenceError('foo is not defined') + ); + expect(formattedError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+/ + ), + message: 'foo is not defined', + name: 'ReferenceError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), }); + }); - test('when an error of type SyntaxError is passed, it returns an object with expected structure and values', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - eval('foo bar'); - }; - - // Act - try { - shouldThrow(); - } catch (error) { - // Assess - expect(error).toBeInstanceOf(SyntaxError); - const formattedSyntaxError = formatter.formatError( - error - ); - expect(formattedSyntaxError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+/ - ), - message: 'Unexpected identifier', - name: 'SyntaxError', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } + test('when an error of type SyntaxError is passed, it returns an object with expected structure and values', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); - expect(shouldThrow).toThrowError(expect.any(SyntaxError)); + // Act & Assess + const formattedSyntaxError = formatter.formatError( + new SyntaxError(`Unexpected identifier 'bar'`) + ); + expect(formattedSyntaxError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+/ + ), + message: `Unexpected identifier 'bar'`, + name: 'SyntaxError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), }); + }); - test('when an error of type TypeError is passed, it returns an object with expected structure and values', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - // This is a reference error purposely to test the formatter - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - null.foo(); - }; - - // Act - try { - shouldThrow(); - } catch (error) { - // TODO: review message content assertion (see Issue #304) - // Assess - expect(error).toBeInstanceOf(Error); - const formattedTypeError = formatter.formatError(error); - expect(formattedTypeError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+/ - ), - message: expect.stringMatching(/Cannot read propert/), - name: 'TypeError', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } + test('when an error of type TypeError is passed, it returns an object with expected structure and values', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); - expect(shouldThrow).toThrowError(expect.any(TypeError)); + // Act & Assess + const formattedTypeError = formatter.formatError( + new TypeError(`Cannot read property 'foo' of null`) + ); + expect(formattedTypeError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+/ + ), + message: expect.stringMatching(/Cannot read propert/), + name: 'TypeError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), }); + }); - test('when an error of type URIError is passed, it returns an object with expected structure and values', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - const shouldThrow = (): void => { - decodeURIComponent('%'); - }; - - // Act - try { - shouldThrow(); - } catch (error) { - // Assess - expect(error).toBeInstanceOf(URIError); - const formattedURIError = formatter.formatError(error); - expect(formattedURIError).toEqual({ - location: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+/ - ), - message: 'URI malformed', - name: 'URIError', - stack: expect.stringMatching( - /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }); - } + test('when an error of type URIError is passed, it returns an object with expected structure and values', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); - expect(shouldThrow).toThrowError(expect.any(URIError)); + // Act & Assess + const formattedURIError = formatter.formatError( + new URIError('URI malformed') + ); + expect(formattedURIError).toEqual({ + location: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+/ + ), + message: 'URI malformed', + name: 'URIError', + stack: expect.stringMatching( + /PowertoolsLogFormatter.test.ts:[0-9]+:[0-9]+/ + ), }); + }); - test('when an error with cause of type Error is formatted, the cause key is included and formatted', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - class ErrorWithCause extends Error { - public cause?: Error; - public constructor(message: string, options?: { cause: Error }) { - super(message); - this.cause = options?.cause; - } + test('when an error with cause of type Error is formatted, the cause key is included and formatted', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); + class ErrorWithCause extends Error { + public cause?: Error; + public constructor(message: string, options?: { cause: Error }) { + super(message); + this.cause = options?.cause; } + } - // Act - const formattedURIError = formatter.formatError( - new ErrorWithCause('foo', { cause: new Error('bar') }) - ); + // Act + const formattedURIError = formatter.formatError( + new ErrorWithCause('foo', { cause: new Error('bar') }) + ); - // Assess - expect(formattedURIError).toEqual({ - location: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+/ - ), - message: 'foo', + // Assess + expect(formattedURIError).toEqual({ + location: expect.stringMatching(/PowertoolsLogFormatter.test.ts:\d+/), + message: 'foo', + name: 'Error', + stack: expect.stringMatching(/PowertoolsLogFormatter.test.ts:\d+:\d+/), + cause: { + location: expect.stringMatching(/PowertoolsLogFormatter.test.ts:\d+/), + message: 'bar', name: 'Error', stack: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+:[0-9]+/ + /PowertoolsLogFormatter.test.ts:\d+:\d+/ ), - cause: { - location: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+/ - ), - message: 'bar', - name: 'Error', - stack: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - }, - }); + }, }); + }); - test('when an error with cause of type other than Error is formatted, the cause key is included as-is', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - class ErrorWithCause extends Error { - public cause?: unknown; - public constructor(message: string, options?: { cause: unknown }) { - super(message); - this.cause = options?.cause; - } + test('when an error with cause of type other than Error is formatted, the cause key is included as-is', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); + class ErrorWithCause extends Error { + public cause?: unknown; + public constructor(message: string, options?: { cause: unknown }) { + super(message); + this.cause = options?.cause; } + } - // Act - const formattedURIError = formatter.formatError( - new ErrorWithCause('foo', { cause: 'bar' }) - ); + // Act + const formattedURIError = formatter.formatError( + new ErrorWithCause('foo', { cause: 'bar' }) + ); - // Assess - expect(formattedURIError).toEqual({ - location: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+/ - ), - message: 'foo', - name: 'Error', - stack: expect.stringMatching( - /PowertoolLogFormatter.test.ts:[0-9]+:[0-9]+/ - ), - cause: 'bar', - }); + // Assess + expect(formattedURIError).toEqual({ + location: expect.stringMatching(/PowertoolsLogFormatter.test.ts:\d+/), + message: 'foo', + name: 'Error', + stack: expect.stringMatching(/PowertoolsLogFormatter.test.ts:\d+:\d+/), + cause: 'bar', }); }); + }); - describe('Method: formatTimestamp', () => { - test('it returns a datetime value ISO 8601 compliant', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); + describe('Method: formatTimestamp', () => { + test('it returns a datetime value ISO 8601 compliant', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); - // Act - const timestamp = formatter.formatTimestamp(new Date()); + // Act + const timestamp = formatter.formatTimestamp(new Date()); - // Assess - expect(timestamp).toEqual('2016-06-20T12:08:10.000Z'); - }); + // Assess + expect(timestamp).toEqual('2016-06-20T12:08:10.000Z'); }); + }); - describe('Method: getCodeLocation', () => { - test('when the stack IS present, it returns a datetime value ISO 8601 compliant', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - const stack = - 'Error: Things keep happening!\n' + - ' at /home/foo/bar/file-that-threw-the-error.ts:22:5\n' + - ' at SomeOther.function (/home/foo/bar/some-file.ts:154:19)'; + describe('Method: getCodeLocation', () => { + test('when the stack IS present, it returns a datetime value ISO 8601 compliant', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); + const stack = + 'Error: Things keep happening!\n' + + ' at /home/foo/bar/file-that-threw-the-error.ts:22:5\n' + + ' at SomeOther.function (/home/foo/bar/some-file.ts:154:19)'; - // Act - const errorLocation = formatter.getCodeLocation(stack); + // Act + const errorLocation = formatter.getCodeLocation(stack); - // Assess - expect(errorLocation).toEqual('/home/foo/bar/some-file.ts:154'); - }); + // Assess + expect(errorLocation).toEqual('/home/foo/bar/some-file.ts:154'); + }); - test('when the stack IS NOT present, it returns a datetime value ISO 8601 compliant', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - const stack = undefined; + test('when the stack IS NOT present, it returns a datetime value ISO 8601 compliant', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); + const stack = undefined; - // Act - const errorLocation = formatter.getCodeLocation(stack); + // Act + const errorLocation = formatter.getCodeLocation(stack); - // Assess - expect(errorLocation).toEqual(''); - }); + // Assess + expect(errorLocation).toEqual(''); + }); - test('when the stack IS NOT present, it returns a datetime value ISO 8601 compliant', () => { - // Prepare - const formatter = new PowertoolsLogFormatter(); - const stack = 'A weird stack trace...'; + test('when the stack IS NOT present, it returns a datetime value ISO 8601 compliant', () => { + // Prepare + const formatter = new PowertoolsLogFormatter(); + const stack = 'A weird stack trace...'; - // Act - const errorLocation = formatter.getCodeLocation(stack); + // Act + const errorLocation = formatter.getCodeLocation(stack); - // Assess - expect(errorLocation).toEqual(''); - }); + // Assess + expect(errorLocation).toEqual(''); }); }); }); diff --git a/packages/metrics/package.json b/packages/metrics/package.json index 8b7c687175..3c1218d7e0 100644 --- a/packages/metrics/package.json +++ b/packages/metrics/package.json @@ -12,8 +12,11 @@ "scripts": { "test": "npm run test:unit", "test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", +<<<<<<< HEAD "jest": "jest --detectOpenHandles --verbose", "test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e", +======= +>>>>>>> f113ef18 (chore(maintenance): bump dependencies & drop nodejs14x (#1687)) "test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e", "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x jest --group=e2e", @@ -67,4 +70,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file diff --git a/packages/parameters/package.json b/packages/parameters/package.json index b00d1101b8..8cdfca28be 100644 --- a/packages/parameters/package.json +++ b/packages/parameters/package.json @@ -12,8 +12,6 @@ "scripts": { "test": "npm run test:unit", "test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", - "jest": "jest --detectOpenHandles --verbose", - "test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e", "test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e", "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x jest --group=e2e", @@ -179,4 +177,4 @@ "optional": true } } -} +} \ No newline at end of file diff --git a/packages/testing/package.json b/packages/testing/package.json index a6f806b567..274beaf98e 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -50,4 +50,4 @@ "aws-cdk-lib": "^2.123.0", "esbuild": "^0.19.12" } -} +} \ No newline at end of file diff --git a/packages/tracer/package.json b/packages/tracer/package.json index 303dbad186..3e535b2dbd 100644 --- a/packages/tracer/package.json +++ b/packages/tracer/package.json @@ -12,8 +12,6 @@ "scripts": { "test": "npm run test:unit", "test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose", - "jest": "jest --detectOpenHandles --verbose", - "test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e", "test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e", "test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e", "test:e2e:nodejs20x": "RUNTIME=nodejs20x jest --group=e2e", @@ -72,4 +70,4 @@ "serverless", "nodejs" ] -} +} \ No newline at end of file