@nu-art/jira
Version:
129 lines (128 loc) • 3.54 kB
TypeScript
import { Module, TypedMap } from '@nu-art/ts-common';
import { JiraIssueText } from './utils';
import { JiraVersion } from '../../shared/version';
type Config = {
auth: JiraAuth;
defaultAssignee: JiraUser;
baseUrl?: string;
};
type JiraAuth = {
email: string;
apiKey: string;
};
type JiraUser = {
accountId: string;
name?: string;
email?: string;
};
type JiraMark = {
type: string;
attrs: {
href: string;
};
};
type JiraContent = {
type: 'paragraph' | string;
text?: string;
marks?: JiraMark[];
content?: JiraContent[];
};
type JiraDescription = string | {
type: 'doc' | string;
version: number;
content: JiraContent[];
};
export type JiraIssue_Fields = {
project: JiraProject;
issuetype: IssueType;
description: JiraDescription;
summary: string;
reporter?: {
id: string;
};
} & TypedMap<any>;
export type IssueType = {
id?: string;
name: string;
};
export type LabelType = {
label: string[];
};
export type JiraProject = {
id: string;
name: string;
key: string;
};
export type BaseIssue = {
id: string;
key: string;
self: string;
url: string;
};
export type JiraIssue = BaseIssue & {
expand: string;
fields: JiraIssue_Fields;
};
export type FixVersionType = {
fixVersions: {
name: string;
}[];
};
export type QueryItemWithOperator = {
value: string;
operator: string;
};
export type JiraQuery = TypedMap<string | string[] | QueryItemWithOperator> & {
status?: string | string[];
project?: string | string[];
fixVersion?: string | string[];
};
export type JiraResponse_IssuesQuery = {
expand: string;
startAt: number;
maxResults: number;
total: number;
issues: JiraIssue[];
};
export type ResponsePostIssue = BaseIssue;
export declare class ModuleBE_Jira_Class extends Module<Config> {
private headersJson;
private headersForm;
private projects;
private versions;
private restUrl;
protected init(): void;
private buildHeaders;
project: {
query: (projectKey: string) => Promise<JiraProject>;
};
version: {
query: (projectId: string, versionName: string) => Promise<JiraVersion | undefined>;
create: (projectId: string, versionName: string) => Promise<JiraVersion>;
};
comment: {
add: (issueKey: string, comment: string) => Promise<unknown>;
};
issue: {
query: (query: JiraQuery) => Promise<JiraIssue[]>;
get: (issueId: string) => Promise<JiraIssue>;
comment: {
add: (issueKey: string, comment: string) => Promise<unknown>;
};
create: (project: JiraProject, issueType: IssueType, summary: string, descriptions: JiraIssueText[], label: string[]) => Promise<ResponsePostIssue>;
update: (issueKey: string, fields: Partial<JiraIssue_Fields>) => Promise<unknown>;
resolve: (issueKey: string, projectKey: string, versionName: string, status: string) => Promise<unknown>;
};
getIssueTypes: (id: string) => Promise<unknown>;
query: (query: JiraQuery) => Promise<JiraIssue[]>;
getIssueRequest: (issueId: string) => Promise<JiraIssue>;
addIssueAttachment: (issue: string, file: Buffer) => Promise<unknown>;
private executeFormRequest;
private executePostRequest;
private executePutRequest;
private handleResponse;
private executeGetRequest;
private executeRequest;
}
export declare const JiraModule: ModuleBE_Jira_Class;
export {};