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

Sprint types fixed #140

Merged
merged 2 commits into from
Jun 30, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Jira.js changelog

### 2.4.1

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

### 2.4.0

- Some properties to some endpoints added :D
Expand Down
245 changes: 96 additions & 149 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jira.js",
"version": "2.4.0",
"version": "2.4.1",
"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 @@ -29,9 +29,9 @@
"lint:base": "eslint --ext .ts",
"lint:fix": "npm run lint:tests -- --fix && npm run lint:src:agile -- --fix && npm run lint:src:clients -- --fix && npm run lint:src:services -- --fix && npm run lint:src:version2 -- --fix && npm run lint:src:version3 -- --fix && npm run lint:src:files -- --fix",
"doc": "typedoc --name Jira.js --out docs ./src",
"test": "npm run test:unit && npm run test:system",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "jest tests/unit",
"test:system": "jest tests/system --setupFiles=./tests/setup.ts --runInBand",
"test:e2e": "jest tests/integration --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 @@ -44,23 +44,23 @@
"devDependencies": {
"@types/express": "^4.17.12",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.2",
"@types/node": "^15.12.5",
"@types/oauth": "^0.9.1",
"@types/sinon": "^10.0.2",
"@typescript-eslint/eslint-plugin": "^4.26.1",
"@typescript-eslint/parser": "^4.26.1",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"dotenv": "^10.0.0",
"eslint": "^7.28.0",
"eslint": "^7.29.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.4",
"jest": "^26.6.3",
"prettier": "^2.3.1",
"prettier": "^2.3.2",
"prettier-plugin-jsdoc": "^0.3.23",
"sinon": "^11.1.1",
"ts-jest": "^26.5.6",
"typedoc": "^0.20.36",
"typescript": "^4.3.2"
"typedoc": "^0.21.2",
"typescript": "^4.3.4"
},
"dependencies": {
"atlassian-jwt": "^2.0.1",
Expand Down
6 changes: 3 additions & 3 deletions src/agile/backlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class Backlog {
* be moved at once.
*/
async moveIssuesToBacklog<T = void>(
parameters: Parameters.MoveIssuesToBacklog | undefined,
parameters: Parameters.MoveIssuesToBacklog,
callback: Callback<T>
): Promise<void>;
/**
Expand All @@ -22,9 +22,9 @@ export class Backlog {
* This operation is equivalent to remove future and active sprints from a given set of issues. At most 50 issues may
* be moved at once.
*/
async moveIssuesToBacklog<T = void>(parameters?: Parameters.MoveIssuesToBacklog, callback?: never): Promise<T>;
async moveIssuesToBacklog<T = void>(parameters: Parameters.MoveIssuesToBacklog, callback?: never): Promise<T>;
async moveIssuesToBacklog<T = void>(
parameters?: Parameters.MoveIssuesToBacklog,
parameters: Parameters.MoveIssuesToBacklog,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
Expand Down
12 changes: 6 additions & 6 deletions src/agile/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class Board {
* </ul>
*/
async createBoard<T = Models.CreateBoard>(
parameters: Parameters.CreateBoard | undefined,
parameters: Parameters.CreateBoard,
callback: Callback<T>
): Promise<void>;
/**
Expand Down Expand Up @@ -101,9 +101,9 @@ export class Board {
* </li>
* </ul>
*/
async createBoard<T = Models.CreateBoard>(parameters?: Parameters.CreateBoard, callback?: never): Promise<T>;
async createBoard<T = Models.CreateBoard>(parameters: Parameters.CreateBoard, callback?: never): Promise<T>;
async createBoard<T = Models.CreateBoard>(
parameters?: Parameters.CreateBoard,
parameters: Parameters.CreateBoard,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
Expand Down Expand Up @@ -752,16 +752,16 @@ export class Board {
}

/** Returns all sprints from a board, for a given board ID. This only includes sprints that the user has permission to view. */
async getAllSprints<T = Paginated<Models.SprintBean[]>>(
async getAllSprints<T = Paginated<Models.Sprint>>(
parameters: Parameters.GetAllSprints,
callback: Callback<T>
): Promise<void>;
/** Returns all sprints from a board, for a given board ID. This only includes sprints that the user has permission to view. */
async getAllSprints<T = Paginated<Models.SprintBean[]>>(
async getAllSprints<T = Paginated<Models.Sprint>>(
parameters: Parameters.GetAllSprints,
callback?: never
): Promise<T>;
async getAllSprints<T = Paginated<Models.SprintBean[]>>(
async getAllSprints<T = Paginated<Models.Sprint>>(
parameters: Parameters.GetAllSprints,
callback?: Callback<T>,
): Promise<void | T> {
Expand Down
2 changes: 1 addition & 1 deletion src/agile/models/createBoard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface CreateBoard {
id?: number;
id: number;
self?: string;
name?: string;
type?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/agile/models/getAllBoards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export interface GetAllBoards {
startAt?: number;
total?: number;
isLast?: boolean;
values?: {
id?: number;
values: {
id: number;
self?: string;
name?: string;
type?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/agile/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export * from './reportBean';
export * from './reportsResponseBean';
export * from './searchResultsBean';
export * from './simpleLinkBean';
export * from './sprintBean';
export * from './sprint';
export * from './sprintCreateBean';
export * from './sprintSwapBean';
export * from './statusCategoryJsonBean';
Expand Down
8 changes: 4 additions & 4 deletions src/agile/models/searchResultsBean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ export interface SearchResultsBean {
/** Expand options that include additional search result details in the response. */
expand?: string;
/** The index of the first item returned on the page. */
startAt?: number;
startAt: number;
/** The maximum number of results that could be on the page. */
maxResults?: number;
maxResults: number;
/** The number of results on the page. */
total?: number;
total: number;
/** The list of issues found by the search. */
issues?: IssueBean[];
issues: IssueBean[];
/** Any warnings related to the JQL query. */
warningMessages?: string[];
/** The ID and name of each field in the search results. */
Expand Down
21 changes: 21 additions & 0 deletions src/agile/models/sprint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export type SprintBean = Sprint;

export interface Sprint {
id: number;
self?: string;
state: string | Sprint.State;
name: string;
startDate?: string;
endDate?: string;
completeDate?: string;
originBoardId?: number;
goal?: string;
}

export namespace Sprint {
export enum State {
Future = 'future',
Active = 'active',
Closed = 'closed',
}
}
11 changes: 0 additions & 11 deletions src/agile/models/sprintBean.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/agile/parameters/createBoard.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface CreateBoard {
name?: string;
name: string;
type?: string;
filterId?: number;
location?: {
Expand Down
4 changes: 2 additions & 2 deletions src/agile/parameters/createSprint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface CreateSprint {
name?: string;
name: string;
originBoardId: number;
startDate?: string;
endDate?: string;
originBoardId?: number;
goal?: string;
}
2 changes: 1 addition & 1 deletion src/agile/parameters/moveIssuesToBacklog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export interface MoveIssuesToBacklog {
issues?: string[];
issues: string[];
}
2 changes: 1 addition & 1 deletion src/agile/parameters/moveIssuesToBoard.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface MoveIssuesToBoard {
boardId: number;
issues?: string[];
issues: string[];
rankBeforeIssue?: string;
rankAfterIssue?: string;
rankCustomFieldId?: number;
Expand Down
2 changes: 1 addition & 1 deletion src/agile/parameters/moveIssuesToSprintAndRank.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface MoveIssuesToSprintAndRank {
/** The ID of the sprint that you want to assign issues to. */
sprintId: number;
issues?: string[];
issues: string[];
rankBeforeIssue?: string;
rankAfterIssue?: string;
rankCustomFieldId?: number;
Expand Down
8 changes: 5 additions & 3 deletions src/agile/parameters/partiallyUpdateSprint.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Sprint } from '../models';

export interface PartiallyUpdateSprint {
/** The ID of the sprint to update. */
sprintId: number;
id?: number;
self?: string;
state?: string;
state?: string | Sprint.State;
name?: string;
startDate?: string;
endDate?: string;
startDate?: string | Date;
endDate?: string | Date;
completeDate?: string;
originBoardId?: number;
goal?: string;
Expand Down
32 changes: 16 additions & 16 deletions src/agile/sprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class Sprint {
* call is ignored and instead the last sprint's duration is used to fill the form.
* </p>
*/
async createSprint<T = Models.SprintBean>(
parameters: Parameters.CreateSprint | undefined,
async createSprint<T = Models.Sprint>(
parameters: Parameters.CreateSprint,
callback: Callback<T>
): Promise<void>;
/**
Expand All @@ -23,8 +23,8 @@ export class Sprint {
* call is ignored and instead the last sprint's duration is used to fill the form.
* </p>
*/
async createSprint<T = Models.SprintBean>(parameters?: Parameters.CreateSprint, callback?: never): Promise<T>;
async createSprint<T = Models.SprintBean>(parameters?: Parameters.CreateSprint, callback?: Callback<T>): Promise<void | T> {
async createSprint<T = Models.Sprint>(parameters: Parameters.CreateSprint, callback?: never): Promise<T>;
async createSprint<T = Models.Sprint>(parameters: Parameters.CreateSprint, callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: '/rest/agile/1.0/sprint',
method: 'POST',
Expand All @@ -44,13 +44,13 @@ export class Sprint {
* Returns the sprint for a given sprint ID. The sprint will only be returned if the user can view the board that the
* sprint was created on, or view at least one of the issues in the sprint.
*/
async getSprint<T = Models.SprintBean>(parameters: Parameters.GetSprint, callback: Callback<T>): Promise<void>;
async getSprint<T = Models.Sprint>(parameters: Parameters.GetSprint, callback: Callback<T>): Promise<void>;
/**
* Returns the sprint for a given sprint ID. The sprint will only be returned if the user can view the board that the
* sprint was created on, or view at least one of the issues in the sprint.
*/
async getSprint<T = Models.SprintBean>(parameters: Parameters.GetSprint, callback?: never): Promise<T>;
async getSprint<T = Models.SprintBean>(parameters: Parameters.GetSprint, callback?: Callback<T>): Promise<void | T> {
async getSprint<T = Models.Sprint>(parameters: Parameters.GetSprint, callback?: never): Promise<T>;
async getSprint<T = Models.Sprint>(parameters: Parameters.GetSprint, callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/agile/1.0/sprint/${parameters.sprintId}`,
method: 'GET',
Expand All @@ -72,7 +72,7 @@ export class Sprint {
* <li>The completeDate field cannot be updated manually.</li>
* </ul>
*/
async partiallyUpdateSprint<T = Models.SprintBean>(
async partiallyUpdateSprint<T = Models.Sprint>(
parameters: Parameters.PartiallyUpdateSprint,
callback: Callback<T>
): Promise<void>;
Expand All @@ -89,8 +89,8 @@ export class Sprint {
* <li>The completeDate field cannot be updated manually.</li>
* </ul>
*/
async partiallyUpdateSprint<T = Models.SprintBean>(parameters: Parameters.PartiallyUpdateSprint, callback?: never): Promise<T>;
async partiallyUpdateSprint<T = Models.SprintBean>(
async partiallyUpdateSprint<T = Models.Sprint>(parameters: Parameters.PartiallyUpdateSprint, callback?: never): Promise<T>;
async partiallyUpdateSprint<T = Models.Sprint>(
parameters: Parameters.PartiallyUpdateSprint,
callback?: Callback<T>,
): Promise<void | T> {
Expand Down Expand Up @@ -126,7 +126,7 @@ export class Sprint {
* <li>The completeDate field cannot be updated manually.</li>
* </ul>
*/
async updateSprint<T = Models.SprintBean>(parameters: Parameters.UpdateSprint, callback: Callback<T>): Promise<void>;
async updateSprint<T = Models.Sprint>(parameters: Parameters.UpdateSprint, callback: Callback<T>): Promise<void>;
/**
* Performs a full update of a sprint. A full update means that the result will be exactly the same as the request
* body. Any fields not present in the request JSON will be set to null. <p>Notes:</p>
Expand All @@ -140,8 +140,8 @@ export class Sprint {
* <li>The completeDate field cannot be updated manually.</li>
* </ul>
*/
async updateSprint<T = Models.SprintBean>(parameters: Parameters.UpdateSprint, callback?: never): Promise<T>;
async updateSprint<T = Models.SprintBean>(parameters: Parameters.UpdateSprint, callback?: Callback<T>): Promise<void | T> {
async updateSprint<T = Models.Sprint>(parameters: Parameters.UpdateSprint, callback?: never): Promise<T>;
async updateSprint<T = Models.Sprint>(parameters: Parameters.UpdateSprint, callback?: Callback<T>): Promise<void | T> {
const config: RequestConfig = {
url: `/rest/agile/1.0/sprint/${parameters.sprintId}`,
method: 'PUT',
Expand Down Expand Up @@ -178,16 +178,16 @@ export class Sprint {
* Returns all issues in a sprint, for a given sprint ID. This only includes issues that the user has permission to
* view. By default, the returned issues are ordered by rank.
*/
async getIssuesForSprint<T = Models.IssueBean>(
async getIssuesForSprint<T = Models.SearchResultsBean>(
parameters: Parameters.GetIssuesForSprint,
callback: Callback<T>
): Promise<void>;
/**
* Returns all issues in a sprint, for a given sprint ID. This only includes issues that the user has permission to
* view. By default, the returned issues are ordered by rank.
*/
async getIssuesForSprint<T = Models.IssueBean>(parameters: Parameters.GetIssuesForSprint, callback?: never): Promise<T>;
async getIssuesForSprint<T = Models.IssueBean>(
async getIssuesForSprint<T = Models.SearchResultsBean>(parameters: Parameters.GetIssuesForSprint, callback?: never): Promise<T>;
async getIssuesForSprint<T = Models.SearchResultsBean>(
parameters: Parameters.GetIssuesForSprint,
callback?: Callback<T>,
): Promise<void | T> {
Expand Down
4 changes: 2 additions & 2 deletions src/clients/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class BaseClient implements Client {
bodyExists: !!requestConfig.data,
callbackUsed: !!callback,
headersExists: !!requestConfig.headers,
libVersion: '2.4.0',
libVersionHash: '11e0eed8d3696c0a632f822df385ab3c',
libVersion: '2.4.1',
libVersionHash: '86bc3115eb4e9873ac96904a4a68e19e',
methodName: telemetryData?.methodName || 'sendRequest',
onErrorMiddlewareUsed: !!this.config.middlewares?.onError,
onResponseMiddlewareUsed: !!this.config.middlewares?.onResponse,
Expand Down
6 changes: 3 additions & 3 deletions src/version3/issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Issues {
* which the issue or subtask is created.
*/
async createIssue<T = Models.CreatedIssue>(
parameters: Parameters.CreateIssue | undefined,
parameters: Parameters.CreateIssue,
callback: Callback<T>
): Promise<void>;
/**
Expand All @@ -57,9 +57,9 @@ export class Issues {
* projects* and *Create issues* [project permissions](https://confluence.atlassian.com/x/yodKLg) for the project in
* which the issue or subtask is created.
*/
async createIssue<T = Models.CreatedIssue>(parameters?: Parameters.CreateIssue, callback?: never): Promise<T>;
async createIssue<T = Models.CreatedIssue>(parameters: Parameters.CreateIssue, callback?: never): Promise<T>;
async createIssue<T = Models.CreatedIssue>(
parameters?: Parameters.CreateIssue,
parameters: Parameters.CreateIssue,
callback?: Callback<T>,
): Promise<void | T> {
const config: RequestConfig = {
Expand Down
Loading