diff --git a/types/jira-client/index.d.ts b/types/jira-client/index.d.ts new file mode 100644 index 0000000000..e92d2a2f64 --- /dev/null +++ b/types/jira-client/index.d.ts @@ -0,0 +1,368 @@ +// Type definitions for jira-client 6.4 +// Project: https://github.com/jira-node/node-jira-client +// Definitions by: Anatoliy Ostapenko +// Orta Therox +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import { CoreOptions, RequestResponse } from "request"; +import { ReadStream } from "fs"; + +declare class JiraApi { + private protocol: string; + private host: string; + private port: string | null; + private apiVersion: string; + private base: string; + private intermediatePath?: string; + private strictSSL: boolean; + private webhookVersion: string; + private greenhopperVersion: string; + + constructor(options: JiraApi.JiraApiOptions); + + findIssue( + issueNumber: string, + expand?: string, + fields?: string, + properties?: string, + fieldsByKeys?: boolean + ): Promise; + + getUnresolvedIssueCount(version: string): Promise; + + getProject(project: string): Promise; + + createProject(project: string): Promise; + + findRapidView(projectName: string): Promise; + + getLastSprintForRapidView(rapidViewId: string): Promise; + + getSprintIssues(rapidViewId: string, sprintId: string): Promise; + + listSprints(rapidViewId: string): Promise; + + addIssueToSprint(issueId: string, sprintId: string): Promise; + + issueLink(link: JiraApi.LinkObject): Promise; + + getRemoteLinks(issueNumber: string): Promise; + + createRemoteLink(issueNumber: string, remoteLink: JiraApi.LinkObject): Promise; + + getVersions(project: string): Promise; + + createVersion(version: string): Promise; + + updateVersion(version: string): Promise; + + deleteVersion( + versionId: string, + moveFixIssuesToId: string, + moveAffectedIssuesToId: string + ): Promise; + + searchJira(searchString: string, optional?: JiraApi.SearchQuery): Promise; + + createUser(user: JiraApi.UserObject): Promise; + + searchUsers(options: JiraApi.SearchUserOptions): Promise; + + getUsersInGroup(groupname: string, startAt?: number, maxResults?: number): Promise; + + addNewIssue(issue: JiraApi.IssueObject): Promise; + + addWatcher(issueKey: string, username: string): Promise; + + deleteIssue(issueId: string): Promise; + + updateIssue(issueId: string, issueUpdate: JiraApi.IssueObject): Promise; + + listComponents(project: string): Promise; + + addNewComponent(component: JiraApi.ComponentObject): Promise; + + deleteComponent(componentId: string): Promise; + + createCustomField(field: JiraApi.FieldObject): Promise; + + listFields(): Promise; + + createFieldOption(fieldKey: string, option: JiraApi.FieldOptionObject): Promise; + + listFieldOptions(fieldKey: string): Promise; + + upsertFieldOption( + fieldKey: string, + optionId: string, + option: JiraApi.FieldOptionObject + ): Promise; + + getFieldOption(fieldKey: string, optionId: string): Promise; + + deleteFieldOption(fieldKey: string, optionId: string): Promise; + + getIssueProperty(issueNumber: string, property: string): Promise; + + listPriorities(): Promise; + + listTransitions(issueId: string): Promise; + + transitionIssue(issueId: string, issueTransition: JiraApi.TransitionObject): Promise; + + listProjects(): Promise; + + addComment(issueId: string, comment: string): Promise; + + updateComment(issueId: string, commentId: string, comment: string, options?: any): Promise; + + addWorklog( + issueId: string, + worklog: JiraApi.WorklogObject, + newEstimate: JiraApi.EstimateObject + ): Promise; + + deleteWorklog(issueId: string, worklogId: string): Promise; + + listIssueTypes(): Promise; + + registerWebhook(webhook: JiraApi.WebhookObject): Promise; + + listWebhooks(): Promise; + + getWebhook(webhookID: string): Promise; + + deleteWebhook(webhookID: string): Promise; + + getCurrentUser(): Promise; + + getBacklogForRapidView(rapidViewId: string): Promise; + + addAttachmentOnIssue(issueId: string, readStream: ReadStream): Promise; + + issueNotify(issueId: string, notificationBody: JiraApi.NotificationObject): Promise; + + listStatus(): Promise; + + getDevStatusSummary(issueId: string): Promise; + + getDevStatusDetail(issueId: string, applicationType: string, dataType: string): Promise; + + moveToBacklog(issues: string[]): Promise; + + getAllBoards( + startAt?: number, + maxResults?: number, + type?: string, + name?: string, + projectKeyOrId?: string + ): Promise; + + createBoard(boardBody: JiraApi.BoardObject): Promise; + + getBoard(boardId: string): Promise; + + deleteBoard(boardId: string): Promise; + + getIssuesForBacklog( + boardId: string, + startAt?: number, + maxResults?: number, + jql?: string, + validateQuery?: boolean, + fields?: string + ): Promise; + + getConfiguration(boardId: string): Promise; + + getIssuesForBoard( + boardId: string, + startAt?: number, + maxResults?: number, + jql?: string, + validateQuery?: boolean, + fields?: string + ): Promise; + + getEpics( + boardId: string, + startAt?: number, + maxResults?: number, + done?: "true" | "false" + ): Promise; + + getBoardIssuesForEpic( + boardId: string, + epicId: string, + startAt?: number, + maxResults?: number, + jql?: string, + validateQuery?: boolean, + fields?: string + ): Promise; + + getProjects(boardId: string, startAt?: number, maxResults?: number): Promise; + + getProjectsFull(boardId: string): Promise; + + getBoardPropertiesKeys(boardId: string): Promise; + + deleteBoardProperty(boardId: string, propertyKey: string): Promise; + + setBoardProperty(boardId: string, propertyKey: string, body: string): Promise; + + getBoardProperty(boardId: string, propertyKey: string): Promise; + + getAllSprints( + boardId: string, + startAt?: number, + maxResults?: number, + state?: "future" | "active" | "closed" + ): Promise; + + getBoardIssuesForSprint( + boardId: string, + sprintId: string, + startAt?: number, + maxResults?: number, + jql?: string, + validateQuery?: boolean, + fields?: string + ): Promise; + + getAllVersions( + boardId: string, + startAt?: number, + maxResults?: number, + released?: "true" | "false" + ): Promise; + + private makeRequestHeader(uri: string, options?: JiraApi.UriOptions); + + private makeUri(options: JiraApi.UriOptions): string; + + private makeWebhookUri(options: JiraApi.UriOptions): string; + + private makeSprintQueryUri(options: JiraApi.UriOptions): string; + + private makeDevStatusUri(options: JiraApi.UriOptions): string; + + private makeAgileUri(options: JiraApi.UriOptions): string; + + private doRequest(requestOptions: CoreOptions): Promise; +} + +declare namespace JiraApi { + interface JiraApiOptions { + protocol?: string; + host: string; + port?: string; + username?: string; + password?: string; + apiVersion?: string; + base?: string; + intermediatePath?: string; + strictSSL?: boolean; + request?: any; + timeout?: number; + webhookVersion?: string; + greenhopperVersion?: string; + bearer?: string; + oauth?: OAuth; + } + + interface OAuth { + consumer_key: string; + consumer_secret: string; + access_token: string; + access_token_secret: string; + signature_method?: string; + } + + interface LinkObject { + [name: string]: any; + } + + interface Query { + [name: string]: any; + } + + interface JsonResponse { + [name: string]: any; + } + + interface UserObject { + [name: string]: any; + } + + interface IssueObject { + [name: string]: any; + } + + interface ComponentObject { + [name: string]: any; + } + + interface FieldObject { + [name: string]: any; + } + + interface FieldOptionObject { + [name: string]: any; + } + + interface TransitionObject { + [name: string]: any; + } + + interface WorklogObject { + [name: string]: any; + } + + interface EstimateObject { + [name: string]: any; + } + + interface WebhookObject { + [name: string]: any; + } + + interface NotificationObject { + [name: string]: any; + } + + interface BoardObject { + [name: string]: any; + } + + interface SearchUserOptions { + username: string; + startAt?: number; + maxResults?: number; + includeActive?: boolean; + includeInactive?: boolean; + } + + interface SearchQuery { + startAt?: number; + maxResults?: number; + fields?: string[]; + } + + interface SearchQuery { + startAt?: number; + maxResults?: number; + fields?: string[]; + } + + interface UriOptions { + pathname: string; + query?: Query; + intermediatePath?: string; + } +} + +export default JiraApi; diff --git a/types/jira-client/jira-client-tests.ts b/types/jira-client/jira-client-tests.ts new file mode 100644 index 0000000000..a87322e5be --- /dev/null +++ b/types/jira-client/jira-client-tests.ts @@ -0,0 +1,30 @@ +import JiraApi from 'jira-client'; + +// Initialize +const jira = new JiraApi({ + protocol: 'https', + host: 'jira.somehost.com', + username: 'username', + password: 'password', + apiVersion: '2', + strictSSL: true +}); + +const issueNumber = "123"; + +jira.findIssue(issueNumber) + .then(issue => { + console.log(`Status: ${issue.fields.status.name}`); + }) + .catch(err => { + console.error(err); + }); + +async function logIssueName() { + try { + const issue = await jira.findIssue(issueNumber); + console.log(`Status: ${issue.fields.status.name}`); + } catch (err) { + console.error(err); + } +} diff --git a/types/jira-client/tsconfig.json b/types/jira-client/tsconfig.json new file mode 100644 index 0000000000..b84638d545 --- /dev/null +++ b/types/jira-client/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jira-client-tests.ts" + ] +} diff --git a/types/jira-client/tslint.json b/types/jira-client/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jira-client/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }