@gitkraken/core-gitlens 0.7.0 → 0.7.2
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 +28 -2
- package/dist/git/remotes/azure-devops.js +3 -3
- package/dist/git/remotes/azure-devops.js.map +1 -1
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +9 -2
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +1 -1
- package/dist/plus/integrations/collectionMetadata.d.ts +48 -3
- package/dist/plus/integrations/collectionMetadata.js +138 -8
- package/dist/plus/integrations/collectionMetadata.js.map +1 -1
- package/dist/plus/integrations/errors.d.ts +3 -1
- package/dist/plus/integrations/errors.js +7 -3
- package/dist/plus/integrations/errors.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +3 -3
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +35 -1
- package/dist/plus/integrations/integrationService.js +90 -43
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/lite.js +5 -4
- package/dist/plus/integrations/lite.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +68 -23
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +31 -15
- package/dist/plus/integrations/models/gitHostIntegration.js +71 -22
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
- package/dist/plus/integrations/models/integration.d.ts +70 -12
- package/dist/plus/integrations/models/integration.js +56 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/models/issueReads.d.ts +17 -0
- package/dist/plus/integrations/models/issuesIntegration.js +2 -0
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
- package/dist/plus/integrations/models/pullRequestReads.d.ts +26 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts +66 -1
- package/dist/plus/integrations/providers/azure/azure.js +192 -12
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/search.d.ts +144 -0
- package/dist/plus/integrations/providers/azure/search.js +250 -0
- package/dist/plus/integrations/providers/azure/search.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +73 -36
- package/dist/plus/integrations/providers/azureDevOps.js +191 -122
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
- package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +176 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js +560 -0
- package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/discovery.d.ts +12 -0
- package/dist/plus/integrations/providers/bitbucket-server/discovery.js +128 -0
- package/dist/plus/integrations/providers/bitbucket-server/discovery.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts +10 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -2
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.d.ts +58 -0
- package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js +485 -0
- package/dist/plus/integrations/providers/bitbucket-server/pullRequestSearch.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +61 -3
- package/dist/plus/integrations/providers/bitbucket-server.js +114 -20
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket.d.ts +9 -1
- package/dist/plus/integrations/providers/bitbucket.js +13 -2
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +6 -6
- package/dist/plus/integrations/providers/github.js +35 -34
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab.d.ts +6 -4
- package/dist/plus/integrations/providers/gitlab.js +32 -28
- package/dist/plus/integrations/providers/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/providers/jira-server.d.ts +9 -0
- package/dist/plus/integrations/providers/jira-server.js +15 -7
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +9 -0
- package/dist/plus/integrations/providers/jira.js +14 -2
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.js +2 -2
- package/dist/plus/integrations/providers/models.d.ts +10 -1
- package/dist/plus/integrations/providers/models.js +86 -0
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.d.ts +10 -0
- package/dist/plus/integrations/providers/providersApi.js +18 -3
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/providers/utils.d.ts +12 -1
- package/dist/plus/integrations/providers/utils.js +36 -6
- package/dist/plus/integrations/providers/utils.js.map +1 -1
- package/dist/plus/integrations/reads/broaden.js +6 -6
- package/dist/plus/integrations/reads/broaden.js.map +1 -1
- package/dist/plus/integrations/reads/context.d.ts +1 -1
- package/dist/plus/integrations/reads/counts.d.ts +18 -4
- package/dist/plus/integrations/reads/counts.js +66 -15
- package/dist/plus/integrations/reads/counts.js.map +1 -1
- package/dist/plus/integrations/reads/cursors.js +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +2 -1
- package/dist/plus/integrations/reads/drains.js +1 -1
- package/dist/plus/integrations/reads/filters.d.ts +1 -1
- package/dist/plus/integrations/reads/filters.js +17 -12
- package/dist/plus/integrations/reads/filters.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.js +2 -2
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -1
- package/dist/plus/integrations/reads/hierarchy.utils.js +1 -1
- package/dist/plus/integrations/reads/issueBatch.js +1 -1
- package/dist/plus/integrations/reads/issueTracker.js +2 -2
- package/dist/plus/integrations/reads/issues.js +2 -2
- package/dist/plus/integrations/reads/paging.js +1 -1
- package/dist/plus/integrations/reads/resolveRepository.d.ts +12 -11
- package/dist/plus/integrations/reads/resolveRepository.js +110 -19
- package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
- package/dist/plus/integrations/reads/searchIssues.js +4 -2
- package/dist/plus/integrations/reads/searchIssues.js.map +1 -1
- package/dist/plus/integrations/reads/searchPullRequests.js +9 -3
- package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
- package/dist/plus/integrations/reads/sweeps.js +1 -1
- package/dist/plus/integrations/reads/trackerIssue.d.ts +9 -5
- package/dist/plus/integrations/reads/trackerIssue.js +15 -9
- package/dist/plus/integrations/reads/trackerIssue.js.map +1 -1
- package/dist/plus/integrations/reads/warnings.d.ts +6 -2
- package/dist/plus/integrations/reads/warnings.js +15 -19
- package/dist/plus/integrations/reads/warnings.js.map +1 -1
- package/dist/plus/integrations/results.d.ts +84 -6
- package/dist/plus/integrations/results.js +9 -2
- package/dist/plus/integrations/results.js.map +1 -1
- package/dist/plus/integrations/utils/domain.utils.d.ts +19 -0
- package/dist/plus/integrations/utils/domain.utils.js +36 -1
- package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
- package/dist/plus/integrations/utils/integration.utils.d.ts +1 -0
- package/dist/plus/integrations/utils/integration.utils.js +12 -1
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
- package/docs/integrations.md +263 -74
- package/docs/kepler-read-api-parity.md +19 -6
- package/package.json +1 -1
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
//#region ../plus/integrations/src/utils/domain.utils.d.ts
|
|
2
2
|
/** Extracts the host from a domain expressed as either a URL or a bare host. */
|
|
3
3
|
export declare function hostFromDomain(domain: string | undefined): string | undefined;
|
|
4
|
+
/** Multiple accounts on the same host are unambiguous; an unknown configured host is not. */
|
|
5
|
+
export declare function getSingleConfiguredDomain(configured: readonly {
|
|
6
|
+
domain?: string;
|
|
7
|
+
}[]): string | undefined;
|
|
4
8
|
/** Whether two URL-or-host domain values identify the same normalized host and port. */
|
|
5
9
|
export declare function areDomainsOnSameHost(first: string | undefined, second: string | undefined): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether two URL-or-host domain values name the same machine, ignoring the port. For comparing an SSH remote
|
|
12
|
+
* against a web address: an SSH port says nothing about the port the host serves its web UI and API on.
|
|
13
|
+
*/
|
|
14
|
+
export declare function areDomainsOnSameHostname(first: string | undefined, second: string | undefined): boolean;
|
|
15
|
+
/** Whether a git remote was addressed over the host's web protocol (`https://`/`http://`) rather than SSH/git. */
|
|
16
|
+
export declare function isWebRemoteScheme(scheme: string | undefined): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* The comparison to use when matching a git remote's host against a configured (web) host. A web remote names
|
|
19
|
+
* the very host and port the API is served on, so it must match exactly; an SSH or git remote's port — which
|
|
20
|
+
* `parseGitRemoteUrl` drops anyway — says nothing about the web port, so only the hostname can be compared.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRemoteHostMatcher(scheme: string | undefined): (first: string | undefined, second: string | undefined) => boolean;
|
|
6
23
|
/**
|
|
7
24
|
* Builds the API base URL for a self-managed host from a domain expressed as either a URL or a bare host.
|
|
8
25
|
*
|
|
@@ -22,5 +39,7 @@ export declare function baseUrlFromDomain(domain: string | undefined, protocol:
|
|
|
22
39
|
* connection gaining or losing one.
|
|
23
40
|
*/
|
|
24
41
|
export declare function sameConfiguredBaseUrl(first: string | undefined, second: string | undefined): boolean;
|
|
42
|
+
/** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */
|
|
43
|
+
export declare function decodePathSegment(segment: string): string;
|
|
25
44
|
//#endregion
|
|
26
45
|
//# sourceMappingURL=domain.utils.d.ts.map
|
|
@@ -14,6 +14,11 @@ function hostFromDomain(domain) {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
/** Multiple accounts on the same host are unambiguous; an unknown configured host is not. */
|
|
18
|
+
function getSingleConfiguredDomain(configured) {
|
|
19
|
+
const hosts = new Set(configured.map((connection) => hostFromDomain(connection.domain)));
|
|
20
|
+
return hosts.size === 1 ? hosts.values().next().value : void 0;
|
|
21
|
+
}
|
|
17
22
|
/** Whether two URL-or-host domain values identify the same normalized host and port. */
|
|
18
23
|
function areDomainsOnSameHost(first, second) {
|
|
19
24
|
const firstHost = hostFromDomain(first);
|
|
@@ -21,6 +26,28 @@ function areDomainsOnSameHost(first, second) {
|
|
|
21
26
|
return firstHost != null && secondHost != null && firstHost === secondHost;
|
|
22
27
|
}
|
|
23
28
|
/**
|
|
29
|
+
* Whether two URL-or-host domain values name the same machine, ignoring the port. For comparing an SSH remote
|
|
30
|
+
* against a web address: an SSH port says nothing about the port the host serves its web UI and API on.
|
|
31
|
+
*/
|
|
32
|
+
function areDomainsOnSameHostname(first, second) {
|
|
33
|
+
const firstHost = hostFromDomain(first);
|
|
34
|
+
const secondHost = hostFromDomain(second);
|
|
35
|
+
if (firstHost == null || secondHost == null) return false;
|
|
36
|
+
return new URL(`https://${firstHost}`).hostname === new URL(`https://${secondHost}`).hostname;
|
|
37
|
+
}
|
|
38
|
+
/** Whether a git remote was addressed over the host's web protocol (`https://`/`http://`) rather than SSH/git. */
|
|
39
|
+
function isWebRemoteScheme(scheme) {
|
|
40
|
+
return scheme === "https://" || scheme === "http://";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The comparison to use when matching a git remote's host against a configured (web) host. A web remote names
|
|
44
|
+
* the very host and port the API is served on, so it must match exactly; an SSH or git remote's port — which
|
|
45
|
+
* `parseGitRemoteUrl` drops anyway — says nothing about the web port, so only the hostname can be compared.
|
|
46
|
+
*/
|
|
47
|
+
function getRemoteHostMatcher(scheme) {
|
|
48
|
+
return isWebRemoteScheme(scheme) ? areDomainsOnSameHost : areDomainsOnSameHostname;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
24
51
|
* Builds the API base URL for a self-managed host from a domain expressed as either a URL or a bare host.
|
|
25
52
|
*
|
|
26
53
|
* Distinct from {@link hostFromDomain}, which exists to collapse a domain to the identity the connection is
|
|
@@ -54,7 +81,15 @@ function sameConfiguredBaseUrl(first, second) {
|
|
|
54
81
|
const secondUrl = baseUrlFromDomain(second, void 0);
|
|
55
82
|
return firstUrl != null && secondUrl != null && firstUrl === secondUrl;
|
|
56
83
|
}
|
|
84
|
+
/** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */
|
|
85
|
+
function decodePathSegment(segment) {
|
|
86
|
+
try {
|
|
87
|
+
return decodeURIComponent(segment);
|
|
88
|
+
} catch {
|
|
89
|
+
return segment;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
57
92
|
//#endregion
|
|
58
|
-
export { areDomainsOnSameHost, baseUrlFromDomain, hostFromDomain, sameConfiguredBaseUrl };
|
|
93
|
+
export { areDomainsOnSameHost, areDomainsOnSameHostname, baseUrlFromDomain, decodePathSegment, getRemoteHostMatcher, getSingleConfiguredDomain, hostFromDomain, isWebRemoteScheme, sameConfiguredBaseUrl };
|
|
59
94
|
|
|
60
95
|
//# sourceMappingURL=domain.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain.utils.js","names":[],"sources":["../../../../../plus/integrations/src/utils/domain.utils.ts"],"sourcesContent":["/** Extracts the host from a domain expressed as either a URL or a bare host. */\nexport function hostFromDomain(domain: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tif (/^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value)) {\n\t\ttry {\n\t\t\treturn new URL(value).host || undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\ttry {\n\t\treturn new URL(`https://${value}`).host || undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Whether two URL-or-host domain values identify the same normalized host and port. */\nexport function areDomainsOnSameHost(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\treturn firstHost != null && secondHost != null && firstHost === secondHost;\n}\n\n/**\n * Builds the API base URL for a self-managed host from a domain expressed as either a URL or a bare host.\n *\n * Distinct from {@link hostFromDomain}, which exists to collapse a domain to the identity the connection is\n * keyed by and therefore DROPS the path. An instance mounted below a context path — Jira Data Center's\n * `/jira`, a reverse-proxied GitLab or Bitbucket — has to be addressed at that path, so the value a request\n * is built from must keep it. Callers pass the session's own domain (the unnormalized one the backend\n * stored) rather than the integration's host-keyed `domain`, and fall back to the latter.\n */\nexport function baseUrlFromDomain(domain: string | undefined, protocol: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tconst scheme = /^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value) ? undefined : (protocol ?? 'https:');\n\ttry {\n\t\tconst url = new URL(scheme == null ? value : `${scheme}//${value}`);\n\t\treturn `${url.protocol}//${url.host}${url.pathname.replace(/\\/+$/, '')}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Whether two configured addresses point at the same place, comparing them the way a request would.\n *\n * Both sides are run through {@link baseUrlFromDomain} first, so the shapes a domain legitimately arrives in\n * — a bare host, a full URL, a trailing slash — compare equal, while a genuinely different context path does\n * not. Two absent values are the same address (neither names a path); one absent is not, since that is a\n * connection gaining or losing one.\n */\nexport function sameConfiguredBaseUrl(first: string | undefined, second: string | undefined): boolean {\n\tif (!first?.trim() && !second?.trim()) return true;\n\n\tconst firstUrl = baseUrlFromDomain(first, undefined);\n\tconst secondUrl = baseUrlFromDomain(second, undefined);\n\treturn firstUrl != null && secondUrl != null && firstUrl === secondUrl;\n}\n"],"mappings":";;AACA,SAAgB,eAAe,QAAgD;CAC9E,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,IAAI,2BAA2B,KAAK,KAAK,GACxC,IAAI;EACH,OAAO,IAAI,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAA;CAC/B,QAAQ;EACP;CACD;CAGD,IAAI;EACH,OAAO,IAAI,IAAI,WAAW,OAAO,CAAC,CAAC,QAAQ,KAAA;CAC5C,QAAQ;EACP;CACD;AACD;;AAGA,SAAgB,qBAAqB,OAA2B,QAAqC;CACpG,MAAM,YAAY,eAAe,KAAK;CACtC,MAAM,aAAa,eAAe,MAAM;CACxC,OAAO,aAAa,QAAQ,cAAc,QAAQ,cAAc;AACjE;;;;;;;;;;AAWA,SAAgB,kBAAkB,QAA4B,UAAkD;CAC/G,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,SAAS,2BAA2B,KAAK,KAAK,IAAI,KAAA,IAAa,YAAY;CACjF,IAAI;EACH,MAAM,MAAM,IAAI,IAAI,UAAU,OAAO,QAAQ,GAAG,OAAO,IAAI,OAAO;EAClE,OAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,IAAI,SAAS,QAAQ,QAAQ,EAAE;CACtE,QAAQ;EACP;CACD;AACD;;;;;;;;;AAUA,SAAgB,sBAAsB,OAA2B,QAAqC;CACrG,IAAI,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,KAAK,GAAG,OAAO;CAE9C,MAAM,WAAW,kBAAkB,OAAO,KAAA,CAAS;CACnD,MAAM,YAAY,kBAAkB,QAAQ,KAAA,CAAS;CACrD,OAAO,YAAY,QAAQ,aAAa,QAAQ,aAAa;AAC9D"}
|
|
1
|
+
{"version":3,"file":"domain.utils.js","names":[],"sources":["../../../../../plus/integrations/src/utils/domain.utils.ts"],"sourcesContent":["/** Extracts the host from a domain expressed as either a URL or a bare host. */\nexport function hostFromDomain(domain: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tif (/^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value)) {\n\t\ttry {\n\t\t\treturn new URL(value).host || undefined;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\ttry {\n\t\treturn new URL(`https://${value}`).host || undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Multiple accounts on the same host are unambiguous; an unknown configured host is not. */\nexport function getSingleConfiguredDomain(configured: readonly { domain?: string }[]): string | undefined {\n\tconst hosts = new Set(configured.map(connection => hostFromDomain(connection.domain)));\n\treturn hosts.size === 1 ? hosts.values().next().value : undefined;\n}\n\n/** Whether two URL-or-host domain values identify the same normalized host and port. */\nexport function areDomainsOnSameHost(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\treturn firstHost != null && secondHost != null && firstHost === secondHost;\n}\n\n/**\n * Whether two URL-or-host domain values name the same machine, ignoring the port. For comparing an SSH remote\n * against a web address: an SSH port says nothing about the port the host serves its web UI and API on.\n */\nexport function areDomainsOnSameHostname(first: string | undefined, second: string | undefined): boolean {\n\tconst firstHost = hostFromDomain(first);\n\tconst secondHost = hostFromDomain(second);\n\tif (firstHost == null || secondHost == null) return false;\n\n\treturn new URL(`https://${firstHost}`).hostname === new URL(`https://${secondHost}`).hostname;\n}\n\n/** Whether a git remote was addressed over the host's web protocol (`https://`/`http://`) rather than SSH/git. */\nexport function isWebRemoteScheme(scheme: string | undefined): boolean {\n\treturn scheme === 'https://' || scheme === 'http://';\n}\n\n/**\n * The comparison to use when matching a git remote's host against a configured (web) host. A web remote names\n * the very host and port the API is served on, so it must match exactly; an SSH or git remote's port — which\n * `parseGitRemoteUrl` drops anyway — says nothing about the web port, so only the hostname can be compared.\n */\nexport function getRemoteHostMatcher(\n\tscheme: string | undefined,\n): (first: string | undefined, second: string | undefined) => boolean {\n\treturn isWebRemoteScheme(scheme) ? areDomainsOnSameHost : areDomainsOnSameHostname;\n}\n\n/**\n * Builds the API base URL for a self-managed host from a domain expressed as either a URL or a bare host.\n *\n * Distinct from {@link hostFromDomain}, which exists to collapse a domain to the identity the connection is\n * keyed by and therefore DROPS the path. An instance mounted below a context path — Jira Data Center's\n * `/jira`, a reverse-proxied GitLab or Bitbucket — has to be addressed at that path, so the value a request\n * is built from must keep it. Callers pass the session's own domain (the unnormalized one the backend\n * stored) rather than the integration's host-keyed `domain`, and fall back to the latter.\n */\nexport function baseUrlFromDomain(domain: string | undefined, protocol: string | undefined): string | undefined {\n\tconst value = domain?.trim();\n\tif (!value) return undefined;\n\n\tconst scheme = /^[a-z][a-z\\d+\\-.]*:\\/\\//i.test(value) ? undefined : (protocol ?? 'https:');\n\ttry {\n\t\tconst url = new URL(scheme == null ? value : `${scheme}//${value}`);\n\t\treturn `${url.protocol}//${url.host}${url.pathname.replace(/\\/+$/, '')}`;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Whether two configured addresses point at the same place, comparing them the way a request would.\n *\n * Both sides are run through {@link baseUrlFromDomain} first, so the shapes a domain legitimately arrives in\n * — a bare host, a full URL, a trailing slash — compare equal, while a genuinely different context path does\n * not. Two absent values are the same address (neither names a path); one absent is not, since that is a\n * connection gaining or losing one.\n */\nexport function sameConfiguredBaseUrl(first: string | undefined, second: string | undefined): boolean {\n\tif (!first?.trim() && !second?.trim()) return true;\n\n\tconst firstUrl = baseUrlFromDomain(first, undefined);\n\tconst secondUrl = baseUrlFromDomain(second, undefined);\n\treturn firstUrl != null && secondUrl != null && firstUrl === secondUrl;\n}\n\n/** Decodes one percent-encoded URL path segment, keeping a malformed one as written. */\nexport function decodePathSegment(segment: string): string {\n\ttry {\n\t\treturn decodeURIComponent(segment);\n\t} catch {\n\t\treturn segment;\n\t}\n}\n"],"mappings":";;AACA,SAAgB,eAAe,QAAgD;CAC9E,MAAM,QAAQ,QAAQ,KAAK;CAC3B,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,IAAI,2BAA2B,KAAK,KAAK,GACxC,IAAI;EACH,OAAO,IAAI,IAAI,KAAK,CAAC,CAAC,QAAQ,KAAA;CAC/B,QAAQ;EACP;CACD;CAGD,IAAI;EACH,OAAO,IAAI,IAAI,WAAW,OAAO,CAAC,CAAC,QAAQ,KAAA;CAC5C,QAAQ;EACP;CACD;AACD;;AAGA,SAAgB,0BAA0B,YAAgE;CACzG,MAAM,QAAQ,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,YAAY,kBAAkB,QAAQ,KAAA,CAAS;CACrD,OAAO,YAAY,QAAQ,aAAa,QAAQ,aAAa;AAC9D;;AAGA,SAAgB,kBAAkB,SAAyB;CAC1D,IAAI;EACH,OAAO,mBAAmB,OAAO;CAClC,QAAQ;EACP,OAAO;CACR;AACD"}
|
|
@@ -60,5 +60,6 @@ export declare function warnOnMissingSessionForDomain(id: IntegrationIds, domain
|
|
|
60
60
|
export declare function remoteProviderTypeForIntegration(id: IntegrationIds): RemoteProviderId | undefined;
|
|
61
61
|
/** Normalizes a host remote-config `type` string (e.g. `'GitHub'`) to a git-remote provider type. */
|
|
62
62
|
export declare function remoteProviderTypeForConfig(type: string): RemoteProviderId | undefined;
|
|
63
|
+
export declare function getSelfManagedBaseUrl(id: IntegrationIds, domain: string | undefined, protocol?: string): string | undefined;
|
|
63
64
|
//#endregion
|
|
64
65
|
//# sourceMappingURL=integration.utils.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "../constants.js";
|
|
2
|
+
import { baseUrlFromDomain } from "./domain.utils.js";
|
|
2
3
|
import { isAzureCloudDomain, isBitbucketCloudDomain, isGitHubDotCom, isGitLabDotCom } from "../providers/models.js";
|
|
3
4
|
//#region ../plus/integrations/src/utils/integration.utils.ts
|
|
4
5
|
const selfHostedIntegrationIds = [
|
|
@@ -169,7 +170,17 @@ function remoteProviderTypeForConfig(type) {
|
|
|
169
170
|
default: return;
|
|
170
171
|
}
|
|
171
172
|
}
|
|
173
|
+
function getSelfManagedBaseUrl(id, domain, protocol) {
|
|
174
|
+
const baseUrl = baseUrlFromDomain(domain, protocol);
|
|
175
|
+
if (baseUrl == null) return void 0;
|
|
176
|
+
switch (id) {
|
|
177
|
+
case "cloud-github-enterprise":
|
|
178
|
+
case "cloud-gitlab-self-hosted": return baseUrl.replace(/\/api(?:\/v\d+)?$/, "");
|
|
179
|
+
case "bitbucket-server": return baseUrl.replace(/\/rest\/api\/1\.0$/, "");
|
|
180
|
+
default: return baseUrl;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
172
183
|
//#endregion
|
|
173
|
-
export { convertRemoteProviderIdToIntegrationId, getIntegrationConnectedKey, getIntegrationIdForRemote, isCloudGitSelfManagedHostIntegrationId, isCloudSelfManagedHostIntegrationId, isGitCloudHostIntegrationId, isGitHostIntegration, isGitSelfManagedHostIntegrationId, isIssuesHostIntegrationId, isIssuesSelfManagedHostIntegrationId, isNonExpiringZeroTokenIntegrationId, isSelfManagedHostIntegrationId, remoteProviderTypeForConfig, remoteProviderTypeForIntegration, supportedIntegrationIds, warnOnMissingSessionForDomain };
|
|
184
|
+
export { convertRemoteProviderIdToIntegrationId, getIntegrationConnectedKey, getIntegrationIdForRemote, getSelfManagedBaseUrl, isCloudGitSelfManagedHostIntegrationId, isCloudSelfManagedHostIntegrationId, isGitCloudHostIntegrationId, isGitHostIntegration, isGitSelfManagedHostIntegrationId, isIssuesHostIntegrationId, isIssuesSelfManagedHostIntegrationId, isNonExpiringZeroTokenIntegrationId, isSelfManagedHostIntegrationId, remoteProviderTypeForConfig, remoteProviderTypeForIntegration, supportedIntegrationIds, warnOnMissingSessionForDomain };
|
|
174
185
|
|
|
175
186
|
//# sourceMappingURL=integration.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration.utils.js","names":[],"sources":["../../../../../plus/integrations/src/utils/integration.utils.ts"],"sourcesContent":["import type { RemoteProvider, RemoteProviderId } from '@gitlens/git/models/remoteProvider.js';\nimport type {\n\tCloudGitSelfManagedHostIntegrationIds,\n\tCloudSelfManagedHostIntegrationIds,\n\tIntegrationIds,\n\tIssuesHostIntegrationIds,\n\tSelfManagedHostIntegrationIds,\n} from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { Integration, IntegrationConnectedKey } from '../models/integration.js';\n// These domain checks come from `providers/models.ts` (already imported here) rather than the individual\n// provider modules: those read `providersMetadata[...]` synchronously at module init, so importing from them\n// while `providers/models.ts` is still loading triggers a TDZ on `providersMetadata`. Importing the shared\n// predicates keeps one definition of each regex — duplicating them let a fix land in only one place.\nimport { isAzureCloudDomain, isBitbucketCloudDomain, isGitHubDotCom, isGitLabDotCom } from '../providers/models.js';\n\nconst selfHostedIntegrationIds: GitSelfManagedHostIntegrationId[] = [\n\tGitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tGitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n] as const;\n\nconst selfHostedIssuesIntegrationIds: IssuesSelfManagedHostIntegrationId[] = [\n\tIssuesSelfManagedHostIntegrationId.JiraServer,\n] as const;\n\nexport const supportedIntegrationIds: IntegrationIds[] = [\n\tGitCloudHostIntegrationId.GitHub,\n\tGitCloudHostIntegrationId.GitLab,\n\tGitCloudHostIntegrationId.Bitbucket,\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tIssuesCloudHostIntegrationId.Jira,\n\tIssuesCloudHostIntegrationId.Trello,\n\t...selfHostedIntegrationIds,\n\t...selfHostedIssuesIntegrationIds,\n] as const;\n\nexport function convertRemoteProviderIdToIntegrationId(\n\tremoteProviderId: RemoteProviderId,\n): GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId | undefined {\n\tswitch (remoteProviderId) {\n\t\tcase 'azure-devops':\n\t\t\treturn GitCloudHostIntegrationId.AzureDevOps;\n\t\tcase 'bitbucket':\n\t\t\treturn GitCloudHostIntegrationId.Bitbucket;\n\t\tcase 'github':\n\t\t\treturn GitCloudHostIntegrationId.GitHub;\n\t\tcase 'gitlab':\n\t\t\treturn GitCloudHostIntegrationId.GitLab;\n\t\tcase 'bitbucket-server':\n\t\t\treturn GitSelfManagedHostIntegrationId.BitbucketServer;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function getIntegrationConnectedKey<T extends IntegrationIds>(\n\tid: T,\n\tdomain?: string,\n): IntegrationConnectedKey<T> {\n\tif (isSelfManagedHostIntegrationId(id)) {\n\t\tif (!domain) {\n\t\t\tthrow new Error(`Domain is required for self-managed integration ID: ${id}`);\n\t\t}\n\t\treturn `connected:${id}:${domain}` as IntegrationConnectedKey<T>;\n\t}\n\n\treturn `connected:${id}` as IntegrationConnectedKey<T>;\n}\n\nexport function getIntegrationIdForRemote(\n\tprovider: RemoteProvider | undefined,\n): GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId | undefined {\n\tswitch (provider?.id) {\n\t\tcase 'azure-devops':\n\t\t\tif (isAzureCloudDomain(provider.domain)) {\n\t\t\t\treturn GitCloudHostIntegrationId.AzureDevOps;\n\t\t\t}\n\t\t\treturn provider.custom ? undefined : GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\t\tcase 'bitbucket':\n\t\tcase 'bitbucket-server':\n\t\t\tif (isBitbucketCloudDomain(provider.domain)) {\n\t\t\t\treturn GitCloudHostIntegrationId.Bitbucket;\n\t\t\t}\n\t\t\treturn GitSelfManagedHostIntegrationId.BitbucketServer;\n\t\tcase 'github':\n\t\t\tif (provider.domain != null && !isGitHubDotCom(provider.domain)) {\n\t\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitHubEnterprise;\n\t\t\t}\n\t\t\treturn GitCloudHostIntegrationId.GitHub;\n\t\tcase 'gitlab':\n\t\t\tif (provider.domain != null && !isGitLabDotCom(provider.domain)) {\n\t\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\t\t\t}\n\t\t\treturn GitCloudHostIntegrationId.GitLab;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function isCloudGitSelfManagedHostIntegrationId(\n\tid: IntegrationIds,\n): id is CloudGitSelfManagedHostIntegrationIds {\n\tswitch (id) {\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Whether this id is a self-managed host whose token comes from the GK cloud backend — the check behind\n * \"expand this provider to one instance per configured host\". Distinct from\n * {@link isCloudGitSelfManagedHostIntegrationId}, which stays git-only because its callers go on to ask the\n * instance for repositories.\n */\nexport function isCloudSelfManagedHostIntegrationId(id: IntegrationIds): id is CloudSelfManagedHostIntegrationIds {\n\treturn isCloudGitSelfManagedHostIntegrationId(id) || isIssuesSelfManagedHostIntegrationId(id);\n}\n\n/**\n * Whether a provider's cloud token uses `expiresIn: 0` to mean \"never expires\" (rather than \"already\n * expired\"). GitHub and the cloud self-managed hosts always return 0 for their non-expiring tokens; Trello\n * is issued with `expiration: never` (identity-service), so its cloud token comes back as 0 too. Callers\n * must map 0 → a far-future expiry for these, or the session is immediately treated as expired.\n *\n * Every backend-managed self-managed host qualifies, not just the git ones: a self-hosted tracker's token is\n * a PAT the backend stores as-is and cannot refresh, so reading 0 as \"already expired\" would re-resolve the\n * session on every single read.\n */\nexport function isNonExpiringZeroTokenIntegrationId(id: IntegrationIds): boolean {\n\treturn (\n\t\tid === GitCloudHostIntegrationId.GitHub ||\n\t\tid === IssuesCloudHostIntegrationId.Trello ||\n\t\tisCloudSelfManagedHostIntegrationId(id)\n\t);\n}\n\nexport function isGitHostIntegration(integration: Integration): integration is GitHostIntegration {\n\treturn integration.type === 'git';\n}\n\nexport function isGitCloudHostIntegrationId(id: IntegrationIds): id is GitCloudHostIntegrationId {\n\tswitch (id) {\n\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function isGitSelfManagedHostIntegrationId(id: IntegrationIds): id is GitSelfManagedHostIntegrationId {\n\treturn selfHostedIntegrationIds.includes(id as GitSelfManagedHostIntegrationId);\n}\n\nexport function isIssuesSelfManagedHostIntegrationId(id: IntegrationIds): id is IssuesSelfManagedHostIntegrationId {\n\treturn selfHostedIssuesIntegrationIds.includes(id as IssuesSelfManagedHostIntegrationId);\n}\n\n/**\n * Whether this id addresses ONE customer-run host, whatever it hosts — the predicate the domain-keyed\n * machinery runs on: the integration cache key, the secret key, the `connected:${id}:${domain}` flag, domain\n * normalization, per-host primary selection, and multi-account reconcile.\n *\n * Deliberately wider than {@link isGitSelfManagedHostIntegrationId}, which is reserved for reads that go on to\n * ask for repositories, pull requests, or a git remote. Widening THOSE to a tracker would attribute a Jira\n * host's remotes to Jira; narrowing THESE to git hosts would key a tracker's connections under an empty\n * domain, collapsing every host of it into one bucket.\n */\nexport function isSelfManagedHostIntegrationId(id: IntegrationIds): id is SelfManagedHostIntegrationIds {\n\treturn isGitSelfManagedHostIntegrationId(id) || isIssuesSelfManagedHostIntegrationId(id);\n}\n\n/**\n * Whether this id belongs to a dedicated issue tracker (resource → project) rather than a git host.\n *\n * Decided from the id alone, so a read can refuse a mismatched surface — a repo/PR read asked of Jira, or an\n * issue-tracker project read asked of GitHub — before resolving a connection. The instance-level\n * {@link isIssuesIntegration} answers the same question once an integration is in hand.\n */\nexport function isIssuesHostIntegrationId(id: IntegrationIds): id is IssuesHostIntegrationIds {\n\tswitch (id) {\n\t\tcase IssuesCloudHostIntegrationId.Jira:\n\t\tcase IssuesCloudHostIntegrationId.Linear:\n\t\tcase IssuesCloudHostIntegrationId.Trello:\n\t\tcase IssuesSelfManagedHostIntegrationId.JiraServer:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Whether a read targeted only by an explicit self-managed `domain` (no `connectionId`) must treat a\n * session-less core result as a broken target instead of an empty account. Without this, a self-managed host\n * addressed only by domain — the manual-token/external-auth case `domain` exists to cover — returns an empty\n * success with no warning and no `fetchFailed`, indistinguishable from \"this host has nothing\".\n */\nexport function warnOnMissingSessionForDomain(id: IntegrationIds, domain: string | undefined): boolean {\n\treturn domain != null && isSelfManagedHostIntegrationId(id);\n}\n\n/** Maps an integration id to the git-remote provider type used by the remote-URL matcher. */\nexport function remoteProviderTypeForIntegration(id: IntegrationIds): RemoteProviderId | undefined {\n\tswitch (id) {\n\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\t\treturn 'github';\n\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\treturn 'gitlab';\n\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\treturn 'bitbucket';\n\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\t\treturn 'bitbucket-server';\n\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\treturn 'azure-devops';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/** Normalizes a host remote-config `type` string (e.g. `'GitHub'`) to a git-remote provider type. */\nexport function remoteProviderTypeForConfig(type: string): RemoteProviderId | undefined {\n\tswitch (type.toLowerCase()) {\n\t\tcase 'github':\n\t\t\treturn 'github';\n\t\tcase 'gitlab':\n\t\t\treturn 'gitlab';\n\t\tcase 'bitbucket':\n\t\t\treturn 'bitbucket';\n\t\tcase 'bitbucket-server':\n\t\tcase 'bitbucketserver':\n\t\t\treturn 'bitbucket-server';\n\t\tcase 'azuredevops':\n\t\tcase 'azure-devops':\n\t\t\treturn 'azure-devops';\n\t\tcase 'gitea':\n\t\t\treturn 'gitea';\n\t\tcase 'gerrit':\n\t\t\treturn 'gerrit';\n\t\tdefault:\n\t\t\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AAA,YACA,oCAAoC,EAAE;AAExC;AAEA,SAAgB,qBAAqB,aAA6D;CACjG,OAAO,YAAY,SAAS;AAC7B;AAEA,SAAgB,4BAA4B,IAAqD;CAChG,QAAQ,IAAR;EACC,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,eACC,OAAO;EACR,SACC,OAAO;CACT;AACD;AAEA,SAAgB,kCAAkC,IAA2D;CAC5G,OAAO,yBAAyB,SAAS,EAAqC;AAC/E;AAEA,SAAgB,qCAAqC,IAA8D;CAClH,OAAO,+BAA+B,SAAS,EAAwC;AACxF;;;;;;;;;;;AAYA,SAAgB,+BAA+B,IAAyD;CACvG,OAAO,kCAAkC,EAAE,KAAK,qCAAqC,EAAE;AACxF;;;;;;;;AASA,SAAgB,0BAA0B,IAAoD;CAC7F,QAAQ,IAAR;EACC,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,eACC,OAAO;EACR,SACC,OAAO;CACT;AACD;;;;;;;AAQA,SAAgB,8BAA8B,IAAoB,QAAqC;CACtG,OAAO,UAAU,QAAQ,+BAA+B,EAAE;AAC3D;;AAGA,SAAgB,iCAAiC,IAAkD;CAClG,QAAQ,IAAR;EACC,KAAA;EACA,KAAA,2BACC,OAAO;EACR,KAAA;EACA,KAAA,4BACC,OAAO;EACR,KAAA,aACC,OAAO;EACR,KAAA,oBACC,OAAO;EACR,KAAA;EACA,KAAA,uBACC,OAAO;EACR,SACC;CACF;AACD;;AAGA,SAAgB,4BAA4B,MAA4C;CACvF,QAAQ,KAAK,YAAY,GAAzB;EACC,KAAK,UACJ,OAAO;EACR,KAAK,UACJ,OAAO;EACR,KAAK,aACJ,OAAO;EACR,KAAK;EACL,KAAK,mBACJ,OAAO;EACR,KAAK;EACL,KAAK,gBACJ,OAAO;EACR,KAAK,SACJ,OAAO;EACR,KAAK,UACJ,OAAO;EACR,SACC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"integration.utils.js","names":[],"sources":["../../../../../plus/integrations/src/utils/integration.utils.ts"],"sourcesContent":["import type { RemoteProvider, RemoteProviderId } from '@gitlens/git/models/remoteProvider.js';\nimport type {\n\tCloudGitSelfManagedHostIntegrationIds,\n\tCloudSelfManagedHostIntegrationIds,\n\tIntegrationIds,\n\tIssuesHostIntegrationIds,\n\tSelfManagedHostIntegrationIds,\n} from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { Integration, IntegrationConnectedKey } from '../models/integration.js';\n// These domain checks come from `providers/models.ts` (already imported here) rather than the individual\n// provider modules: those read `providersMetadata[...]` synchronously at module init, so importing from them\n// while `providers/models.ts` is still loading triggers a TDZ on `providersMetadata`. Importing the shared\n// predicates keeps one definition of each regex — duplicating them let a fix land in only one place.\nimport { isAzureCloudDomain, isBitbucketCloudDomain, isGitHubDotCom, isGitLabDotCom } from '../providers/models.js';\nimport { baseUrlFromDomain } from './domain.utils.js';\n\nconst selfHostedIntegrationIds: GitSelfManagedHostIntegrationId[] = [\n\tGitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tGitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n] as const;\n\nconst selfHostedIssuesIntegrationIds: IssuesSelfManagedHostIntegrationId[] = [\n\tIssuesSelfManagedHostIntegrationId.JiraServer,\n] as const;\n\nexport const supportedIntegrationIds: IntegrationIds[] = [\n\tGitCloudHostIntegrationId.GitHub,\n\tGitCloudHostIntegrationId.GitLab,\n\tGitCloudHostIntegrationId.Bitbucket,\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tIssuesCloudHostIntegrationId.Jira,\n\tIssuesCloudHostIntegrationId.Trello,\n\t...selfHostedIntegrationIds,\n\t...selfHostedIssuesIntegrationIds,\n] as const;\n\nexport function convertRemoteProviderIdToIntegrationId(\n\tremoteProviderId: RemoteProviderId,\n): GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId | undefined {\n\tswitch (remoteProviderId) {\n\t\tcase 'azure-devops':\n\t\t\treturn GitCloudHostIntegrationId.AzureDevOps;\n\t\tcase 'bitbucket':\n\t\t\treturn GitCloudHostIntegrationId.Bitbucket;\n\t\tcase 'github':\n\t\t\treturn GitCloudHostIntegrationId.GitHub;\n\t\tcase 'gitlab':\n\t\t\treturn GitCloudHostIntegrationId.GitLab;\n\t\tcase 'bitbucket-server':\n\t\t\treturn GitSelfManagedHostIntegrationId.BitbucketServer;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function getIntegrationConnectedKey<T extends IntegrationIds>(\n\tid: T,\n\tdomain?: string,\n): IntegrationConnectedKey<T> {\n\tif (isSelfManagedHostIntegrationId(id)) {\n\t\tif (!domain) {\n\t\t\tthrow new Error(`Domain is required for self-managed integration ID: ${id}`);\n\t\t}\n\t\treturn `connected:${id}:${domain}` as IntegrationConnectedKey<T>;\n\t}\n\n\treturn `connected:${id}` as IntegrationConnectedKey<T>;\n}\n\nexport function getIntegrationIdForRemote(\n\tprovider: RemoteProvider | undefined,\n): GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId | undefined {\n\tswitch (provider?.id) {\n\t\tcase 'azure-devops':\n\t\t\tif (isAzureCloudDomain(provider.domain)) {\n\t\t\t\treturn GitCloudHostIntegrationId.AzureDevOps;\n\t\t\t}\n\t\t\treturn provider.custom ? undefined : GitSelfManagedHostIntegrationId.AzureDevOpsServer;\n\t\tcase 'bitbucket':\n\t\tcase 'bitbucket-server':\n\t\t\tif (isBitbucketCloudDomain(provider.domain)) {\n\t\t\t\treturn GitCloudHostIntegrationId.Bitbucket;\n\t\t\t}\n\t\t\treturn GitSelfManagedHostIntegrationId.BitbucketServer;\n\t\tcase 'github':\n\t\t\tif (provider.domain != null && !isGitHubDotCom(provider.domain)) {\n\t\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitHubEnterprise;\n\t\t\t}\n\t\t\treturn GitCloudHostIntegrationId.GitHub;\n\t\tcase 'gitlab':\n\t\t\tif (provider.domain != null && !isGitLabDotCom(provider.domain)) {\n\t\t\t\treturn GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\t\t\t}\n\t\t\treturn GitCloudHostIntegrationId.GitLab;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function isCloudGitSelfManagedHostIntegrationId(\n\tid: IntegrationIds,\n): id is CloudGitSelfManagedHostIntegrationIds {\n\tswitch (id) {\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Whether this id is a self-managed host whose token comes from the GK cloud backend — the check behind\n * \"expand this provider to one instance per configured host\". Distinct from\n * {@link isCloudGitSelfManagedHostIntegrationId}, which stays git-only because its callers go on to ask the\n * instance for repositories.\n */\nexport function isCloudSelfManagedHostIntegrationId(id: IntegrationIds): id is CloudSelfManagedHostIntegrationIds {\n\treturn isCloudGitSelfManagedHostIntegrationId(id) || isIssuesSelfManagedHostIntegrationId(id);\n}\n\n/**\n * Whether a provider's cloud token uses `expiresIn: 0` to mean \"never expires\" (rather than \"already\n * expired\"). GitHub and the cloud self-managed hosts always return 0 for their non-expiring tokens; Trello\n * is issued with `expiration: never` (identity-service), so its cloud token comes back as 0 too. Callers\n * must map 0 → a far-future expiry for these, or the session is immediately treated as expired.\n *\n * Every backend-managed self-managed host qualifies, not just the git ones: a self-hosted tracker's token is\n * a PAT the backend stores as-is and cannot refresh, so reading 0 as \"already expired\" would re-resolve the\n * session on every single read.\n */\nexport function isNonExpiringZeroTokenIntegrationId(id: IntegrationIds): boolean {\n\treturn (\n\t\tid === GitCloudHostIntegrationId.GitHub ||\n\t\tid === IssuesCloudHostIntegrationId.Trello ||\n\t\tisCloudSelfManagedHostIntegrationId(id)\n\t);\n}\n\nexport function isGitHostIntegration(integration: Integration): integration is GitHostIntegration {\n\treturn integration.type === 'git';\n}\n\nexport function isGitCloudHostIntegrationId(id: IntegrationIds): id is GitCloudHostIntegrationId {\n\tswitch (id) {\n\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport function isGitSelfManagedHostIntegrationId(id: IntegrationIds): id is GitSelfManagedHostIntegrationId {\n\treturn selfHostedIntegrationIds.includes(id as GitSelfManagedHostIntegrationId);\n}\n\nexport function isIssuesSelfManagedHostIntegrationId(id: IntegrationIds): id is IssuesSelfManagedHostIntegrationId {\n\treturn selfHostedIssuesIntegrationIds.includes(id as IssuesSelfManagedHostIntegrationId);\n}\n\n/**\n * Whether this id addresses ONE customer-run host, whatever it hosts — the predicate the domain-keyed\n * machinery runs on: the integration cache key, the secret key, the `connected:${id}:${domain}` flag, domain\n * normalization, per-host primary selection, and multi-account reconcile.\n *\n * Deliberately wider than {@link isGitSelfManagedHostIntegrationId}, which is reserved for reads that go on to\n * ask for repositories, pull requests, or a git remote. Widening THOSE to a tracker would attribute a Jira\n * host's remotes to Jira; narrowing THESE to git hosts would key a tracker's connections under an empty\n * domain, collapsing every host of it into one bucket.\n */\nexport function isSelfManagedHostIntegrationId(id: IntegrationIds): id is SelfManagedHostIntegrationIds {\n\treturn isGitSelfManagedHostIntegrationId(id) || isIssuesSelfManagedHostIntegrationId(id);\n}\n\n/**\n * Whether this id belongs to a dedicated issue tracker (resource → project) rather than a git host.\n *\n * Decided from the id alone, so a read can refuse a mismatched surface — a repo/PR read asked of Jira, or an\n * issue-tracker project read asked of GitHub — before resolving a connection. The instance-level\n * {@link isIssuesIntegration} answers the same question once an integration is in hand.\n */\nexport function isIssuesHostIntegrationId(id: IntegrationIds): id is IssuesHostIntegrationIds {\n\tswitch (id) {\n\t\tcase IssuesCloudHostIntegrationId.Jira:\n\t\tcase IssuesCloudHostIntegrationId.Linear:\n\t\tcase IssuesCloudHostIntegrationId.Trello:\n\t\tcase IssuesSelfManagedHostIntegrationId.JiraServer:\n\t\t\treturn true;\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/**\n * Whether a read targeted only by an explicit self-managed `domain` (no `connectionId`) must treat a\n * session-less core result as a broken target instead of an empty account. Without this, a self-managed host\n * addressed only by domain — the manual-token/external-auth case `domain` exists to cover — returns an empty\n * success with no warning and no `fetchFailed`, indistinguishable from \"this host has nothing\".\n */\nexport function warnOnMissingSessionForDomain(id: IntegrationIds, domain: string | undefined): boolean {\n\treturn domain != null && isSelfManagedHostIntegrationId(id);\n}\n\n/** Maps an integration id to the git-remote provider type used by the remote-URL matcher. */\nexport function remoteProviderTypeForIntegration(id: IntegrationIds): RemoteProviderId | undefined {\n\tswitch (id) {\n\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\t\treturn 'github';\n\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\treturn 'gitlab';\n\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\treturn 'bitbucket';\n\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\t\treturn 'bitbucket-server';\n\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\treturn 'azure-devops';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\n/** Normalizes a host remote-config `type` string (e.g. `'GitHub'`) to a git-remote provider type. */\nexport function remoteProviderTypeForConfig(type: string): RemoteProviderId | undefined {\n\tswitch (type.toLowerCase()) {\n\t\tcase 'github':\n\t\t\treturn 'github';\n\t\tcase 'gitlab':\n\t\t\treturn 'gitlab';\n\t\tcase 'bitbucket':\n\t\t\treturn 'bitbucket';\n\t\tcase 'bitbucket-server':\n\t\tcase 'bitbucketserver':\n\t\t\treturn 'bitbucket-server';\n\t\tcase 'azuredevops':\n\t\tcase 'azure-devops':\n\t\t\treturn 'azure-devops';\n\t\tcase 'gitea':\n\t\t\treturn 'gitea';\n\t\tcase 'gerrit':\n\t\t\treturn 'gerrit';\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function getSelfManagedBaseUrl(\n\tid: IntegrationIds,\n\tdomain: string | undefined,\n\tprotocol?: string,\n): string | undefined {\n\tconst baseUrl = baseUrlFromDomain(domain, protocol);\n\tif (baseUrl == null) return undefined;\n\n\tswitch (id) {\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\treturn baseUrl.replace(/\\/api(?:\\/v\\d+)?$/, '');\n\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\t\treturn baseUrl.replace(/\\/rest\\/api\\/1\\.0$/, '');\n\t\tdefault:\n\t\t\treturn baseUrl;\n\t}\n}\n"],"mappings":";;;;AAuBA,MAAM,2BAA8D;;;;;AAKpE;AAEA,MAAM,iCAAuE,CAAA,aAE7E;AAEA,MAAa,0BAA4C;;;;;;;CAOxD,GAAG;CACH,GAAG;AACJ;AAEA,SAAgB,uCACf,kBAC0E;CAC1E,QAAQ,kBAAR;EACC,KAAK,gBACJ,OAAA;EACD,KAAK,aACJ,OAAA;EACD,KAAK,UACJ,OAAA;EACD,KAAK,UACJ,OAAA;EACD,KAAK,oBACJ,OAAA;EACD,SACC;CACF;AACD;AAEA,SAAgB,2BACf,IACA,QAC6B;CAC7B,IAAI,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