diff --git a/package-lock.json b/package-lock.json index 3393bfeeb4..dd3652464e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2281,9 +2281,9 @@ } }, "node_modules/@mswjs/interceptors": { - "version": "0.38.6", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.38.6.tgz", - "integrity": "sha512-qFlpmObPqeUs4u3oFYv/OM/xyX+pNa5TRAjqjvMhbGYlyMhzSrE5UfncL2rUcEeVfD9Gebgff73hPwqcOwJQNA==", + "version": "0.38.7", + "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.38.7.tgz", + "integrity": "sha512-Jkb27iSn7JPdkqlTqKfhncFfnEZsIJVYxsFbUSWEkxdIPdsyngrhoDBk0/BGD2FQcRH99vlRrkHpNTyKqI+0/w==", "dev": true, "license": "MIT", "dependencies": { @@ -9569,15 +9569,6 @@ "node": ">=8" } }, - "node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "license": "MIT", - "engines": { - "node": ">= 12" - } - }, "node_modules/data-view-buffer": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", @@ -12000,29 +11991,6 @@ "dev": true, "license": "MIT" }, - "node_modules/fetch-blob": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", - "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "paypal", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "dependencies": { - "node-domexception": "^1.0.0", - "web-streams-polyfill": "^3.0.3" - }, - "engines": { - "node": "^12.20 || >= 14.13" - } - }, "node_modules/fetch-node-website": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/fetch-node-website/-/fetch-node-website-8.1.0.tgz", @@ -12323,79 +12291,6 @@ "node": ">= 14.17" } }, - "node_modules/formdata-polyfill": { - "version": "4.0.10", - "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", - "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", - "license": "MIT", - "dependencies": { - "fetch-blob": "^3.1.2" - }, - "engines": { - "node": ">=12.20.0" - } - }, - "node_modules/from2": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", - "integrity": "sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "inherits": "^2.0.1", - "readable-stream": "^2.0.0" - } - }, - "node_modules/from2-string": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/from2-string/-/from2-string-1.1.0.tgz", - "integrity": "sha512-m8vCh+KnXXXBtfF2VUbiYlQ+nczLcntB0BrtNgpmLkHylhObe9WF1b2LZjBBzrZzA6P4mkEla6ZYQoOUTG8cYA==", - "dev": true, - "license": "MIT", - "dependencies": { - "from2": "^2.0.3" - } - }, - "node_modules/from2/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, - "license": "MIT" - }, - "node_modules/from2/node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dev": true, - "license": "MIT", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/from2/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true, - "license": "MIT" - }, - "node_modules/from2/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, "node_modules/front-matter": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-4.0.2.tgz", @@ -17644,55 +17539,18 @@ "license": "MIT" }, "node_modules/nock": { - "version": "13.5.6", - "resolved": "https://registry.npmjs.org/nock/-/nock-13.5.6.tgz", - "integrity": "sha512-o2zOYiCpzRqSzPj0Zt/dQ/DqZeYoaQ7TUonc/xUPjCGl9WeHpNbxgVvOquXYAaJzI0M9BXV3HTzG0p8IUAbBTQ==", + "version": "14.0.5", + "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.5.tgz", + "integrity": "sha512-R49fALR9caB6vxuSWUIaK2eBYeTloZQUFBZ4rHO+TbhMGQHtwnhdqKLYki+o+8qMgLvoBYWrp/2KzGPhxL4S6w==", "dev": true, "license": "MIT", "dependencies": { - "debug": "^4.1.0", + "@mswjs/interceptors": "^0.38.7", "json-stringify-safe": "^5.0.1", "propagate": "^2.0.0" }, "engines": { - "node": ">= 10.13" - } - }, - "node_modules/node-domexception": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/jimmywarting" - }, - { - "type": "github", - "url": "https://paypal.me/jimmywarting" - } - ], - "license": "MIT", - "engines": { - "node": ">=10.5.0" - } - }, - "node_modules/node-fetch": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", - "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", - "license": "MIT", - "dependencies": { - "data-uri-to-buffer": "^4.0.0", - "fetch-blob": "^3.1.4", - "formdata-polyfill": "^4.0.10" - }, - "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-fetch" + "node": ">=18.20.0 <20 || >=20.12.1" } }, "node_modules/node-gyp": { @@ -24664,15 +24522,6 @@ "defaults": "^1.0.3" } }, - "node_modules/web-streams-polyfill": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", - "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", @@ -27093,21 +26942,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "packages/edge-bundler/node_modules/nock": { - "version": "14.0.4", - "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.4.tgz", - "integrity": "sha512-86fh+gIKH8H02+y0/HKAOZZXn6OwgzXvl6JYwfjvKkoKxUWz54wIIDU/+w24xzMvk/R8pNVXOrvTubyl+Ml6cg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@mswjs/interceptors": "^0.38.5", - "json-stringify-safe": "^5.0.1", - "propagate": "^2.0.0" - }, - "engines": { - "node": ">=18.20.0 <20 || >=20.12.1" - } - }, "packages/edge-bundler/node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -28713,7 +28547,6 @@ "@netlify/open-api": "^2.37.0", "lodash-es": "^4.17.21", "micro-api-client": "^3.3.0", - "node-fetch": "^3.0.0", "p-wait-for": "^5.0.0", "qs": "^6.9.6" }, @@ -28722,8 +28555,7 @@ "@types/node": "^18.0.0", "ava": "^5.0.0", "c8": "^10.0.0", - "from2-string": "^1.1.0", - "nock": "^13.0.0", + "nock": "^14.0.0", "ts-node": "^10.9.1", "typescript": "^5.0.0", "uuid": "^11.0.0" diff --git a/packages/build/tests/core/snapshots/tests.js.md b/packages/build/tests/core/snapshots/tests.js.md index 277f9bef75..c31928436a 100644 --- a/packages/build/tests/core/snapshots/tests.js.md +++ b/packages/build/tests/core/snapshots/tests.js.md @@ -1468,7 +1468,7 @@ Generated by [AVA](https://avajs.dev). [ { body: '', - headers: 'accept accept-encoding authorization connection content-length host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/cancel', }, diff --git a/packages/build/tests/core/snapshots/tests.js.snap b/packages/build/tests/core/snapshots/tests.js.snap index aa1ca0226d..79de53df97 100644 Binary files a/packages/build/tests/core/snapshots/tests.js.snap and b/packages/build/tests/core/snapshots/tests.js.snap differ diff --git a/packages/build/tests/status/snapshots/tests.js.md b/packages/build/tests/status/snapshots/tests.js.md index 6aeab9f83f..2c48e8b23b 100644 --- a/packages/build/tests/status/snapshots/tests.js.md +++ b/packages/build/tests/status/snapshots/tests.js.md @@ -73,7 +73,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -162,7 +162,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -274,7 +274,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -349,7 +349,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -414,7 +414,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: undefined, }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -505,7 +505,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: undefined, }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -519,7 +519,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./two.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -584,7 +584,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: undefined, }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -651,7 +651,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -719,7 +719,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -787,7 +787,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1054,7 +1054,7 @@ Generated by [AVA](https://avajs.dev). title: 'title', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1068,7 +1068,7 @@ Generated by [AVA](https://avajs.dev). title: 'title', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1081,7 +1081,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1094,7 +1094,7 @@ Generated by [AVA](https://avajs.dev). text: 'text', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1108,7 +1108,7 @@ Generated by [AVA](https://avajs.dev). title: 'title ./two.js', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1459,7 +1459,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1533,7 +1533,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1620,7 +1620,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" failed', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1713,7 +1713,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" failed', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1781,7 +1781,7 @@ Generated by [AVA](https://avajs.dev). title: 'Build canceled by ./plugin.js', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -1937,7 +1937,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2026,7 +2026,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2119,7 +2119,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2212,7 +2212,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2299,7 +2299,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2398,7 +2398,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" invalid input "test"', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2494,7 +2494,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./one" internal error', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2505,7 +2505,7 @@ Generated by [AVA](https://avajs.dev). text: undefined, version: undefined, }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, @@ -2595,7 +2595,7 @@ Generated by [AVA](https://avajs.dev). title: 'Plugin "./plugin.js" failed', version: '1.0.0', }, - headers: 'accept accept-encoding authorization connection content-length content-type host user-agent', + headers: 'accept accept-encoding accept-language authorization connection content-length content-type host sec-fetch-mode user-agent', method: 'POST', url: '/api/v1/deploys/test/plugin_runs', }, diff --git a/packages/build/tests/status/snapshots/tests.js.snap b/packages/build/tests/status/snapshots/tests.js.snap index 5de711b77b..996f136ef2 100644 Binary files a/packages/build/tests/status/snapshots/tests.js.snap and b/packages/build/tests/status/snapshots/tests.js.snap differ diff --git a/packages/js-client/README.md b/packages/js-client/README.md index 1b39ead1e1..8014006c05 100644 --- a/packages/js-client/README.md +++ b/packages/js-client/README.md @@ -94,8 +94,8 @@ const params = { } ``` -Optional `opts` can include any property you want passed to [`node-fetch`](https://github.com/bitinn/node-fetch). The -`headers` property is merged with some `defaultHeaders`. +Optional `opts` can include any property you want passed to `fetch`. The `headers` property is merged with some +`defaultHeaders`. ```js // example opts @@ -105,7 +105,7 @@ const opts = { 'User-agent': 'netlify-js-client', accept: 'application/json', }, - // any other properties for node-fetch + // any other properties for fetch } ``` diff --git a/packages/js-client/package.json b/packages/js-client/package.json index fd88ae7c66..7b0b4b0106 100644 --- a/packages/js-client/package.json +++ b/packages/js-client/package.json @@ -44,7 +44,6 @@ "@netlify/open-api": "^2.37.0", "lodash-es": "^4.17.21", "micro-api-client": "^3.3.0", - "node-fetch": "^3.0.0", "p-wait-for": "^5.0.0", "qs": "^6.9.6" }, @@ -53,8 +52,7 @@ "@types/node": "^18.0.0", "ava": "^5.0.0", "c8": "^10.0.0", - "from2-string": "^1.1.0", - "nock": "^13.0.0", + "nock": "^14.0.0", "ts-node": "^10.9.1", "typescript": "^5.0.0", "uuid": "^11.0.0" diff --git a/packages/js-client/src/index.test.ts b/packages/js-client/src/index.test.ts index dab39aca35..4dd8392f6d 100644 --- a/packages/js-client/src/index.test.ts +++ b/packages/js-client/src/index.test.ts @@ -1,7 +1,6 @@ -import http from 'http' +import { Readable } from 'node:stream' import test from 'ava' -import fromString from 'from2-string' import { TextHTTPError, JSONHTTPError } from 'micro-api-client' import nock from 'nock' import { v4 as uuidv4 } from 'uuid' @@ -16,18 +15,6 @@ const host = `${domain}:${port}` const origin = `${scheme}://${host}` const testAccessToken = 'testAccessToken' -const AGENT_KEEP_ALIVE_MSECS = 60_000 -const AGENT_MAX_SOCKETS = 10 -const AGENT_MAX_FREE_SOCKETS = 10 -const AGENT_TIMEOUT = 60_000 -const agent = new http.Agent({ - keepAlive: true, - keepAliveMsecs: AGENT_KEEP_ALIVE_MSECS, - maxSockets: AGENT_MAX_SOCKETS, - maxFreeSockets: AGENT_MAX_FREE_SOCKETS, - timeout: AGENT_TIMEOUT, -}) - const getClient = function (opts: any = {}) { return new NetlifyAPI(opts.accessToken, { scheme, host, pathPrefix, ...opts }) } @@ -38,7 +25,6 @@ test('Default options', (t) => { t.is(client.host, 'api.netlify.com') t.is(client.pathPrefix, '/api/v1') t.is(client.accessToken, null) - t.is(client.agent, undefined) t.deepEqual(client.globalParams, {}) t.deepEqual(client.defaultHeaders, { 'User-agent': 'netlify/js-client', @@ -224,7 +210,12 @@ test('Can specify binary request body as a stream', async (t) => { .reply(200, expectedResponse) const client: any = getClient() - const response = await client.uploadDeployFile({ deploy_id: deployId, path, body: fromString(body) }) + const response = await client.uploadDeployFile({ + deploy_id: deployId, + path, + body: Readable.from(body), + duplex: 'half', + }) t.deepEqual(response, expectedResponse) t.true(scope.isDone()) @@ -240,7 +231,12 @@ test('Can specify binary request body as a function', async (t) => { .reply(200, expectedResponse) const client: any = getClient() - const response = await client.uploadDeployFile({ deploy_id: deployId, path, body: () => fromString(body) }) + const response = await client.uploadDeployFile({ + deploy_id: deployId, + path, + body: () => Readable.from(body), + duplex: 'half', + }) t.deepEqual(response, expectedResponse) t.true(scope.isDone()) @@ -273,7 +269,8 @@ test('Can set header parameters', async (t) => { const response = await client.uploadDeployFunction({ deploy_id: deployId, name: functionName, - body: fromString(body), + body: Readable.from(body), + duplex: 'half', xNfRetryCount: retryCount, }) @@ -349,7 +346,6 @@ test('Handle error empty responses', async (t) => { const error: any = await t.throwsAsync(client.getAccount({ account_id: accountId })) t.is(error.status, status) - t.is(error.message, expectedResponse) t.is(error.data, expectedResponse) t.true(error instanceof TextHTTPError) t.true(error.stack !== undefined) @@ -366,7 +362,6 @@ test('Handle error text responses', async (t) => { const error: any = await t.throwsAsync(client.getAccount({ account_id: accountId })) t.is(error.status, status) - t.is(error.message, expectedResponse) t.is(error.data, expectedResponse) t.true(error instanceof TextHTTPError) t.true(error.stack !== undefined) @@ -385,7 +380,6 @@ test('Handle error text responses on JSON endpoints', async (t) => { const error: any = await t.throwsAsync(client.getAccount({ account_id: accountId })) t.is(error.status, status) - t.is(error.message, expectedResponse) t.is(error.data, expectedResponse) t.true(error instanceof TextHTTPError) t.true(error.stack !== undefined) @@ -402,7 +396,6 @@ test('Handle error JSON responses', async (t) => { const error: any = await t.throwsAsync(client.getAccount({ account_id: accountId })) t.is(error.status, status) - t.notThrows(() => JSON.parse(error.message)) t.deepEqual(error.json, errorJson) t.true(error instanceof JSONHTTPError) t.true(error.stack !== undefined) @@ -511,7 +504,7 @@ test('Does not retry on server errors', async (t) => { const error: any = await t.throwsAsync(client.getAccount({ account_id: accountId })) t.is(error.status, 500) - t.is(error.message, errorMessage) + t.is(error.data, errorMessage) t.false(scope.isDone()) }) @@ -541,7 +534,7 @@ test('Handles API rate limiting', async (t) => { const expectedResponse = { test: 'test' } const scope = nock(origin) .get(`${pathPrefix}/accounts/${accountId}`) - .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt }) + .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt.toString() }) .get(`${pathPrefix}/accounts/${accountId}`) .reply(200, expectedResponse) @@ -556,9 +549,10 @@ test('Handles API rate limiting', async (t) => { test('Handles API rate limiting when date is in the past', async (t) => { const accountId = uuidv4() const expectedResponse = { test: 'test' } + const retryAt = '0' const scope = nock(origin) .get(`${pathPrefix}/accounts/${accountId}`) - .reply(429, { retryAt: 0 }, { 'X-RateLimit-Reset': 0 }) + .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt.toString() }) .get(`${pathPrefix}/accounts/${accountId}`) .reply(200, expectedResponse) @@ -592,7 +586,7 @@ test('Gives up retrying on API rate limiting after a timeout', async (t) => { const scope = nock(origin) .get(`${pathPrefix}/accounts/${accountId}`) .times(times) - .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt }) + .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt.toString() }) .get(`${pathPrefix}/accounts/${accountId}`) .reply(200, expectedResponse) @@ -600,7 +594,7 @@ test('Gives up retrying on API rate limiting after a timeout', async (t) => { const error: any = await t.throwsAsync(client.getAccount({ account_id: accountId })) t.is(error.status, 429) - t.is(error.message, JSON.stringify({ retryAt })) + t.deepEqual(error.json, { retryAt }) t.true(Number.isInteger(error.json.retryAt)) t.false(scope.isDone()) @@ -612,9 +606,12 @@ errorCodes.forEach((code) => { const accountId = uuidv4() const retryAtMs = Date.now() + TEST_RATE_LIMIT_DELAY const expectedResponse = { test: 'test' } + const error = new Error('Error Response') as NodeJS.ErrnoException + error.code = code + const scope = nock(origin) .get(`${pathPrefix}/accounts/${accountId}`) - .replyWithError({ code }) + .replyWithError(error) .get(`${pathPrefix}/accounts/${accountId}`) .reply(200, expectedResponse) @@ -636,39 +633,21 @@ test('Recreates a function body when handling API rate limiting', async (t) => { const expectedResponse = { test: 'test' } const scope = nock(origin) .put(`${pathPrefix}/deploys/${deployId}/files/${path}`, body, { 'Content-Type': 'application/octet-stream' } as any) - .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt }) + .reply(429, { retryAt }, { 'X-RateLimit-Reset': retryAt.toString() }) .put(`${pathPrefix}/deploys/${deployId}/files/${path}`, body, { 'Content-Type': 'application/octet-stream' } as any) .reply(200, expectedResponse) const client: any = getClient() - const response = await client.uploadDeployFile({ deploy_id: deployId, path, body: () => fromString(body) }) + const response = await client.uploadDeployFile({ + deploy_id: deployId, + path, + body: () => Readable.from(body), + duplex: 'half', + }) t.true(Date.now() >= retryAtMs) t.deepEqual(response, expectedResponse) t.true(scope.isDone()) }) -test('Can set (proxy) agent', (t) => { - const client: any = getClient({ accessToken: testAccessToken, agent }) - t.is(client.agent, agent) -}) - -test('(Proxy) agent is passed as request option', async (t) => { - const accountId = uuidv4() - const scope = nock(origin).get(`${pathPrefix}/accounts/${accountId}`).reply(200) - - const client: any = getClient({ accessToken: testAccessToken, agent }) - await client.getAccount({ account_id: accountId }) - t.is((scope as any).interceptors[0].req.options.agent, agent) -}) - -test('(Proxy) agent is not passed as request option if not set', async (t) => { - const accountId = uuidv4() - const scope = nock(origin).get(`${pathPrefix}/accounts/${accountId}`).reply(200) - - const client: any = getClient({ accessToken: testAccessToken }) - await client.getAccount({ account_id: accountId }) - t.falsy((scope as any).interceptors[0].req.options.agent) -}) - const TEST_RATE_LIMIT_DELAY = 5e3 const SECS_TO_MSECS = 1e3 diff --git a/packages/js-client/src/index.ts b/packages/js-client/src/index.ts index 189267fa49..1c39b99164 100644 --- a/packages/js-client/src/index.ts +++ b/packages/js-client/src/index.ts @@ -76,7 +76,6 @@ export class NetlifyAPI { const methods = getMethods({ basePath: this.basePath, defaultHeaders: this.defaultHeaders, - agent: this.agent, globalParams: this.globalParams, }) Object.assign(this, { ...methods }) diff --git a/packages/js-client/src/methods/index.js b/packages/js-client/src/methods/index.js index d78df9a09a..325e5b5b9b 100644 --- a/packages/js-client/src/methods/index.js +++ b/packages/js-client/src/methods/index.js @@ -1,5 +1,3 @@ -import fetch from 'node-fetch' - import { getOperations } from '../operations.js' import { addBody } from './body.js' @@ -10,36 +8,36 @@ import { getUrl } from './url.js' // For each OpenAPI operation, add a corresponding method. // The `operationId` is the method name. -export const getMethods = function ({ basePath, defaultHeaders, agent, globalParams }) { +export const getMethods = function ({ basePath, defaultHeaders, globalParams }) { const operations = getOperations() - const methods = operations.map((method) => getMethod({ method, basePath, defaultHeaders, agent, globalParams })) + const methods = operations.map((method) => getMethod({ method, basePath, defaultHeaders, globalParams })) return Object.assign({}, ...methods) } -const getMethod = function ({ method, basePath, defaultHeaders, agent, globalParams }) { +const getMethod = function ({ method, basePath, defaultHeaders, globalParams }) { return { [method.operationId](params, opts) { - return callMethod({ method, basePath, defaultHeaders, agent, globalParams, params, opts }) + return callMethod({ method, basePath, defaultHeaders, globalParams, params, opts }) }, } } -const callMethod = async function ({ method, basePath, defaultHeaders, agent, globalParams, params, opts }) { +const callMethod = async function ({ method, basePath, defaultHeaders, globalParams, params, opts }) { const requestParams = { ...globalParams, ...params } const url = getUrl(method, basePath, requestParams) - const response = await makeRequestOrRetry({ url, method, defaultHeaders, agent, requestParams, opts }) + const response = await makeRequestOrRetry({ url, method, defaultHeaders, requestParams, opts }) const parsedResponse = await parseResponse(response) return parsedResponse } -const getOpts = function ({ method: { verb, parameters }, defaultHeaders, agent, requestParams, opts }) { - const { body } = requestParams +const getOpts = function ({ method: { verb, parameters }, defaultHeaders, requestParams, opts }) { + const { body, duplex } = requestParams const optsA = addHttpMethod(verb, opts) const optsB = addHeaderParams(parameters, requestParams, optsA) const optsC = addDefaultHeaders(defaultHeaders, optsB) const optsD = addBody(body, parameters, optsC) - const optsE = addAgent(agent, optsD) + const optsE = addDuplex(duplex, optsD) return optsE } @@ -62,18 +60,19 @@ const addDefaultHeaders = function (defaultHeaders, opts) { return { ...opts, headers: { ...defaultHeaders, ...opts.headers } } } -// Assign fetch agent (like for example HttpsProxyAgent) if there is one -const addAgent = function (agent, opts) { - if (agent) { - return { ...opts, agent } +// Set duplex value +const addDuplex = function (duplex, opts) { + if (duplex === undefined) { + return opts } - return opts + + return { ...opts, duplex } } -const makeRequestOrRetry = async function ({ url, method, defaultHeaders, agent, requestParams, opts }) { +const makeRequestOrRetry = async function ({ url, method, defaultHeaders, requestParams, opts }) { // Using a loop is simpler here for (let index = 0; index <= MAX_RETRY; index++) { - const optsA = getOpts({ method, defaultHeaders, agent, requestParams, opts }) + const optsA = getOpts({ method, defaultHeaders, requestParams, opts }) const { response, error } = await makeRequest(url, optsA) if (shouldRetry({ response, error, method }) && index !== MAX_RETRY) { diff --git a/packages/js-client/src/methods/response.js b/packages/js-client/src/methods/response.js index 5316c46aa0..1de50f5637 100644 --- a/packages/js-client/src/methods/response.js +++ b/packages/js-client/src/methods/response.js @@ -1,7 +1,9 @@ -import { JSONHTTPError, TextHTTPError } from 'micro-api-client' - import omit from '../omit.js' +class TextHTTPError extends Error {} + +class JSONHTTPError extends Error {} + // Read and parse the HTTP response export const parseResponse = async function (response) { const responseType = getResponseType(response) diff --git a/packages/js-client/src/types.ts b/packages/js-client/src/types.ts index 8a12521a41..6967709b41 100644 --- a/packages/js-client/src/types.ts +++ b/packages/js-client/src/types.ts @@ -1,7 +1,6 @@ import type { ReadStream } from 'node:fs' import type { operations } from '@netlify/open-api' -import type { RequestInit } from 'node-fetch' /** * Determines whether all keys in T are optional. @@ -206,7 +205,7 @@ export type DynamicMethods = { [K in keyof operations]: ( params: OperationParams, /** - * Any properties you want passed to `node-fetch`. + * Any properties you want passed to `fetch`. * * The `headers` property is merged with some `defaultHeaders`: * ```ts