Skip to content

Commit c25cf68

Browse files
committed
code formatting and fixes
1 parent de9c851 commit c25cf68

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

src/services/formDataService/formDataService.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class FormDataService {
4545

4646
this.formData.append('file', file);
4747
} else {
48-
throw new Error('Invalid value'); // todo
48+
throw new Error('Invalid value'); // todo error handling
4949
}
5050
}
5151

@@ -66,8 +66,6 @@ export class FormDataService {
6666
totalSize += value.size;
6767
} else if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {
6868
totalSize += value.byteLength;
69-
} else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
70-
totalSize += value.length;
7169
} else if (value === null || value === undefined) {
7270
continue;
7371
} else {

src/version2/issueAttachments.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type * as Models from './models';
22
import type * as Parameters from './parameters';
33
import type { Client } from '../clients';
44
import type { Callback } from '../callback';
5-
import type { Request } from '../requestConfig';
5+
import type { Request } from '../request';
66
import { FormDataService } from '../services/formDataService';
77

88
export class IssueAttachments {
@@ -380,10 +380,7 @@ export class IssueAttachments {
380380
* to view the issue.
381381
*/
382382
async addAttachment<T = Models.Attachment[]>(parameters: Parameters.AddAttachment, callback?: never): Promise<T>;
383-
async addAttachment<T = Models.Attachment[]>(
384-
parameters: Parameters.AddAttachment,
385-
callback?: Callback<T>,
386-
): Promise<void | T> {
383+
async addAttachment<T = Models.Attachment[]>(parameters: Parameters.AddAttachment): Promise<void | T> {
387384
const formDataService = new FormDataService();
388385
const attachments = Array.isArray(parameters.attachment) ? parameters.attachment : [parameters.attachment];
389386

@@ -396,18 +393,18 @@ export class IssueAttachments {
396393
),
397394
);
398395

399-
const config: RequestConfig = {
396+
const config: Request = {
400397
url: `/rest/api/2/issue/${parameters.issueIdOrKey}/attachments`,
401398
method: 'POST',
402399
headers: {
403400
'X-Atlassian-Token': 'no-check',
404401
'Content-Type': 'multipart/form-data',
405402
},
406-
data: formDataService.formData,
407-
maxBodyLength: Infinity,
408-
maxContentLength: Infinity,
403+
body: formDataService.formData,
404+
// maxBodyLength: Infinity, // todo needed?
405+
// maxContentLength: Infinity, // todo needed?
409406
};
410407

411-
return this.client.sendRequest(config, callback);
408+
return this.client.sendRequest(config);
412409
}
413410
}

tests/integration/version2/issueAttachments.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from 'node:fs';
22
import { open } from 'node:fs/promises';
3-
import { afterAll, beforeAll, describe, test, it } from 'vitest';
3+
import { afterAll, beforeAll, describe, test, it, expect } from 'vitest';
44
import type { Attachment, Issue } from '@jirajs/version2/models';
55
import { Constants } from '@tests/integration/constants';
66
import { cleanupEnvironment, getVersion2Client, prepareEnvironment } from '@tests/integration/utils';

0 commit comments

Comments
 (0)