Added the node modules.
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 33s
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 33s
This commit is contained in:
21
node_modules/@octokit/auth-token/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/auth-token/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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 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.
|
290
node_modules/@octokit/auth-token/README.md
generated
vendored
Normal file
290
node_modules/@octokit/auth-token/README.md
generated
vendored
Normal file
@ -0,0 +1,290 @@
|
||||
# auth-token.js
|
||||
|
||||
> GitHub API token authentication for browsers and Node.js
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/auth-token)
|
||||
[](https://github.com/octokit/auth-token.js/actions?query=workflow%3ATest)
|
||||
|
||||
`@octokit/auth-token` is the simplest of [GitHub’s authentication strategies](https://github.com/octokit/auth.js).
|
||||
|
||||
It is useful if you want to support multiple authentication strategies, as it’s API is compatible with its sibling packages for [basic](https://github.com/octokit/auth-basic.js), [GitHub App](https://github.com/octokit/auth-app.js) and [OAuth app](https://github.com/octokit/auth.js) authentication.
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [`createTokenAuth(token) options`](#createtokenauthtoken-options)
|
||||
- [`auth()`](#auth)
|
||||
- [Authentication object](#authentication-object)
|
||||
- [`auth.hook(request, route, options)` or `auth.hook(request, options)`](#authhookrequest-route-options-or-authhookrequest-options)
|
||||
- [Find more information](#find-more-information)
|
||||
- [Find out what scopes are enabled for oauth tokens](#find-out-what-scopes-are-enabled-for-oauth-tokens)
|
||||
- [Find out if token is a personal access token or if it belongs to an OAuth app](#find-out-if-token-is-a-personal-access-token-or-if-it-belongs-to-an-oauth-app)
|
||||
- [Find out what permissions are enabled for a repository](#find-out-what-permissions-are-enabled-for-a-repository)
|
||||
- [Use token for git operations](#use-token-for-git-operations)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/auth-token` directly from [cdn.skypack.dev](https://cdn.skypack.dev)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { createTokenAuth } from "https://cdn.skypack.dev/@octokit/auth-token";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/auth-token</code>
|
||||
|
||||
```js
|
||||
const { createTokenAuth } = require("@octokit/auth-token");
|
||||
// or: import { createTokenAuth } from "@octokit/auth-token";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
```js
|
||||
const auth = createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
||||
const authentication = await auth();
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghp_PersonalAccessToken01245678900000000',
|
||||
// tokenType: 'oauth'
|
||||
// }
|
||||
```
|
||||
|
||||
## `createTokenAuth(token) options`
|
||||
|
||||
The `createTokenAuth` method accepts a single argument of type string, which is the token. The passed token can be one of the following:
|
||||
|
||||
- [Personal access token](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line)
|
||||
- [OAuth access token](https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/)
|
||||
- [GITHUB_TOKEN provided to GitHub Actions](https://developer.github.com/actions/creating-github-actions/accessing-the-runtime-environment/#environment-variables)
|
||||
- Installation access token ([server-to-server](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation))
|
||||
- User authentication for installation ([user-to-server](https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps))
|
||||
|
||||
Examples
|
||||
|
||||
```js
|
||||
// Personal access token or OAuth access token
|
||||
createTokenAuth("ghp_PersonalAccessToken01245678900000000");
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghp_PersonalAccessToken01245678900000000',
|
||||
// tokenType: 'oauth'
|
||||
// }
|
||||
|
||||
// Installation access token or GitHub Action token
|
||||
createTokenAuth("ghs_InstallallationOrActionToken00000000");
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghs_InstallallationOrActionToken00000000',
|
||||
// tokenType: 'installation'
|
||||
// }
|
||||
|
||||
// Installation access token or GitHub Action token
|
||||
createTokenAuth("ghu_InstallationUserToServer000000000000");
|
||||
// {
|
||||
// type: 'token',
|
||||
// token: 'ghu_InstallationUserToServer000000000000',
|
||||
// tokenType: 'user-to-server'
|
||||
// }
|
||||
```
|
||||
|
||||
## `auth()`
|
||||
|
||||
The `auth()` method has no options. It returns a promise which resolves with the the authentication object.
|
||||
|
||||
## Authentication object
|
||||
|
||||
<table width="100%">
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th width=150>
|
||||
name
|
||||
</th>
|
||||
<th width=70>
|
||||
type
|
||||
</th>
|
||||
<th>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>type</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>"token"</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>token</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
The provided token.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>tokenType</code>
|
||||
</th>
|
||||
<th>
|
||||
<code>string</code>
|
||||
</th>
|
||||
<td>
|
||||
Can be either <code>"oauth"</code> for personal access tokens and OAuth tokens, <code>"installation"</code> for installation access tokens (includes <code>GITHUB_TOKEN</code> provided to GitHub Actions), <code>"app"</code> for a GitHub App JSON Web Token, or <code>"user-to-server"</code> for a user authentication token through an app installation.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## `auth.hook(request, route, options)` or `auth.hook(request, options)`
|
||||
|
||||
`auth.hook()` hooks directly into the request life cycle. It authenticates the request using the provided token.
|
||||
|
||||
The `request` option is an instance of [`@octokit/request`](https://github.com/octokit/request.js#readme). The `route`/`options` parameters are the same as for the [`request()` method](https://github.com/octokit/request.js#request).
|
||||
|
||||
`auth.hook()` can be called directly to send an authenticated request
|
||||
|
||||
```js
|
||||
const { data: authorizations } = await auth.hook(
|
||||
request,
|
||||
"GET /authorizations"
|
||||
);
|
||||
```
|
||||
|
||||
Or it can be passed as option to [`request()`](https://github.com/octokit/request.js#request).
|
||||
|
||||
```js
|
||||
const requestWithAuth = request.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
});
|
||||
|
||||
const { data: authorizations } = await requestWithAuth("GET /authorizations");
|
||||
```
|
||||
|
||||
## Find more information
|
||||
|
||||
`auth()` does not send any requests, it only transforms the provided token string into an authentication object.
|
||||
|
||||
Here is a list of things you can do to retrieve further information
|
||||
|
||||
### Find out what scopes are enabled for oauth tokens
|
||||
|
||||
Note that this does not work for installations. There is no way to retrieve permissions based on an installation access tokens.
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const authentication = await auth();
|
||||
|
||||
const response = await request("HEAD /", {
|
||||
headers: authentication.headers,
|
||||
});
|
||||
const scopes = response.headers["x-oauth-scopes"].split(/,\s+/);
|
||||
|
||||
if (scopes.length) {
|
||||
console.log(
|
||||
`"${TOKEN}" has ${scopes.length} scopes enabled: ${scopes.join(", ")}`
|
||||
);
|
||||
} else {
|
||||
console.log(`"${TOKEN}" has no scopes enabled`);
|
||||
}
|
||||
```
|
||||
|
||||
### Find out if token is a personal access token or if it belongs to an OAuth app
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const authentication = await auth();
|
||||
|
||||
const response = await request("HEAD /", {
|
||||
headers: authentication.headers,
|
||||
});
|
||||
const clientId = response.headers["x-oauth-client-id"];
|
||||
|
||||
if (clientId) {
|
||||
console.log(
|
||||
`"${token}" is an OAuth token, its app’s client_id is ${clientId}.`
|
||||
);
|
||||
} else {
|
||||
console.log(`"${token}" is a personal access token`);
|
||||
}
|
||||
```
|
||||
|
||||
### Find out what permissions are enabled for a repository
|
||||
|
||||
Note that the `permissions` key is not set when authenticated using an installation access token.
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const authentication = await auth();
|
||||
|
||||
const response = await request("GET /repos/{owner}/{repo}", {
|
||||
owner: 'octocat',
|
||||
repo: 'hello-world'
|
||||
headers: authentication.headers
|
||||
});
|
||||
|
||||
console.log(response.data.permissions)
|
||||
// {
|
||||
// admin: true,
|
||||
// push: true,
|
||||
// pull: true
|
||||
// }
|
||||
```
|
||||
|
||||
### Use token for git operations
|
||||
|
||||
Both OAuth and installation access tokens can be used for git operations. However, when using with an installation, [the token must be prefixed with `x-access-token`](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation).
|
||||
|
||||
This example is using the [`execa`](https://github.com/sindresorhus/execa) package to run a `git push` command.
|
||||
|
||||
```js
|
||||
const TOKEN = "ghp_PersonalAccessToken01245678900000000";
|
||||
|
||||
const auth = createTokenAuth(TOKEN);
|
||||
const { token, tokenType } = await auth();
|
||||
const tokenWithPrefix =
|
||||
tokenType === "installation" ? `x-access-token:${token}` : token;
|
||||
|
||||
const repositoryUrl = `https://${tokenWithPrefix}@github.com/octocat/hello-world.git`;
|
||||
|
||||
const { stdout } = await execa("git", ["push", repositoryUrl]);
|
||||
console.log(stdout);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
55
node_modules/@octokit/auth-token/dist-node/index.js
generated
vendored
Normal file
55
node_modules/@octokit/auth-token/dist-node/index.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
||||
const REGEX_IS_INSTALLATION = /^ghs_/;
|
||||
const REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
||||
async function auth(token) {
|
||||
const isApp = token.split(/\./).length === 3;
|
||||
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
|
||||
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
||||
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
||||
return {
|
||||
type: "token",
|
||||
token: token,
|
||||
tokenType
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix token for usage in the Authorization header
|
||||
*
|
||||
* @param token OAuth token or JSON Web Token
|
||||
*/
|
||||
function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
|
||||
return `token ${token}`;
|
||||
}
|
||||
|
||||
async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
const createTokenAuth = function createTokenAuth(token) {
|
||||
if (!token) {
|
||||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||||
}
|
||||
|
||||
if (typeof token !== "string") {
|
||||
throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
|
||||
}
|
||||
|
||||
token = token.replace(/^(token|bearer) +/i, "");
|
||||
return Object.assign(auth.bind(null, token), {
|
||||
hook: hook.bind(null, token)
|
||||
});
|
||||
};
|
||||
|
||||
exports.createTokenAuth = createTokenAuth;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-token/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/auth-token/dist-node/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../dist-src/auth.js","../dist-src/with-authorization-prefix.js","../dist-src/hook.js","../dist-src/index.js"],"sourcesContent":["const REGEX_IS_INSTALLATION_LEGACY = /^v1\\./;\nconst REGEX_IS_INSTALLATION = /^ghs_/;\nconst REGEX_IS_USER_TO_SERVER = /^ghu_/;\nexport async function auth(token) {\n const isApp = token.split(/\\./).length === 3;\n const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) ||\n REGEX_IS_INSTALLATION.test(token);\n const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);\n const tokenType = isApp\n ? \"app\"\n : isInstallation\n ? \"installation\"\n : isUserToServer\n ? \"user-to-server\"\n : \"oauth\";\n return {\n type: \"token\",\n token: token,\n tokenType,\n };\n}\n","/**\n * Prefix token for usage in the Authorization header\n *\n * @param token OAuth token or JSON Web Token\n */\nexport function withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n return `token ${token}`;\n}\n","import { withAuthorizationPrefix } from \"./with-authorization-prefix\";\nexport async function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(route, parameters);\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\n","import { auth } from \"./auth\";\nimport { hook } from \"./hook\";\nexport const createTokenAuth = function createTokenAuth(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n if (typeof token !== \"string\") {\n throw new Error(\"[@octokit/auth-token] Token passed to createTokenAuth is not a string\");\n }\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token),\n });\n};\n"],"names":["REGEX_IS_INSTALLATION_LEGACY","REGEX_IS_INSTALLATION","REGEX_IS_USER_TO_SERVER","auth","token","isApp","split","length","isInstallation","test","isUserToServer","tokenType","type","withAuthorizationPrefix","hook","request","route","parameters","endpoint","merge","headers","authorization","createTokenAuth","Error","replace","Object","assign","bind"],"mappings":";;;;AAAA,MAAMA,4BAA4B,GAAG,OAArC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;AACA,MAAMC,uBAAuB,GAAG,OAAhC;AACO,eAAeC,IAAf,CAAoBC,KAApB,EAA2B;AAC9B,QAAMC,KAAK,GAAGD,KAAK,CAACE,KAAN,CAAY,IAAZ,EAAkBC,MAAlB,KAA6B,CAA3C;AACA,QAAMC,cAAc,GAAGR,4BAA4B,CAACS,IAA7B,CAAkCL,KAAlC,KACnBH,qBAAqB,CAACQ,IAAtB,CAA2BL,KAA3B,CADJ;AAEA,QAAMM,cAAc,GAAGR,uBAAuB,CAACO,IAAxB,CAA6BL,KAA7B,CAAvB;AACA,QAAMO,SAAS,GAAGN,KAAK,GACjB,KADiB,GAEjBG,cAAc,GACV,cADU,GAEVE,cAAc,GACV,gBADU,GAEV,OANd;AAOA,SAAO;AACHE,IAAAA,IAAI,EAAE,OADH;AAEHR,IAAAA,KAAK,EAAEA,KAFJ;AAGHO,IAAAA;AAHG,GAAP;AAKH;;ACpBD;AACA;AACA;AACA;AACA;AACA,AAAO,SAASE,uBAAT,CAAiCT,KAAjC,EAAwC;AAC3C,MAAIA,KAAK,CAACE,KAAN,CAAY,IAAZ,EAAkBC,MAAlB,KAA6B,CAAjC,EAAoC;AAChC,WAAQ,UAASH,KAAM,EAAvB;AACH;;AACD,SAAQ,SAAQA,KAAM,EAAtB;AACH;;ACTM,eAAeU,IAAf,CAAoBV,KAApB,EAA2BW,OAA3B,EAAoCC,KAApC,EAA2CC,UAA3C,EAAuD;AAC1D,QAAMC,QAAQ,GAAGH,OAAO,CAACG,QAAR,CAAiBC,KAAjB,CAAuBH,KAAvB,EAA8BC,UAA9B,CAAjB;AACAC,EAAAA,QAAQ,CAACE,OAAT,CAAiBC,aAAjB,GAAiCR,uBAAuB,CAACT,KAAD,CAAxD;AACA,SAAOW,OAAO,CAACG,QAAD,CAAd;AACH;;MCHYI,eAAe,GAAG,SAASA,eAAT,CAAyBlB,KAAzB,EAAgC;AAC3D,MAAI,CAACA,KAAL,EAAY;AACR,UAAM,IAAImB,KAAJ,CAAU,0DAAV,CAAN;AACH;;AACD,MAAI,OAAOnB,KAAP,KAAiB,QAArB,EAA+B;AAC3B,UAAM,IAAImB,KAAJ,CAAU,uEAAV,CAAN;AACH;;AACDnB,EAAAA,KAAK,GAAGA,KAAK,CAACoB,OAAN,CAAc,oBAAd,EAAoC,EAApC,CAAR;AACA,SAAOC,MAAM,CAACC,MAAP,CAAcvB,IAAI,CAACwB,IAAL,CAAU,IAAV,EAAgBvB,KAAhB,CAAd,EAAsC;AACzCU,IAAAA,IAAI,EAAEA,IAAI,CAACa,IAAL,CAAU,IAAV,EAAgBvB,KAAhB;AADmC,GAAtC,CAAP;AAGH,CAXM;;;;"}
|
21
node_modules/@octokit/auth-token/dist-src/auth.js
generated
vendored
Normal file
21
node_modules/@octokit/auth-token/dist-src/auth.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
const REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
||||
const REGEX_IS_INSTALLATION = /^ghs_/;
|
||||
const REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
||||
export async function auth(token) {
|
||||
const isApp = token.split(/\./).length === 3;
|
||||
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) ||
|
||||
REGEX_IS_INSTALLATION.test(token);
|
||||
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
||||
const tokenType = isApp
|
||||
? "app"
|
||||
: isInstallation
|
||||
? "installation"
|
||||
: isUserToServer
|
||||
? "user-to-server"
|
||||
: "oauth";
|
||||
return {
|
||||
type: "token",
|
||||
token: token,
|
||||
tokenType,
|
||||
};
|
||||
}
|
6
node_modules/@octokit/auth-token/dist-src/hook.js
generated
vendored
Normal file
6
node_modules/@octokit/auth-token/dist-src/hook.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import { withAuthorizationPrefix } from "./with-authorization-prefix";
|
||||
export async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
14
node_modules/@octokit/auth-token/dist-src/index.js
generated
vendored
Normal file
14
node_modules/@octokit/auth-token/dist-src/index.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
import { auth } from "./auth";
|
||||
import { hook } from "./hook";
|
||||
export const createTokenAuth = function createTokenAuth(token) {
|
||||
if (!token) {
|
||||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||||
}
|
||||
if (typeof token !== "string") {
|
||||
throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
|
||||
}
|
||||
token = token.replace(/^(token|bearer) +/i, "");
|
||||
return Object.assign(auth.bind(null, token), {
|
||||
hook: hook.bind(null, token),
|
||||
});
|
||||
};
|
1
node_modules/@octokit/auth-token/dist-src/types.js
generated
vendored
Normal file
1
node_modules/@octokit/auth-token/dist-src/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
11
node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js
generated
vendored
Normal file
11
node_modules/@octokit/auth-token/dist-src/with-authorization-prefix.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Prefix token for usage in the Authorization header
|
||||
*
|
||||
* @param token OAuth token or JSON Web Token
|
||||
*/
|
||||
export function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
return `token ${token}`;
|
||||
}
|
2
node_modules/@octokit/auth-token/dist-types/auth.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-token/dist-types/auth.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { Token, Authentication } from "./types";
|
||||
export declare function auth(token: Token): Promise<Authentication>;
|
2
node_modules/@octokit/auth-token/dist-types/hook.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/auth-token/dist-types/hook.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { AnyResponse, EndpointOptions, RequestInterface, RequestParameters, Route, Token } from "./types";
|
||||
export declare function hook(token: Token, request: RequestInterface, route: Route | EndpointOptions, parameters?: RequestParameters): Promise<AnyResponse>;
|
7
node_modules/@octokit/auth-token/dist-types/index.d.ts
generated
vendored
Normal file
7
node_modules/@octokit/auth-token/dist-types/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { StrategyInterface, Token, Authentication } from "./types";
|
||||
export declare type Types = {
|
||||
StrategyOptions: Token;
|
||||
AuthOptions: never;
|
||||
Authentication: Authentication;
|
||||
};
|
||||
export declare const createTokenAuth: StrategyInterface;
|
33
node_modules/@octokit/auth-token/dist-types/types.d.ts
generated
vendored
Normal file
33
node_modules/@octokit/auth-token/dist-types/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
import * as OctokitTypes from "@octokit/types";
|
||||
export declare type AnyResponse = OctokitTypes.OctokitResponse<any>;
|
||||
export declare type StrategyInterface = OctokitTypes.StrategyInterface<[
|
||||
Token
|
||||
], [
|
||||
], Authentication>;
|
||||
export declare type EndpointDefaults = OctokitTypes.EndpointDefaults;
|
||||
export declare type EndpointOptions = OctokitTypes.EndpointOptions;
|
||||
export declare type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export declare type RequestInterface = OctokitTypes.RequestInterface;
|
||||
export declare type Route = OctokitTypes.Route;
|
||||
export declare type Token = string;
|
||||
export declare type OAuthTokenAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "oauth";
|
||||
token: Token;
|
||||
};
|
||||
export declare type InstallationTokenAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "installation";
|
||||
token: Token;
|
||||
};
|
||||
export declare type AppAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "app";
|
||||
token: Token;
|
||||
};
|
||||
export declare type UserToServerAuthentication = {
|
||||
type: "token";
|
||||
tokenType: "user-to-server";
|
||||
token: Token;
|
||||
};
|
||||
export declare type Authentication = OAuthTokenAuthentication | InstallationTokenAuthentication | AppAuthentication | UserToServerAuthentication;
|
6
node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts
generated
vendored
Normal file
6
node_modules/@octokit/auth-token/dist-types/with-authorization-prefix.d.ts
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Prefix token for usage in the Authorization header
|
||||
*
|
||||
* @param token OAuth token or JSON Web Token
|
||||
*/
|
||||
export declare function withAuthorizationPrefix(token: string): string;
|
55
node_modules/@octokit/auth-token/dist-web/index.js
generated
vendored
Normal file
55
node_modules/@octokit/auth-token/dist-web/index.js
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
const REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
||||
const REGEX_IS_INSTALLATION = /^ghs_/;
|
||||
const REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
||||
async function auth(token) {
|
||||
const isApp = token.split(/\./).length === 3;
|
||||
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) ||
|
||||
REGEX_IS_INSTALLATION.test(token);
|
||||
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
||||
const tokenType = isApp
|
||||
? "app"
|
||||
: isInstallation
|
||||
? "installation"
|
||||
: isUserToServer
|
||||
? "user-to-server"
|
||||
: "oauth";
|
||||
return {
|
||||
type: "token",
|
||||
token: token,
|
||||
tokenType,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix token for usage in the Authorization header
|
||||
*
|
||||
* @param token OAuth token or JSON Web Token
|
||||
*/
|
||||
function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
return `token ${token}`;
|
||||
}
|
||||
|
||||
async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
const createTokenAuth = function createTokenAuth(token) {
|
||||
if (!token) {
|
||||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||||
}
|
||||
if (typeof token !== "string") {
|
||||
throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
|
||||
}
|
||||
token = token.replace(/^(token|bearer) +/i, "");
|
||||
return Object.assign(auth.bind(null, token), {
|
||||
hook: hook.bind(null, token),
|
||||
});
|
||||
};
|
||||
|
||||
export { createTokenAuth };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/auth-token/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/auth-token/dist-web/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../dist-src/auth.js","../dist-src/with-authorization-prefix.js","../dist-src/hook.js","../dist-src/index.js"],"sourcesContent":["const REGEX_IS_INSTALLATION_LEGACY = /^v1\\./;\nconst REGEX_IS_INSTALLATION = /^ghs_/;\nconst REGEX_IS_USER_TO_SERVER = /^ghu_/;\nexport async function auth(token) {\n const isApp = token.split(/\\./).length === 3;\n const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) ||\n REGEX_IS_INSTALLATION.test(token);\n const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);\n const tokenType = isApp\n ? \"app\"\n : isInstallation\n ? \"installation\"\n : isUserToServer\n ? \"user-to-server\"\n : \"oauth\";\n return {\n type: \"token\",\n token: token,\n tokenType,\n };\n}\n","/**\n * Prefix token for usage in the Authorization header\n *\n * @param token OAuth token or JSON Web Token\n */\nexport function withAuthorizationPrefix(token) {\n if (token.split(/\\./).length === 3) {\n return `bearer ${token}`;\n }\n return `token ${token}`;\n}\n","import { withAuthorizationPrefix } from \"./with-authorization-prefix\";\nexport async function hook(token, request, route, parameters) {\n const endpoint = request.endpoint.merge(route, parameters);\n endpoint.headers.authorization = withAuthorizationPrefix(token);\n return request(endpoint);\n}\n","import { auth } from \"./auth\";\nimport { hook } from \"./hook\";\nexport const createTokenAuth = function createTokenAuth(token) {\n if (!token) {\n throw new Error(\"[@octokit/auth-token] No token passed to createTokenAuth\");\n }\n if (typeof token !== \"string\") {\n throw new Error(\"[@octokit/auth-token] Token passed to createTokenAuth is not a string\");\n }\n token = token.replace(/^(token|bearer) +/i, \"\");\n return Object.assign(auth.bind(null, token), {\n hook: hook.bind(null, token),\n });\n};\n"],"names":[],"mappings":"AAAA,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAC7C,MAAM,qBAAqB,GAAG,OAAO,CAAC;AACtC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AACjC,eAAe,IAAI,CAAC,KAAK,EAAE;AAClC,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACjD,IAAI,MAAM,cAAc,GAAG,4BAA4B,CAAC,IAAI,CAAC,KAAK,CAAC;AACnE,QAAQ,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,IAAI,MAAM,cAAc,GAAG,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC/D,IAAI,MAAM,SAAS,GAAG,KAAK;AAC3B,UAAU,KAAK;AACf,UAAU,cAAc;AACxB,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,kBAAkB,gBAAgB;AAClC,kBAAkB,OAAO,CAAC;AAC1B,IAAI,OAAO;AACX,QAAQ,IAAI,EAAE,OAAO;AACrB,QAAQ,KAAK,EAAE,KAAK;AACpB,QAAQ,SAAS;AACjB,KAAK,CAAC;AACN;;ACpBA;AACA;AACA;AACA;AACA;AACA,AAAO,SAAS,uBAAuB,CAAC,KAAK,EAAE;AAC/C,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;AACxC,QAAQ,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AACjC,KAAK;AACL,IAAI,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5B,CAAC;;ACTM,eAAe,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE;AAC9D,IAAI,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AAC/D,IAAI,QAAQ,CAAC,OAAO,CAAC,aAAa,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;AACpE,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC;;ACHW,MAAC,eAAe,GAAG,SAAS,eAAe,CAAC,KAAK,EAAE;AAC/D,IAAI,IAAI,CAAC,KAAK,EAAE;AAChB,QAAQ,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;AACpF,KAAK;AACL,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;AACnC,QAAQ,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;AACjG,KAAK;AACL,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AACpD,IAAI,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE;AACjD,QAAQ,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC;AACpC,KAAK,CAAC,CAAC;AACP,CAAC;;;;"}
|
45
node_modules/@octokit/auth-token/package.json
generated
vendored
Normal file
45
node_modules/@octokit/auth-token/package.json
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@octokit/auth-token",
|
||||
"description": "GitHub API token authentication for browsers and Node.js",
|
||||
"version": "2.5.0",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"github",
|
||||
"octokit",
|
||||
"authentication",
|
||||
"api"
|
||||
],
|
||||
"repository": "github:octokit/auth-token.js",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/core": "^3.0.0",
|
||||
"@octokit/request": "^5.3.0",
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/fetch-mock": "^7.3.1",
|
||||
"@types/jest": "^27.0.0",
|
||||
"fetch-mock": "^9.0.0",
|
||||
"jest": "^27.0.0",
|
||||
"prettier": "2.4.1",
|
||||
"semantic-release": "^17.0.0",
|
||||
"ts-jest": "^27.0.0-next.12",
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js"
|
||||
}
|
21
node_modules/@octokit/core/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/core/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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 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.
|
448
node_modules/@octokit/core/README.md
generated
vendored
Normal file
448
node_modules/@octokit/core/README.md
generated
vendored
Normal file
@ -0,0 +1,448 @@
|
||||
# core.js
|
||||
|
||||
> Extendable client for GitHub's REST & GraphQL APIs
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/core)
|
||||
[](https://github.com/octokit/core.js/actions?query=workflow%3ATest+branch%3Amaster)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [REST API example](#rest-api-example)
|
||||
- [GraphQL example](#graphql-example)
|
||||
- [Options](#options)
|
||||
- [Defaults](#defaults)
|
||||
- [Authentication](#authentication)
|
||||
- [Logging](#logging)
|
||||
- [Hooks](#hooks)
|
||||
- [Plugins](#plugins)
|
||||
- [Build your own Octokit with Plugins and Defaults](#build-your-own-octokit-with-plugins-and-defaults)
|
||||
- [LICENSE](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
If you need a minimalistic library to utilize GitHub's [REST API](https://developer.github.com/v3/) and [GraphQL API](https://developer.github.com/v4/) which you can extend with plugins as needed, then `@octokit/core` is a great starting point.
|
||||
|
||||
If you don't need the Plugin API then using [`@octokit/request`](https://github.com/octokit/request.js/) or [`@octokit/graphql`](https://github.com/octokit/graphql.js/) directly is a good alternative.
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/core</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/core</code>
|
||||
|
||||
```js
|
||||
const { Octokit } = require("@octokit/core");
|
||||
// or: import { Octokit } from "@octokit/core";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### REST API example
|
||||
|
||||
```js
|
||||
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
|
||||
const octokit = new Octokit({ auth: `personal-access-token123` });
|
||||
|
||||
const response = await octokit.request("GET /orgs/{org}/repos", {
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
See [`@octokit/request`](https://github.com/octokit/request.js) for full documentation of the `.request` method.
|
||||
|
||||
### GraphQL example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({ auth: `secret123` });
|
||||
|
||||
const response = await octokit.graphql(
|
||||
`query ($login: String!) {
|
||||
organization(login: $login) {
|
||||
repositories(privacy: PRIVATE) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}`,
|
||||
{ login: "octokit" }
|
||||
);
|
||||
```
|
||||
|
||||
See [`@octokit/graphql`](https://github.com/octokit/graphql.js) for full documentation of the `.graphql` method.
|
||||
|
||||
## Options
|
||||
|
||||
<table>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>
|
||||
name
|
||||
</th>
|
||||
<th>
|
||||
type
|
||||
</th>
|
||||
<th width=100%>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.authStrategy</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>Function<code>
|
||||
</td>
|
||||
<td>
|
||||
Defaults to <a href="https://github.com/octokit/auth-token.js#readme"><code>@octokit/auth-token</code></a>. See <a href="#authentication">Authentication</a> below for examples.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.auth</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code> or <code>Object</code>
|
||||
</td>
|
||||
<td>
|
||||
See <a href="#authentication">Authentication</a> below for examples.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
When using with GitHub Enterprise Server, set `options.baseUrl` to the root URL of the API. For example, if your GitHub Enterprise Server's hostname is `github.acme-inc.com`, then set `options.baseUrl` to `https://github.acme-inc.com/api/v3`. Example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
baseUrl: "https://github.acme-inc.com/api/v3",
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.previews</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>Array of Strings</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Some REST API endpoints require preview headers to be set, or enable
|
||||
additional features. Preview headers can be set on a per-request basis, e.g.
|
||||
|
||||
```js
|
||||
octokit.request("POST /repos/{owner}/{repo}/pulls", {
|
||||
mediaType: {
|
||||
previews: ["shadow-cat"],
|
||||
},
|
||||
owner,
|
||||
repo,
|
||||
title: "My pull request",
|
||||
base: "master",
|
||||
head: "my-feature",
|
||||
draft: true,
|
||||
});
|
||||
```
|
||||
|
||||
You can also set previews globally, by setting the `options.previews` option on the constructor. Example:
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
previews: ["shadow-cat"],
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.request</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>Object</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Set a default request timeout (`options.request.timeout`) or an [`http(s).Agent`](https://nodejs.org/api/http.html#http_class_http_agent) e.g. for proxy usage (Node only, `options.request.agent`).
|
||||
|
||||
There are more `options.request.*` options, see [`@octokit/request` options](https://github.com/octokit/request.js#request). `options.request` can also be set on a per-request basis.
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.timeZone</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
Sets the `Time-Zone` header which defines a timezone according to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
timeZone: "America/Los_Angeles",
|
||||
});
|
||||
```
|
||||
|
||||
The time zone header will determine the timezone used for generating the timestamp when creating commits. See [GitHub's Timezones documentation](https://developer.github.com/v3/#timezones).
|
||||
|
||||
</td></tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.userAgent</code>
|
||||
</th>
|
||||
<td>
|
||||
<code>String</code>
|
||||
</td>
|
||||
<td>
|
||||
|
||||
A custom user agent string for your app or library. Example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
userAgent: "my-app/v1.2.3",
|
||||
});
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
## Defaults
|
||||
|
||||
You can create a new Octokit class with customized default options.
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.defaults({
|
||||
auth: "personal-access-token123",
|
||||
baseUrl: "https://github.acme-inc.com/api/v3",
|
||||
userAgent: "my-app/v1.2.3",
|
||||
});
|
||||
const octokit1 = new MyOctokit();
|
||||
const octokit2 = new MyOctokit();
|
||||
```
|
||||
|
||||
If you pass additional options to your new constructor, the options will be merged shallowly.
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.defaults({
|
||||
foo: {
|
||||
opt1: 1,
|
||||
},
|
||||
});
|
||||
const octokit = new MyOctokit({
|
||||
foo: {
|
||||
opt2: 1,
|
||||
},
|
||||
});
|
||||
// options will be { foo: { opt2: 1 }}
|
||||
```
|
||||
|
||||
If you need a deep or conditional merge, you can pass a function instead.
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.defaults((options) => {
|
||||
return {
|
||||
foo: Object.assign({}, options.foo, { opt2: 1 }),
|
||||
};
|
||||
});
|
||||
const octokit = new MyOctokit({
|
||||
foo: { opt2: 1 },
|
||||
});
|
||||
// options will be { foo: { opt1: 1, opt2: 1 }}
|
||||
```
|
||||
|
||||
Be careful about mutating the `options` object in the `Octokit.defaults` callback, as it can have unforeseen consequences.
|
||||
|
||||
## Authentication
|
||||
|
||||
Authentication is optional for some REST API endpoints accessing public data, but is required for GraphQL queries. Using authentication also increases your [API rate limit](https://developer.github.com/v3/#rate-limiting).
|
||||
|
||||
By default, Octokit authenticates using the [token authentication strategy](https://github.com/octokit/auth-token.js). Pass in a token using `options.auth`. It can be a personal access token, an OAuth token, an installation access token or a JSON Web Token for GitHub App authentication. The `Authorization` header will be set according to the type of token.
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: "mypersonalaccesstoken123",
|
||||
});
|
||||
|
||||
const { data } = await octokit.request("/user");
|
||||
```
|
||||
|
||||
To use a different authentication strategy, set `options.authStrategy`. A list of authentication strategies is available at [octokit/authentication-strategies.js](https://github.com/octokit/authentication-strategies.js/#readme).
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
|
||||
const appOctokit = new Octokit({
|
||||
authStrategy: createAppAuth,
|
||||
auth: {
|
||||
appId: 123,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
},
|
||||
});
|
||||
|
||||
const { data } = await appOctokit.request("/app");
|
||||
```
|
||||
|
||||
The `.auth()` method returned by the current authentication strategy can be accessed at `octokit.auth()`. Example
|
||||
|
||||
```js
|
||||
const { token } = await appOctokit.auth({
|
||||
type: "installation",
|
||||
installationId: 123,
|
||||
});
|
||||
```
|
||||
|
||||
## Logging
|
||||
|
||||
There are four built-in log methods
|
||||
|
||||
1. `octokit.log.debug(message[, additionalInfo])`
|
||||
1. `octokit.log.info(message[, additionalInfo])`
|
||||
1. `octokit.log.warn(message[, additionalInfo])`
|
||||
1. `octokit.log.error(message[, additionalInfo])`
|
||||
|
||||
They can be configured using the [`log` client option](client-options). By default, `octokit.log.debug()` and `octokit.log.info()` are no-ops, while the other two call `console.warn()` and `console.error()` respectively.
|
||||
|
||||
This is useful if you build reusable [plugins](#plugins).
|
||||
|
||||
If you would like to make the log level configurable using an environment variable or external option, we recommend the [console-log-level](https://github.com/watson/console-log-level) package. Example
|
||||
|
||||
```js
|
||||
const octokit = new Octokit({
|
||||
log: require("console-log-level")({ level: "info" }),
|
||||
});
|
||||
```
|
||||
|
||||
## Hooks
|
||||
|
||||
You can customize Octokit's request lifecycle with hooks.
|
||||
|
||||
```js
|
||||
octokit.hook.before("request", async (options) => {
|
||||
validate(options);
|
||||
});
|
||||
octokit.hook.after("request", async (response, options) => {
|
||||
console.log(`${options.method} ${options.url}: ${response.status}`);
|
||||
});
|
||||
octokit.hook.error("request", async (error, options) => {
|
||||
if (error.status === 304) {
|
||||
return findInCache(error.response.headers.etag);
|
||||
}
|
||||
|
||||
throw error;
|
||||
});
|
||||
octokit.hook.wrap("request", async (request, options) => {
|
||||
// add logic before, after, catch errors or replace the request altogether
|
||||
return request(options);
|
||||
});
|
||||
```
|
||||
|
||||
See [before-after-hook](https://github.com/gr2m/before-after-hook#readme) for more documentation on hooks.
|
||||
|
||||
## Plugins
|
||||
|
||||
Octokit’s functionality can be extended using plugins. The `Octokit.plugin()` method accepts a plugin (or many) and returns a new constructor.
|
||||
|
||||
A plugin is a function which gets two arguments:
|
||||
|
||||
1. the current instance
|
||||
2. the options passed to the constructor.
|
||||
|
||||
In order to extend `octokit`'s API, the plugin must return an object with the new methods.
|
||||
|
||||
```js
|
||||
// index.js
|
||||
const { Octokit } = require("@octokit/core")
|
||||
const MyOctokit = Octokit.plugin(
|
||||
require("./lib/my-plugin"),
|
||||
require("octokit-plugin-example")
|
||||
);
|
||||
|
||||
const octokit = new MyOctokit({ greeting: "Moin moin" });
|
||||
octokit.helloWorld(); // logs "Moin moin, world!"
|
||||
octokit.request("GET /"); // logs "GET / - 200 in 123ms"
|
||||
|
||||
// lib/my-plugin.js
|
||||
module.exports = (octokit, options = { greeting: "Hello" }) => {
|
||||
// hook into the request lifecycle
|
||||
octokit.hook.wrap("request", async (request, options) => {
|
||||
const time = Date.now();
|
||||
const response = await request(options);
|
||||
console.log(
|
||||
`${options.method} ${options.url} – ${response.status} in ${Date.now() -
|
||||
time}ms`
|
||||
);
|
||||
return response;
|
||||
});
|
||||
|
||||
// add a custom method
|
||||
return {
|
||||
helloWorld: () => console.log(`${options.greeting}, world!`);
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Build your own Octokit with Plugins and Defaults
|
||||
|
||||
You can build your own Octokit class with preset default options and plugins. In fact, this is mostly how the `@octokit/<context>` modules work, such as [`@octokit/action`](https://github.com/octokit/action.js):
|
||||
|
||||
```js
|
||||
const { Octokit } = require("@octokit/core");
|
||||
const MyActionOctokit = Octokit.plugin(
|
||||
require("@octokit/plugin-paginate-rest").paginateRest,
|
||||
require("@octokit/plugin-throttling").throttling,
|
||||
require("@octokit/plugin-retry").retry
|
||||
).defaults({
|
||||
throttle: {
|
||||
onAbuseLimit: (retryAfter, options) => {
|
||||
/* ... */
|
||||
},
|
||||
onRateLimit: (retryAfter, options) => {
|
||||
/* ... */
|
||||
},
|
||||
},
|
||||
authStrategy: require("@octokit/auth-action").createActionAuth,
|
||||
userAgent: `my-octokit-action/v1.2.3`,
|
||||
});
|
||||
|
||||
const octokit = new MyActionOctokit();
|
||||
const installations = await octokit.paginate("GET /app/installations");
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
176
node_modules/@octokit/core/dist-node/index.js
generated
vendored
Normal file
176
node_modules/@octokit/core/dist-node/index.js
generated
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
var beforeAfterHook = require('before-after-hook');
|
||||
var request = require('@octokit/request');
|
||||
var graphql = require('@octokit/graphql');
|
||||
var authToken = require('@octokit/auth-token');
|
||||
|
||||
function _objectWithoutPropertiesLoose(source, excluded) {
|
||||
if (source == null) return {};
|
||||
var target = {};
|
||||
var sourceKeys = Object.keys(source);
|
||||
var key, i;
|
||||
|
||||
for (i = 0; i < sourceKeys.length; i++) {
|
||||
key = sourceKeys[i];
|
||||
if (excluded.indexOf(key) >= 0) continue;
|
||||
target[key] = source[key];
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function _objectWithoutProperties(source, excluded) {
|
||||
if (source == null) return {};
|
||||
|
||||
var target = _objectWithoutPropertiesLoose(source, excluded);
|
||||
|
||||
var key, i;
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
||||
|
||||
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
||||
key = sourceSymbolKeys[i];
|
||||
if (excluded.indexOf(key) >= 0) continue;
|
||||
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
const VERSION = "3.6.0";
|
||||
|
||||
const _excluded = ["authStrategy"];
|
||||
class Octokit {
|
||||
constructor(options = {}) {
|
||||
const hook = new beforeAfterHook.Collection();
|
||||
const requestDefaults = {
|
||||
baseUrl: request.request.endpoint.DEFAULTS.baseUrl,
|
||||
headers: {},
|
||||
request: Object.assign({}, options.request, {
|
||||
// @ts-ignore internal usage only, no need to type
|
||||
hook: hook.bind(null, "request")
|
||||
}),
|
||||
mediaType: {
|
||||
previews: [],
|
||||
format: ""
|
||||
}
|
||||
}; // prepend default user agent with `options.userAgent` if set
|
||||
|
||||
requestDefaults.headers["user-agent"] = [options.userAgent, `octokit-core.js/${VERSION} ${universalUserAgent.getUserAgent()}`].filter(Boolean).join(" ");
|
||||
|
||||
if (options.baseUrl) {
|
||||
requestDefaults.baseUrl = options.baseUrl;
|
||||
}
|
||||
|
||||
if (options.previews) {
|
||||
requestDefaults.mediaType.previews = options.previews;
|
||||
}
|
||||
|
||||
if (options.timeZone) {
|
||||
requestDefaults.headers["time-zone"] = options.timeZone;
|
||||
}
|
||||
|
||||
this.request = request.request.defaults(requestDefaults);
|
||||
this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults);
|
||||
this.log = Object.assign({
|
||||
debug: () => {},
|
||||
info: () => {},
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console)
|
||||
}, options.log);
|
||||
this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
|
||||
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.
|
||||
// (2) If only `options.auth` is set, use the default token authentication strategy.
|
||||
// (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
|
||||
// TODO: type `options.auth` based on `options.authStrategy`.
|
||||
|
||||
if (!options.authStrategy) {
|
||||
if (!options.auth) {
|
||||
// (1)
|
||||
this.auth = async () => ({
|
||||
type: "unauthenticated"
|
||||
});
|
||||
} else {
|
||||
// (2)
|
||||
const auth = authToken.createTokenAuth(options.auth); // @ts-ignore ¯\_(ツ)_/¯
|
||||
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
} else {
|
||||
const {
|
||||
authStrategy
|
||||
} = options,
|
||||
otherOptions = _objectWithoutProperties(options, _excluded);
|
||||
|
||||
const auth = authStrategy(Object.assign({
|
||||
request: this.request,
|
||||
log: this.log,
|
||||
// we pass the current octokit instance as well as its constructor options
|
||||
// to allow for authentication strategies that return a new octokit instance
|
||||
// that shares the same internal state as the current one. The original
|
||||
// requirement for this was the "event-octokit" authentication strategy
|
||||
// of https://github.com/probot/octokit-auth-probot.
|
||||
octokit: this,
|
||||
octokitOptions: otherOptions
|
||||
}, options.auth)); // @ts-ignore ¯\_(ツ)_/¯
|
||||
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
} // apply plugins
|
||||
// https://stackoverflow.com/a/16345172
|
||||
|
||||
|
||||
const classConstructor = this.constructor;
|
||||
classConstructor.plugins.forEach(plugin => {
|
||||
Object.assign(this, plugin(this, options));
|
||||
});
|
||||
}
|
||||
|
||||
static defaults(defaults) {
|
||||
const OctokitWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
const options = args[0] || {};
|
||||
|
||||
if (typeof defaults === "function") {
|
||||
super(defaults(options));
|
||||
return;
|
||||
}
|
||||
|
||||
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent ? {
|
||||
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
||||
} : null));
|
||||
}
|
||||
|
||||
};
|
||||
return OctokitWithDefaults;
|
||||
}
|
||||
/**
|
||||
* Attach a plugin (or many) to your Octokit instance.
|
||||
*
|
||||
* @example
|
||||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||||
*/
|
||||
|
||||
|
||||
static plugin(...newPlugins) {
|
||||
var _a;
|
||||
|
||||
const currentPlugins = this.plugins;
|
||||
const NewOctokit = (_a = class extends this {}, _a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))), _a);
|
||||
return NewOctokit;
|
||||
}
|
||||
|
||||
}
|
||||
Octokit.VERSION = VERSION;
|
||||
Octokit.plugins = [];
|
||||
|
||||
exports.Octokit = Octokit;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/core/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
125
node_modules/@octokit/core/dist-src/index.js
generated
vendored
Normal file
125
node_modules/@octokit/core/dist-src/index.js
generated
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { Collection } from "before-after-hook";
|
||||
import { request } from "@octokit/request";
|
||||
import { withCustomRequest } from "@octokit/graphql";
|
||||
import { createTokenAuth } from "@octokit/auth-token";
|
||||
import { VERSION } from "./version";
|
||||
export class Octokit {
|
||||
constructor(options = {}) {
|
||||
const hook = new Collection();
|
||||
const requestDefaults = {
|
||||
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
||||
headers: {},
|
||||
request: Object.assign({}, options.request, {
|
||||
// @ts-ignore internal usage only, no need to type
|
||||
hook: hook.bind(null, "request"),
|
||||
}),
|
||||
mediaType: {
|
||||
previews: [],
|
||||
format: "",
|
||||
},
|
||||
};
|
||||
// prepend default user agent with `options.userAgent` if set
|
||||
requestDefaults.headers["user-agent"] = [
|
||||
options.userAgent,
|
||||
`octokit-core.js/${VERSION} ${getUserAgent()}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
if (options.baseUrl) {
|
||||
requestDefaults.baseUrl = options.baseUrl;
|
||||
}
|
||||
if (options.previews) {
|
||||
requestDefaults.mediaType.previews = options.previews;
|
||||
}
|
||||
if (options.timeZone) {
|
||||
requestDefaults.headers["time-zone"] = options.timeZone;
|
||||
}
|
||||
this.request = request.defaults(requestDefaults);
|
||||
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
||||
this.log = Object.assign({
|
||||
debug: () => { },
|
||||
info: () => { },
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console),
|
||||
}, options.log);
|
||||
this.hook = hook;
|
||||
// (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
|
||||
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.
|
||||
// (2) If only `options.auth` is set, use the default token authentication strategy.
|
||||
// (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
|
||||
// TODO: type `options.auth` based on `options.authStrategy`.
|
||||
if (!options.authStrategy) {
|
||||
if (!options.auth) {
|
||||
// (1)
|
||||
this.auth = async () => ({
|
||||
type: "unauthenticated",
|
||||
});
|
||||
}
|
||||
else {
|
||||
// (2)
|
||||
const auth = createTokenAuth(options.auth);
|
||||
// @ts-ignore ¯\_(ツ)_/¯
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const { authStrategy, ...otherOptions } = options;
|
||||
const auth = authStrategy(Object.assign({
|
||||
request: this.request,
|
||||
log: this.log,
|
||||
// we pass the current octokit instance as well as its constructor options
|
||||
// to allow for authentication strategies that return a new octokit instance
|
||||
// that shares the same internal state as the current one. The original
|
||||
// requirement for this was the "event-octokit" authentication strategy
|
||||
// of https://github.com/probot/octokit-auth-probot.
|
||||
octokit: this,
|
||||
octokitOptions: otherOptions,
|
||||
}, options.auth));
|
||||
// @ts-ignore ¯\_(ツ)_/¯
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
// apply plugins
|
||||
// https://stackoverflow.com/a/16345172
|
||||
const classConstructor = this.constructor;
|
||||
classConstructor.plugins.forEach((plugin) => {
|
||||
Object.assign(this, plugin(this, options));
|
||||
});
|
||||
}
|
||||
static defaults(defaults) {
|
||||
const OctokitWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
const options = args[0] || {};
|
||||
if (typeof defaults === "function") {
|
||||
super(defaults(options));
|
||||
return;
|
||||
}
|
||||
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent
|
||||
? {
|
||||
userAgent: `${options.userAgent} ${defaults.userAgent}`,
|
||||
}
|
||||
: null));
|
||||
}
|
||||
};
|
||||
return OctokitWithDefaults;
|
||||
}
|
||||
/**
|
||||
* Attach a plugin (or many) to your Octokit instance.
|
||||
*
|
||||
* @example
|
||||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||||
*/
|
||||
static plugin(...newPlugins) {
|
||||
var _a;
|
||||
const currentPlugins = this.plugins;
|
||||
const NewOctokit = (_a = class extends this {
|
||||
},
|
||||
_a.plugins = currentPlugins.concat(newPlugins.filter((plugin) => !currentPlugins.includes(plugin))),
|
||||
_a);
|
||||
return NewOctokit;
|
||||
}
|
||||
}
|
||||
Octokit.VERSION = VERSION;
|
||||
Octokit.plugins = [];
|
1
node_modules/@octokit/core/dist-src/types.js
generated
vendored
Normal file
1
node_modules/@octokit/core/dist-src/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
1
node_modules/@octokit/core/dist-src/version.js
generated
vendored
Normal file
1
node_modules/@octokit/core/dist-src/version.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export const VERSION = "3.6.0";
|
30
node_modules/@octokit/core/dist-types/index.d.ts
generated
vendored
Normal file
30
node_modules/@octokit/core/dist-types/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
import { HookCollection } from "before-after-hook";
|
||||
import { request } from "@octokit/request";
|
||||
import { graphql } from "@octokit/graphql";
|
||||
import { Constructor, Hooks, OctokitOptions, OctokitPlugin, ReturnTypeOf, UnionToIntersection } from "./types";
|
||||
export declare class Octokit {
|
||||
static VERSION: string;
|
||||
static defaults<S extends Constructor<any>>(this: S, defaults: OctokitOptions | Function): S;
|
||||
static plugins: OctokitPlugin[];
|
||||
/**
|
||||
* Attach a plugin (or many) to your Octokit instance.
|
||||
*
|
||||
* @example
|
||||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||||
*/
|
||||
static plugin<S extends Constructor<any> & {
|
||||
plugins: any[];
|
||||
}, T extends OctokitPlugin[]>(this: S, ...newPlugins: T): S & Constructor<UnionToIntersection<ReturnTypeOf<T>>>;
|
||||
constructor(options?: OctokitOptions);
|
||||
request: typeof request;
|
||||
graphql: typeof graphql;
|
||||
log: {
|
||||
debug: (message: string, additionalInfo?: object) => any;
|
||||
info: (message: string, additionalInfo?: object) => any;
|
||||
warn: (message: string, additionalInfo?: object) => any;
|
||||
error: (message: string, additionalInfo?: object) => any;
|
||||
[key: string]: any;
|
||||
};
|
||||
hook: HookCollection<Hooks>;
|
||||
auth: (...args: unknown[]) => Promise<unknown>;
|
||||
}
|
44
node_modules/@octokit/core/dist-types/types.d.ts
generated
vendored
Normal file
44
node_modules/@octokit/core/dist-types/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
import * as OctokitTypes from "@octokit/types";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
import { Octokit } from ".";
|
||||
export declare type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export interface OctokitOptions {
|
||||
authStrategy?: any;
|
||||
auth?: any;
|
||||
userAgent?: string;
|
||||
previews?: string[];
|
||||
baseUrl?: string;
|
||||
log?: {
|
||||
debug: (message: string) => unknown;
|
||||
info: (message: string) => unknown;
|
||||
warn: (message: string) => unknown;
|
||||
error: (message: string) => unknown;
|
||||
};
|
||||
request?: OctokitTypes.RequestRequestOptions;
|
||||
timeZone?: string;
|
||||
[option: string]: any;
|
||||
}
|
||||
export declare type Constructor<T> = new (...args: any[]) => T;
|
||||
export declare type ReturnTypeOf<T extends AnyFunction | AnyFunction[]> = T extends AnyFunction ? ReturnType<T> : T extends AnyFunction[] ? UnionToIntersection<Exclude<ReturnType<T[number]>, void>> : never;
|
||||
/**
|
||||
* @author https://stackoverflow.com/users/2887218/jcalz
|
||||
* @see https://stackoverflow.com/a/50375286/10325032
|
||||
*/
|
||||
export declare type UnionToIntersection<Union> = (Union extends any ? (argument: Union) => void : never) extends (argument: infer Intersection) => void ? Intersection : never;
|
||||
declare type AnyFunction = (...args: any) => any;
|
||||
export declare type OctokitPlugin = (octokit: Octokit, options: OctokitOptions) => {
|
||||
[key: string]: any;
|
||||
} | void;
|
||||
export declare type Hooks = {
|
||||
request: {
|
||||
Options: Required<OctokitTypes.EndpointDefaults>;
|
||||
Result: OctokitTypes.OctokitResponse<any>;
|
||||
Error: RequestError | Error;
|
||||
};
|
||||
[key: string]: {
|
||||
Options: unknown;
|
||||
Result: unknown;
|
||||
Error: unknown;
|
||||
};
|
||||
};
|
||||
export {};
|
1
node_modules/@octokit/core/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/core/dist-types/version.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const VERSION = "3.6.0";
|
130
node_modules/@octokit/core/dist-web/index.js
generated
vendored
Normal file
130
node_modules/@octokit/core/dist-web/index.js
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
import { Collection } from 'before-after-hook';
|
||||
import { request } from '@octokit/request';
|
||||
import { withCustomRequest } from '@octokit/graphql';
|
||||
import { createTokenAuth } from '@octokit/auth-token';
|
||||
|
||||
const VERSION = "3.6.0";
|
||||
|
||||
class Octokit {
|
||||
constructor(options = {}) {
|
||||
const hook = new Collection();
|
||||
const requestDefaults = {
|
||||
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
||||
headers: {},
|
||||
request: Object.assign({}, options.request, {
|
||||
// @ts-ignore internal usage only, no need to type
|
||||
hook: hook.bind(null, "request"),
|
||||
}),
|
||||
mediaType: {
|
||||
previews: [],
|
||||
format: "",
|
||||
},
|
||||
};
|
||||
// prepend default user agent with `options.userAgent` if set
|
||||
requestDefaults.headers["user-agent"] = [
|
||||
options.userAgent,
|
||||
`octokit-core.js/${VERSION} ${getUserAgent()}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" ");
|
||||
if (options.baseUrl) {
|
||||
requestDefaults.baseUrl = options.baseUrl;
|
||||
}
|
||||
if (options.previews) {
|
||||
requestDefaults.mediaType.previews = options.previews;
|
||||
}
|
||||
if (options.timeZone) {
|
||||
requestDefaults.headers["time-zone"] = options.timeZone;
|
||||
}
|
||||
this.request = request.defaults(requestDefaults);
|
||||
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
||||
this.log = Object.assign({
|
||||
debug: () => { },
|
||||
info: () => { },
|
||||
warn: console.warn.bind(console),
|
||||
error: console.error.bind(console),
|
||||
}, options.log);
|
||||
this.hook = hook;
|
||||
// (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
|
||||
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered.
|
||||
// (2) If only `options.auth` is set, use the default token authentication strategy.
|
||||
// (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance.
|
||||
// TODO: type `options.auth` based on `options.authStrategy`.
|
||||
if (!options.authStrategy) {
|
||||
if (!options.auth) {
|
||||
// (1)
|
||||
this.auth = async () => ({
|
||||
type: "unauthenticated",
|
||||
});
|
||||
}
|
||||
else {
|
||||
// (2)
|
||||
const auth = createTokenAuth(options.auth);
|
||||
// @ts-ignore ¯\_(ツ)_/¯
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const { authStrategy, ...otherOptions } = options;
|
||||
const auth = authStrategy(Object.assign({
|
||||
request: this.request,
|
||||
log: this.log,
|
||||
// we pass the current octokit instance as well as its constructor options
|
||||
// to allow for authentication strategies that return a new octokit instance
|
||||
// that shares the same internal state as the current one. The original
|
||||
// requirement for this was the "event-octokit" authentication strategy
|
||||
// of https://github.com/probot/octokit-auth-probot.
|
||||
octokit: this,
|
||||
octokitOptions: otherOptions,
|
||||
}, options.auth));
|
||||
// @ts-ignore ¯\_(ツ)_/¯
|
||||
hook.wrap("request", auth.hook);
|
||||
this.auth = auth;
|
||||
}
|
||||
// apply plugins
|
||||
// https://stackoverflow.com/a/16345172
|
||||
const classConstructor = this.constructor;
|
||||
classConstructor.plugins.forEach((plugin) => {
|
||||
Object.assign(this, plugin(this, options));
|
||||
});
|
||||
}
|
||||
static defaults(defaults) {
|
||||
const OctokitWithDefaults = class extends this {
|
||||
constructor(...args) {
|
||||
const options = args[0] || {};
|
||||
if (typeof defaults === "function") {
|
||||
super(defaults(options));
|
||||
return;
|
||||
}
|
||||
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent
|
||||
? {
|
||||
userAgent: `${options.userAgent} ${defaults.userAgent}`,
|
||||
}
|
||||
: null));
|
||||
}
|
||||
};
|
||||
return OctokitWithDefaults;
|
||||
}
|
||||
/**
|
||||
* Attach a plugin (or many) to your Octokit instance.
|
||||
*
|
||||
* @example
|
||||
* const API = Octokit.plugin(plugin1, plugin2, plugin3, ...)
|
||||
*/
|
||||
static plugin(...newPlugins) {
|
||||
var _a;
|
||||
const currentPlugins = this.plugins;
|
||||
const NewOctokit = (_a = class extends this {
|
||||
},
|
||||
_a.plugins = currentPlugins.concat(newPlugins.filter((plugin) => !currentPlugins.includes(plugin))),
|
||||
_a);
|
||||
return NewOctokit;
|
||||
}
|
||||
}
|
||||
Octokit.VERSION = VERSION;
|
||||
Octokit.plugins = [];
|
||||
|
||||
export { Octokit };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/core/dist-web/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
57
node_modules/@octokit/core/package.json
generated
vendored
Normal file
57
node_modules/@octokit/core/package.json
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "@octokit/core",
|
||||
"description": "Extendable client for GitHub's REST & GraphQL APIs",
|
||||
"version": "3.6.0",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit"
|
||||
],
|
||||
"repository": "github:octokit/core.js",
|
||||
"dependencies": {
|
||||
"@octokit/auth-token": "^2.4.4",
|
||||
"@octokit/graphql": "^4.5.8",
|
||||
"@octokit/request": "^5.6.3",
|
||||
"@octokit/request-error": "^2.0.5",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"before-after-hook": "^2.2.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/auth": "^3.0.1",
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/fetch-mock": "^7.3.1",
|
||||
"@types/jest": "^27.0.0",
|
||||
"@types/lolex": "^5.1.0",
|
||||
"@types/node": "^14.0.4",
|
||||
"fetch-mock": "^9.0.0",
|
||||
"http-proxy-agent": "^5.0.0",
|
||||
"jest": "^27.0.0",
|
||||
"lolex": "^6.0.0",
|
||||
"prettier": "2.4.1",
|
||||
"proxy": "^1.0.1",
|
||||
"semantic-release": "^18.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^27.0.0",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js"
|
||||
}
|
21
node_modules/@octokit/endpoint/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/endpoint/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2018 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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 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.
|
421
node_modules/@octokit/endpoint/README.md
generated
vendored
Normal file
421
node_modules/@octokit/endpoint/README.md
generated
vendored
Normal file
@ -0,0 +1,421 @@
|
||||
# endpoint.js
|
||||
|
||||
> Turns GitHub REST API endpoints into generic request options
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/endpoint)
|
||||

|
||||
|
||||
`@octokit/endpoint` combines [GitHub REST API routes](https://developer.github.com/v3/) with your parameters and turns them into generic request options that can be used in any request library.
|
||||
|
||||
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [API](#api)
|
||||
- [`endpoint(route, options)` or `endpoint(options)`](#endpointroute-options-or-endpointoptions)
|
||||
- [`endpoint.defaults()`](#endpointdefaults)
|
||||
- [`endpoint.DEFAULTS`](#endpointdefaults)
|
||||
- [`endpoint.merge(route, options)` or `endpoint.merge(options)`](#endpointmergeroute-options-or-endpointmergeoptions)
|
||||
- [`endpoint.parse()`](#endpointparse)
|
||||
- [Special cases](#special-cases)
|
||||
- [The `data` parameter – set request body directly](#the-data-parameter-%E2%80%93-set-request-body-directly)
|
||||
- [Set parameters for both the URL/query and the request body](#set-parameters-for-both-the-urlquery-and-the-request-body)
|
||||
- [LICENSE](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/endpoint</code> directly from <a href="https://cdn.skypack.dev">cdn.skypack.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { endpoint } from "https://cdn.skypack.dev/@octokit/endpoint";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/endpoint</code>
|
||||
|
||||
```js
|
||||
const { endpoint } = require("@octokit/endpoint");
|
||||
// or: import { endpoint } from "@octokit/endpoint";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
Example for [List organization repositories](https://developer.github.com/v3/repos/#list-organization-repositories)
|
||||
|
||||
```js
|
||||
const requestOptions = endpoint("GET /orgs/{org}/repos", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
The resulting `requestOptions` looks as follows
|
||||
|
||||
```json
|
||||
{
|
||||
"method": "GET",
|
||||
"url": "https://api.github.com/orgs/octokit/repos?type=private",
|
||||
"headers": {
|
||||
"accept": "application/vnd.github.v3+json",
|
||||
"authorization": "token 0000000000000000000000000000000000000001",
|
||||
"user-agent": "octokit/endpoint.js v1.2.3"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can pass `requestOptions` to common request libraries
|
||||
|
||||
```js
|
||||
const { url, ...options } = requestOptions;
|
||||
// using with fetch (https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
fetch(url, options);
|
||||
// using with request (https://github.com/request/request)
|
||||
request(requestOptions);
|
||||
// using with got (https://github.com/sindresorhus/got)
|
||||
got[options.method](url, options);
|
||||
// using with axios
|
||||
axios(requestOptions);
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `endpoint(route, options)` or `endpoint(options)`
|
||||
|
||||
<table>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>
|
||||
name
|
||||
</th>
|
||||
<th>
|
||||
type
|
||||
</th>
|
||||
<th width=100%>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th>
|
||||
<code>route</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
If set, it has to be a string consisting of URL and the request method, e.g., <code>GET /orgs/{org}</code>. If it’s set to a URL, only the method defaults to <code>GET</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.method</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required unless <code>route</code> is set.</strong> Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>. <em>Defaults to <code>GET</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.url</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required unless <code>route</code> is set.</strong> A path or full URL which may contain <code>:variable</code> or <code>{variable}</code> placeholders,
|
||||
e.g., <code>/orgs/{org}/repos</code>. The <code>url</code> is parsed using <a href="https://github.com/bramstein/url-template">url-template</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<em>Defaults to <code>https://api.github.com</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.headers</code>
|
||||
</th>
|
||||
<td>
|
||||
Object
|
||||
</td>
|
||||
<td>
|
||||
Custom headers. Passed headers are merged with defaults:<br>
|
||||
<em><code>headers['user-agent']</code> defaults to <code>octokit-endpoint.js/1.2.3</code> (where <code>1.2.3</code> is the released version)</em>.<br>
|
||||
<em><code>headers['accept']</code> defaults to <code>application/vnd.github.v3+json</code></em>.<br>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.mediaType.format</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Media type param, such as <code>raw</code>, <code>diff</code>, or <code>text+json</code>. See <a href="https://developer.github.com/v3/media/">Media Types</a>. Setting <code>options.mediaType.format</code> will amend the <code>headers.accept</code> value.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.mediaType.previews</code>
|
||||
</th>
|
||||
<td>
|
||||
Array of Strings
|
||||
</td>
|
||||
<td>
|
||||
Name of previews, such as <code>mercy</code>, <code>symmetra</code>, or <code>scarlet-witch</code>. See <a href="https://developer.github.com/v3/previews/">API Previews</a>. If <code>options.mediaType.previews</code> was set as default, the new previews will be merged into the default ones. Setting <code>options.mediaType.previews</code> will amend the <code>headers.accept</code> value. <code>options.mediaType.previews</code> will be merged with an existing array set using <code>.defaults()</code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.data</code>
|
||||
</th>
|
||||
<td>
|
||||
Any
|
||||
</td>
|
||||
<td>
|
||||
Set request body directly instead of setting it to JSON based on additional parameters. See <a href="#data-parameter">"The <code>data</code> parameter"</a> below.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<code>options.request</code>
|
||||
</th>
|
||||
<td>
|
||||
Object
|
||||
</td>
|
||||
<td>
|
||||
Pass custom meta information for the request. The <code>request</code> object will be returned as is.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
All other options will be passed depending on the `method` and `url` options.
|
||||
|
||||
1. If the option key has a placeholder in the `url`, it will be used as the replacement. For example, if the passed options are `{url: '/orgs/{org}/repos', org: 'foo'}` the returned `options.url` is `https://api.github.com/orgs/foo/repos`.
|
||||
2. If the `method` is `GET` or `HEAD`, the option is passed as a query parameter.
|
||||
3. Otherwise, the parameter is passed in the request body as a JSON key.
|
||||
|
||||
**Result**
|
||||
|
||||
`endpoint()` is a synchronous method and returns an object with the following keys:
|
||||
|
||||
<table>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>
|
||||
key
|
||||
</th>
|
||||
<th>
|
||||
type
|
||||
</th>
|
||||
<th width=100%>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody align=left valign=top>
|
||||
<tr>
|
||||
<th><code>method</code></th>
|
||||
<td>String</td>
|
||||
<td>The http method. Always lowercase.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>url</code></th>
|
||||
<td>String</td>
|
||||
<td>The url with placeholders replaced with passed parameters.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>headers</code></th>
|
||||
<td>Object</td>
|
||||
<td>All header names are lowercased.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>body</code></th>
|
||||
<td>Any</td>
|
||||
<td>The request body if one is present. Only for <code>PATCH</code>, <code>POST</code>, <code>PUT</code>, <code>DELETE</code> requests.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><code>request</code></th>
|
||||
<td>Object</td>
|
||||
<td>Request meta option, it will be returned as it was passed into <code>endpoint()</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### `endpoint.defaults()`
|
||||
|
||||
Override or set default options. Example:
|
||||
|
||||
```js
|
||||
const request = require("request");
|
||||
const myEndpoint = require("@octokit/endpoint").defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
org: "my-project",
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
request(myEndpoint(`GET /orgs/{org}/repos`));
|
||||
```
|
||||
|
||||
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
||||
|
||||
```js
|
||||
const myProjectEndpoint = endpoint.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
const myProjectEndpointWithAuth = myProjectEndpoint.defaults({
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`myProjectEndpointWithAuth` now defaults the `baseUrl`, `headers['user-agent']`,
|
||||
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
||||
by the global default.
|
||||
|
||||
### `endpoint.DEFAULTS`
|
||||
|
||||
The current default options.
|
||||
|
||||
```js
|
||||
endpoint.DEFAULTS.baseUrl; // https://api.github.com
|
||||
const myEndpoint = endpoint.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
});
|
||||
myEndpoint.DEFAULTS.baseUrl; // https://github-enterprise.acme-inc.com/api/v3
|
||||
```
|
||||
|
||||
### `endpoint.merge(route, options)` or `endpoint.merge(options)`
|
||||
|
||||
Get the defaulted endpoint options, but without parsing them into request options:
|
||||
|
||||
```js
|
||||
const myProjectEndpoint = endpoint.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
myProjectEndpoint.merge("GET /orgs/{org}/repos", {
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
org: "my-secret-project",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
// {
|
||||
// baseUrl: 'https://github-enterprise.acme-inc.com/api/v3',
|
||||
// method: 'GET',
|
||||
// url: '/orgs/{org}/repos',
|
||||
// headers: {
|
||||
// accept: 'application/vnd.github.v3+json',
|
||||
// authorization: `token 0000000000000000000000000000000000000001`,
|
||||
// 'user-agent': 'myApp/1.2.3'
|
||||
// },
|
||||
// org: 'my-secret-project',
|
||||
// type: 'private'
|
||||
// }
|
||||
```
|
||||
|
||||
### `endpoint.parse()`
|
||||
|
||||
Stateless method to turn endpoint options into request options. Calling
|
||||
`endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`.
|
||||
|
||||
## Special cases
|
||||
|
||||
<a name="data-parameter"></a>
|
||||
|
||||
### The `data` parameter – set request body directly
|
||||
|
||||
Some endpoints such as [Render a Markdown document in raw mode](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode) don’t have parameters that are sent as request body keys, instead, the request body needs to be set directly. In these cases, set the `data` parameter.
|
||||
|
||||
```js
|
||||
const options = endpoint("POST /markdown/raw", {
|
||||
data: "Hello world github/linguist#1 **cool**, and #1!",
|
||||
headers: {
|
||||
accept: "text/html;charset=utf-8",
|
||||
"content-type": "text/plain",
|
||||
},
|
||||
});
|
||||
|
||||
// options is
|
||||
// {
|
||||
// method: 'post',
|
||||
// url: 'https://api.github.com/markdown/raw',
|
||||
// headers: {
|
||||
// accept: 'text/html;charset=utf-8',
|
||||
// 'content-type': 'text/plain',
|
||||
// 'user-agent': userAgent
|
||||
// },
|
||||
// body: 'Hello world github/linguist#1 **cool**, and #1!'
|
||||
// }
|
||||
```
|
||||
|
||||
### Set parameters for both the URL/query and the request body
|
||||
|
||||
There are API endpoints that accept both query parameters as well as a body. In that case, you need to add the query parameters as templates to `options.url`, as defined in the [RFC 6570 URI Template specification](https://tools.ietf.org/html/rfc6570).
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
endpoint(
|
||||
"POST https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name,label}",
|
||||
{
|
||||
name: "example.zip",
|
||||
label: "short description",
|
||||
headers: {
|
||||
"content-type": "text/plain",
|
||||
"content-length": 14,
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
data: "Hello, world!",
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
390
node_modules/@octokit/endpoint/dist-node/index.js
generated
vendored
Normal file
390
node_modules/@octokit/endpoint/dist-node/index.js
generated
vendored
Normal file
@ -0,0 +1,390 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var isPlainObject = require('is-plain-object');
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
|
||||
function lowercaseKeys(object) {
|
||||
if (!object) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Object.keys(object).reduce((newObj, key) => {
|
||||
newObj[key.toLowerCase()] = object[key];
|
||||
return newObj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function mergeDeep(defaults, options) {
|
||||
const result = Object.assign({}, defaults);
|
||||
Object.keys(options).forEach(key => {
|
||||
if (isPlainObject.isPlainObject(options[key])) {
|
||||
if (!(key in defaults)) Object.assign(result, {
|
||||
[key]: options[key]
|
||||
});else result[key] = mergeDeep(defaults[key], options[key]);
|
||||
} else {
|
||||
Object.assign(result, {
|
||||
[key]: options[key]
|
||||
});
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function removeUndefinedProperties(obj) {
|
||||
for (const key in obj) {
|
||||
if (obj[key] === undefined) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function merge(defaults, route, options) {
|
||||
if (typeof route === "string") {
|
||||
let [method, url] = route.split(" ");
|
||||
options = Object.assign(url ? {
|
||||
method,
|
||||
url
|
||||
} : {
|
||||
url: method
|
||||
}, options);
|
||||
} else {
|
||||
options = Object.assign({}, route);
|
||||
} // lowercase header names before merging with defaults to avoid duplicates
|
||||
|
||||
|
||||
options.headers = lowercaseKeys(options.headers); // remove properties with undefined values before merging
|
||||
|
||||
removeUndefinedProperties(options);
|
||||
removeUndefinedProperties(options.headers);
|
||||
const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten
|
||||
|
||||
if (defaults && defaults.mediaType.previews.length) {
|
||||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews);
|
||||
}
|
||||
|
||||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, ""));
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
function addQueryParameters(url, parameters) {
|
||||
const separator = /\?/.test(url) ? "&" : "?";
|
||||
const names = Object.keys(parameters);
|
||||
|
||||
if (names.length === 0) {
|
||||
return url;
|
||||
}
|
||||
|
||||
return url + separator + names.map(name => {
|
||||
if (name === "q") {
|
||||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+");
|
||||
}
|
||||
|
||||
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||||
}).join("&");
|
||||
}
|
||||
|
||||
const urlVariableRegex = /\{[^}]+\}/g;
|
||||
|
||||
function removeNonChars(variableName) {
|
||||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
|
||||
}
|
||||
|
||||
function extractUrlVariableNames(url) {
|
||||
const matches = url.match(urlVariableRegex);
|
||||
|
||||
if (!matches) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
||||
}
|
||||
|
||||
function omit(object, keysToOmit) {
|
||||
return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => {
|
||||
obj[key] = object[key];
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
// Based on https://github.com/bramstein/url-template, licensed under BSD
|
||||
// TODO: create separate package.
|
||||
//
|
||||
// Copyright (c) 2012-2014, Bram Stein
|
||||
// All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// 3. The name of the author may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/* istanbul ignore file */
|
||||
function encodeReserved(str) {
|
||||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) {
|
||||
if (!/%[0-9A-Fa-f]/.test(part)) {
|
||||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
||||
}
|
||||
|
||||
return part;
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function encodeUnreserved(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
||||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function encodeValue(operator, value, key) {
|
||||
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value);
|
||||
|
||||
if (key) {
|
||||
return encodeUnreserved(key) + "=" + value;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
function isDefined(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
|
||||
function isKeyOperator(operator) {
|
||||
return operator === ";" || operator === "&" || operator === "?";
|
||||
}
|
||||
|
||||
function getValues(context, operator, key, modifier) {
|
||||
var value = context[key],
|
||||
result = [];
|
||||
|
||||
if (isDefined(value) && value !== "") {
|
||||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
||||
value = value.toString();
|
||||
|
||||
if (modifier && modifier !== "*") {
|
||||
value = value.substring(0, parseInt(modifier, 10));
|
||||
}
|
||||
|
||||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
||||
} else {
|
||||
if (modifier === "*") {
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function (value) {
|
||||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function (k) {
|
||||
if (isDefined(value[k])) {
|
||||
result.push(encodeValue(operator, value[k], k));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const tmp = [];
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function (value) {
|
||||
tmp.push(encodeValue(operator, value));
|
||||
});
|
||||
} else {
|
||||
Object.keys(value).forEach(function (k) {
|
||||
if (isDefined(value[k])) {
|
||||
tmp.push(encodeUnreserved(k));
|
||||
tmp.push(encodeValue(operator, value[k].toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isKeyOperator(operator)) {
|
||||
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
||||
} else if (tmp.length !== 0) {
|
||||
result.push(tmp.join(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (operator === ";") {
|
||||
if (isDefined(value)) {
|
||||
result.push(encodeUnreserved(key));
|
||||
}
|
||||
} else if (value === "" && (operator === "&" || operator === "?")) {
|
||||
result.push(encodeUnreserved(key) + "=");
|
||||
} else if (value === "") {
|
||||
result.push("");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseUrl(template) {
|
||||
return {
|
||||
expand: expand.bind(null, template)
|
||||
};
|
||||
}
|
||||
|
||||
function expand(template, context) {
|
||||
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
||||
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
|
||||
if (expression) {
|
||||
let operator = "";
|
||||
const values = [];
|
||||
|
||||
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
||||
operator = expression.charAt(0);
|
||||
expression = expression.substr(1);
|
||||
}
|
||||
|
||||
expression.split(/,/g).forEach(function (variable) {
|
||||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
||||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
||||
});
|
||||
|
||||
if (operator && operator !== "+") {
|
||||
var separator = ",";
|
||||
|
||||
if (operator === "?") {
|
||||
separator = "&";
|
||||
} else if (operator !== "#") {
|
||||
separator = operator;
|
||||
}
|
||||
|
||||
return (values.length !== 0 ? operator : "") + values.join(separator);
|
||||
} else {
|
||||
return values.join(",");
|
||||
}
|
||||
} else {
|
||||
return encodeReserved(literal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parse(options) {
|
||||
// https://fetch.spec.whatwg.org/#methods
|
||||
let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible
|
||||
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||||
let headers = Object.assign({}, options.headers);
|
||||
let body;
|
||||
let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later
|
||||
|
||||
const urlVariableNames = extractUrlVariableNames(url);
|
||||
url = parseUrl(url).expand(parameters);
|
||||
|
||||
if (!/^http/.test(url)) {
|
||||
url = options.baseUrl + url;
|
||||
}
|
||||
|
||||
const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl");
|
||||
const remainingParameters = omit(parameters, omittedParameters);
|
||||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||||
|
||||
if (!isBinaryRequest) {
|
||||
if (options.mediaType.format) {
|
||||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw
|
||||
headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(",");
|
||||
}
|
||||
|
||||
if (options.mediaType.previews.length) {
|
||||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
||||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => {
|
||||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json";
|
||||
return `application/vnd.github.${preview}-preview${format}`;
|
||||
}).join(",");
|
||||
}
|
||||
} // for GET/HEAD requests, set URL query parameters from remaining parameters
|
||||
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters
|
||||
|
||||
|
||||
if (["GET", "HEAD"].includes(method)) {
|
||||
url = addQueryParameters(url, remainingParameters);
|
||||
} else {
|
||||
if ("data" in remainingParameters) {
|
||||
body = remainingParameters.data;
|
||||
} else {
|
||||
if (Object.keys(remainingParameters).length) {
|
||||
body = remainingParameters;
|
||||
} else {
|
||||
headers["content-length"] = 0;
|
||||
}
|
||||
}
|
||||
} // default content-type for JSON if body is set
|
||||
|
||||
|
||||
if (!headers["content-type"] && typeof body !== "undefined") {
|
||||
headers["content-type"] = "application/json; charset=utf-8";
|
||||
} // GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
|
||||
// fetch does not allow to set `content-length` header, but we can set body to an empty string
|
||||
|
||||
|
||||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||||
body = "";
|
||||
} // Only return body/request keys if present
|
||||
|
||||
|
||||
return Object.assign({
|
||||
method,
|
||||
url,
|
||||
headers
|
||||
}, typeof body !== "undefined" ? {
|
||||
body
|
||||
} : null, options.request ? {
|
||||
request: options.request
|
||||
} : null);
|
||||
}
|
||||
|
||||
function endpointWithDefaults(defaults, route, options) {
|
||||
return parse(merge(defaults, route, options));
|
||||
}
|
||||
|
||||
function withDefaults(oldDefaults, newDefaults) {
|
||||
const DEFAULTS = merge(oldDefaults, newDefaults);
|
||||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
|
||||
return Object.assign(endpoint, {
|
||||
DEFAULTS,
|
||||
defaults: withDefaults.bind(null, DEFAULTS),
|
||||
merge: merge.bind(null, DEFAULTS),
|
||||
parse
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION = "6.0.12";
|
||||
|
||||
const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url.
|
||||
// So we use RequestParameters and add method as additional required property.
|
||||
|
||||
const DEFAULTS = {
|
||||
method: "GET",
|
||||
baseUrl: "https://api.github.com",
|
||||
headers: {
|
||||
accept: "application/vnd.github.v3+json",
|
||||
"user-agent": userAgent
|
||||
},
|
||||
mediaType: {
|
||||
format: "",
|
||||
previews: []
|
||||
}
|
||||
};
|
||||
|
||||
const endpoint = withDefaults(null, DEFAULTS);
|
||||
|
||||
exports.endpoint = endpoint;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/endpoint/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/@octokit/endpoint/dist-src/defaults.js
generated
vendored
Normal file
17
node_modules/@octokit/endpoint/dist-src/defaults.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { VERSION } from "./version";
|
||||
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
|
||||
// DEFAULTS has all properties set that EndpointOptions has, except url.
|
||||
// So we use RequestParameters and add method as additional required property.
|
||||
export const DEFAULTS = {
|
||||
method: "GET",
|
||||
baseUrl: "https://api.github.com",
|
||||
headers: {
|
||||
accept: "application/vnd.github.v3+json",
|
||||
"user-agent": userAgent,
|
||||
},
|
||||
mediaType: {
|
||||
format: "",
|
||||
previews: [],
|
||||
},
|
||||
};
|
5
node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
generated
vendored
Normal file
5
node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { merge } from "./merge";
|
||||
import { parse } from "./parse";
|
||||
export function endpointWithDefaults(defaults, route, options) {
|
||||
return parse(merge(defaults, route, options));
|
||||
}
|
3
node_modules/@octokit/endpoint/dist-src/index.js
generated
vendored
Normal file
3
node_modules/@octokit/endpoint/dist-src/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { withDefaults } from "./with-defaults";
|
||||
import { DEFAULTS } from "./defaults";
|
||||
export const endpoint = withDefaults(null, DEFAULTS);
|
26
node_modules/@octokit/endpoint/dist-src/merge.js
generated
vendored
Normal file
26
node_modules/@octokit/endpoint/dist-src/merge.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
import { lowercaseKeys } from "./util/lowercase-keys";
|
||||
import { mergeDeep } from "./util/merge-deep";
|
||||
import { removeUndefinedProperties } from "./util/remove-undefined-properties";
|
||||
export function merge(defaults, route, options) {
|
||||
if (typeof route === "string") {
|
||||
let [method, url] = route.split(" ");
|
||||
options = Object.assign(url ? { method, url } : { url: method }, options);
|
||||
}
|
||||
else {
|
||||
options = Object.assign({}, route);
|
||||
}
|
||||
// lowercase header names before merging with defaults to avoid duplicates
|
||||
options.headers = lowercaseKeys(options.headers);
|
||||
// remove properties with undefined values before merging
|
||||
removeUndefinedProperties(options);
|
||||
removeUndefinedProperties(options.headers);
|
||||
const mergedOptions = mergeDeep(defaults || {}, options);
|
||||
// mediaType.previews arrays are merged, instead of overwritten
|
||||
if (defaults && defaults.mediaType.previews.length) {
|
||||
mergedOptions.mediaType.previews = defaults.mediaType.previews
|
||||
.filter((preview) => !mergedOptions.mediaType.previews.includes(preview))
|
||||
.concat(mergedOptions.mediaType.previews);
|
||||
}
|
||||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, ""));
|
||||
return mergedOptions;
|
||||
}
|
81
node_modules/@octokit/endpoint/dist-src/parse.js
generated
vendored
Normal file
81
node_modules/@octokit/endpoint/dist-src/parse.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
import { addQueryParameters } from "./util/add-query-parameters";
|
||||
import { extractUrlVariableNames } from "./util/extract-url-variable-names";
|
||||
import { omit } from "./util/omit";
|
||||
import { parseUrl } from "./util/url-template";
|
||||
export function parse(options) {
|
||||
// https://fetch.spec.whatwg.org/#methods
|
||||
let method = options.method.toUpperCase();
|
||||
// replace :varname with {varname} to make it RFC 6570 compatible
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||||
let headers = Object.assign({}, options.headers);
|
||||
let body;
|
||||
let parameters = omit(options, [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"mediaType",
|
||||
]);
|
||||
// extract variable names from URL to calculate remaining variables later
|
||||
const urlVariableNames = extractUrlVariableNames(url);
|
||||
url = parseUrl(url).expand(parameters);
|
||||
if (!/^http/.test(url)) {
|
||||
url = options.baseUrl + url;
|
||||
}
|
||||
const omittedParameters = Object.keys(options)
|
||||
.filter((option) => urlVariableNames.includes(option))
|
||||
.concat("baseUrl");
|
||||
const remainingParameters = omit(parameters, omittedParameters);
|
||||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||||
if (!isBinaryRequest) {
|
||||
if (options.mediaType.format) {
|
||||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw
|
||||
headers.accept = headers.accept
|
||||
.split(/,/)
|
||||
.map((preview) => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`))
|
||||
.join(",");
|
||||
}
|
||||
if (options.mediaType.previews.length) {
|
||||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
||||
headers.accept = previewsFromAcceptHeader
|
||||
.concat(options.mediaType.previews)
|
||||
.map((preview) => {
|
||||
const format = options.mediaType.format
|
||||
? `.${options.mediaType.format}`
|
||||
: "+json";
|
||||
return `application/vnd.github.${preview}-preview${format}`;
|
||||
})
|
||||
.join(",");
|
||||
}
|
||||
}
|
||||
// for GET/HEAD requests, set URL query parameters from remaining parameters
|
||||
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters
|
||||
if (["GET", "HEAD"].includes(method)) {
|
||||
url = addQueryParameters(url, remainingParameters);
|
||||
}
|
||||
else {
|
||||
if ("data" in remainingParameters) {
|
||||
body = remainingParameters.data;
|
||||
}
|
||||
else {
|
||||
if (Object.keys(remainingParameters).length) {
|
||||
body = remainingParameters;
|
||||
}
|
||||
else {
|
||||
headers["content-length"] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// default content-type for JSON if body is set
|
||||
if (!headers["content-type"] && typeof body !== "undefined") {
|
||||
headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
|
||||
// fetch does not allow to set `content-length` header, but we can set body to an empty string
|
||||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||||
body = "";
|
||||
}
|
||||
// Only return body/request keys if present
|
||||
return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null);
|
||||
}
|
17
node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
generated
vendored
Normal file
17
node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
export function addQueryParameters(url, parameters) {
|
||||
const separator = /\?/.test(url) ? "&" : "?";
|
||||
const names = Object.keys(parameters);
|
||||
if (names.length === 0) {
|
||||
return url;
|
||||
}
|
||||
return (url +
|
||||
separator +
|
||||
names
|
||||
.map((name) => {
|
||||
if (name === "q") {
|
||||
return ("q=" + parameters.q.split("+").map(encodeURIComponent).join("+"));
|
||||
}
|
||||
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||||
})
|
||||
.join("&"));
|
||||
}
|
11
node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
generated
vendored
Normal file
11
node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
const urlVariableRegex = /\{[^}]+\}/g;
|
||||
function removeNonChars(variableName) {
|
||||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
|
||||
}
|
||||
export function extractUrlVariableNames(url) {
|
||||
const matches = url.match(urlVariableRegex);
|
||||
if (!matches) {
|
||||
return [];
|
||||
}
|
||||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
||||
}
|
9
node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
generated
vendored
Normal file
9
node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
export function lowercaseKeys(object) {
|
||||
if (!object) {
|
||||
return {};
|
||||
}
|
||||
return Object.keys(object).reduce((newObj, key) => {
|
||||
newObj[key.toLowerCase()] = object[key];
|
||||
return newObj;
|
||||
}, {});
|
||||
}
|
16
node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
generated
vendored
Normal file
16
node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
import { isPlainObject } from "is-plain-object";
|
||||
export function mergeDeep(defaults, options) {
|
||||
const result = Object.assign({}, defaults);
|
||||
Object.keys(options).forEach((key) => {
|
||||
if (isPlainObject(options[key])) {
|
||||
if (!(key in defaults))
|
||||
Object.assign(result, { [key]: options[key] });
|
||||
else
|
||||
result[key] = mergeDeep(defaults[key], options[key]);
|
||||
}
|
||||
else {
|
||||
Object.assign(result, { [key]: options[key] });
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
8
node_modules/@octokit/endpoint/dist-src/util/omit.js
generated
vendored
Normal file
8
node_modules/@octokit/endpoint/dist-src/util/omit.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export function omit(object, keysToOmit) {
|
||||
return Object.keys(object)
|
||||
.filter((option) => !keysToOmit.includes(option))
|
||||
.reduce((obj, key) => {
|
||||
obj[key] = object[key];
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
8
node_modules/@octokit/endpoint/dist-src/util/remove-undefined-properties.js
generated
vendored
Normal file
8
node_modules/@octokit/endpoint/dist-src/util/remove-undefined-properties.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
export function removeUndefinedProperties(obj) {
|
||||
for (const key in obj) {
|
||||
if (obj[key] === undefined) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
164
node_modules/@octokit/endpoint/dist-src/util/url-template.js
generated
vendored
Normal file
164
node_modules/@octokit/endpoint/dist-src/util/url-template.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
// Based on https://github.com/bramstein/url-template, licensed under BSD
|
||||
// TODO: create separate package.
|
||||
//
|
||||
// Copyright (c) 2012-2014, Bram Stein
|
||||
// All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// 3. The name of the author may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/* istanbul ignore file */
|
||||
function encodeReserved(str) {
|
||||
return str
|
||||
.split(/(%[0-9A-Fa-f]{2})/g)
|
||||
.map(function (part) {
|
||||
if (!/%[0-9A-Fa-f]/.test(part)) {
|
||||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
||||
}
|
||||
return part;
|
||||
})
|
||||
.join("");
|
||||
}
|
||||
function encodeUnreserved(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
||||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||||
});
|
||||
}
|
||||
function encodeValue(operator, value, key) {
|
||||
value =
|
||||
operator === "+" || operator === "#"
|
||||
? encodeReserved(value)
|
||||
: encodeUnreserved(value);
|
||||
if (key) {
|
||||
return encodeUnreserved(key) + "=" + value;
|
||||
}
|
||||
else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
function isDefined(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
function isKeyOperator(operator) {
|
||||
return operator === ";" || operator === "&" || operator === "?";
|
||||
}
|
||||
function getValues(context, operator, key, modifier) {
|
||||
var value = context[key], result = [];
|
||||
if (isDefined(value) && value !== "") {
|
||||
if (typeof value === "string" ||
|
||||
typeof value === "number" ||
|
||||
typeof value === "boolean") {
|
||||
value = value.toString();
|
||||
if (modifier && modifier !== "*") {
|
||||
value = value.substring(0, parseInt(modifier, 10));
|
||||
}
|
||||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
||||
}
|
||||
else {
|
||||
if (modifier === "*") {
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function (value) {
|
||||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.keys(value).forEach(function (k) {
|
||||
if (isDefined(value[k])) {
|
||||
result.push(encodeValue(operator, value[k], k));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
const tmp = [];
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function (value) {
|
||||
tmp.push(encodeValue(operator, value));
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.keys(value).forEach(function (k) {
|
||||
if (isDefined(value[k])) {
|
||||
tmp.push(encodeUnreserved(k));
|
||||
tmp.push(encodeValue(operator, value[k].toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isKeyOperator(operator)) {
|
||||
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
||||
}
|
||||
else if (tmp.length !== 0) {
|
||||
result.push(tmp.join(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (operator === ";") {
|
||||
if (isDefined(value)) {
|
||||
result.push(encodeUnreserved(key));
|
||||
}
|
||||
}
|
||||
else if (value === "" && (operator === "&" || operator === "?")) {
|
||||
result.push(encodeUnreserved(key) + "=");
|
||||
}
|
||||
else if (value === "") {
|
||||
result.push("");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export function parseUrl(template) {
|
||||
return {
|
||||
expand: expand.bind(null, template),
|
||||
};
|
||||
}
|
||||
function expand(template, context) {
|
||||
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
||||
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
|
||||
if (expression) {
|
||||
let operator = "";
|
||||
const values = [];
|
||||
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
||||
operator = expression.charAt(0);
|
||||
expression = expression.substr(1);
|
||||
}
|
||||
expression.split(/,/g).forEach(function (variable) {
|
||||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
||||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
||||
});
|
||||
if (operator && operator !== "+") {
|
||||
var separator = ",";
|
||||
if (operator === "?") {
|
||||
separator = "&";
|
||||
}
|
||||
else if (operator !== "#") {
|
||||
separator = operator;
|
||||
}
|
||||
return (values.length !== 0 ? operator : "") + values.join(separator);
|
||||
}
|
||||
else {
|
||||
return values.join(",");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return encodeReserved(literal);
|
||||
}
|
||||
});
|
||||
}
|
1
node_modules/@octokit/endpoint/dist-src/version.js
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-src/version.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export const VERSION = "6.0.12";
|
13
node_modules/@octokit/endpoint/dist-src/with-defaults.js
generated
vendored
Normal file
13
node_modules/@octokit/endpoint/dist-src/with-defaults.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { endpointWithDefaults } from "./endpoint-with-defaults";
|
||||
import { merge } from "./merge";
|
||||
import { parse } from "./parse";
|
||||
export function withDefaults(oldDefaults, newDefaults) {
|
||||
const DEFAULTS = merge(oldDefaults, newDefaults);
|
||||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
|
||||
return Object.assign(endpoint, {
|
||||
DEFAULTS,
|
||||
defaults: withDefaults.bind(null, DEFAULTS),
|
||||
merge: merge.bind(null, DEFAULTS),
|
||||
parse,
|
||||
});
|
||||
}
|
2
node_modules/@octokit/endpoint/dist-types/defaults.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/endpoint/dist-types/defaults.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { EndpointDefaults } from "@octokit/types";
|
||||
export declare const DEFAULTS: EndpointDefaults;
|
3
node_modules/@octokit/endpoint/dist-types/endpoint-with-defaults.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/endpoint/dist-types/endpoint-with-defaults.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { EndpointOptions, RequestParameters, Route } from "@octokit/types";
|
||||
import { DEFAULTS } from "./defaults";
|
||||
export declare function endpointWithDefaults(defaults: typeof DEFAULTS, route: Route | EndpointOptions, options?: RequestParameters): import("@octokit/types").RequestOptions;
|
1
node_modules/@octokit/endpoint/dist-types/index.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-types/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const endpoint: import("@octokit/types").EndpointInterface<object>;
|
2
node_modules/@octokit/endpoint/dist-types/merge.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/endpoint/dist-types/merge.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { EndpointDefaults, RequestParameters, Route } from "@octokit/types";
|
||||
export declare function merge(defaults: EndpointDefaults | null, route?: Route | RequestParameters, options?: RequestParameters): EndpointDefaults;
|
2
node_modules/@octokit/endpoint/dist-types/parse.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/endpoint/dist-types/parse.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { EndpointDefaults, RequestOptions } from "@octokit/types";
|
||||
export declare function parse(options: EndpointDefaults): RequestOptions;
|
4
node_modules/@octokit/endpoint/dist-types/util/add-query-parameters.d.ts
generated
vendored
Normal file
4
node_modules/@octokit/endpoint/dist-types/util/add-query-parameters.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
export declare function addQueryParameters(url: string, parameters: {
|
||||
[x: string]: string | undefined;
|
||||
q?: string;
|
||||
}): string;
|
1
node_modules/@octokit/endpoint/dist-types/util/extract-url-variable-names.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-types/util/extract-url-variable-names.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function extractUrlVariableNames(url: string): string[];
|
5
node_modules/@octokit/endpoint/dist-types/util/lowercase-keys.d.ts
generated
vendored
Normal file
5
node_modules/@octokit/endpoint/dist-types/util/lowercase-keys.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export declare function lowercaseKeys(object?: {
|
||||
[key: string]: any;
|
||||
}): {
|
||||
[key: string]: any;
|
||||
};
|
1
node_modules/@octokit/endpoint/dist-types/util/merge-deep.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-types/util/merge-deep.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function mergeDeep(defaults: any, options: any): object;
|
5
node_modules/@octokit/endpoint/dist-types/util/omit.d.ts
generated
vendored
Normal file
5
node_modules/@octokit/endpoint/dist-types/util/omit.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export declare function omit(object: {
|
||||
[key: string]: any;
|
||||
}, keysToOmit: string[]): {
|
||||
[key: string]: any;
|
||||
};
|
1
node_modules/@octokit/endpoint/dist-types/util/remove-undefined-properties.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-types/util/remove-undefined-properties.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare function removeUndefinedProperties(obj: any): any;
|
3
node_modules/@octokit/endpoint/dist-types/util/url-template.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/endpoint/dist-types/util/url-template.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare function parseUrl(template: string): {
|
||||
expand: (context: object) => string;
|
||||
};
|
1
node_modules/@octokit/endpoint/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-types/version.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const VERSION = "6.0.12";
|
2
node_modules/@octokit/endpoint/dist-types/with-defaults.d.ts
generated
vendored
Normal file
2
node_modules/@octokit/endpoint/dist-types/with-defaults.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { EndpointInterface, RequestParameters, EndpointDefaults } from "@octokit/types";
|
||||
export declare function withDefaults(oldDefaults: EndpointDefaults | null, newDefaults: RequestParameters): EndpointInterface;
|
381
node_modules/@octokit/endpoint/dist-web/index.js
generated
vendored
Normal file
381
node_modules/@octokit/endpoint/dist-web/index.js
generated
vendored
Normal file
@ -0,0 +1,381 @@
|
||||
import { isPlainObject } from 'is-plain-object';
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
|
||||
function lowercaseKeys(object) {
|
||||
if (!object) {
|
||||
return {};
|
||||
}
|
||||
return Object.keys(object).reduce((newObj, key) => {
|
||||
newObj[key.toLowerCase()] = object[key];
|
||||
return newObj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function mergeDeep(defaults, options) {
|
||||
const result = Object.assign({}, defaults);
|
||||
Object.keys(options).forEach((key) => {
|
||||
if (isPlainObject(options[key])) {
|
||||
if (!(key in defaults))
|
||||
Object.assign(result, { [key]: options[key] });
|
||||
else
|
||||
result[key] = mergeDeep(defaults[key], options[key]);
|
||||
}
|
||||
else {
|
||||
Object.assign(result, { [key]: options[key] });
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function removeUndefinedProperties(obj) {
|
||||
for (const key in obj) {
|
||||
if (obj[key] === undefined) {
|
||||
delete obj[key];
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function merge(defaults, route, options) {
|
||||
if (typeof route === "string") {
|
||||
let [method, url] = route.split(" ");
|
||||
options = Object.assign(url ? { method, url } : { url: method }, options);
|
||||
}
|
||||
else {
|
||||
options = Object.assign({}, route);
|
||||
}
|
||||
// lowercase header names before merging with defaults to avoid duplicates
|
||||
options.headers = lowercaseKeys(options.headers);
|
||||
// remove properties with undefined values before merging
|
||||
removeUndefinedProperties(options);
|
||||
removeUndefinedProperties(options.headers);
|
||||
const mergedOptions = mergeDeep(defaults || {}, options);
|
||||
// mediaType.previews arrays are merged, instead of overwritten
|
||||
if (defaults && defaults.mediaType.previews.length) {
|
||||
mergedOptions.mediaType.previews = defaults.mediaType.previews
|
||||
.filter((preview) => !mergedOptions.mediaType.previews.includes(preview))
|
||||
.concat(mergedOptions.mediaType.previews);
|
||||
}
|
||||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, ""));
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
function addQueryParameters(url, parameters) {
|
||||
const separator = /\?/.test(url) ? "&" : "?";
|
||||
const names = Object.keys(parameters);
|
||||
if (names.length === 0) {
|
||||
return url;
|
||||
}
|
||||
return (url +
|
||||
separator +
|
||||
names
|
||||
.map((name) => {
|
||||
if (name === "q") {
|
||||
return ("q=" + parameters.q.split("+").map(encodeURIComponent).join("+"));
|
||||
}
|
||||
return `${name}=${encodeURIComponent(parameters[name])}`;
|
||||
})
|
||||
.join("&"));
|
||||
}
|
||||
|
||||
const urlVariableRegex = /\{[^}]+\}/g;
|
||||
function removeNonChars(variableName) {
|
||||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/);
|
||||
}
|
||||
function extractUrlVariableNames(url) {
|
||||
const matches = url.match(urlVariableRegex);
|
||||
if (!matches) {
|
||||
return [];
|
||||
}
|
||||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []);
|
||||
}
|
||||
|
||||
function omit(object, keysToOmit) {
|
||||
return Object.keys(object)
|
||||
.filter((option) => !keysToOmit.includes(option))
|
||||
.reduce((obj, key) => {
|
||||
obj[key] = object[key];
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
// Based on https://github.com/bramstein/url-template, licensed under BSD
|
||||
// TODO: create separate package.
|
||||
//
|
||||
// Copyright (c) 2012-2014, Bram Stein
|
||||
// All rights reserved.
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// 1. Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// 3. The name of the author may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
/* istanbul ignore file */
|
||||
function encodeReserved(str) {
|
||||
return str
|
||||
.split(/(%[0-9A-Fa-f]{2})/g)
|
||||
.map(function (part) {
|
||||
if (!/%[0-9A-Fa-f]/.test(part)) {
|
||||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]");
|
||||
}
|
||||
return part;
|
||||
})
|
||||
.join("");
|
||||
}
|
||||
function encodeUnreserved(str) {
|
||||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) {
|
||||
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
|
||||
});
|
||||
}
|
||||
function encodeValue(operator, value, key) {
|
||||
value =
|
||||
operator === "+" || operator === "#"
|
||||
? encodeReserved(value)
|
||||
: encodeUnreserved(value);
|
||||
if (key) {
|
||||
return encodeUnreserved(key) + "=" + value;
|
||||
}
|
||||
else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
function isDefined(value) {
|
||||
return value !== undefined && value !== null;
|
||||
}
|
||||
function isKeyOperator(operator) {
|
||||
return operator === ";" || operator === "&" || operator === "?";
|
||||
}
|
||||
function getValues(context, operator, key, modifier) {
|
||||
var value = context[key], result = [];
|
||||
if (isDefined(value) && value !== "") {
|
||||
if (typeof value === "string" ||
|
||||
typeof value === "number" ||
|
||||
typeof value === "boolean") {
|
||||
value = value.toString();
|
||||
if (modifier && modifier !== "*") {
|
||||
value = value.substring(0, parseInt(modifier, 10));
|
||||
}
|
||||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
||||
}
|
||||
else {
|
||||
if (modifier === "*") {
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function (value) {
|
||||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : ""));
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.keys(value).forEach(function (k) {
|
||||
if (isDefined(value[k])) {
|
||||
result.push(encodeValue(operator, value[k], k));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
const tmp = [];
|
||||
if (Array.isArray(value)) {
|
||||
value.filter(isDefined).forEach(function (value) {
|
||||
tmp.push(encodeValue(operator, value));
|
||||
});
|
||||
}
|
||||
else {
|
||||
Object.keys(value).forEach(function (k) {
|
||||
if (isDefined(value[k])) {
|
||||
tmp.push(encodeUnreserved(k));
|
||||
tmp.push(encodeValue(operator, value[k].toString()));
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isKeyOperator(operator)) {
|
||||
result.push(encodeUnreserved(key) + "=" + tmp.join(","));
|
||||
}
|
||||
else if (tmp.length !== 0) {
|
||||
result.push(tmp.join(","));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (operator === ";") {
|
||||
if (isDefined(value)) {
|
||||
result.push(encodeUnreserved(key));
|
||||
}
|
||||
}
|
||||
else if (value === "" && (operator === "&" || operator === "?")) {
|
||||
result.push(encodeUnreserved(key) + "=");
|
||||
}
|
||||
else if (value === "") {
|
||||
result.push("");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function parseUrl(template) {
|
||||
return {
|
||||
expand: expand.bind(null, template),
|
||||
};
|
||||
}
|
||||
function expand(template, context) {
|
||||
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
||||
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) {
|
||||
if (expression) {
|
||||
let operator = "";
|
||||
const values = [];
|
||||
if (operators.indexOf(expression.charAt(0)) !== -1) {
|
||||
operator = expression.charAt(0);
|
||||
expression = expression.substr(1);
|
||||
}
|
||||
expression.split(/,/g).forEach(function (variable) {
|
||||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable);
|
||||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3]));
|
||||
});
|
||||
if (operator && operator !== "+") {
|
||||
var separator = ",";
|
||||
if (operator === "?") {
|
||||
separator = "&";
|
||||
}
|
||||
else if (operator !== "#") {
|
||||
separator = operator;
|
||||
}
|
||||
return (values.length !== 0 ? operator : "") + values.join(separator);
|
||||
}
|
||||
else {
|
||||
return values.join(",");
|
||||
}
|
||||
}
|
||||
else {
|
||||
return encodeReserved(literal);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function parse(options) {
|
||||
// https://fetch.spec.whatwg.org/#methods
|
||||
let method = options.method.toUpperCase();
|
||||
// replace :varname with {varname} to make it RFC 6570 compatible
|
||||
let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
||||
let headers = Object.assign({}, options.headers);
|
||||
let body;
|
||||
let parameters = omit(options, [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"mediaType",
|
||||
]);
|
||||
// extract variable names from URL to calculate remaining variables later
|
||||
const urlVariableNames = extractUrlVariableNames(url);
|
||||
url = parseUrl(url).expand(parameters);
|
||||
if (!/^http/.test(url)) {
|
||||
url = options.baseUrl + url;
|
||||
}
|
||||
const omittedParameters = Object.keys(options)
|
||||
.filter((option) => urlVariableNames.includes(option))
|
||||
.concat("baseUrl");
|
||||
const remainingParameters = omit(parameters, omittedParameters);
|
||||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept);
|
||||
if (!isBinaryRequest) {
|
||||
if (options.mediaType.format) {
|
||||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw
|
||||
headers.accept = headers.accept
|
||||
.split(/,/)
|
||||
.map((preview) => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`))
|
||||
.join(",");
|
||||
}
|
||||
if (options.mediaType.previews.length) {
|
||||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || [];
|
||||
headers.accept = previewsFromAcceptHeader
|
||||
.concat(options.mediaType.previews)
|
||||
.map((preview) => {
|
||||
const format = options.mediaType.format
|
||||
? `.${options.mediaType.format}`
|
||||
: "+json";
|
||||
return `application/vnd.github.${preview}-preview${format}`;
|
||||
})
|
||||
.join(",");
|
||||
}
|
||||
}
|
||||
// for GET/HEAD requests, set URL query parameters from remaining parameters
|
||||
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters
|
||||
if (["GET", "HEAD"].includes(method)) {
|
||||
url = addQueryParameters(url, remainingParameters);
|
||||
}
|
||||
else {
|
||||
if ("data" in remainingParameters) {
|
||||
body = remainingParameters.data;
|
||||
}
|
||||
else {
|
||||
if (Object.keys(remainingParameters).length) {
|
||||
body = remainingParameters;
|
||||
}
|
||||
else {
|
||||
headers["content-length"] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// default content-type for JSON if body is set
|
||||
if (!headers["content-type"] && typeof body !== "undefined") {
|
||||
headers["content-type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body.
|
||||
// fetch does not allow to set `content-length` header, but we can set body to an empty string
|
||||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") {
|
||||
body = "";
|
||||
}
|
||||
// Only return body/request keys if present
|
||||
return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null);
|
||||
}
|
||||
|
||||
function endpointWithDefaults(defaults, route, options) {
|
||||
return parse(merge(defaults, route, options));
|
||||
}
|
||||
|
||||
function withDefaults(oldDefaults, newDefaults) {
|
||||
const DEFAULTS = merge(oldDefaults, newDefaults);
|
||||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS);
|
||||
return Object.assign(endpoint, {
|
||||
DEFAULTS,
|
||||
defaults: withDefaults.bind(null, DEFAULTS),
|
||||
merge: merge.bind(null, DEFAULTS),
|
||||
parse,
|
||||
});
|
||||
}
|
||||
|
||||
const VERSION = "6.0.12";
|
||||
|
||||
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`;
|
||||
// DEFAULTS has all properties set that EndpointOptions has, except url.
|
||||
// So we use RequestParameters and add method as additional required property.
|
||||
const DEFAULTS = {
|
||||
method: "GET",
|
||||
baseUrl: "https://api.github.com",
|
||||
headers: {
|
||||
accept: "application/vnd.github.v3+json",
|
||||
"user-agent": userAgent,
|
||||
},
|
||||
mediaType: {
|
||||
format: "",
|
||||
previews: [],
|
||||
},
|
||||
};
|
||||
|
||||
const endpoint = withDefaults(null, DEFAULTS);
|
||||
|
||||
export { endpoint };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/endpoint/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/endpoint/dist-web/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
44
node_modules/@octokit/endpoint/package.json
generated
vendored
Normal file
44
node_modules/@octokit/endpoint/package.json
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "@octokit/endpoint",
|
||||
"description": "Turns REST API endpoints into generic request options",
|
||||
"version": "6.0.12",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"rest"
|
||||
],
|
||||
"repository": "github:octokit/endpoint.js",
|
||||
"dependencies": {
|
||||
"@octokit/types": "^6.0.3",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/jest": "^26.0.0",
|
||||
"jest": "^27.0.0",
|
||||
"prettier": "2.3.1",
|
||||
"semantic-release": "^17.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^27.0.0-next.12",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js"
|
||||
}
|
21
node_modules/@octokit/graphql/LICENSE
generated
vendored
Normal file
21
node_modules/@octokit/graphql/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2018 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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 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.
|
409
node_modules/@octokit/graphql/README.md
generated
vendored
Normal file
409
node_modules/@octokit/graphql/README.md
generated
vendored
Normal file
@ -0,0 +1,409 @@
|
||||
# graphql.js
|
||||
|
||||
> GitHub GraphQL API client for browsers and Node
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/graphql)
|
||||
[](https://github.com/octokit/graphql.js/actions?query=workflow%3ATest+branch%3Amaster)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [Send a simple query](#send-a-simple-query)
|
||||
- [Authentication](#authentication)
|
||||
- [Variables](#variables)
|
||||
- [Pass query together with headers and variables](#pass-query-together-with-headers-and-variables)
|
||||
- [Use with GitHub Enterprise](#use-with-github-enterprise)
|
||||
- [Use custom `@octokit/request` instance](#use-custom-octokitrequest-instance)
|
||||
- [TypeScript](#typescript)
|
||||
- [Additional Types](#additional-types)
|
||||
- [Errors](#errors)
|
||||
- [Partial responses](#partial-responses)
|
||||
- [Writing tests](#writing-tests)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/graphql` directly from [cdn.skypack.dev](https://cdn.skypack.dev)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { graphql } from "https://cdn.skypack.dev/@octokit/graphql";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/graphql</code>
|
||||
|
||||
```js
|
||||
const { graphql } = require("@octokit/graphql");
|
||||
// or: import { graphql } from "@octokit/graphql";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### Send a simple query
|
||||
|
||||
```js
|
||||
const { repository } = await graphql(
|
||||
`
|
||||
{
|
||||
repository(owner: "octokit", name: "graphql.js") {
|
||||
issues(last: 3) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
{
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Authentication
|
||||
|
||||
The simplest way to authenticate a request is to set the `Authorization` header, e.g. to a [personal access token](https://github.com/settings/tokens/).
|
||||
|
||||
```js
|
||||
const graphqlWithAuth = graphql.defaults({
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
});
|
||||
const { repository } = await graphqlWithAuth(`
|
||||
{
|
||||
repository(owner: "octokit", name: "graphql.js") {
|
||||
issues(last: 3) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
```
|
||||
|
||||
For more complex authentication strategies such as GitHub Apps or Basic, we recommend the according authentication library exported by [`@octokit/auth`](https://github.com/octokit/auth.js).
|
||||
|
||||
```js
|
||||
const { createAppAuth } = require("@octokit/auth-app");
|
||||
const auth = createAppAuth({
|
||||
id: process.env.APP_ID,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
installationId: 123,
|
||||
});
|
||||
const graphqlWithAuth = graphql.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
});
|
||||
|
||||
const { repository } = await graphqlWithAuth(
|
||||
`{
|
||||
repository(owner: "octokit", name: "graphql.js") {
|
||||
issues(last: 3) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`
|
||||
);
|
||||
```
|
||||
|
||||
### Variables
|
||||
|
||||
⚠️ Do not use [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) in the query strings as they make your code vulnerable to query injection attacks (see [#2](https://github.com/octokit/graphql.js/issues/2)). Use variables instead:
|
||||
|
||||
```js
|
||||
const { lastIssues } = await graphql(
|
||||
`
|
||||
query lastIssues($owner: String!, $repo: String!, $num: Int = 3) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
issues(last: $num) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
{
|
||||
owner: "octokit",
|
||||
repo: "graphql.js",
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
### Pass query together with headers and variables
|
||||
|
||||
```js
|
||||
const { graphql } = require("@octokit/graphql");
|
||||
const { lastIssues } = await graphql({
|
||||
query: `query lastIssues($owner: String!, $repo: String!, $num: Int = 3) {
|
||||
repository(owner:$owner, name:$repo) {
|
||||
issues(last:$num) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`,
|
||||
owner: "octokit",
|
||||
repo: "graphql.js",
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Use with GitHub Enterprise
|
||||
|
||||
```js
|
||||
let { graphql } = require("@octokit/graphql");
|
||||
graphql = graphql.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api",
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
});
|
||||
const { repository } = await graphql(`
|
||||
{
|
||||
repository(owner: "acme-project", name: "acme-repo") {
|
||||
issues(last: 3) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
```
|
||||
|
||||
### Use custom `@octokit/request` instance
|
||||
|
||||
```js
|
||||
const { request } = require("@octokit/request");
|
||||
const { withCustomRequest } = require("@octokit/graphql");
|
||||
|
||||
let requestCounter = 0;
|
||||
const myRequest = request.defaults({
|
||||
headers: {
|
||||
authentication: "token secret123",
|
||||
},
|
||||
request: {
|
||||
hook(request, options) {
|
||||
requestCounter++;
|
||||
return request(options);
|
||||
},
|
||||
},
|
||||
});
|
||||
const myGraphql = withCustomRequest(myRequest);
|
||||
await request("/");
|
||||
await myGraphql(`
|
||||
{
|
||||
repository(owner: "acme-project", name: "acme-repo") {
|
||||
issues(last: 3) {
|
||||
edges {
|
||||
node {
|
||||
title
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`);
|
||||
// requestCounter is now 2
|
||||
```
|
||||
|
||||
## TypeScript
|
||||
|
||||
`@octokit/graphql` is exposing proper types for its usage with TypeScript projects.
|
||||
|
||||
### Additional Types
|
||||
|
||||
Additionally, `GraphQlQueryResponseData` has been exposed to users:
|
||||
|
||||
```ts
|
||||
import type { GraphQlQueryResponseData } from "@octokit/graphql";
|
||||
```
|
||||
|
||||
## Errors
|
||||
|
||||
In case of a GraphQL error, `error.message` is set to a combined message describing all errors returned by the endpoint.
|
||||
All errors can be accessed at `error.errors`. `error.request` has the request options such as query, variables and headers set for easier debugging.
|
||||
|
||||
```js
|
||||
let { graphql, GraphqlResponseError } = require("@octokit/graphql");
|
||||
graphqlt = graphql.defaults({
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
});
|
||||
const query = `{
|
||||
viewer {
|
||||
bioHtml
|
||||
}
|
||||
}`;
|
||||
|
||||
try {
|
||||
const result = await graphql(query);
|
||||
} catch (error) {
|
||||
if (error instanceof GraphqlResponseError) {
|
||||
// do something with the error, allowing you to detect a graphql response error,
|
||||
// compared to accidentally catching unrelated errors.
|
||||
|
||||
// server responds with an object like the following (as an example)
|
||||
// class GraphqlResponseError {
|
||||
// "headers": {
|
||||
// "status": "403",
|
||||
// },
|
||||
// "data": null,
|
||||
// "errors": [{
|
||||
// "message": "Field 'bioHtml' doesn't exist on type 'User'",
|
||||
// "locations": [{
|
||||
// "line": 3,
|
||||
// "column": 5
|
||||
// }]
|
||||
// }]
|
||||
// }
|
||||
|
||||
console.log("Request failed:", error.request); // { query, variables: {}, headers: { authorization: 'token secret123' } }
|
||||
console.log(error.message); // Field 'bioHtml' doesn't exist on type 'User'
|
||||
} else {
|
||||
// handle non-GraphQL error
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Partial responses
|
||||
|
||||
A GraphQL query may respond with partial data accompanied by errors. In this case we will throw an error but the partial data will still be accessible through `error.data`
|
||||
|
||||
```js
|
||||
let { graphql } = require("@octokit/graphql");
|
||||
graphql = graphql.defaults({
|
||||
headers: {
|
||||
authorization: `token secret123`,
|
||||
},
|
||||
});
|
||||
const query = `{
|
||||
repository(name: "probot", owner: "probot") {
|
||||
name
|
||||
ref(qualifiedName: "master") {
|
||||
target {
|
||||
... on Commit {
|
||||
history(first: 25, after: "invalid cursor") {
|
||||
nodes {
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}`;
|
||||
|
||||
try {
|
||||
const result = await graphql(query);
|
||||
} catch (error) {
|
||||
// server responds with
|
||||
// {
|
||||
// "data": {
|
||||
// "repository": {
|
||||
// "name": "probot",
|
||||
// "ref": null
|
||||
// }
|
||||
// },
|
||||
// "errors": [
|
||||
// {
|
||||
// "type": "INVALID_CURSOR_ARGUMENTS",
|
||||
// "path": [
|
||||
// "repository",
|
||||
// "ref",
|
||||
// "target",
|
||||
// "history"
|
||||
// ],
|
||||
// "locations": [
|
||||
// {
|
||||
// "line": 7,
|
||||
// "column": 11
|
||||
// }
|
||||
// ],
|
||||
// "message": "`invalid cursor` does not appear to be a valid cursor."
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
|
||||
console.log("Request failed:", error.request); // { query, variables: {}, headers: { authorization: 'token secret123' } }
|
||||
console.log(error.message); // `invalid cursor` does not appear to be a valid cursor.
|
||||
console.log(error.data); // { repository: { name: 'probot', ref: null } }
|
||||
}
|
||||
```
|
||||
|
||||
## Writing tests
|
||||
|
||||
You can pass a replacement for [the built-in fetch implementation](https://github.com/bitinn/node-fetch) as `request.fetch` option. For example, using [fetch-mock](http://www.wheresrhys.co.uk/fetch-mock/) works great to write tests
|
||||
|
||||
```js
|
||||
const assert = require("assert");
|
||||
const fetchMock = require("fetch-mock/es5/server");
|
||||
|
||||
const { graphql } = require("@octokit/graphql");
|
||||
|
||||
graphql("{ viewer { login } }", {
|
||||
headers: {
|
||||
authorization: "token secret123",
|
||||
},
|
||||
request: {
|
||||
fetch: fetchMock
|
||||
.sandbox()
|
||||
.post("https://api.github.com/graphql", (url, options) => {
|
||||
assert.strictEqual(options.headers.authorization, "token secret123");
|
||||
assert.strictEqual(
|
||||
options.body,
|
||||
'{"query":"{ viewer { login } }"}',
|
||||
"Sends correct query"
|
||||
);
|
||||
return { data: {} };
|
||||
}),
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
118
node_modules/@octokit/graphql/dist-node/index.js
generated
vendored
Normal file
118
node_modules/@octokit/graphql/dist-node/index.js
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var request = require('@octokit/request');
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
|
||||
const VERSION = "4.8.0";
|
||||
|
||||
function _buildMessageForResponseErrors(data) {
|
||||
return `Request failed due to following response errors:\n` + data.errors.map(e => ` - ${e.message}`).join("\n");
|
||||
}
|
||||
|
||||
class GraphqlResponseError extends Error {
|
||||
constructor(request, headers, response) {
|
||||
super(_buildMessageForResponseErrors(response));
|
||||
this.request = request;
|
||||
this.headers = headers;
|
||||
this.response = response;
|
||||
this.name = "GraphqlResponseError"; // Expose the errors and response data in their shorthand properties.
|
||||
|
||||
this.errors = response.errors;
|
||||
this.data = response.data; // Maintains proper stack trace (only available on V8)
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const NON_VARIABLE_OPTIONS = ["method", "baseUrl", "url", "headers", "request", "query", "mediaType"];
|
||||
const FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
||||
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
||||
function graphql(request, query, options) {
|
||||
if (options) {
|
||||
if (typeof query === "string" && "query" in options) {
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
||||
}
|
||||
|
||||
for (const key in options) {
|
||||
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key)) continue;
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
|
||||
}
|
||||
}
|
||||
|
||||
const parsedOptions = typeof query === "string" ? Object.assign({
|
||||
query
|
||||
}, options) : query;
|
||||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
||||
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
||||
result[key] = parsedOptions[key];
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!result.variables) {
|
||||
result.variables = {};
|
||||
}
|
||||
|
||||
result.variables[key] = parsedOptions[key];
|
||||
return result;
|
||||
}, {}); // workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
|
||||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
|
||||
|
||||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
|
||||
|
||||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
||||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
||||
}
|
||||
|
||||
return request(requestOptions).then(response => {
|
||||
if (response.data.errors) {
|
||||
const headers = {};
|
||||
|
||||
for (const key of Object.keys(response.headers)) {
|
||||
headers[key] = response.headers[key];
|
||||
}
|
||||
|
||||
throw new GraphqlResponseError(requestOptions, headers, response.data);
|
||||
}
|
||||
|
||||
return response.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
function withDefaults(request$1, newDefaults) {
|
||||
const newRequest = request$1.defaults(newDefaults);
|
||||
|
||||
const newApi = (query, options) => {
|
||||
return graphql(newRequest, query, options);
|
||||
};
|
||||
|
||||
return Object.assign(newApi, {
|
||||
defaults: withDefaults.bind(null, newRequest),
|
||||
endpoint: request.request.endpoint
|
||||
});
|
||||
}
|
||||
|
||||
const graphql$1 = withDefaults(request.request, {
|
||||
headers: {
|
||||
"user-agent": `octokit-graphql.js/${VERSION} ${universalUserAgent.getUserAgent()}`
|
||||
},
|
||||
method: "POST",
|
||||
url: "/graphql"
|
||||
});
|
||||
function withCustomRequest(customRequest) {
|
||||
return withDefaults(customRequest, {
|
||||
method: "POST",
|
||||
url: "/graphql"
|
||||
});
|
||||
}
|
||||
|
||||
exports.GraphqlResponseError = GraphqlResponseError;
|
||||
exports.graphql = graphql$1;
|
||||
exports.withCustomRequest = withCustomRequest;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/graphql/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/graphql/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
21
node_modules/@octokit/graphql/dist-src/error.js
generated
vendored
Normal file
21
node_modules/@octokit/graphql/dist-src/error.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
function _buildMessageForResponseErrors(data) {
|
||||
return (`Request failed due to following response errors:\n` +
|
||||
data.errors.map((e) => ` - ${e.message}`).join("\n"));
|
||||
}
|
||||
export class GraphqlResponseError extends Error {
|
||||
constructor(request, headers, response) {
|
||||
super(_buildMessageForResponseErrors(response));
|
||||
this.request = request;
|
||||
this.headers = headers;
|
||||
this.response = response;
|
||||
this.name = "GraphqlResponseError";
|
||||
// Expose the errors and response data in their shorthand properties.
|
||||
this.errors = response.errors;
|
||||
this.data = response.data;
|
||||
// Maintains proper stack trace (only available on V8)
|
||||
/* istanbul ignore next */
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
}
|
52
node_modules/@octokit/graphql/dist-src/graphql.js
generated
vendored
Normal file
52
node_modules/@octokit/graphql/dist-src/graphql.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import { GraphqlResponseError } from "./error";
|
||||
const NON_VARIABLE_OPTIONS = [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"query",
|
||||
"mediaType",
|
||||
];
|
||||
const FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
||||
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
||||
export function graphql(request, query, options) {
|
||||
if (options) {
|
||||
if (typeof query === "string" && "query" in options) {
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
||||
}
|
||||
for (const key in options) {
|
||||
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
|
||||
continue;
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
|
||||
}
|
||||
}
|
||||
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
||||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
||||
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
||||
result[key] = parsedOptions[key];
|
||||
return result;
|
||||
}
|
||||
if (!result.variables) {
|
||||
result.variables = {};
|
||||
}
|
||||
result.variables[key] = parsedOptions[key];
|
||||
return result;
|
||||
}, {});
|
||||
// workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
|
||||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
|
||||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
|
||||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
||||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
||||
}
|
||||
return request(requestOptions).then((response) => {
|
||||
if (response.data.errors) {
|
||||
const headers = {};
|
||||
for (const key of Object.keys(response.headers)) {
|
||||
headers[key] = response.headers[key];
|
||||
}
|
||||
throw new GraphqlResponseError(requestOptions, headers, response.data);
|
||||
}
|
||||
return response.data.data;
|
||||
});
|
||||
}
|
18
node_modules/@octokit/graphql/dist-src/index.js
generated
vendored
Normal file
18
node_modules/@octokit/graphql/dist-src/index.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
import { request } from "@octokit/request";
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { VERSION } from "./version";
|
||||
import { withDefaults } from "./with-defaults";
|
||||
export const graphql = withDefaults(request, {
|
||||
headers: {
|
||||
"user-agent": `octokit-graphql.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
method: "POST",
|
||||
url: "/graphql",
|
||||
});
|
||||
export { GraphqlResponseError } from "./error";
|
||||
export function withCustomRequest(customRequest) {
|
||||
return withDefaults(customRequest, {
|
||||
method: "POST",
|
||||
url: "/graphql",
|
||||
});
|
||||
}
|
1
node_modules/@octokit/graphql/dist-src/types.js
generated
vendored
Normal file
1
node_modules/@octokit/graphql/dist-src/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
1
node_modules/@octokit/graphql/dist-src/version.js
generated
vendored
Normal file
1
node_modules/@octokit/graphql/dist-src/version.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export const VERSION = "4.8.0";
|
12
node_modules/@octokit/graphql/dist-src/with-defaults.js
generated
vendored
Normal file
12
node_modules/@octokit/graphql/dist-src/with-defaults.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
import { request as Request } from "@octokit/request";
|
||||
import { graphql } from "./graphql";
|
||||
export function withDefaults(request, newDefaults) {
|
||||
const newRequest = request.defaults(newDefaults);
|
||||
const newApi = (query, options) => {
|
||||
return graphql(newRequest, query, options);
|
||||
};
|
||||
return Object.assign(newApi, {
|
||||
defaults: withDefaults.bind(null, newRequest),
|
||||
endpoint: Request.endpoint,
|
||||
});
|
||||
}
|
13
node_modules/@octokit/graphql/dist-types/error.d.ts
generated
vendored
Normal file
13
node_modules/@octokit/graphql/dist-types/error.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
import { ResponseHeaders } from "@octokit/types";
|
||||
import { GraphQlEndpointOptions, GraphQlQueryResponse } from "./types";
|
||||
declare type ServerResponseData<T> = Required<GraphQlQueryResponse<T>>;
|
||||
export declare class GraphqlResponseError<ResponseData> extends Error {
|
||||
readonly request: GraphQlEndpointOptions;
|
||||
readonly headers: ResponseHeaders;
|
||||
readonly response: ServerResponseData<ResponseData>;
|
||||
name: string;
|
||||
readonly errors: GraphQlQueryResponse<never>["errors"];
|
||||
readonly data: ResponseData;
|
||||
constructor(request: GraphQlEndpointOptions, headers: ResponseHeaders, response: ServerResponseData<ResponseData>);
|
||||
}
|
||||
export {};
|
3
node_modules/@octokit/graphql/dist-types/graphql.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/graphql/dist-types/graphql.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { request as Request } from "@octokit/request";
|
||||
import { RequestParameters, GraphQlQueryResponseData } from "./types";
|
||||
export declare function graphql<ResponseData = GraphQlQueryResponseData>(request: typeof Request, query: string | RequestParameters, options?: RequestParameters): Promise<ResponseData>;
|
5
node_modules/@octokit/graphql/dist-types/index.d.ts
generated
vendored
Normal file
5
node_modules/@octokit/graphql/dist-types/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { request } from "@octokit/request";
|
||||
export declare const graphql: import("./types").graphql;
|
||||
export { GraphQlQueryResponseData } from "./types";
|
||||
export { GraphqlResponseError } from "./error";
|
||||
export declare function withCustomRequest(customRequest: typeof request): import("./types").graphql;
|
55
node_modules/@octokit/graphql/dist-types/types.d.ts
generated
vendored
Normal file
55
node_modules/@octokit/graphql/dist-types/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
import { EndpointOptions, RequestParameters as RequestParametersType, EndpointInterface } from "@octokit/types";
|
||||
export declare type GraphQlEndpointOptions = EndpointOptions & {
|
||||
variables?: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
};
|
||||
export declare type RequestParameters = RequestParametersType;
|
||||
export declare type Query = string;
|
||||
export interface graphql {
|
||||
/**
|
||||
* Sends a GraphQL query request based on endpoint options
|
||||
* The GraphQL query must be specified in `options`.
|
||||
*
|
||||
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
||||
*/
|
||||
<ResponseData>(options: RequestParameters): GraphQlResponse<ResponseData>;
|
||||
/**
|
||||
* Sends a GraphQL query request based on endpoint options
|
||||
*
|
||||
* @param {string} query GraphQL query. Example: `'query { viewer { login } }'`.
|
||||
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
||||
*/
|
||||
<ResponseData>(query: Query, parameters?: RequestParameters): GraphQlResponse<ResponseData>;
|
||||
/**
|
||||
* Returns a new `endpoint` with updated route and parameters
|
||||
*/
|
||||
defaults: (newDefaults: RequestParameters) => graphql;
|
||||
/**
|
||||
* Octokit endpoint API, see {@link https://github.com/octokit/endpoint.js|@octokit/endpoint}
|
||||
*/
|
||||
endpoint: EndpointInterface;
|
||||
}
|
||||
export declare type GraphQlResponse<ResponseData> = Promise<ResponseData>;
|
||||
export declare type GraphQlQueryResponseData = {
|
||||
[key: string]: any;
|
||||
};
|
||||
export declare type GraphQlQueryResponse<ResponseData> = {
|
||||
data: ResponseData;
|
||||
errors?: [
|
||||
{
|
||||
type: string;
|
||||
message: string;
|
||||
path: [string];
|
||||
extensions: {
|
||||
[key: string]: any;
|
||||
};
|
||||
locations: [
|
||||
{
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
};
|
1
node_modules/@octokit/graphql/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/graphql/dist-types/version.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export declare const VERSION = "4.8.0";
|
3
node_modules/@octokit/graphql/dist-types/with-defaults.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/graphql/dist-types/with-defaults.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { request as Request } from "@octokit/request";
|
||||
import { graphql as ApiInterface, RequestParameters } from "./types";
|
||||
export declare function withDefaults(request: typeof Request, newDefaults: RequestParameters): ApiInterface;
|
106
node_modules/@octokit/graphql/dist-web/index.js
generated
vendored
Normal file
106
node_modules/@octokit/graphql/dist-web/index.js
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
import { request } from '@octokit/request';
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
|
||||
const VERSION = "4.8.0";
|
||||
|
||||
function _buildMessageForResponseErrors(data) {
|
||||
return (`Request failed due to following response errors:\n` +
|
||||
data.errors.map((e) => ` - ${e.message}`).join("\n"));
|
||||
}
|
||||
class GraphqlResponseError extends Error {
|
||||
constructor(request, headers, response) {
|
||||
super(_buildMessageForResponseErrors(response));
|
||||
this.request = request;
|
||||
this.headers = headers;
|
||||
this.response = response;
|
||||
this.name = "GraphqlResponseError";
|
||||
// Expose the errors and response data in their shorthand properties.
|
||||
this.errors = response.errors;
|
||||
this.data = response.data;
|
||||
// Maintains proper stack trace (only available on V8)
|
||||
/* istanbul ignore next */
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const NON_VARIABLE_OPTIONS = [
|
||||
"method",
|
||||
"baseUrl",
|
||||
"url",
|
||||
"headers",
|
||||
"request",
|
||||
"query",
|
||||
"mediaType",
|
||||
];
|
||||
const FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
||||
const GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
||||
function graphql(request, query, options) {
|
||||
if (options) {
|
||||
if (typeof query === "string" && "query" in options) {
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
||||
}
|
||||
for (const key in options) {
|
||||
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
|
||||
continue;
|
||||
return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
|
||||
}
|
||||
}
|
||||
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
||||
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
||||
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
||||
result[key] = parsedOptions[key];
|
||||
return result;
|
||||
}
|
||||
if (!result.variables) {
|
||||
result.variables = {};
|
||||
}
|
||||
result.variables[key] = parsedOptions[key];
|
||||
return result;
|
||||
}, {});
|
||||
// workaround for GitHub Enterprise baseUrl set with /api/v3 suffix
|
||||
// https://github.com/octokit/auth-app.js/issues/111#issuecomment-657610451
|
||||
const baseUrl = parsedOptions.baseUrl || request.endpoint.DEFAULTS.baseUrl;
|
||||
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
||||
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
||||
}
|
||||
return request(requestOptions).then((response) => {
|
||||
if (response.data.errors) {
|
||||
const headers = {};
|
||||
for (const key of Object.keys(response.headers)) {
|
||||
headers[key] = response.headers[key];
|
||||
}
|
||||
throw new GraphqlResponseError(requestOptions, headers, response.data);
|
||||
}
|
||||
return response.data.data;
|
||||
});
|
||||
}
|
||||
|
||||
function withDefaults(request$1, newDefaults) {
|
||||
const newRequest = request$1.defaults(newDefaults);
|
||||
const newApi = (query, options) => {
|
||||
return graphql(newRequest, query, options);
|
||||
};
|
||||
return Object.assign(newApi, {
|
||||
defaults: withDefaults.bind(null, newRequest),
|
||||
endpoint: request.endpoint,
|
||||
});
|
||||
}
|
||||
|
||||
const graphql$1 = withDefaults(request, {
|
||||
headers: {
|
||||
"user-agent": `octokit-graphql.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
method: "POST",
|
||||
url: "/graphql",
|
||||
});
|
||||
function withCustomRequest(customRequest) {
|
||||
return withDefaults(customRequest, {
|
||||
method: "POST",
|
||||
url: "/graphql",
|
||||
});
|
||||
}
|
||||
|
||||
export { GraphqlResponseError, graphql$1 as graphql, withCustomRequest };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/graphql/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/graphql/dist-web/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
node_modules/@octokit/graphql/package.json
generated
vendored
Normal file
47
node_modules/@octokit/graphql/package.json
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "@octokit/graphql",
|
||||
"description": "GitHub GraphQL API client for browsers and Node",
|
||||
"version": "4.8.0",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"graphql"
|
||||
],
|
||||
"repository": "github:octokit/graphql.js",
|
||||
"dependencies": {
|
||||
"@octokit/request": "^5.6.0",
|
||||
"@octokit/types": "^6.0.3",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/fetch-mock": "^7.2.5",
|
||||
"@types/jest": "^27.0.0",
|
||||
"@types/node": "^14.0.4",
|
||||
"fetch-mock": "^9.0.0",
|
||||
"jest": "^27.0.0",
|
||||
"prettier": "2.3.2",
|
||||
"semantic-release": "^17.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^27.0.0-next.12",
|
||||
"typescript": "^4.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js"
|
||||
}
|
7
node_modules/@octokit/openapi-types/LICENSE
generated
vendored
Normal file
7
node_modules/@octokit/openapi-types/LICENSE
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
Copyright 2020 Gregor Martynus
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
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 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.
|
17
node_modules/@octokit/openapi-types/README.md
generated
vendored
Normal file
17
node_modules/@octokit/openapi-types/README.md
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# @octokit/openapi-types
|
||||
|
||||
> Generated TypeScript definitions based on GitHub's OpenAPI spec
|
||||
|
||||
This package is continously updated based on [GitHub's OpenAPI specification](https://github.com/github/rest-api-description/)
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import { components } from "@octokit/openapi-types";
|
||||
|
||||
type Repository = components["schemas"]["full-repository"];
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
20
node_modules/@octokit/openapi-types/package.json
generated
vendored
Normal file
20
node_modules/@octokit/openapi-types/package.json
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@octokit/openapi-types",
|
||||
"description": "Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/octokit/openapi-types.ts.git",
|
||||
"directory": "packages/openapi-types"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"version": "12.11.0",
|
||||
"main": "",
|
||||
"types": "types.d.ts",
|
||||
"author": "Gregor Martynus (https://twitter.com/gr2m)",
|
||||
"license": "MIT",
|
||||
"octokit": {
|
||||
"openapi-version": "6.8.0"
|
||||
}
|
||||
}
|
47095
node_modules/@octokit/openapi-types/types.d.ts
generated
vendored
Normal file
47095
node_modules/@octokit/openapi-types/types.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7
node_modules/@octokit/plugin-paginate-rest/LICENSE
generated
vendored
Normal file
7
node_modules/@octokit/plugin-paginate-rest/LICENSE
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
MIT License Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
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 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.
|
269
node_modules/@octokit/plugin-paginate-rest/README.md
generated
vendored
Normal file
269
node_modules/@octokit/plugin-paginate-rest/README.md
generated
vendored
Normal file
@ -0,0 +1,269 @@
|
||||
# plugin-paginate-rest.js
|
||||
|
||||
> Octokit plugin to paginate REST API endpoint responses
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/plugin-paginate-rest)
|
||||
[](https://github.com/octokit/plugin-paginate-rest.js/actions?workflow=Test)
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
|
||||
Load `@octokit/plugin-paginate-rest` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [cdn.skypack.dev](https://cdn.skypack.dev)
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
|
||||
import {
|
||||
paginateRest,
|
||||
composePaginateRest,
|
||||
} from "https://cdn.skypack.dev/@octokit/plugin-paginate-rest";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with `npm install @octokit/core @octokit/plugin-paginate-rest`. Optionally replace `@octokit/core` with a core-compatible module
|
||||
|
||||
```js
|
||||
const { Octokit } = require("@octokit/core");
|
||||
const {
|
||||
paginateRest,
|
||||
composePaginateRest,
|
||||
} = require("@octokit/plugin-paginate-rest");
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
```js
|
||||
const MyOctokit = Octokit.plugin(paginateRest);
|
||||
const octokit = new MyOctokit({ auth: "secret123" });
|
||||
|
||||
// See https://developer.github.com/v3/issues/#list-issues-for-a-repository
|
||||
const issues = await octokit.paginate("GET /repos/{owner}/{repo}/issues", {
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
since: "2010-10-01",
|
||||
per_page: 100,
|
||||
});
|
||||
```
|
||||
|
||||
If you want to utilize the pagination methods in another plugin, use `composePaginateRest`.
|
||||
|
||||
```js
|
||||
function myPlugin(octokit, options) {
|
||||
return {
|
||||
allStars({owner, repo}) => {
|
||||
return composePaginateRest(
|
||||
octokit,
|
||||
"GET /repos/{owner}/{repo}/stargazers",
|
||||
{owner, repo }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## `octokit.paginate()`
|
||||
|
||||
The `paginateRest` plugin adds a new `octokit.paginate()` method which accepts the same parameters as [`octokit.request`](https://github.com/octokit/request.js#request). Only "List ..." endpoints such as [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository) are supporting pagination. Their [response includes a Link header](https://developer.github.com/v3/issues/#response-1). For other endpoints, `octokit.paginate()` behaves the same as `octokit.request()`.
|
||||
|
||||
The `per_page` parameter is usually defaulting to `30`, and can be set to up to `100`, which helps retrieving a big amount of data without hitting the rate limits too soon.
|
||||
|
||||
An optional `mapFunction` can be passed to map each page response to a new value, usually an array with only the data you need. This can help to reduce memory usage, as only the relevant data has to be kept in memory until the pagination is complete.
|
||||
|
||||
```js
|
||||
const issueTitles = await octokit.paginate(
|
||||
"GET /repos/{owner}/{repo}/issues",
|
||||
{
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
since: "2010-10-01",
|
||||
per_page: 100,
|
||||
},
|
||||
(response) => response.data.map((issue) => issue.title)
|
||||
);
|
||||
```
|
||||
|
||||
The `mapFunction` gets a 2nd argument `done` which can be called to end the pagination early.
|
||||
|
||||
```js
|
||||
const issues = await octokit.paginate(
|
||||
"GET /repos/{owner}/{repo}/issues",
|
||||
{
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
since: "2010-10-01",
|
||||
per_page: 100,
|
||||
},
|
||||
(response, done) => {
|
||||
if (response.data.find((issue) => issue.title.includes("something"))) {
|
||||
done();
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
Alternatively you can pass a `request` method as first argument. This is great when using in combination with [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/):
|
||||
|
||||
```js
|
||||
const issues = await octokit.paginate(octokit.rest.issues.listForRepo, {
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
since: "2010-10-01",
|
||||
per_page: 100,
|
||||
});
|
||||
```
|
||||
|
||||
## `octokit.paginate.iterator()`
|
||||
|
||||
If your target runtime environments supports async iterators (such as most modern browsers and Node 10+), you can iterate through each response
|
||||
|
||||
```js
|
||||
const parameters = {
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
since: "2010-10-01",
|
||||
per_page: 100,
|
||||
};
|
||||
for await (const response of octokit.paginate.iterator(
|
||||
"GET /repos/{owner}/{repo}/issues",
|
||||
parameters
|
||||
)) {
|
||||
// do whatever you want with each response, break out of the loop, etc.
|
||||
const issues = response.data;
|
||||
console.log("%d issues found", issues.length);
|
||||
}
|
||||
```
|
||||
|
||||
Alternatively you can pass a `request` method as first argument. This is great when using in combination with [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/):
|
||||
|
||||
```js
|
||||
const parameters = {
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
since: "2010-10-01",
|
||||
per_page: 100,
|
||||
};
|
||||
for await (const response of octokit.paginate.iterator(
|
||||
octokit.rest.issues.listForRepo,
|
||||
parameters
|
||||
)) {
|
||||
// do whatever you want with each response, break out of the loop, etc.
|
||||
const issues = response.data;
|
||||
console.log("%d issues found", issues.length);
|
||||
}
|
||||
```
|
||||
|
||||
## `composePaginateRest` and `composePaginateRest.iterator`
|
||||
|
||||
The `compose*` methods work just like their `octokit.*` counterparts described above, with the differenct that both methods require an `octokit` instance to be passed as first argument
|
||||
|
||||
## How it works
|
||||
|
||||
`octokit.paginate()` wraps `octokit.request()`. As long as a `rel="next"` link value is present in the response's `Link` header, it sends another request for that URL, and so on.
|
||||
|
||||
Most of GitHub's paginating REST API endpoints return an array, but there are a few exceptions which return an object with a key that includes the items array. For example:
|
||||
|
||||
- [Search repositories](https://developer.github.com/v3/search/#example) (key `items`)
|
||||
- [List check runs for a specific ref](https://developer.github.com/v3/checks/runs/#response-3) (key: `check_runs`)
|
||||
- [List check suites for a specific ref](https://developer.github.com/v3/checks/suites/#response-1) (key: `check_suites`)
|
||||
- [List repositories](https://developer.github.com/v3/apps/installations/#list-repositories) for an installation (key: `repositories`)
|
||||
- [List installations for a user](https://developer.github.com/v3/apps/installations/#response-1) (key `installations`)
|
||||
|
||||
`octokit.paginate()` is working around these inconsistencies so you don't have to worry about it.
|
||||
|
||||
If a response is lacking the `Link` header, `octokit.paginate()` still resolves with an array, even if the response returns a single object.
|
||||
|
||||
## Types
|
||||
|
||||
The plugin also exposes some types and runtime type guards for TypeScript projects.
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Types
|
||||
</th><td>
|
||||
|
||||
```typescript
|
||||
import {
|
||||
PaginateInterface,
|
||||
PaginatingEndpoints,
|
||||
} from "@octokit/plugin-paginate-rest";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Guards
|
||||
</th><td>
|
||||
|
||||
```typescript
|
||||
import { isPaginatingEndpoint } from "@octokit/plugin-paginate-rest";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### PaginateInterface
|
||||
|
||||
An `interface` that declares all the overloads of the `.paginate` method.
|
||||
|
||||
### PaginatingEndpoints
|
||||
|
||||
An `interface` which describes all API endpoints supported by the plugin. Some overloads of `.paginate()` method and `composePaginateRest()` function depend on `PaginatingEndpoints`, using the `keyof PaginatingEndpoints` as a type for one of its arguments.
|
||||
|
||||
```typescript
|
||||
import { Octokit } from "@octokit/core";
|
||||
import {
|
||||
PaginatingEndpoints,
|
||||
composePaginateRest,
|
||||
} from "@octokit/plugin-paginate-rest";
|
||||
|
||||
type DataType<T> = "data" extends keyof T ? T["data"] : unknown;
|
||||
|
||||
async function myPaginatePlugin<E extends keyof PaginatingEndpoints>(
|
||||
octokit: Octokit,
|
||||
endpoint: E,
|
||||
parameters?: PaginatingEndpoints[E]["parameters"]
|
||||
): Promise<DataType<PaginatingEndpoints[E]["response"]>> {
|
||||
return await composePaginateRest(octokit, endpoint, parameters);
|
||||
}
|
||||
```
|
||||
|
||||
### isPaginatingEndpoint
|
||||
|
||||
A type guard, `isPaginatingEndpoint(arg)` returns `true` if `arg` is one of the keys in `PaginatingEndpoints` (is `keyof PaginatingEndpoints`).
|
||||
|
||||
```typescript
|
||||
import { Octokit } from "@octokit/core";
|
||||
import {
|
||||
isPaginatingEndpoint,
|
||||
composePaginateRest,
|
||||
} from "@octokit/plugin-paginate-rest";
|
||||
|
||||
async function myPlugin(octokit: Octokit, arg: unknown) {
|
||||
if (isPaginatingEndpoint(arg)) {
|
||||
return await composePaginateRest(octokit, arg);
|
||||
}
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
205
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js
generated
vendored
Normal file
205
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/@octokit/plugin-paginate-rest/dist-src/compose-paginate.js
generated
vendored
Normal file
5
node_modules/@octokit/plugin-paginate-rest/dist-src/compose-paginate.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { paginate } from "./paginate";
|
||||
import { iterator } from "./iterator";
|
||||
export const composePaginateRest = Object.assign(paginate, {
|
||||
iterator,
|
||||
});
|
216
node_modules/@octokit/plugin-paginate-rest/dist-src/generated/paginating-endpoints.js
generated
vendored
Normal file
216
node_modules/@octokit/plugin-paginate-rest/dist-src/generated/paginating-endpoints.js
generated
vendored
Normal file
@ -0,0 +1,216 @@
|
||||
export const paginatingEndpoints = [
|
||||
"GET /app/hook/deliveries",
|
||||
"GET /app/installations",
|
||||
"GET /applications/grants",
|
||||
"GET /authorizations",
|
||||
"GET /enterprises/{enterprise}/actions/permissions/organizations",
|
||||
"GET /enterprises/{enterprise}/actions/runner-groups",
|
||||
"GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/organizations",
|
||||
"GET /enterprises/{enterprise}/actions/runner-groups/{runner_group_id}/runners",
|
||||
"GET /enterprises/{enterprise}/actions/runners",
|
||||
"GET /enterprises/{enterprise}/audit-log",
|
||||
"GET /enterprises/{enterprise}/secret-scanning/alerts",
|
||||
"GET /enterprises/{enterprise}/settings/billing/advanced-security",
|
||||
"GET /events",
|
||||
"GET /gists",
|
||||
"GET /gists/public",
|
||||
"GET /gists/starred",
|
||||
"GET /gists/{gist_id}/comments",
|
||||
"GET /gists/{gist_id}/commits",
|
||||
"GET /gists/{gist_id}/forks",
|
||||
"GET /installation/repositories",
|
||||
"GET /issues",
|
||||
"GET /licenses",
|
||||
"GET /marketplace_listing/plans",
|
||||
"GET /marketplace_listing/plans/{plan_id}/accounts",
|
||||
"GET /marketplace_listing/stubbed/plans",
|
||||
"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
||||
"GET /networks/{owner}/{repo}/events",
|
||||
"GET /notifications",
|
||||
"GET /organizations",
|
||||
"GET /orgs/{org}/actions/cache/usage-by-repository",
|
||||
"GET /orgs/{org}/actions/permissions/repositories",
|
||||
"GET /orgs/{org}/actions/runner-groups",
|
||||
"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories",
|
||||
"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners",
|
||||
"GET /orgs/{org}/actions/runners",
|
||||
"GET /orgs/{org}/actions/secrets",
|
||||
"GET /orgs/{org}/actions/secrets/{secret_name}/repositories",
|
||||
"GET /orgs/{org}/audit-log",
|
||||
"GET /orgs/{org}/blocks",
|
||||
"GET /orgs/{org}/code-scanning/alerts",
|
||||
"GET /orgs/{org}/codespaces",
|
||||
"GET /orgs/{org}/credential-authorizations",
|
||||
"GET /orgs/{org}/dependabot/secrets",
|
||||
"GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories",
|
||||
"GET /orgs/{org}/events",
|
||||
"GET /orgs/{org}/external-groups",
|
||||
"GET /orgs/{org}/failed_invitations",
|
||||
"GET /orgs/{org}/hooks",
|
||||
"GET /orgs/{org}/hooks/{hook_id}/deliveries",
|
||||
"GET /orgs/{org}/installations",
|
||||
"GET /orgs/{org}/invitations",
|
||||
"GET /orgs/{org}/invitations/{invitation_id}/teams",
|
||||
"GET /orgs/{org}/issues",
|
||||
"GET /orgs/{org}/members",
|
||||
"GET /orgs/{org}/migrations",
|
||||
"GET /orgs/{org}/migrations/{migration_id}/repositories",
|
||||
"GET /orgs/{org}/outside_collaborators",
|
||||
"GET /orgs/{org}/packages",
|
||||
"GET /orgs/{org}/packages/{package_type}/{package_name}/versions",
|
||||
"GET /orgs/{org}/projects",
|
||||
"GET /orgs/{org}/public_members",
|
||||
"GET /orgs/{org}/repos",
|
||||
"GET /orgs/{org}/secret-scanning/alerts",
|
||||
"GET /orgs/{org}/settings/billing/advanced-security",
|
||||
"GET /orgs/{org}/team-sync/groups",
|
||||
"GET /orgs/{org}/teams",
|
||||
"GET /orgs/{org}/teams/{team_slug}/discussions",
|
||||
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments",
|
||||
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions",
|
||||
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions",
|
||||
"GET /orgs/{org}/teams/{team_slug}/invitations",
|
||||
"GET /orgs/{org}/teams/{team_slug}/members",
|
||||
"GET /orgs/{org}/teams/{team_slug}/projects",
|
||||
"GET /orgs/{org}/teams/{team_slug}/repos",
|
||||
"GET /orgs/{org}/teams/{team_slug}/teams",
|
||||
"GET /projects/columns/{column_id}/cards",
|
||||
"GET /projects/{project_id}/collaborators",
|
||||
"GET /projects/{project_id}/columns",
|
||||
"GET /repos/{owner}/{repo}/actions/artifacts",
|
||||
"GET /repos/{owner}/{repo}/actions/caches",
|
||||
"GET /repos/{owner}/{repo}/actions/runners",
|
||||
"GET /repos/{owner}/{repo}/actions/runs",
|
||||
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts",
|
||||
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs",
|
||||
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs",
|
||||
"GET /repos/{owner}/{repo}/actions/secrets",
|
||||
"GET /repos/{owner}/{repo}/actions/workflows",
|
||||
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs",
|
||||
"GET /repos/{owner}/{repo}/assignees",
|
||||
"GET /repos/{owner}/{repo}/branches",
|
||||
"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations",
|
||||
"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs",
|
||||
"GET /repos/{owner}/{repo}/code-scanning/alerts",
|
||||
"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances",
|
||||
"GET /repos/{owner}/{repo}/code-scanning/analyses",
|
||||
"GET /repos/{owner}/{repo}/codespaces",
|
||||
"GET /repos/{owner}/{repo}/codespaces/devcontainers",
|
||||
"GET /repos/{owner}/{repo}/codespaces/secrets",
|
||||
"GET /repos/{owner}/{repo}/collaborators",
|
||||
"GET /repos/{owner}/{repo}/comments",
|
||||
"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions",
|
||||
"GET /repos/{owner}/{repo}/commits",
|
||||
"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments",
|
||||
"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls",
|
||||
"GET /repos/{owner}/{repo}/commits/{ref}/check-runs",
|
||||
"GET /repos/{owner}/{repo}/commits/{ref}/check-suites",
|
||||
"GET /repos/{owner}/{repo}/commits/{ref}/status",
|
||||
"GET /repos/{owner}/{repo}/commits/{ref}/statuses",
|
||||
"GET /repos/{owner}/{repo}/contributors",
|
||||
"GET /repos/{owner}/{repo}/dependabot/secrets",
|
||||
"GET /repos/{owner}/{repo}/deployments",
|
||||
"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses",
|
||||
"GET /repos/{owner}/{repo}/environments",
|
||||
"GET /repos/{owner}/{repo}/events",
|
||||
"GET /repos/{owner}/{repo}/forks",
|
||||
"GET /repos/{owner}/{repo}/git/matching-refs/{ref}",
|
||||
"GET /repos/{owner}/{repo}/hooks",
|
||||
"GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries",
|
||||
"GET /repos/{owner}/{repo}/invitations",
|
||||
"GET /repos/{owner}/{repo}/issues",
|
||||
"GET /repos/{owner}/{repo}/issues/comments",
|
||||
"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions",
|
||||
"GET /repos/{owner}/{repo}/issues/events",
|
||||
"GET /repos/{owner}/{repo}/issues/{issue_number}/comments",
|
||||
"GET /repos/{owner}/{repo}/issues/{issue_number}/events",
|
||||
"GET /repos/{owner}/{repo}/issues/{issue_number}/labels",
|
||||
"GET /repos/{owner}/{repo}/issues/{issue_number}/reactions",
|
||||
"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline",
|
||||
"GET /repos/{owner}/{repo}/keys",
|
||||
"GET /repos/{owner}/{repo}/labels",
|
||||
"GET /repos/{owner}/{repo}/milestones",
|
||||
"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels",
|
||||
"GET /repos/{owner}/{repo}/notifications",
|
||||
"GET /repos/{owner}/{repo}/pages/builds",
|
||||
"GET /repos/{owner}/{repo}/projects",
|
||||
"GET /repos/{owner}/{repo}/pulls",
|
||||
"GET /repos/{owner}/{repo}/pulls/comments",
|
||||
"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions",
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments",
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits",
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/files",
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers",
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews",
|
||||
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments",
|
||||
"GET /repos/{owner}/{repo}/releases",
|
||||
"GET /repos/{owner}/{repo}/releases/{release_id}/assets",
|
||||
"GET /repos/{owner}/{repo}/releases/{release_id}/reactions",
|
||||
"GET /repos/{owner}/{repo}/secret-scanning/alerts",
|
||||
"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations",
|
||||
"GET /repos/{owner}/{repo}/stargazers",
|
||||
"GET /repos/{owner}/{repo}/subscribers",
|
||||
"GET /repos/{owner}/{repo}/tags",
|
||||
"GET /repos/{owner}/{repo}/teams",
|
||||
"GET /repos/{owner}/{repo}/topics",
|
||||
"GET /repositories",
|
||||
"GET /repositories/{repository_id}/environments/{environment_name}/secrets",
|
||||
"GET /search/code",
|
||||
"GET /search/commits",
|
||||
"GET /search/issues",
|
||||
"GET /search/labels",
|
||||
"GET /search/repositories",
|
||||
"GET /search/topics",
|
||||
"GET /search/users",
|
||||
"GET /teams/{team_id}/discussions",
|
||||
"GET /teams/{team_id}/discussions/{discussion_number}/comments",
|
||||
"GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions",
|
||||
"GET /teams/{team_id}/discussions/{discussion_number}/reactions",
|
||||
"GET /teams/{team_id}/invitations",
|
||||
"GET /teams/{team_id}/members",
|
||||
"GET /teams/{team_id}/projects",
|
||||
"GET /teams/{team_id}/repos",
|
||||
"GET /teams/{team_id}/teams",
|
||||
"GET /user/blocks",
|
||||
"GET /user/codespaces",
|
||||
"GET /user/codespaces/secrets",
|
||||
"GET /user/emails",
|
||||
"GET /user/followers",
|
||||
"GET /user/following",
|
||||
"GET /user/gpg_keys",
|
||||
"GET /user/installations",
|
||||
"GET /user/installations/{installation_id}/repositories",
|
||||
"GET /user/issues",
|
||||
"GET /user/keys",
|
||||
"GET /user/marketplace_purchases",
|
||||
"GET /user/marketplace_purchases/stubbed",
|
||||
"GET /user/memberships/orgs",
|
||||
"GET /user/migrations",
|
||||
"GET /user/migrations/{migration_id}/repositories",
|
||||
"GET /user/orgs",
|
||||
"GET /user/packages",
|
||||
"GET /user/packages/{package_type}/{package_name}/versions",
|
||||
"GET /user/public_emails",
|
||||
"GET /user/repos",
|
||||
"GET /user/repository_invitations",
|
||||
"GET /user/starred",
|
||||
"GET /user/subscriptions",
|
||||
"GET /user/teams",
|
||||
"GET /users",
|
||||
"GET /users/{username}/events",
|
||||
"GET /users/{username}/events/orgs/{org}",
|
||||
"GET /users/{username}/events/public",
|
||||
"GET /users/{username}/followers",
|
||||
"GET /users/{username}/following",
|
||||
"GET /users/{username}/gists",
|
||||
"GET /users/{username}/gpg_keys",
|
||||
"GET /users/{username}/keys",
|
||||
"GET /users/{username}/orgs",
|
||||
"GET /users/{username}/packages",
|
||||
"GET /users/{username}/projects",
|
||||
"GET /users/{username}/received_events",
|
||||
"GET /users/{username}/received_events/public",
|
||||
"GET /users/{username}/repos",
|
||||
"GET /users/{username}/starred",
|
||||
"GET /users/{username}/subscriptions",
|
||||
];
|
17
node_modules/@octokit/plugin-paginate-rest/dist-src/index.js
generated
vendored
Normal file
17
node_modules/@octokit/plugin-paginate-rest/dist-src/index.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
import { VERSION } from "./version";
|
||||
import { paginate } from "./paginate";
|
||||
import { iterator } from "./iterator";
|
||||
export { composePaginateRest } from "./compose-paginate";
|
||||
export { isPaginatingEndpoint, paginatingEndpoints, } from "./paginating-endpoints";
|
||||
/**
|
||||
* @param octokit Octokit instance
|
||||
* @param options Options passed to Octokit constructor
|
||||
*/
|
||||
export function paginateRest(octokit) {
|
||||
return {
|
||||
paginate: Object.assign(paginate.bind(null, octokit), {
|
||||
iterator: iterator.bind(null, octokit),
|
||||
}),
|
||||
};
|
||||
}
|
||||
paginateRest.VERSION = VERSION;
|
39
node_modules/@octokit/plugin-paginate-rest/dist-src/iterator.js
generated
vendored
Normal file
39
node_modules/@octokit/plugin-paginate-rest/dist-src/iterator.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
import { normalizePaginatedListResponse } from "./normalize-paginated-list-response";
|
||||
export function iterator(octokit, route, parameters) {
|
||||
const options = typeof route === "function"
|
||||
? route.endpoint(parameters)
|
||||
: octokit.request.endpoint(route, parameters);
|
||||
const requestMethod = typeof route === "function" ? route : octokit.request;
|
||||
const method = options.method;
|
||||
const headers = options.headers;
|
||||
let url = options.url;
|
||||
return {
|
||||
[Symbol.asyncIterator]: () => ({
|
||||
async next() {
|
||||
if (!url)
|
||||
return { done: true };
|
||||
try {
|
||||
const response = await requestMethod({ method, url, headers });
|
||||
const normalizedResponse = normalizePaginatedListResponse(response);
|
||||
// `response.headers.link` format:
|
||||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
|
||||
// sets `url` to undefined if "next" URL is not present or `link` header is not set
|
||||
url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1];
|
||||
return { value: normalizedResponse };
|
||||
}
|
||||
catch (error) {
|
||||
if (error.status !== 409)
|
||||
throw error;
|
||||
url = "";
|
||||
return {
|
||||
value: {
|
||||
status: 200,
|
||||
headers: {},
|
||||
data: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
47
node_modules/@octokit/plugin-paginate-rest/dist-src/normalize-paginated-list-response.js
generated
vendored
Normal file
47
node_modules/@octokit/plugin-paginate-rest/dist-src/normalize-paginated-list-response.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Some “list” response that can be paginated have a different response structure
|
||||
*
|
||||
* They have a `total_count` key in the response (search also has `incomplete_results`,
|
||||
* /installation/repositories also has `repository_selection`), as well as a key with
|
||||
* the list of the items which name varies from endpoint to endpoint.
|
||||
*
|
||||
* Octokit normalizes these responses so that paginated results are always returned following
|
||||
* the same structure. One challenge is that if the list response has only one page, no Link
|
||||
* header is provided, so this header alone is not sufficient to check wether a response is
|
||||
* paginated or not.
|
||||
*
|
||||
* We check if a "total_count" key is present in the response data, but also make sure that
|
||||
* a "url" property is not, as the "Get the combined status for a specific ref" endpoint would
|
||||
* otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
|
||||
*/
|
||||
export function normalizePaginatedListResponse(response) {
|
||||
// endpoints can respond with 204 if repository is empty
|
||||
if (!response.data) {
|
||||
return {
|
||||
...response,
|
||||
data: [],
|
||||
};
|
||||
}
|
||||
const responseNeedsNormalization = "total_count" in response.data && !("url" in response.data);
|
||||
if (!responseNeedsNormalization)
|
||||
return response;
|
||||
// keep the additional properties intact as there is currently no other way
|
||||
// to retrieve the same information.
|
||||
const incompleteResults = response.data.incomplete_results;
|
||||
const repositorySelection = response.data.repository_selection;
|
||||
const totalCount = response.data.total_count;
|
||||
delete response.data.incomplete_results;
|
||||
delete response.data.repository_selection;
|
||||
delete response.data.total_count;
|
||||
const namespaceKey = Object.keys(response.data)[0];
|
||||
const data = response.data[namespaceKey];
|
||||
response.data = data;
|
||||
if (typeof incompleteResults !== "undefined") {
|
||||
response.data.incomplete_results = incompleteResults;
|
||||
}
|
||||
if (typeof repositorySelection !== "undefined") {
|
||||
response.data.repository_selection = repositorySelection;
|
||||
}
|
||||
response.data.total_count = totalCount;
|
||||
return response;
|
||||
}
|
24
node_modules/@octokit/plugin-paginate-rest/dist-src/paginate.js
generated
vendored
Normal file
24
node_modules/@octokit/plugin-paginate-rest/dist-src/paginate.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
import { iterator } from "./iterator";
|
||||
export function paginate(octokit, route, parameters, mapFn) {
|
||||
if (typeof parameters === "function") {
|
||||
mapFn = parameters;
|
||||
parameters = undefined;
|
||||
}
|
||||
return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);
|
||||
}
|
||||
function gather(octokit, results, iterator, mapFn) {
|
||||
return iterator.next().then((result) => {
|
||||
if (result.done) {
|
||||
return results;
|
||||
}
|
||||
let earlyExit = false;
|
||||
function done() {
|
||||
earlyExit = true;
|
||||
}
|
||||
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);
|
||||
if (earlyExit) {
|
||||
return results;
|
||||
}
|
||||
return gather(octokit, results, iterator, mapFn);
|
||||
});
|
||||
}
|
10
node_modules/@octokit/plugin-paginate-rest/dist-src/paginating-endpoints.js
generated
vendored
Normal file
10
node_modules/@octokit/plugin-paginate-rest/dist-src/paginating-endpoints.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import { paginatingEndpoints, } from "./generated/paginating-endpoints";
|
||||
export { paginatingEndpoints } from "./generated/paginating-endpoints";
|
||||
export function isPaginatingEndpoint(arg) {
|
||||
if (typeof arg === "string") {
|
||||
return paginatingEndpoints.includes(arg);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
1
node_modules/@octokit/plugin-paginate-rest/dist-src/types.js
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-src/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user