From 9d23ce1b1a3d33a8a9a7da8e6e4a47137bb58a98 Mon Sep 17 00:00:00 2001 From: Julian Gruber Date: Mon, 2 Oct 2023 14:21:05 +0200 Subject: [PATCH] apply fix --- fetch.d.ts | 15 +++++++++++++ package-lock.json | 54 ++++++++++++++++++++++++++++++++++++++++------- package.json | 4 +++- tsconfig.json | 5 +++-- 4 files changed, 67 insertions(+), 11 deletions(-) create mode 100644 fetch.d.ts diff --git a/fetch.d.ts b/fetch.d.ts new file mode 100644 index 00000000..244a4ffd --- /dev/null +++ b/fetch.d.ts @@ -0,0 +1,15 @@ +import type * as undici from "undici"; + +declare global { + // Re-export undici fetch function and various classes to global scope. + // These are classes and functions expected to be at global scope according to + // Node.js v18 API documentation. + // See: https://nodejs.org/dist/latest-v18.x/docs/api/globals.html + export const { + FormData, + Headers, + Request, + Response, + fetch, + }: typeof undici; +} diff --git a/package-lock.json b/package-lock.json index 2a0aa1a0..21e165b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "station": "bin/station.js" }, "devDependencies": { + "@types/node": "^20.8.0", "@types/yargs": "^17.0.24", "get-stream": "^8.0.1", "mocha": "^10.2.0", @@ -30,10 +31,11 @@ "prettier": "^3.0.0", "standard": "^17.0.0", "stream-match": "^1.2.1", - "typescript": "^5.0.4" + "typescript": "^5.0.4", + "undici": "^5.25.3" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/@babel/code-frame": { @@ -228,6 +230,15 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@fastify/busboy": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz", + "integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==", + "dev": true, + "engines": { + "node": ">=14" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -494,9 +505,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.2.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", - "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "version": "20.8.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.0.tgz", + "integrity": "sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -8374,6 +8385,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.25.3.tgz", + "integrity": "sha512-7lmhlz3K1+IKB6IUjkdzV2l0jKY8/0KguEMdEpzzXCug5pEGIp3DxUg0DEN65DrVoxHiRKpPORC/qzX+UglSkQ==", + "dev": true, + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, "node_modules/unique-string": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-3.0.0.tgz", @@ -9043,6 +9066,12 @@ "integrity": "sha512-LxcyMGxwmTh2lY9FwHPGWOHmYFCZvbrFCBZL4FzSSsxsRPuhrYUg/49/0KDfW8tnIEaEHtfmn6+NPN+1DqaNmA==", "dev": true }, + "@fastify/busboy": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.0.0.tgz", + "integrity": "sha512-JUFJad5lv7jxj926GPgymrWQxxjPYuJNiNjNMzqT+HiuP6Vl3dk5xzG+8sTX96np0ZAluvaMzPsjhHZ5rNuNQQ==", + "dev": true + }, "@humanwhocodes/config-array": { "version": "0.11.8", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", @@ -9245,9 +9274,9 @@ "dev": true }, "@types/node": { - "version": "20.2.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.2.5.tgz", - "integrity": "sha512-JJulVEQXmiY9Px5axXHeYGLSjhkZEnD+MDPDGbCbIAbMslkKwmygtZFy1X6s/075Yo94sf8GuSlFfPzysQrWZQ==", + "version": "20.8.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.0.tgz", + "integrity": "sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==", "dev": true }, "@types/normalize-package-data": { @@ -14867,6 +14896,15 @@ "which-boxed-primitive": "^1.0.2" } }, + "undici": { + "version": "5.25.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.25.3.tgz", + "integrity": "sha512-7lmhlz3K1+IKB6IUjkdzV2l0jKY8/0KguEMdEpzzXCug5pEGIp3DxUg0DEN65DrVoxHiRKpPORC/qzX+UglSkQ==", + "dev": true, + "requires": { + "@fastify/busboy": "^2.0.0" + } + }, "unique-string": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/unique-string/-/unique-string-3.0.0.tgz", diff --git a/package.json b/package.json index 1cd63b83..57b58e54 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ ] }, "devDependencies": { + "@types/node": "^20.8.0", "@types/yargs": "^17.0.24", "get-stream": "^8.0.1", "mocha": "^10.2.0", @@ -39,7 +40,8 @@ "prettier": "^3.0.0", "standard": "^17.0.0", "stream-match": "^1.2.1", - "typescript": "^5.0.4" + "typescript": "^5.0.4", + "undici": "^5.25.3" }, "dependencies": { "@influxdata/influxdb-client": "^1.33.2", diff --git a/tsconfig.json b/tsconfig.json index 5d96c501..6adc0051 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "allowJs": true, "checkJs": true, "skipLibCheck": true, - "lib": ["es2021", "DOM"], + "lib": ["es2021"], "target": "es2021", "module": "Node16", "moduleResolution": "node16", @@ -24,7 +24,8 @@ "commands", "lib", "scripts", - "tests" + "tests", + "fetch.d.ts" ], "exclude": [ "dist/**/*"