Skip to content

Commit 411d083

Browse files
committed
Using builtin formdata (nodejs + browsers)
1 parent a41d208 commit 411d083

File tree

12 files changed

+15
-44
lines changed

12 files changed

+15
-44
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ coverage
66
.idea
77
examples
88

9-
.eslintrc
9+
eslint.config.js
1010
.editorconfig
1111
.DS_Store
1212
pnpm-lock.yaml

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "5.0.0",
44
"description": "A comprehensive JavaScript/TypeScript library designed for both Node.JS and browsers, facilitating seamless interaction with the Atlassian Jira API.",
55
"repository": "https://github.com/MrRefactoring/jira.js.git",
6+
"homepage": "https://mrrefactoring.github.io/jira.js",
67
"author": "Vladislav Tupikin <[email protected]>",
78
"license": "MIT",
89
"type": "module",
@@ -35,11 +36,9 @@
3536
"main": "./dist/index.js",
3637
"types": "./dist/index.d.ts",
3738
"exports": {
38-
"node": {
39-
"types": "./dist/index.d.ts",
40-
"import": "./dist/index.esm.js",
41-
"require": "./dist/index.cjs.js"
42-
}
39+
"types": "./dist/index.d.ts",
40+
"import": "./dist/index.esm.js",
41+
"require": "./dist/index.cjs.js"
4342
},
4443
"scripts": {
4544
"build": "pnpm run build:src && pnpm run build:tests",
@@ -83,7 +82,6 @@
8382
},
8483
"dependencies": {
8584
"axios": "^1.9.0",
86-
"formdata-node": "^6.0.3",
8785
"mime": "^4.0.7",
8886
"zod": "^3.24.3"
8987
},

pnpm-lock.yaml

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rollup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ export default defineConfig({
3535
commonjs(),
3636
typescript({ tsconfig: './tsconfig.json' }),
3737
],
38-
external, // todo build for browsers
38+
external,
3939
});

src/createClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export enum ClientType {
1515
export function createClient(clientType: ClientType.Agile, config: Config): AgileClient;
1616
export function createClient(clientType: ClientType.Version2, config: Config): Version2Client;
1717
export function createClient(clientType: ClientType.Version3, config: Config): Version3Client;
18+
export function createClient(clientType: ClientType.ServiceDesk, config: Config): ServiceDeskClient;
1819
export function createClient(clientType: ClientType, config: Config): BaseClient {
1920
switch (clientType) {
2021
case ClientType.Agile:

src/serviceDesk/serviceDesk.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { FormData, File } from 'formdata-node';
2-
import type { Mime } from 'mime' with { 'resolution-mode': 'import' };
1+
import mime, { Mime } from 'mime';
32
import * as Models from './models';
43
import * as Parameters from './parameters';
54
import { Callback } from '../callback';
@@ -117,8 +116,6 @@ export class ServiceDesk {
117116
const formData = new FormData();
118117
const attachments = Array.isArray(parameters.attachment) ? parameters.attachment : [parameters.attachment];
119118

120-
const { default: mime } = await import('mime');
121-
122119
let Readable: typeof import('stream').Readable | undefined;
123120

124121
if (typeof window === 'undefined') {

src/version2/issueAttachments.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { FormData, File } from 'formdata-node';
2-
import type { Mime } from 'mime' with { 'resolution-mode': 'import' };
1+
import mime, { Mime } from 'mime';
32
import * as Models from './models';
43
import * as Parameters from './parameters';
54
import { Client } from '../clients';
@@ -414,8 +413,6 @@ export class IssueAttachments {
414413
const formData = new FormData();
415414
const attachments = Array.isArray(parameters.attachment) ? parameters.attachment : [parameters.attachment];
416415

417-
const { default: mime } = await import('mime');
418-
419416
let Readable: typeof import('stream').Readable | undefined;
420417

421418
if (typeof window === 'undefined') {

src/version3/issueAttachments.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { FormData, File } from 'formdata-node';
2-
import type { Mime } from 'mime' with { 'resolution-mode': 'import' };
1+
import mime, { Mime } from 'mime';
32
import * as Models from './models';
43
import * as Parameters from './parameters';
54
import { Client } from '../clients';
@@ -436,8 +435,6 @@ export class IssueAttachments {
436435
const formData = new FormData();
437436
const attachments = Array.isArray(parameters.attachment) ? parameters.attachment : [parameters.attachment];
438437

439-
const { default: mime } = await import('mime');
440-
441438
let Readable: typeof import('stream').Readable | undefined;
442439

443440
if (typeof window === 'undefined') {

tests/integration/utils/createSoftwareProject.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const createSoftwareProject = async () => {
99
if (!currentUser.accountId) {
1010
throw new Error(
1111
"Couldn't get the current user's account ID",
12-
// @ts-expect-error -- Requires to use lib ES2022+ in tsconfig to use "cause"
1312
{ cause: { currentUser } },
1413
);
1514
}

tests/unit/createClient.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test('should create ServiceDesk client', ({ expect }) => {
3939
});
4040

4141
test('should create Base client', ({ expect }) => {
42+
// @ts-expect-error Internal typings
4243
const client = createClient('baseClient', defaultConfig);
4344

4445
expect(!!client).toBeTruthy();

0 commit comments

Comments
 (0)