Skip to content

Commit eb27950

Browse files
committed
few todos fixed
1 parent 15c4ea4 commit eb27950

File tree

6 files changed

+13
-67
lines changed

6 files changed

+13
-67
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jira.js",
3-
"version": "5.2.2",
3+
"version": "6.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",
66
"homepage": "https://mrrefactoring.github.io/jira.js",

src/clients/baseClient.ts

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ export class BaseClient extends Client {
8282

8383
const { body, contentType } = this.prepareBodyPayload(request);
8484

85-
// console.log('content-type', contentType);
86-
8785
const config: RequestInit = {
8886
method: request.method,
8987
headers: this.removeUndefinedProperties({
@@ -98,9 +96,6 @@ export class BaseClient extends Client {
9896
body,
9997
};
10098

101-
// console.log(url.toString());
102-
// console.log(config);
103-
10499
const response = await fetch(url, config);
105100

106101
if (!response.ok) {
@@ -116,63 +111,16 @@ export class BaseClient extends Client {
116111
if (contentType.includes('application/json')) {
117112
const json = await response.json();
118113

119-
throw new Error(JSON.stringify(json));
114+
throw new Error(JSON.stringify(json)); // todo error handling
120115
}
121116

122117
const errorMessage = await response.text();
123118

124-
console.error(response.status);
125-
console.error(response.statusText);
126-
127119
throw new Error(errorMessage);
128120
}
129121

130-
// handleSuccessResponse<T>(response: any): T {
131-
// this.config.middlewares?.onResponse?.(response.data);
132-
//
133-
// return response;
134-
// }
135-
//
136-
// handleFailedResponse(e: unknown): JiraError {
137-
// const err = this.buildErrorHandlingResponse(e);
138-
//
139-
// this.config.middlewares?.onError?.(err);
140-
//
141-
// return err;
142-
// }
143-
//
144-
// private buildErrorHandlingResponse(e: unknown): JiraError {
145-
// if (axios.isAxiosError(e) && e.response) {
146-
// return new HttpException(
147-
// {
148-
// code: e.code,
149-
// message: e.message,
150-
// data: e.response.data,
151-
// status: e.response.status,
152-
// statusText: e.response.statusText,
153-
// },
154-
// e.response.status,
155-
// { cause: e },
156-
// );
157-
// }
158-
//
159-
// if (axios.isAxiosError(e)) {
160-
// return e;
161-
// }
162-
//
163-
// if (isObject(e) && isObject((e as Record<string, any>).response)) {
164-
// return new HttpException((e as Record<string, any>).response);
165-
// }
166-
//
167-
// if (e instanceof Error) {
168-
// return new HttpException(e);
169-
// }
170-
//
171-
// return new HttpException('Unknown error occurred.', 500, { cause: e });
172-
// }
173-
174-
private prepareBodyPayload(request: Request) {
175-
let body: string | Blob | FormData | ArrayBuffer | undefined = request.body;
122+
private prepareBodyPayload(request: Request): { body: BodyInit | null | undefined; contentType: string | undefined } {
123+
let body: BodyInit | object | undefined | null = request.body;
176124
let contentType: string | undefined = request.headers?.['Content-Type'] ?? request.headers?.['content-type'];
177125

178126
if (request.body instanceof FormData) {
@@ -189,14 +137,11 @@ export class BaseClient extends Client {
189137
} else if (typeof request.body === 'string') {
190138
body = request.body;
191139
contentType = 'text/plain';
192-
} else if (request.body instanceof URLSearchParams) {
193-
body = request.body.toString();
194-
contentType = 'application/x-www-form-urlencoded';
195140
}
196141

197142
return {
198143
body,
199144
contentType,
200-
};
145+
} as { body: BodyInit | null | undefined; contentType: string };
201146
}
202147
}

src/paramSerializer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export function paramSerializer(key: string, values?: string | string[] | number
77
return undefined;
88
}
99

10-
return () => values.map(value => `${key}=${value}`).join('&');
10+
return values.map(value => `${key}=${value}`).join('&');
1111
}

src/request.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
1+
import type { OneOrMany } from './interfaces';
2+
23
export type Request = {
34
url: string;
45
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
5-
body?: any; // todo
6-
query?: any; // todo
7-
headers?: any; // todo
6+
body?: BodyInit | null | undefined | object;
7+
query?: Record<string, OneOrMany<string | number | boolean | unknown | null | undefined>>;
8+
headers?: Record<string, string>;
89
};

src/version2/issueAttachments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class IssueAttachments {
2929
* - If attachments are added in private comments, the comment-level restriction will be applied.
3030
*/
3131
async getAttachmentContent<T = Models.AttachmentContent>(parameters: Parameters.GetAttachmentContent): Promise<T> {
32-
// todo add Range header
32+
// todo #396 add Range header - https://github.com/MrRefactoring/jira.js/issues/396
3333
const config: Request = {
3434
url: `/rest/api/2/attachment/content/${parameters.id}`,
3535
method: 'GET',

src/version3/issueAttachments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class IssueAttachments {
2929
* - If attachments are added in private comments, the comment-level restriction will be applied.
3030
*/
3131
async getAttachmentContent<T = Models.AttachmentContent>(parameters: Parameters.GetAttachmentContent): Promise<T> {
32-
// todo add Range header
32+
// todo #396 add Range header - https://github.com/MrRefactoring/jira.js/issues/396
3333
const config: Request = {
3434
url: `/rest/api/3/attachment/content/${parameters.id}`,
3535
method: 'GET',

0 commit comments

Comments
 (0)