diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 6e3fd1b..102519a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -17,7 +17,6 @@ module.exports = { rules: { '@typescript-eslint/no-unused-vars': 'error', 'no-undef': 'error', - 'no-console': 'error', 'no-const-assign': 'error', }, env: { diff --git a/.nvmrc b/.nvmrc index 3516580..2a393af 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -20.17.0 +20.18.0 diff --git a/README.md b/README.md index d4217e5..5aaf578 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This is a JavaScript/TypeScript SDK for the [fulfillmenttools REST API](https:// ## 👉 Get started -The TypeScript SDK is fully open source and is available on [GitHub](https://github.com/fulfillmenttools/fulfillmenttools-sdk-typescript). +The **TypeScript SDK** is fully open source and is available on [GitHub](https://github.com/fulfillmenttools/fulfillmenttools-sdk-typescript). The package is published on [npmjs.com](https://www.npmjs.com/package/@fulfillmenttools/fulfillmenttools-sdk-typescript). It contains both an ESM and a CommonJS build, so you can use it in the browser and in the backend. You can install it with the command below: @@ -49,6 +49,9 @@ Learn how to set up and use the TypeScript SDK with our [tutorial](./TUTORIAL.md The official fulfillmenttools API documentation can be found [here](https://docs.fulfillmenttools.com/api-docs/), and we also publish our [OpenAPI specification](https://fulfillmenttools.github.io/api-reference-ui/). +> [!NOTE] +> Currently, the SDK is still in _beta_ status. It does not provide access to all of the features of our API but we are continuously extending it and pushing out new versions. We hope you will find it easy to use and are looking forward to your feedback. + ## 👨‍💻 Development ### 👉 Requirements @@ -58,14 +61,14 @@ The official fulfillmenttools API documentation can be found [here](https://docs ### 🛫 Setup ```bash -$ nvm use +nvm use ``` ### 🤸 Building ```bash -$ npm install -$ npm run build +npm install +npm run build ``` ### 🕵️ Running unit tests @@ -73,13 +76,13 @@ $ npm run build When running unit tests the `.env.local` file will be used with dummy settings. ```bash -$ npm run test +npm run test ``` ### 🕵️‍♀️ Linting ```bash -$ npm run lint +npm run lint ``` ## 📜 License diff --git a/package-lock.json b/package-lock.json index 68ff037..b419705 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,9 +8,6 @@ "name": "@fulfillmenttools/fulfillmenttools-sdk-typescript", "version": "0.2.0", "license": "MIT", - "dependencies": { - "tslog": "4.9.3" - }, "devDependencies": { "@babel/preset-env": "7.25.4", "@babel/preset-typescript": "7.24.7", @@ -2071,74 +2068,6 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz", - "integrity": "sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.23.1.tgz", - "integrity": "sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz", - "integrity": "sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.23.1.tgz", - "integrity": "sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, "node_modules/@esbuild/darwin-arm64": { "version": "0.23.1", "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz", @@ -2156,329 +2085,6 @@ "node": ">=18" } }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz", - "integrity": "sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz", - "integrity": "sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz", - "integrity": "sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz", - "integrity": "sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz", - "integrity": "sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz", - "integrity": "sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz", - "integrity": "sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz", - "integrity": "sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz", - "integrity": "sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz", - "integrity": "sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz", - "integrity": "sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz", - "integrity": "sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz", - "integrity": "sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz", - "integrity": "sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz", - "integrity": "sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz", - "integrity": "sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz", - "integrity": "sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz", - "integrity": "sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.23.1", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz", - "integrity": "sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -3399,230 +3005,19 @@ "node": ">=12" } }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.2.tgz", - "integrity": "sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.2.tgz", - "integrity": "sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ] - }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.2.tgz", - "integrity": "sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.22.4.tgz", + "integrity": "sha512-xMM9ORBqu81jyMKCDP+SZDhnX2QEVQzTcC6G18KlTQEzWK8r/oNZtKuZaCcHhnsa6fEeOBionoyl5JsAbE/36Q==", "cpu": [ "arm64" ], "dev": true, - "license": "MIT", "optional": true, "os": [ "darwin" ] }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.2.tgz", - "integrity": "sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.2.tgz", - "integrity": "sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.2.tgz", - "integrity": "sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.2.tgz", - "integrity": "sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.2.tgz", - "integrity": "sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.2.tgz", - "integrity": "sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.2.tgz", - "integrity": "sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.2.tgz", - "integrity": "sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz", - "integrity": "sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz", - "integrity": "sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.2.tgz", - "integrity": "sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.2.tgz", - "integrity": "sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.2.tgz", - "integrity": "sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", @@ -9899,11 +9294,10 @@ } }, "node_modules/rollup": { - "version": "4.21.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.21.2.tgz", - "integrity": "sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw==", + "version": "4.22.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.22.4.tgz", + "integrity": "sha512-vD8HJ5raRcWOyymsR6Z3o6+RzfEPCnVLMFJ6vRslO1jt4LO6dUo5Qnpg7y4RkZFM2DMe3WUirkI5c16onjrc6A==", "dev": true, - "license": "MIT", "dependencies": { "@types/estree": "1.0.5" }, @@ -9915,22 +9309,22 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.21.2", - "@rollup/rollup-android-arm64": "4.21.2", - "@rollup/rollup-darwin-arm64": "4.21.2", - "@rollup/rollup-darwin-x64": "4.21.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.21.2", - "@rollup/rollup-linux-arm-musleabihf": "4.21.2", - "@rollup/rollup-linux-arm64-gnu": "4.21.2", - "@rollup/rollup-linux-arm64-musl": "4.21.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.21.2", - "@rollup/rollup-linux-riscv64-gnu": "4.21.2", - "@rollup/rollup-linux-s390x-gnu": "4.21.2", - "@rollup/rollup-linux-x64-gnu": "4.21.2", - "@rollup/rollup-linux-x64-musl": "4.21.2", - "@rollup/rollup-win32-arm64-msvc": "4.21.2", - "@rollup/rollup-win32-ia32-msvc": "4.21.2", - "@rollup/rollup-win32-x64-msvc": "4.21.2", + "@rollup/rollup-android-arm-eabi": "4.22.4", + "@rollup/rollup-android-arm64": "4.22.4", + "@rollup/rollup-darwin-arm64": "4.22.4", + "@rollup/rollup-darwin-x64": "4.22.4", + "@rollup/rollup-linux-arm-gnueabihf": "4.22.4", + "@rollup/rollup-linux-arm-musleabihf": "4.22.4", + "@rollup/rollup-linux-arm64-gnu": "4.22.4", + "@rollup/rollup-linux-arm64-musl": "4.22.4", + "@rollup/rollup-linux-powerpc64le-gnu": "4.22.4", + "@rollup/rollup-linux-riscv64-gnu": "4.22.4", + "@rollup/rollup-linux-s390x-gnu": "4.22.4", + "@rollup/rollup-linux-x64-gnu": "4.22.4", + "@rollup/rollup-linux-x64-musl": "4.22.4", + "@rollup/rollup-win32-arm64-msvc": "4.22.4", + "@rollup/rollup-win32-ia32-msvc": "4.22.4", + "@rollup/rollup-win32-x64-msvc": "4.22.4", "fsevents": "~2.3.2" } }, @@ -10663,18 +10057,6 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, - "node_modules/tslog": { - "version": "4.9.3", - "resolved": "https://registry.npmjs.org/tslog/-/tslog-4.9.3.tgz", - "integrity": "sha512-oDWuGVONxhVEBtschLf2cs/Jy8i7h1T+CpdkTNWQgdAF7DhRo2G8vMCgILKe7ojdEkLhICWgI1LYSSKaJsRgcw==", - "license": "MIT", - "engines": { - "node": ">=16" - }, - "funding": { - "url": "https://github.com/fullstack-build/tslog?sponsor=1" - } - }, "node_modules/tsup": { "version": "8.2.4", "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.2.4.tgz", diff --git a/package.json b/package.json index 8804751..f9902ba 100644 --- a/package.json +++ b/package.json @@ -66,9 +66,6 @@ "tsup": "8.2.4", "typescript": "5.5.4" }, - "dependencies": { - "tslog": "4.9.3" - }, "engines": { "node": ">=20" } diff --git a/src/common/httpClient/httpClient.ts b/src/common/httpClient/httpClient.ts index 156c2ac..20f12be 100644 --- a/src/common/httpClient/httpClient.ts +++ b/src/common/httpClient/httpClient.ts @@ -2,12 +2,9 @@ import { HTTP_TIMEOUT_MS } from './constants'; import { USER_AGENT } from '../projectConstants'; import { BasicHttpClient, HttpRequestConfiguration, HttpResult } from './models'; import { serializeWithDatesAsIsoString } from './serialize'; -import { Logger } from 'tslog'; -import { CustomLogger } from '../logging'; import { ErrorType, FetchError, FftSdkError } from './error'; export class HttpClient implements BasicHttpClient { - private readonly logger: Logger = new CustomLogger(); private shouldLogHttpRequestAndResponse: boolean; constructor(shouldLogHttpRequestAndResponse?: boolean) { @@ -20,8 +17,6 @@ export class HttpClient implements BasicHttpClient { requestHeaders.set('Content-Type', 'application/json'); requestHeaders.set('User-Agent', USER_AGENT); - // TODO retries with 'fetch-retry' - if (config.customHeaders) { Object.entries(config?.customHeaders).forEach(([key, value]) => { requestHeaders.set(key, String(value)); @@ -46,7 +41,7 @@ export class HttpClient implements BasicHttpClient { } if (this.shouldLogHttpRequestAndResponse) { - this.logger.debug(`Sending request. Url: ${config.url}, Method: ${config.method}`, [ + console.debug(`Sending request. Url: ${config.url}, Method: ${config.method}`, [ { params: url.searchParams, body: requestOptions.body, @@ -69,14 +64,11 @@ export class HttpClient implements BasicHttpClient { : undefined; if (this.shouldLogHttpRequestAndResponse) { - this.logger.debug( - `Received response. Url: ${url}, Method: ${config.method} - Response Status: ${response.status}`, - [ - { - body: responseBody, - }, - ] - ); + console.debug(`Received response. Url: ${url}, Method: ${config.method} - Response Status: ${response.status}`, [ + { + body: responseBody, + }, + ]); } if (!response.ok) { diff --git a/src/common/index.ts b/src/common/index.ts index b85c47e..bb216fd 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -1,4 +1,3 @@ export * from './httpClient'; export * from './projectConstants'; export * from './utils'; -export * from './logging'; diff --git a/src/common/logging/index.ts b/src/common/logging/index.ts deleted file mode 100644 index 1ff09ef..0000000 --- a/src/common/logging/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './logger'; diff --git a/src/common/logging/logger.ts b/src/common/logging/logger.ts deleted file mode 100644 index 838691a..0000000 --- a/src/common/logging/logger.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Logger } from 'tslog'; - -export class CustomLogger extends Logger { - constructor() { - super({ type: 'json' }); - } -} diff --git a/src/fft-api/auth/authService.ts b/src/fft-api/auth/authService.ts index 2519020..9684adf 100644 --- a/src/fft-api/auth/authService.ts +++ b/src/fft-api/auth/authService.ts @@ -1,6 +1,5 @@ -import { Logger } from 'tslog'; -import { CustomLogger, HttpClient, HttpMethod, MS_PER_SECOND } from '../../common'; import { RefreshTokenResponse, TokenResponse } from './models'; +import { HttpClient, HttpMethod, MS_PER_SECOND } from '../../common'; export interface FftAuthConfig { authUrl: string; @@ -23,7 +22,6 @@ export class AuthService { private readonly authRefreshUrl: string; private static readonly EXPIRY_TOLERANCE_MS = 5000; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly authConfig: FftAuthConfig, private readonly httpClient: HttpClient) { this.authLoginUrl = this.authConfig.authUrl; @@ -50,7 +48,7 @@ export class AuthService { this.refreshToken = tokenResponse.body.refreshToken; this.expiresAt = this.calcExpiresAt(tokenResponse.body.expiresIn); } catch (err) { - this.logger.error(`Could not obtain token for '${this.username}'.`, err); + console.error(`Could not obtain token for '${this.username}'.`, err); throw err; } } else if (new Date().getTime() > this.expiresAt.getTime() - AuthService.EXPIRY_TOLERANCE_MS) { @@ -68,7 +66,7 @@ export class AuthService { this.refreshToken = refreshTokenResponse.body.refresh_token; this.expiresAt = this.calcExpiresAt(refreshTokenResponse.body.expires_in); } catch (err) { - this.logger.error(`Could not refresh token for '${this.username}'.`, err); + console.error(`Could not refresh token for '${this.username}'.`, err); throw err; } } diff --git a/src/fft-api/carrier/fftCarrierService.ts b/src/fft-api/carrier/fftCarrierService.ts index 8b0459b..4e23fa7 100644 --- a/src/fft-api/carrier/fftCarrierService.ts +++ b/src/fft-api/carrier/fftCarrierService.ts @@ -1,12 +1,8 @@ -import { Logger } from 'tslog'; - -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { Carrier, CarrierConfiguration, StrippedCarriers } from '../types'; export class FftCarrierService { private readonly path = 'carriers'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} diff --git a/src/fft-api/external-action/fftExternalActionService.ts b/src/fft-api/external-action/fftExternalActionService.ts index b37f701..6503261 100644 --- a/src/fft-api/external-action/fftExternalActionService.ts +++ b/src/fft-api/external-action/fftExternalActionService.ts @@ -1,5 +1,3 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { ExternalAction, @@ -12,15 +10,13 @@ import { export class FftExternalActionService { private readonly path = 'externalactions'; - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async create(request: ExternalActionForCreation): Promise { try { return await this.apiClient.post(this.path, { ...request }); } catch (err) { - this.logger.error(`FFT ExternalActions POST failed.`, err); + console.error(`FFT ExternalActions POST failed.`, err); throw err; } } @@ -29,7 +25,7 @@ export class FftExternalActionService { try { return await this.apiClient.get(`${this.path}/${externalActionId}`); } catch (err) { - this.logger.error(`FFT ExternalActions get id ${externalActionId} failed.`, err); + console.error(`FFT ExternalActions get id ${externalActionId} failed.`, err); throw err; } } @@ -38,7 +34,7 @@ export class FftExternalActionService { try { return await this.apiClient.post(`${this.path}/${externalActionId}/logs`, { ...logEntry }); } catch (err) { - this.logger.error(`FFT ExternalActions POST Log for ID ${externalActionId} failed.`, err); + console.error(`FFT ExternalActions POST Log for ID ${externalActionId} failed.`, err); throw err; } } @@ -47,7 +43,7 @@ export class FftExternalActionService { try { return await this.apiClient.put(`${this.path}/${externalActionId}`, { ...replacement }); } catch (err) { - this.logger.error(`FFT ExternalActions PUT replacement for ID ${externalActionId} failed.`, err); + console.error(`FFT ExternalActions PUT replacement for ID ${externalActionId} failed.`, err); throw err; } } @@ -56,7 +52,7 @@ export class FftExternalActionService { try { await this.apiClient.delete(`${this.path}/${externalActionId}`); } catch (err) { - this.logger.error(`FFT ExternalActions DELETE ID ${externalActionId} failed.`, err); + console.error(`FFT ExternalActions DELETE ID ${externalActionId} failed.`, err); throw err; } } @@ -78,7 +74,7 @@ export class FftExternalActionService { return await this.apiClient.get(`${this.path}/${externalActionId}/logs`, params); } catch (err) { - this.logger.error(`FFT ExternalActions GET Logs for ID ${externalActionId} failed.`, err); + console.error(`FFT ExternalActions GET Logs for ID ${externalActionId} failed.`, err); throw err; } } diff --git a/src/fft-api/facility/fftFacilityService.ts b/src/fft-api/facility/fftFacilityService.ts index 73e0c8d..e2d64da 100644 --- a/src/fft-api/facility/fftFacilityService.ts +++ b/src/fft-api/facility/fftFacilityService.ts @@ -1,5 +1,4 @@ -import { Logger } from 'tslog'; -import { CustomLogger, FftApiError, QueryParams } from '../../common'; +import { FftApiError, QueryParams } from '../../common'; import { FftApiClient } from '../common'; import { CarrierStatus, @@ -28,8 +27,6 @@ export class FftFacilityService { private readonly PATH = 'facilities'; - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async getFacilityId(tenantFacilityId: string, relaxed = false): Promise { @@ -45,7 +42,7 @@ export class FftFacilityService { facility = strippedFacilities.facilities?.[0] as StrippedFacility; FftFacilityService.facilityCache.set(tenantFacilityId, facility.id); if (length > 1) { - this.logger.warn( + console.warn( `Did not find exactly 1 facility with tenantFacilityId '${tenantFacilityId}' but ${length}, returning first one with id '${facility.id}'` ); } @@ -53,7 +50,7 @@ export class FftFacilityService { if (relaxed) { return undefined; } else { - this.logger.error(`Did not find facility with tenantFacilityId '${tenantFacilityId}'`); + console.error(`Did not find facility with tenantFacilityId '${tenantFacilityId}'`); throw new FftApiError({ message: `Did not find facility with tenantFacilityId '${tenantFacilityId}'`, }); @@ -67,7 +64,7 @@ export class FftFacilityService { try { return await this.apiClient.get(this.PATH, params); } catch (err) { - this.logger.error(`Getting all facilities failed.`, err); + console.error(`Getting all facilities failed.`, err); throw err; } } @@ -76,7 +73,7 @@ export class FftFacilityService { try { return await this.apiClient.post(this.PATH, facilityForCreation); } catch (err) { - this.logger.error(`Creating FFT Facility '${facilityForCreation.tenantFacilityId}' failed.`, err); + console.error(`Creating FFT Facility '${facilityForCreation.tenantFacilityId}' failed.`, err); throw err; } } @@ -95,11 +92,11 @@ export class FftFacilityService { `${this.PATH}/${facilityId}/carriers/${carrierRef}`, { ...data } ); - this.logger.debug( + console.debug( `Successfully connected FFT Facility '${facilityId}' with Carrier '${facilityCarrierConnection.key}' '${carrierRef}'` ); } catch (err) { - this.logger.error(`Connecting FFT Facility '${facilityId}' with Carrier '${carrierRef}' failed.`, err); + console.error(`Connecting FFT Facility '${facilityId}' with Carrier '${carrierRef}' failed.`, err); throw err; } } @@ -131,17 +128,17 @@ export class FftFacilityService { facilityId = facility.id; if (realDelete) { - this.logger.warn(`Deleting FFT Facility '${facilityId}' for CT Channel '${tenantFacilityId}'`); + console.warn(`Deleting FFT Facility '${facilityId}' for CT Channel '${tenantFacilityId}'`); await this.apiClient.delete(`${this.PATH}/${facilityId}`); FftFacilityService.facilityCache.delete(tenantFacilityId); } else { - this.logger.debug( + console.debug( `Not deleting FFT Facility '${facilityId}' for CT Channel '${tenantFacilityId}' because functionality is disabled` ); } return facility.id; } catch (err) { - this.logger.error(`Deleting FFT Facility '${facilityId}' from CT Channel '${tenantFacilityId}' failed.`, err); + console.error(`Deleting FFT Facility '${facilityId}' from CT Channel '${tenantFacilityId}' failed.`, err); throw err; } } @@ -149,7 +146,7 @@ export class FftFacilityService { public async getFacility(facilityId: string): Promise { const facility = await this.apiClient.get(this.PATH.concat(`/${facilityId}`)); if (!facility) { - this.logger.error(`Did not find facility with facilityId '${facilityId}'.`); + console.error(`Did not find facility with facilityId '${facilityId}'.`); throw new FftApiError({ message: `Did not find facility with facilityId '${facilityId}'`, }); @@ -160,14 +157,14 @@ export class FftFacilityService { public async getStrippedFacility(tenantFacilityId: string): Promise { const strippedFacilities = await this.apiClient.get(this.PATH, { tenantFacilityId }); if (!strippedFacilities.facilities || strippedFacilities.facilities.length === 0) { - this.logger.error(`Did not find facility with tenantFacilityId '${tenantFacilityId}'.`); + console.error(`Did not find facility with tenantFacilityId '${tenantFacilityId}'.`); throw new FftApiError({ message: `Did not find facility with tenantFacilityId '${tenantFacilityId}'`, }); } if (strippedFacilities.facilities.length > 1) { - this.logger.warn( + console.warn( `Did not find exactly 1 facility with tenantFacilityId '${tenantFacilityId}' but ${strippedFacilities.facilities.length}, returning first one with id '${strippedFacilities.facilities[0].id}'` ); } @@ -186,10 +183,7 @@ export class FftFacilityService { facility = await this.apiClient.patch(`${this.PATH}/${facilityId}`, { ...data }); return facility; } catch (err) { - this.logger.error( - `Updating FFT Facility '${facilityId}' from CT Channel '${action.tenantFacilityId}' failed.`, - err - ); + console.error(`Updating FFT Facility '${facilityId}' from CT Channel '${action.tenantFacilityId}' failed.`, err); throw err; } } @@ -216,7 +210,7 @@ export class FftFacilityService { try { let facilityStockConfiguration = await this.getFacilityStockConfiguration(facilityId); if (facilityStockConfiguration && !facilityStockConfiguration.shortpick.active) { - this.logger.debug(`ShortPick for Facility ${facilityId} already disabled`); + console.debug(`ShortPick for Facility ${facilityId} already disabled`); return facilityStockConfiguration; } const data: StockConfigurationPatchActions = { @@ -227,7 +221,7 @@ export class FftFacilityService { return facilityStockConfiguration; } catch (err) { if (err instanceof Error && retries > 0) { - this.logger.debug( + console.debug( `No stock configuration for FFT Facility ${facilityId} found. it could be possible that this is a new Facility and the stock configuration is not created yet. will retry in ${ delay / 1000 } seconds` @@ -235,7 +229,7 @@ export class FftFacilityService { await sleep(delay); return this.disableShortPick(facilityId, retries - 1, delay * 2); } - this.logger.error(`Disabling ShortPick for Facility '${facilityId}' failed.`, err); + console.error(`Disabling ShortPick for Facility '${facilityId}' failed.`, err); throw err; } } diff --git a/src/fft-api/handover/fftHandoverService.ts b/src/fft-api/handover/fftHandoverService.ts index 11f1163..f9d7be3 100644 --- a/src/fft-api/handover/fftHandoverService.ts +++ b/src/fft-api/handover/fftHandoverService.ts @@ -1,5 +1,3 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { HandoverJobCancelActionEnum, @@ -14,7 +12,6 @@ import ActionEnum = ModifyHandoverjobAction.ActionEnum; export class FftHandoverService { private readonly path = 'handoverjobs'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -24,7 +21,7 @@ export class FftHandoverService { pickJobRef: pickJobId, }); } catch (err) { - this.logger.error(`Could not get handover jobs for pickjob id '${pickJobId}'`, err); + console.error(`Could not get handover jobs for pickjob id '${pickJobId}'`, err); throw err; } } @@ -33,7 +30,7 @@ export class FftHandoverService { try { return await this.apiClient.get(`${this.path}/${handoverJobId}`); } catch (err) { - this.logger.error(`Could not get handover job with id '${handoverJobId}'`, err); + console.error(`Could not get handover job with id '${handoverJobId}'`, err); throw err; } } @@ -52,7 +49,7 @@ export class FftHandoverService { try { return await this.apiClient.patch(`${this.path}/${handoverJobId}`, { ...patchObject }); } catch (err) { - this.logger.error(`Could not mark handover job with id '${handoverJobId}' as delivered.`, err); + console.error(`Could not mark handover job with id '${handoverJobId}' as delivered.`, err); throw err; } } @@ -69,7 +66,7 @@ export class FftHandoverService { return handoverJob; } catch (err) { - this.logger.error(`Could not cancel handover job with id '${handoverJobId}' and version ${version}.`, err); + console.error(`Could not cancel handover job with id '${handoverJobId}' and version ${version}.`, err); throw err; } } diff --git a/src/fft-api/listing/fftListingService.ts b/src/fft-api/listing/fftListingService.ts index fe1537e..132e802 100644 --- a/src/fft-api/listing/fftListingService.ts +++ b/src/fft-api/listing/fftListingService.ts @@ -1,12 +1,9 @@ -import { Logger } from 'tslog'; - -import { CustomLogger, FftApiError } from '../../common'; +import { FftApiError } from '../../common'; import { FftApiClient } from '../common'; import { Listing, ListingForReplacement, ModifyListingAction, StrippedListings } from '../types'; export class FftListingService { private readonly path = 'listings'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -17,7 +14,7 @@ export class FftListingService { ...listingsForReplacement, }); } catch (err) { - this.logger.error(`Could not create listing ${listing.tenantArticleId} for facility ${facilityId}.`, err); + console.error(`Could not create listing ${listing.tenantArticleId} for facility ${facilityId}.`, err); throw err; } } @@ -29,7 +26,7 @@ export class FftListingService { if (relaxed && FftApiError.isApiError(err) && err.status === 404) { return undefined; } - this.logger.error(`Could not fetch listing ${tenantArticleId} for facility ${facilityId}.`, err); + console.error(`Could not fetch listing ${tenantArticleId} for facility ${facilityId}.`, err); throw err; } } @@ -40,7 +37,7 @@ export class FftListingService { ...(size && { size: size.toString() }), }); } catch (err) { - this.logger.error(`Could not get listings for facility ${facilityId}.`, err); + console.error(`Could not get listings for facility ${facilityId}.`, err); throw err; } } @@ -57,7 +54,7 @@ export class FftListingService { ...listingPatchActions, }); } catch (err) { - this.logger.error(`Could not update listing ${tenantArticleId} for facility ${facilityId}.`, err); + console.error(`Could not update listing ${tenantArticleId} for facility ${facilityId}.`, err); throw err; } } @@ -66,7 +63,7 @@ export class FftListingService { try { return await this.apiClient.delete(`facilities/${facilityId}/${this.path}/${tenantArticleId}`); } catch (err) { - this.logger.error(`Could not delete listing ${tenantArticleId} for facility ${facilityId}.`, err); + console.error(`Could not delete listing ${tenantArticleId} for facility ${facilityId}.`, err); throw err; } } @@ -75,7 +72,7 @@ export class FftListingService { try { return await this.apiClient.delete(`facilities/${facilityId}/${this.path}`); } catch (err) { - this.logger.error(`Could not delete listings for facility ${facilityId}.`, err); + console.error(`Could not delete listings for facility ${facilityId}.`, err); throw err; } } diff --git a/src/fft-api/loadunit/fftLoadUnitService.ts b/src/fft-api/loadunit/fftLoadUnitService.ts index 78bef2a..19b64a9 100644 --- a/src/fft-api/loadunit/fftLoadUnitService.ts +++ b/src/fft-api/loadunit/fftLoadUnitService.ts @@ -1,12 +1,8 @@ -import { Logger } from 'tslog'; - -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { LoadUnit, LoadUnits } from '../types'; export class FftLoadUnitService { private readonly path = 'loadunits'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -15,7 +11,7 @@ export class FftLoadUnitService { const loadunits = await this.apiClient.get(this.path, { pickJobRef }); return loadunits.loadUnits || []; } catch (err) { - this.logger.error(`Could not get load units for pickjob id '${pickJobRef}'.`, err); + console.error(`Could not get load units for pickjob id '${pickJobRef}'.`, err); throw err; } } diff --git a/src/fft-api/order/fftOrderService.ts b/src/fft-api/order/fftOrderService.ts index 263fba1..1501e74 100644 --- a/src/fft-api/order/fftOrderService.ts +++ b/src/fft-api/order/fftOrderService.ts @@ -1,5 +1,3 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { Order, @@ -12,20 +10,19 @@ import { export class FftOrderService { private readonly path = 'orders'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} public async create(orderForCreation: OrderForCreation): Promise { try { const order = await this.apiClient.post(`${this.path}`, { ...orderForCreation }); - this.logger.debug( + console.debug( `Successfully created order with tenantOrderId '${orderForCreation.tenantOrderId}' and order id '${order.id}'` ); return order; } catch (err) { - this.logger.error(`FFT Order POST with for tenantOrderId '${orderForCreation.tenantOrderId}'.`, err); + console.error(`FFT Order POST with for tenantOrderId '${orderForCreation.tenantOrderId}'.`, err); throw err; } } @@ -39,7 +36,7 @@ export class FftOrderService { return order; } catch (err) { - this.logger.error(`Could not cancel order with id '${orderId}' and version ${version}.`, err); + console.error(`Could not cancel order with id '${orderId}' and version ${version}.`, err); throw err; } } @@ -53,7 +50,7 @@ export class FftOrderService { return order; } catch (err) { - this.logger.error(`Could not unlock order with id '${orderId}' and version ${version}.`, err); + console.error(`Could not unlock order with id '${orderId}' and version ${version}.`, err); throw err; } } @@ -76,7 +73,7 @@ export class FftOrderService { return firstOrder; } - this.logger.warn( + console.warn( `Did not find exactly 1 order with tenantOrderId '${tenantOrderId}' but ${length}, returning first one with id '${firstOrder.id}'` ); return firstOrder; diff --git a/src/fft-api/packjob/fftPackJobService.ts b/src/fft-api/packjob/fftPackJobService.ts index 41becb9..5773f13 100644 --- a/src/fft-api/packjob/fftPackJobService.ts +++ b/src/fft-api/packjob/fftPackJobService.ts @@ -1,11 +1,9 @@ -import { Logger } from 'tslog'; -import { CustomLogger, QueryParams } from '../../common'; +import { QueryParams } from '../../common'; import { FftApiClient } from '../common'; import { AbstractModificationAction, PackJob, PackJobForCreation } from '../types'; export class FftPackJobService { private readonly path = 'packjobs'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -13,7 +11,7 @@ export class FftPackJobService { try { return await this.apiClient.post(`${this.path}`, packJob); } catch (err) { - this.logger.error(`Could not create pack job.`, err); + console.error(`Could not create pack job.`, err); throw err; } } @@ -22,7 +20,7 @@ export class FftPackJobService { try { return await this.apiClient.patch(`${this.path}/${packJob.id}`, { version: packJob.version, actions }); } catch (err) { - this.logger.error(`Could not update pack job with id '${packJob.id}'.`, err); + console.error(`Could not update pack job with id '${packJob.id}'.`, err); throw err; } } @@ -31,7 +29,7 @@ export class FftPackJobService { try { return await this.apiClient.get(`${this.path}/${packJobId}`); } catch (err) { - this.logger.error(`Could not get pack job with id '${packJobId}'.`, err); + console.error(`Could not get pack job with id '${packJobId}'.`, err); throw err; } } @@ -39,7 +37,7 @@ export class FftPackJobService { try { return await this.apiClient.get<{ packJobs: PackJob[] }>(`${this.path}`, params); } catch (err) { - this.logger.error(`Could not get pack jobs.`, err); + console.error(`Could not get pack jobs.`, err); throw err; } } diff --git a/src/fft-api/parcel/fftParcelService.ts b/src/fft-api/parcel/fftParcelService.ts index c66241e..49e1765 100644 --- a/src/fft-api/parcel/fftParcelService.ts +++ b/src/fft-api/parcel/fftParcelService.ts @@ -1,13 +1,10 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; -import { ResponseType } from '../../common/httpClient/models'; -import { FftApiClient } from '../common'; import { Parcel } from '../types'; +import { FftApiClient } from '../common'; import { LabelDocument } from './labelDocument'; +import { ResponseType } from '../../common/httpClient/models'; export class FftParcelService { private readonly path = 'parcels'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -15,7 +12,7 @@ export class FftParcelService { try { return await this.apiClient.get(`${this.path}/${parcelId}`); } catch (err) { - this.logger.error(`Could not get parcel with id '${parcelId}'.`, err); + console.error(`Could not get parcel with id '${parcelId}'.`, err); throw err; } } @@ -32,7 +29,7 @@ export class FftParcelService { ResponseType.BLOB ); } catch (err) { - this.logger.error(`Could not get label ${labelDocument} for parcel with id '${parcelId}'.`, err); + console.error(`Could not get label ${labelDocument} for parcel with id '${parcelId}'.`, err); throw err; } } diff --git a/src/fft-api/pickjob/fftPickJobService.ts b/src/fft-api/pickjob/fftPickJobService.ts index 66a9a2c..0696a43 100644 --- a/src/fft-api/pickjob/fftPickJobService.ts +++ b/src/fft-api/pickjob/fftPickJobService.ts @@ -1,6 +1,3 @@ -import { Logger } from 'tslog'; -import { CustomLogger, isDate, QueryParams } from '../../common'; -import { FftApiClient, MAX_ARRAY_SIZE } from '../common'; import { AbstractModificationAction, PickJob, @@ -12,10 +9,11 @@ import { PickJobStatus, StrippedPickJobs, } from '../types'; +import { FftApiClient, MAX_ARRAY_SIZE } from '../common'; +import { isDate, QueryParams } from '../../common'; export class FftPickJobService { private readonly path = 'pickjobs'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -23,7 +21,7 @@ export class FftPickJobService { try { return await this.apiClient.get(this.path, { tenantOrderId }); } catch (err) { - this.logger.error(`Could not get pick jobs with tenant order id '${tenantOrderId}'.`, err); + console.error(`Could not get pick jobs with tenant order id '${tenantOrderId}'.`, err); throw err; } } @@ -51,7 +49,7 @@ export class FftPickJobService { version, }); } catch (err) { - this.logger.error(`Could not update pick job with id '${pickJobId}' and version ${version}.`, err); + console.error(`Could not update pick job with id '${pickJobId}' and version ${version}.`, err); throw err; } } @@ -60,7 +58,7 @@ export class FftPickJobService { try { return await this.apiClient.get(`${this.path}/${pickJobId}`); } catch (err) { - this.logger.error(`Could not get pick job with id '${pickJobId}'.`, err); + console.error(`Could not get pick job with id '${pickJobId}'.`, err); throw err; } } @@ -82,7 +80,7 @@ export class FftPickJobService { try { return await this.apiClient.get(this.path, params); } catch (err) { - this.logger.error(`Could not get pick jobs for facility '${id}'.`, err); + console.error(`Could not get pick jobs for facility '${id}'.`, err); throw err; } } @@ -91,7 +89,7 @@ export class FftPickJobService { try { return await this.apiClient.patch(`${this.path}/${pickJob.id}`, { version: pickJob.version, actions }); } catch (err) { - this.logger.error(`Could not update pick job with id '${pickJob.id}'.`, err); + console.error(`Could not update pick job with id '${pickJob.id}'.`, err); throw err; } } @@ -187,7 +185,7 @@ export class FftPickJobService { return await this.apiClient.get(this.path, queryParams); } catch (err) { - this.logger.error(`Fetching all pick jobs failed.`, err); + console.error(`Fetching all pick jobs failed.`, err); throw err; } } diff --git a/src/fft-api/process/fftProcessService.ts b/src/fft-api/process/fftProcessService.ts index 3998333..835c298 100644 --- a/src/fft-api/process/fftProcessService.ts +++ b/src/fft-api/process/fftProcessService.ts @@ -1,11 +1,8 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { Process } from '../types'; export class FftProcessService { private readonly path = 'processes'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -13,7 +10,7 @@ export class FftProcessService { try { return await this.apiClient.get(`${this.path}/${processId}`); } catch (err) { - this.logger.error(`Could not get process with id '${processId}'.`, err); + console.error(`Could not get process with id '${processId}'.`, err); throw err; } } diff --git a/src/fft-api/project/fftProjectService.ts b/src/fft-api/project/fftProjectService.ts index f766e60..e9939e3 100644 --- a/src/fft-api/project/fftProjectService.ts +++ b/src/fft-api/project/fftProjectService.ts @@ -1,12 +1,7 @@ -import { Logger } from 'tslog'; - -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { SupportedEvents, SupportedLocales } from '../types'; export class FftProjectService { - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async getSupportedLocales(): Promise { diff --git a/src/fft-api/promising/fftOrderPromisingService.ts b/src/fft-api/promising/fftOrderPromisingService.ts index 9581ddb..9d79ab5 100644 --- a/src/fft-api/promising/fftOrderPromisingService.ts +++ b/src/fft-api/promising/fftOrderPromisingService.ts @@ -1,5 +1,3 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { CheckoutOptionsDeliveryEarliestRequest, @@ -15,7 +13,6 @@ import { export class FftOrderPromisingService { private readonly path = 'promises/checkoutoptions'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -27,7 +24,7 @@ export class FftOrderPromisingService { ...request, }); } catch (err) { - this.logger.error(`FFT Checkoutoptions Earliest POST failed.`, err); + console.error(`FFT Checkoutoptions Earliest POST failed.`, err); throw err; } } @@ -40,7 +37,7 @@ export class FftOrderPromisingService { ...request, }); } catch (err) { - this.logger.error(`FFT Checkoutoptions TimePeriod POST failed.`, err); + console.error(`FFT Checkoutoptions TimePeriod POST failed.`, err); throw err; } } @@ -53,7 +50,7 @@ export class FftOrderPromisingService { ...request, }); } catch (err) { - this.logger.error(`FFT Checkoutoptions TimePoint POST failed.`, err); + console.error(`FFT Checkoutoptions TimePoint POST failed.`, err); throw err; } } @@ -66,7 +63,7 @@ export class FftOrderPromisingService { ...request, }); } catch (err) { - this.logger.error(`FFT CheckoutOptions POST failed.`, err); + console.error(`FFT CheckoutOptions POST failed.`, err); throw err; } } diff --git a/src/fft-api/routing-plan/fftRoutingPlanService.ts b/src/fft-api/routing-plan/fftRoutingPlanService.ts index 2d16a91..110a131 100644 --- a/src/fft-api/routing-plan/fftRoutingPlanService.ts +++ b/src/fft-api/routing-plan/fftRoutingPlanService.ts @@ -1,11 +1,8 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; -import { FftApiClient } from '../common'; import { DecisionLog, RoutingPlan, RoutingPlans } from '../types'; +import { FftApiClient } from '../common'; export class FftRoutingPlanService { private readonly path = 'routingplans'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -13,7 +10,7 @@ export class FftRoutingPlanService { try { return await this.apiClient.get(this.path, { orderRef }); } catch (err) { - this.logger.error(`Could not get routing plans for order ref '${orderRef}'.`, err); + console.error(`Could not get routing plans for order ref '${orderRef}'.`, err); throw err; } } @@ -22,7 +19,7 @@ export class FftRoutingPlanService { try { return await this.apiClient.get(`${this.path}/${routingPlanId}`); } catch (err) { - this.logger.error(`Could not get routing plan for ID '${routingPlanId}'.`, err); + console.error(`Could not get routing plan for ID '${routingPlanId}'.`, err); throw err; } } @@ -31,7 +28,7 @@ export class FftRoutingPlanService { try { return await this.apiClient.get(`${this.path}/${routingPlanId}/decisionlogs/${routingRun}`); } catch (err) { - this.logger.error(`Could not get decision log for routing plan '${routingPlanId}'.`, err); + console.error(`Could not get decision log for routing plan '${routingPlanId}'.`, err); throw err; } } diff --git a/src/fft-api/shipment/fftShipmentService.ts b/src/fft-api/shipment/fftShipmentService.ts index 8c23412..8a69a59 100644 --- a/src/fft-api/shipment/fftShipmentService.ts +++ b/src/fft-api/shipment/fftShipmentService.ts @@ -1,11 +1,8 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; -import { FftApiClient } from '../common'; import { Parcel, ParcelForCreation, Shipment, StrippedShipments } from '../types'; +import { FftApiClient } from '../common'; export class FftShipmentService { private readonly path = 'shipments'; - private readonly logger: Logger = new CustomLogger(); constructor(private readonly apiClient: FftApiClient) {} @@ -13,7 +10,7 @@ export class FftShipmentService { try { return await this.apiClient.get(`${this.path}/${shipmentId}`); } catch (err) { - this.logger.error(`Could not get shipment with id '${shipmentId}'.`, err); + console.error(`Could not get shipment with id '${shipmentId}'.`, err); throw err; } } @@ -22,7 +19,7 @@ export class FftShipmentService { try { return await this.apiClient.get(`${this.path}`, { pickJobRef }); } catch (err) { - this.logger.error(`Could not get shipments for pickJob '${pickJobRef}'.`, err); + console.error(`Could not get shipments for pickJob '${pickJobRef}'.`, err); throw err; } } @@ -34,7 +31,7 @@ export class FftShipmentService { parcel as unknown as Record ); } catch (err) { - this.logger.error(`Could not create parcel for shipment '${shipmentId}'.`, err); + console.error(`Could not create parcel for shipment '${shipmentId}'.`, err); throw err; } } diff --git a/src/fft-api/stock/fftStockService.ts b/src/fft-api/stock/fftStockService.ts index 040a453..81cca7f 100644 --- a/src/fft-api/stock/fftStockService.ts +++ b/src/fft-api/stock/fftStockService.ts @@ -1,5 +1,4 @@ -import { Logger } from 'tslog'; -import { CustomLogger, ErrorType, FftSdkError, QueryParams } from '../../common'; +import { ErrorType, FftSdkError, QueryParams } from '../../common'; import { FftApiClient, MAX_ARRAY_SIZE } from '../common'; import { FacilityServiceType, @@ -17,15 +16,13 @@ import { export class FftStockService { private readonly path: string = 'stocks'; - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async createStock(stockForCreation: StockForCreation): Promise { try { return await this.apiClient.post(this.path, { ...stockForCreation }); } catch (error) { - this.logger.error(`Could not create stock.`, error); + console.error(`Could not create stock.`, error); throw error; } } @@ -64,7 +61,7 @@ export class FftStockService { return await this.apiClient.get(this.path, queryParams); } catch (error) { - this.logger.error(`Fetching all stock failed.`, error); + console.error(`Fetching all stock failed.`, error); throw error; } } @@ -73,7 +70,7 @@ export class FftStockService { try { return await this.apiClient.put(this.path, { ...stocksForUpsert }); } catch (error) { - this.logger.error(`Could not upsert stock.`, error); + console.error(`Could not upsert stock.`, error); throw error; } } @@ -82,7 +79,7 @@ export class FftStockService { try { return await this.apiClient.put(`${this.path}/${stockId}`, { ...stockForUpdate }); } catch (error) { - this.logger.error(`Could not update stock ${stockId}.`, error); + console.error(`Could not update stock ${stockId}.`, error); throw error; } } @@ -91,7 +88,7 @@ export class FftStockService { try { return await this.apiClient.delete(`${this.path}/${stockId}`); } catch (error) { - this.logger.error(`Could not delete stock with id ${stockId}.`, error); + console.error(`Could not delete stock with id ${stockId}.`, error); throw error; } } @@ -117,7 +114,7 @@ export class FftStockService { try { return await this.apiClient.post(`${this.path}/actions`, action); } catch (error) { - this.logger.error(`Could not delete stocks with ids ${stockIds.join()}.`, error); + console.error(`Could not delete stocks with ids ${stockIds.join()}.`, error); throw error; } } @@ -144,7 +141,7 @@ export class FftStockService { try { return await this.apiClient.post(`${this.path}/actions`, action); } catch (error) { - this.logger.error(`Could not delete stocks in facility ${facilityId} for ${tenantArticleIds.join()}.`, error); + console.error(`Could not delete stocks in facility ${facilityId} for ${tenantArticleIds.join()}.`, error); throw error; } } @@ -170,7 +167,7 @@ export class FftStockService { try { return await this.apiClient.post(`${this.path}/actions`, action); } catch (error) { - this.logger.error(`Could not delete stocks for locations ${locationIds.join()}.`, error); + console.error(`Could not delete stocks for locations ${locationIds.join()}.`, error); throw error; } } @@ -195,7 +192,7 @@ export class FftStockService { try { return await this.apiClient.post(`${this.path}/actions`, action); } catch (error) { - this.logger.error(`Could not move stock ${fromStockId} to location ${toLocationId}.`, error); + console.error(`Could not move stock ${fromStockId} to location ${toLocationId}.`, error); throw error; } } @@ -204,7 +201,7 @@ export class FftStockService { try { return await this.apiClient.get(`${this.path}/${stockId}`); } catch (error) { - this.logger.error(`Could not get stock with id '${stockId}'.`, error); + console.error(`Could not get stock with id '${stockId}'.`, error); throw error; } } @@ -258,7 +255,7 @@ export class FftStockService { } return await this.apiClient.get(`${this.path}/summaries`, queryParams); } catch (error) { - this.logger.error(`Fetching stock summaries failed.`, error); + console.error(`Fetching stock summaries failed.`, error); throw error; } } @@ -302,7 +299,7 @@ export class FftStockService { return await this.apiClient.get(`articles/${tenantArticleId}/stockdistribution`, queryParams); } catch (error) { - this.logger.error(`Fetching stock distribution for tenantArticleId ${tenantArticleId} failed.`, error); + console.error(`Fetching stock distribution for tenantArticleId ${tenantArticleId} failed.`, error); throw error; } } diff --git a/src/fft-api/subscription/fftSubscriptionService.ts b/src/fft-api/subscription/fftSubscriptionService.ts index 668e72e..7093e71 100644 --- a/src/fft-api/subscription/fftSubscriptionService.ts +++ b/src/fft-api/subscription/fftSubscriptionService.ts @@ -1,20 +1,16 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { Subscription, SubscriptionForCreation, Subscriptions } from '../types'; export class FftSubscriptionService { private readonly PATH = 'subscriptions'; - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async getSubscriptions(size = 25): Promise { try { return await this.apiClient.get(this.PATH, { ...(size && { size: size.toString() }) }); } catch (err) { - this.logger.error(`Getting FFT Subscriptions failed.`, err); + console.error(`Getting FFT Subscriptions failed.`, err); throw err; } } @@ -23,7 +19,7 @@ export class FftSubscriptionService { try { return await this.apiClient.post(this.PATH, { ...subscriptionForCreation }); } catch (err) { - this.logger.error(`Creating FFT Subscription '${subscriptionForCreation.name}' failed.`, err); + console.error(`Creating FFT Subscription '${subscriptionForCreation.name}' failed.`, err); throw err; } } @@ -32,7 +28,7 @@ export class FftSubscriptionService { try { await this.apiClient.delete(`${this.PATH}/${subscriptionId}`); } catch (err) { - this.logger.error(`Deleting FFT Subscription '${subscriptionId}' failed.`, err); + console.error(`Deleting FFT Subscription '${subscriptionId}' failed.`, err); throw err; } } diff --git a/src/fft-api/tag/fftTagService.ts b/src/fft-api/tag/fftTagService.ts index 0ff7b37..50f563a 100644 --- a/src/fft-api/tag/fftTagService.ts +++ b/src/fft-api/tag/fftTagService.ts @@ -1,13 +1,9 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { AddAllowedValueToTagAction, StrippedTags, Tag, TagForCreation, TagPatchActions } from '../types'; export class FftTagService { private readonly PATH = 'tags'; - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async create(key: string, values: string[]): Promise { @@ -18,7 +14,7 @@ export class FftTagService { try { return await this.apiClient.post(this.PATH, { ...tagForCreation }); } catch (error) { - this.logger.error(`Could not create tag.`, error); + console.error(`Could not create tag.`, error); throw error; } } @@ -27,7 +23,7 @@ export class FftTagService { try { return await this.apiClient.get(`${this.PATH}/${id}`); } catch (error) { - this.logger.error(`Could not get tag ${id}.`, error); + console.error(`Could not get tag ${id}.`, error); throw error; } } @@ -36,7 +32,7 @@ export class FftTagService { try { return await this.apiClient.get(this.PATH, { ...(size && { size: size.toString() }) }); } catch (error) { - this.logger.error(`Could not get tags.`, error); + console.error(`Could not get tags.`, error); throw error; } } @@ -57,7 +53,7 @@ export class FftTagService { }; return await this.apiClient.patch(`${this.PATH}/${id}`, { ...tagPatchActions }); } catch (error) { - this.logger.error(`Could not update tag ${id}.`, error); + console.error(`Could not update tag ${id}.`, error); throw error; } } diff --git a/src/fft-api/zone/fftZoneService.ts b/src/fft-api/zone/fftZoneService.ts index 5ca385e..c4aa86c 100644 --- a/src/fft-api/zone/fftZoneService.ts +++ b/src/fft-api/zone/fftZoneService.ts @@ -1,13 +1,9 @@ -import { Logger } from 'tslog'; -import { CustomLogger } from '../../common'; import { FftApiClient } from '../common'; import { Zone, ZoneForCreation, ZoneForReplacement } from '../types'; export class FftZoneService { private readonly PATH = 'zones'; - private readonly logger: Logger = new CustomLogger(); - constructor(private readonly apiClient: FftApiClient) {} public async create(facilityId: string, name: string, score: number): Promise { @@ -18,7 +14,7 @@ export class FftZoneService { try { return await this.apiClient.post(`facilities/${facilityId}/${this.PATH}`, { ...zoneForCreation }); } catch (error) { - this.logger.error(`Could not create zone for facility ${facilityId}.`, error); + console.error(`Could not create zone for facility ${facilityId}.`, error); throw error; } } @@ -29,7 +25,7 @@ export class FftZoneService { ...(size && { size: size.toString() }), }); } catch (error) { - this.logger.error(`Could not get zones for facility ${facilityId}.`, error); + console.error(`Could not get zones for facility ${facilityId}.`, error); throw error; } } @@ -38,7 +34,7 @@ export class FftZoneService { try { return await this.apiClient.get(`facilities/${facilityId}/${this.PATH}/${zoneId}`); } catch (error) { - this.logger.error(`Could not get zone ${zoneId} for facility ${facilityId}.`, error); + console.error(`Could not get zone ${zoneId} for facility ${facilityId}.`, error); throw error; } } @@ -55,7 +51,7 @@ export class FftZoneService { ...zoneForReplacement, }); } catch (error) { - this.logger.error(`Could not update zone ${zoneId} for facility ${facilityId}.`, error); + console.error(`Could not update zone ${zoneId} for facility ${facilityId}.`, error); throw error; } } @@ -64,7 +60,7 @@ export class FftZoneService { try { return await this.apiClient.delete(`facilities/${facilityId}/${this.PATH}/${zoneId}`); } catch (error) { - this.logger.error(`Could not delete zone ${zoneId} for facility ${facilityId}.`, error); + console.error(`Could not delete zone ${zoneId} for facility ${facilityId}.`, error); throw error; } }