@gitkraken/core-gitlens 0.46.0 → 0.48.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 +19 -1
- package/dist/git-cli/providers/branches.js +8 -4
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/plus/ai/providers/anthropicProvider.js +0 -20
- package/dist/plus/ai/providers/anthropicProvider.js.map +1 -1
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.d.ts +31 -0
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js +166 -0
- package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js.map +1 -0
- package/dist/plus/git-github/api/github.d.ts +7 -4
- package/dist/plus/git-github/api/github.js +44 -14
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +1 -0
- package/dist/plus/git-github/api/issueWrites.js +5 -5
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/api/pullRequestWrites.d.ts +7 -3
- package/dist/plus/git-github/api/pullRequestWrites.js +120 -67
- package/dist/plus/git-github/api/pullRequestWrites.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +4 -4
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +14 -14
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +3 -3
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +4 -4
- package/dist/plus/integrations/index.d.ts +8 -4
- package/dist/plus/integrations/index.js +2 -1
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +9 -2
- package/dist/plus/integrations/integrationService.js +95 -31
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +16 -4
- package/dist/plus/integrations/models/gitHostIntegration.js +7 -4
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +2 -1
- package/dist/plus/integrations/models/integration.js +11 -4
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueTrackerWrites.d.ts +128 -0
- package/dist/plus/integrations/models/issueTrackerWrites.js +0 -0
- package/dist/plus/integrations/models/publicIntegration.d.ts +4 -0
- package/dist/plus/integrations/models/publicIntegration.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +19 -6
- package/dist/plus/integrations/providers/github.js +126 -53
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/jira.js +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +2 -0
- package/dist/plus/integrations/providers/jiraIssueByKey.js +1 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.d.ts +10 -0
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.js +68 -0
- package/dist/plus/integrations/providers/jiraIssueWriteErrors.js.map +1 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.d.ts +40 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js +397 -0
- package/dist/plus/integrations/providers/jiraIssueWrites.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +4 -1
- package/dist/plus/integrations/providers/providersApi.js +21 -10
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/utils/integration.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/integration.utils.js +7 -1
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
- package/dist/utils/date.d.ts +1 -0
- package/dist/utils/date.js +10 -1
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/keys/keymapDispatcher.d.ts +12 -0
- package/dist/utils/keys/keymapDispatcher.js +33 -1
- package/dist/utils/keys/keymapDispatcher.js.map +1 -1
- package/dist/utils/pausedOperation.js +48 -16
- package/dist/utils/pausedOperation.js.map +1 -1
- package/dist/utils/plural.d.ts +1 -0
- package/dist/utils/plural.js +7 -2
- package/dist/utils/plural.js.map +1 -1
- package/dist/utils/wheel.d.ts +8 -0
- package/dist/utils/wheel.js +12 -0
- package/dist/utils/wheel.js.map +1 -0
- package/docs/integrations.md +80 -8
- package/package.json +1 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { IssuesCloudHostIntegrationId } from "../constants.js";
|
|
2
|
+
//#region ../plus/integrations/src/models/issueTrackerWrites.d.ts
|
|
3
|
+
export type IssueTrackerWriteConnection = {
|
|
4
|
+
providerId: IssuesCloudHostIntegrationId.Jira;
|
|
5
|
+
connectionId: string;
|
|
6
|
+
resourceId: string;
|
|
7
|
+
expectedAccountId?: string;
|
|
8
|
+
};
|
|
9
|
+
type IssueTrackerIssueAddress = IssueTrackerWriteConnection & {
|
|
10
|
+
issue: string;
|
|
11
|
+
expectedIssueId?: string;
|
|
12
|
+
};
|
|
13
|
+
type IssueTrackerExistingIssue = IssueTrackerIssueAddress & {
|
|
14
|
+
expectedIssueId: string;
|
|
15
|
+
};
|
|
16
|
+
type IssueTrackerEditableFields = {
|
|
17
|
+
description?: string;
|
|
18
|
+
fields?: Readonly<Record<string, unknown>>;
|
|
19
|
+
};
|
|
20
|
+
export type IssueTrackerCreateOptions = IssueTrackerWriteConnection & {
|
|
21
|
+
project: string;
|
|
22
|
+
issueTypeId?: string;
|
|
23
|
+
};
|
|
24
|
+
export type IssueTrackerIssueWriteOptions = IssueTrackerIssueAddress;
|
|
25
|
+
export type IssueTrackerWriteTargetOptions = IssueTrackerIssueAddress & {
|
|
26
|
+
intent?: 'delete';
|
|
27
|
+
};
|
|
28
|
+
export type IssueTrackerDeleteOptions = IssueTrackerExistingIssue & {
|
|
29
|
+
expectedAccountId: string;
|
|
30
|
+
};
|
|
31
|
+
export type IssueTrackerWriteOptions = (IssueTrackerWriteConnection & IssueTrackerEditableFields & {
|
|
32
|
+
action: 'create';
|
|
33
|
+
project: string;
|
|
34
|
+
issueTypeId: string;
|
|
35
|
+
summary: string;
|
|
36
|
+
}) | (IssueTrackerExistingIssue & IssueTrackerEditableFields & {
|
|
37
|
+
action: 'edit';
|
|
38
|
+
summary?: string;
|
|
39
|
+
}) | (IssueTrackerExistingIssue & IssueTrackerEditableFields & {
|
|
40
|
+
action: 'transition';
|
|
41
|
+
transitionId: string;
|
|
42
|
+
summary?: string;
|
|
43
|
+
});
|
|
44
|
+
export type IssueTrackerWriteFailure = {
|
|
45
|
+
ok: false;
|
|
46
|
+
reason: 'unsupported' | 'no-connection' | 'forbidden' | 'not-found' | 'invalid-input' | 'transition-unavailable' | 'conflict' | 'insufficient-scope' | 'rate-limit' | 'unknown';
|
|
47
|
+
fieldErrors?: Readonly<Record<string, string>>;
|
|
48
|
+
messages?: readonly string[];
|
|
49
|
+
mutationDispatched?: false;
|
|
50
|
+
applied?: 'maybe';
|
|
51
|
+
};
|
|
52
|
+
export type IssueTrackerStatus = {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
category: 'TO_DO' | 'IN_PROGRESS' | 'DONE';
|
|
56
|
+
};
|
|
57
|
+
export type IssueTrackerIssueReceipt = {
|
|
58
|
+
resourceId: string;
|
|
59
|
+
siteUrl: string;
|
|
60
|
+
id: string;
|
|
61
|
+
key: string;
|
|
62
|
+
url: string;
|
|
63
|
+
project: {
|
|
64
|
+
id: string;
|
|
65
|
+
key: string;
|
|
66
|
+
};
|
|
67
|
+
issueType: {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
summary: string;
|
|
72
|
+
status: IssueTrackerStatus;
|
|
73
|
+
};
|
|
74
|
+
export type IssueTrackerField = {
|
|
75
|
+
fieldId: string;
|
|
76
|
+
name: string;
|
|
77
|
+
required: boolean;
|
|
78
|
+
schema?: Readonly<Record<string, unknown>>;
|
|
79
|
+
allowedValues?: readonly unknown[];
|
|
80
|
+
hasDefaultValue: boolean;
|
|
81
|
+
operations: readonly string[];
|
|
82
|
+
};
|
|
83
|
+
export type IssueTrackerTransition = {
|
|
84
|
+
id: string;
|
|
85
|
+
name: string;
|
|
86
|
+
to: IssueTrackerStatus;
|
|
87
|
+
hasScreen: boolean;
|
|
88
|
+
isAvailable: boolean;
|
|
89
|
+
isConditional: boolean;
|
|
90
|
+
fields: readonly IssueTrackerField[];
|
|
91
|
+
};
|
|
92
|
+
export type IssueTrackerCreateOptionsResult = ({
|
|
93
|
+
ok: true;
|
|
94
|
+
resourceId: string;
|
|
95
|
+
siteUrl: string;
|
|
96
|
+
accountId: string;
|
|
97
|
+
project: IssueTrackerIssueReceipt['project'];
|
|
98
|
+
truncated: boolean;
|
|
99
|
+
} & ({
|
|
100
|
+
issueTypes: readonly IssueTrackerIssueReceipt['issueType'][];
|
|
101
|
+
} | {
|
|
102
|
+
issueTypeId: string;
|
|
103
|
+
fields: readonly IssueTrackerField[];
|
|
104
|
+
})) | IssueTrackerWriteFailure;
|
|
105
|
+
type IssueTrackerWriteSuccess = {
|
|
106
|
+
ok: true;
|
|
107
|
+
issue: IssueTrackerIssueReceipt;
|
|
108
|
+
accountId: string;
|
|
109
|
+
};
|
|
110
|
+
export type IssueTrackerIssueWriteOptionsResult = (IssueTrackerWriteSuccess & {
|
|
111
|
+
fields: readonly IssueTrackerField[];
|
|
112
|
+
transitions: readonly IssueTrackerTransition[];
|
|
113
|
+
permissions: {
|
|
114
|
+
edit: boolean;
|
|
115
|
+
transition: boolean;
|
|
116
|
+
delete: boolean;
|
|
117
|
+
};
|
|
118
|
+
deleteCapability: {
|
|
119
|
+
allowed: true;
|
|
120
|
+
} | {
|
|
121
|
+
allowed: false;
|
|
122
|
+
reason: 'forbidden' | 'insufficient-scope' | 'invalid-input';
|
|
123
|
+
};
|
|
124
|
+
}) | IssueTrackerWriteFailure;
|
|
125
|
+
export type IssueTrackerWriteResult = IssueTrackerWriteSuccess | IssueTrackerWriteFailure;
|
|
126
|
+
export type IssueTrackerWriteTargetResult = IssueTrackerWriteSuccess | IssueTrackerWriteFailure;
|
|
127
|
+
//#endregion
|
|
128
|
+
//# sourceMappingURL=issueTrackerWrites.d.ts.map
|
|
File without changes
|
|
@@ -136,6 +136,8 @@ export interface GitHostIntegration extends IntegrationViewBase {
|
|
|
136
136
|
getAccountForCommit(repo: ResourceDescriptor, rev: string, options?: {
|
|
137
137
|
avatarSize?: number;
|
|
138
138
|
}): Promise<Account | UnidentifiedAuthor | undefined>;
|
|
139
|
+
/** Gets the established local session's cache descriptor for this fetch remote, without resolving or refreshing it. */
|
|
140
|
+
getCachedPullRequestScope?(remoteUrl: string): IntegrationCacheDescriptor | undefined;
|
|
139
141
|
getCurrentAccount(options?: {
|
|
140
142
|
avatarSize?: number;
|
|
141
143
|
connectionId?: string;
|
|
@@ -230,6 +232,8 @@ export type IntegrationById<T extends IntegrationIds> = T extends IssuesHostInte
|
|
|
230
232
|
export interface IntegrationCacheDescriptor {
|
|
231
233
|
readonly id: IntegrationIds;
|
|
232
234
|
readonly domain?: string;
|
|
235
|
+
/** The HTTP(S) origin used by the selected session for this Enterprise pull request read. */
|
|
236
|
+
readonly installationOrigin?: string;
|
|
233
237
|
/** Whether the integration has a session; `undefined` until it has looked. */
|
|
234
238
|
readonly maybeConnected?: boolean;
|
|
235
239
|
/** A hash of the current session's token, which changes when the account or token does. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicIntegration.js","names":[],"sources":["../../../../../plus/integrations/src/models/publicIntegration.ts"],"sourcesContent":["import type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue } from '@gitlens/git/models/issue.js';\nimport type {\n\tIssueOrPullRequest,\n\tIssueOrPullRequestState,\n\tIssueOrPullRequestType,\n} from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestMergeQueueActionResult,\n\tPullRequestMergeQueueEntry,\n\tPullRequestStackInfo,\n\tPullRequestStackLayers,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport type {\n\tGitCloudHostIntegrationId,\n\tIntegrationIds,\n\tIssuesCloudHostIntegrationId,\n\tIssuesHostIntegrationIds,\n} from '../constants.js';\nimport type { ProviderRepositoriesInput } from '../manager.js';\nimport type { PullRequestFilter } from '../providerFilters.js';\nimport type { ProviderRepositoryShape } from '../results.js';\nimport type { Sources } from '../telemetry.js';\nimport { IntegrationBase } from './integration.js';\n\n// The public, interface-only views of the integration classes: what a consumer of the `index.js` facade may call on\n// an integration. They are written out member by member, in package-owned and `@gitlens/*` types only, so nothing\n// a consumer can reach from them names `@gitkraken/provider-apis` or an internal class. The classes `implements`\n// these views, so the compiler keeps each class member assignable to the view's.\n// Code inside the package keeps importing the classes from `models/*`.\n// The views' doc comments are the consumer contract; the classes' doc comments are maintainer notes.\n\n/** The kind of an integration: a git host or an issue tracker. */\nexport type IntegrationType = 'git' | 'issues';\n\n// Keep this in step with `isSelfManagedHostIntegrationId`: it is the type-level twin of that predicate, and a\n// disagreement compiles cleanly while the runtime writes a domain-keyed key the type says is unkeyed (so the\n// local-disconnect flag is written under one key and read under another).\nexport type IntegrationKey<T extends IntegrationIds = IntegrationIds> = T extends\n\t| GitCloudHostIntegrationId\n\t| IssuesCloudHostIntegrationId\n\t? `${T}`\n\t: `${T}:${string}`;\n\nexport type IntegrationConnectedKey<T extends IntegrationIds = IntegrationIds> = `connected:${IntegrationKey<T>}`;\n\n/** A read's outcome: its value, or the error it failed with; `undefined` when there was nothing to read. */\nexport type IntegrationResult<T> =\n\t| { value: T; duration?: number; error?: Error }\n\t| { error: Error; duration?: number; value?: never }\n\t| undefined;\n\n/** The credential an integration is connected with, for a consumer that has to hand it to another service. */\nexport interface IntegrationCredential {\n\t/** The id of the provider the token was issued for, which is the integration's own id. */\n\treadonly providerId: IntegrationIds;\n\treadonly accessToken: string;\n}\n\n/** Read options for {@link GitHostIntegration.searchMyPullRequests} and the provider hook behind it. */\nexport type SearchMyPullRequestsOptions = {\n\t/** Suppresses the user-facing notification when the read fails. */\n\tsilent?: boolean;\n\t/**\n\t * PR states to include (open/closed/merged/all). Providers that cannot express it in a single query\n\t * filter the normalized results; omitted preserves the historical open-only behavior.\n\t */\n\tstate?: PullRequestStateFilter;\n\tincludeReviewRequested?: boolean;\n};\n\n/** Read options for {@link GitHostIntegration.searchPullRequests} and the provider hook behind it. */\nexport type SearchPullRequestsOptions = {\n\t/** PR states to include; omitted preserves the provider's default. */\n\tinclude?: IssueOrPullRequestState[];\n};\n\n/** Read options for {@link GitHostIntegration.getMyPullRequestsForRepos}. */\nexport type MyPullRequestsForReposOptions = {\n\tfilters?: PullRequestFilter[];\n\tcursor?: string;\n\tcustomUrl?: string;\n\tpage?: number;\n\tpageSize?: number;\n\t/** PR states to include; when omitted the provider returns its default (open only). */\n\tstate?: PullRequestStateFilter | PullRequestStateFilter[];\n\t/** Requests the lightweight row shape without per-row build status or commit count. */\n\tsummary?: boolean;\n\t/**\n\t * Most per-repository requests one provider read keeps in flight. Defaults to 6. Only hosts that read repository\n\t * by repository fan out — GitLab, GitLab self-managed, Bitbucket Cloud, Bitbucket Data Center and Azure DevOps;\n\t * GitHub/GHE send one query whatever the repo count. A value that isn't a finite number >= 1 falls back to the\n\t * default.\n\t */\n\tscopeConcurrency?: number;\n\t/**\n\t * Azure DevOps only, repo-scoped: `false` skips the lookup that fills each row's clone URLs, saving one\n\t * request per repository (and fork source) per page. Rows then carry no `refs.base.url`/`refs.head.url`\n\t * (empty) and no `cloneHttps`/`cloneSsh`, so leave it on for rows that will be checked out or matched to local\n\t * remotes. Defaults to `true`; other providers ignore it.\n\t */\n\tincludeRemoteInfo?: boolean;\n};\n\n/** The members shared by every integration view. */\ninterface IntegrationViewBase {\n\treadonly type: IntegrationType;\n\treadonly id: IntegrationIds;\n\treadonly name: string;\n\t/**\n\t * The `gl-provider-<key>` glicon key for this provider, which is NOT always its id: a self-managed variant\n\t * draws with its cloud family's glyph.\n\t */\n\treadonly icon: string;\n\treadonly domain: string;\n\t/** Whether the integration has a session; `undefined` until it has looked. */\n\treadonly maybeConnected: boolean | undefined;\n\n\t/** Whether the user's plan allows this integration (a trial or paid account; GitHub and GitLab cloud always do). */\n\taccess(): Promise<boolean>;\n\tautolinks():\n\t\t| (AutolinkReference | DynamicAutolinkReference)[]\n\t\t| Promise<(AutolinkReference | DynamicAutolinkReference)[]>;\n\t/** Connects the integration, prompting the user if needed; whether it became connected. */\n\tconnect(source: Sources): Promise<boolean>;\n\tisConnected(): Promise<boolean>;\n\t/**\n\t * The credential the integration is connected with, refreshed first when it has expired; `undefined` when it isn't\n\t * connected or the refresh failed. An unexpired token is returned as is, so one the provider has since revoked still\n\t * comes back.\n\t */\n\tgetCredential(source: Sources): Promise<IntegrationCredential | undefined>;\n\tgetIssue(\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t\toptions?: { connectionId?: string; expiryOverride?: boolean | number },\n\t): Promise<Issue | undefined>;\n\tgetLinkedIssueOrPullRequest(\n\t\tresource: ResourceDescriptor,\n\t\tlink: { id: string; key: string },\n\t\toptions?: { expiryOverride?: boolean | number; type?: IssueOrPullRequestType; throwOnError?: boolean },\n\t): Promise<IssueOrPullRequest | undefined>;\n}\n\n/** A git host integration (GitHub, GitLab, Bitbucket, Azure DevOps, and their self-managed variants). */\nexport interface GitHostIntegration extends IntegrationViewBase {\n\treadonly type: 'git';\n\n\t/**\n\t * Removes a queued pull request from its base branch's merge queue, losing its place there. Results, failures and\n\t * cancellation as {@link GitHostIntegration.enqueuePullRequest}.\n\t */\n\tdequeuePullRequest(pr: PullRequest, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;\n\tdisconnect(options?: { silent?: boolean; currentSessionOnly?: boolean }): Promise<void>;\n\t/**\n\t * Adds a pull request to its base branch's merge queue (where `mergeQueueRequired` says merging means queueing).\n\t * The result says why on failure: the host's refusal (`already-queued`, `head-changed`, `permission`, …),\n\t * `unsupported` where this host has no merge queue to act on (only GitHub.com's is), or `unknown` for anything\n\t * else, including no connection or a failure to reach the host; the provider's message rides along for logs, not\n\t * for display. Cancellation throws `CancellationError`.\n\t */\n\tenqueuePullRequest(pr: PullRequest, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;\n\tgetAccountForCommit(\n\t\trepo: ResourceDescriptor,\n\t\trev: string,\n\t\toptions?: { avatarSize?: number },\n\t): Promise<Account | UnidentifiedAuthor | undefined>;\n\tgetCurrentAccount(options?: {\n\t\tavatarSize?: number;\n\t\tconnectionId?: string;\n\t\texpiryOverride?: boolean | number;\n\t}): Promise<Account | undefined>;\n\tgetDefaultBranch(\n\t\trepo: ResourceDescriptor,\n\t\toptions?: { cancellation?: AbortSignal; expiryOverride?: boolean | number },\n\t): Promise<DefaultBranch | undefined>;\n\t/**\n\t * Merge-queue entries for the given base branches of the repository, keyed by pull request number, for rows from a\n\t * read that selects no merge queue. Only hosts with a readable merge queue implement this (currently GitHub.com);\n\t * `undefined` means unavailable. Interim: expect it to go once every pull request read can carry its entry.\n\t */\n\tgetMergeQueueEntriesByPullRequestNumber?(\n\t\towner: string,\n\t\trepo: string,\n\t\tbranches: readonly string[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<Map<number, PullRequestMergeQueueEntry> | undefined>;\n\t/**\n\t * The current user's pull requests (or, without `filters`, every pull request) in `reposOrRepoIds`, one page at a\n\t * time; `undefined` when the read failed.\n\t */\n\tgetMyPullRequestsForRepos(\n\t\treposOrRepoIds: ProviderRepositoriesInput,\n\t\toptions?: MyPullRequestsForReposOptions,\n\t\tconnectionId?: string,\n\t): Promise<PagedResult<PullRequest> | undefined>;\n\tgetPullRequest(\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t\toptions?: { expiryOverride?: boolean | number; throwOnError?: boolean },\n\t): Promise<PullRequest | undefined>;\n\tgetPullRequestForBranch(\n\t\trepo: ResourceDescriptor,\n\t\tbranch: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t\texpiryOverride?: boolean | number;\n\t\t\tinclude?: IssueOrPullRequestState[];\n\t\t\t/**\n\t\t\t * Rethrow a failed lookup instead of folding it into `undefined`, for callers that must tell\n\t\t\t * \"no pull request\" apart from \"couldn't ask\".\n\t\t\t */\n\t\t\tthrowOnError?: boolean;\n\t\t},\n\t): Promise<PullRequest | undefined>;\n\tgetPullRequestForCommit(\n\t\trepo: ResourceDescriptor,\n\t\trev: string,\n\t\toptions?: { expiryOverride?: boolean | number; throwOnError?: boolean },\n\t): Promise<PullRequest | undefined>;\n\tgetPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined;\n\t/**\n\t * The repository a host reports for `repo`, or `undefined` when it can't be read. Only the hosts that can look a\n\t * repository up implement it.\n\t */\n\tgetRepoInfo?(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<Pick<ProviderRepositoryShape, 'id' | 'namespace' | 'name' | 'project'> | undefined>;\n\tgetRepositoryMetadata(\n\t\trepo: ResourceDescriptor,\n\t\toptions?: { cancellation?: AbortSignal; expiryOverride?: boolean | number },\n\t): Promise<RepositoryMetadata | undefined>;\n\t/**\n\t * The SSH signing keys (full OpenSSH-format `<type> <key> [comment]` strings) registered by the accounts matching\n\t * `emails`, for building an `allowed_signers` file. Keyed by lowercased email; an email with no match is absent.\n\t * A provider that doesn't expose signing keys (or isn't connected, or fails the read) returns an empty map.\n\t */\n\tgetSshSigningKeysForEmails(repo: ResourceDescriptor, emails: string[]): Promise<Map<string, string[]>>;\n\t/**\n\t * The ordered layers of the stack the given pull request belongs to, bottom to top. `undefined` when the host\n\t * has no stacks concept, the repository isn't enrolled, or the pull request isn't stacked.\n\t */\n\tgetStackLayersForPullRequest?(\n\t\towner: string,\n\t\trepo: string,\n\t\tpullRequestNumber: number,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequestStackLayers | undefined>;\n\t/**\n\t * Stack membership for every stacked pull request in the repository, keyed by pull request number. Only hosts\n\t * with a stacks concept implement this (currently GitHub).\n\t */\n\tgetStacksByPullRequestNumber?(\n\t\towner: string,\n\t\trepo: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Map<number, PullRequestStackInfo> | undefined>;\n\tmergePullRequest(\n\t\tpr: PullRequest,\n\t\toptions?: { mergeMethod?: PullRequestMergeMethod },\n\t\tcancellation?: AbortSignal,\n\t): Promise<boolean>;\n\t/** Account-wide (or repo-scoped) search for the current user's pull requests. */\n\tsearchMyPullRequests(\n\t\trepos?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions & { connectionId?: string },\n\t): Promise<IntegrationResult<PullRequest[] | undefined>>;\n\t/** Free-text search across pull requests, optionally narrowed to `repos`. */\n\tsearchPullRequests(\n\t\tsearchQuery: string,\n\t\trepos?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions & { connectionId?: string },\n\t): Promise<PullRequest[] | undefined>;\n}\n\n/** An issue tracker integration (Jira, Linear, Trello, and their self-managed variants). */\nexport interface IssuesIntegration extends IntegrationViewBase {\n\treadonly type: 'issues';\n}\n\nexport type Integration = GitHostIntegration | IssuesIntegration;\n\nexport type IntegrationById<T extends IntegrationIds> = T extends IssuesHostIntegrationIds\n\t? IssuesIntegration\n\t: GitHostIntegration;\n\n/**\n * What a consumer-owned cache is told about the integration a cached value was read through: enough to key the value\n * by host and to invalidate it when the connection or its credential changes.\n */\nexport interface IntegrationCacheDescriptor {\n\treadonly id: IntegrationIds;\n\treadonly domain?: string;\n\t/** Whether the integration has a session; `undefined` until it has looked. */\n\treadonly maybeConnected?: boolean;\n\t/** A hash of the current session's token, which changes when the account or token does. */\n\treadonly sessionFingerprint?: string;\n}\n\n/** Whether `value` is an integration. Replaces an `instanceof` check against the internal base class. */\nexport function isIntegration(value: unknown): value is Integration {\n\treturn value instanceof IntegrationBase;\n}\n\n/**\n * Whether `integration` is a git host. Generic so it narrows whatever integration type it is handed: the public\n * {@link Integration} views, or (inside the package) the classes, which implement them.\n */\nexport function isGitHostIntegration<T extends Integration>(\n\tintegration: T,\n): integration is Extract<T, { readonly type: 'git' }> {\n\treturn integration.type === 'git';\n}\n\n/** Whether `integration` is an issue tracker. Generic for the same reason as {@link isGitHostIntegration}. */\nexport function isIssuesIntegration<T extends Integration>(\n\tintegration: T,\n): integration is Extract<T, { readonly type: 'issues' }> {\n\treturn integration.type === 'issues';\n}\n"],"mappings":";;;AA0TA,SAAgB,cAAc,OAAsC;CACnE,OAAO,iBAAiB;AACzB;;;;;AAMA,SAAgB,qBACf,aACsD;CACtD,OAAO,YAAY,SAAS;AAC7B;;AAGA,SAAgB,oBACf,aACyD;CACzD,OAAO,YAAY,SAAS;AAC7B"}
|
|
1
|
+
{"version":3,"file":"publicIntegration.js","names":[],"sources":["../../../../../plus/integrations/src/models/publicIntegration.ts"],"sourcesContent":["import type { Account, UnidentifiedAuthor } from '@gitlens/git/models/author.js';\nimport type { AutolinkReference, DynamicAutolinkReference } from '@gitlens/git/models/autolink.js';\nimport type { DefaultBranch } from '@gitlens/git/models/defaultBranch.js';\nimport type { Issue } from '@gitlens/git/models/issue.js';\nimport type {\n\tIssueOrPullRequest,\n\tIssueOrPullRequestState,\n\tIssueOrPullRequestType,\n} from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestMergeMethod,\n\tPullRequestMergeQueueActionResult,\n\tPullRequestMergeQueueEntry,\n\tPullRequestStackInfo,\n\tPullRequestStackLayers,\n\tPullRequestStateFilter,\n} from '@gitlens/git/models/pullRequest.js';\nimport type { RepositoryMetadata } from '@gitlens/git/models/repositoryMetadata.js';\nimport type { ResourceDescriptor } from '@gitlens/git/models/resourceDescriptor.js';\nimport type { PullRequestUrlIdentity } from '@gitlens/git/utils/pullRequest.utils.js';\nimport type { PagedResult } from '@gitlens/utils/paging.js';\nimport type {\n\tGitCloudHostIntegrationId,\n\tIntegrationIds,\n\tIssuesCloudHostIntegrationId,\n\tIssuesHostIntegrationIds,\n} from '../constants.js';\nimport type { ProviderRepositoriesInput } from '../manager.js';\nimport type { PullRequestFilter } from '../providerFilters.js';\nimport type { ProviderRepositoryShape } from '../results.js';\nimport type { Sources } from '../telemetry.js';\nimport { IntegrationBase } from './integration.js';\n\n// The public, interface-only views of the integration classes: what a consumer of the `index.js` facade may call on\n// an integration. They are written out member by member, in package-owned and `@gitlens/*` types only, so nothing\n// a consumer can reach from them names `@gitkraken/provider-apis` or an internal class. The classes `implements`\n// these views, so the compiler keeps each class member assignable to the view's.\n// Code inside the package keeps importing the classes from `models/*`.\n// The views' doc comments are the consumer contract; the classes' doc comments are maintainer notes.\n\n/** The kind of an integration: a git host or an issue tracker. */\nexport type IntegrationType = 'git' | 'issues';\n\n// Keep this in step with `isSelfManagedHostIntegrationId`: it is the type-level twin of that predicate, and a\n// disagreement compiles cleanly while the runtime writes a domain-keyed key the type says is unkeyed (so the\n// local-disconnect flag is written under one key and read under another).\nexport type IntegrationKey<T extends IntegrationIds = IntegrationIds> = T extends\n\t| GitCloudHostIntegrationId\n\t| IssuesCloudHostIntegrationId\n\t? `${T}`\n\t: `${T}:${string}`;\n\nexport type IntegrationConnectedKey<T extends IntegrationIds = IntegrationIds> = `connected:${IntegrationKey<T>}`;\n\n/** A read's outcome: its value, or the error it failed with; `undefined` when there was nothing to read. */\nexport type IntegrationResult<T> =\n\t| { value: T; duration?: number; error?: Error }\n\t| { error: Error; duration?: number; value?: never }\n\t| undefined;\n\n/** The credential an integration is connected with, for a consumer that has to hand it to another service. */\nexport interface IntegrationCredential {\n\t/** The id of the provider the token was issued for, which is the integration's own id. */\n\treadonly providerId: IntegrationIds;\n\treadonly accessToken: string;\n}\n\n/** Read options for {@link GitHostIntegration.searchMyPullRequests} and the provider hook behind it. */\nexport type SearchMyPullRequestsOptions = {\n\t/** Suppresses the user-facing notification when the read fails. */\n\tsilent?: boolean;\n\t/**\n\t * PR states to include (open/closed/merged/all). Providers that cannot express it in a single query\n\t * filter the normalized results; omitted preserves the historical open-only behavior.\n\t */\n\tstate?: PullRequestStateFilter;\n\tincludeReviewRequested?: boolean;\n};\n\n/** Read options for {@link GitHostIntegration.searchPullRequests} and the provider hook behind it. */\nexport type SearchPullRequestsOptions = {\n\t/** PR states to include; omitted preserves the provider's default. */\n\tinclude?: IssueOrPullRequestState[];\n};\n\n/** Read options for {@link GitHostIntegration.getMyPullRequestsForRepos}. */\nexport type MyPullRequestsForReposOptions = {\n\tfilters?: PullRequestFilter[];\n\tcursor?: string;\n\tcustomUrl?: string;\n\tpage?: number;\n\tpageSize?: number;\n\t/** PR states to include; when omitted the provider returns its default (open only). */\n\tstate?: PullRequestStateFilter | PullRequestStateFilter[];\n\t/** Requests the lightweight row shape without per-row build status or commit count. */\n\tsummary?: boolean;\n\t/**\n\t * Most per-repository requests one provider read keeps in flight. Defaults to 6. Only hosts that read repository\n\t * by repository fan out — GitLab, GitLab self-managed, Bitbucket Cloud, Bitbucket Data Center and Azure DevOps;\n\t * GitHub/GHE send one query whatever the repo count. A value that isn't a finite number >= 1 falls back to the\n\t * default.\n\t */\n\tscopeConcurrency?: number;\n\t/**\n\t * Azure DevOps only, repo-scoped: `false` skips the lookup that fills each row's clone URLs, saving one\n\t * request per repository (and fork source) per page. Rows then carry no `refs.base.url`/`refs.head.url`\n\t * (empty) and no `cloneHttps`/`cloneSsh`, so leave it on for rows that will be checked out or matched to local\n\t * remotes. Defaults to `true`; other providers ignore it.\n\t */\n\tincludeRemoteInfo?: boolean;\n};\n\n/** The members shared by every integration view. */\ninterface IntegrationViewBase {\n\treadonly type: IntegrationType;\n\treadonly id: IntegrationIds;\n\treadonly name: string;\n\t/**\n\t * The `gl-provider-<key>` glicon key for this provider, which is NOT always its id: a self-managed variant\n\t * draws with its cloud family's glyph.\n\t */\n\treadonly icon: string;\n\treadonly domain: string;\n\t/** Whether the integration has a session; `undefined` until it has looked. */\n\treadonly maybeConnected: boolean | undefined;\n\n\t/** Whether the user's plan allows this integration (a trial or paid account; GitHub and GitLab cloud always do). */\n\taccess(): Promise<boolean>;\n\tautolinks():\n\t\t| (AutolinkReference | DynamicAutolinkReference)[]\n\t\t| Promise<(AutolinkReference | DynamicAutolinkReference)[]>;\n\t/** Connects the integration, prompting the user if needed; whether it became connected. */\n\tconnect(source: Sources): Promise<boolean>;\n\tisConnected(): Promise<boolean>;\n\t/**\n\t * The credential the integration is connected with, refreshed first when it has expired; `undefined` when it isn't\n\t * connected or the refresh failed. An unexpired token is returned as is, so one the provider has since revoked still\n\t * comes back.\n\t */\n\tgetCredential(source: Sources): Promise<IntegrationCredential | undefined>;\n\tgetIssue(\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t\toptions?: { connectionId?: string; expiryOverride?: boolean | number },\n\t): Promise<Issue | undefined>;\n\tgetLinkedIssueOrPullRequest(\n\t\tresource: ResourceDescriptor,\n\t\tlink: { id: string; key: string },\n\t\toptions?: { expiryOverride?: boolean | number; type?: IssueOrPullRequestType; throwOnError?: boolean },\n\t): Promise<IssueOrPullRequest | undefined>;\n}\n\n/** A git host integration (GitHub, GitLab, Bitbucket, Azure DevOps, and their self-managed variants). */\nexport interface GitHostIntegration extends IntegrationViewBase {\n\treadonly type: 'git';\n\n\t/**\n\t * Removes a queued pull request from its base branch's merge queue, losing its place there. Results, failures and\n\t * cancellation as {@link GitHostIntegration.enqueuePullRequest}.\n\t */\n\tdequeuePullRequest(pr: PullRequest, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;\n\tdisconnect(options?: { silent?: boolean; currentSessionOnly?: boolean }): Promise<void>;\n\t/**\n\t * Adds a pull request to its base branch's merge queue (where `mergeQueueRequired` says merging means queueing).\n\t * The result says why on failure: the host's refusal (`already-queued`, `head-changed`, `permission`, …),\n\t * `unsupported` where this host has no merge queue to act on (only GitHub.com's is), or `unknown` for anything\n\t * else, including no connection or a failure to reach the host; the provider's message rides along for logs, not\n\t * for display. Cancellation throws `CancellationError`.\n\t */\n\tenqueuePullRequest(pr: PullRequest, cancellation?: AbortSignal): Promise<PullRequestMergeQueueActionResult>;\n\tgetAccountForCommit(\n\t\trepo: ResourceDescriptor,\n\t\trev: string,\n\t\toptions?: { avatarSize?: number },\n\t): Promise<Account | UnidentifiedAuthor | undefined>;\n\t/** Gets the established local session's cache descriptor for this fetch remote, without resolving or refreshing it. */\n\tgetCachedPullRequestScope?(remoteUrl: string): IntegrationCacheDescriptor | undefined;\n\tgetCurrentAccount(options?: {\n\t\tavatarSize?: number;\n\t\tconnectionId?: string;\n\t\texpiryOverride?: boolean | number;\n\t}): Promise<Account | undefined>;\n\tgetDefaultBranch(\n\t\trepo: ResourceDescriptor,\n\t\toptions?: { cancellation?: AbortSignal; expiryOverride?: boolean | number },\n\t): Promise<DefaultBranch | undefined>;\n\t/**\n\t * Merge-queue entries for the given base branches of the repository, keyed by pull request number, for rows from a\n\t * read that selects no merge queue. Only hosts with a readable merge queue implement this (currently GitHub.com);\n\t * `undefined` means unavailable. Interim: expect it to go once every pull request read can carry its entry.\n\t */\n\tgetMergeQueueEntriesByPullRequestNumber?(\n\t\towner: string,\n\t\trepo: string,\n\t\tbranches: readonly string[],\n\t\tcancellation?: AbortSignal,\n\t): Promise<Map<number, PullRequestMergeQueueEntry> | undefined>;\n\t/**\n\t * The current user's pull requests (or, without `filters`, every pull request) in `reposOrRepoIds`, one page at a\n\t * time; `undefined` when the read failed.\n\t */\n\tgetMyPullRequestsForRepos(\n\t\treposOrRepoIds: ProviderRepositoriesInput,\n\t\toptions?: MyPullRequestsForReposOptions,\n\t\tconnectionId?: string,\n\t): Promise<PagedResult<PullRequest> | undefined>;\n\tgetPullRequest(\n\t\tresource: ResourceDescriptor,\n\t\tid: string,\n\t\toptions?: { expiryOverride?: boolean | number; throwOnError?: boolean },\n\t): Promise<PullRequest | undefined>;\n\tgetPullRequestForBranch(\n\t\trepo: ResourceDescriptor,\n\t\tbranch: string,\n\t\toptions?: {\n\t\t\tavatarSize?: number;\n\t\t\texpiryOverride?: boolean | number;\n\t\t\tinclude?: IssueOrPullRequestState[];\n\t\t\t/**\n\t\t\t * Rethrow a failed lookup instead of folding it into `undefined`, for callers that must tell\n\t\t\t * \"no pull request\" apart from \"couldn't ask\".\n\t\t\t */\n\t\t\tthrowOnError?: boolean;\n\t\t},\n\t): Promise<PullRequest | undefined>;\n\tgetPullRequestForCommit(\n\t\trepo: ResourceDescriptor,\n\t\trev: string,\n\t\toptions?: { expiryOverride?: boolean | number; throwOnError?: boolean },\n\t): Promise<PullRequest | undefined>;\n\tgetPullRequestIdentityFromMaybeUrl(search: string): PullRequestUrlIdentity | undefined;\n\t/**\n\t * The repository a host reports for `repo`, or `undefined` when it can't be read. Only the hosts that can look a\n\t * repository up implement it.\n\t */\n\tgetRepoInfo?(repo: {\n\t\towner: string;\n\t\tname: string;\n\t\tproject?: string;\n\t\tconnectionId?: string;\n\t}): Promise<Pick<ProviderRepositoryShape, 'id' | 'namespace' | 'name' | 'project'> | undefined>;\n\tgetRepositoryMetadata(\n\t\trepo: ResourceDescriptor,\n\t\toptions?: { cancellation?: AbortSignal; expiryOverride?: boolean | number },\n\t): Promise<RepositoryMetadata | undefined>;\n\t/**\n\t * The SSH signing keys (full OpenSSH-format `<type> <key> [comment]` strings) registered by the accounts matching\n\t * `emails`, for building an `allowed_signers` file. Keyed by lowercased email; an email with no match is absent.\n\t * A provider that doesn't expose signing keys (or isn't connected, or fails the read) returns an empty map.\n\t */\n\tgetSshSigningKeysForEmails(repo: ResourceDescriptor, emails: string[]): Promise<Map<string, string[]>>;\n\t/**\n\t * The ordered layers of the stack the given pull request belongs to, bottom to top. `undefined` when the host\n\t * has no stacks concept, the repository isn't enrolled, or the pull request isn't stacked.\n\t */\n\tgetStackLayersForPullRequest?(\n\t\towner: string,\n\t\trepo: string,\n\t\tpullRequestNumber: number,\n\t\tcancellation?: AbortSignal,\n\t): Promise<PullRequestStackLayers | undefined>;\n\t/**\n\t * Stack membership for every stacked pull request in the repository, keyed by pull request number. Only hosts\n\t * with a stacks concept implement this (currently GitHub).\n\t */\n\tgetStacksByPullRequestNumber?(\n\t\towner: string,\n\t\trepo: string,\n\t\tcancellation?: AbortSignal,\n\t): Promise<Map<number, PullRequestStackInfo> | undefined>;\n\tmergePullRequest(\n\t\tpr: PullRequest,\n\t\toptions?: { mergeMethod?: PullRequestMergeMethod },\n\t\tcancellation?: AbortSignal,\n\t): Promise<boolean>;\n\t/** Account-wide (or repo-scoped) search for the current user's pull requests. */\n\tsearchMyPullRequests(\n\t\trepos?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchMyPullRequestsOptions & { connectionId?: string },\n\t): Promise<IntegrationResult<PullRequest[] | undefined>>;\n\t/** Free-text search across pull requests, optionally narrowed to `repos`. */\n\tsearchPullRequests(\n\t\tsearchQuery: string,\n\t\trepos?: ResourceDescriptor | ResourceDescriptor[],\n\t\tcancellation?: AbortSignal,\n\t\toptions?: SearchPullRequestsOptions & { connectionId?: string },\n\t): Promise<PullRequest[] | undefined>;\n}\n\n/** An issue tracker integration (Jira, Linear, Trello, and their self-managed variants). */\nexport interface IssuesIntegration extends IntegrationViewBase {\n\treadonly type: 'issues';\n}\n\nexport type Integration = GitHostIntegration | IssuesIntegration;\n\nexport type IntegrationById<T extends IntegrationIds> = T extends IssuesHostIntegrationIds\n\t? IssuesIntegration\n\t: GitHostIntegration;\n\n/**\n * What a consumer-owned cache is told about the integration a cached value was read through: enough to key the value\n * by host and to invalidate it when the connection or its credential changes.\n */\nexport interface IntegrationCacheDescriptor {\n\treadonly id: IntegrationIds;\n\treadonly domain?: string;\n\t/** The HTTP(S) origin used by the selected session for this Enterprise pull request read. */\n\treadonly installationOrigin?: string;\n\t/** Whether the integration has a session; `undefined` until it has looked. */\n\treadonly maybeConnected?: boolean;\n\t/** A hash of the current session's token, which changes when the account or token does. */\n\treadonly sessionFingerprint?: string;\n}\n\n/** Whether `value` is an integration. Replaces an `instanceof` check against the internal base class. */\nexport function isIntegration(value: unknown): value is Integration {\n\treturn value instanceof IntegrationBase;\n}\n\n/**\n * Whether `integration` is a git host. Generic so it narrows whatever integration type it is handed: the public\n * {@link Integration} views, or (inside the package) the classes, which implement them.\n */\nexport function isGitHostIntegration<T extends Integration>(\n\tintegration: T,\n): integration is Extract<T, { readonly type: 'git' }> {\n\treturn integration.type === 'git';\n}\n\n/** Whether `integration` is an issue tracker. Generic for the same reason as {@link isGitHostIntegration}. */\nexport function isIssuesIntegration<T extends Integration>(\n\tintegration: T,\n): integration is Extract<T, { readonly type: 'issues' }> {\n\treturn integration.type === 'issues';\n}\n"],"mappings":";;;AA8TA,SAAgB,cAAc,OAAsC;CACnE,OAAO,iBAAiB;AACzB;;;;;AAMA,SAAgB,qBACf,aACsD;CACtD,OAAO,YAAY,SAAS;AAC7B;;AAGA,SAAgB,oBACf,aACyD;CACzD,OAAO,YAAY,SAAS;AAC7B"}
|
|
@@ -8,14 +8,14 @@ import { DefaultBranch } from "../../../git/models/defaultBranch.js";
|
|
|
8
8
|
import { PullRequestActivityPage } from "../../../git/models/pullRequestActivity.js";
|
|
9
9
|
import { RepositoryMetadata } from "../../../git/models/repositoryMetadata.js";
|
|
10
10
|
import { PullRequestUrlIdentity } from "../../../git/utils/pullRequest.utils.js";
|
|
11
|
-
import { GitHubIssueMutation, IssueWriteResult } from "../../git-github/api/issueWrites.js";
|
|
12
11
|
import { GitHubPullRequestCreateTarget, GitHubPullRequestWrite, GitHubPullRequestWriteTarget, PullRequestCreateCapabilityResult, PullRequestWriteResult, PullRequestWriteTargetResult } from "../../git-github/api/pullRequestWrites.js";
|
|
12
|
+
import { GitHubIssueMutation, IssueWriteResult } from "../../git-github/api/issueWrites.js";
|
|
13
13
|
import { ProviderAuthenticationSession } from "../authentication/models.js";
|
|
14
14
|
import { GitCloudHostIntegrationId, GitSelfManagedHostIntegrationId } from "../constants.js";
|
|
15
15
|
import { IntegrationAuthenticationProviderDescriptor } from "../authentication/integrationAuthenticationProvider.js";
|
|
16
16
|
import { IssueEtagFields, IssueEtagInclude, PullRequestEtagFields, PullRequestEtagInclude } from "../reads/etag.js";
|
|
17
17
|
import { ProviderOrganization, ProviderWarningCause } from "../results.js";
|
|
18
|
-
import { SearchMyPullRequestsOptions, SearchPullRequestsOptions } from "../models/publicIntegration.js";
|
|
18
|
+
import { IntegrationCacheDescriptor, SearchMyPullRequestsOptions, SearchPullRequestsOptions } from "../models/publicIntegration.js";
|
|
19
19
|
import { IntegrationServiceContext } from "../context.js";
|
|
20
20
|
import { ProviderRefusal } from "../collectionMetadata.js";
|
|
21
21
|
import { ProviderPullRequestCount, ProviderPullRequestSearchPage } from "../models/pullRequestReads.js";
|
|
@@ -40,6 +40,19 @@ declare abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> ex
|
|
|
40
40
|
expectedLogin?: string;
|
|
41
41
|
installationOrigin?: string;
|
|
42
42
|
}): Promise<IssueWriteResult>;
|
|
43
|
+
resolvePullRequestWriteTarget(connectionId: string, input: GitHubPullRequestWriteTarget, scope: {
|
|
44
|
+
expectedLogin?: string;
|
|
45
|
+
installationOrigin?: string;
|
|
46
|
+
}): Promise<PullRequestWriteTargetResult>;
|
|
47
|
+
writePullRequest(connectionId: string, input: GitHubPullRequestWrite, scope: {
|
|
48
|
+
expectedLogin?: string;
|
|
49
|
+
installationOrigin?: string;
|
|
50
|
+
}): Promise<PullRequestWriteResult>;
|
|
51
|
+
getPullRequestCreateCapability(connectionId: string, input: GitHubPullRequestCreateTarget, scope: {
|
|
52
|
+
expectedLogin?: string;
|
|
53
|
+
installationOrigin?: string;
|
|
54
|
+
}): Promise<PullRequestCreateCapabilityResult>;
|
|
55
|
+
private withPullRequestWriteSession;
|
|
43
56
|
protected getProviderAccountForCommit(session: ProviderAuthenticationSession, repo: GitHubRepositoryDescriptor, rev: string, options?: {
|
|
44
57
|
avatarSize?: number;
|
|
45
58
|
}): Promise<Account | UnidentifiedAuthor | undefined>;
|
|
@@ -318,10 +331,6 @@ export declare class GitHubIntegration extends GitHubIntegrationBase<GitCloudHos
|
|
|
318
331
|
protected readonly key = GitCloudHostIntegrationId.GitHub;
|
|
319
332
|
readonly name: string;
|
|
320
333
|
get domain(): string;
|
|
321
|
-
resolvePullRequestWriteTarget(connectionId: string, input: GitHubPullRequestWriteTarget): Promise<PullRequestWriteTargetResult>;
|
|
322
|
-
writePullRequest(connectionId: string, input: GitHubPullRequestWrite): Promise<PullRequestWriteResult>;
|
|
323
|
-
getPullRequestCreateCapability(connectionId: string, input: GitHubPullRequestCreateTarget): Promise<PullRequestCreateCapabilityResult>;
|
|
324
|
-
private withPullRequestWriteSession;
|
|
325
334
|
protected apiBaseUrlFor(_session: ProviderAuthenticationSession): string | undefined;
|
|
326
335
|
access(): Promise<boolean>;
|
|
327
336
|
refresh(): Promise<void>;
|
|
@@ -333,7 +342,11 @@ export declare class GitHubEnterpriseIntegration extends GitHubIntegrationBase<G
|
|
|
333
342
|
protected readonly key: `cloud-github-enterprise:${string}`;
|
|
334
343
|
readonly name = "GitHub Enterprise";
|
|
335
344
|
get domain(): string;
|
|
345
|
+
private readonly _removedSessions;
|
|
346
|
+
getCachedPullRequestScope(remoteUrl: string): IntegrationCacheDescriptor | undefined;
|
|
347
|
+
onSessionsRemoving(connectionId?: string, cloud?: boolean): void;
|
|
336
348
|
protected apiBaseUrlFor(session: ProviderAuthenticationSession): string;
|
|
349
|
+
protected getPullRequestCacheDescriptor(session: ProviderAuthenticationSession): IntegrationCacheDescriptor;
|
|
337
350
|
constructor(ctx: IntegrationServiceContext, authenticationService: IntegrationAuthenticationService, getProvidersApi: () => Promise<ProvidersApi>, didChangeConnection: Emitter<IntegrationConnectionChangeEvent>, _domain: string);
|
|
338
351
|
}
|
|
339
352
|
//#endregion
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { chunk } from "../../../utils/array.js";
|
|
2
2
|
import { batch, mapBounded, mapSettledBounded } from "../../../utils/promise.js";
|
|
3
3
|
import { AuthenticationError, RequestNotFoundError } from "../../../git/errors.js";
|
|
4
|
+
import { parseGitRemoteUrl } from "../../../git/utils/remote.utils.js";
|
|
4
5
|
import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
|
|
5
6
|
import "../../../git/models/pullRequest.js";
|
|
6
7
|
import { decodeGitHubCheckRunId, fromGitHubCheckContextState, fromGitHubIssueOrPullRequestState, fromGitHubMergeQueueEntryState, fromGitHubMergeQueueRemoval, fromGitHubPullRequestMergeableState, fromGitHubPullRequestReviewDecision, fromGitHubPullRequestStatusCheckRollupState, toGitHubCheckRunId } from "../../git-github/models.js";
|
|
@@ -10,6 +11,8 @@ import { toCollectionScopeFailure } from "../collectionMetadata.js";
|
|
|
10
11
|
import "../providerFilters.js";
|
|
11
12
|
import { resolveBranchPullRequests } from "./utils/providerPaging.js";
|
|
12
13
|
import { providersMetadata } from "./metadata.js";
|
|
14
|
+
import { areDomainsOnSameHostname, isWebRemoteScheme } from "../utils/domain.utils.js";
|
|
15
|
+
import { getGitHubEnterprisePullRequestWriteOrigin } from "../utils/integration.utils.js";
|
|
13
16
|
import { getSessionIdentity, toTokenWithInfo } from "../authentication/models.js";
|
|
14
17
|
import { getProviderPullRequestIdentity, stampNativePullRequest } from "./models.js";
|
|
15
18
|
import { pullRequestCheckRunsEtag } from "../reads/etag.js";
|
|
@@ -166,7 +169,7 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
|
|
|
166
169
|
let result;
|
|
167
170
|
try {
|
|
168
171
|
if (expectedLogin !== void 0) {
|
|
169
|
-
if ((await api.
|
|
172
|
+
if ((await api.getWriteViewer(this, token, baseUrl, onUnauthorized))?.toLowerCase() !== expectedLogin.toLowerCase()) return {
|
|
170
173
|
ok: false,
|
|
171
174
|
reason: "no-connection"
|
|
172
175
|
};
|
|
@@ -202,6 +205,96 @@ var GitHubIntegrationBase = class extends GitHostIntegration {
|
|
|
202
205
|
} : failure;
|
|
203
206
|
}
|
|
204
207
|
}
|
|
208
|
+
async resolvePullRequestWriteTarget(connectionId, input, scope) {
|
|
209
|
+
return this.withPullRequestWriteSession(connectionId, "read", scope, (api, token, options) => api.resolvePullRequestWriteTarget(this, token, input, options.onUnauthorized, options.baseUrl));
|
|
210
|
+
}
|
|
211
|
+
async writePullRequest(connectionId, input, scope) {
|
|
212
|
+
const result = await this.withPullRequestWriteSession(connectionId, "write", scope, (api, token, options) => api.writePullRequest(this, token, input, options.isSessionCurrent, options.onUnauthorized, options.baseUrl));
|
|
213
|
+
if (result.ok || result.reason === "outcome-unknown" || scope.installationOrigin == null && (input.action === "merge" || input.action === "enqueue")) {
|
|
214
|
+
const domain = scope.installationOrigin;
|
|
215
|
+
this.ctx.cache.deletePullRequests(domain == null ? void 0 : {
|
|
216
|
+
id: this.id,
|
|
217
|
+
domain
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
async getPullRequestCreateCapability(connectionId, input, scope) {
|
|
223
|
+
return this.withPullRequestWriteSession(connectionId, "read", scope, (api, token, options) => api.getPullRequestCreateCapability(this, token, input, options.onUnauthorized, options.baseUrl));
|
|
224
|
+
}
|
|
225
|
+
async withPullRequestWriteSession(connectionId, operation, { expectedLogin, installationOrigin }, run) {
|
|
226
|
+
try {
|
|
227
|
+
const session = await this.resolveReadSessionOrThrow(connectionId, void 0);
|
|
228
|
+
if (session?.id !== connectionId || !session.accessToken) return {
|
|
229
|
+
ok: false,
|
|
230
|
+
reason: "no-connection"
|
|
231
|
+
};
|
|
232
|
+
if (installationOrigin != null && getGitHubEnterprisePullRequestWriteOrigin(session.baseUrl ?? (session.domain || this.domain), session.protocol) !== installationOrigin) return {
|
|
233
|
+
ok: false,
|
|
234
|
+
reason: "no-connection"
|
|
235
|
+
};
|
|
236
|
+
const api = await this.authenticationService.apis.github;
|
|
237
|
+
if (api == null) return {
|
|
238
|
+
ok: false,
|
|
239
|
+
reason: "unsupported"
|
|
240
|
+
};
|
|
241
|
+
const baseUrl = this.apiBaseUrlFor(session);
|
|
242
|
+
if (baseUrl !== (installationOrigin == null ? void 0 : `${installationOrigin}/api/v3`)) return {
|
|
243
|
+
ok: false,
|
|
244
|
+
reason: "no-connection"
|
|
245
|
+
};
|
|
246
|
+
const isSessionCurrent = baseUrl != null ? this.authenticationService.trackStoredSession(this.id, session) : async () => {
|
|
247
|
+
const current = await this.resolveReadSessionOrThrow(connectionId, void 0);
|
|
248
|
+
return current != null && getSessionIdentity(current) === getSessionIdentity(session) && current.account?.id === session.account?.id;
|
|
249
|
+
};
|
|
250
|
+
const token = toTokenWithInfo(this.id, session);
|
|
251
|
+
let unauthorized = false;
|
|
252
|
+
const onUnauthorized = () => {
|
|
253
|
+
unauthorized = true;
|
|
254
|
+
};
|
|
255
|
+
let result;
|
|
256
|
+
try {
|
|
257
|
+
if (expectedLogin !== void 0) {
|
|
258
|
+
if (!await isSessionCurrent()) return {
|
|
259
|
+
ok: false,
|
|
260
|
+
reason: "no-connection"
|
|
261
|
+
};
|
|
262
|
+
if ((await api.getWriteViewer(this, token, baseUrl, onUnauthorized))?.toLowerCase() !== expectedLogin.toLowerCase() || !await isSessionCurrent()) return {
|
|
263
|
+
ok: false,
|
|
264
|
+
reason: "no-connection"
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
result = await run(api, token, {
|
|
268
|
+
baseUrl,
|
|
269
|
+
onUnauthorized,
|
|
270
|
+
isSessionCurrent
|
|
271
|
+
});
|
|
272
|
+
} catch (ex) {
|
|
273
|
+
result = pullRequestWriteFailure(ex);
|
|
274
|
+
}
|
|
275
|
+
if (unauthorized) {
|
|
276
|
+
if (await isSessionCurrent().catch(() => false)) this.handleConnectionAuthenticationRejection(connectionId, true, session.accessToken);
|
|
277
|
+
return {
|
|
278
|
+
ok: false,
|
|
279
|
+
reason: "no-connection"
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
if (result.ok) {
|
|
283
|
+
if (operation === "read" ? await isSessionCurrent() : await isSessionCurrent().catch(() => false)) this.resetRequestExceptionCount("writePullRequest", connectionId);
|
|
284
|
+
else if (operation === "read") return {
|
|
285
|
+
ok: false,
|
|
286
|
+
reason: "no-connection"
|
|
287
|
+
};
|
|
288
|
+
else if (baseUrl != null) return {
|
|
289
|
+
...result,
|
|
290
|
+
credentialChanged: true
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
} catch (ex) {
|
|
295
|
+
return pullRequestWriteFailure(ex);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
205
298
|
async getProviderAccountForCommit(session, repo, rev, options) {
|
|
206
299
|
return (await this.authenticationService.apis.github)?.getAccountForCommit(this, toTokenWithInfo(this.id, session), repo.owner, repo.name, rev, {
|
|
207
300
|
...options,
|
|
@@ -934,58 +1027,6 @@ var GitHubIntegration = class extends GitHubIntegrationBase {
|
|
|
934
1027
|
get domain() {
|
|
935
1028
|
return metadata.domain;
|
|
936
1029
|
}
|
|
937
|
-
async resolvePullRequestWriteTarget(connectionId, input) {
|
|
938
|
-
return this.withPullRequestWriteSession(connectionId, "read", (api, token, onUnauthorized) => api.resolvePullRequestWriteTarget(this, token, input, onUnauthorized));
|
|
939
|
-
}
|
|
940
|
-
async writePullRequest(connectionId, input) {
|
|
941
|
-
const result = await this.withPullRequestWriteSession(connectionId, "write", (api, token, onUnauthorized, isSessionCurrent) => api.writePullRequest(this, token, input, isSessionCurrent, onUnauthorized));
|
|
942
|
-
if (result.ok || result.reason === "outcome-unknown" || input.action === "merge" || input.action === "enqueue") this.ctx.cache.deletePullRequests();
|
|
943
|
-
return result;
|
|
944
|
-
}
|
|
945
|
-
async getPullRequestCreateCapability(connectionId, input) {
|
|
946
|
-
return this.withPullRequestWriteSession(connectionId, "read", (api, token, onUnauthorized) => api.getPullRequestCreateCapability(this, token, input, onUnauthorized));
|
|
947
|
-
}
|
|
948
|
-
async withPullRequestWriteSession(connectionId, operation, run) {
|
|
949
|
-
try {
|
|
950
|
-
const session = await this.resolveReadSessionOrThrow(connectionId, void 0);
|
|
951
|
-
if (session?.id !== connectionId || !session.accessToken) return {
|
|
952
|
-
ok: false,
|
|
953
|
-
reason: "no-connection"
|
|
954
|
-
};
|
|
955
|
-
const api = await this.authenticationService.apis.github;
|
|
956
|
-
if (api == null) return {
|
|
957
|
-
ok: false,
|
|
958
|
-
reason: "unsupported"
|
|
959
|
-
};
|
|
960
|
-
const identity = getSessionIdentity(session);
|
|
961
|
-
const accountId = session.account?.id;
|
|
962
|
-
const isSessionCurrent = async () => {
|
|
963
|
-
const current = await this.resolveReadSessionOrThrow(connectionId, void 0);
|
|
964
|
-
return current != null && getSessionIdentity(current) === identity && current.account?.id === accountId;
|
|
965
|
-
};
|
|
966
|
-
let unauthorized = false;
|
|
967
|
-
const result = await run(api, toTokenWithInfo(this.id, session), () => {
|
|
968
|
-
unauthorized = true;
|
|
969
|
-
}, isSessionCurrent);
|
|
970
|
-
if (unauthorized) {
|
|
971
|
-
if (await isSessionCurrent().catch(() => false)) this.handleConnectionAuthenticationRejection(connectionId, true, session.accessToken);
|
|
972
|
-
return {
|
|
973
|
-
ok: false,
|
|
974
|
-
reason: "no-connection"
|
|
975
|
-
};
|
|
976
|
-
}
|
|
977
|
-
if (result.ok) {
|
|
978
|
-
if (operation === "read" ? await isSessionCurrent() : await isSessionCurrent().catch(() => false)) this.resetRequestExceptionCount("writePullRequest", connectionId);
|
|
979
|
-
else if (operation === "read") return {
|
|
980
|
-
ok: false,
|
|
981
|
-
reason: "no-connection"
|
|
982
|
-
};
|
|
983
|
-
}
|
|
984
|
-
return result;
|
|
985
|
-
} catch (ex) {
|
|
986
|
-
return pullRequestWriteFailure(ex);
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
1030
|
apiBaseUrlFor(_session) {}
|
|
990
1031
|
access() {
|
|
991
1032
|
return Promise.resolve(true);
|
|
@@ -1005,9 +1046,41 @@ var GitHubEnterpriseIntegration = class extends GitHubIntegrationBase {
|
|
|
1005
1046
|
get domain() {
|
|
1006
1047
|
return this._domain;
|
|
1007
1048
|
}
|
|
1049
|
+
_removedSessions = /* @__PURE__ */ new WeakSet();
|
|
1050
|
+
getCachedPullRequestScope(remoteUrl) {
|
|
1051
|
+
const session = this._session;
|
|
1052
|
+
if (!session?.accessToken || this.connectionExpired === true || this._removedSessions.has(session) || session.id !== this.authenticationService.getPrimaryConnectionId(this.authProvider.id, this.authProviderDescriptor)) return;
|
|
1053
|
+
const descriptor = this.getPullRequestCacheDescriptor(session);
|
|
1054
|
+
const { installationOrigin } = descriptor;
|
|
1055
|
+
if (installationOrigin == null) return void 0;
|
|
1056
|
+
const [scheme, domain, path] = parseGitRemoteUrl(remoteUrl);
|
|
1057
|
+
if (!domain || !path) return void 0;
|
|
1058
|
+
if (isWebRemoteScheme(scheme)) return URL.parse(remoteUrl)?.origin === installationOrigin ? descriptor : void 0;
|
|
1059
|
+
if (scheme != null && scheme !== "ssh://") return void 0;
|
|
1060
|
+
const hostname = scheme === "ssh://" ? URL.parse(remoteUrl)?.hostname : domain;
|
|
1061
|
+
return areDomainsOnSameHostname(hostname, installationOrigin) ? descriptor : void 0;
|
|
1062
|
+
}
|
|
1063
|
+
onSessionsRemoving(connectionId, cloud) {
|
|
1064
|
+
const session = this._session;
|
|
1065
|
+
if (session != null && (connectionId == null || connectionId === session.id) && (cloud == null || cloud === session.cloud)) this._removedSessions.add(session);
|
|
1066
|
+
super.onSessionsRemoving(connectionId, cloud);
|
|
1067
|
+
}
|
|
1008
1068
|
apiBaseUrlFor(session) {
|
|
1009
1069
|
return this.getSelfManagedApiBaseUrl(session);
|
|
1010
1070
|
}
|
|
1071
|
+
getPullRequestCacheDescriptor(session) {
|
|
1072
|
+
try {
|
|
1073
|
+
return {
|
|
1074
|
+
id: this.id,
|
|
1075
|
+
domain: this.domain,
|
|
1076
|
+
maybeConnected: true,
|
|
1077
|
+
installationOrigin: new URL(this.apiBaseUrlFor(session)).origin,
|
|
1078
|
+
sessionFingerprint: this.getSessionFingerprint(session)
|
|
1079
|
+
};
|
|
1080
|
+
} catch {
|
|
1081
|
+
return this;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1011
1084
|
constructor(ctx, authenticationService, getProvidersApi, didChangeConnection, _domain) {
|
|
1012
1085
|
super(ctx, authenticationService, getProvidersApi, didChangeConnection);
|
|
1013
1086
|
this._domain = _domain;
|