@gitkraken/core-gitlens 0.3.1 → 0.4.100
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 +83 -1
- package/README.md +22 -12
- package/dist/git/cache.d.ts +29 -2
- package/dist/git/cache.d.ts.map +1 -1
- package/dist/git/cache.js +67 -7
- package/dist/git/cache.js.map +1 -1
- package/dist/git/context.d.ts +4 -3
- package/dist/git/context.d.ts.map +1 -1
- package/dist/git/context.js.map +1 -1
- package/dist/git/errors.d.ts +31 -1
- package/dist/git/errors.d.ts.map +1 -1
- package/dist/git/errors.js +29 -0
- package/dist/git/errors.js.map +1 -1
- package/dist/git/models/author.d.ts.map +1 -1
- package/dist/git/models/author.js.map +1 -1
- package/dist/git/models/autolink.d.ts.map +1 -1
- package/dist/git/models/autolink.js.map +1 -1
- package/dist/git/models/blame.d.ts.map +1 -1
- package/dist/git/models/blame.js.map +1 -1
- package/dist/git/models/branch.d.ts.map +1 -1
- package/dist/git/models/branch.js.map +1 -1
- package/dist/git/models/commit.d.ts.map +1 -1
- package/dist/git/models/commit.js +1 -1
- package/dist/git/models/commit.js.map +1 -1
- package/dist/git/models/contributor.d.ts.map +1 -1
- package/dist/git/models/contributor.js.map +1 -1
- package/dist/git/models/defaultBranch.d.ts.map +1 -1
- package/dist/git/models/defaultBranch.js.map +1 -1
- package/dist/git/models/diff.d.ts.map +1 -1
- package/dist/git/models/diff.js.map +1 -1
- package/dist/git/models/file.d.ts.map +1 -1
- package/dist/git/models/file.js.map +1 -1
- package/dist/git/models/fileChange.d.ts.map +1 -1
- package/dist/git/models/fileChange.js.map +1 -1
- package/dist/git/models/fileStatus.d.ts +22 -22
- package/dist/git/models/fileStatus.d.ts.map +1 -1
- package/dist/git/models/fileStatus.js.map +1 -1
- package/dist/git/models/graph.d.ts +122 -1
- package/dist/git/models/graph.d.ts.map +1 -1
- package/dist/git/models/graph.js +4 -0
- package/dist/git/models/graph.js.map +1 -1
- package/dist/git/models/graphSearch.d.ts.map +1 -1
- package/dist/git/models/graphSearch.js.map +1 -1
- package/dist/git/models/graphSession.d.ts +177 -0
- package/dist/git/models/graphSession.d.ts.map +1 -0
- package/dist/git/models/graphSession.js +7 -0
- package/dist/git/models/graphSession.js.map +1 -0
- package/dist/git/models/issue.d.ts +12 -2
- package/dist/git/models/issue.d.ts.map +1 -1
- package/dist/git/models/issue.js +3 -1
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/issueOrPullRequest.d.ts.map +1 -1
- package/dist/git/models/issueOrPullRequest.js.map +1 -1
- package/dist/git/models/lineRange.d.ts.map +1 -1
- package/dist/git/models/lineRange.js.map +1 -1
- package/dist/git/models/log.d.ts.map +1 -1
- package/dist/git/models/log.js.map +1 -1
- package/dist/git/models/mergeConflicts.d.ts.map +1 -1
- package/dist/git/models/mergeConflicts.js.map +1 -1
- package/dist/git/models/patch.d.ts.map +1 -1
- package/dist/git/models/patch.js.map +1 -1
- package/dist/git/models/pausedOperationStatus.d.ts.map +1 -1
- package/dist/git/models/pausedOperationStatus.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +27 -2
- package/dist/git/models/pullRequest.d.ts.map +1 -1
- package/dist/git/models/pullRequest.js +7 -1
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/models/rebase.d.ts.map +1 -1
- package/dist/git/models/rebase.js.map +1 -1
- package/dist/git/models/reference.d.ts.map +1 -1
- package/dist/git/models/reference.js.map +1 -1
- package/dist/git/models/reflog.d.ts.map +1 -1
- package/dist/git/models/reflog.js.map +1 -1
- package/dist/git/models/remote.d.ts.map +1 -1
- package/dist/git/models/remote.js.map +1 -1
- package/dist/git/models/remoteProvider.d.ts.map +1 -1
- package/dist/git/models/remoteProvider.js.map +1 -1
- package/dist/git/models/remoteResource.d.ts.map +1 -1
- package/dist/git/models/remoteResource.js.map +1 -1
- package/dist/git/models/repository.d.ts +20 -2
- package/dist/git/models/repository.d.ts.map +1 -1
- package/dist/git/models/repository.js +19 -0
- package/dist/git/models/repository.js.map +1 -1
- package/dist/git/models/repositoryChangeEvent.d.ts.map +1 -1
- package/dist/git/models/repositoryChangeEvent.js.map +1 -1
- package/dist/git/models/repositoryIdentities.d.ts.map +1 -1
- package/dist/git/models/repositoryIdentities.js.map +1 -1
- package/dist/git/models/repositoryMetadata.d.ts.map +1 -1
- package/dist/git/models/repositoryMetadata.js.map +1 -1
- package/dist/git/models/resourceDescriptor.d.ts +16 -0
- package/dist/git/models/resourceDescriptor.d.ts.map +1 -1
- package/dist/git/models/resourceDescriptor.js.map +1 -1
- package/dist/git/models/revision.d.ts.map +1 -1
- package/dist/git/models/revision.js.map +1 -1
- package/dist/git/models/search.d.ts.map +1 -1
- package/dist/git/models/search.js.map +1 -1
- package/dist/git/models/shortlog.d.ts.map +1 -1
- package/dist/git/models/shortlog.js.map +1 -1
- package/dist/git/models/signature.d.ts +14 -0
- package/dist/git/models/signature.d.ts.map +1 -1
- package/dist/git/models/signature.js.map +1 -1
- package/dist/git/models/staging.d.ts.map +1 -1
- package/dist/git/models/staging.js.map +1 -1
- package/dist/git/models/stash.d.ts.map +1 -1
- package/dist/git/models/stash.js.map +1 -1
- package/dist/git/models/status.d.ts.map +1 -1
- package/dist/git/models/status.js.map +1 -1
- package/dist/git/models/statusFile.d.ts.map +1 -1
- package/dist/git/models/statusFile.js.map +1 -1
- package/dist/git/models/tag.d.ts +11 -1
- package/dist/git/models/tag.d.ts.map +1 -1
- package/dist/git/models/tag.js +9 -2
- package/dist/git/models/tag.js.map +1 -1
- package/dist/git/models/tree.d.ts.map +1 -1
- package/dist/git/models/tree.js.map +1 -1
- package/dist/git/models/user.d.ts.map +1 -1
- package/dist/git/models/user.js.map +1 -1
- package/dist/git/models/worktree.d.ts.map +1 -1
- package/dist/git/models/worktree.js.map +1 -1
- package/dist/git/parsers/diffParser.d.ts.map +1 -1
- package/dist/git/parsers/diffParser.js +1 -1
- package/dist/git/parsers/diffParser.js.map +1 -1
- package/dist/git/parsers/rebaseTodoParser.d.ts.map +1 -1
- package/dist/git/parsers/rebaseTodoParser.js.map +1 -1
- package/dist/git/providers/blame.d.ts.map +1 -1
- package/dist/git/providers/blame.js.map +1 -1
- package/dist/git/providers/branches.d.ts +8 -1
- package/dist/git/providers/branches.d.ts.map +1 -1
- package/dist/git/providers/branches.js.map +1 -1
- package/dist/git/providers/commits.d.ts +6 -1
- package/dist/git/providers/commits.d.ts.map +1 -1
- package/dist/git/providers/commits.js.map +1 -1
- package/dist/git/providers/config.d.ts +6 -2
- package/dist/git/providers/config.d.ts.map +1 -1
- package/dist/git/providers/config.js.map +1 -1
- package/dist/git/providers/contributors.d.ts.map +1 -1
- package/dist/git/providers/contributors.js.map +1 -1
- package/dist/git/providers/diff.d.ts.map +1 -1
- package/dist/git/providers/diff.js.map +1 -1
- package/dist/git/providers/graph.d.ts +55 -1
- package/dist/git/providers/graph.d.ts.map +1 -1
- package/dist/git/providers/graph.js.map +1 -1
- package/dist/git/providers/operations.d.ts +1 -0
- package/dist/git/providers/operations.d.ts.map +1 -1
- package/dist/git/providers/operations.js.map +1 -1
- package/dist/git/providers/patch.d.ts.map +1 -1
- package/dist/git/providers/patch.js.map +1 -1
- package/dist/git/providers/pausedOperations.d.ts.map +1 -1
- package/dist/git/providers/pausedOperations.js.map +1 -1
- package/dist/git/providers/provider.d.ts.map +1 -1
- package/dist/git/providers/provider.js.map +1 -1
- package/dist/git/providers/refs.d.ts.map +1 -1
- package/dist/git/providers/refs.js.map +1 -1
- package/dist/git/providers/remotes.d.ts.map +1 -1
- package/dist/git/providers/remotes.js.map +1 -1
- package/dist/git/providers/revision.d.ts.map +1 -1
- package/dist/git/providers/revision.js.map +1 -1
- package/dist/git/providers/shared/remotes.d.ts.map +1 -1
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/providers/staging.d.ts.map +1 -1
- package/dist/git/providers/staging.js.map +1 -1
- package/dist/git/providers/stash.d.ts.map +1 -1
- package/dist/git/providers/stash.js.map +1 -1
- package/dist/git/providers/status.d.ts +1 -0
- package/dist/git/providers/status.d.ts.map +1 -1
- package/dist/git/providers/status.js.map +1 -1
- package/dist/git/providers/tags.d.ts.map +1 -1
- package/dist/git/providers/tags.js.map +1 -1
- package/dist/git/providers/types.d.ts.map +1 -1
- package/dist/git/providers/types.js.map +1 -1
- package/dist/git/providers/worktrees.d.ts +5 -1
- package/dist/git/providers/worktrees.d.ts.map +1 -1
- package/dist/git/providers/worktrees.js.map +1 -1
- package/dist/git/remotes/azure-devops.d.ts.map +1 -1
- package/dist/git/remotes/azure-devops.js +27 -31
- package/dist/git/remotes/azure-devops.js.map +1 -1
- package/dist/git/remotes/bitbucket-server.d.ts.map +1 -1
- package/dist/git/remotes/bitbucket-server.js +21 -23
- package/dist/git/remotes/bitbucket-server.js.map +1 -1
- package/dist/git/remotes/bitbucket.d.ts.map +1 -1
- package/dist/git/remotes/bitbucket.js +21 -23
- package/dist/git/remotes/bitbucket.js.map +1 -1
- package/dist/git/remotes/custom.d.ts.map +1 -1
- package/dist/git/remotes/custom.js.map +1 -1
- package/dist/git/remotes/gerrit.d.ts.map +1 -1
- package/dist/git/remotes/gerrit.js +11 -13
- package/dist/git/remotes/gerrit.js.map +1 -1
- package/dist/git/remotes/gitea.d.ts.map +1 -1
- package/dist/git/remotes/gitea.js +12 -14
- package/dist/git/remotes/gitea.js.map +1 -1
- package/dist/git/remotes/github.d.ts.map +1 -1
- package/dist/git/remotes/github.js +54 -56
- package/dist/git/remotes/github.js.map +1 -1
- package/dist/git/remotes/gitlab.d.ts.map +1 -1
- package/dist/git/remotes/gitlab.js +93 -95
- package/dist/git/remotes/gitlab.js.map +1 -1
- package/dist/git/remotes/google-source.d.ts.map +1 -1
- package/dist/git/remotes/google-source.js.map +1 -1
- package/dist/git/remotes/matcher.d.ts.map +1 -1
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/run.types.d.ts +62 -3
- package/dist/git/run.types.d.ts.map +1 -1
- package/dist/git/service.d.ts.map +1 -1
- package/dist/git/utils/autolink.utils.d.ts.map +1 -1
- package/dist/git/utils/autolink.utils.js.map +1 -1
- package/dist/git/utils/blame.utils.d.ts.map +1 -1
- package/dist/git/utils/blame.utils.js.map +1 -1
- package/dist/git/utils/branch.utils.d.ts.map +1 -1
- package/dist/git/utils/branch.utils.js +12 -1
- package/dist/git/utils/branch.utils.js.map +1 -1
- package/dist/git/utils/commit.utils.d.ts.map +1 -1
- package/dist/git/utils/commit.utils.js.map +1 -1
- package/dist/git/utils/conflictResolution.utils.d.ts +32 -0
- package/dist/git/utils/conflictResolution.utils.d.ts.map +1 -1
- package/dist/git/utils/conflictResolution.utils.js +95 -0
- package/dist/git/utils/conflictResolution.utils.js.map +1 -1
- package/dist/git/utils/contributor.utils.d.ts +1 -1
- package/dist/git/utils/contributor.utils.d.ts.map +1 -1
- package/dist/git/utils/contributor.utils.js +1 -2
- package/dist/git/utils/contributor.utils.js.map +1 -1
- package/dist/git/utils/fetch.utils.d.ts.map +1 -1
- package/dist/git/utils/fetch.utils.js.map +1 -1
- package/dist/git/utils/fileStatus.utils.d.ts +7 -0
- package/dist/git/utils/fileStatus.utils.d.ts.map +1 -1
- package/dist/git/utils/fileStatus.utils.js +6 -0
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/utils/graph.utils.d.ts +20 -0
- package/dist/git/utils/graph.utils.d.ts.map +1 -0
- package/dist/git/utils/graph.utils.js +40 -0
- package/dist/git/utils/graph.utils.js.map +1 -0
- package/dist/git/utils/issue.utils.d.ts.map +1 -1
- package/dist/git/utils/issue.utils.js +1 -0
- package/dist/git/utils/issue.utils.js.map +1 -1
- package/dist/git/utils/issueOrPullRequest.utils.d.ts.map +1 -1
- package/dist/git/utils/issueOrPullRequest.utils.js.map +1 -1
- package/dist/git/utils/mergeConflicts.utils.d.ts.map +1 -1
- package/dist/git/utils/mergeConflicts.utils.js.map +1 -1
- package/dist/git/utils/pausedOperationStatus.utils.d.ts +13 -13
- package/dist/git/utils/pausedOperationStatus.utils.d.ts.map +1 -1
- package/dist/git/utils/pausedOperationStatus.utils.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts.map +1 -1
- package/dist/git/utils/pullRequest.utils.js +9 -0
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/utils/reachability.utils.d.ts +20 -2
- package/dist/git/utils/reachability.utils.d.ts.map +1 -1
- package/dist/git/utils/reachability.utils.js +68 -7
- package/dist/git/utils/reachability.utils.js.map +1 -1
- package/dist/git/utils/rebase.utils.d.ts.map +1 -1
- package/dist/git/utils/rebase.utils.js.map +1 -1
- package/dist/git/utils/reference.utils.d.ts.map +1 -1
- package/dist/git/utils/reference.utils.js.map +1 -1
- package/dist/git/utils/remote.utils.d.ts.map +1 -1
- package/dist/git/utils/remote.utils.js.map +1 -1
- package/dist/git/utils/repository.utils.d.ts.map +1 -1
- package/dist/git/utils/repository.utils.js.map +1 -1
- package/dist/git/utils/resourceDescriptor.utils.d.ts.map +1 -1
- package/dist/git/utils/resourceDescriptor.utils.js.map +1 -1
- package/dist/git/utils/revision.utils.d.ts.map +1 -1
- package/dist/git/utils/revision.utils.js.map +1 -1
- package/dist/git/utils/search.utils.d.ts.map +1 -1
- package/dist/git/utils/search.utils.js.map +1 -1
- package/dist/git/utils/sorting.d.ts.map +1 -1
- package/dist/git/utils/sorting.js.map +1 -1
- package/dist/git/utils/sshKey.utils.d.ts +7 -0
- package/dist/git/utils/sshKey.utils.d.ts.map +1 -0
- package/dist/git/utils/sshKey.utils.js +25 -0
- package/dist/git/utils/sshKey.utils.js.map +1 -0
- package/dist/git/utils/status.utils.d.ts.map +1 -1
- package/dist/git/utils/status.utils.js.map +1 -1
- package/dist/git/utils/statusFile.utils.d.ts.map +1 -1
- package/dist/git/utils/statusFile.utils.js.map +1 -1
- package/dist/git/utils/tag.utils.d.ts.map +1 -1
- package/dist/git/utils/tag.utils.js.map +1 -1
- package/dist/git/utils/tooltip.utils.d.ts.map +1 -1
- package/dist/git/utils/tooltip.utils.js.map +1 -1
- package/dist/git/utils/uriAuthority.d.ts.map +1 -1
- package/dist/git/utils/uriAuthority.js.map +1 -1
- package/dist/git/utils/user.utils.d.ts.map +1 -1
- package/dist/git/utils/user.utils.js.map +1 -1
- package/dist/git/utils/worktree.utils.d.ts.map +1 -1
- package/dist/git/utils/worktree.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts.map +1 -1
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/classifyChange.d.ts.map +1 -1
- package/dist/git/watching/classifyChange.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.d.ts.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/initWatcher.d.ts.map +1 -1
- package/dist/git/watching/initWatcher.js.map +1 -1
- package/dist/git/watching/provider.d.ts.map +1 -1
- package/dist/git/watching/provider.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts.map +1 -1
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +4 -0
- package/dist/git/watching/watchService.d.ts.map +1 -1
- package/dist/git/watching/watchService.js +15 -1
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +7 -0
- package/dist/git/watching/watchSession.d.ts.map +1 -1
- package/dist/git/watching/watchSession.js +14 -2
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts.map +1 -1
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts.map +1 -1
- package/dist/git-cli/exec/exec.d.ts.map +1 -1
- package/dist/git-cli/exec/exec.errors.d.ts.map +1 -1
- package/dist/git-cli/exec/exec.errors.js.map +1 -1
- package/dist/git-cli/exec/exec.js.map +1 -1
- package/dist/git-cli/exec/exec.types.d.ts.map +1 -1
- package/dist/git-cli/exec/exec.types.js.map +1 -1
- package/dist/git-cli/exec/features.d.ts.map +1 -1
- package/dist/git-cli/exec/features.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +19 -27
- package/dist/git-cli/exec/git.d.ts.map +1 -1
- package/dist/git-cli/exec/git.js +126 -34
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/gitQueue.d.ts.map +1 -1
- package/dist/git-cli/exec/gitQueue.js.map +1 -1
- package/dist/git-cli/exec/locator.d.ts.map +1 -1
- package/dist/git-cli/exec/locator.js.map +1 -1
- package/dist/git-cli/parsers/blameParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/blameParser.js.map +1 -1
- package/dist/git-cli/parsers/indexParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/indexParser.js.map +1 -1
- package/dist/git-cli/parsers/logParser.d.ts +9 -1
- package/dist/git-cli/parsers/logParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/logParser.js +141 -60
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/parsers/mergeTreeParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/mergeTreeParser.js.map +1 -1
- package/dist/git-cli/parsers/refParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/refParser.js.map +1 -1
- package/dist/git-cli/parsers/reflogParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/reflogParser.js.map +1 -1
- package/dist/git-cli/parsers/remoteParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/remoteParser.js.map +1 -1
- package/dist/git-cli/parsers/shortlogParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/shortlogParser.js.map +1 -1
- package/dist/git-cli/parsers/signatureParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/signatureParser.js.map +1 -1
- package/dist/git-cli/parsers/sshSignatureParser.d.ts +21 -0
- package/dist/git-cli/parsers/sshSignatureParser.d.ts.map +1 -0
- package/dist/git-cli/parsers/sshSignatureParser.js +78 -0
- package/dist/git-cli/parsers/sshSignatureParser.js.map +1 -0
- package/dist/git-cli/parsers/statusParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/statusParser.js.map +1 -1
- package/dist/git-cli/parsers/treeParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/treeParser.js.map +1 -1
- package/dist/git-cli/parsers/worktreeParser.d.ts.map +1 -1
- package/dist/git-cli/parsers/worktreeParser.js +5 -7
- package/dist/git-cli/parsers/worktreeParser.js.map +1 -1
- package/dist/git-cli/providers/blame.d.ts.map +1 -1
- package/dist/git-cli/providers/blame.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +1 -0
- package/dist/git-cli/providers/branches.d.ts.map +1 -1
- package/dist/git-cli/providers/branches.js +51 -32
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commitFilesetUtils.d.ts.map +1 -1
- package/dist/git-cli/providers/commitFilesetUtils.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +12 -1
- package/dist/git-cli/providers/commits.d.ts.map +1 -1
- package/dist/git-cli/providers/commits.js +89 -8
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts.map +1 -1
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.d.ts.map +1 -1
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts.map +1 -1
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.d.ts +35 -1
- package/dist/git-cli/providers/graph.d.ts.map +1 -1
- package/dist/git-cli/providers/graph.js +1434 -330
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +1 -0
- package/dist/git-cli/providers/operations.d.ts.map +1 -1
- package/dist/git-cli/providers/operations.js +22 -1
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.d.ts.map +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.d.ts.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +3 -3
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts.map +1 -1
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/remotes.d.ts.map +1 -1
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/git-cli/providers/revision.d.ts +1 -0
- package/dist/git-cli/providers/revision.d.ts.map +1 -1
- package/dist/git-cli/providers/revision.js +33 -0
- package/dist/git-cli/providers/revision.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts.map +1 -1
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/git-cli/providers/stash.d.ts.map +1 -1
- package/dist/git-cli/providers/stash.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +28 -0
- package/dist/git-cli/providers/status.d.ts.map +1 -1
- package/dist/git-cli/providers/status.js +240 -154
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts.map +1 -1
- package/dist/git-cli/providers/tags.js +2 -1
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/providers/worktrees.d.ts +4 -1
- package/dist/git-cli/providers/worktrees.d.ts.map +1 -1
- package/dist/git-cli/providers/worktrees.js +31 -3
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.d.ts.map +1 -1
- package/dist/git-cli/service.js +8 -0
- package/dist/git-cli/service.js.map +1 -1
- package/dist/ipc/ipcServer.d.ts.map +1 -1
- package/dist/ipc/ipcServer.js +1 -1
- package/dist/ipc/ipcServer.js.map +1 -1
- package/dist/plus/agents/providers/claudeCodeProvider.d.ts +6 -1
- package/dist/plus/agents/providers/claudeCodeProvider.d.ts.map +1 -1
- package/dist/plus/agents/providers/claudeCodeProvider.js +19 -0
- package/dist/plus/agents/providers/claudeCodeProvider.js.map +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.d.ts +68 -0
- package/dist/plus/agents/providers/claudeCodeTranscript.d.ts.map +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +262 -8
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/agents/types.d.ts +36 -2
- package/dist/plus/agents/types.d.ts.map +1 -1
- package/dist/plus/ai/constants.d.ts +1 -2
- package/dist/plus/ai/constants.d.ts.map +1 -1
- package/dist/plus/ai/constants.js +1 -8
- package/dist/plus/ai/constants.js.map +1 -1
- package/dist/plus/ai/errors.d.ts.map +1 -1
- package/dist/plus/ai/errors.js.map +1 -1
- package/dist/plus/ai/models/conversation.d.ts.map +1 -1
- package/dist/plus/ai/models/conversation.js.map +1 -1
- package/dist/plus/ai/models/model.d.ts +2 -1
- package/dist/plus/ai/models/model.d.ts.map +1 -1
- package/dist/plus/ai/models/model.js +50 -1
- package/dist/plus/ai/models/model.js.map +1 -1
- package/dist/plus/ai/models/promptTemplates.d.ts +5 -2
- package/dist/plus/ai/models/promptTemplates.d.ts.map +1 -1
- package/dist/plus/ai/models/promptTemplates.js.map +1 -1
- package/dist/plus/ai/models/provider.d.ts.map +1 -1
- package/dist/plus/ai/models/provider.js.map +1 -1
- package/dist/plus/ai/models/results.d.ts.map +1 -1
- package/dist/plus/ai/models/results.js.map +1 -1
- package/dist/plus/ai/prompts.d.ts +1 -1
- package/dist/plus/ai/prompts.d.ts.map +1 -1
- package/dist/plus/ai/prompts.js +15 -47
- package/dist/plus/ai/prompts.js.map +1 -1
- package/dist/plus/ai/providers/anthropicProvider.d.ts +5 -0
- package/dist/plus/ai/providers/anthropicProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/anthropicProvider.js +40 -3
- package/dist/plus/ai/providers/anthropicProvider.js.map +1 -1
- package/dist/plus/ai/providers/azureProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/azureProvider.js.map +1 -1
- package/dist/plus/ai/providers/context.d.ts.map +1 -1
- package/dist/plus/ai/providers/context.js.map +1 -1
- package/dist/plus/ai/providers/deepSeekProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/deepSeekProvider.js +17 -1
- package/dist/plus/ai/providers/deepSeekProvider.js.map +1 -1
- package/dist/plus/ai/providers/geminiProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/geminiProvider.js +25 -6
- package/dist/plus/ai/providers/geminiProvider.js.map +1 -1
- package/dist/plus/ai/providers/gitkrakenProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/gitkrakenProvider.js +1 -0
- package/dist/plus/ai/providers/gitkrakenProvider.js.map +1 -1
- package/dist/plus/ai/providers/huggingFaceProvider.d.ts +1 -1
- package/dist/plus/ai/providers/huggingFaceProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/huggingFaceProvider.js +21 -18
- package/dist/plus/ai/providers/huggingFaceProvider.js.map +1 -1
- package/dist/plus/ai/providers/mistralProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/mistralProvider.js.map +1 -1
- package/dist/plus/ai/providers/ollamaProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/ollamaProvider.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProvider.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.d.ts +10 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.d.ts.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +9 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js.map +1 -1
- package/dist/plus/ai/providers/openRouterProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/openRouterProvider.js.map +1 -1
- package/dist/plus/ai/providers/openaiProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/openaiProvider.js.map +1 -1
- package/dist/plus/ai/providers/xaiProvider.d.ts.map +1 -1
- package/dist/plus/ai/providers/xaiProvider.js +14 -1
- package/dist/plus/ai/providers/xaiProvider.js.map +1 -1
- package/dist/plus/ai/utils/ai.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/ai.utils.js +5 -7
- package/dist/plus/ai/utils/ai.utils.js.map +1 -1
- package/dist/plus/ai/utils/results.utils.d.ts +3 -0
- package/dist/plus/ai/utils/results.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/results.utils.js +26 -0
- package/dist/plus/ai/utils/results.utils.js.map +1 -1
- package/dist/plus/ai/utils/truncation.utils.d.ts +1 -1
- package/dist/plus/ai/utils/truncation.utils.d.ts.map +1 -1
- package/dist/plus/ai/utils/truncation.utils.js.map +1 -1
- package/dist/plus/git-github/api/config.d.ts.map +1 -1
- package/dist/plus/git-github/api/config.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +71 -15
- package/dist/plus/git-github/api/github.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.js +350 -84
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/github.utils.d.ts.map +1 -1
- package/dist/plus/git-github/api/github.utils.js.map +1 -1
- package/dist/plus/git-github/api/token.d.ts.map +1 -1
- package/dist/plus/git-github/api/token.js.map +1 -1
- package/dist/plus/git-github/api/tokenUtils.d.ts.map +1 -1
- package/dist/plus/git-github/api/tokenUtils.js.map +1 -1
- package/dist/plus/git-github/api/types.d.ts.map +1 -1
- package/dist/plus/git-github/api/types.js.map +1 -1
- package/dist/plus/git-github/context.d.ts.map +1 -1
- package/dist/plus/git-github/models.d.ts +5 -0
- package/dist/plus/git-github/models.d.ts.map +1 -1
- package/dist/plus/git-github/models.js +27 -2
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/git-github/providers/github/blame.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/blame.js.map +1 -1
- package/dist/plus/git-github/providers/github/branches.d.ts +2 -1
- package/dist/plus/git-github/providers/github/branches.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/branches.js +7 -3
- package/dist/plus/git-github/providers/github/branches.js.map +1 -1
- package/dist/plus/git-github/providers/github/commits.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/commits.js.map +1 -1
- package/dist/plus/git-github/providers/github/config.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/config.js.map +1 -1
- package/dist/plus/git-github/providers/github/contributors.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/contributors.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/diff.js +2 -2
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/git-github/providers/github/graph.d.ts +12 -1
- package/dist/plus/git-github/providers/github/graph.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/graph.js +85 -0
- package/dist/plus/git-github/providers/github/graph.js.map +1 -1
- package/dist/plus/git-github/providers/github/refs.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/refs.js.map +1 -1
- package/dist/plus/git-github/providers/github/remotes.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/remotes.js.map +1 -1
- package/dist/plus/git-github/providers/github/revision.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/revision.js.map +1 -1
- package/dist/plus/git-github/providers/github/status.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/status.js.map +1 -1
- package/dist/plus/git-github/providers/github/tags.d.ts.map +1 -1
- package/dist/plus/git-github/providers/github/tags.js +3 -1
- package/dist/plus/git-github/providers/github/tags.js.map +1 -1
- package/dist/plus/git-github/providers/githubGitProvider.d.ts.map +1 -1
- package/dist/plus/git-github/providers/githubGitProvider.js.map +1 -1
- package/dist/plus/git-github/providers/githubProvider.d.ts.map +1 -1
- package/dist/plus/git-github/providers/githubProvider.js.map +1 -1
- package/dist/plus/integrations/authentication/cloudIntegrationService.d.ts +30 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.js +214 -0
- package/dist/plus/integrations/authentication/cloudIntegrationService.js.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts +114 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js +497 -0
- package/dist/plus/integrations/authentication/configuredIntegrationService.js.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts +112 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js +217 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts +62 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js +126 -0
- package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.d.ts +16 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.js +53 -0
- package/dist/plus/integrations/authentication/manualTokenProvider.js.map +1 -0
- package/dist/plus/integrations/authentication/models.d.ts +120 -0
- package/dist/plus/integrations/authentication/models.d.ts.map +1 -0
- package/dist/plus/integrations/authentication/models.js +64 -0
- package/dist/plus/integrations/authentication/models.js.map +1 -0
- package/dist/plus/integrations/collectionMetadata.d.ts +21 -0
- package/dist/plus/integrations/collectionMetadata.d.ts.map +1 -0
- package/dist/plus/integrations/collectionMetadata.js +121 -0
- package/dist/plus/integrations/collectionMetadata.js.map +1 -0
- package/dist/plus/integrations/constants.d.ts +57 -0
- package/dist/plus/integrations/constants.d.ts.map +1 -0
- package/dist/plus/integrations/constants.js +138 -0
- package/dist/plus/integrations/constants.js.map +1 -0
- package/dist/plus/integrations/context.d.ts +358 -0
- package/dist/plus/integrations/context.d.ts.map +1 -0
- package/dist/plus/integrations/context.js +2 -0
- package/dist/plus/integrations/context.js.map +1 -0
- package/dist/plus/integrations/errors.d.ts +79 -0
- package/dist/plus/integrations/errors.d.ts.map +1 -0
- package/dist/plus/integrations/errors.js +150 -0
- package/dist/plus/integrations/errors.js.map +1 -0
- package/dist/plus/integrations/index.d.ts +77 -0
- package/dist/plus/integrations/index.d.ts.map +1 -0
- package/dist/plus/integrations/index.js +64 -0
- package/dist/plus/integrations/index.js.map +1 -0
- package/dist/plus/integrations/integrationService.d.ts +379 -0
- package/dist/plus/integrations/integrationService.d.ts.map +1 -0
- package/dist/plus/integrations/integrationService.js +1895 -0
- package/dist/plus/integrations/integrationService.js.map +1 -0
- package/dist/plus/integrations/lite.d.ts +47 -0
- package/dist/plus/integrations/lite.d.ts.map +1 -0
- package/dist/plus/integrations/lite.js +141 -0
- package/dist/plus/integrations/lite.js.map +1 -0
- package/dist/plus/integrations/manager.d.ts +332 -0
- package/dist/plus/integrations/manager.d.ts.map +1 -0
- package/dist/plus/integrations/manager.js +2 -0
- package/dist/plus/integrations/manager.js.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts +341 -0
- package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -0
- package/dist/plus/integrations/models/gitHostIntegration.js +1146 -0
- package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -0
- package/dist/plus/integrations/models/integration.d.ts +212 -0
- package/dist/plus/integrations/models/integration.d.ts.map +1 -0
- package/dist/plus/integrations/models/integration.js +627 -0
- package/dist/plus/integrations/models/integration.js.map +1 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts +108 -0
- package/dist/plus/integrations/models/issuesIntegration.d.ts.map +1 -0
- package/dist/plus/integrations/models/issuesIntegration.js +216 -0
- package/dist/plus/integrations/models/issuesIntegration.js.map +1 -0
- package/dist/plus/integrations/providerFilters.d.ts +12 -0
- package/dist/plus/integrations/providerFilters.d.ts.map +1 -0
- package/dist/plus/integrations/providerFilters.js +14 -0
- package/dist/plus/integrations/providerFilters.js.map +1 -0
- package/dist/plus/integrations/providers/apiClients.d.ts +25 -0
- package/dist/plus/integrations/providers/apiClients.d.ts.map +1 -0
- package/dist/plus/integrations/providers/apiClients.js +39 -0
- package/dist/plus/integrations/providers/apiClients.js.map +1 -0
- package/dist/plus/integrations/providers/apiConfig.d.ts +52 -0
- package/dist/plus/integrations/providers/apiConfig.d.ts.map +1 -0
- package/dist/plus/integrations/providers/apiConfig.js +19 -0
- package/dist/plus/integrations/providers/apiConfig.js.map +1 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts +59 -0
- package/dist/plus/integrations/providers/azure/azure.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azure/azure.js +519 -0
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -0
- package/dist/plus/integrations/providers/azure/models.d.ts +302 -0
- package/dist/plus/integrations/providers/azure/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azure/models.js +203 -0
- package/dist/plus/integrations/providers/azure/models.js.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts +141 -0
- package/dist/plus/integrations/providers/azureDevOps.d.ts.map +1 -0
- package/dist/plus/integrations/providers/azureDevOps.js +925 -0
- package/dist/plus/integrations/providers/azureDevOps.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts +53 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +589 -0
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/models.d.ts +222 -0
- package/dist/plus/integrations/providers/bitbucket/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket/models.js +158 -0
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts +138 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.js +130 -0
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts +84 -0
- package/dist/plus/integrations/providers/bitbucket-server.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket-server.js +242 -0
- package/dist/plus/integrations/providers/bitbucket-server.js.map +1 -0
- package/dist/plus/integrations/providers/bitbucket.d.ts +84 -0
- package/dist/plus/integrations/providers/bitbucket.d.ts.map +1 -0
- package/dist/plus/integrations/providers/bitbucket.js +477 -0
- package/dist/plus/integrations/providers/bitbucket.js.map +1 -0
- package/dist/plus/integrations/providers/github/github.d.ts +5 -0
- package/dist/plus/integrations/providers/github/github.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/github.js +47 -0
- package/dist/plus/integrations/providers/github/github.js.map +1 -0
- package/dist/plus/integrations/providers/github/github.utils.d.ts +11 -0
- package/dist/plus/integrations/providers/github/github.utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/github.utils.js +6 -0
- package/dist/plus/integrations/providers/github/github.utils.js.map +1 -0
- package/dist/plus/integrations/providers/github/models.d.ts +3 -0
- package/dist/plus/integrations/providers/github/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github/models.js +2 -0
- package/dist/plus/integrations/providers/github/models.js.map +1 -0
- package/dist/plus/integrations/providers/github.d.ts +116 -0
- package/dist/plus/integrations/providers/github.d.ts.map +1 -0
- package/dist/plus/integrations/providers/github.js +445 -0
- package/dist/plus/integrations/providers/github.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +71 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +902 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +27 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +53 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab/models.d.ts +138 -0
- package/dist/plus/integrations/providers/gitlab/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab/models.js +99 -0
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -0
- package/dist/plus/integrations/providers/gitlab.d.ts +124 -0
- package/dist/plus/integrations/providers/gitlab.d.ts.map +1 -0
- package/dist/plus/integrations/providers/gitlab.js +519 -0
- package/dist/plus/integrations/providers/gitlab.js.map +1 -0
- package/dist/plus/integrations/providers/jira.d.ts +57 -0
- package/dist/plus/integrations/providers/jira.d.ts.map +1 -0
- package/dist/plus/integrations/providers/jira.js +425 -0
- package/dist/plus/integrations/providers/jira.js.map +1 -0
- package/dist/plus/integrations/providers/linear.d.ts +58 -0
- package/dist/plus/integrations/providers/linear.d.ts.map +1 -0
- package/dist/plus/integrations/providers/linear.js +304 -0
- package/dist/plus/integrations/providers/linear.js.map +1 -0
- package/dist/plus/integrations/providers/models.d.ts +712 -0
- package/dist/plus/integrations/providers/models.d.ts.map +1 -0
- package/dist/plus/integrations/providers/models.js +850 -0
- package/dist/plus/integrations/providers/models.js.map +1 -0
- package/dist/plus/integrations/providers/providersApi.d.ts +262 -0
- package/dist/plus/integrations/providers/providersApi.d.ts.map +1 -0
- package/dist/plus/integrations/providers/providersApi.js +1033 -0
- package/dist/plus/integrations/providers/providersApi.js.map +1 -0
- package/dist/plus/integrations/providers/trello.d.ts +47 -0
- package/dist/plus/integrations/providers/trello.d.ts.map +1 -0
- package/dist/plus/integrations/providers/trello.js +141 -0
- package/dist/plus/integrations/providers/trello.js.map +1 -0
- package/dist/plus/integrations/providers/utils/providerPaging.d.ts +29 -0
- package/dist/plus/integrations/providers/utils/providerPaging.d.ts.map +1 -0
- package/dist/plus/integrations/providers/utils/providerPaging.js +154 -0
- package/dist/plus/integrations/providers/utils/providerPaging.js.map +1 -0
- package/dist/plus/integrations/providers/utils.d.ts +75 -0
- package/dist/plus/integrations/providers/utils.d.ts.map +1 -0
- package/dist/plus/integrations/providers/utils.js +313 -0
- package/dist/plus/integrations/providers/utils.js.map +1 -0
- package/dist/plus/integrations/reads/context.d.ts +52 -0
- package/dist/plus/integrations/reads/context.d.ts.map +1 -0
- package/dist/plus/integrations/reads/context.js +2 -0
- package/dist/plus/integrations/reads/context.js.map +1 -0
- package/dist/plus/integrations/reads/cursors.d.ts +66 -0
- package/dist/plus/integrations/reads/cursors.d.ts.map +1 -0
- package/dist/plus/integrations/reads/cursors.js +133 -0
- package/dist/plus/integrations/reads/cursors.js.map +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +60 -0
- package/dist/plus/integrations/reads/drains.d.ts.map +1 -0
- package/dist/plus/integrations/reads/drains.js +255 -0
- package/dist/plus/integrations/reads/drains.js.map +1 -0
- package/dist/plus/integrations/reads/filters.d.ts +81 -0
- package/dist/plus/integrations/reads/filters.d.ts.map +1 -0
- package/dist/plus/integrations/reads/filters.js +87 -0
- package/dist/plus/integrations/reads/filters.js.map +1 -0
- package/dist/plus/integrations/reads/hierarchy.d.ts +17 -0
- package/dist/plus/integrations/reads/hierarchy.d.ts.map +1 -0
- package/dist/plus/integrations/reads/hierarchy.js +348 -0
- package/dist/plus/integrations/reads/hierarchy.js.map +1 -0
- package/dist/plus/integrations/reads/hierarchy.utils.d.ts +53 -0
- package/dist/plus/integrations/reads/hierarchy.utils.d.ts.map +1 -0
- package/dist/plus/integrations/reads/hierarchy.utils.js +85 -0
- package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -0
- package/dist/plus/integrations/reads/issueTracker.d.ts +19 -0
- package/dist/plus/integrations/reads/issueTracker.d.ts.map +1 -0
- package/dist/plus/integrations/reads/issueTracker.js +346 -0
- package/dist/plus/integrations/reads/issueTracker.js.map +1 -0
- package/dist/plus/integrations/reads/issues.d.ts +34 -0
- package/dist/plus/integrations/reads/issues.d.ts.map +1 -0
- package/dist/plus/integrations/reads/issues.js +244 -0
- package/dist/plus/integrations/reads/issues.js.map +1 -0
- package/dist/plus/integrations/reads/paging.d.ts +136 -0
- package/dist/plus/integrations/reads/paging.d.ts.map +1 -0
- package/dist/plus/integrations/reads/paging.js +221 -0
- package/dist/plus/integrations/reads/paging.js.map +1 -0
- package/dist/plus/integrations/reads/pullRequests.d.ts +32 -0
- package/dist/plus/integrations/reads/pullRequests.d.ts.map +1 -0
- package/dist/plus/integrations/reads/pullRequests.js +151 -0
- package/dist/plus/integrations/reads/pullRequests.js.map +1 -0
- package/dist/plus/integrations/reads/warnings.d.ts +47 -0
- package/dist/plus/integrations/reads/warnings.d.ts.map +1 -0
- package/dist/plus/integrations/reads/warnings.js +81 -0
- package/dist/plus/integrations/reads/warnings.js.map +1 -0
- package/dist/plus/integrations/results.d.ts +189 -0
- package/dist/plus/integrations/results.d.ts.map +1 -0
- package/dist/plus/integrations/results.js +62 -0
- package/dist/plus/integrations/results.js.map +1 -0
- package/dist/plus/integrations/telemetry.d.ts +26 -0
- package/dist/plus/integrations/telemetry.d.ts.map +1 -0
- package/dist/plus/integrations/telemetry.js +11 -0
- package/dist/plus/integrations/telemetry.js.map +1 -0
- package/dist/plus/integrations/utils/domain.utils.d.ts +5 -0
- package/dist/plus/integrations/utils/domain.utils.d.ts.map +1 -0
- package/dist/plus/integrations/utils/domain.utils.js +27 -0
- package/dist/plus/integrations/utils/domain.utils.js.map +1 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts +40 -0
- package/dist/plus/integrations/utils/integration.utils.d.ts.map +1 -0
- package/dist/plus/integrations/utils/integration.utils.js +182 -0
- package/dist/plus/integrations/utils/integration.utils.js.map +1 -0
- package/dist/utils/array.d.ts.map +1 -1
- package/dist/utils/array.js.map +1 -1
- package/dist/utils/brand.d.ts.map +1 -1
- package/dist/utils/cancellation.d.ts +13 -0
- package/dist/utils/cancellation.d.ts.map +1 -1
- package/dist/utils/cancellation.js +52 -7
- package/dist/utils/cancellation.js.map +1 -1
- package/dist/utils/charCode.d.ts.map +1 -1
- package/dist/utils/coalescedRun.d.ts +16 -0
- package/dist/utils/coalescedRun.d.ts.map +1 -0
- package/dist/utils/coalescedRun.js +43 -0
- package/dist/utils/coalescedRun.js.map +1 -0
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +3 -3
- package/dist/utils/color.js.map +1 -1
- package/dist/utils/date.d.ts +24 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +62 -0
- package/dist/utils/date.js.map +1 -1
- package/dist/utils/debounce.js +1 -1
- package/dist/utils/debounce.js.map +1 -1
- package/dist/utils/decorators/debounce.d.ts.map +1 -1
- package/dist/utils/decorators/debounce.js.map +1 -1
- package/dist/utils/decorators/gate.d.ts.map +1 -1
- package/dist/utils/decorators/gate.js +2 -2
- package/dist/utils/decorators/gate.js.map +1 -1
- package/dist/utils/decorators/log.d.ts.map +1 -1
- package/dist/utils/decorators/log.js +5 -5
- package/dist/utils/decorators/log.js.map +1 -1
- package/dist/utils/decorators/memoize.d.ts.map +1 -1
- package/dist/utils/decorators/memoize.js +2 -2
- package/dist/utils/decorators/memoize.js.map +1 -1
- package/dist/utils/decorators/resolver.d.ts.map +1 -1
- package/dist/utils/decorators/resolver.js.map +1 -1
- package/dist/utils/decorators/sequentialize.d.ts.map +1 -1
- package/dist/utils/decorators/sequentialize.js +2 -2
- package/dist/utils/decorators/sequentialize.js.map +1 -1
- package/dist/utils/decorators/serializable.d.ts.map +1 -1
- package/dist/utils/decorators/serializable.js +1 -1
- package/dist/utils/decorators/serializable.js.map +1 -1
- package/dist/utils/dedupedAsyncCache.d.ts.map +1 -1
- package/dist/utils/disposable.d.ts +15 -2
- package/dist/utils/disposable.d.ts.map +1 -1
- package/dist/utils/disposable.js.map +1 -1
- package/dist/utils/env/browser/base64.d.ts.map +1 -1
- package/dist/utils/env/browser/base64.js.map +1 -1
- package/dist/utils/env/browser/crypto.d.ts.map +1 -1
- package/dist/utils/env/browser/crypto.js.map +1 -1
- package/dist/utils/env/browser/fs.d.ts.map +1 -1
- package/dist/utils/env/browser/fs.js.map +1 -1
- package/dist/utils/env/browser/hex.d.ts.map +1 -1
- package/dist/utils/env/browser/hex.js.map +1 -1
- package/dist/utils/env/browser/hrtime.d.ts.map +1 -1
- package/dist/utils/env/browser/hrtime.js.map +1 -1
- package/dist/utils/env/browser/logScope.d.ts.map +1 -1
- package/dist/utils/env/browser/logScope.js.map +1 -1
- package/dist/utils/env/browser/md5.d.ts.map +1 -1
- package/dist/utils/env/browser/md5.js.map +1 -1
- package/dist/utils/env/browser/platform.d.ts.map +1 -1
- package/dist/utils/env/browser/platform.js.map +1 -1
- package/dist/utils/env/node/base64.d.ts.map +1 -1
- package/dist/utils/env/node/base64.js.map +1 -1
- package/dist/utils/env/node/crypto.d.ts.map +1 -1
- package/dist/utils/env/node/crypto.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +9 -1
- package/dist/utils/env/node/exec.d.ts.map +1 -1
- package/dist/utils/env/node/exec.js +11 -4
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/env/node/fs.d.ts.map +1 -1
- package/dist/utils/env/node/fs.js.map +1 -1
- package/dist/utils/env/node/hex.d.ts.map +1 -1
- package/dist/utils/env/node/hex.js.map +1 -1
- package/dist/utils/env/node/hrtime.d.ts.map +1 -1
- package/dist/utils/env/node/hrtime.js.map +1 -1
- package/dist/utils/env/node/logScope.d.ts.map +1 -1
- package/dist/utils/env/node/logScope.js.map +1 -1
- package/dist/utils/env/node/platform.d.ts.map +1 -1
- package/dist/utils/env/node/platform.js.map +1 -1
- package/dist/utils/event.d.ts.map +1 -1
- package/dist/utils/event.js +18 -22
- package/dist/utils/event.js.map +1 -1
- package/dist/utils/formatter.d.ts.map +1 -1
- package/dist/utils/formatter.js.map +1 -1
- package/dist/utils/function.d.ts.map +1 -1
- package/dist/utils/function.js +3 -3
- package/dist/utils/function.js.map +1 -1
- package/dist/utils/hash.js.map +1 -1
- package/dist/utils/iterable.d.ts.map +1 -1
- package/dist/utils/iterable.js +2 -6
- package/dist/utils/iterable.js.map +1 -1
- package/dist/utils/lazy.d.ts.map +1 -1
- package/dist/utils/lazy.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/logger.scoped.js +1 -1
- package/dist/utils/logger.scoped.js.map +1 -1
- package/dist/utils/lruMap.d.ts.map +1 -1
- package/dist/utils/lruMap.js.map +1 -1
- package/dist/utils/mru.d.ts.map +1 -1
- package/dist/utils/mru.js.map +1 -1
- package/dist/utils/object.js.map +1 -1
- package/dist/utils/paging.d.ts +29 -0
- package/dist/utils/paging.d.ts.map +1 -1
- package/dist/utils/paging.js +18 -0
- package/dist/utils/paging.js.map +1 -1
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/promise.d.ts +10 -0
- package/dist/utils/promise.d.ts.map +1 -1
- package/dist/utils/promise.js +26 -3
- package/dist/utils/promise.js.map +1 -1
- package/dist/utils/promiseCache.d.ts +12 -2
- package/dist/utils/promiseCache.d.ts.map +1 -1
- package/dist/utils/promiseCache.js +80 -50
- package/dist/utils/promiseCache.js.map +1 -1
- package/dist/utils/searchTree.d.ts.map +1 -1
- package/dist/utils/searchTree.js +4 -1
- package/dist/utils/searchTree.js.map +1 -1
- package/dist/utils/stopwatch.d.ts.map +1 -1
- package/dist/utils/string.js +1 -1
- package/dist/utils/string.js.map +1 -1
- package/dist/utils/subscriptionManager.d.ts.map +1 -1
- package/dist/utils/subscriptionManager.js.map +1 -1
- package/dist/utils/trie.d.ts.map +1 -1
- package/dist/utils/trie.js +1 -0
- package/dist/utils/trie.js.map +1 -1
- package/docs/integrations.md +372 -0
- package/docs/kepler-read-api-parity.md +112 -0
- package/package.json +238 -172
- package/src/git/cache.ts +75 -8
- package/src/git/context.ts +4 -3
- package/src/git/errors.ts +36 -1
- package/src/git/models/commit.ts +1 -1
- package/src/git/models/graph.ts +147 -0
- package/src/git/models/graphSession.ts +205 -0
- package/src/git/models/issue.ts +12 -1
- package/src/git/models/pullRequest.ts +27 -1
- package/src/git/models/repository.ts +24 -1
- package/src/git/models/resourceDescriptor.ts +17 -0
- package/src/git/models/signature.ts +16 -0
- package/src/git/models/tag.ts +6 -1
- package/src/git/parsers/diffParser.ts +1 -1
- package/src/git/providers/branches.ts +6 -1
- package/src/git/providers/commits.ts +6 -1
- package/src/git/providers/config.ts +5 -1
- package/src/git/providers/graph.ts +69 -2
- package/src/git/providers/operations.ts +1 -1
- package/src/git/providers/status.ts +1 -1
- package/src/git/providers/worktrees.ts +17 -3
- package/src/git/remotes/azure-devops.ts +29 -33
- package/src/git/remotes/bitbucket-server.ts +23 -25
- package/src/git/remotes/bitbucket.ts +23 -25
- package/src/git/remotes/gerrit.ts +12 -14
- package/src/git/remotes/gitea.ts +13 -15
- package/src/git/remotes/github.ts +56 -58
- package/src/git/remotes/gitlab.ts +102 -104
- package/src/git/run.types.ts +54 -4
- package/src/git/utils/branch.utils.ts +12 -1
- package/src/git/utils/conflictResolution.utils.ts +126 -0
- package/src/git/utils/contributor.utils.ts +1 -1
- package/src/git/utils/fileStatus.utils.ts +7 -0
- package/src/git/utils/graph.utils.ts +46 -0
- package/src/git/utils/issue.utils.ts +1 -0
- package/src/git/utils/pullRequest.utils.ts +9 -0
- package/src/git/utils/reachability.utils.ts +79 -8
- package/src/git/utils/sshKey.utils.ts +30 -0
- package/src/git/watching/watchService.ts +16 -1
- package/src/git/watching/watchSession.ts +20 -2
- package/src/git-cli/exec/git.ts +144 -42
- package/src/git-cli/parsers/logParser.ts +83 -1
- package/src/git-cli/parsers/sshSignatureParser.ts +85 -0
- package/src/git-cli/parsers/worktreeParser.ts +5 -7
- package/src/git-cli/providers/branches.ts +60 -38
- package/src/git-cli/providers/commits.ts +102 -9
- package/src/git-cli/providers/graph.ts +1771 -393
- package/src/git-cli/providers/operations.ts +22 -2
- package/src/git-cli/providers/pausedOperations.ts +3 -3
- package/src/git-cli/providers/revision.ts +42 -0
- package/src/git-cli/providers/status.ts +333 -178
- package/src/git-cli/providers/tags.ts +2 -0
- package/src/git-cli/providers/worktrees.ts +57 -6
- package/src/git-cli/service.ts +9 -0
- package/src/ipc/ipcServer.ts +1 -1
- package/src/plus/agents/providers/claudeCodeProvider.ts +25 -0
- package/src/plus/agents/providers/claudeCodeTranscript.ts +320 -8
- package/src/plus/agents/types.ts +34 -0
- package/src/plus/ai/constants.ts +1 -9
- package/src/plus/ai/models/model.ts +53 -2
- package/src/plus/ai/models/promptTemplates.ts +9 -2
- package/src/plus/ai/prompts.ts +16 -48
- package/src/plus/ai/providers/anthropicProvider.ts +45 -3
- package/src/plus/ai/providers/deepSeekProvider.ts +17 -1
- package/src/plus/ai/providers/geminiProvider.ts +25 -6
- package/src/plus/ai/providers/gitkrakenProvider.ts +2 -0
- package/src/plus/ai/providers/huggingFaceProvider.ts +28 -21
- package/src/plus/ai/providers/openAICompatibleProviderBase.ts +16 -1
- package/src/plus/ai/providers/xaiProvider.ts +14 -1
- package/src/plus/ai/utils/ai.utils.ts +5 -7
- package/src/plus/ai/utils/results.utils.ts +32 -0
- package/src/plus/ai/utils/truncation.utils.ts +0 -1
- package/src/plus/git-github/api/github.ts +497 -129
- package/src/plus/git-github/models.ts +33 -0
- package/src/plus/git-github/providers/github/branches.ts +6 -3
- package/src/plus/git-github/providers/github/diff.ts +1 -1
- package/src/plus/git-github/providers/github/graph.ts +131 -0
- package/src/plus/git-github/providers/github/tags.ts +2 -0
- package/src/plus/integrations/authentication/cloudIntegrationService.ts +292 -0
- package/src/plus/integrations/authentication/configuredIntegrationService.ts +651 -0
- package/src/plus/integrations/authentication/integrationAuthenticationProvider.ts +363 -0
- package/src/plus/integrations/authentication/integrationAuthenticationService.ts +148 -0
- package/src/plus/integrations/authentication/manualTokenProvider.ts +79 -0
- package/src/plus/integrations/authentication/models.ts +202 -0
- package/src/plus/integrations/collectionMetadata.ts +143 -0
- package/src/plus/integrations/constants.ts +190 -0
- package/src/plus/integrations/context.ts +382 -0
- package/src/plus/integrations/errors.ts +184 -0
- package/src/plus/integrations/index.ts +216 -0
- package/src/plus/integrations/integrationService.ts +2589 -0
- package/src/plus/integrations/lite.ts +233 -0
- package/src/plus/integrations/manager.ts +359 -0
- package/src/plus/integrations/models/gitHostIntegration.ts +1631 -0
- package/src/plus/integrations/models/integration.ts +926 -0
- package/src/plus/integrations/models/issuesIntegration.ts +264 -0
- package/src/plus/integrations/providerFilters.ts +12 -0
- package/src/plus/integrations/providers/apiClients.ts +69 -0
- package/src/plus/integrations/providers/apiConfig.ts +71 -0
- package/src/plus/integrations/providers/azure/azure.ts +822 -0
- package/src/plus/integrations/providers/azure/models.ts +618 -0
- package/src/plus/integrations/providers/azureDevOps.ts +1342 -0
- package/src/plus/integrations/providers/bitbucket/bitbucket.ts +904 -0
- package/src/plus/integrations/providers/bitbucket/models.ts +445 -0
- package/src/plus/integrations/providers/bitbucket-server/models.ts +283 -0
- package/src/plus/integrations/providers/bitbucket-server.ts +447 -0
- package/src/plus/integrations/providers/bitbucket.ts +794 -0
- package/src/plus/integrations/providers/github/github.ts +64 -0
- package/src/plus/integrations/providers/github/github.utils.ts +23 -0
- package/src/plus/integrations/providers/github/models.ts +29 -0
- package/src/plus/integrations/providers/github.ts +750 -0
- package/src/plus/integrations/providers/gitlab/gitlab.ts +1320 -0
- package/src/plus/integrations/providers/gitlab/gitlab.utils.ts +80 -0
- package/src/plus/integrations/providers/gitlab/models.ts +271 -0
- package/src/plus/integrations/providers/gitlab.ts +832 -0
- package/src/plus/integrations/providers/jira.ts +564 -0
- package/src/plus/integrations/providers/linear.ts +402 -0
- package/src/plus/integrations/providers/models.ts +1622 -0
- package/src/plus/integrations/providers/providersApi.ts +1889 -0
- package/src/plus/integrations/providers/trello.ts +205 -0
- package/src/plus/integrations/providers/utils/providerPaging.ts +177 -0
- package/src/plus/integrations/providers/utils.ts +419 -0
- package/src/plus/integrations/reads/context.ts +75 -0
- package/src/plus/integrations/reads/cursors.ts +224 -0
- package/src/plus/integrations/reads/drains.ts +343 -0
- package/src/plus/integrations/reads/filters.ts +124 -0
- package/src/plus/integrations/reads/hierarchy.ts +493 -0
- package/src/plus/integrations/reads/hierarchy.utils.ts +106 -0
- package/src/plus/integrations/reads/issueTracker.ts +480 -0
- package/src/plus/integrations/reads/issues.ts +407 -0
- package/src/plus/integrations/reads/paging.ts +277 -0
- package/src/plus/integrations/reads/pullRequests.ts +267 -0
- package/src/plus/integrations/reads/warnings.ts +170 -0
- package/src/plus/integrations/results.ts +275 -0
- package/src/plus/integrations/telemetry.ts +29 -0
- package/src/plus/integrations/utils/domain.utils.ts +26 -0
- package/src/plus/integrations/utils/integration.utils.ts +215 -0
- package/src/utils/brand.ts +0 -2
- package/src/utils/cancellation.ts +56 -7
- package/src/utils/coalescedRun.ts +45 -0
- package/src/utils/color.ts +3 -3
- package/src/utils/date.ts +72 -0
- package/src/utils/debounce.ts +1 -1
- package/src/utils/decorators/gate.ts +2 -2
- package/src/utils/decorators/log.ts +5 -5
- package/src/utils/decorators/memoize.ts +2 -2
- package/src/utils/decorators/sequentialize.ts +2 -2
- package/src/utils/decorators/serializable.ts +1 -1
- package/src/utils/disposable.ts +15 -2
- package/src/utils/env/node/exec.ts +20 -5
- package/src/utils/event.ts +19 -25
- package/src/utils/function.ts +3 -3
- package/src/utils/iterable.ts +2 -6
- package/src/utils/logger.scoped.ts +1 -1
- package/src/utils/logger.ts +1 -1
- package/src/utils/paging.ts +46 -0
- package/src/utils/promise.ts +33 -3
- package/src/utils/promiseCache.ts +81 -51
- package/src/utils/searchTree.ts +4 -2
- package/src/utils/string.ts +1 -1
- package/src/utils/trie.ts +1 -0
- package/dist/plus/ai/providers/githubModelsProvider.d.ts +0 -19
- package/dist/plus/ai/providers/githubModelsProvider.d.ts.map +0 -1
- package/dist/plus/ai/providers/githubModelsProvider.js +0 -51
- package/dist/plus/ai/providers/githubModelsProvider.js.map +0 -1
- package/src/plus/ai/providers/githubModelsProvider.ts +0 -92
|
@@ -0,0 +1,1889 @@
|
|
|
1
|
+
import ProviderApis from '@gitkraken/provider-apis';
|
|
2
|
+
import type {
|
|
3
|
+
CollectionMetadata,
|
|
4
|
+
GitPullRequestState,
|
|
5
|
+
GraphQLError,
|
|
6
|
+
GraphQLErrors,
|
|
7
|
+
TrelloBoard,
|
|
8
|
+
TrelloList,
|
|
9
|
+
} from '@gitkraken/provider-apis';
|
|
10
|
+
import type { PullRequest, PullRequestMergeMethod } from '../../../git/models/pullRequest.js';
|
|
11
|
+
import { base64 } from '../../../utils/base64.js';
|
|
12
|
+
import type { PagedResult } from '../../../utils/paging.js';
|
|
13
|
+
import type { IntegrationAuthenticationService } from '../authentication/integrationAuthenticationService.js';
|
|
14
|
+
import type { TokenOptInfo, TokenWithInfo } from '../authentication/models.js';
|
|
15
|
+
import { toTokenWithInfo } from '../authentication/models.js';
|
|
16
|
+
import type { IntegrationIds } from '../constants.js';
|
|
17
|
+
import {
|
|
18
|
+
GitCloudHostIntegrationId,
|
|
19
|
+
GitSelfManagedHostIntegrationId,
|
|
20
|
+
IssuesCloudHostIntegrationId,
|
|
21
|
+
} from '../constants.js';
|
|
22
|
+
import {
|
|
23
|
+
AuthenticationError,
|
|
24
|
+
AuthenticationErrorReason,
|
|
25
|
+
isRateLimitResponse,
|
|
26
|
+
RequestClientError,
|
|
27
|
+
RequestNotFoundError,
|
|
28
|
+
toError,
|
|
29
|
+
toRateLimitError,
|
|
30
|
+
} from '../errors.js';
|
|
31
|
+
import type {
|
|
32
|
+
GetIssueFn,
|
|
33
|
+
GetIssuesForReposFn,
|
|
34
|
+
GetIssuesOptions,
|
|
35
|
+
GetPullRequestsForRepoFn,
|
|
36
|
+
GetPullRequestsForReposFn,
|
|
37
|
+
GetPullRequestsForUserFn,
|
|
38
|
+
GetPullRequestsForUserOptions,
|
|
39
|
+
GetPullRequestsOptions,
|
|
40
|
+
GetReposOptions,
|
|
41
|
+
IssueFilter,
|
|
42
|
+
PageInfo,
|
|
43
|
+
PagingInput,
|
|
44
|
+
PagingMode,
|
|
45
|
+
ProviderAccount,
|
|
46
|
+
ProviderApiCollectionResult,
|
|
47
|
+
ProviderApiPagedResult,
|
|
48
|
+
ProviderAzureProject,
|
|
49
|
+
ProviderAzureResource,
|
|
50
|
+
ProviderBitbucketResource,
|
|
51
|
+
ProviderGitHubOrganization,
|
|
52
|
+
ProviderGitLabGroup,
|
|
53
|
+
ProviderHierarchyResult,
|
|
54
|
+
ProviderInfo,
|
|
55
|
+
ProviderIssue,
|
|
56
|
+
ProviderJiraProject,
|
|
57
|
+
ProviderJiraResource,
|
|
58
|
+
ProviderLinearOrganization,
|
|
59
|
+
ProviderLinearTeam,
|
|
60
|
+
ProviderPullRequest,
|
|
61
|
+
ProviderRepoInput,
|
|
62
|
+
ProviderReposInput,
|
|
63
|
+
ProviderRepository,
|
|
64
|
+
ProviderRequestFunction,
|
|
65
|
+
ProviderRequestOptions,
|
|
66
|
+
ProviderRequestResponse,
|
|
67
|
+
Providers,
|
|
68
|
+
PullRequestFilter,
|
|
69
|
+
} from './models.js';
|
|
70
|
+
import { providersMetadata } from './models.js';
|
|
71
|
+
import {
|
|
72
|
+
collectProviderPagedResult,
|
|
73
|
+
mergeCollectionMetadata,
|
|
74
|
+
parsePageCursor,
|
|
75
|
+
toPageCursor,
|
|
76
|
+
} from './utils/providerPaging.js';
|
|
77
|
+
|
|
78
|
+
// `@gitkraken/provider-apis` is published as CommonJS with its factory on the `default` export.
|
|
79
|
+
// How that surfaces depends on the consuming bundler's CJS->ESM interop: esbuild yields the
|
|
80
|
+
// callable factory directly, while webpack and Node surface the module namespace (with the
|
|
81
|
+
// factory under `.default`). Normalize to the callable factory so every consumer resolves it.
|
|
82
|
+
type ProviderApisFactory = typeof ProviderApis;
|
|
83
|
+
const createProviderApis: ProviderApisFactory =
|
|
84
|
+
(ProviderApis as ProviderApisFactory & { default?: ProviderApisFactory }).default ?? ProviderApis;
|
|
85
|
+
|
|
86
|
+
// Both GitHub and GitLab `getRepo` throw a missing-repo error whose message is exactly
|
|
87
|
+
// `Repository <x> not found`. Anchoring to that shape (rather than a loose `not found` substring) keeps
|
|
88
|
+
// the message fallbacks from misclassifying unrelated GraphQL/transport failures as a confident negative.
|
|
89
|
+
const repoNotFoundMessage = /^Repository .+ not found$/i;
|
|
90
|
+
|
|
91
|
+
// Duck-typed rather than `ex instanceof GraphQLErrors`, because importing the class as a value makes this
|
|
92
|
+
// module unloadable from plain Node ESM consumers: `@gitkraken/provider-apis` is CommonJS and declares its
|
|
93
|
+
// exports through getters, which Node's `cjs-module-lexer` cannot see, so the only named exports it can
|
|
94
|
+
// synthesize are `default` and `module.exports`. Bundled hosts (webpack/esbuild) bind the named export
|
|
95
|
+
// fine, but the published package keeps third-party deps external, so the named import survives into
|
|
96
|
+
// consumers and breaks linking there. The SDK's constructor always assigns `graphQLErrors` (defaulting to
|
|
97
|
+
// `[]`) and it is the only SDK error carrying that field, so the shape check is unambiguous.
|
|
98
|
+
function isGraphQLErrors(ex: unknown): ex is GraphQLErrors {
|
|
99
|
+
return ex instanceof Error && Array.isArray((ex as Partial<GraphQLErrors>).graphQLErrors);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// `handleProviderError` classifies not-found by HTTP status (404/410/422), which only works for the
|
|
103
|
+
// REST `getRepo` clients (Bitbucket, Bitbucket Server, Azure DevOps). GitHub and GitLab `getRepo` are
|
|
104
|
+
// GraphQL: a missing repo comes back as HTTP 200 with a null node, and the SDK throws an unclassified
|
|
105
|
+
// error with no `response.status`, so it would otherwise fall through to the generic error bucket. This
|
|
106
|
+
// detects the SDK's not-found shapes so `getRepo` can rethrow them as `RequestNotFoundError`, keeping the
|
|
107
|
+
// facade's by-type mapping intact.
|
|
108
|
+
function isGraphQLRepoNotFoundError(ex: unknown): boolean {
|
|
109
|
+
// GitHub throws `GraphQLErrors`. The SDK reports the null repository node with the same
|
|
110
|
+
// `Repository <x> not found` message regardless of the underlying cause, so a `FORBIDDEN` or
|
|
111
|
+
// `RATE_LIMITED` GraphQL error would also surface with that message. Trust the structured error type
|
|
112
|
+
// when entries are present (only `NOT_FOUND` is a real not-found), and fall back to the repo-specific
|
|
113
|
+
// message only when there are no entries to disambiguate (a bare null node).
|
|
114
|
+
if (isGraphQLErrors(ex)) {
|
|
115
|
+
const errors = ex.graphQLErrors;
|
|
116
|
+
// Scope NOT_FOUND to the `repository` field: `getRepo`'s query only selects that node today, but
|
|
117
|
+
// were it to grow other selections that can emit NOT_FOUND, an unscoped check would misclassify
|
|
118
|
+
// them. Tolerate a missing `path` so we degrade to the current behavior if the SDK stops populating
|
|
119
|
+
// it, rather than silently regressing to `error`.
|
|
120
|
+
if (errors?.length) {
|
|
121
|
+
return errors.some(
|
|
122
|
+
(e: GraphQLError) => e.type === 'NOT_FOUND' && (e.path == null || e.path.includes('repository')),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
return repoNotFoundMessage.test(ex.message);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// GitLab's `getRepo` throws a plain Error; match its not-found message specifically so unrelated
|
|
129
|
+
// bare Errors (network/parse failures) still reach the generic error bucket.
|
|
130
|
+
return ex instanceof Error && repoNotFoundMessage.test(ex.message);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const trelloBaseUrl = 'https://api.trello.com';
|
|
134
|
+
|
|
135
|
+
type TrelloMemberResponse = {
|
|
136
|
+
id: string;
|
|
137
|
+
username?: string | null;
|
|
138
|
+
fullName?: string | null;
|
|
139
|
+
avatarHash?: string | null;
|
|
140
|
+
avatarUrl?: string | null;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
type TrelloCardResponse = {
|
|
144
|
+
id: string;
|
|
145
|
+
idShort: number;
|
|
146
|
+
name: string;
|
|
147
|
+
url: string;
|
|
148
|
+
dateLastActivity: string;
|
|
149
|
+
idList?: string | null;
|
|
150
|
+
badges?: {
|
|
151
|
+
comments?: number | null;
|
|
152
|
+
votes?: number | null;
|
|
153
|
+
};
|
|
154
|
+
members?: TrelloMemberResponse[];
|
|
155
|
+
labels?: Array<{ color: string | null; id: string; name: string }>;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
function getTrelloAuthHeaders(appKey: string, token: string): Record<string, string> {
|
|
159
|
+
return {
|
|
160
|
+
Authorization: `OAuth oauth_consumer_key="${appKey}", oauth_token="${token}"`,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function getTrelloMemberAvatarUrl(member: TrelloMemberResponse): string | null {
|
|
165
|
+
if (member.avatarUrl != null) return member.avatarUrl;
|
|
166
|
+
if (member.avatarHash == null) return null;
|
|
167
|
+
|
|
168
|
+
return `https://trello-members.s3.amazonaws.com/${member.id}/${member.avatarHash}/50.png`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function fromTrelloCard(
|
|
172
|
+
card: TrelloCardResponse,
|
|
173
|
+
trelloBoardListsById: Record<string, { name: string }>,
|
|
174
|
+
): ProviderIssue {
|
|
175
|
+
const createdDate = new Date(1000 * parseInt(card.id.substring(0, 8), 16));
|
|
176
|
+
const list = card.idList != null ? trelloBoardListsById[card.idList] : undefined;
|
|
177
|
+
|
|
178
|
+
return {
|
|
179
|
+
id: card.id,
|
|
180
|
+
commentCount: card.badges?.comments ?? null,
|
|
181
|
+
number: String(card.idShort),
|
|
182
|
+
title: card.name,
|
|
183
|
+
url: card.url,
|
|
184
|
+
closedDate: null,
|
|
185
|
+
createdDate: new Date(createdDate.toISOString()),
|
|
186
|
+
author: null,
|
|
187
|
+
updatedDate: new Date(card.dateLastActivity),
|
|
188
|
+
assignees: (card.members ?? []).map(member => ({
|
|
189
|
+
id: member.id,
|
|
190
|
+
username: member.username ?? null,
|
|
191
|
+
name: member.fullName ?? null,
|
|
192
|
+
email: null,
|
|
193
|
+
avatarUrl: getTrelloMemberAvatarUrl(member),
|
|
194
|
+
url: null,
|
|
195
|
+
})),
|
|
196
|
+
description: null,
|
|
197
|
+
state: list != null ? { id: card.idList!, name: list.name, color: null } : null,
|
|
198
|
+
type: null,
|
|
199
|
+
repository: null,
|
|
200
|
+
upvoteCount: card.badges?.votes ?? null,
|
|
201
|
+
labels: (card.labels ?? []).map(label => ({
|
|
202
|
+
color: label.color,
|
|
203
|
+
description: null,
|
|
204
|
+
id: label.id,
|
|
205
|
+
name: label.name,
|
|
206
|
+
})),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export class ProvidersApi {
|
|
211
|
+
private readonly providers: Providers;
|
|
212
|
+
private readonly request: ProviderRequestFunction;
|
|
213
|
+
|
|
214
|
+
constructor(private readonly authenticationService: IntegrationAuthenticationService) {
|
|
215
|
+
const http = authenticationService.ctx.http;
|
|
216
|
+
const userAgent = http.userAgent;
|
|
217
|
+
const customFetch: ProviderRequestFunction = async <T>({
|
|
218
|
+
url,
|
|
219
|
+
...options
|
|
220
|
+
}: ProviderRequestOptions): Promise<ProviderRequestResponse<T>> => {
|
|
221
|
+
const response = await http.fetch(url, {
|
|
222
|
+
...options,
|
|
223
|
+
headers: {
|
|
224
|
+
'User-Agent': userAgent,
|
|
225
|
+
...options.headers,
|
|
226
|
+
},
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
return parseFetchResponseForApi<T>(response);
|
|
230
|
+
};
|
|
231
|
+
this.request = customFetch;
|
|
232
|
+
const providerApis = createProviderApis({ request: customFetch });
|
|
233
|
+
this.providers = {
|
|
234
|
+
[GitCloudHostIntegrationId.GitHub]: {
|
|
235
|
+
...providersMetadata[GitCloudHostIntegrationId.GitHub],
|
|
236
|
+
provider: providerApis.github,
|
|
237
|
+
getRepoFn: providerApis.github.getRepo.bind(providerApis.github),
|
|
238
|
+
getCurrentUserFn: providerApis.github.getCurrentUser.bind(providerApis.github),
|
|
239
|
+
getPullRequestsForReposFn: providerApis.github.getPullRequestsForRepos.bind(
|
|
240
|
+
providerApis.github,
|
|
241
|
+
) as GetPullRequestsForReposFn,
|
|
242
|
+
getPullRequestsForUserFn: providerApis.github.getPullRequestsAssociatedWithUser.bind(
|
|
243
|
+
providerApis.github,
|
|
244
|
+
) as GetPullRequestsForUserFn,
|
|
245
|
+
getIssuesForReposFn: providerApis.github.getIssuesForRepos.bind(
|
|
246
|
+
providerApis.github,
|
|
247
|
+
) as GetIssuesForReposFn,
|
|
248
|
+
getOrgsForCurrentUserFn: providerApis.github.getOrgsForCurrentUser.bind(providerApis.github),
|
|
249
|
+
getReposForOrgFn: providerApis.github.getReposForOrg.bind(providerApis.github),
|
|
250
|
+
getReposForCurrentUserFn: providerApis.github.getReposForCurrentUser.bind(providerApis.github),
|
|
251
|
+
},
|
|
252
|
+
[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise]: {
|
|
253
|
+
...providersMetadata[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise],
|
|
254
|
+
provider: providerApis.github,
|
|
255
|
+
getRepoFn: providerApis.github.getRepo.bind(providerApis.github),
|
|
256
|
+
getCurrentUserFn: providerApis.github.getCurrentUser.bind(providerApis.github),
|
|
257
|
+
getPullRequestsForReposFn: providerApis.github.getPullRequestsForRepos.bind(
|
|
258
|
+
providerApis.github,
|
|
259
|
+
) as GetPullRequestsForReposFn,
|
|
260
|
+
getPullRequestsForUserFn: providerApis.github.getPullRequestsAssociatedWithUser.bind(
|
|
261
|
+
providerApis.github,
|
|
262
|
+
) as GetPullRequestsForUserFn,
|
|
263
|
+
getIssuesForReposFn: providerApis.github.getIssuesForRepos.bind(
|
|
264
|
+
providerApis.github,
|
|
265
|
+
) as GetIssuesForReposFn,
|
|
266
|
+
getOrgsForCurrentUserFn: providerApis.github.getOrgsForCurrentUser.bind(providerApis.github),
|
|
267
|
+
getReposForOrgFn: providerApis.github.getReposForOrg.bind(providerApis.github),
|
|
268
|
+
getReposForCurrentUserFn: providerApis.github.getReposForCurrentUser.bind(providerApis.github),
|
|
269
|
+
},
|
|
270
|
+
[GitCloudHostIntegrationId.GitLab]: {
|
|
271
|
+
...providersMetadata[GitCloudHostIntegrationId.GitLab],
|
|
272
|
+
provider: providerApis.gitlab,
|
|
273
|
+
getRepoFn: providerApis.gitlab.getRepo.bind(providerApis.gitlab),
|
|
274
|
+
getCurrentUserFn: providerApis.gitlab.getCurrentUser.bind(providerApis.gitlab),
|
|
275
|
+
getPullRequestsForReposFn: providerApis.gitlab.getPullRequestsForRepos.bind(
|
|
276
|
+
providerApis.gitlab,
|
|
277
|
+
) as GetPullRequestsForReposFn,
|
|
278
|
+
getPullRequestsForRepoFn: providerApis.gitlab.getPullRequestsForRepo.bind(
|
|
279
|
+
providerApis.gitlab,
|
|
280
|
+
) as GetPullRequestsForRepoFn,
|
|
281
|
+
getPullRequestsForUserFn: providerApis.gitlab.getPullRequestsAssociatedWithUser.bind(
|
|
282
|
+
providerApis.gitlab,
|
|
283
|
+
) as GetPullRequestsForUserFn,
|
|
284
|
+
getGitLabPullRequestsForUserAssociationFn: providerApis.gitlab.getPullRequestsForUser.bind(
|
|
285
|
+
providerApis.gitlab,
|
|
286
|
+
),
|
|
287
|
+
getIssueFn: providerApis.gitlab.getIssue.bind(providerApis.gitlab) as GetIssueFn,
|
|
288
|
+
getIssuesForReposFn: providerApis.gitlab.getIssuesForRepos.bind(
|
|
289
|
+
providerApis.gitlab,
|
|
290
|
+
) as GetIssuesForReposFn,
|
|
291
|
+
getIssuesForRepoFn: providerApis.gitlab.getIssuesForRepo.bind(providerApis.gitlab),
|
|
292
|
+
getIssuesForCurrentUserFn: providerApis.gitlab.getIssuesForCurrentUser.bind(providerApis.gitlab),
|
|
293
|
+
mergePullRequestFn: providerApis.gitlab.mergePullRequest.bind(providerApis.gitlab),
|
|
294
|
+
getGroupsForCurrentUserFn: providerApis.gitlab.getGroupsForCurrentUser.bind(providerApis.gitlab),
|
|
295
|
+
getReposForCurrentUserFn: providerApis.gitlab.getReposForCurrentUser.bind(providerApis.gitlab),
|
|
296
|
+
},
|
|
297
|
+
[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted]: {
|
|
298
|
+
...providersMetadata[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted],
|
|
299
|
+
provider: providerApis.gitlab,
|
|
300
|
+
getRepoFn: providerApis.gitlab.getRepo.bind(providerApis.gitlab),
|
|
301
|
+
getCurrentUserFn: providerApis.gitlab.getCurrentUser.bind(providerApis.gitlab),
|
|
302
|
+
getPullRequestsForReposFn: providerApis.gitlab.getPullRequestsForRepos.bind(
|
|
303
|
+
providerApis.gitlab,
|
|
304
|
+
) as GetPullRequestsForReposFn,
|
|
305
|
+
getPullRequestsForRepoFn: providerApis.gitlab.getPullRequestsForRepo.bind(
|
|
306
|
+
providerApis.gitlab,
|
|
307
|
+
) as GetPullRequestsForRepoFn,
|
|
308
|
+
getPullRequestsForUserFn: providerApis.gitlab.getPullRequestsAssociatedWithUser.bind(
|
|
309
|
+
providerApis.gitlab,
|
|
310
|
+
) as GetPullRequestsForUserFn,
|
|
311
|
+
getGitLabPullRequestsForUserAssociationFn: providerApis.gitlab.getPullRequestsForUser.bind(
|
|
312
|
+
providerApis.gitlab,
|
|
313
|
+
),
|
|
314
|
+
getIssueFn: providerApis.gitlab.getIssue.bind(providerApis.gitlab) as GetIssueFn,
|
|
315
|
+
getIssuesForReposFn: providerApis.gitlab.getIssuesForRepos.bind(
|
|
316
|
+
providerApis.gitlab,
|
|
317
|
+
) as GetIssuesForReposFn,
|
|
318
|
+
getIssuesForRepoFn: providerApis.gitlab.getIssuesForRepo.bind(providerApis.gitlab),
|
|
319
|
+
getIssuesForCurrentUserFn: providerApis.gitlab.getIssuesForCurrentUser.bind(providerApis.gitlab),
|
|
320
|
+
mergePullRequestFn: providerApis.gitlab.mergePullRequest.bind(providerApis.gitlab),
|
|
321
|
+
getGroupsForCurrentUserFn: providerApis.gitlab.getGroupsForCurrentUser.bind(providerApis.gitlab),
|
|
322
|
+
getReposForCurrentUserFn: providerApis.gitlab.getReposForCurrentUser.bind(providerApis.gitlab),
|
|
323
|
+
},
|
|
324
|
+
[GitCloudHostIntegrationId.Bitbucket]: {
|
|
325
|
+
...providersMetadata[GitCloudHostIntegrationId.Bitbucket],
|
|
326
|
+
provider: providerApis.bitbucket,
|
|
327
|
+
getRepoFn: providerApis.bitbucket.getRepo.bind(providerApis.bitbucket),
|
|
328
|
+
getCurrentUserFn: providerApis.bitbucket.getCurrentUser.bind(providerApis.bitbucket),
|
|
329
|
+
getBitbucketResourcesForCurrentUserFn: providerApis.bitbucket.getWorkspacesForCurrentUser.bind(
|
|
330
|
+
providerApis.bitbucket,
|
|
331
|
+
),
|
|
332
|
+
getBitbucketPullRequestsAuthoredByUserForWorkspaceFn:
|
|
333
|
+
providerApis.bitbucket.getPullRequestsForUserAndWorkspace.bind(providerApis.bitbucket),
|
|
334
|
+
getPullRequestsForReposFn: providerApis.bitbucket.getPullRequestsForRepos.bind(
|
|
335
|
+
providerApis.bitbucket,
|
|
336
|
+
) as GetPullRequestsForReposFn,
|
|
337
|
+
getPullRequestsForRepoFn: providerApis.bitbucket.getPullRequestsForRepo.bind(providerApis.bitbucket),
|
|
338
|
+
mergePullRequestFn: providerApis.bitbucket.mergePullRequest.bind(providerApis.bitbucket),
|
|
339
|
+
getReposForWorkspaceFn: providerApis.bitbucket.getReposForWorkspace.bind(providerApis.bitbucket),
|
|
340
|
+
},
|
|
341
|
+
[GitSelfManagedHostIntegrationId.BitbucketServer]: {
|
|
342
|
+
...providersMetadata[GitSelfManagedHostIntegrationId.BitbucketServer],
|
|
343
|
+
provider: providerApis.bitbucketServer,
|
|
344
|
+
getRepoFn: providerApis.bitbucketServer.getRepo.bind(providerApis.bitbucketServer),
|
|
345
|
+
getCurrentUserFn: providerApis.bitbucketServer.getCurrentUser.bind(providerApis.bitbucketServer),
|
|
346
|
+
getBitbucketServerPullRequestsForCurrentUserFn:
|
|
347
|
+
providerApis.bitbucketServer.getPullRequestsForCurrentUser.bind(providerApis.bitbucketServer),
|
|
348
|
+
getPullRequestsForReposFn: providerApis.bitbucketServer.getPullRequestsForRepos.bind(
|
|
349
|
+
providerApis.bitbucketServer,
|
|
350
|
+
) as GetPullRequestsForReposFn,
|
|
351
|
+
getPullRequestsForRepoFn: providerApis.bitbucketServer.getPullRequestsForRepo.bind(
|
|
352
|
+
providerApis.bitbucketServer,
|
|
353
|
+
),
|
|
354
|
+
mergePullRequestFn: providerApis.bitbucketServer.mergePullRequest.bind(providerApis.bitbucketServer),
|
|
355
|
+
},
|
|
356
|
+
[GitCloudHostIntegrationId.AzureDevOps]: {
|
|
357
|
+
...providersMetadata[GitCloudHostIntegrationId.AzureDevOps],
|
|
358
|
+
provider: providerApis.azureDevOps,
|
|
359
|
+
getRepoOfProjectFn: providerApis.azureDevOps.getRepo.bind(providerApis.azureDevOps),
|
|
360
|
+
getCurrentUserFn: providerApis.azureDevOps.getCurrentUser.bind(providerApis.azureDevOps),
|
|
361
|
+
getCurrentUserForInstanceFn: providerApis.azureDevOps.getCurrentUserForInstance.bind(
|
|
362
|
+
providerApis.azureDevOps,
|
|
363
|
+
),
|
|
364
|
+
getAzureResourcesForUserFn: providerApis.azureDevOps.getOrgsForUser.bind(providerApis.azureDevOps),
|
|
365
|
+
getAzureProjectsForResourceFn: providerApis.azureDevOps.getAzureProjects.bind(providerApis.azureDevOps),
|
|
366
|
+
getPullRequestsForReposFn: providerApis.azureDevOps.getPullRequestsForRepos.bind(
|
|
367
|
+
providerApis.azureDevOps,
|
|
368
|
+
) as GetPullRequestsForReposFn,
|
|
369
|
+
getPullRequestsForRepoFn: providerApis.azureDevOps.getPullRequestsForRepo.bind(
|
|
370
|
+
providerApis.azureDevOps,
|
|
371
|
+
),
|
|
372
|
+
getPullRequestsForAzureProjectsFn: providerApis.azureDevOps.getPullRequestsForProjects.bind(
|
|
373
|
+
providerApis.azureDevOps,
|
|
374
|
+
),
|
|
375
|
+
getPullRequestsForAzureProjectFn: providerApis.azureDevOps.getPullRequestsForProject.bind(
|
|
376
|
+
providerApis.azureDevOps,
|
|
377
|
+
),
|
|
378
|
+
getIssuesForAzureProjectFn: providerApis.azureDevOps.getIssuesForAzureProject.bind(
|
|
379
|
+
providerApis.azureDevOps,
|
|
380
|
+
),
|
|
381
|
+
getReposForAzureProjectFn: providerApis.azureDevOps.getReposForAzureProject.bind(
|
|
382
|
+
providerApis.azureDevOps,
|
|
383
|
+
),
|
|
384
|
+
mergePullRequestFn: providerApis.azureDevOps.mergePullRequest.bind(providerApis.azureDevOps),
|
|
385
|
+
},
|
|
386
|
+
[GitSelfManagedHostIntegrationId.AzureDevOpsServer]: {
|
|
387
|
+
...providersMetadata[GitSelfManagedHostIntegrationId.AzureDevOpsServer],
|
|
388
|
+
provider: providerApis.azureDevOps,
|
|
389
|
+
getRepoOfProjectFn: providerApis.azureDevOps.getRepo.bind(providerApis.azureDevOps),
|
|
390
|
+
getCurrentUserFn: providerApis.azureDevOps.getCurrentUser.bind(providerApis.azureDevOps),
|
|
391
|
+
getCurrentUserForInstanceFn: providerApis.azureDevOps.getCurrentUserForInstance.bind(
|
|
392
|
+
providerApis.azureDevOps,
|
|
393
|
+
),
|
|
394
|
+
getAzureResourcesForUserFn: providerApis.azureDevOps.getCollectionsForUser.bind(
|
|
395
|
+
providerApis.azureDevOps,
|
|
396
|
+
),
|
|
397
|
+
getAzureProjectsForResourceFn: providerApis.azureDevOps.getAzureProjects.bind(providerApis.azureDevOps),
|
|
398
|
+
getPullRequestsForReposFn: providerApis.azureDevOps.getPullRequestsForRepos.bind(
|
|
399
|
+
providerApis.azureDevOps,
|
|
400
|
+
) as GetPullRequestsForReposFn,
|
|
401
|
+
getPullRequestsForRepoFn: providerApis.azureDevOps.getPullRequestsForRepo.bind(
|
|
402
|
+
providerApis.azureDevOps,
|
|
403
|
+
),
|
|
404
|
+
getPullRequestsForAzureProjectsFn: providerApis.azureDevOps.getPullRequestsForProjects.bind(
|
|
405
|
+
providerApis.azureDevOps,
|
|
406
|
+
),
|
|
407
|
+
getPullRequestsForAzureProjectFn: providerApis.azureDevOps.getPullRequestsForProject.bind(
|
|
408
|
+
providerApis.azureDevOps,
|
|
409
|
+
),
|
|
410
|
+
getIssuesForAzureProjectFn: providerApis.azureDevOps.getIssuesForAzureProject.bind(
|
|
411
|
+
providerApis.azureDevOps,
|
|
412
|
+
),
|
|
413
|
+
getReposForAzureProjectFn: providerApis.azureDevOps.getReposForAzureProject.bind(
|
|
414
|
+
providerApis.azureDevOps,
|
|
415
|
+
),
|
|
416
|
+
mergePullRequestFn: providerApis.azureDevOps.mergePullRequest.bind(providerApis.azureDevOps),
|
|
417
|
+
},
|
|
418
|
+
[IssuesCloudHostIntegrationId.Jira]: {
|
|
419
|
+
...providersMetadata[IssuesCloudHostIntegrationId.Jira],
|
|
420
|
+
provider: providerApis.jira,
|
|
421
|
+
getCurrentUserForResourceFn: providerApis.jira.getCurrentUserForResource.bind(providerApis.jira),
|
|
422
|
+
getJiraResourcesForCurrentUserFn: providerApis.jira.getJiraResourcesForCurrentUser.bind(
|
|
423
|
+
providerApis.jira,
|
|
424
|
+
),
|
|
425
|
+
getJiraProjectsForResourcesFn: providerApis.jira.getJiraProjectsForResources.bind(providerApis.jira),
|
|
426
|
+
getJiraProjectsForResourceFn: providerApis.jira.getJiraProjectsForResource.bind(providerApis.jira),
|
|
427
|
+
getIssueFn: providerApis.jira.getIssue.bind(providerApis.jira) as GetIssueFn,
|
|
428
|
+
getIssuesForProjectFn: providerApis.jira.getIssuesForProject.bind(providerApis.jira),
|
|
429
|
+
getIssuesForResourceForCurrentUserFn: providerApis.jira.getIssuesForResourceForCurrentUser.bind(
|
|
430
|
+
providerApis.jira,
|
|
431
|
+
),
|
|
432
|
+
},
|
|
433
|
+
[IssuesCloudHostIntegrationId.Linear]: {
|
|
434
|
+
...providersMetadata[IssuesCloudHostIntegrationId.Linear],
|
|
435
|
+
provider: providerApis.linear,
|
|
436
|
+
getIssueFn: providerApis.linear.getIssue.bind(providerApis.linear),
|
|
437
|
+
getIssuesForCurrentUserFn: providerApis.linear.getIssuesForCurrentUser.bind(providerApis.linear),
|
|
438
|
+
getLinearOrganizationFn: providerApis.linear.getLinearOrganization.bind(providerApis.linear),
|
|
439
|
+
getLinearTeamsForCurrentUserFn: providerApis.linear.getTeamsForCurrentUser.bind(providerApis.linear),
|
|
440
|
+
getLinearIssuesFn: providerApis.linear.getIssues.bind(providerApis.linear),
|
|
441
|
+
getLinearCurrentUserFn: providerApis.linear.getCurrentUser.bind(providerApis.linear),
|
|
442
|
+
},
|
|
443
|
+
[IssuesCloudHostIntegrationId.Trello]: {
|
|
444
|
+
...providersMetadata[IssuesCloudHostIntegrationId.Trello],
|
|
445
|
+
provider: providerApis.trello,
|
|
446
|
+
getTrelloCurrentUserFn: providerApis.trello.getCurrentUser.bind(providerApis.trello),
|
|
447
|
+
getTrelloBoardsForCurrentUserFn: providerApis.trello.getBoardsForCurrentUser.bind(providerApis.trello),
|
|
448
|
+
getTrelloListsForBoardFn: providerApis.trello.getListsForTrelloBoard.bind(providerApis.trello),
|
|
449
|
+
getTrelloAccountForIdFn: providerApis.trello.getAccountForId.bind(providerApis.trello),
|
|
450
|
+
getTrelloIssuesForBoardFn: providerApis.trello.getIssuesForBoard.bind(providerApis.trello),
|
|
451
|
+
getTrelloLabelsForBoardFn: providerApis.trello.getLabelsForBoard.bind(providerApis.trello),
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
getScopesForProvider(providerId: IntegrationIds): string[] | undefined {
|
|
457
|
+
return this.providers[providerId]?.scopes;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
getProviderDomain(providerId: IntegrationIds): string | undefined {
|
|
461
|
+
return this.providers[providerId]?.domain;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
getProviderPullRequestsPagingMode(providerId: IntegrationIds): PagingMode | undefined {
|
|
465
|
+
return this.providers[providerId]?.pullRequestsPagingMode;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
getProviderIssuesPagingMode(providerId: IntegrationIds): PagingMode | undefined {
|
|
469
|
+
return this.providers[providerId]?.issuesPagingMode;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
providerSupportsPullRequestFilters(providerId: IntegrationIds, filters: PullRequestFilter[]): boolean {
|
|
473
|
+
return (
|
|
474
|
+
this.providers[providerId]?.supportedPullRequestFilters != null &&
|
|
475
|
+
filters.every(filter => this.providers[providerId]?.supportedPullRequestFilters?.includes(filter))
|
|
476
|
+
);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
providerSupportsIssueFilters(providerId: IntegrationIds, filters: IssueFilter[]): boolean {
|
|
480
|
+
return (
|
|
481
|
+
this.providers[providerId]?.supportedIssueFilters != null &&
|
|
482
|
+
filters.every(filter => this.providers[providerId]?.supportedIssueFilters?.includes(filter))
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
isRepoIdsInput(input: any): input is (string | number)[] {
|
|
487
|
+
return (
|
|
488
|
+
input != null &&
|
|
489
|
+
Array.isArray(input) &&
|
|
490
|
+
input.every((id: any) => typeof id === 'string' || typeof id === 'number')
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private async getProviderToken<T extends IntegrationIds>(
|
|
495
|
+
provider: ProviderInfo & { id: T },
|
|
496
|
+
options?: { createSessionIfNeeded?: boolean; connectionId?: string },
|
|
497
|
+
): Promise<TokenWithInfo<T> | undefined> {
|
|
498
|
+
// When a specific connection is requested, resolve that connection's cloud session (mirroring
|
|
499
|
+
// `Integration.resolveReadSession`); otherwise keep the plain descriptor so the primary is resolved.
|
|
500
|
+
// An empty string is not a real target, so it must also fall through to the primary path.
|
|
501
|
+
const providerDescriptor = options?.connectionId
|
|
502
|
+
? { domain: provider.domain, scopes: provider.scopes, connectionId: options.connectionId, cloud: true }
|
|
503
|
+
: { domain: provider.domain, scopes: provider.scopes };
|
|
504
|
+
try {
|
|
505
|
+
const authProvider = await this.authenticationService.get(provider.id);
|
|
506
|
+
const session = await authProvider.getSession(providerDescriptor, {
|
|
507
|
+
createIfNeeded: options?.createSessionIfNeeded,
|
|
508
|
+
});
|
|
509
|
+
if (session == null) {
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
return toTokenWithInfo(provider.id, session);
|
|
513
|
+
} catch {
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
private getAzurePATForOAuthToken(oauthToken: string) {
|
|
519
|
+
return base64(`PAT:${oauthToken}`);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
private async ensureProviderToken<T extends IntegrationIds>(
|
|
523
|
+
tokenOptInfo: TokenOptInfo<T>,
|
|
524
|
+
): Promise<{ provider: ProviderInfo; tokenWithInfo: TokenWithInfo<T> }> {
|
|
525
|
+
const providerId = tokenOptInfo.providerId;
|
|
526
|
+
const provider = this.providers[providerId];
|
|
527
|
+
if (provider == null) {
|
|
528
|
+
throw new Error(`Provider with id ${providerId} not registered`);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (providerId !== provider.id) {
|
|
532
|
+
throw new Error(`Provider id mismatch: expected ${providerId} but got ${provider.id}`);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const connectionId = 'connectionId' in tokenOptInfo ? tokenOptInfo.connectionId : undefined;
|
|
536
|
+
const tokenWithInfo = tokenOptInfo?.accessToken
|
|
537
|
+
? tokenOptInfo
|
|
538
|
+
: await this.getProviderToken<T>(provider as ProviderInfo & { id: T }, {
|
|
539
|
+
connectionId: connectionId,
|
|
540
|
+
});
|
|
541
|
+
if (tokenWithInfo == null) {
|
|
542
|
+
throw new Error(`Not connected to provider ${providerId}`);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return { provider: provider, tokenWithInfo: tokenWithInfo };
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
private async ensureProviderTokenAndFunction<T extends IntegrationIds>(
|
|
549
|
+
tokenOptInfo: TokenOptInfo<T>,
|
|
550
|
+
providerFn: keyof ProviderInfo,
|
|
551
|
+
): Promise<{ provider: ProviderInfo; tokenWithInfo: TokenWithInfo<T> }> {
|
|
552
|
+
const { provider, tokenWithInfo } = await this.ensureProviderToken(tokenOptInfo);
|
|
553
|
+
const providerId = tokenOptInfo.providerId;
|
|
554
|
+
|
|
555
|
+
if (provider[providerFn] == null) {
|
|
556
|
+
throw new Error(`Provider with id ${providerId} does not support function: ${providerFn}`);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return { provider: provider, tokenWithInfo: tokenWithInfo };
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
private handleProviderError<T>(tokenWithInfo: TokenWithInfo, error: any): T {
|
|
563
|
+
const { accessToken: token, ...tokenInfo } = tokenWithInfo;
|
|
564
|
+
const providerId = tokenWithInfo.providerId;
|
|
565
|
+
const provider = this.providers[providerId];
|
|
566
|
+
if (provider == null) {
|
|
567
|
+
throw new Error(`Provider with id ${providerId} not registered`);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (error?.response?.status != null) {
|
|
571
|
+
const status: number = error.response.status;
|
|
572
|
+
switch (status) {
|
|
573
|
+
case 404: // Not found
|
|
574
|
+
case 410: // Gone
|
|
575
|
+
case 422: // Unprocessable Entity
|
|
576
|
+
throw new RequestNotFoundError(error);
|
|
577
|
+
case 429: // Too Many Requests
|
|
578
|
+
throw toRateLimitError(error, token);
|
|
579
|
+
case 401: // Unauthorized
|
|
580
|
+
case 403: // Forbidden
|
|
581
|
+
// A throttled request arrives on both statuses depending on the host (see
|
|
582
|
+
// `isRateLimitResponse`); 403 previously skipped the check, so every provider going through the
|
|
583
|
+
// SDK reported a rate limit as `auth` and asked the user to reconnect a healthy account.
|
|
584
|
+
if (isRateLimitResponse({ status: status, message: error.message })) {
|
|
585
|
+
throw toRateLimitError(error, token);
|
|
586
|
+
}
|
|
587
|
+
throw new AuthenticationError(
|
|
588
|
+
tokenInfo,
|
|
589
|
+
status === 401 ? AuthenticationErrorReason.Unauthorized : AuthenticationErrorReason.Forbidden,
|
|
590
|
+
error,
|
|
591
|
+
);
|
|
592
|
+
default:
|
|
593
|
+
if (status >= 400 && status < 500) {
|
|
594
|
+
throw new RequestClientError(error);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
throw error;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async getPagedResult<T>(
|
|
603
|
+
args: any,
|
|
604
|
+
providerFn:
|
|
605
|
+
| ((
|
|
606
|
+
input: any,
|
|
607
|
+
options?: { token?: string; isPAT?: boolean; baseUrl?: string },
|
|
608
|
+
) => Promise<{ data: NonNullable<T>[]; pageInfo?: PageInfo; metadata?: CollectionMetadata }>)
|
|
609
|
+
| undefined,
|
|
610
|
+
tokenWithInfo: TokenWithInfo,
|
|
611
|
+
cursor: string = '{}',
|
|
612
|
+
isPAT: boolean = false,
|
|
613
|
+
baseUrl?: string,
|
|
614
|
+
): Promise<ProviderApiPagedResult<T>> {
|
|
615
|
+
let cursorInfo;
|
|
616
|
+
try {
|
|
617
|
+
cursorInfo = JSON.parse(cursor);
|
|
618
|
+
} catch {
|
|
619
|
+
cursorInfo = {};
|
|
620
|
+
}
|
|
621
|
+
const cursorValue = cursorInfo.value;
|
|
622
|
+
const cursorType = cursorInfo.type;
|
|
623
|
+
// An explicit numbered `page` request wins over a page-typed cursor; otherwise follow the cursor. A
|
|
624
|
+
// live cursor-typed cursor still takes precedence so an in-flight continuation is never clobbered.
|
|
625
|
+
const requestedPage: number | undefined = typeof args?.page === 'number' ? args.page : undefined;
|
|
626
|
+
const requestedPageSize: number | undefined = typeof args?.pageSize === 'number' ? args.pageSize : undefined;
|
|
627
|
+
let cursorOrPage = {};
|
|
628
|
+
if (requestedPage != null && cursorType !== 'cursor') {
|
|
629
|
+
cursorOrPage = { page: requestedPage };
|
|
630
|
+
} else if (cursorType === 'page') {
|
|
631
|
+
cursorOrPage = { page: cursorValue };
|
|
632
|
+
} else if (cursorType === 'cursor') {
|
|
633
|
+
cursorOrPage = { cursor: cursorValue };
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// Strip the caller's paging keys so `getPagedResult` fully controls them; otherwise `args.page` could
|
|
637
|
+
// survive alongside a resolved `cursor` (or the raw serialized wrapper `args.cursor` could leak in when
|
|
638
|
+
// following a page), letting the provider clobber the continuation we intended.
|
|
639
|
+
const { page: _page, pageSize: _pageSize, cursor: _cursor, ...restArgs } = args ?? {};
|
|
640
|
+
const input = {
|
|
641
|
+
...restArgs,
|
|
642
|
+
...cursorOrPage,
|
|
643
|
+
// `pageSize` is honored by numbered providers; GitHub reads `maxPageSize`. Set both so whichever
|
|
644
|
+
// the resolved provider understands takes effect; the other is ignored.
|
|
645
|
+
...(requestedPageSize != null ? { pageSize: requestedPageSize, maxPageSize: requestedPageSize } : {}),
|
|
646
|
+
};
|
|
647
|
+
|
|
648
|
+
try {
|
|
649
|
+
const result = await providerFn?.(input, {
|
|
650
|
+
token: tokenWithInfo.accessToken,
|
|
651
|
+
isPAT: isPAT,
|
|
652
|
+
baseUrl: baseUrl,
|
|
653
|
+
});
|
|
654
|
+
if (result == null) {
|
|
655
|
+
const continuationWasRequested =
|
|
656
|
+
(cursor != null && cursor !== '{}') || (requestedPage != null && requestedPage > 1);
|
|
657
|
+
return continuationWasRequested
|
|
658
|
+
? {
|
|
659
|
+
values: [],
|
|
660
|
+
paging: { cursor: '{}', more: false, truncated: true },
|
|
661
|
+
metadata: { completeness: 'partial' },
|
|
662
|
+
}
|
|
663
|
+
: { values: [] };
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
const pageInfo = result.pageInfo;
|
|
667
|
+
const hasMore = pageInfo?.hasNextPage ?? false;
|
|
668
|
+
|
|
669
|
+
let nextCursor = '{}';
|
|
670
|
+
if (pageInfo?.endCursor != null) {
|
|
671
|
+
nextCursor = JSON.stringify({ value: pageInfo.endCursor, type: 'cursor' });
|
|
672
|
+
} else if (pageInfo?.nextPage != null) {
|
|
673
|
+
nextCursor = JSON.stringify({ value: pageInfo.nextPage, type: 'page' });
|
|
674
|
+
}
|
|
675
|
+
const continuationBroken = hasMore && (nextCursor === '{}' || nextCursor === cursor);
|
|
676
|
+
const normalizedMetadata = mergeCollectionMetadata(
|
|
677
|
+
result.metadata,
|
|
678
|
+
continuationBroken ? { completeness: 'partial' } : undefined,
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
// SDK collection completeness is independent from provider-native pagination: a result can expose a
|
|
682
|
+
// real next page (`more`) and still have a failed sibling scope (`partial`/`unknown`). Surface the
|
|
683
|
+
// latter as `truncated` so consumers treat the page as incomplete. Absent metadata (old providers,
|
|
684
|
+
// test doubles) leaves `truncated` unset for backward compatibility.
|
|
685
|
+
const truncated =
|
|
686
|
+
normalizedMetadata != null && normalizedMetadata.completeness !== 'complete' ? true : undefined;
|
|
687
|
+
|
|
688
|
+
return {
|
|
689
|
+
values: result.data,
|
|
690
|
+
paging: {
|
|
691
|
+
cursor: nextCursor,
|
|
692
|
+
more: hasMore && !continuationBroken,
|
|
693
|
+
truncated: truncated,
|
|
694
|
+
// Numbered-page metadata; left undefined by cursor-based providers (which don't report a
|
|
695
|
+
// currentPage), so we never echo the requested page for a provider that ignored it.
|
|
696
|
+
page: pageInfo?.currentPage ?? undefined,
|
|
697
|
+
pageSize: requestedPageSize,
|
|
698
|
+
nextPage: pageInfo?.nextPage ?? undefined,
|
|
699
|
+
totalPages: pageInfo?.totalPages ?? undefined,
|
|
700
|
+
totalCount: pageInfo?.totalCount ?? undefined,
|
|
701
|
+
},
|
|
702
|
+
metadata: normalizedMetadata,
|
|
703
|
+
};
|
|
704
|
+
} catch (e) {
|
|
705
|
+
return this.handleProviderError<ProviderApiPagedResult<T>>(tokenWithInfo, e);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
async getRepo(
|
|
710
|
+
tokenOptInfo: TokenOptInfo,
|
|
711
|
+
owner: string,
|
|
712
|
+
name: string,
|
|
713
|
+
project?: string,
|
|
714
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
715
|
+
): Promise<ProviderRepository | undefined> {
|
|
716
|
+
const providerId = tokenOptInfo.providerId;
|
|
717
|
+
const isAzureDevOps =
|
|
718
|
+
providerId === GitCloudHostIntegrationId.AzureDevOps ||
|
|
719
|
+
providerId === GitSelfManagedHostIntegrationId.AzureDevOpsServer;
|
|
720
|
+
if (isAzureDevOps) {
|
|
721
|
+
if (project == null) return undefined;
|
|
722
|
+
|
|
723
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
724
|
+
tokenOptInfo,
|
|
725
|
+
'getRepoOfProjectFn',
|
|
726
|
+
);
|
|
727
|
+
const token = tokenWithInfo.accessToken;
|
|
728
|
+
|
|
729
|
+
try {
|
|
730
|
+
const result = await provider['getRepoOfProjectFn']?.(
|
|
731
|
+
{ namespace: owner, name: name, project: project },
|
|
732
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
733
|
+
);
|
|
734
|
+
return result?.data;
|
|
735
|
+
} catch (e) {
|
|
736
|
+
if (isGraphQLRepoNotFoundError(e)) throw new RequestNotFoundError(toError(e));
|
|
737
|
+
return this.handleProviderError<ProviderRepository>(tokenWithInfo, e);
|
|
738
|
+
}
|
|
739
|
+
} else {
|
|
740
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(tokenOptInfo, 'getRepoFn');
|
|
741
|
+
const token = tokenWithInfo.accessToken;
|
|
742
|
+
|
|
743
|
+
try {
|
|
744
|
+
const result = await provider['getRepoFn']?.(
|
|
745
|
+
{ namespace: owner, name: name, project: project },
|
|
746
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
747
|
+
);
|
|
748
|
+
return result?.data;
|
|
749
|
+
} catch (e) {
|
|
750
|
+
if (isGraphQLRepoNotFoundError(e)) throw new RequestNotFoundError(toError(e));
|
|
751
|
+
return this.handleProviderError<ProviderRepository>(tokenWithInfo, e);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
async getCurrentUser(
|
|
757
|
+
tokenOptInfo: TokenOptInfo,
|
|
758
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
759
|
+
): Promise<ProviderAccount | undefined> {
|
|
760
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(tokenOptInfo, 'getCurrentUserFn');
|
|
761
|
+
const token = tokenWithInfo.accessToken;
|
|
762
|
+
|
|
763
|
+
try {
|
|
764
|
+
return (
|
|
765
|
+
await provider.getCurrentUserFn?.(
|
|
766
|
+
{},
|
|
767
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
768
|
+
)
|
|
769
|
+
)?.data;
|
|
770
|
+
} catch (e) {
|
|
771
|
+
return this.handleProviderError<ProviderAccount>(tokenWithInfo, e);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
async getCurrentUserForInstance(
|
|
776
|
+
tokenOptInfo: TokenOptInfo,
|
|
777
|
+
namespace: string,
|
|
778
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
779
|
+
): Promise<ProviderAccount | undefined> {
|
|
780
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
781
|
+
tokenOptInfo,
|
|
782
|
+
'getCurrentUserForInstanceFn',
|
|
783
|
+
);
|
|
784
|
+
const token = tokenWithInfo.accessToken;
|
|
785
|
+
|
|
786
|
+
return (
|
|
787
|
+
await provider.getCurrentUserForInstanceFn?.(
|
|
788
|
+
{ namespace: namespace },
|
|
789
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
790
|
+
)
|
|
791
|
+
)?.data;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
async getCurrentUserForResource(
|
|
795
|
+
tokenOptInfo: TokenWithInfo,
|
|
796
|
+
resourceId: string,
|
|
797
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
798
|
+
): Promise<ProviderAccount | undefined> {
|
|
799
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
800
|
+
tokenOptInfo,
|
|
801
|
+
'getCurrentUserForResourceFn',
|
|
802
|
+
);
|
|
803
|
+
const token = tokenWithInfo.accessToken;
|
|
804
|
+
|
|
805
|
+
try {
|
|
806
|
+
return (
|
|
807
|
+
await provider.getCurrentUserForResourceFn?.(
|
|
808
|
+
{ resourceId: resourceId },
|
|
809
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
810
|
+
)
|
|
811
|
+
)?.data;
|
|
812
|
+
} catch (e) {
|
|
813
|
+
return this.handleProviderError<ProviderAccount>(tokenWithInfo, e);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
async getJiraResourcesForCurrentUser(
|
|
818
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Jira>,
|
|
819
|
+
): Promise<ProviderJiraResource[] | undefined> {
|
|
820
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
821
|
+
tokenOptInfo,
|
|
822
|
+
'getJiraResourcesForCurrentUserFn',
|
|
823
|
+
);
|
|
824
|
+
const token = tokenWithInfo.accessToken;
|
|
825
|
+
|
|
826
|
+
try {
|
|
827
|
+
return (await provider.getJiraResourcesForCurrentUserFn?.({ token: token }))?.data;
|
|
828
|
+
} catch (e) {
|
|
829
|
+
return this.handleProviderError<ProviderJiraResource[] | undefined>(tokenWithInfo, e);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
async getLinearOrganization(
|
|
834
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Linear>,
|
|
835
|
+
): Promise<ProviderLinearOrganization | undefined> {
|
|
836
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
837
|
+
tokenOptInfo,
|
|
838
|
+
'getLinearOrganizationFn',
|
|
839
|
+
);
|
|
840
|
+
const token = tokenWithInfo.accessToken;
|
|
841
|
+
|
|
842
|
+
try {
|
|
843
|
+
const x = await provider.getLinearOrganizationFn?.({ token: token });
|
|
844
|
+
const y = x?.data;
|
|
845
|
+
return y;
|
|
846
|
+
} catch (e) {
|
|
847
|
+
return this.handleProviderError<ProviderLinearOrganization | undefined>(tokenWithInfo, e);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
async getLinearTeamsForCurrentUser(
|
|
852
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Linear>,
|
|
853
|
+
): Promise<ProviderLinearTeam[] | undefined> {
|
|
854
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
855
|
+
tokenOptInfo,
|
|
856
|
+
'getLinearTeamsForCurrentUserFn',
|
|
857
|
+
);
|
|
858
|
+
const token = tokenWithInfo.accessToken;
|
|
859
|
+
|
|
860
|
+
try {
|
|
861
|
+
return (await provider.getLinearTeamsForCurrentUserFn?.({ token: token }))?.data;
|
|
862
|
+
} catch (e) {
|
|
863
|
+
return this.handleProviderError<ProviderLinearTeam[] | undefined>(tokenWithInfo, e);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Reads issues scoped to Linear teams/projects/labels (Linear's issue-list filter). One page per call —
|
|
869
|
+
* follow `paging.cursor`. Linear's `getIssues` has no author/assignee filter, so per-user scoping is
|
|
870
|
+
* applied client-side by the caller.
|
|
871
|
+
*/
|
|
872
|
+
async getLinearIssues(
|
|
873
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Linear>,
|
|
874
|
+
input: { teams?: string[]; projects?: string[]; labels?: string[] },
|
|
875
|
+
options?: PagingInput,
|
|
876
|
+
): Promise<PagedResult<ProviderIssue>> {
|
|
877
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
878
|
+
tokenOptInfo,
|
|
879
|
+
'getLinearIssuesFn',
|
|
880
|
+
);
|
|
881
|
+
return this.getPagedResult<ProviderIssue>(
|
|
882
|
+
{ ...input, ...options },
|
|
883
|
+
provider.getLinearIssuesFn,
|
|
884
|
+
tokenWithInfo,
|
|
885
|
+
options?.cursor ?? undefined,
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** Resolves Linear's current user (viewer). The viewer query returns only id/name/email/displayName. */
|
|
890
|
+
async getLinearCurrentUser(
|
|
891
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Linear>,
|
|
892
|
+
): Promise<{ id: string; name?: string | null; email?: string | null; displayName?: string | null } | undefined> {
|
|
893
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
894
|
+
tokenOptInfo,
|
|
895
|
+
'getLinearCurrentUserFn',
|
|
896
|
+
);
|
|
897
|
+
const token = tokenWithInfo.accessToken;
|
|
898
|
+
|
|
899
|
+
try {
|
|
900
|
+
return (await provider.getLinearCurrentUserFn?.({ token: token }))?.data;
|
|
901
|
+
} catch (e) {
|
|
902
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
async getAzureResourcesForUser(
|
|
907
|
+
tokenOptInfo: TokenWithInfo<
|
|
908
|
+
GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer
|
|
909
|
+
>,
|
|
910
|
+
userId: string,
|
|
911
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
912
|
+
): Promise<ProviderAzureResource[] | undefined> {
|
|
913
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
914
|
+
tokenOptInfo,
|
|
915
|
+
'getAzureResourcesForUserFn',
|
|
916
|
+
);
|
|
917
|
+
const token = tokenWithInfo.accessToken;
|
|
918
|
+
|
|
919
|
+
try {
|
|
920
|
+
return (
|
|
921
|
+
await provider.getAzureResourcesForUserFn?.(
|
|
922
|
+
{ userId: userId },
|
|
923
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
924
|
+
)
|
|
925
|
+
)?.data;
|
|
926
|
+
} catch (e) {
|
|
927
|
+
return this.handleProviderError<ProviderAzureResource[] | undefined>(tokenWithInfo, e);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
async getBitbucketResourcesForCurrentUser(
|
|
932
|
+
tokenOptInfo: TokenWithInfo<GitCloudHostIntegrationId.Bitbucket>,
|
|
933
|
+
): Promise<ProviderApiPagedResult<ProviderBitbucketResource> | undefined> {
|
|
934
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
935
|
+
tokenOptInfo,
|
|
936
|
+
'getBitbucketResourcesForCurrentUserFn',
|
|
937
|
+
);
|
|
938
|
+
const token = tokenWithInfo.accessToken;
|
|
939
|
+
|
|
940
|
+
// Drain every workspace page (numbered): the SDK returns 50 per page, and a user in more than one page
|
|
941
|
+
// of workspaces would otherwise silently lose the rest (with them, their orgs/PRs). A scoped drain keeps
|
|
942
|
+
// a successful prefix plus structured failure metadata when a later page fails.
|
|
943
|
+
const result = await collectProviderPagedResult(
|
|
944
|
+
async cursor => {
|
|
945
|
+
try {
|
|
946
|
+
const page = parsePageCursor(cursor);
|
|
947
|
+
const response = await provider.getBitbucketResourcesForCurrentUserFn?.(
|
|
948
|
+
{ page: page },
|
|
949
|
+
{ token: token },
|
|
950
|
+
);
|
|
951
|
+
if (response == null) return undefined;
|
|
952
|
+
|
|
953
|
+
const hasMore = response.pageInfo?.hasNextPage === true;
|
|
954
|
+
const nextPage = response.pageInfo?.nextPage;
|
|
955
|
+
return {
|
|
956
|
+
values: response.data,
|
|
957
|
+
paging: {
|
|
958
|
+
more: hasMore,
|
|
959
|
+
cursor: hasMore && nextPage != null ? toPageCursor(nextPage) : '{}',
|
|
960
|
+
},
|
|
961
|
+
};
|
|
962
|
+
} catch (ex) {
|
|
963
|
+
return this.handleProviderError<ProviderApiPagedResult<ProviderBitbucketResource>>(
|
|
964
|
+
tokenWithInfo,
|
|
965
|
+
ex,
|
|
966
|
+
);
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
20,
|
|
970
|
+
{ providerId: tokenWithInfo.providerId },
|
|
971
|
+
);
|
|
972
|
+
return {
|
|
973
|
+
values: result.values,
|
|
974
|
+
paging: { cursor: '{}', more: false, ...(result.truncated ? { truncated: true } : {}) },
|
|
975
|
+
...(result.metadata != null ? { metadata: result.metadata } : {}),
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
async getBitbucketPullRequestsAuthoredByUserForWorkspace(
|
|
980
|
+
tokenOptInfo: TokenWithInfo<GitCloudHostIntegrationId.Bitbucket>,
|
|
981
|
+
userId: string,
|
|
982
|
+
workspaceSlug: string,
|
|
983
|
+
options?: { states?: GitPullRequestState[]; page?: number },
|
|
984
|
+
): Promise<{ data: ProviderPullRequest[]; hasMore: boolean; nextPage: number | null } | undefined> {
|
|
985
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
986
|
+
tokenOptInfo,
|
|
987
|
+
'getBitbucketPullRequestsAuthoredByUserForWorkspaceFn',
|
|
988
|
+
);
|
|
989
|
+
const token = tokenWithInfo.accessToken;
|
|
990
|
+
|
|
991
|
+
try {
|
|
992
|
+
const result = await provider.getBitbucketPullRequestsAuthoredByUserForWorkspaceFn?.(
|
|
993
|
+
{ userId: userId, workspaceSlug: workspaceSlug, states: options?.states, page: options?.page },
|
|
994
|
+
{ token: token },
|
|
995
|
+
);
|
|
996
|
+
if (result == null) return undefined;
|
|
997
|
+
return { data: result.data, hasMore: result.pageInfo.hasNextPage, nextPage: result.pageInfo.nextPage };
|
|
998
|
+
} catch (e) {
|
|
999
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
async getBitbucketServerPullRequestsForCurrentUser(
|
|
1004
|
+
tokenOptInfo: TokenWithInfo<GitSelfManagedHostIntegrationId.BitbucketServer>,
|
|
1005
|
+
baseUrl: string,
|
|
1006
|
+
options?: { states?: GitPullRequestState[]; page?: number },
|
|
1007
|
+
): Promise<{ data: ProviderPullRequest[]; hasMore: boolean; nextPage: number | null } | undefined> {
|
|
1008
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1009
|
+
tokenOptInfo,
|
|
1010
|
+
'getBitbucketServerPullRequestsForCurrentUserFn',
|
|
1011
|
+
);
|
|
1012
|
+
const token = tokenWithInfo.accessToken;
|
|
1013
|
+
try {
|
|
1014
|
+
const result = await provider.getBitbucketServerPullRequestsForCurrentUserFn?.(
|
|
1015
|
+
{ states: options?.states, page: options?.page },
|
|
1016
|
+
{ token: token, baseUrl: baseUrl },
|
|
1017
|
+
);
|
|
1018
|
+
if (result == null) return undefined;
|
|
1019
|
+
return { data: result.data, hasMore: result.pageInfo.hasNextPage, nextPage: result.pageInfo.nextPage };
|
|
1020
|
+
} catch (e) {
|
|
1021
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
async getJiraProjectsForResources(
|
|
1026
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Jira>,
|
|
1027
|
+
resourceIds: string[],
|
|
1028
|
+
): Promise<ProviderApiCollectionResult<ProviderJiraProject>> {
|
|
1029
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1030
|
+
tokenOptInfo,
|
|
1031
|
+
'getJiraProjectsForResourcesFn',
|
|
1032
|
+
);
|
|
1033
|
+
const token = tokenWithInfo.accessToken;
|
|
1034
|
+
|
|
1035
|
+
try {
|
|
1036
|
+
const result = await provider.getJiraProjectsForResourcesFn?.(
|
|
1037
|
+
{ resourceIds: resourceIds },
|
|
1038
|
+
{ token: token },
|
|
1039
|
+
);
|
|
1040
|
+
// Preserve the SDK's per-resource completeness/failures instead of collapsing to a bare array, so the
|
|
1041
|
+
// Jira integration can cache only proven-successful resources and warn on the failed ones.
|
|
1042
|
+
return { values: result?.data ?? [], metadata: result?.metadata };
|
|
1043
|
+
} catch (e) {
|
|
1044
|
+
return this.handleProviderError<ProviderApiCollectionResult<ProviderJiraProject>>(tokenWithInfo, e);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
async getJiraProjectsForResource(
|
|
1049
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Jira>,
|
|
1050
|
+
resourceId: string,
|
|
1051
|
+
options?: { cursor?: string },
|
|
1052
|
+
): Promise<ProviderApiPagedResult<ProviderJiraProject>> {
|
|
1053
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1054
|
+
tokenOptInfo,
|
|
1055
|
+
'getJiraProjectsForResourceFn',
|
|
1056
|
+
);
|
|
1057
|
+
|
|
1058
|
+
return this.getPagedResult(
|
|
1059
|
+
{ resourceId: resourceId },
|
|
1060
|
+
provider.getJiraProjectsForResourceFn,
|
|
1061
|
+
tokenWithInfo,
|
|
1062
|
+
options?.cursor,
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
async getAzureProjectsForResource(
|
|
1067
|
+
tokenOptInfo: TokenWithInfo<
|
|
1068
|
+
GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer
|
|
1069
|
+
>,
|
|
1070
|
+
namespace: string,
|
|
1071
|
+
options?: { cursor?: string; isPAT?: boolean; baseUrl?: string },
|
|
1072
|
+
): Promise<PagedResult<ProviderAzureProject>> {
|
|
1073
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1074
|
+
tokenOptInfo,
|
|
1075
|
+
'getAzureProjectsForResourceFn',
|
|
1076
|
+
);
|
|
1077
|
+
const token = tokenWithInfo.accessToken;
|
|
1078
|
+
|
|
1079
|
+
// Azure only supports PAT for this call
|
|
1080
|
+
const azureToken = options?.isPAT ? token : this.getAzurePATForOAuthToken(token);
|
|
1081
|
+
|
|
1082
|
+
try {
|
|
1083
|
+
return await this.getPagedResult<ProviderAzureProject>(
|
|
1084
|
+
{ namespace: namespace, ...options },
|
|
1085
|
+
provider.getAzureProjectsForResourceFn,
|
|
1086
|
+
{ ...tokenWithInfo, accessToken: azureToken },
|
|
1087
|
+
options?.cursor,
|
|
1088
|
+
options?.isPAT,
|
|
1089
|
+
options?.baseUrl,
|
|
1090
|
+
);
|
|
1091
|
+
} catch (e) {
|
|
1092
|
+
return this.handleProviderError<PagedResult<ProviderAzureProject>>(tokenWithInfo, e);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
async getReposForAzureProject(
|
|
1097
|
+
tokenOptInfo: TokenWithInfo<
|
|
1098
|
+
GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer
|
|
1099
|
+
>,
|
|
1100
|
+
namespace: string,
|
|
1101
|
+
project: string,
|
|
1102
|
+
options?: GetReposOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1103
|
+
): Promise<PagedResult<ProviderRepository>> {
|
|
1104
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1105
|
+
tokenOptInfo,
|
|
1106
|
+
'getReposForAzureProjectFn',
|
|
1107
|
+
);
|
|
1108
|
+
|
|
1109
|
+
return this.getPagedResult<ProviderRepository>(
|
|
1110
|
+
{ namespace: namespace, project: project, ...options },
|
|
1111
|
+
provider.getReposForAzureProjectFn,
|
|
1112
|
+
tokenWithInfo,
|
|
1113
|
+
options?.cursor,
|
|
1114
|
+
options?.isPAT,
|
|
1115
|
+
options?.baseUrl,
|
|
1116
|
+
);
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
async getGitHubOrgsForCurrentUser(
|
|
1120
|
+
tokenOptInfo: TokenWithInfo<
|
|
1121
|
+
GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise
|
|
1122
|
+
>,
|
|
1123
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
1124
|
+
): Promise<ProviderHierarchyResult<ProviderGitHubOrganization>> {
|
|
1125
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1126
|
+
tokenOptInfo,
|
|
1127
|
+
'getOrgsForCurrentUserFn',
|
|
1128
|
+
);
|
|
1129
|
+
|
|
1130
|
+
// Drain all pages so a user in many orgs doesn't lose everything past the first page, while
|
|
1131
|
+
// surfacing `truncated` when the defensive backstop stops before the listing is exhausted.
|
|
1132
|
+
const result = await collectProviderPagedResult(
|
|
1133
|
+
cursor =>
|
|
1134
|
+
this.getPagedResult<ProviderGitHubOrganization>(
|
|
1135
|
+
{},
|
|
1136
|
+
provider.getOrgsForCurrentUserFn,
|
|
1137
|
+
tokenWithInfo,
|
|
1138
|
+
cursor,
|
|
1139
|
+
options?.isPAT,
|
|
1140
|
+
options?.baseUrl,
|
|
1141
|
+
),
|
|
1142
|
+
20,
|
|
1143
|
+
{ providerId: tokenWithInfo.providerId },
|
|
1144
|
+
);
|
|
1145
|
+
// This method drains internally and takes no cursor, so a backstop cursor isn't resumable by
|
|
1146
|
+
// callers — keep only the truncation signal rather than exposing a misleading `paging`.
|
|
1147
|
+
return {
|
|
1148
|
+
values: result.values,
|
|
1149
|
+
...(result.truncated ? { truncated: true } : {}),
|
|
1150
|
+
...(result.metadata != null ? { metadata: result.metadata } : {}),
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
async getReposForOrg(
|
|
1155
|
+
tokenOptInfo: TokenWithInfo<
|
|
1156
|
+
GitCloudHostIntegrationId.GitHub | GitSelfManagedHostIntegrationId.CloudGitHubEnterprise
|
|
1157
|
+
>,
|
|
1158
|
+
orgName: string,
|
|
1159
|
+
options?: GetReposOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1160
|
+
): Promise<PagedResult<ProviderRepository>> {
|
|
1161
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(tokenOptInfo, 'getReposForOrgFn');
|
|
1162
|
+
|
|
1163
|
+
return this.getPagedResult<ProviderRepository>(
|
|
1164
|
+
{ orgName: orgName },
|
|
1165
|
+
provider.getReposForOrgFn,
|
|
1166
|
+
tokenWithInfo,
|
|
1167
|
+
options?.cursor,
|
|
1168
|
+
options?.isPAT,
|
|
1169
|
+
options?.baseUrl,
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
async getReposForBitbucketWorkspace(
|
|
1174
|
+
tokenOptInfo: TokenWithInfo<GitCloudHostIntegrationId.Bitbucket>,
|
|
1175
|
+
workspace: string,
|
|
1176
|
+
options?: GetReposOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1177
|
+
): Promise<PagedResult<ProviderRepository>> {
|
|
1178
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1179
|
+
tokenOptInfo,
|
|
1180
|
+
'getReposForWorkspaceFn',
|
|
1181
|
+
);
|
|
1182
|
+
|
|
1183
|
+
return this.getPagedResult<ProviderRepository>(
|
|
1184
|
+
{ workspace: workspace },
|
|
1185
|
+
provider.getReposForWorkspaceFn,
|
|
1186
|
+
tokenWithInfo,
|
|
1187
|
+
options?.cursor,
|
|
1188
|
+
options?.isPAT,
|
|
1189
|
+
options?.baseUrl,
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
async getReposForCurrentUser(
|
|
1194
|
+
tokenOptInfo: TokenWithInfo<
|
|
1195
|
+
| GitCloudHostIntegrationId.GitHub
|
|
1196
|
+
| GitSelfManagedHostIntegrationId.CloudGitHubEnterprise
|
|
1197
|
+
| GitCloudHostIntegrationId.GitLab
|
|
1198
|
+
| GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted
|
|
1199
|
+
>,
|
|
1200
|
+
options?: GetReposOptions & {
|
|
1201
|
+
/** GitHub `/user/repos` affiliation filter; ignored by GitLab's membership read. */
|
|
1202
|
+
affiliations?: ('owner' | 'collaborator' | 'organization_member')[];
|
|
1203
|
+
isPAT?: boolean;
|
|
1204
|
+
baseUrl?: string;
|
|
1205
|
+
},
|
|
1206
|
+
): Promise<PagedResult<ProviderRepository>> {
|
|
1207
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1208
|
+
tokenOptInfo,
|
|
1209
|
+
'getReposForCurrentUserFn',
|
|
1210
|
+
);
|
|
1211
|
+
|
|
1212
|
+
return this.getPagedResult<ProviderRepository>(
|
|
1213
|
+
options?.affiliations != null ? { affiliations: options.affiliations } : {},
|
|
1214
|
+
provider.getReposForCurrentUserFn,
|
|
1215
|
+
tokenWithInfo,
|
|
1216
|
+
options?.cursor,
|
|
1217
|
+
options?.isPAT,
|
|
1218
|
+
options?.baseUrl,
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
async getGitlabGroupsForCurrentUser(
|
|
1223
|
+
tokenOptInfo: TokenWithInfo<
|
|
1224
|
+
GitCloudHostIntegrationId.GitLab | GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted
|
|
1225
|
+
>,
|
|
1226
|
+
options?: { topLevelOnly?: boolean; isPAT?: boolean; baseUrl?: string },
|
|
1227
|
+
): Promise<ProviderHierarchyResult<ProviderGitLabGroup>> {
|
|
1228
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1229
|
+
tokenOptInfo,
|
|
1230
|
+
'getGroupsForCurrentUserFn',
|
|
1231
|
+
);
|
|
1232
|
+
|
|
1233
|
+
// Drain all pages so a user in many groups doesn't lose everything past the first page, while
|
|
1234
|
+
// surfacing `truncated` when the defensive backstop stops before the listing is exhausted.
|
|
1235
|
+
const result = await collectProviderPagedResult(
|
|
1236
|
+
cursor =>
|
|
1237
|
+
this.getPagedResult<ProviderGitLabGroup>(
|
|
1238
|
+
{ topLevelOnly: options?.topLevelOnly },
|
|
1239
|
+
provider.getGroupsForCurrentUserFn,
|
|
1240
|
+
tokenWithInfo,
|
|
1241
|
+
cursor,
|
|
1242
|
+
options?.isPAT,
|
|
1243
|
+
options?.baseUrl,
|
|
1244
|
+
),
|
|
1245
|
+
20,
|
|
1246
|
+
{ providerId: tokenWithInfo.providerId },
|
|
1247
|
+
);
|
|
1248
|
+
// This method drains internally and takes no cursor, so a backstop cursor isn't resumable by
|
|
1249
|
+
// callers — keep only the truncation signal rather than exposing a misleading `paging`.
|
|
1250
|
+
return {
|
|
1251
|
+
values: result.values,
|
|
1252
|
+
...(result.truncated ? { truncated: true } : {}),
|
|
1253
|
+
...(result.metadata != null ? { metadata: result.metadata } : {}),
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
async getPullRequestsForRepos(
|
|
1258
|
+
tokenOptInfo: TokenOptInfo,
|
|
1259
|
+
reposOrIds: ProviderReposInput,
|
|
1260
|
+
options?: GetPullRequestsOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1261
|
+
): Promise<ProviderApiPagedResult<ProviderPullRequest>> {
|
|
1262
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1263
|
+
tokenOptInfo,
|
|
1264
|
+
'getPullRequestsForReposFn',
|
|
1265
|
+
);
|
|
1266
|
+
|
|
1267
|
+
return this.getPagedResult<ProviderPullRequest>(
|
|
1268
|
+
{
|
|
1269
|
+
...(this.isRepoIdsInput(reposOrIds) ? { repoIds: reposOrIds } : { repos: reposOrIds }),
|
|
1270
|
+
...options,
|
|
1271
|
+
},
|
|
1272
|
+
provider.getPullRequestsForReposFn,
|
|
1273
|
+
tokenWithInfo,
|
|
1274
|
+
options?.cursor,
|
|
1275
|
+
options?.isPAT,
|
|
1276
|
+
options?.baseUrl,
|
|
1277
|
+
);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
async getPullRequestsForRepo(
|
|
1281
|
+
tokenOptInfo: TokenOptInfo,
|
|
1282
|
+
repo: ProviderRepoInput,
|
|
1283
|
+
options?: GetPullRequestsOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1284
|
+
): Promise<ProviderApiPagedResult<ProviderPullRequest>> {
|
|
1285
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1286
|
+
tokenOptInfo,
|
|
1287
|
+
'getPullRequestsForRepoFn',
|
|
1288
|
+
);
|
|
1289
|
+
|
|
1290
|
+
return this.getPagedResult<ProviderPullRequest>(
|
|
1291
|
+
{ repo: repo, ...options },
|
|
1292
|
+
provider.getPullRequestsForRepoFn,
|
|
1293
|
+
tokenWithInfo,
|
|
1294
|
+
options?.cursor,
|
|
1295
|
+
options?.isPAT,
|
|
1296
|
+
options?.baseUrl,
|
|
1297
|
+
);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
async getPullRequestsForUser(
|
|
1301
|
+
tokenWithInfo: TokenWithInfo<GitCloudHostIntegrationId.Bitbucket>,
|
|
1302
|
+
userId: string,
|
|
1303
|
+
options?: { isPAT?: boolean } & GetPullRequestsForUserOptions,
|
|
1304
|
+
): Promise<ProviderApiPagedResult<ProviderPullRequest>>;
|
|
1305
|
+
async getPullRequestsForUser(
|
|
1306
|
+
tokenWithInfo: TokenWithInfo<Exclude<IntegrationIds, GitCloudHostIntegrationId.Bitbucket>>,
|
|
1307
|
+
username: string,
|
|
1308
|
+
options?: { isPAT?: boolean } & GetPullRequestsForUserOptions,
|
|
1309
|
+
): Promise<ProviderApiPagedResult<ProviderPullRequest>>;
|
|
1310
|
+
async getPullRequestsForUser(
|
|
1311
|
+
tokenOptInfo: TokenWithInfo,
|
|
1312
|
+
usernameOrId: string,
|
|
1313
|
+
options?: { isPAT?: boolean } & GetPullRequestsForUserOptions,
|
|
1314
|
+
): Promise<ProviderApiPagedResult<ProviderPullRequest>> {
|
|
1315
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1316
|
+
tokenOptInfo,
|
|
1317
|
+
'getPullRequestsForUserFn',
|
|
1318
|
+
);
|
|
1319
|
+
|
|
1320
|
+
return this.getPagedResult<ProviderPullRequest>(
|
|
1321
|
+
{
|
|
1322
|
+
...(tokenWithInfo.providerId === GitCloudHostIntegrationId.Bitbucket
|
|
1323
|
+
? { userId: usernameOrId }
|
|
1324
|
+
: { username: usernameOrId }),
|
|
1325
|
+
...options,
|
|
1326
|
+
},
|
|
1327
|
+
provider.getPullRequestsForUserFn,
|
|
1328
|
+
tokenWithInfo,
|
|
1329
|
+
options?.cursor,
|
|
1330
|
+
options?.isPAT,
|
|
1331
|
+
options?.baseUrl,
|
|
1332
|
+
);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
async getGitLabPullRequestsForUserAssociation(
|
|
1336
|
+
tokenOptInfo: TokenWithInfo<
|
|
1337
|
+
GitCloudHostIntegrationId.GitLab | GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted
|
|
1338
|
+
>,
|
|
1339
|
+
username: string,
|
|
1340
|
+
association: 'assigned' | 'authored' | 'reviewRequested',
|
|
1341
|
+
options?: {
|
|
1342
|
+
isPAT?: boolean;
|
|
1343
|
+
baseUrl?: string;
|
|
1344
|
+
states?: GitPullRequestState[];
|
|
1345
|
+
cursor?: string;
|
|
1346
|
+
pageSize?: number;
|
|
1347
|
+
},
|
|
1348
|
+
): Promise<ProviderApiPagedResult<ProviderPullRequest>> {
|
|
1349
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1350
|
+
tokenOptInfo,
|
|
1351
|
+
'getGitLabPullRequestsForUserAssociationFn',
|
|
1352
|
+
);
|
|
1353
|
+
|
|
1354
|
+
return this.getPagedResult(
|
|
1355
|
+
{
|
|
1356
|
+
username: username,
|
|
1357
|
+
association: association,
|
|
1358
|
+
states: options?.states,
|
|
1359
|
+
pageSize: options?.pageSize,
|
|
1360
|
+
},
|
|
1361
|
+
provider.getGitLabPullRequestsForUserAssociationFn,
|
|
1362
|
+
tokenWithInfo,
|
|
1363
|
+
options?.cursor,
|
|
1364
|
+
options?.isPAT,
|
|
1365
|
+
options?.baseUrl,
|
|
1366
|
+
);
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
async getPullRequestsForAzureProjects(
|
|
1370
|
+
tokenOptInfo: TokenWithInfo<
|
|
1371
|
+
GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer
|
|
1372
|
+
>,
|
|
1373
|
+
projects: { namespace: string; project: string }[],
|
|
1374
|
+
options?: {
|
|
1375
|
+
authorLogin?: string;
|
|
1376
|
+
assigneeLogins?: string[];
|
|
1377
|
+
reviewerId?: string;
|
|
1378
|
+
states?: GitPullRequestState[];
|
|
1379
|
+
repo?: ProviderRepoInput;
|
|
1380
|
+
isPAT?: boolean;
|
|
1381
|
+
baseUrl?: string;
|
|
1382
|
+
},
|
|
1383
|
+
): Promise<ProviderApiCollectionResult<ProviderPullRequest>> {
|
|
1384
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1385
|
+
tokenOptInfo,
|
|
1386
|
+
'getPullRequestsForAzureProjectsFn',
|
|
1387
|
+
);
|
|
1388
|
+
const token = tokenWithInfo.accessToken;
|
|
1389
|
+
|
|
1390
|
+
// Azure only supports PAT for this call
|
|
1391
|
+
const azureToken = options?.isPAT ? token : this.getAzurePATForOAuthToken(token);
|
|
1392
|
+
|
|
1393
|
+
try {
|
|
1394
|
+
const result = await provider.getPullRequestsForAzureProjectsFn?.(
|
|
1395
|
+
{
|
|
1396
|
+
projects: projects,
|
|
1397
|
+
authorLogin: options?.authorLogin,
|
|
1398
|
+
assigneeLogins: options?.assigneeLogins,
|
|
1399
|
+
reviewerId: options?.reviewerId,
|
|
1400
|
+
states: options?.states,
|
|
1401
|
+
repo: options?.repo,
|
|
1402
|
+
},
|
|
1403
|
+
// `azureToken` is always a PAT here (the raw token when `isPAT`, otherwise a PAT derived from
|
|
1404
|
+
// the OAuth token), so it must be sent as a PAT regardless of the incoming `options?.isPAT`.
|
|
1405
|
+
{ token: azureToken, isPAT: true, baseUrl: options?.baseUrl },
|
|
1406
|
+
);
|
|
1407
|
+
// The SDK's multi-project aggregate preserves successful projects and reports failed/incomplete ones
|
|
1408
|
+
// through `metadata` (it has no `pageInfo`); keep it so the account-wide drain can warn on the failed
|
|
1409
|
+
// projects and set `fetchFailed` instead of publishing a partial Azure read as complete.
|
|
1410
|
+
return { values: result?.data ?? [], metadata: result?.metadata };
|
|
1411
|
+
} catch (e) {
|
|
1412
|
+
return this.handleProviderError<ProviderApiCollectionResult<ProviderPullRequest>>(tokenWithInfo, e);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
/**
|
|
1417
|
+
* Single Azure project PR read, paginated by number. Unlike {@link getPullRequestsForAzureProjects} (which
|
|
1418
|
+
* aggregates across projects and exposes no paging), this returns one page plus whether more remain, so a
|
|
1419
|
+
* caller can drain a project fully.
|
|
1420
|
+
*/
|
|
1421
|
+
async getPullRequestsForAzureProject(
|
|
1422
|
+
tokenOptInfo: TokenWithInfo<
|
|
1423
|
+
GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer
|
|
1424
|
+
>,
|
|
1425
|
+
project: { namespace: string; project: string },
|
|
1426
|
+
options?: {
|
|
1427
|
+
authorLogin?: string;
|
|
1428
|
+
assigneeLogins?: string[];
|
|
1429
|
+
reviewerId?: string;
|
|
1430
|
+
states?: GitPullRequestState[];
|
|
1431
|
+
repo?: ProviderRepoInput;
|
|
1432
|
+
page?: number;
|
|
1433
|
+
isPAT?: boolean;
|
|
1434
|
+
baseUrl?: string;
|
|
1435
|
+
},
|
|
1436
|
+
): Promise<{ data: ProviderPullRequest[]; hasMore: boolean; nextPage: number | null } | undefined> {
|
|
1437
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1438
|
+
tokenOptInfo,
|
|
1439
|
+
'getPullRequestsForAzureProjectFn',
|
|
1440
|
+
);
|
|
1441
|
+
const token = tokenWithInfo.accessToken;
|
|
1442
|
+
// Azure only supports PAT for this call
|
|
1443
|
+
const azureToken = options?.isPAT ? token : this.getAzurePATForOAuthToken(token);
|
|
1444
|
+
|
|
1445
|
+
try {
|
|
1446
|
+
const result = await provider.getPullRequestsForAzureProjectFn?.(
|
|
1447
|
+
{
|
|
1448
|
+
namespace: project.namespace,
|
|
1449
|
+
project: project.project,
|
|
1450
|
+
authorLogin: options?.authorLogin,
|
|
1451
|
+
assigneeLogins: options?.assigneeLogins,
|
|
1452
|
+
reviewerId: options?.reviewerId,
|
|
1453
|
+
states: options?.states,
|
|
1454
|
+
repo: options?.repo,
|
|
1455
|
+
page: options?.page,
|
|
1456
|
+
},
|
|
1457
|
+
// `azureToken` is always a PAT here (already PAT-formatted when `isPAT`, otherwise derived from
|
|
1458
|
+
// the OAuth token), so it must be sent as a PAT regardless of the incoming `options?.isPAT`.
|
|
1459
|
+
{ token: azureToken, isPAT: true, baseUrl: options?.baseUrl },
|
|
1460
|
+
);
|
|
1461
|
+
if (result == null) return undefined;
|
|
1462
|
+
return { data: result.data, hasMore: result.pageInfo.hasNextPage, nextPage: result.pageInfo.nextPage };
|
|
1463
|
+
} catch (e) {
|
|
1464
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
async mergePullRequest(
|
|
1469
|
+
tokenOptInfo: TokenWithInfo,
|
|
1470
|
+
pr: PullRequest,
|
|
1471
|
+
options?: {
|
|
1472
|
+
mergeMethod?: PullRequestMergeMethod;
|
|
1473
|
+
isPAT?: boolean;
|
|
1474
|
+
baseUrl?: string;
|
|
1475
|
+
},
|
|
1476
|
+
): Promise<boolean> {
|
|
1477
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1478
|
+
tokenOptInfo,
|
|
1479
|
+
'mergePullRequestFn',
|
|
1480
|
+
);
|
|
1481
|
+
const token = tokenWithInfo.accessToken;
|
|
1482
|
+
const headRef = pr.refs?.head;
|
|
1483
|
+
if (headRef == null) return false;
|
|
1484
|
+
|
|
1485
|
+
if (provider.id === GitCloudHostIntegrationId.AzureDevOps && pr.project == null) {
|
|
1486
|
+
return false;
|
|
1487
|
+
}
|
|
1488
|
+
|
|
1489
|
+
try {
|
|
1490
|
+
await provider.mergePullRequestFn?.(
|
|
1491
|
+
{
|
|
1492
|
+
pullRequest: {
|
|
1493
|
+
headRef: { oid: headRef.sha },
|
|
1494
|
+
id: pr.id,
|
|
1495
|
+
number: Number.parseInt(pr.id, 10),
|
|
1496
|
+
repository: {
|
|
1497
|
+
id: pr.repository.repo,
|
|
1498
|
+
name: pr.repository.repo,
|
|
1499
|
+
project: pr.project?.name ?? '',
|
|
1500
|
+
owner: {
|
|
1501
|
+
login: pr.repository.owner,
|
|
1502
|
+
},
|
|
1503
|
+
},
|
|
1504
|
+
version: pr.version,
|
|
1505
|
+
},
|
|
1506
|
+
...options,
|
|
1507
|
+
},
|
|
1508
|
+
{ token: token, isPAT: options?.isPAT, baseUrl: options?.baseUrl },
|
|
1509
|
+
);
|
|
1510
|
+
return true;
|
|
1511
|
+
} catch (e) {
|
|
1512
|
+
return this.handleProviderError<boolean>(tokenWithInfo, e);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
async getIssuesForRepos(
|
|
1517
|
+
tokenOptInfo: TokenOptInfo,
|
|
1518
|
+
reposOrIds: ProviderReposInput,
|
|
1519
|
+
options?: GetIssuesOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1520
|
+
): Promise<PagedResult<ProviderIssue>> {
|
|
1521
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1522
|
+
tokenOptInfo,
|
|
1523
|
+
'getIssuesForReposFn',
|
|
1524
|
+
);
|
|
1525
|
+
|
|
1526
|
+
return this.getPagedResult<ProviderIssue>(
|
|
1527
|
+
{
|
|
1528
|
+
...(this.isRepoIdsInput(reposOrIds) ? { repoIds: reposOrIds } : { repos: reposOrIds }),
|
|
1529
|
+
...options,
|
|
1530
|
+
},
|
|
1531
|
+
provider.getIssuesForReposFn,
|
|
1532
|
+
tokenWithInfo,
|
|
1533
|
+
options?.cursor,
|
|
1534
|
+
options?.isPAT,
|
|
1535
|
+
options?.baseUrl,
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
async getIssuesForRepo(
|
|
1540
|
+
tokenOptInfo: TokenOptInfo,
|
|
1541
|
+
repo: ProviderRepoInput,
|
|
1542
|
+
options?: GetIssuesOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1543
|
+
): Promise<PagedResult<ProviderIssue>> {
|
|
1544
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1545
|
+
tokenOptInfo,
|
|
1546
|
+
'getIssuesForRepoFn',
|
|
1547
|
+
);
|
|
1548
|
+
|
|
1549
|
+
return this.getPagedResult<ProviderIssue>(
|
|
1550
|
+
{ repo: repo, ...options },
|
|
1551
|
+
provider.getIssuesForRepoFn,
|
|
1552
|
+
tokenWithInfo,
|
|
1553
|
+
options?.cursor,
|
|
1554
|
+
options?.isPAT,
|
|
1555
|
+
options?.baseUrl,
|
|
1556
|
+
);
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
async getIssuesForCurrentUser(
|
|
1560
|
+
tokenOptInfo: TokenWithInfo,
|
|
1561
|
+
options?: PagingInput & {
|
|
1562
|
+
// Forwarded to the provider fn (GitLab's account-wide REST read); Linear ignores them.
|
|
1563
|
+
scope?: 'assigned_to_me' | 'all';
|
|
1564
|
+
assigneeUsername?: string;
|
|
1565
|
+
/**
|
|
1566
|
+
* Narrows to issues authored by this user. Honored as of `@gitkraken/provider-apis` 0.54.0
|
|
1567
|
+
* (`author_username`); it composes with `assigneeUsername` as AND, so a caller wanting the UNION of the
|
|
1568
|
+
* two relationships must read each separately (see GitLab's account-wide issue read).
|
|
1569
|
+
*/
|
|
1570
|
+
authorUsername?: string;
|
|
1571
|
+
pageSize?: number;
|
|
1572
|
+
isPAT?: boolean;
|
|
1573
|
+
baseUrl?: string;
|
|
1574
|
+
},
|
|
1575
|
+
): Promise<PagedResult<ProviderIssue>> {
|
|
1576
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1577
|
+
tokenOptInfo,
|
|
1578
|
+
'getIssuesForCurrentUserFn',
|
|
1579
|
+
);
|
|
1580
|
+
return this.getPagedResult<ProviderIssue>(
|
|
1581
|
+
{
|
|
1582
|
+
scope: options?.scope,
|
|
1583
|
+
assigneeUsername: options?.assigneeUsername,
|
|
1584
|
+
authorUsername: options?.authorUsername,
|
|
1585
|
+
page: options?.page,
|
|
1586
|
+
pageSize: options?.pageSize,
|
|
1587
|
+
},
|
|
1588
|
+
provider.getIssuesForCurrentUserFn,
|
|
1589
|
+
tokenWithInfo,
|
|
1590
|
+
options?.cursor ?? undefined,
|
|
1591
|
+
options?.isPAT,
|
|
1592
|
+
options?.baseUrl,
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
async getIssuesForAzureProject(
|
|
1597
|
+
tokenOptInfo: TokenOptInfo<
|
|
1598
|
+
GitCloudHostIntegrationId.AzureDevOps | GitSelfManagedHostIntegrationId.AzureDevOpsServer
|
|
1599
|
+
>,
|
|
1600
|
+
namespace: string,
|
|
1601
|
+
project: string,
|
|
1602
|
+
options?: GetIssuesOptions & { isPAT?: boolean; baseUrl?: string },
|
|
1603
|
+
): Promise<PagedResult<ProviderIssue>> {
|
|
1604
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1605
|
+
tokenOptInfo,
|
|
1606
|
+
'getIssuesForAzureProjectFn',
|
|
1607
|
+
);
|
|
1608
|
+
|
|
1609
|
+
return this.getPagedResult<ProviderIssue>(
|
|
1610
|
+
{ namespace: namespace, project: project, ...options },
|
|
1611
|
+
provider.getIssuesForAzureProjectFn,
|
|
1612
|
+
tokenWithInfo,
|
|
1613
|
+
options?.cursor,
|
|
1614
|
+
options?.isPAT,
|
|
1615
|
+
options?.baseUrl,
|
|
1616
|
+
);
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
async getIssuesForProject(
|
|
1620
|
+
tokenOptInfo: TokenWithInfo,
|
|
1621
|
+
project: string,
|
|
1622
|
+
resourceId: string,
|
|
1623
|
+
options?: GetIssuesOptions,
|
|
1624
|
+
): Promise<ProviderIssue[] | undefined> {
|
|
1625
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1626
|
+
tokenOptInfo,
|
|
1627
|
+
'getIssuesForProjectFn',
|
|
1628
|
+
);
|
|
1629
|
+
const token = tokenWithInfo.accessToken;
|
|
1630
|
+
|
|
1631
|
+
try {
|
|
1632
|
+
const result = await provider.getIssuesForProjectFn?.(
|
|
1633
|
+
{ projectKey: project, resourceId: resourceId, ...options },
|
|
1634
|
+
{ token: token },
|
|
1635
|
+
);
|
|
1636
|
+
|
|
1637
|
+
return result?.data;
|
|
1638
|
+
} catch (e) {
|
|
1639
|
+
return this.handleProviderError<ProviderIssue[] | undefined>(tokenWithInfo, e);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Single page of {@link getIssuesForProject} that preserves the SDK's `pageInfo` so a caller can drain
|
|
1645
|
+
* every page (the plain {@link getIssuesForProject} discards it, silently capping at the first page).
|
|
1646
|
+
* `nextCursor` is the raw provider cursor (Jira offset / nextPageToken) fed back verbatim as `options.cursor`.
|
|
1647
|
+
*/
|
|
1648
|
+
async getIssuesForProjectPaged(
|
|
1649
|
+
tokenOptInfo: TokenWithInfo,
|
|
1650
|
+
project: string,
|
|
1651
|
+
resourceId: string,
|
|
1652
|
+
options?: GetIssuesOptions,
|
|
1653
|
+
): Promise<{ data: ProviderIssue[]; hasMore: boolean; nextCursor: string | undefined } | undefined> {
|
|
1654
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1655
|
+
tokenOptInfo,
|
|
1656
|
+
'getIssuesForProjectFn',
|
|
1657
|
+
);
|
|
1658
|
+
const token = tokenWithInfo.accessToken;
|
|
1659
|
+
|
|
1660
|
+
try {
|
|
1661
|
+
const result = await provider.getIssuesForProjectFn?.(
|
|
1662
|
+
{ projectKey: project, resourceId: resourceId, ...options },
|
|
1663
|
+
{ token: token },
|
|
1664
|
+
);
|
|
1665
|
+
if (result == null) return undefined;
|
|
1666
|
+
return {
|
|
1667
|
+
data: result.data,
|
|
1668
|
+
hasMore: result.pageInfo?.hasNextPage ?? false,
|
|
1669
|
+
nextCursor: result.pageInfo?.endCursor ?? undefined,
|
|
1670
|
+
};
|
|
1671
|
+
} catch (e) {
|
|
1672
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
async getTrelloCard(
|
|
1677
|
+
tokenOptInfo: TokenWithInfo<IssuesCloudHostIntegrationId.Trello>,
|
|
1678
|
+
appKey: string,
|
|
1679
|
+
cardId: string,
|
|
1680
|
+
options?: { trelloBoardListsById?: Record<string, { name: string }> },
|
|
1681
|
+
): Promise<ProviderIssue | undefined> {
|
|
1682
|
+
const { tokenWithInfo } = await this.ensureProviderToken(tokenOptInfo);
|
|
1683
|
+
|
|
1684
|
+
try {
|
|
1685
|
+
const result = await this.request<TrelloCardResponse>({
|
|
1686
|
+
url: `${trelloBaseUrl}/1/cards/${encodeURIComponent(cardId)}?members=true`,
|
|
1687
|
+
headers: getTrelloAuthHeaders(appKey, tokenWithInfo.accessToken),
|
|
1688
|
+
});
|
|
1689
|
+
|
|
1690
|
+
return fromTrelloCard(result.body, options?.trelloBoardListsById ?? {});
|
|
1691
|
+
} catch (e) {
|
|
1692
|
+
try {
|
|
1693
|
+
return this.handleProviderError<ProviderIssue | undefined>(tokenWithInfo, e);
|
|
1694
|
+
} catch (ex) {
|
|
1695
|
+
if (RequestNotFoundError.is(ex)) return undefined;
|
|
1696
|
+
throw ex;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
// Trello reads. The Trello client is keyed by an `appKey` (the Trello app key from the cloud token exchange)
|
|
1702
|
+
// paired with the OAuth token, so each wrapper threads `appKey` through alongside `tokenWithInfo`.
|
|
1703
|
+
async getTrelloCurrentUser(
|
|
1704
|
+
tokenOptInfo: TokenWithInfo,
|
|
1705
|
+
appKey: string,
|
|
1706
|
+
): Promise<
|
|
1707
|
+
{ id: string; name: string; email: string; username: string; url: string; avatarUrl: string | null } | undefined
|
|
1708
|
+
> {
|
|
1709
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1710
|
+
tokenOptInfo,
|
|
1711
|
+
'getTrelloCurrentUserFn',
|
|
1712
|
+
);
|
|
1713
|
+
try {
|
|
1714
|
+
const result = await provider.getTrelloCurrentUserFn?.(
|
|
1715
|
+
{ appKey: appKey },
|
|
1716
|
+
{ token: tokenWithInfo.accessToken },
|
|
1717
|
+
);
|
|
1718
|
+
return result?.data;
|
|
1719
|
+
} catch (e) {
|
|
1720
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
async getTrelloBoardsForCurrentUser(
|
|
1725
|
+
tokenOptInfo: TokenWithInfo,
|
|
1726
|
+
appKey: string,
|
|
1727
|
+
): Promise<TrelloBoard[] | undefined> {
|
|
1728
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1729
|
+
tokenOptInfo,
|
|
1730
|
+
'getTrelloBoardsForCurrentUserFn',
|
|
1731
|
+
);
|
|
1732
|
+
try {
|
|
1733
|
+
const result = await provider.getTrelloBoardsForCurrentUserFn?.(
|
|
1734
|
+
{ appKey: appKey },
|
|
1735
|
+
{ token: tokenWithInfo.accessToken },
|
|
1736
|
+
);
|
|
1737
|
+
return result?.data;
|
|
1738
|
+
} catch (e) {
|
|
1739
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
async getTrelloListsForBoard(
|
|
1744
|
+
tokenOptInfo: TokenWithInfo,
|
|
1745
|
+
appKey: string,
|
|
1746
|
+
boardId: string,
|
|
1747
|
+
): Promise<TrelloList[] | undefined> {
|
|
1748
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1749
|
+
tokenOptInfo,
|
|
1750
|
+
'getTrelloListsForBoardFn',
|
|
1751
|
+
);
|
|
1752
|
+
try {
|
|
1753
|
+
const result = await provider.getTrelloListsForBoardFn?.(
|
|
1754
|
+
{ appKey: appKey, boardId: boardId },
|
|
1755
|
+
{ token: tokenWithInfo.accessToken },
|
|
1756
|
+
);
|
|
1757
|
+
return result?.data;
|
|
1758
|
+
} catch (e) {
|
|
1759
|
+
return this.handleProviderError(tokenWithInfo, e);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
async getTrelloIssuesForBoard(
|
|
1764
|
+
tokenOptInfo: TokenWithInfo,
|
|
1765
|
+
appKey: string,
|
|
1766
|
+
boardId: string,
|
|
1767
|
+
options?: { assigneeLogins?: string[]; trelloBoardListsById?: Record<string, { name: string }> },
|
|
1768
|
+
): Promise<ProviderApiCollectionResult<ProviderIssue>> {
|
|
1769
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1770
|
+
tokenOptInfo,
|
|
1771
|
+
'getTrelloIssuesForBoardFn',
|
|
1772
|
+
);
|
|
1773
|
+
try {
|
|
1774
|
+
const result = await provider.getTrelloIssuesForBoardFn?.(
|
|
1775
|
+
{ appKey: appKey, boardId: boardId, ...options },
|
|
1776
|
+
{ token: tokenWithInfo.accessToken },
|
|
1777
|
+
);
|
|
1778
|
+
// Trello's search caps results and reports the cap through `metadata.completeness` (never a cursor).
|
|
1779
|
+
// Preserve it so the integration can signal a terminal truncation rather than a fake next page.
|
|
1780
|
+
return { values: result?.data ?? [], metadata: result?.metadata };
|
|
1781
|
+
} catch (e) {
|
|
1782
|
+
return this.handleProviderError<ProviderApiCollectionResult<ProviderIssue>>(tokenWithInfo, e);
|
|
1783
|
+
}
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
async getIssuesForResourceForCurrentUser(
|
|
1787
|
+
tokenOptInfo: TokenWithInfo,
|
|
1788
|
+
resourceId: string,
|
|
1789
|
+
options?: { cursor?: string; isPAT?: boolean; baseUrl?: string },
|
|
1790
|
+
): Promise<PagedResult<ProviderIssue>> {
|
|
1791
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(
|
|
1792
|
+
tokenOptInfo,
|
|
1793
|
+
'getIssuesForResourceForCurrentUserFn',
|
|
1794
|
+
);
|
|
1795
|
+
|
|
1796
|
+
return this.getPagedResult<ProviderIssue>(
|
|
1797
|
+
{ resourceId: resourceId },
|
|
1798
|
+
provider.getIssuesForResourceForCurrentUserFn,
|
|
1799
|
+
tokenWithInfo,
|
|
1800
|
+
options?.cursor,
|
|
1801
|
+
options?.isPAT,
|
|
1802
|
+
options?.baseUrl,
|
|
1803
|
+
);
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
async getIssue(
|
|
1807
|
+
tokenOptInfo: TokenWithInfo,
|
|
1808
|
+
input: { resourceId: string; number: string } | { namespace: string; name: string; number: string },
|
|
1809
|
+
options?: { isPAT?: boolean; baseUrl?: string },
|
|
1810
|
+
): Promise<ProviderIssue | undefined> {
|
|
1811
|
+
const { provider, tokenWithInfo } = await this.ensureProviderTokenAndFunction(tokenOptInfo, 'getIssueFn');
|
|
1812
|
+
const token = tokenWithInfo.accessToken;
|
|
1813
|
+
|
|
1814
|
+
try {
|
|
1815
|
+
const result = await provider.getIssueFn?.(input, {
|
|
1816
|
+
token: token,
|
|
1817
|
+
isPAT: options?.isPAT,
|
|
1818
|
+
baseUrl: options?.baseUrl,
|
|
1819
|
+
});
|
|
1820
|
+
|
|
1821
|
+
return result?.data;
|
|
1822
|
+
} catch (e) {
|
|
1823
|
+
return this.handleProviderError<ProviderIssue | undefined>(tokenWithInfo, e);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
// This is copied over from the shared provider library because the current version is not respecting the "forceIsFetch: true"
|
|
1829
|
+
// option in the config and our custom fetch function isn't being wrapped by the necessary fetch wrapper. Remove this once the library
|
|
1830
|
+
// properly wraps our custom fetch and use `forceIsFetch: true` in the config.
|
|
1831
|
+
async function parseFetchResponseForApi<T>(response: Response): Promise<ProviderRequestResponse<T>> {
|
|
1832
|
+
const contentType = response.headers.get('content-type') || '';
|
|
1833
|
+
let body;
|
|
1834
|
+
|
|
1835
|
+
// parse the response body
|
|
1836
|
+
if (contentType.startsWith('application/json')) {
|
|
1837
|
+
const text = await response.text();
|
|
1838
|
+
body = text.trim().length > 0 ? JSON.parse(text) : null;
|
|
1839
|
+
} else if (contentType.startsWith('text/') || contentType === '') {
|
|
1840
|
+
body = await response.text();
|
|
1841
|
+
} else if (contentType.startsWith('application/vnd.github.raw+json')) {
|
|
1842
|
+
body = await response.arrayBuffer();
|
|
1843
|
+
} else {
|
|
1844
|
+
throw new Error(`Unsupported content-type: ${contentType}`);
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
const result = {
|
|
1848
|
+
body: body,
|
|
1849
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
1850
|
+
status: response.status,
|
|
1851
|
+
statusText: response.statusText,
|
|
1852
|
+
};
|
|
1853
|
+
|
|
1854
|
+
// throw an error if the response is not ok
|
|
1855
|
+
if (!response.ok) {
|
|
1856
|
+
const status = `(${response.status})${response.statusText ? ` ${response.statusText}` : ''}.`;
|
|
1857
|
+
const detail = getProviderResponseBodyMessage(body);
|
|
1858
|
+
const error = new Error(detail != null ? `${status} ${detail}` : status);
|
|
1859
|
+
Object.assign(error, { response: result });
|
|
1860
|
+
throw error;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
return result;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
const maxProviderErrorBodyLength = 500;
|
|
1867
|
+
|
|
1868
|
+
/** Extracts the useful provider prose from an already-parsed SDK response body. */
|
|
1869
|
+
function getProviderResponseBodyMessage(body: unknown): string | undefined {
|
|
1870
|
+
let message: string | undefined;
|
|
1871
|
+
if (typeof body === 'string') {
|
|
1872
|
+
message = body;
|
|
1873
|
+
} else if (body != null && typeof body === 'object') {
|
|
1874
|
+
const { message: direct, error } = body as { message?: unknown; error?: unknown };
|
|
1875
|
+
if (typeof direct === 'string') {
|
|
1876
|
+
message = direct;
|
|
1877
|
+
} else if (typeof error === 'string') {
|
|
1878
|
+
message = error;
|
|
1879
|
+
} else if (error != null && typeof error === 'object') {
|
|
1880
|
+
const nested = (error as { message?: unknown }).message;
|
|
1881
|
+
if (typeof nested === 'string') {
|
|
1882
|
+
message = nested;
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
|
|
1887
|
+
message = message?.trim();
|
|
1888
|
+
return message ? message.slice(0, maxProviderErrorBodyLength) : undefined;
|
|
1889
|
+
}
|