Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#144 Fixed error when tried vote issue #145

Merged
merged 10 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Jira.js changelog

### 2.4.2

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

### 2.4.1

- A lot of small improvements in types for agile and for project API
Expand Down
184 changes: 101 additions & 83 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jira.js",
"version": "2.4.1",
"version": "2.4.2",
"description": "jira.js is a powerful Node.JS/Browser module that allows you to interact with the Jira API very easily",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down Expand Up @@ -31,7 +31,7 @@
"doc": "typedoc --name Jira.js --out docs ./src",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "jest tests/unit",
"test:e2e": "jest tests/integration --setupFiles=./tests/setup.ts --runInBand",
"test:e2e": "jest tests/e2e --setupFiles=./tests/setup.ts --runInBand",
"test:verbose": "npm run test -- --verbose",
"test:coverage": "npm run test:unit:coverage && npm run test:system:coverage",
"test:unit:coverage": "npm run test:unit -- --coverage",
Expand All @@ -42,15 +42,15 @@
"testEnvironment": "node"
},
"devDependencies": {
"@types/express": "^4.17.12",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.5",
"@types/express": "^4.17.13",
"@types/jest": "^26.0.24",
"@types/node": "^16.0.1",
"@types/oauth": "^0.9.1",
"@types/sinon": "^10.0.2",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"dotenv": "^10.0.0",
"eslint": "^7.29.0",
"eslint": "^7.30.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.4",
Expand All @@ -60,7 +60,7 @@
"sinon": "^11.1.1",
"ts-jest": "^26.5.6",
"typedoc": "^0.21.2",
"typescript": "^4.3.4"
"typescript": "^4.3.5"
},
"dependencies": {
"atlassian-jwt": "^2.0.1",
Expand Down
3 changes: 3 additions & 0 deletions src/version2/issueVotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class IssueVotes {
const config: RequestConfig = {
url: `/rest/api/2/issue/${parameters.issueIdOrKey}/votes`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};

return this.client.sendRequest(config, callback, { methodName: 'version2.issueVotes.addVote' });
Expand Down
2 changes: 1 addition & 1 deletion src/version2/models/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export interface Fields {
total: number;
startAt: number;
};
votes: Votes;
votes: Votes & { voters: never; };
worklog: {
startAt: number;
maxResults: number;
Expand Down
4 changes: 2 additions & 2 deletions src/version2/models/issueBean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export interface IssueBean {
/** Expand options that include additional issue details in the response. */
expand?: string;
/** The ID of the issue. */
id?: string;
id: string;
/** The URL of the issue details. */
self?: string;
/** The key of the issue. */
key?: string;
key: string;
/** The rendered value of each field present on the issue. */
renderedFields?: {};
/** Details of the issue properties identified in the request. */
Expand Down
3 changes: 2 additions & 1 deletion src/version2/models/issueUpdateDetails.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IssueTransition } from './issueTransition';
import { HistoryMetadata } from './historyMetadata';
import { EntityProperty } from './entityProperty';
import { Fields } from './fields';

/** Details of an issue update request. */
export interface IssueUpdateDetails {
Expand All @@ -10,7 +11,7 @@ export interface IssueUpdateDetails {
* provides a straightforward option when setting a sub-field. When multiple sub-fields or other operations are
* required, use `update`. Fields included in here cannot be included in `update`.
*/
fields?: any;
fields?: Partial<Fields> | any;
/** List of operations to perform on issue screen fields. Note that fields included in here cannot be included in `fields`. */
update?: any;
historyMetadata?: HistoryMetadata;
Expand Down
8 changes: 4 additions & 4 deletions src/version2/models/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export interface Project {
/** The URL of the project details. */
self?: string;
/** The ID of the project. */
id?: string;
id: string;
/** The key of the project. */
key?: string;
key: string;
/** A brief description of the project. */
description?: string;
lead?: User;
lead: User;
/** List of the components contained in the project. */
components?: Component[];
/** List of the issue types available in the project. */
Expand All @@ -35,7 +35,7 @@ export interface Project {
/** The versions defined in the project. For more information, see [Create version](#api-rest-api-2-version-post). */
versions?: Version[];
/** The name of the project. */
name?: string;
name: string;
/**
* The name and self URL for each role defined in the project. For more information, see [Create project
* role](#api-rest-api-2-role-post).
Expand Down
4 changes: 2 additions & 2 deletions src/version2/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface User {
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
* *5b10ac8d82e05b22cc7d4ef5*. Required in requests.
*/
accountId?: string;
accountId: string;
/**
* The user account type. Can take the following values:
*
Expand All @@ -45,7 +45,7 @@ export interface User {
/** The display name of the user. Depending on the user’s privacy setting, this may return an alternative value. */
displayName?: string;
/** Whether the user is active. */
active?: boolean;
active: boolean;
/** The time zone specified in the user's profile. Depending on the user’s privacy setting, this may be returned as null. */
timeZone?: string;
/** The locale of the user. Depending on the user’s privacy setting, this may be returned as null. */
Expand Down
8 changes: 4 additions & 4 deletions src/version2/models/votes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { User } from './user';
/** The details of votes on an issue. */
export interface Votes {
/** The URL of these issue vote details. */
self?: string;
self: string;
/** The number of votes on the issue. */
votes?: number;
votes: number;
/** Whether the user making this request has voted on the issue. */
hasVoted?: boolean;
hasVoted: boolean;
/**
* List of the users who have voted on this issue. An empty list is returned when the calling user doesn't have the
* *View voters and watchers* project permission.
*/
voters?: User[];
voters: User[];
}
11 changes: 10 additions & 1 deletion src/version2/parameters/assignIssue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { User } from '../models';

export interface AssignIssue extends User {
export interface AssignIssue extends Omit<User, 'accountId' | 'active'> {
/** The ID or key of the issue to be assigned. */
issueIdOrKey: string;

/**
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
* *5b10ac8d82e05b22cc7d4ef5*. If passed `null` it will unassigned issue.
*/
accountId: string | null;

/** Whether the user is active. */
active?: boolean;
}
17 changes: 12 additions & 5 deletions src/version2/parameters/getCurrentUser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
export interface GetCurrentUser {
/**
* Use [expand](#expansion) to include additional information about user in the response. This parameter accepts a
* comma-separated list. Expand options include:
* Use [expand](https://developer.atlassian.com/cloud/jira/platform/rest/v2/intro/#expansion) to include additional
* information about user in the response. Expand options include:
*
* `groups` Returns all groups, including nested groups, the user belongs to. `applicationRoles` Returns the
* application roles the user is assigned to.
* - `groups` Returns all groups, including nested groups, the user belongs to.
* - `applicationRoles` Returns the application roles the user is assigned to.
*/
expand?: string;
expand?: string | string[] | GetCurrentUser.Expand | GetCurrentUser.Expand[];
}

export namespace GetCurrentUser {
export enum Expand {
Groups = 'groups',
ApplicationRoles = 'applicationRoles',
}
}
2 changes: 1 addition & 1 deletion src/version2/parameters/getProject.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface GetProject {
/** The project ID or project key (case sensitive). */
projectIdOrKey: string;
projectIdOrKey: string | number;
/**
* Use [expand](#expansion) to include additional information in the response. This parameter accepts a
* comma-separated list. Note that the project description, issue types, and project lead are included in all
Expand Down
3 changes: 3 additions & 0 deletions src/version3/issueVotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class IssueVotes {
const config: RequestConfig = {
url: `/rest/api/3/issue/${parameters.issueIdOrKey}/votes`,
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};

return this.client.sendRequest(config, callback, { methodName: 'version3.issueVotes.addVote' });
Expand Down
2 changes: 1 addition & 1 deletion src/version3/models/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface Fields {
total: number;
startAt: number;
};
votes: Votes;
votes: Votes & { voters: never; };
worklog: {
startAt: number;
maxResults: number;
Expand Down
4 changes: 2 additions & 2 deletions src/version3/models/issueBean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export interface IssueBean {
/** Expand options that include additional issue details in the response. */
expand?: string;
/** The ID of the issue. */
id?: string;
id: string;
/** The URL of the issue details. */
self?: string;
/** The key of the issue. */
key?: string;
key: string;
/** The rendered value of each field present on the issue. */
renderedFields?: {};
/** Details of the issue properties identified in the request. */
Expand Down
3 changes: 2 additions & 1 deletion src/version3/models/issueUpdateDetails.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IssueTransition } from './issueTransition';
import { HistoryMetadata } from './historyMetadata';
import { EntityProperty } from './entityProperty';
import { Fields } from './fields';

/** Details of an issue update request. */
export interface IssueUpdateDetails {
Expand All @@ -10,7 +11,7 @@ export interface IssueUpdateDetails {
* provides a straightforward option when setting a sub-field. When multiple sub-fields or other operations are
* required, use `update`. Fields included in here cannot be included in `update`.
*/
fields?: {};
fields?: Partial<Fields> | any;
/** List of operations to perform on issue screen fields. Note that fields included in here cannot be included in `fields`. */
update?: {};
historyMetadata?: HistoryMetadata;
Expand Down
4 changes: 2 additions & 2 deletions src/version3/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface User {
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
* *5b10ac8d82e05b22cc7d4ef5*. Required in requests.
*/
accountId?: string;
accountId: string;
/**
* The user account type. Can take the following values:
*
Expand All @@ -45,7 +45,7 @@ export interface User {
/** The display name of the user. Depending on the user’s privacy setting, this may return an alternative value. */
displayName?: string;
/** Whether the user is active. */
active?: boolean;
active: boolean;
/** The time zone specified in the user's profile. Depending on the user’s privacy setting, this may be returned as null. */
timeZone?: string;
/** The locale of the user. Depending on the user’s privacy setting, this may be returned as null. */
Expand Down
8 changes: 4 additions & 4 deletions src/version3/models/votes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { User } from './user';
/** The details of votes on an issue. */
export interface Votes {
/** The URL of these issue vote details. */
self?: string;
self: string;
/** The number of votes on the issue. */
votes?: number;
votes: number;
/** Whether the user making this request has voted on the issue. */
hasVoted?: boolean;
hasVoted: boolean;
/**
* List of the users who have voted on this issue. An empty list is returned when the calling user doesn't have the
* *View voters and watchers* project permission.
*/
voters?: User[];
voters: User[];
}
11 changes: 10 additions & 1 deletion src/version3/parameters/assignIssue.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { User } from '../models';

export interface AssignIssue extends User {
export interface AssignIssue extends Omit<User, 'accountId' | 'active'> {
/** The ID or key of the issue to be assigned. */
issueIdOrKey: string;

/**
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example,
* *5b10ac8d82e05b22cc7d4ef5*. If passed `null` it will unassigned issue.
*/
accountId: string | null;

/** Whether the user is active. */
active?: boolean;
}
17 changes: 12 additions & 5 deletions src/version3/parameters/getCurrentUser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
export interface GetCurrentUser {
/**
* Use [expand](#expansion) to include additional information about user in the response. This parameter accepts a
* comma-separated list. Expand options include:
* Use [expand](https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/#expansion) to include additional
* information about user in the response. Expand options include:
*
* `groups` Returns all groups, including nested groups, the user belongs to. `applicationRoles` Returns the
* application roles the user is assigned to.
* - `groups` Returns all groups, including nested groups, the user belongs to.
* - `applicationRoles` Returns the application roles the user is assigned to.
*/
expand?: string;
expand?: string | string[] | GetCurrentUser.Expand | GetCurrentUser.Expand[];
}

export namespace GetCurrentUser {
export enum Expand {
Groups = 'groups',
ApplicationRoles = 'applicationRoles',
}
}
2 changes: 1 addition & 1 deletion src/version3/parameters/getProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Project } from '../models';

export interface GetProject {
/** The project ID or project key (case sensitive). */
projectIdOrKey: string;
projectIdOrKey: string | number;
/**
* Use [expand](#expansion) to include additional information in the response. This parameter accepts a
* comma-separated list. Note that the project description, issue types, and project lead are included in all
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/integration/constants.ts → tests/e2e/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export namespace Constants {
export const testTimeouts = 60_000;
export const testProjectKey = 'AUTOTEST';
export const testProjectName = 'Jira.js project for lib automatic tests';
export const testProjectKey = 'AUTOTEST1';
export const testProjectName = 'Jira.js project for lib automatic1 tests';
export const testGroupName = 'Automated tests group name';
export const testDashboardName = 'Automated dashboard name';
export const testIssueSummary = 'Test issue summary';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('IssueAttachments', () => {
issueIdOrKey: issue.key,
attachment: {
filename: 'issueAttachments.test.ts',
file: fs.readFileSync('./tests/integration/version2/issueAttachments.test.ts'),
file: fs.readFileSync('./tests/e2e/version2/issueAttachments.test.ts'),
},
});

Expand Down
Loading