From a650eb19b2792d3156e2fd7014b079d4021cb2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Kroupa?= Date: Thu, 2 Jan 2025 03:24:13 +0100 Subject: [PATCH] Swap form-data for formdata-node (#333) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The newer library better supports modules and is written in TypeScript. The FormData interface is a drop-in replacement except for getHeaders(), but that didn't do anything useful, so it can be dropped. Closes #327 Signed-off-by: Matyáš Kroupa Co-authored-by: Matyáš Kroupa Co-authored-by: Vladislav Tupikin --- package-lock.json | 9 +++++++++ package.json | 6 +++--- src/serviceDesk/serviceDesk.ts | 3 +-- src/version2/issueAttachments.ts | 4 +--- src/version3/issueAttachments.ts | 4 +--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 35e16de8a2..74a9018b79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2877,6 +2877,15 @@ "node": ">= 6" } }, + "node_modules/formdata-node": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-6.0.3.tgz", + "integrity": "sha512-8e1++BCiTzUno9v5IZ2J6bv4RU+3UKDmqWUQD0MIMVCd9AdhWkO1gw57oo1mNEX1dMq2EGI+FbWz4B92pscSQg==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", diff --git a/package.json b/package.json index cce81d7b5f..0dec96d41f 100644 --- a/package.json +++ b/package.json @@ -71,8 +71,8 @@ "vitest": "^2.1.8" }, "dependencies": { - "axios": "^1.7.9", - "form-data": "^4.0.1", - "tslib": "^2.8.1" + "axios": "^1.7.7", + "formdata-node": "^6.0.3", + "tslib": "^2.7.0" } } diff --git a/src/serviceDesk/serviceDesk.ts b/src/serviceDesk/serviceDesk.ts index 9437d6b2b3..ec3d824f12 100644 --- a/src/serviceDesk/serviceDesk.ts +++ b/src/serviceDesk/serviceDesk.ts @@ -1,4 +1,4 @@ -import * as FormData from 'form-data'; +import { FormData } from 'formdata-node'; import * as Models from './models'; import * as Parameters from './parameters'; import { Callback } from '../callback'; @@ -124,7 +124,6 @@ export class ServiceDesk { headers: { 'X-Atlassian-Token': 'no-check', 'Content-Type': 'multipart/form-data', - ...formData.getHeaders?.(), }, data: formData, }; diff --git a/src/version2/issueAttachments.ts b/src/version2/issueAttachments.ts index c1961e3af4..33bad5b823 100644 --- a/src/version2/issueAttachments.ts +++ b/src/version2/issueAttachments.ts @@ -1,5 +1,4 @@ -// @ts-expect-error Wrong form data typings -import FormData from 'form-data'; +import { FormData } from 'formdata-node'; import * as Models from './models'; import * as Parameters from './parameters'; import { Callback } from '../callback'; @@ -434,7 +433,6 @@ export class IssueAttachments { headers: { 'X-Atlassian-Token': 'no-check', 'Content-Type': 'multipart/form-data', - ...formData.getHeaders?.(), }, data: formData, maxBodyLength: Infinity, diff --git a/src/version3/issueAttachments.ts b/src/version3/issueAttachments.ts index cbae4311fa..b134f7a4f0 100644 --- a/src/version3/issueAttachments.ts +++ b/src/version3/issueAttachments.ts @@ -1,5 +1,4 @@ -// @ts-expect-error Wrong form data typings -import FormData from 'form-data'; +import { FormData } from 'formdata-node'; import * as Models from './models'; import * as Parameters from './parameters'; import { Callback } from '../callback'; @@ -434,7 +433,6 @@ export class IssueAttachments { headers: { 'X-Atlassian-Token': 'no-check', 'Content-Type': 'multipart/form-data', - ...formData.getHeaders?.(), }, data: formData, maxBodyLength: Infinity,