Skip to content

Commit 9f3c97a

Browse files
#144 Fixed error when tried vote issue (#145)
* types improvements * types improvements * assign required arguments fixed * assign required arguments fixed * #144 fixed error when tried vote issue * eslint fixed * tests added * issue votes type fixed * integration to e2e rename * tests fixed
1 parent 77af1a8 commit 9f3c97a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+331
-134
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Jira.js changelog
22

3+
### 2.4.2
4+
5+
- [#144](https://github.com/MrRefactoring/jira.js/issues/144) Fixed error when tried vote issue. Thanks [João Lopes](https://github.com/lopis)!
6+
- A lot of small improvements in types for agile and for project API
7+
38
### 2.4.1
49

510
- A lot of small improvements in types for agile and for project API

package-lock.json

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

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jira.js",
3-
"version": "2.4.1",
3+
"version": "2.4.2",
44
"description": "jira.js is a powerful Node.JS/Browser module that allows you to interact with the Jira API very easily",
55
"main": "out/index.js",
66
"types": "out/index.d.ts",
@@ -31,7 +31,7 @@
3131
"doc": "typedoc --name Jira.js --out docs ./src",
3232
"test": "npm run test:unit && npm run test:e2e",
3333
"test:unit": "jest tests/unit",
34-
"test:e2e": "jest tests/integration --setupFiles=./tests/setup.ts --runInBand",
34+
"test:e2e": "jest tests/e2e --setupFiles=./tests/setup.ts --runInBand",
3535
"test:verbose": "npm run test -- --verbose",
3636
"test:coverage": "npm run test:unit:coverage && npm run test:system:coverage",
3737
"test:unit:coverage": "npm run test:unit -- --coverage",
@@ -42,15 +42,15 @@
4242
"testEnvironment": "node"
4343
},
4444
"devDependencies": {
45-
"@types/express": "^4.17.12",
46-
"@types/jest": "^26.0.23",
47-
"@types/node": "^15.12.5",
45+
"@types/express": "^4.17.13",
46+
"@types/jest": "^26.0.24",
47+
"@types/node": "^16.0.1",
4848
"@types/oauth": "^0.9.1",
4949
"@types/sinon": "^10.0.2",
50-
"@typescript-eslint/eslint-plugin": "^4.28.1",
51-
"@typescript-eslint/parser": "^4.28.1",
50+
"@typescript-eslint/eslint-plugin": "^4.28.2",
51+
"@typescript-eslint/parser": "^4.28.2",
5252
"dotenv": "^10.0.0",
53-
"eslint": "^7.29.0",
53+
"eslint": "^7.30.0",
5454
"eslint-config-airbnb-typescript": "^12.3.1",
5555
"eslint-import-resolver-typescript": "^2.4.0",
5656
"eslint-plugin-import": "^2.23.4",
@@ -60,7 +60,7 @@
6060
"sinon": "^11.1.1",
6161
"ts-jest": "^26.5.6",
6262
"typedoc": "^0.21.2",
63-
"typescript": "^4.3.4"
63+
"typescript": "^4.3.5"
6464
},
6565
"dependencies": {
6666
"atlassian-jwt": "^2.0.1",

src/version2/issueVotes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export class IssueVotes {
8282
const config: RequestConfig = {
8383
url: `/rest/api/2/issue/${parameters.issueIdOrKey}/votes`,
8484
method: 'POST',
85+
headers: {
86+
'Content-Type': 'application/json',
87+
},
8588
};
8689

8790
return this.client.sendRequest(config, callback, { methodName: 'version2.issueVotes.addVote' });

src/version2/models/fields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export interface Fields {
5959
total: number;
6060
startAt: number;
6161
};
62-
votes: Votes;
62+
votes: Votes & { voters: never; };
6363
worklog: {
6464
startAt: number;
6565
maxResults: number;

src/version2/models/issueBean.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export interface IssueBean {
99
/** Expand options that include additional issue details in the response. */
1010
expand?: string;
1111
/** The ID of the issue. */
12-
id?: string;
12+
id: string;
1313
/** The URL of the issue details. */
1414
self?: string;
1515
/** The key of the issue. */
16-
key?: string;
16+
key: string;
1717
/** The rendered value of each field present on the issue. */
1818
renderedFields?: {};
1919
/** Details of the issue properties identified in the request. */

src/version2/models/issueUpdateDetails.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IssueTransition } from './issueTransition';
22
import { HistoryMetadata } from './historyMetadata';
33
import { EntityProperty } from './entityProperty';
4+
import { Fields } from './fields';
45

56
/** Details of an issue update request. */
67
export interface IssueUpdateDetails {
@@ -10,7 +11,7 @@ export interface IssueUpdateDetails {
1011
* provides a straightforward option when setting a sub-field. When multiple sub-fields or other operations are
1112
* required, use `update`. Fields included in here cannot be included in `update`.
1213
*/
13-
fields?: any;
14+
fields?: Partial<Fields> | any;
1415
/** List of operations to perform on issue screen fields. Note that fields included in here cannot be included in `fields`. */
1516
update?: any;
1617
historyMetadata?: HistoryMetadata;

src/version2/models/project.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export interface Project {
1616
/** The URL of the project details. */
1717
self?: string;
1818
/** The ID of the project. */
19-
id?: string;
19+
id: string;
2020
/** The key of the project. */
21-
key?: string;
21+
key: string;
2222
/** A brief description of the project. */
2323
description?: string;
24-
lead?: User;
24+
lead: User;
2525
/** List of the components contained in the project. */
2626
components?: Component[];
2727
/** List of the issue types available in the project. */
@@ -35,7 +35,7 @@ export interface Project {
3535
/** The versions defined in the project. For more information, see [Create version](#api-rest-api-2-version-post). */
3636
versions?: Version[];
3737
/** The name of the project. */
38-
name?: string;
38+
name: string;
3939
/**
4040
* The name and self URL for each role defined in the project. For more information, see [Create project
4141
* role](#api-rest-api-2-role-post).

src/version2/models/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface User {
2525
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
2626
* *5b10ac8d82e05b22cc7d4ef5*. Required in requests.
2727
*/
28-
accountId?: string;
28+
accountId: string;
2929
/**
3030
* The user account type. Can take the following values:
3131
*
@@ -45,7 +45,7 @@ export interface User {
4545
/** The display name of the user. Depending on the user’s privacy setting, this may return an alternative value. */
4646
displayName?: string;
4747
/** Whether the user is active. */
48-
active?: boolean;
48+
active: boolean;
4949
/** The time zone specified in the user's profile. Depending on the user’s privacy setting, this may be returned as null. */
5050
timeZone?: string;
5151
/** The locale of the user. Depending on the user’s privacy setting, this may be returned as null. */

src/version2/models/votes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { User } from './user';
33
/** The details of votes on an issue. */
44
export interface Votes {
55
/** The URL of these issue vote details. */
6-
self?: string;
6+
self: string;
77
/** The number of votes on the issue. */
8-
votes?: number;
8+
votes: number;
99
/** Whether the user making this request has voted on the issue. */
10-
hasVoted?: boolean;
10+
hasVoted: boolean;
1111
/**
1212
* List of the users who have voted on this issue. An empty list is returned when the calling user doesn't have the
1313
* *View voters and watchers* project permission.
1414
*/
15-
voters?: User[];
15+
voters: User[];
1616
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { User } from '../models';
22

3-
export interface AssignIssue extends User {
3+
export interface AssignIssue extends Omit<User, 'accountId' | 'active'> {
44
/** The ID or key of the issue to be assigned. */
55
issueIdOrKey: string;
6+
7+
/**
8+
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
9+
* *5b10ac8d82e05b22cc7d4ef5*. If passed `null` it will unassigned issue.
10+
*/
11+
accountId: string | null;
12+
13+
/** Whether the user is active. */
14+
active?: boolean;
615
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
export interface GetCurrentUser {
22
/**
3-
* Use [expand](#expansion) to include additional information about user in the response. This parameter accepts a
4-
* comma-separated list. Expand options include:
3+
* Use [expand](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#expansion) to include additional
4+
* information about user in the response. Expand options include:
55
*
6-
* `groups` Returns all groups, including nested groups, the user belongs to. `applicationRoles` Returns the
7-
* application roles the user is assigned to.
6+
* - `groups` Returns all groups, including nested groups, the user belongs to.
7+
* - `applicationRoles` Returns the application roles the user is assigned to.
88
*/
9-
expand?: string;
9+
expand?: string | string[] | GetCurrentUser.Expand | GetCurrentUser.Expand[];
10+
}
11+
12+
export namespace GetCurrentUser {
13+
export enum Expand {
14+
Groups = 'groups',
15+
ApplicationRoles = 'applicationRoles',
16+
}
1017
}

src/version2/parameters/getProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface GetProject {
22
/** The project ID or project key (case sensitive). */
3-
projectIdOrKey: string;
3+
projectIdOrKey: string | number;
44
/**
55
* Use [expand](#expansion) to include additional information in the response. This parameter accepts a
66
* comma-separated list. Note that the project description, issue types, and project lead are included in all

src/version3/issueVotes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export class IssueVotes {
8282
const config: RequestConfig = {
8383
url: `/rest/api/3/issue/${parameters.issueIdOrKey}/votes`,
8484
method: 'POST',
85+
headers: {
86+
'Content-Type': 'application/json',
87+
},
8588
};
8689

8790
return this.client.sendRequest(config, callback, { methodName: 'version3.issueVotes.addVote' });

src/version3/models/fields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export interface Fields {
6565
total: number;
6666
startAt: number;
6767
};
68-
votes: Votes;
68+
votes: Votes & { voters: never; };
6969
worklog: {
7070
startAt: number;
7171
maxResults: number;

src/version3/models/issueBean.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ export interface IssueBean {
99
/** Expand options that include additional issue details in the response. */
1010
expand?: string;
1111
/** The ID of the issue. */
12-
id?: string;
12+
id: string;
1313
/** The URL of the issue details. */
1414
self?: string;
1515
/** The key of the issue. */
16-
key?: string;
16+
key: string;
1717
/** The rendered value of each field present on the issue. */
1818
renderedFields?: {};
1919
/** Details of the issue properties identified in the request. */

src/version3/models/issueUpdateDetails.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IssueTransition } from './issueTransition';
22
import { HistoryMetadata } from './historyMetadata';
33
import { EntityProperty } from './entityProperty';
4+
import { Fields } from './fields';
45

56
/** Details of an issue update request. */
67
export interface IssueUpdateDetails {
@@ -10,7 +11,7 @@ export interface IssueUpdateDetails {
1011
* provides a straightforward option when setting a sub-field. When multiple sub-fields or other operations are
1112
* required, use `update`. Fields included in here cannot be included in `update`.
1213
*/
13-
fields?: {};
14+
fields?: Partial<Fields> | any;
1415
/** List of operations to perform on issue screen fields. Note that fields included in here cannot be included in `fields`. */
1516
update?: {};
1617
historyMetadata?: HistoryMetadata;

src/version3/models/user.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface User {
2525
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
2626
* *5b10ac8d82e05b22cc7d4ef5*. Required in requests.
2727
*/
28-
accountId?: string;
28+
accountId: string;
2929
/**
3030
* The user account type. Can take the following values:
3131
*
@@ -45,7 +45,7 @@ export interface User {
4545
/** The display name of the user. Depending on the user’s privacy setting, this may return an alternative value. */
4646
displayName?: string;
4747
/** Whether the user is active. */
48-
active?: boolean;
48+
active: boolean;
4949
/** The time zone specified in the user's profile. Depending on the user’s privacy setting, this may be returned as null. */
5050
timeZone?: string;
5151
/** The locale of the user. Depending on the user’s privacy setting, this may be returned as null. */

src/version3/models/votes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { User } from './user';
33
/** The details of votes on an issue. */
44
export interface Votes {
55
/** The URL of these issue vote details. */
6-
self?: string;
6+
self: string;
77
/** The number of votes on the issue. */
8-
votes?: number;
8+
votes: number;
99
/** Whether the user making this request has voted on the issue. */
10-
hasVoted?: boolean;
10+
hasVoted: boolean;
1111
/**
1212
* List of the users who have voted on this issue. An empty list is returned when the calling user doesn't have the
1313
* *View voters and watchers* project permission.
1414
*/
15-
voters?: User[];
15+
voters: User[];
1616
}
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import { User } from '../models';
22

3-
export interface AssignIssue extends User {
3+
export interface AssignIssue extends Omit<User, 'accountId' | 'active'> {
44
/** The ID or key of the issue to be assigned. */
55
issueIdOrKey: string;
6+
7+
/**
8+
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
9+
* *5b10ac8d82e05b22cc7d4ef5*. If passed `null` it will unassigned issue.
10+
*/
11+
accountId: string | null;
12+
13+
/** Whether the user is active. */
14+
active?: boolean;
615
}
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
export interface GetCurrentUser {
22
/**
3-
* Use [expand](#expansion) to include additional information about user in the response. This parameter accepts a
4-
* comma-separated list. Expand options include:
3+
* Use [expand](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#expansion) to include additional
4+
* information about user in the response. Expand options include:
55
*
6-
* `groups` Returns all groups, including nested groups, the user belongs to. `applicationRoles` Returns the
7-
* application roles the user is assigned to.
6+
* - `groups` Returns all groups, including nested groups, the user belongs to.
7+
* - `applicationRoles` Returns the application roles the user is assigned to.
88
*/
9-
expand?: string;
9+
expand?: string | string[] | GetCurrentUser.Expand | GetCurrentUser.Expand[];
10+
}
11+
12+
export namespace GetCurrentUser {
13+
export enum Expand {
14+
Groups = 'groups',
15+
ApplicationRoles = 'applicationRoles',
16+
}
1017
}

src/version3/parameters/getProject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Project } from '../models';
22

33
export interface GetProject {
44
/** The project ID or project key (case sensitive). */
5-
projectIdOrKey: string;
5+
projectIdOrKey: string | number;
66
/**
77
* Use [expand](#expansion) to include additional information in the response. This parameter accepts a
88
* comma-separated list. Note that the project description, issue types, and project lead are included in all

tests/integration/constants.ts renamed to tests/e2e/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export namespace Constants {
22
export const testTimeouts = 60_000;
3-
export const testProjectKey = 'AUTOTEST';
4-
export const testProjectName = 'Jira.js project for lib automatic tests';
3+
export const testProjectKey = 'AUTOTEST1';
4+
export const testProjectName = 'Jira.js project for lib automatic1 tests';
55
export const testGroupName = 'Automated tests group name';
66
export const testDashboardName = 'Automated dashboard name';
77
export const testIssueSummary = 'Test issue summary';
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/integration/version2/issueAttachments.test.ts renamed to tests/e2e/version2/issueAttachments.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('IssueAttachments', () => {
3737
issueIdOrKey: issue.key,
3838
attachment: {
3939
filename: 'issueAttachments.test.ts',
40-
file: fs.readFileSync('./tests/integration/version2/issueAttachments.test.ts'),
40+
file: fs.readFileSync('./tests/e2e/version2/issueAttachments.test.ts'),
4141
},
4242
});
4343

0 commit comments

Comments
 (0)