@gitkraken/core-gitlens 0.46.0 → 0.47.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/git-cli/providers/config.js +2 -2
  3. package/dist/git-cli/providers/pausedOperations.js +2 -2
  4. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  5. package/dist/git-cli/providers/staging.js +1 -1
  6. package/dist/ipc/discovery.js +1 -1
  7. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  8. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  9. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  10. package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.d.ts +31 -0
  11. package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js +166 -0
  12. package/dist/plus/git-github/api/enterprisePullRequestMergePolicy.js.map +1 -0
  13. package/dist/plus/git-github/api/github.d.ts +7 -4
  14. package/dist/plus/git-github/api/github.js +44 -14
  15. package/dist/plus/git-github/api/github.js.map +1 -1
  16. package/dist/plus/git-github/api/issueWrites.d.ts +1 -0
  17. package/dist/plus/git-github/api/issueWrites.js +5 -5
  18. package/dist/plus/git-github/api/issueWrites.js.map +1 -1
  19. package/dist/plus/git-github/api/pullRequestWrites.d.ts +7 -3
  20. package/dist/plus/git-github/api/pullRequestWrites.js +120 -67
  21. package/dist/plus/git-github/api/pullRequestWrites.js.map +1 -1
  22. package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +4 -4
  23. package/dist/plus/integrations/authentication/configuredIntegrationService.js +14 -14
  24. package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -1
  25. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +3 -3
  26. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  27. package/dist/plus/integrations/context.d.ts +4 -4
  28. package/dist/plus/integrations/index.d.ts +8 -4
  29. package/dist/plus/integrations/index.js +2 -1
  30. package/dist/plus/integrations/index.js.map +1 -1
  31. package/dist/plus/integrations/integrationService.d.ts +9 -2
  32. package/dist/plus/integrations/integrationService.js +95 -31
  33. package/dist/plus/integrations/integrationService.js.map +1 -1
  34. package/dist/plus/integrations/manager.d.ts +16 -4
  35. package/dist/plus/integrations/models/gitHostIntegration.js +7 -4
  36. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  37. package/dist/plus/integrations/models/integration.d.ts +2 -1
  38. package/dist/plus/integrations/models/integration.js +11 -4
  39. package/dist/plus/integrations/models/integration.js.map +1 -1
  40. package/dist/plus/integrations/models/issueTrackerWrites.d.ts +128 -0
  41. package/dist/plus/integrations/models/issueTrackerWrites.js +0 -0
  42. package/dist/plus/integrations/models/publicIntegration.d.ts +5 -0
  43. package/dist/plus/integrations/models/publicIntegration.js.map +1 -1
  44. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  45. package/dist/plus/integrations/providers/github.d.ts +19 -6
  46. package/dist/plus/integrations/providers/github.js +126 -53
  47. package/dist/plus/integrations/providers/github.js.map +1 -1
  48. package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
  49. package/dist/plus/integrations/providers/jira.js +1 -1
  50. package/dist/plus/integrations/providers/jiraIssueByKey.d.ts +2 -0
  51. package/dist/plus/integrations/providers/jiraIssueByKey.js +1 -1
  52. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  53. package/dist/plus/integrations/providers/jiraIssueWriteErrors.d.ts +10 -0
  54. package/dist/plus/integrations/providers/jiraIssueWriteErrors.js +68 -0
  55. package/dist/plus/integrations/providers/jiraIssueWriteErrors.js.map +1 -0
  56. package/dist/plus/integrations/providers/jiraIssueWrites.d.ts +40 -0
  57. package/dist/plus/integrations/providers/jiraIssueWrites.js +397 -0
  58. package/dist/plus/integrations/providers/jiraIssueWrites.js.map +1 -0
  59. package/dist/plus/integrations/providers/providersApi.d.ts +4 -1
  60. package/dist/plus/integrations/providers/providersApi.js +21 -10
  61. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  62. package/dist/plus/integrations/reads/drains.d.ts +1 -0
  63. package/dist/plus/integrations/utils/integration.utils.d.ts +1 -0
  64. package/dist/plus/integrations/utils/integration.utils.js +7 -1
  65. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  66. package/dist/utils/env/node/exec.js +2 -2
  67. package/docs/integrations.md +80 -8
  68. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import { ResourceDescriptor } from "../../../git/models/resourceDescriptor.js";
2
2
  import { PullRequest, PullRequestFilter, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
3
3
  import { IntegrationIds } from "../constants.js";
4
+ import "../providerFilters.js";
4
5
  import { ProviderWarning } from "../results.js";
5
6
  import { ProviderSweepTarget, PullRequestSweepOptions } from "../manager.js";
6
7
  import { IntegrationResult } from "../models/publicIntegration.js";
@@ -64,5 +64,6 @@ export declare function remoteProviderTypeForIntegration(id: IntegrationIds): Re
64
64
  /** Normalizes a host remote-config `type` string (e.g. `'GitHub'`) to a git-remote provider type. */
65
65
  export declare function remoteProviderTypeForConfig(type: string): RemoteProviderId | undefined;
66
66
  export declare function getSelfManagedBaseUrl(id: IntegrationIds, domain: string | undefined, protocol?: string): string | undefined;
67
+ export declare function getGitHubEnterprisePullRequestWriteOrigin(domain: string | undefined, protocol?: string): string | undefined;
67
68
  //#endregion
68
69
  //# sourceMappingURL=integration.utils.d.ts.map
@@ -176,7 +176,13 @@ function getSelfManagedBaseUrl(id, domain, protocol) {
176
176
  default: return baseUrl;
177
177
  }
178
178
  }
179
+ function getGitHubEnterprisePullRequestWriteOrigin(domain, protocol) {
180
+ const baseUrl = baseUrlFromDomain(domain, protocol);
181
+ const url = baseUrl == null ? null : URL.parse(baseUrl);
182
+ if (url?.protocol !== "http:" && url?.protocol !== "https:") return void 0;
183
+ return url.pathname === "/" || url.pathname === "/api" || url.pathname === "/api/v3" ? url.origin : void 0;
184
+ }
179
185
  //#endregion
180
- export { convertRemoteProviderIdToIntegrationId, getIntegrationConnectedKey, getIntegrationIdForRemote, getSelfManagedBaseUrl, isCloudGitSelfManagedHostIntegrationId, isCloudSelfManagedHostIntegrationId, isGitCloudHostIntegrationId, isGitSelfManagedHostIntegrationId, isIssuesHostIntegrationId, isIssuesSelfManagedHostIntegrationId, isJiraIntegrationId, isNonExpiringZeroTokenIntegrationId, isSelfManagedHostIntegrationId, remoteProviderTypeForConfig, remoteProviderTypeForIntegration, supportedIntegrationIds, warnOnMissingSessionForDomain };
186
+ export { convertRemoteProviderIdToIntegrationId, getGitHubEnterprisePullRequestWriteOrigin, getIntegrationConnectedKey, getIntegrationIdForRemote, getSelfManagedBaseUrl, isCloudGitSelfManagedHostIntegrationId, isCloudSelfManagedHostIntegrationId, isGitCloudHostIntegrationId, isGitSelfManagedHostIntegrationId, isIssuesHostIntegrationId, isIssuesSelfManagedHostIntegrationId, isJiraIntegrationId, isNonExpiringZeroTokenIntegrationId, isSelfManagedHostIntegrationId, remoteProviderTypeForConfig, remoteProviderTypeForIntegration, supportedIntegrationIds, warnOnMissingSessionForDomain };
181
187
 
182
188
  //# 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\tintegrationIds,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { IntegrationConnectedKey } from '../models/publicIntegration.js';\n// These domain checks come from `providers/metadata.ts` rather than the individual provider modules: those read\n// `providersMetadata[...]` synchronously at module init, so importing from them while `providers/metadata.ts` is\n// still loading triggers a TDZ on `providersMetadata`. Importing the shared predicates keeps one definition of each\n// regex — duplicating them let a fix land in only one place.\nimport { isAzureCloudDomain, isBitbucketCloudDomain, isGitHubDotCom, isGitLabDotCom } from '../providers/metadata.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[] = integrationIds;\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 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.some(integrationId => integrationId === id);\n}\n\nexport function isIssuesSelfManagedHostIntegrationId(id: IntegrationIds): id is IssuesSelfManagedHostIntegrationId {\n\treturn selfHostedIssuesIntegrationIds.some(integrationId => integrationId === id);\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 is Jira, Cloud or Data Center: the two share their project and site identity rules and the SDK's\n * status mapper. Takes any string, as a provider reference's `id` is one.\n */\nexport function isJiraIntegrationId(\n\tid: string,\n): id is IssuesCloudHostIntegrationId.Jira | IssuesSelfManagedHostIntegrationId.JiraServer {\n\treturn id === IssuesCloudHostIntegrationId.Jira || id === IssuesSelfManagedHostIntegrationId.JiraServer;\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 IssuesCloudHostIntegrationId.Asana:\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":"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"}
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\tintegrationIds,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { IntegrationConnectedKey } from '../models/publicIntegration.js';\n// These domain checks come from `providers/metadata.ts` rather than the individual provider modules: those read\n// `providersMetadata[...]` synchronously at module init, so importing from them while `providers/metadata.ts` is\n// still loading triggers a TDZ on `providersMetadata`. Importing the shared predicates keeps one definition of each\n// regex — duplicating them let a fix land in only one place.\nimport { isAzureCloudDomain, isBitbucketCloudDomain, isGitHubDotCom, isGitLabDotCom } from '../providers/metadata.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[] = integrationIds;\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 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.some(integrationId => integrationId === id);\n}\n\nexport function isIssuesSelfManagedHostIntegrationId(id: IntegrationIds): id is IssuesSelfManagedHostIntegrationId {\n\treturn selfHostedIssuesIntegrationIds.some(integrationId => integrationId === id);\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 is Jira, Cloud or Data Center: the two share their project and site identity rules and the SDK's\n * status mapper. Takes any string, as a provider reference's `id` is one.\n */\nexport function isJiraIntegrationId(\n\tid: string,\n): id is IssuesCloudHostIntegrationId.Jira | IssuesSelfManagedHostIntegrationId.JiraServer {\n\treturn id === IssuesCloudHostIntegrationId.Jira || id === IssuesSelfManagedHostIntegrationId.JiraServer;\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 IssuesCloudHostIntegrationId.Asana:\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\nexport function getGitHubEnterprisePullRequestWriteOrigin(\n\tdomain: string | undefined,\n\tprotocol?: string,\n): string | undefined {\n\tconst baseUrl = baseUrlFromDomain(domain, protocol);\n\tconst url = baseUrl == null ? null : URL.parse(baseUrl);\n\tif (url?.protocol !== 'http:' && url?.protocol !== 'https:') return undefined;\n\n\treturn url.pathname === '/' || url.pathname === '/api' || url.pathname === '/api/v3' ? url.origin : undefined;\n}\n"],"mappings":"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"}
@@ -1,10 +1,10 @@
1
1
  import { getScopedLogger, maybeStartScopedLogger } from "../../logger.scoped.js";
2
2
  import { isWindows } from "./platform.js";
3
3
  import { join } from "path";
4
- import { execFile, spawn } from "child_process";
5
- import { access, constants } from "fs";
6
4
  import { stat } from "fs/promises";
7
5
  import * as process from "process";
6
+ import { execFile, spawn } from "child_process";
7
+ import { access, constants } from "fs";
8
8
  //#region ../utils/src/env/node/exec.ts
9
9
  var RunError = class extends Error {
10
10
  cmd;
@@ -114,16 +114,24 @@ cache controls (`connectionId`, `etag`, expiry). The optional methods are:
114
114
  - `getRepositoryMetadata`, `getRepositoryDefaultBranch`: repository lookups.
115
115
  - `getPullRequestForSha`, `getPullRequestForBranch`, `getPullRequest`: pull-request lookups by commit, branch, or id.
116
116
  - `getIssue`, `getIssueOrPullRequest`: issue lookups by id.
117
- - `deletePullRequests()`: evicts every cached pull request (a merge can change pull requests no caller can name).
117
+ - `deletePullRequests(scope?)` evicts cached pull requests for the provided `{ id, domain }` installation origin.
118
+ Without a scope, evict all pull requests because a merge can change pull requests no caller can name.
118
119
 
119
120
  A method you omit means no caching for that read: its loader runs on every call (and `deletePullRequests` is a
120
121
  no-op). Call a method as `cache.method(...)`; the manager never detaches it, so a class instance works.
121
122
 
122
- The descriptor is `{ id, domain, maybeConnected, sessionFingerprint }`, not the integration class. Its getters read
123
- through to the live integration each time they are read, so the values are live, not snapshots. Key entries by `id`
124
- and `domain`, and treat `maybeConnected` and `sessionFingerprint` as the entry's etag: when either changes (a
125
- reconnect, a token change) the entry must miss. The descriptor is `undefined` for lookups with no integration.
126
- The fixture uses the package's public `PromiseCache` utility, but any cache with the same behavior is valid.
123
+ The cache descriptor exposes `id`, `domain`, `maybeConnected`, and `sessionFingerprint` without exposing the
124
+ integration instance. Key entries by provider and domain, and treat the connection state and fingerprint as the
125
+ entry's etag. Enterprise pull request descriptors also carry `installationOrigin` and the fingerprint captured for
126
+ the request. Use that origin as the cache namespace so installations that share a hostname stay independent.
127
+ For other reads, the state and fingerprint getters reflect the live integration. A lookup without an integration
128
+ receives an undefined descriptor. The fixture uses the package's public `PromiseCache` utility, but any cache with
129
+ the same behavior is valid.
130
+
131
+ For a cached-only Enterprise pull request lookup, `GitHostIntegration.getCachedPullRequestScope?(remoteUrl)` accepts
132
+ the fetch remote URL. HTTP(S) remotes must match the selected session's scheme, host, and port. SSH and scp
133
+ remotes must match its hostname, and the scope uses the session's actual API origin. The optional method returns
134
+ `undefined` without a matching established session and makes no authentication or network requests.
127
135
 
128
136
  ### Authentication
129
137
 
@@ -931,7 +939,51 @@ An `ok: false` result contains a typed reason. GitHub can report inaccessible pr
931
939
  before the response was lost. For an Enterprise failure with `mutationDispatched: false`, Core stopped
932
940
  before sending a mutation.
933
941
 
934
- ### GitHub.com pull request writes
942
+ ### Jira Cloud issue writes
943
+
944
+ Use the tracker methods on `IntegrationManager` from `@gitkraken/core-gitlens/plus/integrations/index.js`.
945
+ Each call takes `providerId: IssuesCloudHostIntegrationId.Jira`, the selected `connectionId` and that
946
+ connection's `resourceId` (the Atlassian cloud ID). The manager looks up the site's URL with the same
947
+ credential used for reads. If you supply `expectedAccountId`, the account returned by Jira's `/myself`
948
+ must match. Use the returned `accountId` for subsequent calls. Issue and project keys can repeat across
949
+ sites, so retain the cloud ID alongside the canonical issue ID.
950
+
951
+ | Method | Additional input | Success |
952
+ | ------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
953
+ | `getIssueTrackerCreateOptions` | `project` (key or ID), optional `issueTypeId` | Canonical project, its `issueTypes` or the selected type's `fields`, and `truncated`. |
954
+ | `getIssueTrackerIssueWriteOptions` | `issue` (key or ID), optional `expectedIssueId` | Issue receipt, `accountId`, editable `fields`, `transitions`, permission flags and `deleteCapability`. |
955
+ | `writeIssueTrackerIssue` | `action: 'create'`, `project`, `issueTypeId`, `summary`, optional `description` and `fields` | Created issue receipt and `accountId`. |
956
+ | `writeIssueTrackerIssue` | `action: 'edit'`, `issue`, `expectedIssueId`, at least one change in `summary`, `description` or `fields` | Updated issue receipt and `accountId`. |
957
+ | `writeIssueTrackerIssue` | `action: 'transition'`, `issue`, `expectedIssueId`, `transitionId`, optional `summary`, `description` and `fields` | Updated issue receipt and `accountId`. |
958
+ | `resolveIssueTrackerIssueWriteTarget` | `issue`, optional `expectedIssueId` and `intent: 'delete'` | Canonical issue receipt and `accountId` for a confirmation UI. Delete intent also checks the credential, permission and subtasks. |
959
+ | `deleteIssueTrackerIssue` | `issue`, `expectedIssueId`, `expectedAccountId` | Pre-delete issue receipt and `accountId` after Jira acknowledges the delete. |
960
+
961
+ Use the metadata for the exact project, issue type or transition you selected. Each field carries its
962
+ ID, operations, required and default flags, and any schema or allowed values Jira sends. Create
963
+ metadata is read in at most 20 requests of up to 50 entries each. Check `truncated` before treating the
964
+ returned list as complete. Pass Jira REST field values as a map keyed by field ID. Use the top-level
965
+ inputs for `summary`, `description`, `project` and `issueTypeId`. A transition takes `summary` and `description` only when
966
+ its screen sets them. Jira REST v2 accepts Jira wiki markup
967
+ strings for rich-text fields. The caller is responsible for converting other formats.
968
+
969
+ For an existing issue, retain the returned key and canonical ID together. Edit, transition and delete
970
+ resolve the address again and send the mutation by canonical ID. A key Jira resolves to a moved issue
971
+ or an ID that differs from the observed ID returns `conflict`. Each receipt contains the site, canonical ID
972
+ and key, browser URL, project ID and key, issue type, summary, and workflow status ID, name and category.
973
+
974
+ Before presenting a delete confirmation, resolve with `intent: 'delete'`. Delete checks the same
975
+ site, account and issue on execution. Issues with subtasks are refused. The site grant must include
976
+ the `delete:issue:jira` granular scope or the `write:jira-work` classic scope, and the user also needs
977
+ Jira's Delete Issues permission. The GitKraken Jira grant currently needs an updated scope and
978
+ reconnection before delete is available.
979
+
980
+ Failures have `ok: false` and a typed `reason`. An `invalid-input` result may include `fieldErrors`
981
+ and `messages` from Jira. A scope mismatch returns `insufficient-scope` without expiring the read
982
+ credential. `mutationDispatched: false` means Core stopped before sending the write. Treat
983
+ `applied: 'maybe'` as uncertain and reconcile the issue state before retrying. A successful delete
984
+ requires Jira's `204` acknowledgement. Jira can also return `404` when visibility changes. [Jira Cloud REST v2 issue operations](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issues/)
985
+
986
+ ### GitHub and GitHub Enterprise Server pull request writes
935
987
 
936
988
  Use `providerId: 'github'` and the `connectionId` that read the repository or pull request. Pass the
937
989
  repository’s `owner` and `repo`, plus the `number` and `expectedNodeId` for an existing pull request.
@@ -944,6 +996,14 @@ repository at the same address. For an active repository, `canCreate` is `true`
944
996
  a repository role for the viewer, and `undefined` when the role is unavailable. GitHub determines
945
997
  whether the viewer may create a pull request between the chosen branches when it receives the write.
946
998
 
999
+ For GitHub Enterprise Server, pass `providerId: 'cloud-github-enterprise'`, the connection ID,
1000
+ the full HTTP(S) installation origin as `domain`, and the expected GitHub login as `expectedLogin`
1001
+ to all three methods. The origin includes the scheme and any non-default port. The PR write API
1002
+ accepts installations served from the origin root. A path in the requested domain returns `invalid-input`.
1003
+ Core accepts `/api` and `/api/v3` as aliases for the root installation on the configured connection
1004
+ and selected credential. Any other path on either returns `no-connection` before a provider request.
1005
+ Core verifies the credential's live login and requires `expectedRepositoryId` on create.
1006
+
947
1007
  | Action for `writePullRequest` | Required input and result |
948
1008
  | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
949
1009
  | `create` | `headRef` and `baseRef` are branch names in the selected repository. Pass a `title` and optional `body`. Returns `created`. |
@@ -959,14 +1019,26 @@ write. The write preflight checks the observed base branch. GitHub checks the ex
959
1019
  for direct merge and enqueue.
960
1020
  Stacked merge actions can land more than one pull request and are unavailable through this API.
961
1021
 
1022
+ On GitHub Enterprise Server, Core checks the installed mutation schema, active branch rules and
1023
+ legacy linear-history policy before offering a merge strategy. It offers enqueue when the branch
1024
+ requires a queue and the installation supports the expected-head check. If Core cannot establish the
1025
+ merge policy, edit and state capabilities still reflect the viewer's pull request permissions.
1026
+ Core checks the base branch again before dispatching a merge or enqueue and verifies that the
1027
+ receipt matches the approved base. GitHub exposes the atomic check for the head only.
1028
+
962
1029
  Every confirmed result carries a canonical snapshot with GitHub’s update time and close or merge
963
- time when available. An enqueue receipt carries the snapshot verified at dispatch and the `queued`
1030
+ time when available. A GitHub.com enqueue receipt carries the snapshot verified at dispatch and the `queued`
964
1031
  status. Consumers should refresh the item and related views for its latest
965
1032
  queue position or merge state. `outcome-unknown` means the write may have reached GitHub. Reconcile it
966
1033
  through a fresh read before retrying. `blocked` means the action was refused by the pull request state or
967
1034
  branch policy. Inaccessible private resources can appear as `not-found`. After GitHub rejects a credential
968
1035
  with HTTP 401, the next operation on that connection can recover it. Core never replays the write.
969
1036
 
1037
+ Enterprise snapshots include the canonical origin in `domain`. An Enterprise enqueue returns the
1038
+ pull request attached to the queue entry. If the selected credential changes while GitHub processes
1039
+ a write, a confirmed result still carries its status and adds `credentialChanged: true`. Use that
1040
+ status to refresh by origin and read the snapshot under the current credential.
1041
+
970
1042
  ## 5. Paging
971
1043
 
972
1044
  Two mechanisms live behind one shape, and they are **not** interchangeable:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.46.0",
4
+ "version": "0.47.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",