@gitkraken/core-gitlens 0.3.1 → 0.4.0
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.
- package/CHANGELOG.md +13 -1
- package/README.md +13 -10
- package/dist/git/context.d.ts +4 -3
- package/dist/git/context.d.ts.map +1 -1
- package/dist/git/context.js.map +1 -1
- package/dist/git/providers/operations.d.ts +1 -0
- package/dist/git/providers/operations.d.ts.map +1 -1
- package/dist/git/providers/worktrees.d.ts +2 -0
- package/dist/git/providers/worktrees.d.ts.map +1 -1
- package/dist/git/utils/conflictResolution.utils.d.ts +32 -0
- package/dist/git/utils/conflictResolution.utils.d.ts.map +1 -1
- package/dist/git/utils/conflictResolution.utils.js +95 -0
- package/dist/git/utils/conflictResolution.utils.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +1 -0
- package/dist/git-cli/providers/operations.d.ts.map +1 -1
- package/dist/git-cli/providers/operations.js +22 -1
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/worktrees.d.ts +2 -0
- package/dist/git-cli/providers/worktrees.d.ts.map +1 -1
- package/dist/git-cli/providers/worktrees.js +3 -0
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/plus/ai/utils/ai.utils.js +5 -5
- package/dist/plus/ai/utils/ai.utils.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +6 -13
- package/dist/plus/git-github/api/github.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.js +5 -10
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationService.d.ts +11 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.js +90 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +67 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +295 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +92 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +185 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +62 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +122 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.d.ts +15 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.js +49 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/models.d.ts +87 -0
- package/dist/plus/integrations/authentication/models.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/models.js +64 -0
- package/dist/plus/integrations/authentication/models.js.map +1 -0
- package/dist/plus/integrations/constants.d.ts +47 -0
- package/dist/plus/integrations/constants.d.ts.map +1 -0
- package/dist/plus/integrations/constants.js +128 -0
- package/dist/plus/integrations/constants.js.map +1 -0
- package/dist/plus/integrations/context.d.ts +354 -0
- package/dist/plus/integrations/context.d.ts.map +1 -0
- package/dist/plus/integrations/context.js +2 -0
- package/dist/plus/integrations/context.js.map +1 -0
- package/dist/plus/integrations/errors.d.ts +14 -0
- package/dist/plus/integrations/errors.d.ts.map +1 -0
- package/dist/plus/integrations/errors.js +19 -0
- package/dist/plus/integrations/errors.js.map +1 -0
- package/dist/plus/integrations/index.d.ts +32 -0
- package/dist/plus/integrations/index.d.ts.map +1 -0
- package/dist/plus/integrations/index.js +62 -0
- package/dist/plus/integrations/index.js.map +1 -0
- package/dist/plus/integrations/integrationService.d.ts +98 -0
- package/dist/plus/integrations/integrationService.d.ts.map +1 -0
- package/dist/plus/integrations/integrationService.js +627 -0
- package/dist/plus/integrations/integrationService.js.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +82 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.js +522 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -0
- package/dist/plus/integrations/models/integration.d.ts +127 -0
- package/dist/plus/integrations/models/integration.d.ts.map +1 -0
- package/dist/plus/integrations/models/integration.js +456 -0
- package/dist/plus/integrations/models/integration.js.map +1 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts +28 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts.map +1 -0
- package/dist/plus/integrations/models/issuesIntegration.js +101 -0
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -0
- package/dist/plus/integrations/providers/apiClients.d.ts +25 -0
- package/dist/plus/integrations/providers/apiClients.d.ts.map +1 -0
- package/dist/plus/integrations/providers/apiClients.js +39 -0
- package/dist/plus/integrations/providers/apiClients.js.map +1 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts +47 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azure/azure.js +444 -0
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -0
- package/dist/plus/integrations/providers/azure/models.d.ts +286 -0
- package/dist/plus/integrations/providers/azure/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azure/models.js +203 -0
- package/dist/plus/integrations/providers/azure/models.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +95 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.js +432 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +42 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +513 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/models.d.ts +222 -0
- package/dist/plus/integrations/providers/bitbucket/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/models.js +158 -0
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts +120 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.js +111 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +60 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.js +138 -0
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket.d.ts +50 -0
- package/dist/plus/integrations/providers/bitbucket.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket.js +181 -0
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -0
- package/dist/plus/integrations/providers/github/github.d.ts +5 -0
- package/dist/plus/integrations/providers/github/github.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/github.js +47 -0
- package/dist/plus/integrations/providers/github/github.js.map +1 -0
- package/dist/plus/integrations/providers/github/github.utils.d.ts +11 -0
- package/dist/plus/integrations/providers/github/github.utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/github.utils.js +6 -0
- package/dist/plus/integrations/providers/github/github.utils.js.map +1 -0
- package/dist/plus/integrations/providers/github/models.d.ts +3 -0
- package/dist/plus/integrations/providers/github/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/models.js +2 -0
- package/dist/plus/integrations/providers/github/models.js.map +1 -0
- package/dist/plus/integrations/providers/github.d.ts +73 -0
- package/dist/plus/integrations/providers/github.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github.js +160 -0
- package/dist/plus/integrations/providers/github.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +63 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +828 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +21 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +45 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/models.d.ts +128 -0
- package/dist/plus/integrations/providers/gitlab/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/models.js +96 -0
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab.d.ts +79 -0
- package/dist/plus/integrations/providers/gitlab.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab.js +253 -0
- package/dist/plus/integrations/providers/gitlab.js.map +1 -0
- package/dist/plus/integrations/providers/jira.d.ts +46 -0
- package/dist/plus/integrations/providers/jira.d.ts.map +1 -0
- package/dist/plus/integrations/providers/jira.js +255 -0
- package/dist/plus/integrations/providers/jira.js.map +1 -0
- package/dist/plus/integrations/providers/linear.d.ts +47 -0
- package/dist/plus/integrations/providers/linear.d.ts.map +1 -0
- package/dist/plus/integrations/providers/linear.js +198 -0
- package/dist/plus/integrations/providers/linear.js.map +1 -0
- package/dist/plus/integrations/providers/models.d.ts +433 -0
- package/dist/plus/integrations/providers/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/models.js +602 -0
- package/dist/plus/integrations/providers/models.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +129 -0
- package/dist/plus/integrations/providers/providersApi.d.ts.map +1 -0
- package/dist/plus/integrations/providers/providersApi.js +602 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -0
- package/dist/plus/integrations/providers/utils.d.ts +54 -0
- package/dist/plus/integrations/providers/utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/utils.js +262 -0
- package/dist/plus/integrations/providers/utils.js.map +1 -0
- package/dist/plus/integrations/telemetry.d.ts +26 -0
- package/dist/plus/integrations/telemetry.d.ts.map +1 -0
- package/dist/plus/integrations/telemetry.js +11 -0
- package/dist/plus/integrations/telemetry.js.map +1 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts +14 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts.map +1 -0
- package/dist/plus/integrations/utils/integration.utils.js +111 -0
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -0
- package/dist/utils/disposable.d.ts +15 -2
- package/dist/utils/disposable.d.ts.map +1 -1
- package/dist/utils/disposable.js.map +1 -1
- package/package.json +43 -2
- package/src/git/context.ts +4 -3
- package/src/git/providers/operations.ts +1 -1
- package/src/git/providers/worktrees.ts +14 -2
- package/src/git/utils/conflictResolution.utils.ts +126 -0
- package/src/git-cli/providers/operations.ts +22 -2
- package/src/git-cli/providers/worktrees.ts +17 -2
- package/src/plus/ai/utils/ai.utils.ts +5 -5
- package/src/plus/git-github/api/github.ts +13 -25
- package/src/plus/integrations/authentication/cloudIntegrationService.ts +120 -0
- package/src/plus/integrations/authentication/configuredIntegrationService.ts +414 -0
- package/src/plus/integrations/authentication/integrationAuthenticationProvider.ts +289 -0
- package/src/plus/integrations/authentication/integrationAuthenticationService.ts +144 -0
- package/src/plus/integrations/authentication/manualTokenProvider.ts +72 -0
- package/src/plus/integrations/authentication/models.ts +168 -0
- package/src/plus/integrations/constants.ts +169 -0
- package/src/plus/integrations/context.ts +383 -0
- package/src/plus/integrations/errors.ts +35 -0
- package/src/plus/integrations/index.ts +119 -0
- package/src/plus/integrations/integrationService.ts +924 -0
- package/src/plus/integrations/models/gitHostIntegration.ts +738 -0
- package/src/plus/integrations/models/integration.ts +657 -0
- package/src/plus/integrations/models/issuesIntegration.ts +124 -0
- package/src/plus/integrations/providers/apiClients.ts +72 -0
- package/src/plus/integrations/providers/azure/azure.ts +691 -0
- package/src/plus/integrations/providers/azure/models.ts +605 -0
- package/src/plus/integrations/providers/azureDevOps.ts +677 -0
- package/src/plus/integrations/providers/bitbucket/bitbucket.ts +774 -0
- package/src/plus/integrations/providers/bitbucket/models.ts +445 -0
- package/src/plus/integrations/providers/bitbucket-server/models.ts +252 -0
- package/src/plus/integrations/providers/bitbucket-server.ts +282 -0
- package/src/plus/integrations/providers/bitbucket.ts +350 -0
- package/src/plus/integrations/providers/github/github.ts +64 -0
- package/src/plus/integrations/providers/github/github.utils.ts +23 -0
- package/src/plus/integrations/providers/github/models.ts +29 -0
- package/src/plus/integrations/providers/github.ts +366 -0
- package/src/plus/integrations/providers/gitlab/gitlab.ts +1210 -0
- package/src/plus/integrations/providers/gitlab/gitlab.utils.ts +71 -0
- package/src/plus/integrations/providers/gitlab/models.ts +257 -0
- package/src/plus/integrations/providers/gitlab.ts +473 -0
- package/src/plus/integrations/providers/jira.ts +359 -0
- package/src/plus/integrations/providers/linear.ts +275 -0
- package/src/plus/integrations/providers/models.ts +1114 -0
- package/src/plus/integrations/providers/providersApi.ts +1126 -0
- package/src/plus/integrations/providers/utils.ts +359 -0
- package/src/plus/integrations/telemetry.ts +29 -0
- package/src/plus/integrations/utils/integration.utils.ts +138 -0
- package/src/utils/disposable.ts +15 -2
|
@@ -0,0 +1,1114 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Account,
|
|
3
|
+
ActionablePullRequest,
|
|
4
|
+
AnyEntityIdentifierInput,
|
|
5
|
+
AzureDevOps,
|
|
6
|
+
AzureOrganization,
|
|
7
|
+
AzureProject,
|
|
8
|
+
AzureSetPullRequestInput,
|
|
9
|
+
Bitbucket,
|
|
10
|
+
BitbucketServer,
|
|
11
|
+
BitbucketWorkspaceStub,
|
|
12
|
+
EnterpriseOptions,
|
|
13
|
+
GetRepoInput,
|
|
14
|
+
GitHub,
|
|
15
|
+
GitLab,
|
|
16
|
+
GitMergeStrategy,
|
|
17
|
+
GitPullRequest,
|
|
18
|
+
GitRepository,
|
|
19
|
+
Jira,
|
|
20
|
+
JiraProject,
|
|
21
|
+
JiraResource,
|
|
22
|
+
Linear,
|
|
23
|
+
LinearOrganization,
|
|
24
|
+
LinearTeam,
|
|
25
|
+
NumberedPageInput,
|
|
26
|
+
Issue as ProviderApiIssue,
|
|
27
|
+
PullRequestWithUniqueID,
|
|
28
|
+
RequestFunction,
|
|
29
|
+
RequestOptions,
|
|
30
|
+
Response,
|
|
31
|
+
SetPullRequestInput,
|
|
32
|
+
Trello,
|
|
33
|
+
} from '@gitkraken/provider-apis';
|
|
34
|
+
import {
|
|
35
|
+
GitBuildStatusState,
|
|
36
|
+
GitPullRequestMergeableState,
|
|
37
|
+
GitPullRequestReviewState,
|
|
38
|
+
GitPullRequestState,
|
|
39
|
+
} from '@gitkraken/provider-apis';
|
|
40
|
+
import { EntityIdentifierUtils } from '@gitkraken/provider-apis/entity-identifiers';
|
|
41
|
+
import { GitProviderUtils } from '@gitkraken/provider-apis/provider-utils';
|
|
42
|
+
import type { Account as UserAccount } from '../../../git/models/author.js';
|
|
43
|
+
import type { IssueMember, IssueProject, IssueShape } from '../../../git/models/issue.js';
|
|
44
|
+
import { Issue, RepositoryAccessLevel } from '../../../git/models/issue.js';
|
|
45
|
+
import type {
|
|
46
|
+
PullRequestMember,
|
|
47
|
+
PullRequestRefs,
|
|
48
|
+
PullRequestRepositoryIdentityDescriptor,
|
|
49
|
+
PullRequestReviewer,
|
|
50
|
+
PullRequestState,
|
|
51
|
+
} from '../../../git/models/pullRequest.js';
|
|
52
|
+
import {
|
|
53
|
+
PullRequest,
|
|
54
|
+
PullRequestMergeableState,
|
|
55
|
+
PullRequestReviewDecision,
|
|
56
|
+
PullRequestReviewState,
|
|
57
|
+
PullRequestStatusCheckRollupState,
|
|
58
|
+
} from '../../../git/models/pullRequest.js';
|
|
59
|
+
import type { Provider, ProviderReference } from '../../../git/models/remoteProvider.js';
|
|
60
|
+
import { gitSuffixRegex } from '../../../git/utils/remote.utils.js';
|
|
61
|
+
import { equalsIgnoreCase } from '../../../utils/string.js';
|
|
62
|
+
import type { IntegrationIds } from '../constants.js';
|
|
63
|
+
import {
|
|
64
|
+
GitCloudHostIntegrationId,
|
|
65
|
+
GitSelfManagedHostIntegrationId,
|
|
66
|
+
IssuesCloudHostIntegrationId,
|
|
67
|
+
} from '../constants.js';
|
|
68
|
+
import type { Integration, IntegrationType } from '../models/integration.js';
|
|
69
|
+
import { getEntityIdentifierInput } from './utils.js';
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Forward-only host type — the package only sets `EnrichablePullRequest.enrichable`
|
|
73
|
+
* for the host to consume. Typed as `any` to avoid duplicating the host's
|
|
74
|
+
* `EnrichableItem` shape.
|
|
75
|
+
*/
|
|
76
|
+
type EnrichableItem = any;
|
|
77
|
+
|
|
78
|
+
export type ProviderAccount = Account;
|
|
79
|
+
export type ProviderReposInput = (string | number)[] | GetRepoInput[];
|
|
80
|
+
export type ProviderRepoInput = GetRepoInput;
|
|
81
|
+
export type ProviderPullRequest = GitPullRequest;
|
|
82
|
+
export type ProviderRepository = GitRepository;
|
|
83
|
+
export type ProviderIssue = ProviderApiIssue;
|
|
84
|
+
export type ProviderEnterpriseOptions = EnterpriseOptions;
|
|
85
|
+
export type ProviderJiraProject = JiraProject;
|
|
86
|
+
export type ProviderJiraResource = JiraResource;
|
|
87
|
+
export type ProviderLinearTeam = LinearTeam;
|
|
88
|
+
export type ProviderLinearOrganization = LinearOrganization;
|
|
89
|
+
export type ProviderAzureProject = AzureProject;
|
|
90
|
+
export type ProviderAzureResource = AzureOrganization;
|
|
91
|
+
export type ProviderBitbucketResource = BitbucketWorkspaceStub;
|
|
92
|
+
export const ProviderPullRequestReviewState = GitPullRequestReviewState;
|
|
93
|
+
export const ProviderBuildStatusState = GitBuildStatusState;
|
|
94
|
+
export type ProviderRequestFunction = RequestFunction;
|
|
95
|
+
export type ProviderRequestResponse<T> = Response<T>;
|
|
96
|
+
export type ProviderRequestOptions = RequestOptions;
|
|
97
|
+
|
|
98
|
+
export enum PullRequestFilter {
|
|
99
|
+
Author = 'author',
|
|
100
|
+
Assignee = 'assignee',
|
|
101
|
+
ReviewRequested = 'review-requested',
|
|
102
|
+
Mention = 'mention',
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export enum IssueFilter {
|
|
106
|
+
Author = 'author',
|
|
107
|
+
Assignee = 'assignee',
|
|
108
|
+
Mention = 'mention',
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export enum PagingMode {
|
|
112
|
+
Project = 'project',
|
|
113
|
+
Repo = 'repo',
|
|
114
|
+
Repos = 'repos',
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface PagingInput {
|
|
118
|
+
cursor?: string | null;
|
|
119
|
+
page?: number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface PagedRepoInput {
|
|
123
|
+
repo: GetRepoInput;
|
|
124
|
+
cursor?: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface PagedProjectInput {
|
|
128
|
+
namespace: string;
|
|
129
|
+
project: string;
|
|
130
|
+
cursor?: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface GetPullRequestsOptions {
|
|
134
|
+
authorLogin?: string;
|
|
135
|
+
assigneeLogins?: string[];
|
|
136
|
+
reviewRequestedLogin?: string;
|
|
137
|
+
mentionLogin?: string;
|
|
138
|
+
query?: string;
|
|
139
|
+
cursor?: string; // stringified JSON object of type { type: 'cursor' | 'page'; value: string | number } | {}
|
|
140
|
+
baseUrl?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface GetPullRequestsForUserOptions {
|
|
144
|
+
includeFromArchivedRepos?: boolean;
|
|
145
|
+
cursor?: string; // stringified JSON object of type { type: 'cursor' | 'page'; value: string | number } | {}
|
|
146
|
+
baseUrl?: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface GetPullRequestsForUserInput extends GetPullRequestsForUserOptions {
|
|
150
|
+
userId: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface GetPullRequestsAssociatedWithUserInput extends GetPullRequestsForUserOptions {
|
|
154
|
+
username: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface GetPullRequestsForRepoInput extends GetPullRequestsOptions {
|
|
158
|
+
repo: GetRepoInput;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface GetPullRequestsForReposInput extends GetPullRequestsOptions {
|
|
162
|
+
repos: GetRepoInput[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface GetPullRequestsForRepoIdsInput extends GetPullRequestsOptions {
|
|
166
|
+
repoIds: (string | number)[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface GetIssuesOptions {
|
|
170
|
+
authorLogin?: string;
|
|
171
|
+
assigneeLogins?: string[];
|
|
172
|
+
mentionLogin?: string;
|
|
173
|
+
cursor?: string; // stringified JSON object of type { type: 'cursor' | 'page'; value: string | number } | {}
|
|
174
|
+
baseUrl?: string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface GetIssuesForRepoInput extends GetIssuesOptions {
|
|
178
|
+
repo: GetRepoInput;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export interface GetIssuesForReposInput extends GetIssuesOptions {
|
|
182
|
+
repos: GetRepoInput[];
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface GetIssuesForRepoIdsInput extends GetIssuesOptions {
|
|
186
|
+
repoIds: (string | number)[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface GetIssuesForProjectInput extends GetIssuesOptions {
|
|
190
|
+
project: string;
|
|
191
|
+
resourceId: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface GetIssuesForAzureProjectInput extends GetIssuesOptions {
|
|
195
|
+
namespace: string;
|
|
196
|
+
project: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface GetReposOptions {
|
|
200
|
+
cursor?: string; // stringified JSON object of type { type: 'cursor' | 'page'; value: string | number } | {}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface GetReposForAzureProjectInput {
|
|
204
|
+
namespace: string;
|
|
205
|
+
project: string;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface PageInfo {
|
|
209
|
+
hasNextPage: boolean;
|
|
210
|
+
endCursor?: string | null;
|
|
211
|
+
nextPage?: number | null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export type GetRepoFn = (
|
|
215
|
+
input: ProviderRepoInput,
|
|
216
|
+
options?: EnterpriseOptions,
|
|
217
|
+
) => Promise<{ data: ProviderRepository }>;
|
|
218
|
+
export type GetRepoOfProjectFn = (
|
|
219
|
+
input: ProviderRepoInput & { project: string },
|
|
220
|
+
options?: EnterpriseOptions,
|
|
221
|
+
) => Promise<{ data: ProviderRepository }>;
|
|
222
|
+
|
|
223
|
+
export type GetPullRequestsForReposFn = (
|
|
224
|
+
input: (GetPullRequestsForReposInput | GetPullRequestsForRepoIdsInput) & PagingInput,
|
|
225
|
+
options?: EnterpriseOptions,
|
|
226
|
+
) => Promise<{ data: ProviderPullRequest[]; pageInfo?: PageInfo }>;
|
|
227
|
+
|
|
228
|
+
export type GetPullRequestsForRepoFn = (
|
|
229
|
+
input: GetPullRequestsForRepoInput & PagingInput,
|
|
230
|
+
options?: EnterpriseOptions,
|
|
231
|
+
) => Promise<{ data: ProviderPullRequest[]; pageInfo?: PageInfo }>;
|
|
232
|
+
|
|
233
|
+
export type GetPullRequestsForUserFn = (
|
|
234
|
+
input: GetPullRequestsForUserInput | GetPullRequestsAssociatedWithUserInput,
|
|
235
|
+
options?: EnterpriseOptions,
|
|
236
|
+
) => Promise<{ data: ProviderPullRequest[]; pageInfo?: PageInfo }>;
|
|
237
|
+
|
|
238
|
+
export type GetPullRequestsForAzureProjectsFn = (
|
|
239
|
+
input: { projects: { namespace: string; project: string }[]; authorLogin?: string; assigneeLogins?: string[] },
|
|
240
|
+
options?: EnterpriseOptions,
|
|
241
|
+
) => Promise<{ data: ProviderPullRequest[] }>;
|
|
242
|
+
|
|
243
|
+
export type MergePullRequestFn =
|
|
244
|
+
| ((
|
|
245
|
+
input: {
|
|
246
|
+
pullRequest: {
|
|
247
|
+
headRef: {
|
|
248
|
+
oid: string | null;
|
|
249
|
+
} | null;
|
|
250
|
+
version?: number; // Used by BitbucketServer
|
|
251
|
+
} & SetPullRequestInput;
|
|
252
|
+
mergeStrategy?: GitMergeStrategy;
|
|
253
|
+
},
|
|
254
|
+
options?: EnterpriseOptions,
|
|
255
|
+
) => Promise<void>)
|
|
256
|
+
| ((
|
|
257
|
+
input: {
|
|
258
|
+
pullRequest: {
|
|
259
|
+
headRef: {
|
|
260
|
+
oid: string | null;
|
|
261
|
+
} | null;
|
|
262
|
+
} & SetPullRequestInput;
|
|
263
|
+
mergeStrategy?: GitMergeStrategy.Squash;
|
|
264
|
+
},
|
|
265
|
+
options?: EnterpriseOptions,
|
|
266
|
+
) => Promise<void>)
|
|
267
|
+
| ((
|
|
268
|
+
input: {
|
|
269
|
+
pullRequest: {
|
|
270
|
+
headRef: {
|
|
271
|
+
oid: string;
|
|
272
|
+
};
|
|
273
|
+
} & AzureSetPullRequestInput;
|
|
274
|
+
mergeStrategy?:
|
|
275
|
+
| GitMergeStrategy.MergeCommit
|
|
276
|
+
| GitMergeStrategy.Rebase
|
|
277
|
+
| GitMergeStrategy.RebaseThenMergeCommit
|
|
278
|
+
| GitMergeStrategy.Squash;
|
|
279
|
+
},
|
|
280
|
+
options?: EnterpriseOptions,
|
|
281
|
+
) => Promise<void>);
|
|
282
|
+
|
|
283
|
+
export type GetIssueFn = (
|
|
284
|
+
input:
|
|
285
|
+
| { resourceId: string; number: string } // jira
|
|
286
|
+
| { namespace: string; name: string; number: string }, // gitlab
|
|
287
|
+
options?: EnterpriseOptions,
|
|
288
|
+
) => Promise<{ data: ProviderIssue }>;
|
|
289
|
+
|
|
290
|
+
export type GetIssuesForReposFn = (
|
|
291
|
+
input: (GetIssuesForReposInput | GetIssuesForRepoIdsInput) & PagingInput,
|
|
292
|
+
options?: EnterpriseOptions,
|
|
293
|
+
) => Promise<{ data: ProviderIssue[]; pageInfo?: PageInfo }>;
|
|
294
|
+
|
|
295
|
+
export type GetIssuesForCurrentUserFn = (
|
|
296
|
+
input: PagingInput,
|
|
297
|
+
options?: EnterpriseOptions,
|
|
298
|
+
) => Promise<{ data: ProviderIssue[]; pageInfo?: PageInfo }>;
|
|
299
|
+
|
|
300
|
+
export type GetIssuesForRepoFn = (
|
|
301
|
+
input: GetIssuesForRepoInput & PagingInput,
|
|
302
|
+
options?: EnterpriseOptions,
|
|
303
|
+
) => Promise<{ data: ProviderIssue[]; pageInfo?: PageInfo }>;
|
|
304
|
+
|
|
305
|
+
export type GetIssuesForAzureProjectFn = (
|
|
306
|
+
input: GetIssuesForAzureProjectInput & PagingInput,
|
|
307
|
+
options?: EnterpriseOptions,
|
|
308
|
+
) => Promise<{ data: ProviderIssue[]; pageInfo?: PageInfo }>;
|
|
309
|
+
|
|
310
|
+
export type GetReposForAzureProjectFn = (
|
|
311
|
+
input: GetReposForAzureProjectInput & PagingInput,
|
|
312
|
+
options?: EnterpriseOptions,
|
|
313
|
+
) => Promise<{ data: ProviderRepository[]; pageInfo?: PageInfo }>;
|
|
314
|
+
|
|
315
|
+
export type GetCurrentUserFn = (
|
|
316
|
+
input: Record<string, never>,
|
|
317
|
+
options?: EnterpriseOptions,
|
|
318
|
+
) => Promise<{ data: ProviderAccount }>;
|
|
319
|
+
export type GetCurrentUserForInstanceFn = (
|
|
320
|
+
input: { namespace: string },
|
|
321
|
+
options?: EnterpriseOptions,
|
|
322
|
+
) => Promise<{ data: ProviderAccount }>;
|
|
323
|
+
export type GetCurrentUserForResourceFn = (
|
|
324
|
+
input: { resourceId: string },
|
|
325
|
+
options?: EnterpriseOptions,
|
|
326
|
+
) => Promise<{ data: ProviderAccount }>;
|
|
327
|
+
|
|
328
|
+
export type GetJiraResourcesForCurrentUserFn = (options?: EnterpriseOptions) => Promise<{ data: JiraResource[] }>;
|
|
329
|
+
export type GetLinearOrganizationFn = (options?: EnterpriseOptions) => Promise<{ data: LinearOrganization }>;
|
|
330
|
+
export type GetLinearTeamsForCurrentUserFn = (options?: EnterpriseOptions) => Promise<{ data: LinearTeam[] }>;
|
|
331
|
+
export type GetJiraProjectsForResourcesFn = (
|
|
332
|
+
input: { resourceIds: string[] },
|
|
333
|
+
options?: EnterpriseOptions,
|
|
334
|
+
) => Promise<{ data: JiraProject[] }>;
|
|
335
|
+
export type GetAzureResourcesForUserFn = (
|
|
336
|
+
input: { userId: string },
|
|
337
|
+
options?: EnterpriseOptions,
|
|
338
|
+
) => Promise<{ data: AzureOrganization[] }>;
|
|
339
|
+
export type GetAzureProjectsForResourceFn = (
|
|
340
|
+
input: { namespace: string; cursor?: string },
|
|
341
|
+
options?: EnterpriseOptions,
|
|
342
|
+
) => Promise<{ data: AzureProject[]; pageInfo?: PageInfo }>;
|
|
343
|
+
export type GetBitbucketResourcesForCurrentUserFn = (
|
|
344
|
+
input: Record<string, never>,
|
|
345
|
+
options?: EnterpriseOptions,
|
|
346
|
+
) => Promise<{ data: BitbucketWorkspaceStub[] }>;
|
|
347
|
+
export type GetBitbucketPullRequestsAuthoredByUserForWorkspaceFn = (
|
|
348
|
+
input: {
|
|
349
|
+
userId: string;
|
|
350
|
+
workspaceSlug: string;
|
|
351
|
+
} & NumberedPageInput,
|
|
352
|
+
options?: EnterpriseOptions,
|
|
353
|
+
) => Promise<{
|
|
354
|
+
pageInfo: {
|
|
355
|
+
hasNextPage: boolean;
|
|
356
|
+
nextPage: number | null;
|
|
357
|
+
};
|
|
358
|
+
data: GitPullRequest[];
|
|
359
|
+
}>;
|
|
360
|
+
export type GetBitbucketServerPullRequestsForCurrentUserFn = (
|
|
361
|
+
input: NumberedPageInput,
|
|
362
|
+
options?: EnterpriseOptions,
|
|
363
|
+
) => Promise<{
|
|
364
|
+
pageInfo: {
|
|
365
|
+
hasNextPage: boolean;
|
|
366
|
+
nextPage: number | null;
|
|
367
|
+
};
|
|
368
|
+
data: GitPullRequest[];
|
|
369
|
+
}>;
|
|
370
|
+
export type GetIssuesForProjectFn = Jira['getIssuesForProject'];
|
|
371
|
+
export type GetIssuesForResourceForCurrentUserFn = (
|
|
372
|
+
input: { resourceId: string },
|
|
373
|
+
options?: EnterpriseOptions,
|
|
374
|
+
) => Promise<{ data: ProviderIssue[] }>;
|
|
375
|
+
|
|
376
|
+
export interface ProviderInfo extends ProviderMetadata {
|
|
377
|
+
provider: GitHub | GitLab | Bitbucket | BitbucketServer | Jira | Linear | Trello | AzureDevOps;
|
|
378
|
+
getRepoFn?: GetRepoFn;
|
|
379
|
+
getRepoOfProjectFn?: GetRepoOfProjectFn;
|
|
380
|
+
getPullRequestsForReposFn?: GetPullRequestsForReposFn;
|
|
381
|
+
getPullRequestsForRepoFn?: GetPullRequestsForRepoFn;
|
|
382
|
+
getPullRequestsForUserFn?: GetPullRequestsForUserFn;
|
|
383
|
+
getPullRequestsForAzureProjectsFn?: GetPullRequestsForAzureProjectsFn;
|
|
384
|
+
getIssueFn?: GetIssueFn;
|
|
385
|
+
getIssuesForReposFn?: GetIssuesForReposFn;
|
|
386
|
+
getIssuesForCurrentUserFn?: GetIssuesForCurrentUserFn;
|
|
387
|
+
getIssuesForRepoFn?: GetIssuesForRepoFn;
|
|
388
|
+
getIssuesForAzureProjectFn?: GetIssuesForAzureProjectFn;
|
|
389
|
+
getCurrentUserFn?: GetCurrentUserFn;
|
|
390
|
+
getCurrentUserForInstanceFn?: GetCurrentUserForInstanceFn;
|
|
391
|
+
getCurrentUserForResourceFn?: GetCurrentUserForResourceFn;
|
|
392
|
+
getJiraResourcesForCurrentUserFn?: GetJiraResourcesForCurrentUserFn;
|
|
393
|
+
getLinearOrganizationFn?: GetLinearOrganizationFn;
|
|
394
|
+
getLinearTeamsForCurrentUserFn?: GetLinearTeamsForCurrentUserFn;
|
|
395
|
+
getAzureResourcesForUserFn?: GetAzureResourcesForUserFn;
|
|
396
|
+
getBitbucketResourcesForCurrentUserFn?: GetBitbucketResourcesForCurrentUserFn;
|
|
397
|
+
getBitbucketPullRequestsAuthoredByUserForWorkspaceFn?: GetBitbucketPullRequestsAuthoredByUserForWorkspaceFn;
|
|
398
|
+
getBitbucketServerPullRequestsForCurrentUserFn?: GetBitbucketServerPullRequestsForCurrentUserFn;
|
|
399
|
+
getJiraProjectsForResourcesFn?: GetJiraProjectsForResourcesFn;
|
|
400
|
+
getAzureProjectsForResourceFn?: GetAzureProjectsForResourceFn;
|
|
401
|
+
getIssuesForProjectFn?: GetIssuesForProjectFn;
|
|
402
|
+
getReposForAzureProjectFn?: GetReposForAzureProjectFn;
|
|
403
|
+
getIssuesForResourceForCurrentUserFn?: GetIssuesForResourceForCurrentUserFn;
|
|
404
|
+
mergePullRequestFn?: MergePullRequestFn;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export interface ProviderMetadata {
|
|
408
|
+
domain: string;
|
|
409
|
+
id: IntegrationIds;
|
|
410
|
+
name: string;
|
|
411
|
+
type: IntegrationType;
|
|
412
|
+
/** Key for the `gl-provider-<iconKey>` glicon. Cloud self-managed variants reuse the base
|
|
413
|
+
* `'github-enterprise'`/`'gitlab-self-hosted'` icon (no enum member exists for those anymore). */
|
|
414
|
+
iconKey: string;
|
|
415
|
+
issuesPagingMode?: PagingMode;
|
|
416
|
+
pullRequestsPagingMode?: PagingMode;
|
|
417
|
+
scopes: string[];
|
|
418
|
+
supportedPullRequestFilters?: PullRequestFilter[];
|
|
419
|
+
supportedIssueFilters?: IssueFilter[];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export type Providers = Record<IntegrationIds, ProviderInfo>;
|
|
423
|
+
export type ProvidersMetadata = Record<IntegrationIds, ProviderMetadata>;
|
|
424
|
+
|
|
425
|
+
export const providersMetadata: ProvidersMetadata = {
|
|
426
|
+
[GitCloudHostIntegrationId.GitHub]: {
|
|
427
|
+
domain: 'github.com',
|
|
428
|
+
id: GitCloudHostIntegrationId.GitHub,
|
|
429
|
+
name: 'GitHub',
|
|
430
|
+
type: 'git',
|
|
431
|
+
iconKey: GitCloudHostIntegrationId.GitHub,
|
|
432
|
+
issuesPagingMode: PagingMode.Repos,
|
|
433
|
+
pullRequestsPagingMode: PagingMode.Repos,
|
|
434
|
+
// Use 'username' property on account for PR filters
|
|
435
|
+
supportedPullRequestFilters: [
|
|
436
|
+
PullRequestFilter.Author,
|
|
437
|
+
PullRequestFilter.Assignee,
|
|
438
|
+
PullRequestFilter.ReviewRequested,
|
|
439
|
+
PullRequestFilter.Mention,
|
|
440
|
+
],
|
|
441
|
+
// Use 'username' property on account for issue filters
|
|
442
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee, IssueFilter.Mention],
|
|
443
|
+
scopes: ['repo', 'read:user', 'user:email'],
|
|
444
|
+
},
|
|
445
|
+
[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise]: {
|
|
446
|
+
domain: '',
|
|
447
|
+
id: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,
|
|
448
|
+
name: 'GitHub Enterprise',
|
|
449
|
+
type: 'git',
|
|
450
|
+
iconKey: 'github-enterprise',
|
|
451
|
+
issuesPagingMode: PagingMode.Repos,
|
|
452
|
+
pullRequestsPagingMode: PagingMode.Repos,
|
|
453
|
+
// Use 'username' property on account for PR filters
|
|
454
|
+
supportedPullRequestFilters: [
|
|
455
|
+
PullRequestFilter.Author,
|
|
456
|
+
PullRequestFilter.Assignee,
|
|
457
|
+
PullRequestFilter.ReviewRequested,
|
|
458
|
+
PullRequestFilter.Mention,
|
|
459
|
+
],
|
|
460
|
+
// Use 'username' property on account for issue filters
|
|
461
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee, IssueFilter.Mention],
|
|
462
|
+
scopes: ['repo', 'read:user', 'user:email'],
|
|
463
|
+
},
|
|
464
|
+
[GitCloudHostIntegrationId.GitLab]: {
|
|
465
|
+
domain: 'gitlab.com',
|
|
466
|
+
id: GitCloudHostIntegrationId.GitLab,
|
|
467
|
+
name: 'GitLab',
|
|
468
|
+
type: 'git',
|
|
469
|
+
iconKey: GitCloudHostIntegrationId.GitLab,
|
|
470
|
+
issuesPagingMode: PagingMode.Repo,
|
|
471
|
+
pullRequestsPagingMode: PagingMode.Repo,
|
|
472
|
+
// Use 'username' property on account for PR filters
|
|
473
|
+
supportedPullRequestFilters: [
|
|
474
|
+
PullRequestFilter.Author,
|
|
475
|
+
PullRequestFilter.Assignee,
|
|
476
|
+
PullRequestFilter.ReviewRequested,
|
|
477
|
+
],
|
|
478
|
+
// Use 'username' property on account for issue filters
|
|
479
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee],
|
|
480
|
+
scopes: ['api', 'read_user', 'read_repository'],
|
|
481
|
+
},
|
|
482
|
+
[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted]: {
|
|
483
|
+
domain: '',
|
|
484
|
+
id: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,
|
|
485
|
+
name: 'GitLab Self-Hosted',
|
|
486
|
+
type: 'git',
|
|
487
|
+
iconKey: 'gitlab-self-hosted',
|
|
488
|
+
issuesPagingMode: PagingMode.Repo,
|
|
489
|
+
pullRequestsPagingMode: PagingMode.Repo,
|
|
490
|
+
// Use 'username' property on account for PR filters
|
|
491
|
+
supportedPullRequestFilters: [
|
|
492
|
+
PullRequestFilter.Author,
|
|
493
|
+
PullRequestFilter.Assignee,
|
|
494
|
+
PullRequestFilter.ReviewRequested,
|
|
495
|
+
],
|
|
496
|
+
// Use 'username' property on account for issue filters
|
|
497
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee],
|
|
498
|
+
scopes: ['api', 'read_user', 'read_repository'],
|
|
499
|
+
},
|
|
500
|
+
[GitCloudHostIntegrationId.Bitbucket]: {
|
|
501
|
+
domain: 'bitbucket.org',
|
|
502
|
+
id: GitCloudHostIntegrationId.Bitbucket,
|
|
503
|
+
name: 'Bitbucket',
|
|
504
|
+
type: 'git',
|
|
505
|
+
iconKey: GitCloudHostIntegrationId.Bitbucket,
|
|
506
|
+
pullRequestsPagingMode: PagingMode.Repo,
|
|
507
|
+
// Use 'id' property on account for PR filters
|
|
508
|
+
supportedPullRequestFilters: [PullRequestFilter.Author],
|
|
509
|
+
scopes: ['account:read', 'repository:read', 'pullrequest:read', 'issue:read'],
|
|
510
|
+
},
|
|
511
|
+
[GitSelfManagedHostIntegrationId.BitbucketServer]: {
|
|
512
|
+
domain: '',
|
|
513
|
+
id: GitSelfManagedHostIntegrationId.BitbucketServer,
|
|
514
|
+
name: 'Bitbucket Data Center',
|
|
515
|
+
type: 'git',
|
|
516
|
+
iconKey: GitSelfManagedHostIntegrationId.BitbucketServer,
|
|
517
|
+
supportedPullRequestFilters: [PullRequestFilter.Author, PullRequestFilter.ReviewRequested],
|
|
518
|
+
scopes: ['Project (Read)', 'Repository (Write)'],
|
|
519
|
+
},
|
|
520
|
+
[GitCloudHostIntegrationId.AzureDevOps]: {
|
|
521
|
+
domain: 'dev.azure.com',
|
|
522
|
+
id: GitCloudHostIntegrationId.AzureDevOps,
|
|
523
|
+
name: 'Azure DevOps',
|
|
524
|
+
type: 'git',
|
|
525
|
+
iconKey: GitCloudHostIntegrationId.AzureDevOps,
|
|
526
|
+
issuesPagingMode: PagingMode.Project,
|
|
527
|
+
pullRequestsPagingMode: PagingMode.Repo,
|
|
528
|
+
// Use 'id' property on account for PR filters
|
|
529
|
+
supportedPullRequestFilters: [PullRequestFilter.Author, PullRequestFilter.Assignee],
|
|
530
|
+
// Use 'name' property on account for issue filters
|
|
531
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee, IssueFilter.Mention],
|
|
532
|
+
scopes: ['vso.code', 'vso.identity', 'vso.project', 'vso.profile', 'vso.work'],
|
|
533
|
+
},
|
|
534
|
+
[GitSelfManagedHostIntegrationId.AzureDevOpsServer]: {
|
|
535
|
+
domain: '',
|
|
536
|
+
id: GitSelfManagedHostIntegrationId.AzureDevOpsServer,
|
|
537
|
+
name: 'Azure DevOps Server',
|
|
538
|
+
type: 'git',
|
|
539
|
+
iconKey: GitCloudHostIntegrationId.AzureDevOps,
|
|
540
|
+
issuesPagingMode: PagingMode.Project,
|
|
541
|
+
pullRequestsPagingMode: PagingMode.Repo,
|
|
542
|
+
// Use 'id' property on account for PR filters
|
|
543
|
+
supportedPullRequestFilters: [PullRequestFilter.Author, PullRequestFilter.Assignee],
|
|
544
|
+
// Use 'name' property on account for issue filters
|
|
545
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee, IssueFilter.Mention],
|
|
546
|
+
scopes: ['vso.code', 'vso.identity', 'vso.project', 'vso.profile', 'vso.work'],
|
|
547
|
+
},
|
|
548
|
+
[IssuesCloudHostIntegrationId.Jira]: {
|
|
549
|
+
domain: 'atlassian.net',
|
|
550
|
+
id: IssuesCloudHostIntegrationId.Jira,
|
|
551
|
+
name: 'Jira',
|
|
552
|
+
type: 'issues',
|
|
553
|
+
iconKey: IssuesCloudHostIntegrationId.Jira,
|
|
554
|
+
scopes: [
|
|
555
|
+
'read:status:jira',
|
|
556
|
+
'read:application-role:jira',
|
|
557
|
+
'write:attachment:jira',
|
|
558
|
+
'read:comment:jira',
|
|
559
|
+
'read:project-category:jira',
|
|
560
|
+
'read:project:jira',
|
|
561
|
+
'read:issue.vote:jira',
|
|
562
|
+
'read:field-configuration:jira',
|
|
563
|
+
'write:issue:jira',
|
|
564
|
+
'read:issue-security-level:jira',
|
|
565
|
+
'write:issue.property:jira',
|
|
566
|
+
'read:issue.changelog:jira',
|
|
567
|
+
'read:avatar:jira',
|
|
568
|
+
'read:issue-meta:jira',
|
|
569
|
+
'read:permission:jira',
|
|
570
|
+
'offline_access',
|
|
571
|
+
'read:issue:jira',
|
|
572
|
+
'read:me',
|
|
573
|
+
'read:audit-log:jira',
|
|
574
|
+
'read:project.component:jira',
|
|
575
|
+
'read:group:jira',
|
|
576
|
+
'read:project-role:jira',
|
|
577
|
+
'write:comment:jira',
|
|
578
|
+
'read:label:jira',
|
|
579
|
+
'write:comment.property:jira',
|
|
580
|
+
'read:issue-details:jira',
|
|
581
|
+
'read:issue-type-hierarchy:jira',
|
|
582
|
+
'read:issue.transition:jira',
|
|
583
|
+
'read:user:jira',
|
|
584
|
+
'read:field:jira',
|
|
585
|
+
'read:issue-type:jira',
|
|
586
|
+
'read:project.property:jira',
|
|
587
|
+
'read:comment.property:jira',
|
|
588
|
+
'read:project-version:jira',
|
|
589
|
+
],
|
|
590
|
+
supportedIssueFilters: [IssueFilter.Author, IssueFilter.Assignee, IssueFilter.Mention],
|
|
591
|
+
},
|
|
592
|
+
[IssuesCloudHostIntegrationId.Linear]: {
|
|
593
|
+
domain: 'linear.app',
|
|
594
|
+
id: IssuesCloudHostIntegrationId.Linear,
|
|
595
|
+
name: 'Linear',
|
|
596
|
+
type: 'issues',
|
|
597
|
+
iconKey: IssuesCloudHostIntegrationId.Linear,
|
|
598
|
+
scopes: [],
|
|
599
|
+
},
|
|
600
|
+
[IssuesCloudHostIntegrationId.Trello]: {
|
|
601
|
+
domain: 'trello.com',
|
|
602
|
+
id: IssuesCloudHostIntegrationId.Trello,
|
|
603
|
+
name: 'Trello',
|
|
604
|
+
type: 'issues',
|
|
605
|
+
iconKey: IssuesCloudHostIntegrationId.Trello,
|
|
606
|
+
scopes: [],
|
|
607
|
+
},
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
export function getReasonsForUserIssue(issue: ProviderIssue, userLogin: string): string[] {
|
|
611
|
+
const reasons: string[] = [];
|
|
612
|
+
let isAuthor = false;
|
|
613
|
+
let isAssignee = false;
|
|
614
|
+
if (issue.author?.username === userLogin || issue.author?.name === userLogin) {
|
|
615
|
+
reasons.push('authored');
|
|
616
|
+
isAuthor = true;
|
|
617
|
+
}
|
|
618
|
+
if (issue.assignees?.some(assignee => assignee.username === userLogin || assignee.name === userLogin)) {
|
|
619
|
+
reasons.push('assigned');
|
|
620
|
+
isAssignee = true;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
// TODO: Impossible to denote all issues we are mentioned on given their properties. for now just
|
|
624
|
+
// assume we are mentioned on any of our issues we are not the author or assignee on
|
|
625
|
+
if (!isAuthor && !isAssignee) {
|
|
626
|
+
reasons.push('mentioned');
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
return reasons;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export function toIssueShape(issue: ProviderIssue, provider: ProviderReference): IssueShape | undefined {
|
|
633
|
+
// TODO: Add some protections/baselines rather than killing the transformation here
|
|
634
|
+
if (issue.updatedDate == null || issue.author == null || issue.url == null) return undefined;
|
|
635
|
+
|
|
636
|
+
return {
|
|
637
|
+
type: 'issue',
|
|
638
|
+
provider: provider,
|
|
639
|
+
id: issue.number,
|
|
640
|
+
nodeId: issue.graphQLId ?? issue.id,
|
|
641
|
+
title: issue.title,
|
|
642
|
+
url: issue.url,
|
|
643
|
+
createdDate: issue.createdDate,
|
|
644
|
+
updatedDate: issue.updatedDate,
|
|
645
|
+
closedDate: issue.closedDate ?? undefined,
|
|
646
|
+
closed: issue.closedDate != null,
|
|
647
|
+
state: issue.closedDate != null ? 'closed' : 'opened',
|
|
648
|
+
author: {
|
|
649
|
+
id: issue.author.id ?? '',
|
|
650
|
+
name: issue.author.name ?? '',
|
|
651
|
+
avatarUrl: issue.author.avatarUrl ?? undefined,
|
|
652
|
+
url: issue.author.url ?? undefined,
|
|
653
|
+
},
|
|
654
|
+
assignees:
|
|
655
|
+
issue.assignees?.map(assignee => ({
|
|
656
|
+
id: assignee.id ?? '',
|
|
657
|
+
name: assignee.name ?? '',
|
|
658
|
+
avatarUrl: assignee.avatarUrl ?? undefined,
|
|
659
|
+
url: assignee.url ?? undefined,
|
|
660
|
+
})) ?? [],
|
|
661
|
+
project: {
|
|
662
|
+
id: issue.project?.id ?? '',
|
|
663
|
+
name: issue.project?.name ?? '',
|
|
664
|
+
resourceId: issue.project?.resourceId ?? '',
|
|
665
|
+
resourceName: issue.project?.namespace ?? '',
|
|
666
|
+
},
|
|
667
|
+
repository:
|
|
668
|
+
issue.repository?.owner?.login != null
|
|
669
|
+
? {
|
|
670
|
+
owner: issue.repository.owner.login,
|
|
671
|
+
repo: issue.repository.name,
|
|
672
|
+
}
|
|
673
|
+
: undefined,
|
|
674
|
+
labels: issue.labels.map(label => ({ color: label.color ?? undefined, name: label.name })),
|
|
675
|
+
commentsCount: issue.commentCount ?? undefined,
|
|
676
|
+
thumbsUpCount: issue.upvoteCount ?? undefined,
|
|
677
|
+
body: issue.description ?? undefined,
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
export function issueFilterToReason(filter: IssueFilter): 'authored' | 'assigned' | 'mentioned' {
|
|
682
|
+
switch (filter) {
|
|
683
|
+
case IssueFilter.Author:
|
|
684
|
+
return 'authored';
|
|
685
|
+
case IssueFilter.Assignee:
|
|
686
|
+
return 'assigned';
|
|
687
|
+
case IssueFilter.Mention:
|
|
688
|
+
return 'mentioned';
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export function toAccount(account: ProviderAccount, provider: ProviderReference): UserAccount {
|
|
693
|
+
return {
|
|
694
|
+
provider: provider,
|
|
695
|
+
id: account.id,
|
|
696
|
+
name: account.name ?? undefined,
|
|
697
|
+
email: account.email ?? undefined,
|
|
698
|
+
avatarUrl: account.avatarUrl ?? undefined,
|
|
699
|
+
username: account.username ?? undefined,
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
export const toProviderBuildStatusState = {
|
|
704
|
+
[PullRequestStatusCheckRollupState.Success]: GitBuildStatusState.Success,
|
|
705
|
+
[PullRequestStatusCheckRollupState.Failed]: GitBuildStatusState.Failed,
|
|
706
|
+
[PullRequestStatusCheckRollupState.Pending]: GitBuildStatusState.Pending,
|
|
707
|
+
};
|
|
708
|
+
|
|
709
|
+
export const fromProviderBuildStatusState = {
|
|
710
|
+
[GitBuildStatusState.Success]: PullRequestStatusCheckRollupState.Success,
|
|
711
|
+
[GitBuildStatusState.Failed]: PullRequestStatusCheckRollupState.Failed,
|
|
712
|
+
[GitBuildStatusState.Pending]: PullRequestStatusCheckRollupState.Pending,
|
|
713
|
+
[GitBuildStatusState.ActionRequired]: PullRequestStatusCheckRollupState.Failed,
|
|
714
|
+
// TODO: The rest of these are defaulted because we don't have a matching state for them
|
|
715
|
+
[GitBuildStatusState.Error]: undefined,
|
|
716
|
+
[GitBuildStatusState.Cancelled]: undefined,
|
|
717
|
+
[GitBuildStatusState.OptionalActionRequired]: undefined,
|
|
718
|
+
[GitBuildStatusState.Skipped]: undefined,
|
|
719
|
+
[GitBuildStatusState.Running]: undefined,
|
|
720
|
+
[GitBuildStatusState.Warning]: undefined,
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
export const toProviderPullRequestReviewState = {
|
|
724
|
+
[PullRequestReviewState.Approved]: GitPullRequestReviewState.Approved,
|
|
725
|
+
[PullRequestReviewState.ChangesRequested]: GitPullRequestReviewState.ChangesRequested,
|
|
726
|
+
[PullRequestReviewState.Commented]: GitPullRequestReviewState.Commented,
|
|
727
|
+
[PullRequestReviewState.ReviewRequested]: GitPullRequestReviewState.ReviewRequested,
|
|
728
|
+
[PullRequestReviewState.Dismissed]: null,
|
|
729
|
+
[PullRequestReviewState.Pending]: null,
|
|
730
|
+
};
|
|
731
|
+
|
|
732
|
+
export const fromProviderPullRequestReviewState = {
|
|
733
|
+
[GitPullRequestReviewState.Approved]: PullRequestReviewState.Approved,
|
|
734
|
+
[GitPullRequestReviewState.ChangesRequested]: PullRequestReviewState.ChangesRequested,
|
|
735
|
+
[GitPullRequestReviewState.Commented]: PullRequestReviewState.Commented,
|
|
736
|
+
[GitPullRequestReviewState.ReviewRequested]: PullRequestReviewState.ReviewRequested,
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
export const toProviderPullRequestMergeableState = {
|
|
740
|
+
[PullRequestMergeableState.Mergeable]: GitPullRequestMergeableState.Mergeable,
|
|
741
|
+
[PullRequestMergeableState.Conflicting]: GitPullRequestMergeableState.Conflicts,
|
|
742
|
+
[PullRequestMergeableState.Unknown]: GitPullRequestMergeableState.Unknown,
|
|
743
|
+
[PullRequestMergeableState.FailingChecks]: GitPullRequestMergeableState.FailingChecks,
|
|
744
|
+
[PullRequestMergeableState.BlockedByPolicy]: GitPullRequestMergeableState.Blocked,
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
export const fromProviderPullRequestMergeableState = {
|
|
748
|
+
[GitPullRequestMergeableState.Mergeable]: PullRequestMergeableState.Mergeable,
|
|
749
|
+
[GitPullRequestMergeableState.Conflicts]: PullRequestMergeableState.Conflicting,
|
|
750
|
+
[GitPullRequestMergeableState.Blocked]: PullRequestMergeableState.BlockedByPolicy,
|
|
751
|
+
[GitPullRequestMergeableState.FailingChecks]: PullRequestMergeableState.FailingChecks,
|
|
752
|
+
[GitPullRequestMergeableState.Unknown]: PullRequestMergeableState.Unknown,
|
|
753
|
+
[GitPullRequestMergeableState.Behind]: PullRequestMergeableState.Unknown,
|
|
754
|
+
[GitPullRequestMergeableState.UnknownAndBlocked]: PullRequestMergeableState.Unknown,
|
|
755
|
+
[GitPullRequestMergeableState.Unstable]: PullRequestMergeableState.Unknown,
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
export function toProviderReviews(reviewers: PullRequestReviewer[]): ProviderPullRequest['reviews'] {
|
|
759
|
+
return reviewers
|
|
760
|
+
.filter(r => r.state !== PullRequestReviewState.Dismissed && r.state !== PullRequestReviewState.Pending)
|
|
761
|
+
.map(reviewer => ({
|
|
762
|
+
reviewer: toProviderAccount(reviewer.reviewer),
|
|
763
|
+
state: toProviderPullRequestReviewState[reviewer.state] ?? GitPullRequestReviewState.ReviewRequested,
|
|
764
|
+
}));
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
export function toReviewRequests(reviews: ProviderPullRequest['reviews']): PullRequestReviewer[] | undefined {
|
|
768
|
+
return reviews == null
|
|
769
|
+
? undefined
|
|
770
|
+
: reviews
|
|
771
|
+
?.filter(r => r.state === GitPullRequestReviewState.ReviewRequested)
|
|
772
|
+
.map(r => ({
|
|
773
|
+
isCodeOwner: false, // TODO: Find this value, and implement in the shared lib if needed
|
|
774
|
+
reviewer: fromProviderAccount(r.reviewer),
|
|
775
|
+
state: PullRequestReviewState.ReviewRequested,
|
|
776
|
+
}));
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
export function toCompletedReviews(reviews: ProviderPullRequest['reviews']): PullRequestReviewer[] | undefined {
|
|
780
|
+
return reviews == null
|
|
781
|
+
? undefined
|
|
782
|
+
: reviews
|
|
783
|
+
?.filter(r => r.state !== GitPullRequestReviewState.ReviewRequested)
|
|
784
|
+
.map(r => ({
|
|
785
|
+
isCodeOwner: false, // TODO: Find this value, and implement in the shared lib if needed
|
|
786
|
+
reviewer: fromProviderAccount(r.reviewer),
|
|
787
|
+
state: fromProviderPullRequestReviewState[r.state],
|
|
788
|
+
}));
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export function toProviderReviewDecision(
|
|
792
|
+
reviewDecision?: PullRequestReviewDecision,
|
|
793
|
+
reviewers?: PullRequestReviewer[],
|
|
794
|
+
): GitPullRequestReviewState | null {
|
|
795
|
+
switch (reviewDecision) {
|
|
796
|
+
case PullRequestReviewDecision.Approved:
|
|
797
|
+
return GitPullRequestReviewState.Approved;
|
|
798
|
+
case PullRequestReviewDecision.ChangesRequested:
|
|
799
|
+
return GitPullRequestReviewState.ChangesRequested;
|
|
800
|
+
case PullRequestReviewDecision.ReviewRequired:
|
|
801
|
+
return GitPullRequestReviewState.ReviewRequested;
|
|
802
|
+
default: {
|
|
803
|
+
if (reviewers?.some(r => r.state === PullRequestReviewState.ReviewRequested)) {
|
|
804
|
+
return GitPullRequestReviewState.ReviewRequested;
|
|
805
|
+
} else if (reviewers?.some(r => r.state === PullRequestReviewState.Commented)) {
|
|
806
|
+
return GitPullRequestReviewState.Commented;
|
|
807
|
+
}
|
|
808
|
+
return null;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
export const fromPullRequestReviewDecision = {
|
|
814
|
+
[GitPullRequestReviewState.Approved]: PullRequestReviewDecision.Approved,
|
|
815
|
+
[GitPullRequestReviewState.ChangesRequested]: PullRequestReviewDecision.ChangesRequested,
|
|
816
|
+
[GitPullRequestReviewState.Commented]: undefined,
|
|
817
|
+
[GitPullRequestReviewState.ReviewRequested]: PullRequestReviewDecision.ReviewRequired,
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
export function toProviderPullRequestState(state: PullRequestState): GitPullRequestState {
|
|
821
|
+
return state === 'opened'
|
|
822
|
+
? GitPullRequestState.Open
|
|
823
|
+
: state === 'closed'
|
|
824
|
+
? GitPullRequestState.Closed
|
|
825
|
+
: GitPullRequestState.Merged;
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
export function fromProviderPullRequestState(state: GitPullRequestState): PullRequestState {
|
|
829
|
+
return state === GitPullRequestState.Open ? 'opened' : state === GitPullRequestState.Closed ? 'closed' : 'merged';
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
export function toProviderPullRequest(pr: PullRequest): ProviderPullRequest {
|
|
833
|
+
const prReviews = [...(pr.reviewRequests ?? []), ...(pr.latestReviews ?? [])];
|
|
834
|
+
return {
|
|
835
|
+
id: pr.id,
|
|
836
|
+
graphQLId: pr.nodeId,
|
|
837
|
+
number: Number.parseInt(pr.id, 10),
|
|
838
|
+
title: pr.title,
|
|
839
|
+
description: null,
|
|
840
|
+
url: pr.url,
|
|
841
|
+
state: toProviderPullRequestState(pr.state),
|
|
842
|
+
isDraft: pr.isDraft ?? false,
|
|
843
|
+
createdDate: pr.createdDate,
|
|
844
|
+
updatedDate: pr.updatedDate,
|
|
845
|
+
closedDate: pr.closedDate ?? null,
|
|
846
|
+
mergedDate: pr.mergedDate ?? null,
|
|
847
|
+
commentCount: pr.commentsCount ?? null,
|
|
848
|
+
upvoteCount: pr.thumbsUpCount ?? null,
|
|
849
|
+
commitCount: null,
|
|
850
|
+
fileCount: null,
|
|
851
|
+
additions: pr.additions ?? null,
|
|
852
|
+
deletions: pr.deletions ?? null,
|
|
853
|
+
author: toProviderAccount(pr.author),
|
|
854
|
+
assignees: pr.assignees?.map(toProviderAccount) ?? null,
|
|
855
|
+
baseRef:
|
|
856
|
+
pr.refs?.base == null
|
|
857
|
+
? null
|
|
858
|
+
: {
|
|
859
|
+
name: pr.refs.base.branch,
|
|
860
|
+
oid: pr.refs.base.sha,
|
|
861
|
+
},
|
|
862
|
+
headRef:
|
|
863
|
+
pr.refs?.head == null
|
|
864
|
+
? null
|
|
865
|
+
: {
|
|
866
|
+
name: pr.refs.head.branch,
|
|
867
|
+
oid: pr.refs.head.sha,
|
|
868
|
+
},
|
|
869
|
+
reviews: toProviderReviews(prReviews),
|
|
870
|
+
reviewDecision: toProviderReviewDecision(pr.reviewDecision, prReviews),
|
|
871
|
+
repository:
|
|
872
|
+
pr.repository != null
|
|
873
|
+
? {
|
|
874
|
+
id: pr.repository.repo,
|
|
875
|
+
name: pr.repository.repo,
|
|
876
|
+
owner: {
|
|
877
|
+
login: pr.repository.owner,
|
|
878
|
+
},
|
|
879
|
+
remoteInfo: null, // TODO: Add the urls to our model
|
|
880
|
+
}
|
|
881
|
+
: {
|
|
882
|
+
id: '',
|
|
883
|
+
name: '',
|
|
884
|
+
owner: {
|
|
885
|
+
login: '',
|
|
886
|
+
},
|
|
887
|
+
remoteInfo: null,
|
|
888
|
+
},
|
|
889
|
+
headRepository:
|
|
890
|
+
pr.refs?.head != null
|
|
891
|
+
? {
|
|
892
|
+
id: pr.refs.head.repo,
|
|
893
|
+
name: pr.refs.head.repo,
|
|
894
|
+
owner: {
|
|
895
|
+
login: pr.refs.head.owner,
|
|
896
|
+
},
|
|
897
|
+
remoteInfo: null,
|
|
898
|
+
}
|
|
899
|
+
: null,
|
|
900
|
+
headCommit:
|
|
901
|
+
pr.statusCheckRollupState != null
|
|
902
|
+
? {
|
|
903
|
+
buildStatuses: [
|
|
904
|
+
{
|
|
905
|
+
completedAt: null,
|
|
906
|
+
description: '',
|
|
907
|
+
name: '',
|
|
908
|
+
state: toProviderBuildStatusState[pr.statusCheckRollupState],
|
|
909
|
+
startedAt: null,
|
|
910
|
+
stage: null,
|
|
911
|
+
url: '',
|
|
912
|
+
},
|
|
913
|
+
],
|
|
914
|
+
}
|
|
915
|
+
: null,
|
|
916
|
+
permissions:
|
|
917
|
+
pr.viewerCanUpdate == null
|
|
918
|
+
? null
|
|
919
|
+
: {
|
|
920
|
+
canMerge:
|
|
921
|
+
pr.viewerCanUpdate === true &&
|
|
922
|
+
pr.repository.accessLevel != null &&
|
|
923
|
+
pr.repository.accessLevel >= RepositoryAccessLevel.Write,
|
|
924
|
+
canMergeAndBypassProtections:
|
|
925
|
+
pr.viewerCanUpdate === true &&
|
|
926
|
+
pr.repository.accessLevel != null &&
|
|
927
|
+
pr.repository.accessLevel >= RepositoryAccessLevel.Admin,
|
|
928
|
+
},
|
|
929
|
+
mergeableState: pr.mergeableState
|
|
930
|
+
? toProviderPullRequestMergeableState[pr.mergeableState]
|
|
931
|
+
: GitPullRequestMergeableState.Unknown,
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
export function fromProviderPullRequest(
|
|
936
|
+
pr: ProviderPullRequest,
|
|
937
|
+
provider: Provider,
|
|
938
|
+
options?: { project?: IssueProject },
|
|
939
|
+
): PullRequest {
|
|
940
|
+
return new PullRequest(
|
|
941
|
+
provider,
|
|
942
|
+
fromProviderAccount(pr.author),
|
|
943
|
+
pr.id,
|
|
944
|
+
pr.graphQLId || pr.id,
|
|
945
|
+
pr.title,
|
|
946
|
+
pr.url ?? '',
|
|
947
|
+
{
|
|
948
|
+
owner: pr.repository.owner.login,
|
|
949
|
+
repo: pr.repository.name,
|
|
950
|
+
// This has to be here until we can take this information from ProviderPullRequest:
|
|
951
|
+
accessLevel: RepositoryAccessLevel.Write,
|
|
952
|
+
id: pr.repository.id,
|
|
953
|
+
},
|
|
954
|
+
fromProviderPullRequestState(pr.state),
|
|
955
|
+
pr.createdDate,
|
|
956
|
+
pr.updatedDate,
|
|
957
|
+
pr.closedDate ?? undefined,
|
|
958
|
+
pr.mergedDate ?? undefined,
|
|
959
|
+
pr.mergeableState ? fromProviderPullRequestMergeableState[pr.mergeableState] : undefined,
|
|
960
|
+
pr.permissions?.canMerge || pr.permissions?.canMergeAndBypassProtections ? true : undefined,
|
|
961
|
+
{
|
|
962
|
+
base: {
|
|
963
|
+
branch: pr.baseRef?.name ?? '',
|
|
964
|
+
sha: pr.baseRef?.oid ?? '',
|
|
965
|
+
repo: pr.repository.name,
|
|
966
|
+
owner: pr.repository.owner.login,
|
|
967
|
+
exists: pr.baseRef != null,
|
|
968
|
+
url: pr.repository.remoteInfo?.cloneUrlHTTPS
|
|
969
|
+
? pr.repository.remoteInfo.cloneUrlHTTPS.replace(gitSuffixRegex, '')
|
|
970
|
+
: '',
|
|
971
|
+
},
|
|
972
|
+
head: {
|
|
973
|
+
branch: pr.headRef?.name ?? '',
|
|
974
|
+
sha: pr.headRef?.oid ?? '',
|
|
975
|
+
repo: pr.headRepository?.name ?? '',
|
|
976
|
+
owner: pr.headRepository?.owner.login ?? '',
|
|
977
|
+
exists: pr.headRef != null,
|
|
978
|
+
url: pr.headRepository?.remoteInfo?.cloneUrlHTTPS
|
|
979
|
+
? pr.headRepository.remoteInfo.cloneUrlHTTPS.replace(gitSuffixRegex, '')
|
|
980
|
+
: '',
|
|
981
|
+
},
|
|
982
|
+
isCrossRepository: pr.headRepository?.id !== pr.repository.id,
|
|
983
|
+
},
|
|
984
|
+
pr.isDraft,
|
|
985
|
+
pr.additions ?? undefined,
|
|
986
|
+
pr.deletions ?? undefined,
|
|
987
|
+
pr.commentCount ?? undefined,
|
|
988
|
+
pr.upvoteCount ?? undefined,
|
|
989
|
+
pr.reviewDecision ? fromPullRequestReviewDecision[pr.reviewDecision] : undefined,
|
|
990
|
+
toReviewRequests(pr.reviews),
|
|
991
|
+
toCompletedReviews(pr.reviews),
|
|
992
|
+
pr.assignees?.map(fromProviderAccount) ?? undefined,
|
|
993
|
+
pr.headCommit?.buildStatuses?.[0]?.state
|
|
994
|
+
? fromProviderBuildStatusState[pr.headCommit.buildStatuses[0].state]
|
|
995
|
+
: undefined,
|
|
996
|
+
options?.project,
|
|
997
|
+
pr.version,
|
|
998
|
+
);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
export function fromProviderIssue(
|
|
1002
|
+
issue: ProviderIssue,
|
|
1003
|
+
integration: Integration,
|
|
1004
|
+
options?: { project?: IssueProject },
|
|
1005
|
+
): Issue {
|
|
1006
|
+
return new Issue(
|
|
1007
|
+
integration,
|
|
1008
|
+
issue.id,
|
|
1009
|
+
issue.graphQLId,
|
|
1010
|
+
issue.title,
|
|
1011
|
+
issue.url ?? '',
|
|
1012
|
+
issue.createdDate,
|
|
1013
|
+
issue.updatedDate ?? issue.closedDate ?? issue.createdDate,
|
|
1014
|
+
issue.closedDate != null,
|
|
1015
|
+
issue.closedDate != null ? 'closed' : 'opened',
|
|
1016
|
+
fromProviderAccount(issue.author),
|
|
1017
|
+
issue.assignees?.map(fromProviderAccount) ?? undefined,
|
|
1018
|
+
undefined, // TODO: issue repo
|
|
1019
|
+
issue.closedDate ?? undefined,
|
|
1020
|
+
undefined,
|
|
1021
|
+
issue.commentCount ?? undefined,
|
|
1022
|
+
issue.upvoteCount ?? undefined,
|
|
1023
|
+
issue.description ?? undefined,
|
|
1024
|
+
options?.project != null
|
|
1025
|
+
? {
|
|
1026
|
+
id: options.project.id,
|
|
1027
|
+
name: options.project.name,
|
|
1028
|
+
resourceId: options.project.resourceId,
|
|
1029
|
+
resourceName: options.project.resourceName,
|
|
1030
|
+
}
|
|
1031
|
+
: issue.project?.id && issue.project?.resourceId && issue.project?.namespace
|
|
1032
|
+
? {
|
|
1033
|
+
id: issue.project.id,
|
|
1034
|
+
name: issue.project.name,
|
|
1035
|
+
resourceId: issue.project.resourceId,
|
|
1036
|
+
resourceName: issue.project.namespace,
|
|
1037
|
+
}
|
|
1038
|
+
: undefined,
|
|
1039
|
+
issue.number,
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
export function toProviderPullRequestWithUniqueId(pr: PullRequest): PullRequestWithUniqueID {
|
|
1044
|
+
return {
|
|
1045
|
+
...toProviderPullRequest(pr),
|
|
1046
|
+
uuid: EntityIdentifierUtils.encode(getEntityIdentifierInput(pr)),
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
export function toProviderAccount(account: PullRequestMember | IssueMember): ProviderAccount {
|
|
1051
|
+
return {
|
|
1052
|
+
id: account.id ?? null,
|
|
1053
|
+
avatarUrl: account.avatarUrl ?? null,
|
|
1054
|
+
name: account.name ?? null,
|
|
1055
|
+
url: account.url ?? null,
|
|
1056
|
+
// TODO: Implement these in our own model
|
|
1057
|
+
email: '',
|
|
1058
|
+
username: account.name ?? null,
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
export function fromProviderAccount(account: ProviderAccount | null): PullRequestMember | IssueMember {
|
|
1063
|
+
return {
|
|
1064
|
+
id: account?.id ?? '',
|
|
1065
|
+
name: account?.name ?? 'unknown',
|
|
1066
|
+
avatarUrl: account?.avatarUrl ?? undefined,
|
|
1067
|
+
url: account?.url ?? '',
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
export type ProviderActionablePullRequest = ActionablePullRequest;
|
|
1072
|
+
|
|
1073
|
+
export type EnrichablePullRequest = ProviderPullRequest & {
|
|
1074
|
+
uuid: string;
|
|
1075
|
+
type: 'pullrequest';
|
|
1076
|
+
provider: ProviderReference;
|
|
1077
|
+
enrichable: EnrichableItem;
|
|
1078
|
+
repoIdentity: PullRequestRepositoryIdentityDescriptor;
|
|
1079
|
+
refs?: PullRequestRefs;
|
|
1080
|
+
underlyingPullRequest: PullRequest;
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
export const getActionablePullRequests = GitProviderUtils.getActionablePullRequests;
|
|
1084
|
+
|
|
1085
|
+
export type GitConfigEntityIdentifier = AnyEntityIdentifierInput & {
|
|
1086
|
+
metadata: {
|
|
1087
|
+
id: string;
|
|
1088
|
+
owner: { key: string; name: string; id: string | undefined; owner: string | undefined };
|
|
1089
|
+
createdDate: string;
|
|
1090
|
+
isCloudEnterprise?: boolean;
|
|
1091
|
+
};
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
export function isGitHubDotCom(domain: string | null | undefined): boolean {
|
|
1095
|
+
return equalsIgnoreCase(domain, 'github.com');
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
export function isGitLabDotCom(domain: string | null | undefined): boolean {
|
|
1099
|
+
return equalsIgnoreCase(domain, 'gitlab.com');
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
const azureCloudDomainRegex = /^dev\.azure\.com$|\bvisualstudio\.com$/i;
|
|
1103
|
+
export function isAzureCloudDomain(domain: string | undefined): boolean {
|
|
1104
|
+
return domain != null && azureCloudDomainRegex.test(domain);
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
const bitbucketCloudDomainRegex = /^bitbucket\.org$/i;
|
|
1108
|
+
export function isBitbucketCloudDomain(domain: string | undefined): boolean {
|
|
1109
|
+
return domain != null && bitbucketCloudDomainRegex.test(domain);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1112
|
+
export function supportsCodeSuggest(provider: ProviderReference): boolean {
|
|
1113
|
+
return isGitHubDotCom(provider.domain);
|
|
1114
|
+
}
|