@gitkraken/provider-apis 0.6.1
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 +112 -0
- package/LICENSE +19 -0
- package/README.md +78 -0
- package/dist/defaults.d.ts +6 -0
- package/dist/fetchWrapper.d.ts +2 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +552 -0
- package/dist/providers/azureDevops/azureDevOps.d.ts +116 -0
- package/dist/providers/azureDevops/azureDevOpsHelpers.d.ts +3 -0
- package/dist/providers/azureDevops/azureDevOpsTypes.d.ts +198 -0
- package/dist/providers/bitbucket/bitbucket.d.ts +107 -0
- package/dist/providers/bitbucket/bitbucketHelpers.d.ts +3 -0
- package/dist/providers/bitbucket/bitbucketTypes.d.ts +181 -0
- package/dist/providers/gitProvider.d.ts +166 -0
- package/dist/providers/github/github.d.ts +122 -0
- package/dist/providers/github/githubHelpers.d.ts +19 -0
- package/dist/providers/github/githubTypes.d.ts +159 -0
- package/dist/providers/gitlab/gitlab.d.ts +157 -0
- package/dist/providers/gitlab/gitlabHelpers.d.ts +4 -0
- package/dist/providers/gitlab/gitlabTypes.d.ts +33 -0
- package/dist/providers/issueProvider.d.ts +37 -0
- package/dist/providers/jira/jira.d.ts +14 -0
- package/dist/providers/provider.d.ts +6 -0
- package/dist/providers/trello/trello.d.ts +13 -0
- package/dist/types.d.ts +76 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +59 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
- fixed filtering by `authorLogin` in `getPullRequestsForRepo` and `getPullRequestsForRepos` (Bitbucket)
|
|
6
|
+
|
|
7
|
+
## 0.6.0
|
|
8
|
+
|
|
9
|
+
- added `getBlame` (Github and GitLab)
|
|
10
|
+
- added `getReposForAzureProject` (Azure DevOps)
|
|
11
|
+
- added `getPullRequestsForRepo` (GitLab, Bitbucket, and Azure DevOps)
|
|
12
|
+
- added `getIssuesForRepo` (GitLab)
|
|
13
|
+
- added paging support to the following functions:
|
|
14
|
+
- `getPullRequestsForRepos` (GitHub, GitLab and Azure DevOps)
|
|
15
|
+
- `getIssuesForRepos` (GitHub and GitLab)
|
|
16
|
+
- `getIssuesForAzureProject` (Azure DevOps)
|
|
17
|
+
- added `permission` field to `GitRepository` (GitHub only)
|
|
18
|
+
- fixed incorrect `namespace` field in GitLab `GitRepository` objects
|
|
19
|
+
- changed the type of the `number` field in `GitPullRequest` from `string` to `number`
|
|
20
|
+
|
|
21
|
+
## 0.5.0
|
|
22
|
+
|
|
23
|
+
- added `namespace` and `project` fields to `GitRepository` type
|
|
24
|
+
|
|
25
|
+
### ⚠️ Breaking Changes
|
|
26
|
+
|
|
27
|
+
- ## All functions now return an object with a `data` property. Functions affected:
|
|
28
|
+
- `getCurrentUser`
|
|
29
|
+
- `getCurrentUserForInstance` (Azure DevOps)
|
|
30
|
+
- `getUserForCommit`
|
|
31
|
+
- `getAccountForEmail`
|
|
32
|
+
- `getAccountForUsername`
|
|
33
|
+
- `getRepo`
|
|
34
|
+
- `getIssue` (GitLab)
|
|
35
|
+
- `refreshToken` (Bitbucket)
|
|
36
|
+
|
|
37
|
+
## 0.4.0
|
|
38
|
+
|
|
39
|
+
### Providers
|
|
40
|
+
|
|
41
|
+
- added Jira as a supported provider
|
|
42
|
+
- added Trello as a supported provider
|
|
43
|
+
|
|
44
|
+
### Functions
|
|
45
|
+
|
|
46
|
+
- added `getIssuesForProject` for Jira
|
|
47
|
+
- added `getIssuesForBoard` for Trello
|
|
48
|
+
- added `getCurrentUser` for all git providers
|
|
49
|
+
- added `getBranches` for all git providers
|
|
50
|
+
- added `getTags` for all git providers
|
|
51
|
+
- added `updateConfig` for all providers, to allow updating the base config
|
|
52
|
+
- added filtering options to `getPullRequestsForRepos` for GitLab
|
|
53
|
+
- added filtering options to `getIssuesForRepos` for GitLab
|
|
54
|
+
- better `avatarUrl` support for GitHub Enterprise
|
|
55
|
+
|
|
56
|
+
### Return Types
|
|
57
|
+
|
|
58
|
+
- added `baseRef` (target branch) to the `GitPullRequest` type
|
|
59
|
+
- GitHub user objects now include `email` if the provided token has the scope needed to obtain it
|
|
60
|
+
|
|
61
|
+
### Config / Options
|
|
62
|
+
|
|
63
|
+
- added `config.isPat` and `options.isPat` for better Bitbucket and Azure DevOps support
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
- fixed GitLab `getPullRequestsForRepos` always returning an empty array
|
|
68
|
+
- fixed Bitbucket `getUserForCommit` throwing an error if the commit author doesn't have an associated Bitbucket account
|
|
69
|
+
|
|
70
|
+
### ⚠️ Breaking Changes
|
|
71
|
+
|
|
72
|
+
- Changed the return type of the following functions from an array to an object:
|
|
73
|
+
- `getRepos` (all git providers)
|
|
74
|
+
- `getPullRequestsForRepos` (all git providers)
|
|
75
|
+
- `getIssuesForRepos` (GitHub and GitLab)
|
|
76
|
+
- `getIssuesForAzureProject` (Azure DevOps)
|
|
77
|
+
- `getUserForCommit`: renamed the input field `sha` to `oid`
|
|
78
|
+
- `config.request`'s options now uses `body: string` instead of `data: any`
|
|
79
|
+
|
|
80
|
+
## 0.3.0
|
|
81
|
+
|
|
82
|
+
- added support for `fetch`-like request functions
|
|
83
|
+
- replaced `axios.request` as the default request function. native `fetch` will be used if available, otherwise `node-fetch` will be used.
|
|
84
|
+
- allow `baseUrl` option to be set in the GitProvider constructor
|
|
85
|
+
- added `defaultBranch` to `GitRepository` interface
|
|
86
|
+
- temporarily disabled `email` field for GitHub objects
|
|
87
|
+
- added `getBranches`
|
|
88
|
+
- added `getIssue` for GitLab
|
|
89
|
+
- added `getIssuesForRepos` for GitHub and GitLab
|
|
90
|
+
- added `getIssuesForAzureProject` for Azure DevOps
|
|
91
|
+
- fixed GitHub Enterprise functions
|
|
92
|
+
|
|
93
|
+
## 0.2.0
|
|
94
|
+
|
|
95
|
+
- added ability to pass provider tokens to GitProvider constructors as an alternative to passing them to every function call
|
|
96
|
+
- all GitHub functions now support the `baseUrl` option
|
|
97
|
+
- added `getAccountForUsername` (GitHub and GitLab only)
|
|
98
|
+
- fixed a bug affecting multiple GitLab functions
|
|
99
|
+
|
|
100
|
+
BREAKING:
|
|
101
|
+
|
|
102
|
+
- updated parameters for `getUserForCommit`
|
|
103
|
+
- replaced `getUserForEmail` with `getAccountForEmail`
|
|
104
|
+
|
|
105
|
+
## 0.1.0
|
|
106
|
+
|
|
107
|
+
- support for GitHub, GitLab, Bitbucket, Azure DevOps
|
|
108
|
+
- added `getUserForCommit`
|
|
109
|
+
- added `getUserForEmail` (GitHub and GitLab only)
|
|
110
|
+
- added `getRepo`
|
|
111
|
+
- added `getRepos`
|
|
112
|
+
- added `getPullRequestsForRepos`
|
package/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Provider APIs License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014-2023 Axosoft, LLC dba GitKraken ("GitKraken")
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") may be compiled as part of the gitkraken/vscode-gitlens open source project (the "GitLens") to the extent the Software is a required component of the GitLens; provided, however, that the Software and its functionality may only be used if you (and any entity that you represent) have agreed to, and are in compliance with, the GitKraken End User License Agreement, available at https://gitkraken.com/eula (the "EULA"), or other agreement governing the use of the Software, as agreed by you and GitKraken, and otherwise have a valid subscription for the correct number of user seats for the applicable version of the Software (e.g., GitLens Free+, GitLens Pro, GitLens Teams, and GitLens Enterprise) (the “GitKraken Products”).
|
|
6
|
+
|
|
7
|
+
The Software is licensed, not sold. This license only gives you some rights to use the Software. GitKraken reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the Software only as expressly permitted in this license. In doing so, you must comply with any technical limitations in the Software that only allow you to use it in certain ways. You may not (i) work around any technical limitations in the Software, (ii) reverse engineer, decompile or disassemble the Software, or otherwise attempt to derive the source code for the Software, except and to the extent required by third party licensing terms governing use of certain open source components that may be included with the Software, (iii) remove, minimize, block or modify any notices of GitKraken or its suppliers in the Software, (iv) use the software in any way that is against the law, (v) host, share, publish, rent or lease the Software; (vi) distribute the Software as a stand-alone or integrated offering or combine it with any of your applications for others to use, (vii) use the Software other than in connection with validly licensed GitKraken Products or (viii) use any portion of the Software to create software with the same or similar functionality.
|
|
8
|
+
|
|
9
|
+
You agree that GitKraken and/or its licensors (as applicable) retain all right, title and interest in and to the Software and all modifications and/or patches thereto. You are not granted any other rights beyond what is expressly stated herein. Except as set forth above, it is forbidden to copy, merge, publish, distribute, sublicense, modify and/or sell the Software.
|
|
10
|
+
|
|
11
|
+
If you give feedback about the Software to GitKraken, you give to GitKraken, without charge, the right to use, share and commercialize your feedback in any way and for any purpose. You will not give feedback that is subject to a license that requires GitKraken to license its software or documentation to third parties because we include your feedback in them. These rights survive this License.
|
|
12
|
+
|
|
13
|
+
The full text of this Provider APIs License shall be included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
This License and the EULA, if applicable, are the entire agreement for the Software. You must comply with all domestic and international export laws and regulations that apply to the Software, which include restrictions on destinations, end users and end use. This License is governed and construed by the laws of the State of Arizona, United States without regard to any choice or conflict of law principles or rules.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL GITKRAKEN, THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
|
|
19
|
+
For all third party components incorporated into the Software, those components are licensed under the original license provided by the owner of the applicable component.
|
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# provider-apis
|
|
2
|
+
|
|
3
|
+
[View documenation](/docs/modules.md#default)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @@gitkraken/provider-apis
|
|
9
|
+
or
|
|
10
|
+
yarn add @@gitkraken/provider-apis
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Usage
|
|
14
|
+
|
|
15
|
+
Creating an instance of every provider
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import ProviderAPIs from '@@gitkraken/provider-apis';
|
|
19
|
+
|
|
20
|
+
const providerAPIs = ProviderAPIs(config); // returns an object containing an instance of each provider
|
|
21
|
+
|
|
22
|
+
const repo = await providerAPIs.github.getRepo({ namespace: 'gitkraken', name: 'vscode-gitlens' }, { token: TOKEN });
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Creating an instance of a specific provider
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { GitHub } from 'provider-apis';
|
|
29
|
+
|
|
30
|
+
const github = new GitHub(config);
|
|
31
|
+
const repo = await github.getRepo({ namespace: 'gitkraken', name: 'vscode-gitlens' }, { token: TOKEN });
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Authentication
|
|
35
|
+
|
|
36
|
+
Tokens can be supplied either at construction time or when calling a function. (A token supplied to a function will take priority over one supplied at construction time).
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const providerAPIs = ProviderAPIS({
|
|
40
|
+
github: { token: GITHUB_TOKEN },
|
|
41
|
+
gitlab: { token: GITLAB_TOKEN },
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// OR
|
|
45
|
+
|
|
46
|
+
const github = new GitHub({ token: GITHUB_TOKEN });
|
|
47
|
+
|
|
48
|
+
// OR
|
|
49
|
+
|
|
50
|
+
const repo = await github.getRepo({ namespace: 'gitkraken', name: 'vscode-gitlens' }, { token: TOKEN });
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Overwriting the request function
|
|
54
|
+
|
|
55
|
+
This package allows you to overwrite the function used to make network requests. The function should must either implement `fetch` OR have the following signature:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
(options: { url: string; method?: string; body?: string; headers?: object }) =>
|
|
59
|
+
Promise<{
|
|
60
|
+
status: number;
|
|
61
|
+
statusText: string;
|
|
62
|
+
headers: object;
|
|
63
|
+
body: any;
|
|
64
|
+
}>;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
const github = new GitHub({ request: customRequestFn });
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Configuration
|
|
72
|
+
|
|
73
|
+
All configuration options are optional. All options can be provided either at object creation time or when calling a function as the function's last parameter, with the exception of `request`, which can only be provided at object creation time.
|
|
74
|
+
|
|
75
|
+
- `request`: The function to use to make network requests
|
|
76
|
+
- `[provider].baseUrl`: The base API endpoint to use (meant for Enterprise support)
|
|
77
|
+
- `[provider].token`: The authentication token to be sent with the request
|
|
78
|
+
- `[provider].isPAT`: Whether or not the provided token is a PAT (as opposed to an OAuth token)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AzureDevOps } from './providers/azureDevops/azureDevOps';
|
|
2
|
+
import { Bitbucket } from './providers/bitbucket/bitbucket';
|
|
3
|
+
import { GitHub } from './providers/github/github';
|
|
4
|
+
import { GitLab } from './providers/gitlab/gitlab';
|
|
5
|
+
import { Jira } from './providers/jira/jira';
|
|
6
|
+
import { Trello } from './providers/trello/trello';
|
|
7
|
+
import { Config } from './types';
|
|
8
|
+
declare const makeProviderAPIs: (config?: Partial<Config>) => {
|
|
9
|
+
azureDevOps: AzureDevOps;
|
|
10
|
+
bitbucket: Bitbucket;
|
|
11
|
+
github: GitHub;
|
|
12
|
+
gitlab: GitLab;
|
|
13
|
+
jira: Jira;
|
|
14
|
+
trello: Trello;
|
|
15
|
+
};
|
|
16
|
+
export default makeProviderAPIs;
|
|
17
|
+
export { AzureDevOps, Bitbucket, GitHub, GitLab };
|
|
18
|
+
export type * from './providers/azureDevops/azureDevOps';
|
|
19
|
+
export type * from './providers/bitbucket/bitbucket';
|
|
20
|
+
export type * from './providers/gitProvider';
|
|
21
|
+
export type * from './providers/github/github';
|
|
22
|
+
export type { FetchIssuesData, FetchPullRequestsData } from './providers/github/githubTypes';
|
|
23
|
+
export type * from './providers/gitlab/gitlab';
|
|
24
|
+
export type * from './providers/issueProvider';
|
|
25
|
+
export type * from './providers/jira/jira';
|
|
26
|
+
export type * from './providers/trello/trello';
|
|
27
|
+
export type * from './types';
|