@gitkraken/provider-apis 0.10.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ import { PagedResult, Result } from '../../types';
2
2
  import { CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput, Options } from '../gitProvider';
3
3
  import { Issue } from '../issueProvider';
4
4
  import { Provider } from '../provider';
5
+ import { WorkItemType } from './azureDevOpsTypes';
5
6
  export interface AzureGetRepoInput extends GetRepoInput {
6
7
  project: string;
7
8
  }
@@ -18,6 +19,13 @@ export interface AzureOrganization {
18
19
  id: string;
19
20
  name: string;
20
21
  }
22
+ export type StatusByWorkItemIdByStatusId = {
23
+ [workItemType: string]: {
24
+ [statusId: string]: {
25
+ title: string;
26
+ };
27
+ };
28
+ };
21
29
  export declare class AzureDevOps extends Provider implements GitProvider {
22
30
  /** Note: PATs are not supported for this function, only OAuth tokens are. */
23
31
  getCurrentUser(options?: EnterpriseOptions): Promise<{
@@ -118,6 +126,7 @@ export declare class AzureDevOps extends Provider implements GitProvider {
118
126
  }, options?: EnterpriseOptions): Promise<{
119
127
  data: GitPullRequest[];
120
128
  }>;
129
+ private updatePullRequest;
121
130
  closePullRequest(input: {
122
131
  repo: GetRepoInput;
123
132
  pullRequestId: string;
@@ -127,12 +136,18 @@ export declare class AzureDevOps extends Provider implements GitProvider {
127
136
  pullRequestId: string;
128
137
  expectedSourceSha: string;
129
138
  }, options?: EnterpriseOptions): Promise<void>;
139
+ setPullRequestAsDraft(input: {
140
+ repo: GetRepoInput;
141
+ pullRequestId: string;
142
+ isDraft: boolean;
143
+ }, options?: EnterpriseOptions): Promise<void>;
130
144
  getIssuesForAzureProject(input: {
131
145
  namespace: string;
132
146
  project: string;
133
147
  assigneeLogins?: string[];
134
148
  authorLogin?: string;
135
149
  mentionLogin?: string;
150
+ statusByWorkItemIdByStatusId?: StatusByWorkItemIdByStatusId;
136
151
  } & NumberedPageInput, options?: EnterpriseOptions): Promise<{
137
152
  pageInfo: {
138
153
  hasNextPage: boolean;
@@ -152,4 +167,21 @@ export declare class AzureDevOps extends Provider implements GitProvider {
152
167
  issueId: string;
153
168
  status: string;
154
169
  }, options?: EnterpriseOptions): Promise<void>;
170
+ getIssueTypesForAzureProject(input: {
171
+ namespace: string;
172
+ project: string;
173
+ }, options?: EnterpriseOptions): Promise<{
174
+ data: WorkItemType[];
175
+ }>;
176
+ getLabelsForProject(input: {
177
+ namespace: string;
178
+ project: string;
179
+ }, options?: EnterpriseOptions): Promise<{
180
+ data: {
181
+ color: null;
182
+ description: null;
183
+ id: string;
184
+ name: string;
185
+ }[];
186
+ }>;
155
187
  }
@@ -72,6 +72,12 @@ export interface Ref {
72
72
  creator: CreatedBy;
73
73
  url: string;
74
74
  }
75
+ export interface WorkItemTagDefinition {
76
+ id: string;
77
+ lastUpdated: string;
78
+ name: string;
79
+ url: string;
80
+ }
75
81
  interface Label {
76
82
  id: string;
77
83
  name: string;
@@ -191,4 +197,34 @@ export interface AzureIssue {
191
197
  };
192
198
  url: string;
193
199
  }
200
+ export interface WorkItemTypeField {
201
+ helpText: string;
202
+ alwaysRequired: boolean;
203
+ referenceName: string;
204
+ name: string;
205
+ url: string;
206
+ }
207
+ export interface WorkItemTypeTransition {
208
+ to: string;
209
+ actions: string[] | null;
210
+ }
211
+ export interface WorkItemType {
212
+ name: string;
213
+ referenceName: string;
214
+ description: string;
215
+ color: string;
216
+ icon: {
217
+ id: string;
218
+ url: string;
219
+ };
220
+ isDisabled: boolean;
221
+ xmlForm: string;
222
+ fields: WorkItemTypeField[];
223
+ fieldInstances: WorkItemTypeField[];
224
+ transitions: [string: WorkItemTypeTransition];
225
+ url: string;
226
+ }
227
+ export interface UpdatePullRequestResponse {
228
+ status: string;
229
+ }
194
230
  export {};
@@ -1,4 +1,4 @@
1
- import { EnterpriseOptions, GetRepoInput, GitProvider } from '../gitProvider';
1
+ import { EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitRepository } from '../gitProvider';
2
2
  import { EnterpriseProvider } from '../provider';
3
3
  export declare class BitbucketServer extends EnterpriseProvider implements GitProvider {
4
4
  private getBaseUrl;
@@ -16,15 +16,7 @@ export declare class BitbucketServer extends EnterpriseProvider implements GitPr
16
16
  };
17
17
  }>;
18
18
  getRepos(inputs: GetRepoInput[], options?: EnterpriseOptions): Promise<{
19
- data: {
20
- id: string;
21
- namespace: string;
22
- name: string;
23
- webUrl: string;
24
- httpsUrl: string | null;
25
- sshUrl: string | null;
26
- defaultBranch: null;
27
- permission: null;
28
- }[];
19
+ data: GitRepository[];
20
+ errors: GetRepoErrorData[];
29
21
  }>;
30
22
  }
@@ -24,6 +24,24 @@ export interface Organization {
24
24
  email: string | null;
25
25
  avatarUrl: string;
26
26
  }
27
+ export interface GitLabel {
28
+ color: string | null;
29
+ description: string | null;
30
+ graphQLId?: string;
31
+ id: string | null;
32
+ name: string;
33
+ }
34
+ export interface GitMilestone {
35
+ id: string;
36
+ graphQLId?: string;
37
+ number: number;
38
+ title: string;
39
+ description: string | null;
40
+ isOpen: boolean;
41
+ url: string;
42
+ startDate: Date | null;
43
+ dueDate: Date | null;
44
+ }
27
45
  export interface GitRepository {
28
46
  id: string;
29
47
  graphQLId?: string;
@@ -128,6 +146,8 @@ export interface GitPullRequest {
128
146
  } | null;
129
147
  } | null;
130
148
  mergeableState: GitPullRequestMergeableState;
149
+ milestone?: GitMilestone | null;
150
+ labels?: GitLabel[];
131
151
  }
132
152
  export interface GetRepoInput {
133
153
  namespace: string;
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, Organization } from '../gitProvider';
1
+ import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitLabel, GitMilestone, GitProvider, GitPullRequest, GitRepository, Organization } from '../gitProvider';
2
2
  import { Issue } from '../issueProvider';
3
3
  import { EnterpriseProvider } from '../provider';
4
4
  import { FetchIssuesData, FetchPullRequestsData } from './githubTypes';
@@ -149,6 +149,15 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
149
149
  };
150
150
  data: GitPullRequest[];
151
151
  }>;
152
+ searchIssues(input: {
153
+ query: string;
154
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
155
+ pageInfo: {
156
+ hasNextPage: boolean;
157
+ endCursor: string | null;
158
+ };
159
+ data: Issue[];
160
+ }>;
152
161
  /**
153
162
  * Returns pull requests that were created by, are assigned to, or have been requested to be reviewed by the user.
154
163
  */
@@ -175,10 +184,32 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
175
184
  pullRequestGraphQLId: string;
176
185
  expectedSourceSha: string;
177
186
  }, options?: EnterpriseOptions): Promise<void>;
187
+ setPullRequestMilestone(input: {
188
+ pullRequestGraphQLId: string;
189
+ milestoneGraphQLId: string | null;
190
+ }, options?: EnterpriseOptions): Promise<void>;
191
+ private markPullRequestReadyForReview;
192
+ private convertPullRequestToDraft;
193
+ setPullRequestAsDraft(input: {
194
+ pullRequestGraphQLId: string;
195
+ isDraft: boolean;
196
+ }, options?: EnterpriseOptions): Promise<void>;
197
+ /**
198
+ * Returns issues that were created by or are assigned to the user.
199
+ */
200
+ getIssuesAssociatedWithUser(input: {
201
+ username: string;
202
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
203
+ pageInfo: {
204
+ hasNextPage: boolean;
205
+ endCursor: string;
206
+ };
207
+ data: Issue[];
208
+ }>;
178
209
  getIssuesForRepos(input: FetchIssuesData & CursorPageInput, options?: EnterpriseOptions): Promise<{
179
210
  pageInfo: {
180
- endCursor: string | null;
181
211
  hasNextPage: boolean;
212
+ endCursor: string | null;
182
213
  };
183
214
  data: Issue[];
184
215
  }>;
@@ -190,4 +221,26 @@ export declare class GitHub extends EnterpriseProvider implements GitProvider {
190
221
  status: 'OPEN' | 'CLOSED';
191
222
  closeReason?: 'COMPLETED' | 'NOT_PLANNED';
192
223
  }, options?: EnterpriseOptions): Promise<void>;
224
+ setIssueMilestone(input: {
225
+ issueGraphQLId: string;
226
+ milestoneGraphQLId: string | null;
227
+ }, options?: EnterpriseOptions): Promise<void>;
228
+ getMilestonesForRepo(input: {
229
+ repo: GetRepoInput;
230
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
231
+ pageInfo: {
232
+ endCursor: string | null;
233
+ hasNextPage: boolean;
234
+ };
235
+ data: GitMilestone[];
236
+ }>;
237
+ getLabelsForRepo(input: {
238
+ repo: GetRepoInput;
239
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
240
+ pageInfo: {
241
+ endCursor: string | null;
242
+ hasNextPage: boolean;
243
+ };
244
+ data: GitLabel[];
245
+ }>;
193
246
  }
@@ -2,13 +2,16 @@ import { GraphQLBody, GraphQLError, GraphQLResponse, ProviderConfig } from '../.
2
2
  import { EnterpriseOptions } from '../gitProvider';
3
3
  export declare const GITHUB_API_URL = "https://api.github.com";
4
4
  export declare const GITHUB_GRAPHQL_API_URL: string;
5
+ export declare const GRAPHQL_MILESTONE_FIELDS = "\ndescription\ndueOn\nid\nnumber\nstate\ntitle\nurl\n";
6
+ export declare const GRAPHQL_LABEL_FIELDS = "\ncolor\ndescription\nid\nname\n";
5
7
  export declare const getGraphQLEndpoint: (config: ProviderConfig, options: EnterpriseOptions) => string;
6
8
  export declare const makeGitHubGraphQLRequest: <T>(config: ProviderConfig, data: GraphQLBody, options: EnterpriseOptions) => Promise<import("../../types").Response<GraphQLResponse<T>>>;
7
9
  export declare const hasEmailScope: (scopes: string[]) => boolean;
8
10
  export declare const getAccountFields: (withAvatarSizeVar?: boolean, includeEmail?: boolean) => string;
9
11
  export declare const getBotFields: (withAvatarSizeVar?: boolean) => string;
10
- export declare const getProjectPullRequestFields: (isDraftPullRequestSupported: boolean, includeEmail?: boolean) => string;
12
+ export declare const getPullRequestFields: (isDraftPullRequestSupported: boolean, includeEmail?: boolean) => string;
13
+ export declare const getIssueFields: (includeEmail?: boolean) => string;
11
14
  export declare const GithubSearchSyntaxQualifiers: Record<string, string>;
12
15
  export declare const getProjectGithubSearchSyntax: (search: string) => string[];
13
- export declare const makeSearchPullRequestsGraphQLBody: (query: string, cursor: string | null | undefined, supportsDrafts: boolean, supportsEmail: boolean) => GraphQLBody;
16
+ export declare const makeSearchIssuesOrPRsGraphQLBody: (type: 'issue' | 'pr', query: string, cursor: string | null | undefined, supportsEmail: boolean, supportsDrafts?: boolean) => GraphQLBody;
14
17
  export declare const hasDraftsNotSupportedError: (errors?: GraphQLError[]) => boolean;
@@ -6,6 +6,12 @@ export declare enum GraphQLViewerPermission {
6
6
  TRIAGE = "TRIAGE",
7
7
  WRITE = "WRITE"
8
8
  }
9
+ export interface GraphQLLabel {
10
+ color: string;
11
+ description: string | null;
12
+ id: string;
13
+ name: string;
14
+ }
9
15
  export interface GraphQLRepository {
10
16
  id: string;
11
17
  databaseId: number;
@@ -26,6 +32,10 @@ export declare enum GitHubPullRequestReviewState {
26
32
  Commented = "COMMENTED",
27
33
  ReviewRequested = "REVIEW_REQUESTED"
28
34
  }
35
+ export declare enum GithubIssueState {
36
+ Open = "OPEN",
37
+ Closed = "CLOSED"
38
+ }
29
39
  export declare enum GitHubPullRequestMergeableState {
30
40
  Mergeable = "MERGEABLE",
31
41
  Conflicting = "CONFLICTING",
@@ -135,6 +145,10 @@ export interface GraphQLPullRequest {
135
145
  url: string;
136
146
  updatedAt: string;
137
147
  mergeable: GitHubPullRequestMergeableState;
148
+ milestone: GraphQLMilestone | null;
149
+ labels: {
150
+ nodes: GraphQLLabel[] | null;
151
+ } | null;
138
152
  }
139
153
  export interface GraphQLIssue {
140
154
  id: string;
@@ -142,6 +156,7 @@ export interface GraphQLIssue {
142
156
  number: string;
143
157
  title: string;
144
158
  url: string;
159
+ state: GithubIssueState;
145
160
  repository: {
146
161
  name: string;
147
162
  owner: {
@@ -160,6 +175,19 @@ export interface GraphQLIssue {
160
175
  reactions: {
161
176
  totalCount: number;
162
177
  };
178
+ milestone: GraphQLMilestone | null;
179
+ labels: {
180
+ nodes: GraphQLLabel[] | null;
181
+ } | null;
182
+ }
183
+ export interface GraphQLMilestone {
184
+ description: string | null;
185
+ dueOn: string | null;
186
+ id: string;
187
+ number: number;
188
+ state: string;
189
+ title: string;
190
+ url: string;
163
191
  }
164
192
  export interface FetchPullRequestsData {
165
193
  repos: GetRepoInput[];
@@ -1,4 +1,4 @@
1
- import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
1
+ import { Account, CursorPageInput, EnterpriseOptions, GetRepoErrorData, GetRepoInput, GitLabel, GitProvider, GitPullRequest, GitRepository, NumberedPageInput } from '../gitProvider';
2
2
  import { GetIssueInput, Issue, IssueProvider } from '../issueProvider';
3
3
  import { EnterpriseProvider } from '../provider';
4
4
  export type PullRequestState = 'opened' | 'merged' | 'closed';
@@ -143,6 +143,16 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
143
143
  pullRequestId: string;
144
144
  expectedSourceSha: string;
145
145
  }, options?: EnterpriseOptions): Promise<void>;
146
+ setPullRequestMilestone(input: {
147
+ repo: GetRepoInput;
148
+ pullRequestId: string;
149
+ milestoneGraphQLId: string | null;
150
+ }, options?: EnterpriseOptions): Promise<void>;
151
+ setPullRequestAsDraft(input: {
152
+ repo: GetRepoInput;
153
+ pullRequestId: string;
154
+ isDraft: boolean;
155
+ }, options?: EnterpriseOptions): Promise<void>;
146
156
  getIssue(input: GetIssueInput, options?: EnterpriseOptions): Promise<{
147
157
  data: Issue;
148
158
  }>;
@@ -176,4 +186,37 @@ export declare class GitLab extends EnterpriseProvider implements GitProvider, I
176
186
  issueId: string;
177
187
  status: 'CLOSE' | 'REOPEN';
178
188
  }, options?: EnterpriseOptions): Promise<void>;
189
+ setIssueMilestone(input: {
190
+ repo: GetRepoInput;
191
+ issueId: string;
192
+ milestoneGraphQLId: string | null;
193
+ }, options?: EnterpriseOptions): Promise<void>;
194
+ getMilestonesForRepo(input: {
195
+ repo: GetRepoInput;
196
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
197
+ pageInfo: {
198
+ endCursor: string | null;
199
+ hasNextPage: boolean;
200
+ };
201
+ data: {
202
+ id: string;
203
+ graphQLId: string;
204
+ number: number;
205
+ title: string;
206
+ description: string | null;
207
+ isOpen: boolean;
208
+ url: string;
209
+ startDate: Date | null;
210
+ dueDate: Date | null;
211
+ }[];
212
+ }>;
213
+ getLabelsForRepo(input: {
214
+ repo: GetRepoInput;
215
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
216
+ pageInfo: {
217
+ endCursor: string | null;
218
+ hasNextPage: boolean;
219
+ };
220
+ data: GitLabel[];
221
+ }>;
179
222
  }
@@ -1,5 +1,9 @@
1
1
  import { Result } from '../types';
2
- import { Account, GetReposInput, Options } from './gitProvider';
2
+ import { Account, GetReposInput, GitLabel, GitMilestone, Options } from './gitProvider';
3
+ export declare enum GitIssueState {
4
+ Open = "OPEN",
5
+ Closed = "CLOSED"
6
+ }
3
7
  export interface GetIssueInput {
4
8
  id: string;
5
9
  name: string;
@@ -9,6 +13,10 @@ export interface GetIssueInput {
9
13
  export type GetIssuesForReposInput = GetReposInput | {
10
14
  repoIds: (string | number)[];
11
15
  };
16
+ export interface IssueTransition {
17
+ id: string;
18
+ name: string;
19
+ }
12
20
  export interface Issue {
13
21
  author: Account | null;
14
22
  assignees: Account[];
@@ -17,6 +25,7 @@ export interface Issue {
17
25
  description: string | null;
18
26
  graphQLId?: string;
19
27
  id: string;
28
+ labels: GitLabel[];
20
29
  number: string;
21
30
  repository: {
22
31
  name: string;
@@ -24,12 +33,17 @@ export interface Issue {
24
33
  login?: string;
25
34
  };
26
35
  } | null;
27
- state: string | null;
36
+ state: {
37
+ name: string;
38
+ color: string | null;
39
+ } | null;
40
+ statusTransitions?: IssueTransition[];
28
41
  title: string;
29
42
  type: string | null;
30
43
  updatedDate: Date | null;
31
44
  upvoteCount: number | null;
32
45
  url: string;
46
+ milestone?: GitMilestone | null;
33
47
  }
34
48
  export interface IssueProvider {
35
49
  getIssue(input: GetIssueInput, options: Options): Promise<Result<Issue>>;
@@ -8,6 +8,7 @@ export interface JiraResource {
8
8
  avatarUrl: string;
9
9
  }
10
10
  export interface JiraProject {
11
+ id: string;
11
12
  name: string;
12
13
  resourceId: string;
13
14
  }
@@ -21,6 +22,7 @@ export declare class Jira extends Provider {
21
22
  endCursor: string;
22
23
  };
23
24
  data: {
25
+ id: string;
24
26
  name: string;
25
27
  resourceId: string;
26
28
  }[];
@@ -42,4 +44,18 @@ export declare class Jira extends Provider {
42
44
  issueId: string;
43
45
  status: string;
44
46
  }, options?: EnterpriseOptions): Promise<void>;
47
+ getLabelsForResource(input: {
48
+ resourceId: string;
49
+ } & CursorPageInput, options?: EnterpriseOptions): Promise<{
50
+ pageInfo: {
51
+ hasNextPage: boolean;
52
+ endCursor: string;
53
+ };
54
+ data: {
55
+ color: null;
56
+ description: null;
57
+ id: null;
58
+ name: string;
59
+ }[];
60
+ }>;
45
61
  }
@@ -2,6 +2,24 @@ import { Result } from '../../types';
2
2
  import { EnterpriseOptions } from '../gitProvider';
3
3
  import { Issue } from '../issueProvider';
4
4
  import { Provider } from '../provider';
5
+ interface TrelloList {
6
+ id: string;
7
+ name: string;
8
+ closed: boolean;
9
+ pos: number;
10
+ softLimit: string;
11
+ idBoard: string;
12
+ subscribed: boolean;
13
+ limits: {
14
+ attachments: {
15
+ perBoard: {
16
+ status: string;
17
+ disableAt: number;
18
+ warnAt: number;
19
+ };
20
+ };
21
+ };
22
+ }
5
23
  export interface TrelloBoard {
6
24
  id: string;
7
25
  name: string;
@@ -10,11 +28,20 @@ export declare class Trello extends Provider {
10
28
  getBoardsForCurrentUser(input: {
11
29
  appKey: string;
12
30
  }, options?: EnterpriseOptions): Promise<Result<TrelloBoard[]>>;
31
+ getListsForTrelloBoard(input: {
32
+ appKey: string;
33
+ boardId: string;
34
+ }, options?: EnterpriseOptions): Promise<{
35
+ data: TrelloList[];
36
+ }>;
13
37
  getIssuesForBoard(input: {
14
38
  appKey: string;
15
39
  boardId: string;
16
40
  filterText?: string;
17
41
  assigneeLogins?: string[];
42
+ trelloBoardListsById?: Record<string, {
43
+ name: string;
44
+ }>;
18
45
  }, options?: EnterpriseOptions): Promise<{
19
46
  data: Issue[];
20
47
  }>;
@@ -23,4 +50,16 @@ export declare class Trello extends Provider {
23
50
  cardId: string;
24
51
  status: string;
25
52
  }, options?: EnterpriseOptions): Promise<void>;
53
+ getLabelsForBoard(input: {
54
+ appKey: string;
55
+ boardId: string;
56
+ }, options?: EnterpriseOptions): Promise<{
57
+ data: {
58
+ color: string;
59
+ description: null;
60
+ id: string;
61
+ name: string;
62
+ }[];
63
+ }>;
26
64
  }
65
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitkraken/provider-apis",
3
- "version": "0.10.0",
3
+ "version": "0.11.1",
4
4
  "description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
5
5
  "author": "Axosoft, LLC dba GitKraken",
6
6
  "license": "SEE LICENSE IN LICENSE",