-
-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathIssueLinks.ts
92 lines (87 loc) · 2.83 KB
/
IssueLinks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { BaseResource } from '@gitbeaker/requester-utils';
import { RequestHelper, endpoint } from '../infrastructure';
import type {
GitlabAPIResponse,
MappedOmit,
PaginationRequestOptions,
PaginationTypes,
ShowExpanded,
Sudo,
} from '../infrastructure';
import { SimpleUserSchema } from './Users';
import { MilestoneSchema } from '../templates/ResourceMilestones';
export interface IssueLinkSchema extends Record<string, unknown> {
id: number;
iid: number;
project_id: number;
issue_link_id: number;
state: string;
description: string;
weight?: number;
author: MappedOmit<SimpleUserSchema, 'created_at'>;
milestone: MilestoneSchema;
assignees?: MappedOmit<SimpleUserSchema, 'created_at'>[];
title: string;
labels?: string[];
user_notes_count: number;
due_date: string;
web_url: string;
confidential: boolean;
updated_at: string;
link_created_at: string;
link_updated_at: string;
link_type: 'relates_to' | 'blocks' | 'is_blocked_by';
}
export interface ExpandedIssueLinkSchema extends Record<string, unknown> {
source_issue: MappedOmit<
IssueLinkSchema,
'link_type' | 'link_created_at' | 'link_updated_at' | 'issue_link_id'
>;
target_issue: MappedOmit<
IssueLinkSchema,
'link_type' | 'link_created_at' | 'link_updated_at' | 'issue_link_id'
>;
link_type: 'relates_to' | 'blocks' | 'is_blocked_by';
}
export class IssueLinks<C extends boolean = false> extends BaseResource<C> {
all<E extends boolean = false, P extends PaginationTypes = 'offset'>(
projectId: string | number,
issueIId: number,
options?: Sudo & ShowExpanded<E> & PaginationRequestOptions<P>,
): Promise<GitlabAPIResponse<IssueLinkSchema[], C, E, P>> {
return RequestHelper.get<IssueLinkSchema[]>()(
this,
endpoint`projects/${projectId}/issues/${issueIId}/links`,
options,
);
}
create<E extends boolean = false>(
projectId: string | number,
issueIId: number,
targetProjectId: string | number,
targetIssueIId: number,
options?: { linkType?: 'relates_to' | 'blocks' | 'is_blocked_by' } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<ExpandedIssueLinkSchema, C, E, void>> {
return RequestHelper.post<ExpandedIssueLinkSchema>()(
this,
endpoint`projects/${projectId}/issues/${issueIId}/links`,
{
targetProjectId,
targetIssueIid: targetIssueIId,
...options,
},
);
}
remove<E extends boolean = false>(
projectId: string | number,
issueIId: number,
issueLinkId: number,
options?: { linkType?: 'relates_to' | 'blocks' | 'is_blocked_by' } & Sudo & ShowExpanded<E>,
): Promise<GitlabAPIResponse<ExpandedIssueLinkSchema, C, E, void>> {
return RequestHelper.del<ExpandedIssueLinkSchema>()(
this,
endpoint`projects/${projectId}/issues/${issueIId}/links/${issueLinkId}`,
options,
);
}
}