@gitkraken/provider-apis 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +1 -78
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,78 +1 @@
|
|
|
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)
|
|
1
|
+
# @gitkraken/provider-apis
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/provider-apis",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.6.2",
|
|
4
|
+
"description": "An SDK around different third-party APIs that accepts and returns data in a common format.",
|
|
5
5
|
"author": "Axosoft, LLC dba GitKraken",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
7
7
|
"engines": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "yarn clean && node ./scripts/build.mjs && tsc",
|
|
17
|
-
"build-docs": "typedoc
|
|
17
|
+
"build-docs": "typedoc",
|
|
18
18
|
"ci": "yarn lint:ci && yarn prettier:ci && yarn build && yarn test",
|
|
19
19
|
"clean": "rimraf dist",
|
|
20
20
|
"lint": "eslint src test --fix",
|