Search for the CodeQL bundle in multiple places.
This commit is contained in:
Родитель
9769e4a6df
Коммит
813cb0479f
|
@ -5,7 +5,7 @@ inputs:
|
|||
tools:
|
||||
description: URL of CodeQL tools
|
||||
required: false
|
||||
default: https://github.com/github/codeql-action/releases/download/codeql-bundle-20200630/codeql-bundle.tar.gz
|
||||
# If not specified the Action will check in several places until it finds the CodeQL tools.
|
||||
languages:
|
||||
description: The languages to be analysed
|
||||
required: false
|
||||
|
|
|
@ -6,13 +6,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const http = __importStar(require("@actions/http-client"));
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const rest_1 = require("@octokit/rest");
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const stream = __importStar(require("stream"));
|
||||
const globalutil = __importStar(require("util"));
|
||||
const v4_1 = __importDefault(require("uuid/v4"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const util = __importStar(require("./util"));
|
||||
/**
|
||||
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
|
||||
|
@ -24,16 +34,102 @@ let cachedCodeQL = undefined;
|
|||
* Value is set by setupCodeQL and read by getCodeQL.
|
||||
*/
|
||||
const CODEQL_ACTION_CMD = "CODEQL_ACTION_CMD";
|
||||
const CODEQL_DEFAULT_BUNDLE_VERSION = "codeql-bundle-20200630";
|
||||
const CODEQL_DEFAULT_BUNDLE_NAME = "codeql-bundle.tar.gz";
|
||||
const GITHUB_DOTCOM_API_URL = "https://api.github.com";
|
||||
const INSTANCE_API_URL = process.env["GITHUB_API_URL"] || GITHUB_DOTCOM_API_URL;
|
||||
const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
||||
function getCodeQLActionRepository() {
|
||||
// Actions do not know their own repository name,
|
||||
// so we currently use this hack to find the name based on where our files are.
|
||||
// This can be removed once the change to the runner in https://github.com/actions/runner/pull/585 is deployed.
|
||||
const runnerTemp = util.getRequiredEnvParam("RUNNER_TEMP");
|
||||
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
||||
const relativeScriptPath = path.relative(actionsDirectory, __filename);
|
||||
if (relativeScriptPath.startsWith("..") || path.isAbsolute(relativeScriptPath)) {
|
||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||
}
|
||||
const relativeScriptPathParts = relativeScriptPath.split(path.sep);
|
||||
return relativeScriptPathParts[0] + "/" + relativeScriptPathParts[1];
|
||||
}
|
||||
async function getCodeQLBundleDownloadURL() {
|
||||
const codeQLActionRepository = getCodeQLActionRepository();
|
||||
const potentialDownloadSources = [
|
||||
// This GitHub instance, and this Action.
|
||||
[INSTANCE_API_URL, codeQLActionRepository],
|
||||
// This GitHub instance, and the canonical Action.
|
||||
[INSTANCE_API_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||
// GitHub.com, and the canonical Action.
|
||||
[GITHUB_DOTCOM_API_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||
];
|
||||
// We now filter out any duplicates.
|
||||
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
||||
const uniqueDownloadSources = potentialDownloadSources.filter((url, index, self) => index === self.indexOf(url));
|
||||
for (let downloadSource of uniqueDownloadSources) {
|
||||
let [apiURL, repository] = downloadSource;
|
||||
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
||||
if (apiURL === GITHUB_DOTCOM_API_URL && repository === CODEQL_DEFAULT_ACTION_REPOSITORY) {
|
||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_DEFAULT_BUNDLE_VERSION}/${CODEQL_DEFAULT_BUNDLE_NAME}`;
|
||||
}
|
||||
let [repositoryOwner, repositoryName] = repository.split("/");
|
||||
let client = apiURL === INSTANCE_API_URL ? api.getApiClient() : new rest_1.Octokit();
|
||||
try {
|
||||
const release = await client.repos.getReleaseByTag({
|
||||
owner: repositoryOwner,
|
||||
repo: repositoryName,
|
||||
tag: CODEQL_DEFAULT_BUNDLE_VERSION
|
||||
});
|
||||
for (let asset of release.data.assets) {
|
||||
if (asset.name === CODEQL_DEFAULT_BUNDLE_NAME) {
|
||||
core.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
|
||||
return asset.url;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.info(`Looked for CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} but got error ${e}.`);
|
||||
}
|
||||
}
|
||||
throw new Error("Could not find an accessible CodeQL bundle.");
|
||||
}
|
||||
async function setupCodeQL() {
|
||||
try {
|
||||
const codeqlURL = core.getInput('tools', { required: true });
|
||||
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL);
|
||||
let codeqlURL = core.getInput('tools');
|
||||
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_DEFAULT_BUNDLE_VERSION}/`);
|
||||
let codeqlFolder = toolcache.find('CodeQL', codeqlURLVersion);
|
||||
if (codeqlFolder) {
|
||||
core.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||
}
|
||||
else {
|
||||
const codeqlPath = await toolcache.downloadTool(codeqlURL);
|
||||
if (!codeqlURL) {
|
||||
codeqlURL = await getCodeQLBundleDownloadURL();
|
||||
}
|
||||
// We have to download CodeQL manually because the toolcache doesn't support Accept headers.
|
||||
// This can be changed to a one-liner once https://github.com/actions/toolkit/pull/530 is merged and released.
|
||||
const client = new http.HttpClient('CodeQL Action');
|
||||
const codeqlPath = path.join(util.getRequiredEnvParam('RUNNER_TEMP'), v4_1.default());
|
||||
const headers = { accept: 'application/octet-stream' };
|
||||
// We only want to provide an authorization header if we are downloading
|
||||
// from the same GitHub instance the Action is running on.
|
||||
// This avoids leaking Enterprise tokens to dotcom.
|
||||
if (codeqlURL.startsWith(INSTANCE_API_URL + "/")) {
|
||||
core.debug('Downloading CodeQL bundle with token.');
|
||||
let token = core.getInput('token', { required: true });
|
||||
headers.authorization = `token ${token}`;
|
||||
}
|
||||
else {
|
||||
core.debug('Downloading CodeQL bundle without token.');
|
||||
}
|
||||
const response = await client.get(codeqlURL, headers);
|
||||
if (response.message.statusCode !== 200) {
|
||||
const err = new toolcache.HTTPError(response.message.statusCode);
|
||||
core.info(`Failed to download from "${codeqlURL}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||
throw err;
|
||||
}
|
||||
const pipeline = globalutil.promisify(stream.pipeline);
|
||||
await io.mkdirP(path.dirname(codeqlPath));
|
||||
await pipeline(response.message, fs.createWriteStream(codeqlPath));
|
||||
core.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, 'CodeQL', codeqlURLVersion);
|
||||
}
|
||||
|
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -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.
|
|
@ -0,0 +1,438 @@
|
|||
# core.js
|
||||
|
||||
> Extendable client for GitHub's REST & GraphQL APIs
|
||||
|
||||
[![@latest](https://img.shields.io/npm/v/@octokit/core.svg)](https://www.npmjs.com/package/@octokit/core)
|
||||
[![Build Status](https://github.com/octokit/core.js/workflows/Test/badge.svg)](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.pika.dev">cdn.pika.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { Octokit } from "https://cdn.pika.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 set of officially supported authentication strategies can be retrieved from [`@octokit/auth`](https://github.com/octokit/auth-app.js#readme). Example
|
||||
|
||||
```js
|
||||
import { Octokit } from "@octokit/core";
|
||||
import { createAppAuth } from "@octokit/auth-app";
|
||||
|
||||
const appOctokit = new Octokit({
|
||||
authStrategy: createAppAuth,
|
||||
auth: {
|
||||
id: 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.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"),
|
||||
require("@octokit/plugin-throttle"),
|
||||
require("@octokit/plugin-retry")
|
||||
).defaults({
|
||||
authStrategy: require("@octokit/auth-action"),
|
||||
userAgent: `my-octokit-action/v1.2.3`,
|
||||
});
|
||||
|
||||
const octokit = new MyActionOctokit();
|
||||
const installations = await octokit.paginate("GET /app/installations");
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
|
@ -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 _defineProperty(obj, key, value) {
|
||||
if (key in obj) {
|
||||
Object.defineProperty(obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
});
|
||||
} else {
|
||||
obj[key] = value;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i] != null ? arguments[i] : {};
|
||||
|
||||
if (i % 2) {
|
||||
ownKeys(Object(source), true).forEach(function (key) {
|
||||
_defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(Object(source)).forEach(function (key) {
|
||||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
const VERSION = "3.1.1";
|
||||
|
||||
class Octokit {
|
||||
constructor(options = {}) {
|
||||
const hook = new beforeAfterHook.Collection();
|
||||
const requestDefaults = {
|
||||
baseUrl: request.request.endpoint.DEFAULTS.baseUrl,
|
||||
headers: {},
|
||||
request: Object.assign({}, options.request, {
|
||||
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(_objectSpread2(_objectSpread2({}, requestDefaults), {}, {
|
||||
baseUrl: requestDefaults.baseUrl.replace(/\/api\/v3$/, "/api")
|
||||
}));
|
||||
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 registred.
|
||||
// (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 auth = options.authStrategy(Object.assign({
|
||||
request: this.request
|
||||
}, 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
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,118 @@
|
|||
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, {
|
||||
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,
|
||||
baseUrl: requestDefaults.baseUrl.replace(/\/api\/v3$/, "/api"),
|
||||
});
|
||||
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 registred.
|
||||
// (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 auth = options.authStrategy(Object.assign({
|
||||
request: this.request,
|
||||
}, 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 = [];
|
|
@ -0,0 +1 @@
|
|||
export const VERSION = "3.1.1";
|
|
@ -0,0 +1,40 @@
|
|||
import { HookCollection } from "before-after-hook";
|
||||
import { request } from "@octokit/request";
|
||||
import { graphql } from "@octokit/graphql";
|
||||
import { Constructor, OctokitOptions, OctokitPlugin, ReturnTypeOf, UnionToIntersection } from "./types";
|
||||
export declare class Octokit {
|
||||
static VERSION: string;
|
||||
static defaults<S extends Constructor<any>>(this: S, defaults: OctokitOptions | Function): {
|
||||
new (...args: any[]): {
|
||||
[x: string]: any;
|
||||
};
|
||||
} & 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): {
|
||||
new (...args: any[]): {
|
||||
[x: string]: any;
|
||||
};
|
||||
plugins: any[];
|
||||
} & 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;
|
||||
auth: (...args: unknown[]) => Promise<unknown>;
|
||||
[key: string]: any;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
import * as OctokitTypes from "@octokit/types";
|
||||
import { Octokit } from ".";
|
||||
export declare type RequestParameters = OctokitTypes.RequestParameters;
|
||||
export declare type OctokitOptions = {
|
||||
authStrategy?: any;
|
||||
auth?: any;
|
||||
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<ReturnType<T[number]>> : 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 {};
|
|
@ -0,0 +1 @@
|
|||
export declare const VERSION = "3.1.1";
|
|
@ -0,0 +1,123 @@
|
|||
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.1.1";
|
||||
|
||||
class Octokit {
|
||||
constructor(options = {}) {
|
||||
const hook = new Collection();
|
||||
const requestDefaults = {
|
||||
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
||||
headers: {},
|
||||
request: Object.assign({}, options.request, {
|
||||
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,
|
||||
baseUrl: requestDefaults.baseUrl.replace(/\/api\/v3$/, "/api"),
|
||||
});
|
||||
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 registred.
|
||||
// (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 auth = options.authStrategy(Object.assign({
|
||||
request: this.request,
|
||||
}, 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
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
21
node_modules/@octokit/core/node_modules/@octokit/endpoint/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@octokit/core/node_modules/@octokit/endpoint/LICENSE
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/README.md
сгенерированный
поставляемый
Normal file
421
node_modules/@octokit/core/node_modules/@octokit/endpoint/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,421 @@
|
|||
# endpoint.js
|
||||
|
||||
> Turns GitHub REST API endpoints into generic request options
|
||||
|
||||
[![@latest](https://img.shields.io/npm/v/@octokit/endpoint.svg)](https://www.npmjs.com/package/@octokit/endpoint)
|
||||
![Build Status](https://github.com/octokit/endpoint.js/workflows/Test/badge.svg)
|
||||
|
||||
`@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.pika.dev">cdn.pika.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { endpoint } from "https://cdn.pika.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)
|
379
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-node/index.js
сгенерированный
поставляемый
Normal file
379
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-node/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,379 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var isPlainObject = _interopDefault(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(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 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);
|
||||
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 isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
|
||||
|
||||
if (!isBinaryRequset) {
|
||||
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.5";
|
||||
|
||||
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/core/node_modules/@octokit/endpoint/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
17
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/defaults.js
сгенерированный
поставляемый
Normal file
17
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/defaults.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
сгенерированный
поставляемый
Normal file
5
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/endpoint-with-defaults.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/index.js
сгенерированный
поставляемый
Normal file
3
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,3 @@
|
|||
import { withDefaults } from "./with-defaults";
|
||||
import { DEFAULTS } from "./defaults";
|
||||
export const endpoint = withDefaults(null, DEFAULTS);
|
22
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/merge.js
сгенерированный
поставляемый
Normal file
22
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/merge.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,22 @@
|
|||
import { lowercaseKeys } from "./util/lowercase-keys";
|
||||
import { mergeDeep } from "./util/merge-deep";
|
||||
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);
|
||||
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/core/node_modules/@octokit/endpoint/dist-src/parse.js
сгенерированный
поставляемый
Normal file
81
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/parse.js
сгенерированный
поставляемый
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 isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
|
||||
if (!isBinaryRequset) {
|
||||
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/core/node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
сгенерированный
поставляемый
Normal file
17
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/add-query-parameters.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
сгенерированный
поставляемый
Normal file
11
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/extract-url-variable-names.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
сгенерированный
поставляемый
Normal file
9
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/lowercase-keys.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
сгенерированный
поставляемый
Normal file
16
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/merge-deep.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/util/omit.js
сгенерированный
поставляемый
Normal file
8
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/omit.js
сгенерированный
поставляемый
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;
|
||||
}, {});
|
||||
}
|
164
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/url-template.js
сгенерированный
поставляемый
Normal file
164
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/util/url-template.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-src/version.js
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/version.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export const VERSION = "6.0.5";
|
13
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/with-defaults.js
сгенерированный
поставляемый
Normal file
13
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-src/with-defaults.js
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-types/defaults.d.ts
сгенерированный
поставляемый
Normal file
2
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/defaults.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { EndpointDefaults } from "@octokit/types";
|
||||
export declare const DEFAULTS: EndpointDefaults;
|
3
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/endpoint-with-defaults.d.ts
сгенерированный
поставляемый
Normal file
3
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/endpoint-with-defaults.d.ts
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-types/index.d.ts
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/index.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export declare const endpoint: import("@octokit/types").EndpointInterface<object>;
|
2
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/merge.d.ts
сгенерированный
поставляемый
Normal file
2
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/merge.d.ts
сгенерированный
поставляемый
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/core/node_modules/@octokit/endpoint/dist-types/parse.d.ts
сгенерированный
поставляемый
Normal file
2
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/parse.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { EndpointDefaults, RequestOptions } from "@octokit/types";
|
||||
export declare function parse(options: EndpointDefaults): RequestOptions;
|
4
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/add-query-parameters.d.ts
сгенерированный
поставляемый
Normal file
4
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/add-query-parameters.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,4 @@
|
|||
export declare function addQueryParameters(url: string, parameters: {
|
||||
[x: string]: string | undefined;
|
||||
q?: string;
|
||||
}): string;
|
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/extract-url-variable-names.d.ts
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/extract-url-variable-names.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export declare function extractUrlVariableNames(url: string): string[];
|
5
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/lowercase-keys.d.ts
сгенерированный
поставляемый
Normal file
5
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/lowercase-keys.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,5 @@
|
|||
export declare function lowercaseKeys(object?: {
|
||||
[key: string]: any;
|
||||
}): {
|
||||
[key: string]: any;
|
||||
};
|
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/merge-deep.d.ts
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/merge-deep.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export declare function mergeDeep(defaults: any, options: any): object;
|
5
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/omit.d.ts
сгенерированный
поставляемый
Normal file
5
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/omit.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,5 @@
|
|||
export declare function omit(object: {
|
||||
[key: string]: any;
|
||||
}, keysToOmit: string[]): {
|
||||
[key: string]: any;
|
||||
};
|
3
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/url-template.d.ts
сгенерированный
поставляемый
Normal file
3
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/util/url-template.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,3 @@
|
|||
export declare function parseUrl(template: string): {
|
||||
expand: (context: object) => string;
|
||||
};
|
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/version.d.ts
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/version.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export declare const VERSION = "6.0.5";
|
2
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/with-defaults.d.ts
сгенерированный
поставляемый
Normal file
2
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-types/with-defaults.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { EndpointInterface, RequestParameters, EndpointDefaults } from "@octokit/types";
|
||||
export declare function withDefaults(oldDefaults: EndpointDefaults | null, newDefaults: RequestParameters): EndpointInterface;
|
369
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-web/index.js
сгенерированный
поставляемый
Normal file
369
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-web/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,369 @@
|
|||
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 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);
|
||||
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 isBinaryRequset = /application\/octet-stream/i.test(headers.accept);
|
||||
if (!isBinaryRequset) {
|
||||
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.5";
|
||||
|
||||
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/core/node_modules/@octokit/endpoint/dist-web/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/endpoint/dist-web/index.js.map
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
51
node_modules/@octokit/core/node_modules/@octokit/endpoint/package.json
сгенерированный
поставляемый
Normal file
51
node_modules/@octokit/core/node_modules/@octokit/endpoint/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "@octokit/endpoint",
|
||||
"description": "Turns REST API endpoints into generic request options",
|
||||
"version": "6.0.5",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"rest"
|
||||
],
|
||||
"homepage": "https://github.com/octokit/endpoint.js#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/octokit/endpoint.js/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/octokit/endpoint.js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/types": "^5.0.0",
|
||||
"is-plain-object": "^4.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": "^26.0.1",
|
||||
"prettier": "2.0.5",
|
||||
"semantic-release": "^17.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^26.0.0",
|
||||
"typescript": "^3.4.5"
|
||||
},
|
||||
"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/node_modules/@octokit/request-error/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@octokit/core/node_modules/@octokit/request-error/LICENSE
сгенерированный
поставляемый
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.
|
67
node_modules/@octokit/core/node_modules/@octokit/request-error/README.md
сгенерированный
поставляемый
Normal file
67
node_modules/@octokit/core/node_modules/@octokit/request-error/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,67 @@
|
|||
# http-error.js
|
||||
|
||||
> Error class for Octokit request errors
|
||||
|
||||
[![@latest](https://img.shields.io/npm/v/@octokit/request-error.svg)](https://www.npmjs.com/package/@octokit/request-error)
|
||||
[![Build Status](https://github.com/octokit/request-error.js/workflows/Test/badge.svg)](https://github.com/octokit/request-error.js/actions?query=workflow%3ATest)
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/request-error</code> directly from <a href="https://cdn.pika.dev">cdn.pika.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { RequestError } from "https://cdn.pika.dev/@octokit/request-error";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/request-error</code>
|
||||
|
||||
```js
|
||||
const { RequestError } = require("@octokit/request-error");
|
||||
// or: import { RequestError } from "@octokit/request-error";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
```js
|
||||
const error = new RequestError("Oops", 500, {
|
||||
headers: {
|
||||
"x-github-request-id": "1:2:3:4",
|
||||
}, // response headers
|
||||
request: {
|
||||
method: "POST",
|
||||
url: "https://api.github.com/foo",
|
||||
body: {
|
||||
bar: "baz",
|
||||
},
|
||||
headers: {
|
||||
authorization: "token secret123",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
error.message; // Oops
|
||||
error.status; // 500
|
||||
error.headers; // { 'x-github-request-id': '1:2:3:4' }
|
||||
error.request.method; // POST
|
||||
error.request.url; // https://api.github.com/foo
|
||||
error.request.body; // { bar: 'baz' }
|
||||
error.request.headers; // { authorization: 'token [REDACTED]' }
|
||||
```
|
||||
|
||||
## LICENSE
|
||||
|
||||
[MIT](LICENSE)
|
55
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-node/index.js
сгенерированный
поставляемый
Normal file
55
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-node/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,55 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var deprecation = require('deprecation');
|
||||
var once = _interopDefault(require('once'));
|
||||
|
||||
const logOnce = once(deprecation => console.warn(deprecation));
|
||||
/**
|
||||
* Error with extra properties to help with debugging
|
||||
*/
|
||||
|
||||
class RequestError extends Error {
|
||||
constructor(message, statusCode, options) {
|
||||
super(message); // Maintains proper stack trace (only available on V8)
|
||||
|
||||
/* istanbul ignore next */
|
||||
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
||||
this.name = "HttpError";
|
||||
this.status = statusCode;
|
||||
Object.defineProperty(this, "code", {
|
||||
get() {
|
||||
logOnce(new deprecation.Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
});
|
||||
this.headers = options.headers || {}; // redact request credentials without mutating original request options
|
||||
|
||||
const requestCopy = Object.assign({}, options.request);
|
||||
|
||||
if (options.request.headers.authorization) {
|
||||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||||
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]")
|
||||
});
|
||||
}
|
||||
|
||||
requestCopy.url = requestCopy.url // client_id & client_secret can be passed as URL query parameters to increase rate limit
|
||||
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
||||
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]") // OAuth tokens can be passed as URL query parameters, although it is not recommended
|
||||
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
|
||||
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||||
this.request = requestCopy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.RequestError = RequestError;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sources":["../dist-src/index.js"],"sourcesContent":["import { Deprecation } from \"deprecation\";\nimport once from \"once\";\nconst logOnce = once((deprecation) => console.warn(deprecation));\n/**\n * Error with extra properties to help with debugging\n */\nexport class RequestError extends Error {\n constructor(message, statusCode, options) {\n super(message);\n // Maintains proper stack trace (only available on V8)\n /* istanbul ignore next */\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n this.name = \"HttpError\";\n this.status = statusCode;\n Object.defineProperty(this, \"code\", {\n get() {\n logOnce(new Deprecation(\"[@octokit/request-error] `error.code` is deprecated, use `error.status`.\"));\n return statusCode;\n },\n });\n this.headers = options.headers || {};\n // redact request credentials without mutating original request options\n const requestCopy = Object.assign({}, options.request);\n if (options.request.headers.authorization) {\n requestCopy.headers = Object.assign({}, options.request.headers, {\n authorization: options.request.headers.authorization.replace(/ .*$/, \" [REDACTED]\"),\n });\n }\n requestCopy.url = requestCopy.url\n // client_id & client_secret can be passed as URL query parameters to increase rate limit\n // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications\n .replace(/\\bclient_secret=\\w+/g, \"client_secret=[REDACTED]\")\n // OAuth tokens can be passed as URL query parameters, although it is not recommended\n // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header\n .replace(/\\baccess_token=\\w+/g, \"access_token=[REDACTED]\");\n this.request = requestCopy;\n }\n}\n"],"names":["logOnce","once","deprecation","console","warn","RequestError","Error","constructor","message","statusCode","options","captureStackTrace","name","status","Object","defineProperty","get","Deprecation","headers","requestCopy","assign","request","authorization","replace","url"],"mappings":";;;;;;;;;AAEA,MAAMA,OAAO,GAAGC,IAAI,CAAEC,WAAD,IAAiBC,OAAO,CAACC,IAAR,CAAaF,WAAb,CAAlB,CAApB;AACA;;;;AAGO,MAAMG,YAAN,SAA2BC,KAA3B,CAAiC;AACpCC,EAAAA,WAAW,CAACC,OAAD,EAAUC,UAAV,EAAsBC,OAAtB,EAA+B;AACtC,UAAMF,OAAN,EADsC;;AAGtC;;AACA,QAAIF,KAAK,CAACK,iBAAV,EAA6B;AACzBL,MAAAA,KAAK,CAACK,iBAAN,CAAwB,IAAxB,EAA8B,KAAKJ,WAAnC;AACH;;AACD,SAAKK,IAAL,GAAY,WAAZ;AACA,SAAKC,MAAL,GAAcJ,UAAd;AACAK,IAAAA,MAAM,CAACC,cAAP,CAAsB,IAAtB,EAA4B,MAA5B,EAAoC;AAChCC,MAAAA,GAAG,GAAG;AACFhB,QAAAA,OAAO,CAAC,IAAIiB,uBAAJ,CAAgB,0EAAhB,CAAD,CAAP;AACA,eAAOR,UAAP;AACH;;AAJ+B,KAApC;AAMA,SAAKS,OAAL,GAAeR,OAAO,CAACQ,OAAR,IAAmB,EAAlC,CAfsC;;AAiBtC,UAAMC,WAAW,GAAGL,MAAM,CAACM,MAAP,CAAc,EAAd,EAAkBV,OAAO,CAACW,OAA1B,CAApB;;AACA,QAAIX,OAAO,CAACW,OAAR,CAAgBH,OAAhB,CAAwBI,aAA5B,EAA2C;AACvCH,MAAAA,WAAW,CAACD,OAAZ,GAAsBJ,MAAM,CAACM,MAAP,CAAc,EAAd,EAAkBV,OAAO,CAACW,OAAR,CAAgBH,OAAlC,EAA2C;AAC7DI,QAAAA,aAAa,EAAEZ,OAAO,CAACW,OAAR,CAAgBH,OAAhB,CAAwBI,aAAxB,CAAsCC,OAAtC,CAA8C,MAA9C,EAAsD,aAAtD;AAD8C,OAA3C,CAAtB;AAGH;;AACDJ,IAAAA,WAAW,CAACK,GAAZ,GAAkBL,WAAW,CAACK,GAAZ;AAEd;AAFc,KAGbD,OAHa,CAGL,sBAHK,EAGmB,0BAHnB;AAKd;AALc,KAMbA,OANa,CAML,qBANK,EAMkB,yBANlB,CAAlB;AAOA,SAAKF,OAAL,GAAeF,WAAf;AACH;;AAhCmC;;;;"}
|
40
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-src/index.js
сгенерированный
поставляемый
Normal file
40
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-src/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { Deprecation } from "deprecation";
|
||||
import once from "once";
|
||||
const logOnce = once((deprecation) => console.warn(deprecation));
|
||||
/**
|
||||
* Error with extra properties to help with debugging
|
||||
*/
|
||||
export class RequestError extends Error {
|
||||
constructor(message, statusCode, options) {
|
||||
super(message);
|
||||
// Maintains proper stack trace (only available on V8)
|
||||
/* istanbul ignore next */
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
this.name = "HttpError";
|
||||
this.status = statusCode;
|
||||
Object.defineProperty(this, "code", {
|
||||
get() {
|
||||
logOnce(new Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
||||
return statusCode;
|
||||
},
|
||||
});
|
||||
this.headers = options.headers || {};
|
||||
// redact request credentials without mutating original request options
|
||||
const requestCopy = Object.assign({}, options.request);
|
||||
if (options.request.headers.authorization) {
|
||||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||||
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]"),
|
||||
});
|
||||
}
|
||||
requestCopy.url = requestCopy.url
|
||||
// client_id & client_secret can be passed as URL query parameters to increase rate limit
|
||||
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
||||
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]")
|
||||
// OAuth tokens can be passed as URL query parameters, although it is not recommended
|
||||
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
|
||||
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||||
this.request = requestCopy;
|
||||
}
|
||||
}
|
0
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-src/types.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-src/types.js
сгенерированный
поставляемый
Normal file
27
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-types/index.d.ts
сгенерированный
поставляемый
Normal file
27
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-types/index.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { RequestOptions, ResponseHeaders } from "@octokit/types";
|
||||
import { RequestErrorOptions } from "./types";
|
||||
/**
|
||||
* Error with extra properties to help with debugging
|
||||
*/
|
||||
export declare class RequestError extends Error {
|
||||
name: "HttpError";
|
||||
/**
|
||||
* http status code
|
||||
*/
|
||||
status: number;
|
||||
/**
|
||||
* http status code
|
||||
*
|
||||
* @deprecated `error.code` is deprecated in favor of `error.status`
|
||||
*/
|
||||
code: number;
|
||||
/**
|
||||
* error response headers
|
||||
*/
|
||||
headers: ResponseHeaders;
|
||||
/**
|
||||
* Request options that lead to the error.
|
||||
*/
|
||||
request: RequestOptions;
|
||||
constructor(message: string, statusCode: number, options: RequestErrorOptions);
|
||||
}
|
5
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-types/types.d.ts
сгенерированный
поставляемый
Normal file
5
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-types/types.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { RequestOptions, ResponseHeaders } from "@octokit/types";
|
||||
export declare type RequestErrorOptions = {
|
||||
headers?: ResponseHeaders;
|
||||
request: RequestOptions;
|
||||
};
|
44
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-web/index.js
сгенерированный
поставляемый
Normal file
44
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-web/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,44 @@
|
|||
import { Deprecation } from 'deprecation';
|
||||
import once from 'once';
|
||||
|
||||
const logOnce = once((deprecation) => console.warn(deprecation));
|
||||
/**
|
||||
* Error with extra properties to help with debugging
|
||||
*/
|
||||
class RequestError extends Error {
|
||||
constructor(message, statusCode, options) {
|
||||
super(message);
|
||||
// Maintains proper stack trace (only available on V8)
|
||||
/* istanbul ignore next */
|
||||
if (Error.captureStackTrace) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
this.name = "HttpError";
|
||||
this.status = statusCode;
|
||||
Object.defineProperty(this, "code", {
|
||||
get() {
|
||||
logOnce(new Deprecation("[@octokit/request-error] `error.code` is deprecated, use `error.status`."));
|
||||
return statusCode;
|
||||
},
|
||||
});
|
||||
this.headers = options.headers || {};
|
||||
// redact request credentials without mutating original request options
|
||||
const requestCopy = Object.assign({}, options.request);
|
||||
if (options.request.headers.authorization) {
|
||||
requestCopy.headers = Object.assign({}, options.request.headers, {
|
||||
authorization: options.request.headers.authorization.replace(/ .*$/, " [REDACTED]"),
|
||||
});
|
||||
}
|
||||
requestCopy.url = requestCopy.url
|
||||
// client_id & client_secret can be passed as URL query parameters to increase rate limit
|
||||
// see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
||||
.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]")
|
||||
// OAuth tokens can be passed as URL query parameters, although it is not recommended
|
||||
// see https://developer.github.com/v3/#oauth2-token-sent-in-a-header
|
||||
.replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
||||
this.request = requestCopy;
|
||||
}
|
||||
}
|
||||
|
||||
export { RequestError };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-web/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request-error/dist-web/index.js.map
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sources":["../dist-src/index.js"],"sourcesContent":["import { Deprecation } from \"deprecation\";\nimport once from \"once\";\nconst logOnce = once((deprecation) => console.warn(deprecation));\n/**\n * Error with extra properties to help with debugging\n */\nexport class RequestError extends Error {\n constructor(message, statusCode, options) {\n super(message);\n // Maintains proper stack trace (only available on V8)\n /* istanbul ignore next */\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n this.name = \"HttpError\";\n this.status = statusCode;\n Object.defineProperty(this, \"code\", {\n get() {\n logOnce(new Deprecation(\"[@octokit/request-error] `error.code` is deprecated, use `error.status`.\"));\n return statusCode;\n },\n });\n this.headers = options.headers || {};\n // redact request credentials without mutating original request options\n const requestCopy = Object.assign({}, options.request);\n if (options.request.headers.authorization) {\n requestCopy.headers = Object.assign({}, options.request.headers, {\n authorization: options.request.headers.authorization.replace(/ .*$/, \" [REDACTED]\"),\n });\n }\n requestCopy.url = requestCopy.url\n // client_id & client_secret can be passed as URL query parameters to increase rate limit\n // see https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications\n .replace(/\\bclient_secret=\\w+/g, \"client_secret=[REDACTED]\")\n // OAuth tokens can be passed as URL query parameters, although it is not recommended\n // see https://developer.github.com/v3/#oauth2-token-sent-in-a-header\n .replace(/\\baccess_token=\\w+/g, \"access_token=[REDACTED]\");\n this.request = requestCopy;\n }\n}\n"],"names":[],"mappings":";;;AAEA,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AACjE;AACA;AACA;AACO,MAAM,YAAY,SAAS,KAAK,CAAC;AACxC,IAAI,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE;AAC9C,QAAQ,KAAK,CAAC,OAAO,CAAC,CAAC;AACvB;AACA;AACA,QAAQ,IAAI,KAAK,CAAC,iBAAiB,EAAE;AACrC,YAAY,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;AAC5D,SAAS;AACT,QAAQ,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;AAChC,QAAQ,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC;AACjC,QAAQ,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE;AAC5C,YAAY,GAAG,GAAG;AAClB,gBAAgB,OAAO,CAAC,IAAI,WAAW,CAAC,0EAA0E,CAAC,CAAC,CAAC;AACrH,gBAAgB,OAAO,UAAU,CAAC;AAClC,aAAa;AACb,SAAS,CAAC,CAAC;AACX,QAAQ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AAC7C;AACA,QAAQ,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/D,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE;AACnD,YAAY,WAAW,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;AAC7E,gBAAgB,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC;AACnG,aAAa,CAAC,CAAC;AACf,SAAS;AACT,QAAQ,WAAW,CAAC,GAAG,GAAG,WAAW,CAAC,GAAG;AACzC;AACA;AACA,aAAa,OAAO,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;AACxE;AACA;AACA,aAAa,OAAO,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,CAAC;AACvE,QAAQ,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;AACnC,KAAK;AACL;;;;"}
|
54
node_modules/@octokit/core/node_modules/@octokit/request-error/package.json
сгенерированный
поставляемый
Normal file
54
node_modules/@octokit/core/node_modules/@octokit/request-error/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
"name": "@octokit/request-error",
|
||||
"description": "Error class for Octokit request errors",
|
||||
"version": "2.0.2",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"error"
|
||||
],
|
||||
"homepage": "https://github.com/octokit/request-error.js#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/octokit/request-error.js/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/octokit/request-error.js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/types": "^5.0.1",
|
||||
"deprecation": "^2.0.0",
|
||||
"once": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@pika/pack": "^0.5.0",
|
||||
"@pika/plugin-build-node": "^0.9.0",
|
||||
"@pika/plugin-build-web": "^0.9.0",
|
||||
"@pika/plugin-bundle-web": "^0.9.0",
|
||||
"@pika/plugin-ts-standard-pkg": "^0.9.0",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.0.4",
|
||||
"@types/once": "^1.4.0",
|
||||
"jest": "^25.1.0",
|
||||
"pika-plugin-unpkg-field": "^1.1.0",
|
||||
"prettier": "^2.0.1",
|
||||
"semantic-release": "^17.0.0",
|
||||
"ts-jest": "^25.1.0",
|
||||
"typescript": "^3.4.5"
|
||||
},
|
||||
"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/node_modules/@octokit/request/LICENSE
сгенерированный
поставляемый
Normal file
21
node_modules/@octokit/core/node_modules/@octokit/request/LICENSE
сгенерированный
поставляемый
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.
|
538
node_modules/@octokit/core/node_modules/@octokit/request/README.md
сгенерированный
поставляемый
Normal file
538
node_modules/@octokit/core/node_modules/@octokit/request/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,538 @@
|
|||
# request.js
|
||||
|
||||
> Send parameterized requests to GitHub’s APIs with sensible defaults in browsers and Node
|
||||
|
||||
[![@latest](https://img.shields.io/npm/v/@octokit/request.svg)](https://www.npmjs.com/package/@octokit/request)
|
||||
[![Build Status](https://github.com/octokit/request.js/workflows/Test/badge.svg)](https://github.com/octokit/request.js/actions?query=workflow%3ATest+branch%3Amaster)
|
||||
|
||||
`@octokit/request` is a request library for browsers & node that makes it easier
|
||||
to interact with [GitHub’s REST API](https://developer.github.com/v3/) and
|
||||
[GitHub’s GraphQL API](https://developer.github.com/v4/guides/forming-calls/#the-graphql-endpoint).
|
||||
|
||||
It uses [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) to parse
|
||||
the passed options and sends the request using [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||
([node-fetch](https://github.com/bitinn/node-fetch) in Node).
|
||||
|
||||
<!-- update table of contents by running `npx markdown-toc README.md -i` -->
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Features](#features)
|
||||
- [Usage](#usage)
|
||||
- [REST API example](#rest-api-example)
|
||||
- [GraphQL example](#graphql-example)
|
||||
- [Alternative: pass `method` & `url` as part of options](#alternative-pass-method--url-as-part-of-options)
|
||||
- [Authentication](#authentication)
|
||||
- [request()](#request)
|
||||
- [`request.defaults()`](#requestdefaults)
|
||||
- [`request.endpoint`](#requestendpoint)
|
||||
- [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 -->
|
||||
|
||||
## Features
|
||||
|
||||
🤩 1:1 mapping of REST API endpoint documentation, e.g. [Add labels to an issue](https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue) becomes
|
||||
|
||||
```js
|
||||
request("POST /repos/:owner/:repo/issues/:number/labels", {
|
||||
mediaType: {
|
||||
previews: ["symmetra"],
|
||||
},
|
||||
owner: "octokit",
|
||||
repo: "request.js",
|
||||
number: 1,
|
||||
labels: ["🐛 bug"],
|
||||
});
|
||||
```
|
||||
|
||||
👶 [Small bundle size](https://bundlephobia.com/result?p=@octokit/request@5.0.3) (\<4kb minified + gzipped)
|
||||
|
||||
😎 [Authenticate](#authentication) with any of [GitHubs Authentication Strategies](https://github.com/octokit/auth.js).
|
||||
|
||||
👍 Sensible defaults
|
||||
|
||||
- `baseUrl`: `https://api.github.com`
|
||||
- `headers.accept`: `application/vnd.github.v3+json`
|
||||
- `headers.agent`: `octokit-request.js/<current version> <OS information>`, e.g. `octokit-request.js/1.2.3 Node.js/10.15.0 (macOS Mojave; x64)`
|
||||
|
||||
👌 Simple to test: mock requests by passing a custom fetch method.
|
||||
|
||||
🧐 Simple to debug: Sets `error.request` to request options causing the error (with redacted credentials).
|
||||
|
||||
## Usage
|
||||
|
||||
<table>
|
||||
<tbody valign=top align=left>
|
||||
<tr><th>
|
||||
Browsers
|
||||
</th><td width=100%>
|
||||
Load <code>@octokit/request</code> directly from <a href="https://cdn.pika.dev">cdn.pika.dev</a>
|
||||
|
||||
```html
|
||||
<script type="module">
|
||||
import { request } from "https://cdn.pika.dev/@octokit/request";
|
||||
</script>
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
<tr><th>
|
||||
Node
|
||||
</th><td>
|
||||
|
||||
Install with <code>npm install @octokit/request</code>
|
||||
|
||||
```js
|
||||
const { request } = require("@octokit/request");
|
||||
// or: import { request } from "@octokit/request";
|
||||
```
|
||||
|
||||
</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
### REST API example
|
||||
|
||||
```js
|
||||
// Following GitHub docs formatting:
|
||||
// https://developer.github.com/v3/repos/#list-organization-repositories
|
||||
const result = await request("GET /orgs/:org/repos", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
console.log(`${result.data.length} repos found.`);
|
||||
```
|
||||
|
||||
### GraphQL example
|
||||
|
||||
For GraphQL request we recommend using [`@octokit/graphql`](https://github.com/octokit/graphql.js#readme)
|
||||
|
||||
```js
|
||||
const result = await request("POST /graphql", {
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
query: `query ($login: String!) {
|
||||
organization(login: $login) {
|
||||
repositories(privacy: PRIVATE) {
|
||||
totalCount
|
||||
}
|
||||
}
|
||||
}`,
|
||||
variables: {
|
||||
login: "octokit",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Alternative: pass `method` & `url` as part of options
|
||||
|
||||
Alternatively, pass in a method and a url
|
||||
|
||||
```js
|
||||
const result = await request({
|
||||
method: "GET",
|
||||
url: "/orgs/:org/repos",
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
org: "octokit",
|
||||
type: "private",
|
||||
});
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
The simplest way to authenticate a request is to set the `Authorization` header directly, e.g. to a [personal access token](https://github.com/settings/tokens/).
|
||||
|
||||
```js
|
||||
const requestWithAuth = request.defaults({
|
||||
headers: {
|
||||
authorization: "token 0000000000000000000000000000000000000001",
|
||||
},
|
||||
});
|
||||
const result = await requestWithAuth("GET /user");
|
||||
```
|
||||
|
||||
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 requestWithAuth = request.defaults({
|
||||
request: {
|
||||
hook: auth.hook,
|
||||
},
|
||||
mediaType: {
|
||||
previews: ["machine-man"],
|
||||
},
|
||||
});
|
||||
|
||||
const { data: app } = await requestWithAuth("GET /app");
|
||||
const { data: app } = await requestWithAuth("POST /repos/:owner/:repo/issues", {
|
||||
owner: "octocat",
|
||||
repo: "hello-world",
|
||||
title: "Hello from the engine room",
|
||||
});
|
||||
```
|
||||
|
||||
## request()
|
||||
|
||||
`request(route, options)` or `request(options)`.
|
||||
|
||||
**Options**
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
name
|
||||
</th>
|
||||
<th align=left>
|
||||
type
|
||||
</th>
|
||||
<th align=left>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>route</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
If <code>route</code> is set it has to be a string consisting of the request method and URL, e.g. <code>GET /orgs/:org</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.baseUrl</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required.</strong> Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>https://api.github.com</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<th align=left>
|
||||
<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-rest.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>.<br> Use <code>options.mediaType.{format,previews}</code> to request API previews and custom media types.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.mediaType.format</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
Media type param, such as `raw`, `html`, or `full`. See <a href="https://developer.github.com/v3/media/">Media Types</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.mediaType.previews</code>
|
||||
</th>
|
||||
<td>
|
||||
Array of strings
|
||||
</td>
|
||||
<td>
|
||||
Name of previews, such as `mercy`, `symmetra`, or `scarlet-witch`. See <a href="https://developer.github.com/v3/previews/">API Previews</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.method</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required.</strong> Any supported <a href="https://developer.github.com/v3/#http-verbs">http verb</a>, case insensitive. <em>Defaults to <code>Get</code></em>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.url</code>
|
||||
</th>
|
||||
<td>
|
||||
String
|
||||
</td>
|
||||
<td>
|
||||
<strong>Required.</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 align=left>
|
||||
<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 `data` parameter"</a> below.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.agent</code>
|
||||
</th>
|
||||
<td>
|
||||
<a href="https://nodejs.org/api/http.html#http_class_http_agent">http(s).Agent</a> instance
|
||||
</td>
|
||||
<td>
|
||||
Node only. Useful for custom proxy, certificate, or dns lookup.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.fetch</code>
|
||||
</th>
|
||||
<td>
|
||||
Function
|
||||
</td>
|
||||
<td>
|
||||
Custom replacement for <a href="https://github.com/bitinn/node-fetch">built-in fetch method</a>. Useful for testing or request hooks.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.hook</code>
|
||||
</th>
|
||||
<td>
|
||||
Function
|
||||
</td>
|
||||
<td>
|
||||
Function with the signature <code>hook(request, endpointOptions)</code>, where <code>endpointOptions</code> are the parsed options as returned by <a href="https://github.com/octokit/endpoint.js#endpointmergeroute-options-or-endpointmergeoptions"><code>endpoint.merge()</code></a>, and <code>request</code> is <a href="https://github.com/octokit/request.js#request"><code>request()</code></a>. This option works great in conjuction with <a href="https://github.com/gr2m/before-after-hook">before-after-hook</a>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<a name="options-request-signal"></a><code>options.request.signal</code>
|
||||
</th>
|
||||
<td>
|
||||
<a href="https://github.com/bitinn/node-fetch/tree/e996bdab73baf996cf2dbf25643c8fe2698c3249#request-cancellation-with-abortsignal">new AbortController().signal</a>
|
||||
</td>
|
||||
<td>
|
||||
Use an <code>AbortController</code> instance to cancel a request. In node you can only cancel streamed requests.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left>
|
||||
<code>options.request.timeout</code>
|
||||
</th>
|
||||
<td>
|
||||
Number
|
||||
</td>
|
||||
<td>
|
||||
Node only. Request/response timeout in ms, it resets on redirect. 0 to disable (OS limit applies). <a href="#options-request-signal">options.request.signal</a> is recommended instead.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
All other options except `options.request.*` will be passed depending on the `method` and `url` options.
|
||||
|
||||
1. If the option key is a placeholder in the `url`, it will be used as 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 query parameter
|
||||
3. Otherwise the parameter is passed in the request body as JSON key.
|
||||
|
||||
**Result**
|
||||
|
||||
`request` returns a promise and resolves with 4 keys
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th align=left>
|
||||
key
|
||||
</th>
|
||||
<th align=left>
|
||||
type
|
||||
</th>
|
||||
<th align=left>
|
||||
description
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr>
|
||||
<th align=left><code>status</code></th>
|
||||
<td>Integer</td>
|
||||
<td>Response status status</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>url</code></th>
|
||||
<td>String</td>
|
||||
<td>URL of response. If a request results in redirects, this is the final URL. You can send a <code>HEAD</code> request to retrieve it without loading the full response body.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>headers</code></th>
|
||||
<td>Object</td>
|
||||
<td>All response headers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th align=left><code>data</code></th>
|
||||
<td>Any</td>
|
||||
<td>The response body as returned from server. If the response is JSON then it will be parsed into an object</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
If an error occurs, the `error` instance has additional properties to help with debugging
|
||||
|
||||
- `error.status` The http response status code
|
||||
- `error.headers` The http response headers as an object
|
||||
- `error.request` The request options such as `method`, `url` and `data`
|
||||
|
||||
## `request.defaults()`
|
||||
|
||||
Override or set default options. Example:
|
||||
|
||||
```js
|
||||
const myrequest = require("@octokit/request").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,
|
||||
});
|
||||
|
||||
myrequest(`GET /orgs/:org/repos`);
|
||||
```
|
||||
|
||||
You can call `.defaults()` again on the returned method, the defaults will cascade.
|
||||
|
||||
```js
|
||||
const myProjectRequest = request.defaults({
|
||||
baseUrl: "https://github-enterprise.acme-inc.com/api/v3",
|
||||
headers: {
|
||||
"user-agent": "myApp/1.2.3",
|
||||
},
|
||||
org: "my-project",
|
||||
});
|
||||
const myProjectRequestWithAuth = myProjectRequest.defaults({
|
||||
headers: {
|
||||
authorization: `token 0000000000000000000000000000000000000001`,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
`myProjectRequest` now defaults the `baseUrl`, `headers['user-agent']`,
|
||||
`org` and `headers['authorization']` on top of `headers['accept']` that is set
|
||||
by the global default.
|
||||
|
||||
## `request.endpoint`
|
||||
|
||||
See https://github.com/octokit/endpoint.js. Example
|
||||
|
||||
```js
|
||||
const options = request.endpoint("GET /orgs/:org/repos", {
|
||||
org: "my-project",
|
||||
type: "private",
|
||||
});
|
||||
|
||||
// {
|
||||
// method: 'GET',
|
||||
// url: 'https://api.github.com/orgs/my-project/repos?type=private',
|
||||
// headers: {
|
||||
// accept: 'application/vnd.github.v3+json',
|
||||
// authorization: 'token 0000000000000000000000000000000000000001',
|
||||
// 'user-agent': 'octokit/endpoint.js v1.2.3'
|
||||
// }
|
||||
// }
|
||||
```
|
||||
|
||||
All of the [`@octokit/endpoint`](https://github.com/octokit/endpoint.js) API can be used:
|
||||
|
||||
- [`octokitRequest.endpoint()`](#endpoint)
|
||||
- [`octokitRequest.endpoint.defaults()`](#endpointdefaults)
|
||||
- [`octokitRequest.endpoint.merge()`](#endpointdefaults)
|
||||
- [`octokitRequest.endpoint.parse()`](#endpointmerge)
|
||||
|
||||
## 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 response = await request("POST /markdown/raw", {
|
||||
data: "Hello world github/linguist#1 **cool**, and #1!",
|
||||
headers: {
|
||||
accept: "text/html;charset=utf-8",
|
||||
"content-type": "text/plain",
|
||||
},
|
||||
});
|
||||
|
||||
// Request is sent as
|
||||
//
|
||||
// {
|
||||
// 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!'
|
||||
// }
|
||||
//
|
||||
// not as
|
||||
//
|
||||
// {
|
||||
// ...
|
||||
// body: '{"data": "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
|
||||
request(
|
||||
"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)
|
148
node_modules/@octokit/core/node_modules/@octokit/request/dist-node/index.js
сгенерированный
поставляемый
Normal file
148
node_modules/@octokit/core/node_modules/@octokit/request/dist-node/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,148 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
||||
|
||||
var endpoint = require('@octokit/endpoint');
|
||||
var universalUserAgent = require('universal-user-agent');
|
||||
var isPlainObject = _interopDefault(require('is-plain-object'));
|
||||
var nodeFetch = _interopDefault(require('node-fetch'));
|
||||
var requestError = require('@octokit/request-error');
|
||||
|
||||
const VERSION = "5.4.7";
|
||||
|
||||
function getBufferResponse(response) {
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
|
||||
function fetchWrapper(requestOptions) {
|
||||
if (isPlainObject(requestOptions.body) || Array.isArray(requestOptions.body)) {
|
||||
requestOptions.body = JSON.stringify(requestOptions.body);
|
||||
}
|
||||
|
||||
let headers = {};
|
||||
let status;
|
||||
let url;
|
||||
const fetch = requestOptions.request && requestOptions.request.fetch || nodeFetch;
|
||||
return fetch(requestOptions.url, Object.assign({
|
||||
method: requestOptions.method,
|
||||
body: requestOptions.body,
|
||||
headers: requestOptions.headers,
|
||||
redirect: requestOptions.redirect
|
||||
}, requestOptions.request)).then(response => {
|
||||
url = response.url;
|
||||
status = response.status;
|
||||
|
||||
for (const keyAndValue of response.headers) {
|
||||
headers[keyAndValue[0]] = keyAndValue[1];
|
||||
}
|
||||
|
||||
if (status === 204 || status === 205) {
|
||||
return;
|
||||
} // GitHub API returns 200 for HEAD requests
|
||||
|
||||
|
||||
if (requestOptions.method === "HEAD") {
|
||||
if (status < 400) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new requestError.RequestError(response.statusText, status, {
|
||||
headers,
|
||||
request: requestOptions
|
||||
});
|
||||
}
|
||||
|
||||
if (status === 304) {
|
||||
throw new requestError.RequestError("Not modified", status, {
|
||||
headers,
|
||||
request: requestOptions
|
||||
});
|
||||
}
|
||||
|
||||
if (status >= 400) {
|
||||
return response.text().then(message => {
|
||||
const error = new requestError.RequestError(message, status, {
|
||||
headers,
|
||||
request: requestOptions
|
||||
});
|
||||
|
||||
try {
|
||||
let responseBody = JSON.parse(error.message);
|
||||
Object.assign(error, responseBody);
|
||||
let errors = responseBody.errors; // Assumption `errors` would always be in Array format
|
||||
|
||||
error.message = error.message + ": " + errors.map(JSON.stringify).join(", ");
|
||||
} catch (e) {// ignore, see octokit/rest.js#684
|
||||
}
|
||||
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
const contentType = response.headers.get("content-type");
|
||||
|
||||
if (/application\/json/.test(contentType)) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
|
||||
return response.text();
|
||||
}
|
||||
|
||||
return getBufferResponse(response);
|
||||
}).then(data => {
|
||||
return {
|
||||
status,
|
||||
url,
|
||||
headers,
|
||||
data
|
||||
};
|
||||
}).catch(error => {
|
||||
if (error instanceof requestError.RequestError) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw new requestError.RequestError(error.message, 500, {
|
||||
headers,
|
||||
request: requestOptions
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function withDefaults(oldEndpoint, newDefaults) {
|
||||
const endpoint = oldEndpoint.defaults(newDefaults);
|
||||
|
||||
const newApi = function (route, parameters) {
|
||||
const endpointOptions = endpoint.merge(route, parameters);
|
||||
|
||||
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
||||
return fetchWrapper(endpoint.parse(endpointOptions));
|
||||
}
|
||||
|
||||
const request = (route, parameters) => {
|
||||
return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));
|
||||
};
|
||||
|
||||
Object.assign(request, {
|
||||
endpoint,
|
||||
defaults: withDefaults.bind(null, endpoint)
|
||||
});
|
||||
return endpointOptions.request.hook(request, endpointOptions);
|
||||
};
|
||||
|
||||
return Object.assign(newApi, {
|
||||
endpoint,
|
||||
defaults: withDefaults.bind(null, endpoint)
|
||||
});
|
||||
}
|
||||
|
||||
const request = withDefaults(endpoint.endpoint, {
|
||||
headers: {
|
||||
"user-agent": `octokit-request.js/${VERSION} ${universalUserAgent.getUserAgent()}`
|
||||
}
|
||||
});
|
||||
|
||||
exports.request = request;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
93
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/fetch-wrapper.js
сгенерированный
поставляемый
Normal file
93
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/fetch-wrapper.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,93 @@
|
|||
import isPlainObject from "is-plain-object";
|
||||
import nodeFetch from "node-fetch";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
import getBuffer from "./get-buffer-response";
|
||||
export default function fetchWrapper(requestOptions) {
|
||||
if (isPlainObject(requestOptions.body) ||
|
||||
Array.isArray(requestOptions.body)) {
|
||||
requestOptions.body = JSON.stringify(requestOptions.body);
|
||||
}
|
||||
let headers = {};
|
||||
let status;
|
||||
let url;
|
||||
const fetch = (requestOptions.request && requestOptions.request.fetch) || nodeFetch;
|
||||
return fetch(requestOptions.url, Object.assign({
|
||||
method: requestOptions.method,
|
||||
body: requestOptions.body,
|
||||
headers: requestOptions.headers,
|
||||
redirect: requestOptions.redirect,
|
||||
}, requestOptions.request))
|
||||
.then((response) => {
|
||||
url = response.url;
|
||||
status = response.status;
|
||||
for (const keyAndValue of response.headers) {
|
||||
headers[keyAndValue[0]] = keyAndValue[1];
|
||||
}
|
||||
if (status === 204 || status === 205) {
|
||||
return;
|
||||
}
|
||||
// GitHub API returns 200 for HEAD requests
|
||||
if (requestOptions.method === "HEAD") {
|
||||
if (status < 400) {
|
||||
return;
|
||||
}
|
||||
throw new RequestError(response.statusText, status, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
}
|
||||
if (status === 304) {
|
||||
throw new RequestError("Not modified", status, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
}
|
||||
if (status >= 400) {
|
||||
return response
|
||||
.text()
|
||||
.then((message) => {
|
||||
const error = new RequestError(message, status, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
try {
|
||||
let responseBody = JSON.parse(error.message);
|
||||
Object.assign(error, responseBody);
|
||||
let errors = responseBody.errors;
|
||||
// Assumption `errors` would always be in Array format
|
||||
error.message =
|
||||
error.message + ": " + errors.map(JSON.stringify).join(", ");
|
||||
}
|
||||
catch (e) {
|
||||
// ignore, see octokit/rest.js#684
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
const contentType = response.headers.get("content-type");
|
||||
if (/application\/json/.test(contentType)) {
|
||||
return response.json();
|
||||
}
|
||||
if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
|
||||
return response.text();
|
||||
}
|
||||
return getBuffer(response);
|
||||
})
|
||||
.then((data) => {
|
||||
return {
|
||||
status,
|
||||
url,
|
||||
headers,
|
||||
data,
|
||||
};
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error instanceof RequestError) {
|
||||
throw error;
|
||||
}
|
||||
throw new RequestError(error.message, 500, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
});
|
||||
}
|
3
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/get-buffer-response.js
сгенерированный
поставляемый
Normal file
3
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/get-buffer-response.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,3 @@
|
|||
export default function getBufferResponse(response) {
|
||||
return response.arrayBuffer();
|
||||
}
|
9
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/index.js
сгенерированный
поставляемый
Normal file
9
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { endpoint } from "@octokit/endpoint";
|
||||
import { getUserAgent } from "universal-user-agent";
|
||||
import { VERSION } from "./version";
|
||||
import withDefaults from "./with-defaults";
|
||||
export const request = withDefaults(endpoint, {
|
||||
headers: {
|
||||
"user-agent": `octokit-request.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/version.js
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/version.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export const VERSION = "5.4.7";
|
22
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/with-defaults.js
сгенерированный
поставляемый
Normal file
22
node_modules/@octokit/core/node_modules/@octokit/request/dist-src/with-defaults.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,22 @@
|
|||
import fetchWrapper from "./fetch-wrapper";
|
||||
export default function withDefaults(oldEndpoint, newDefaults) {
|
||||
const endpoint = oldEndpoint.defaults(newDefaults);
|
||||
const newApi = function (route, parameters) {
|
||||
const endpointOptions = endpoint.merge(route, parameters);
|
||||
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
||||
return fetchWrapper(endpoint.parse(endpointOptions));
|
||||
}
|
||||
const request = (route, parameters) => {
|
||||
return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));
|
||||
};
|
||||
Object.assign(request, {
|
||||
endpoint,
|
||||
defaults: withDefaults.bind(null, endpoint),
|
||||
});
|
||||
return endpointOptions.request.hook(request, endpointOptions);
|
||||
};
|
||||
return Object.assign(newApi, {
|
||||
endpoint,
|
||||
defaults: withDefaults.bind(null, endpoint),
|
||||
});
|
||||
}
|
11
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/fetch-wrapper.d.ts
сгенерированный
поставляемый
Normal file
11
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/fetch-wrapper.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,11 @@
|
|||
import { EndpointInterface } from "@octokit/types";
|
||||
export default function fetchWrapper(requestOptions: ReturnType<EndpointInterface> & {
|
||||
redirect?: "error" | "follow" | "manual";
|
||||
}): Promise<{
|
||||
status: number;
|
||||
url: string;
|
||||
headers: {
|
||||
[header: string]: string;
|
||||
};
|
||||
data: any;
|
||||
}>;
|
2
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/get-buffer-response.d.ts
сгенерированный
поставляемый
Normal file
2
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/get-buffer-response.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { Response } from "node-fetch";
|
||||
export default function getBufferResponse(response: Response): Promise<ArrayBuffer>;
|
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/index.d.ts
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/index.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export declare const request: import("@octokit/types").RequestInterface<object>;
|
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/version.d.ts
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/version.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export declare const VERSION = "5.4.7";
|
2
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/with-defaults.d.ts
сгенерированный
поставляемый
Normal file
2
node_modules/@octokit/core/node_modules/@octokit/request/dist-types/with-defaults.d.ts
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,2 @@
|
|||
import { EndpointInterface, RequestInterface, RequestParameters } from "@octokit/types";
|
||||
export default function withDefaults(oldEndpoint: EndpointInterface, newDefaults: RequestParameters): RequestInterface;
|
132
node_modules/@octokit/core/node_modules/@octokit/request/dist-web/index.js
сгенерированный
поставляемый
Normal file
132
node_modules/@octokit/core/node_modules/@octokit/request/dist-web/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,132 @@
|
|||
import { endpoint } from '@octokit/endpoint';
|
||||
import { getUserAgent } from 'universal-user-agent';
|
||||
import isPlainObject from 'is-plain-object';
|
||||
import nodeFetch from 'node-fetch';
|
||||
import { RequestError } from '@octokit/request-error';
|
||||
|
||||
const VERSION = "5.4.7";
|
||||
|
||||
function getBufferResponse(response) {
|
||||
return response.arrayBuffer();
|
||||
}
|
||||
|
||||
function fetchWrapper(requestOptions) {
|
||||
if (isPlainObject(requestOptions.body) ||
|
||||
Array.isArray(requestOptions.body)) {
|
||||
requestOptions.body = JSON.stringify(requestOptions.body);
|
||||
}
|
||||
let headers = {};
|
||||
let status;
|
||||
let url;
|
||||
const fetch = (requestOptions.request && requestOptions.request.fetch) || nodeFetch;
|
||||
return fetch(requestOptions.url, Object.assign({
|
||||
method: requestOptions.method,
|
||||
body: requestOptions.body,
|
||||
headers: requestOptions.headers,
|
||||
redirect: requestOptions.redirect,
|
||||
}, requestOptions.request))
|
||||
.then((response) => {
|
||||
url = response.url;
|
||||
status = response.status;
|
||||
for (const keyAndValue of response.headers) {
|
||||
headers[keyAndValue[0]] = keyAndValue[1];
|
||||
}
|
||||
if (status === 204 || status === 205) {
|
||||
return;
|
||||
}
|
||||
// GitHub API returns 200 for HEAD requests
|
||||
if (requestOptions.method === "HEAD") {
|
||||
if (status < 400) {
|
||||
return;
|
||||
}
|
||||
throw new RequestError(response.statusText, status, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
}
|
||||
if (status === 304) {
|
||||
throw new RequestError("Not modified", status, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
}
|
||||
if (status >= 400) {
|
||||
return response
|
||||
.text()
|
||||
.then((message) => {
|
||||
const error = new RequestError(message, status, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
try {
|
||||
let responseBody = JSON.parse(error.message);
|
||||
Object.assign(error, responseBody);
|
||||
let errors = responseBody.errors;
|
||||
// Assumption `errors` would always be in Array format
|
||||
error.message =
|
||||
error.message + ": " + errors.map(JSON.stringify).join(", ");
|
||||
}
|
||||
catch (e) {
|
||||
// ignore, see octokit/rest.js#684
|
||||
}
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
const contentType = response.headers.get("content-type");
|
||||
if (/application\/json/.test(contentType)) {
|
||||
return response.json();
|
||||
}
|
||||
if (!contentType || /^text\/|charset=utf-8$/.test(contentType)) {
|
||||
return response.text();
|
||||
}
|
||||
return getBufferResponse(response);
|
||||
})
|
||||
.then((data) => {
|
||||
return {
|
||||
status,
|
||||
url,
|
||||
headers,
|
||||
data,
|
||||
};
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error instanceof RequestError) {
|
||||
throw error;
|
||||
}
|
||||
throw new RequestError(error.message, 500, {
|
||||
headers,
|
||||
request: requestOptions,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function withDefaults(oldEndpoint, newDefaults) {
|
||||
const endpoint = oldEndpoint.defaults(newDefaults);
|
||||
const newApi = function (route, parameters) {
|
||||
const endpointOptions = endpoint.merge(route, parameters);
|
||||
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
||||
return fetchWrapper(endpoint.parse(endpointOptions));
|
||||
}
|
||||
const request = (route, parameters) => {
|
||||
return fetchWrapper(endpoint.parse(endpoint.merge(route, parameters)));
|
||||
};
|
||||
Object.assign(request, {
|
||||
endpoint,
|
||||
defaults: withDefaults.bind(null, endpoint),
|
||||
});
|
||||
return endpointOptions.request.hook(request, endpointOptions);
|
||||
};
|
||||
return Object.assign(newApi, {
|
||||
endpoint,
|
||||
defaults: withDefaults.bind(null, endpoint),
|
||||
});
|
||||
}
|
||||
|
||||
const request = withDefaults(endpoint, {
|
||||
headers: {
|
||||
"user-agent": `octokit-request.js/${VERSION} ${getUserAgent()}`,
|
||||
},
|
||||
});
|
||||
|
||||
export { request };
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-web/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/request/dist-web/index.js.map
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
64
node_modules/@octokit/core/node_modules/@octokit/request/package.json
сгенерированный
поставляемый
Normal file
64
node_modules/@octokit/core/node_modules/@octokit/request/package.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"name": "@octokit/request",
|
||||
"description": "Send parameterized requests to GitHub’s APIs with sensible defaults in browsers and Node",
|
||||
"version": "5.4.7",
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"pika": true,
|
||||
"sideEffects": false,
|
||||
"keywords": [
|
||||
"octokit",
|
||||
"github",
|
||||
"api",
|
||||
"request"
|
||||
],
|
||||
"homepage": "https://github.com/octokit/request.js#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/octokit/request.js/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/octokit/request.js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/endpoint": "^6.0.1",
|
||||
"@octokit/request-error": "^2.0.0",
|
||||
"@octokit/types": "^5.0.0",
|
||||
"deprecation": "^2.0.0",
|
||||
"is-plain-object": "^4.0.0",
|
||||
"node-fetch": "^2.3.0",
|
||||
"once": "^1.4.0",
|
||||
"universal-user-agent": "^6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@octokit/auth-app": "^2.1.2",
|
||||
"@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.4",
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/lolex": "^5.1.0",
|
||||
"@types/node": "^14.0.0",
|
||||
"@types/node-fetch": "^2.3.3",
|
||||
"@types/once": "^1.4.0",
|
||||
"fetch-mock": "^9.3.1",
|
||||
"jest": "^26.0.1",
|
||||
"lolex": "^6.0.0",
|
||||
"prettier": "^2.0.1",
|
||||
"semantic-release": "^17.0.0",
|
||||
"semantic-release-plugin-update-version-in-files": "^1.0.0",
|
||||
"ts-jest": "^26.1.0",
|
||||
"typescript": "^3.9.5"
|
||||
},
|
||||
"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/core/node_modules/@octokit/types/LICENSE
сгенерированный
поставляемый
Normal file
7
node_modules/@octokit/core/node_modules/@octokit/types/LICENSE
сгенерированный
поставляемый
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.
|
64
node_modules/@octokit/core/node_modules/@octokit/types/README.md
сгенерированный
поставляемый
Normal file
64
node_modules/@octokit/core/node_modules/@octokit/types/README.md
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,64 @@
|
|||
# types.ts
|
||||
|
||||
> Shared TypeScript definitions for Octokit projects
|
||||
|
||||
[![@latest](https://img.shields.io/npm/v/@octokit/types.svg)](https://www.npmjs.com/package/@octokit/types)
|
||||
[![Build Status](https://github.com/octokit/types.ts/workflows/Test/badge.svg)](https://github.com/octokit/types.ts/actions?workflow=Test)
|
||||
|
||||
<!-- toc -->
|
||||
|
||||
- [Usage](#usage)
|
||||
- [Examples](#examples)
|
||||
- [Get parameter and response data types for a REST API endpoint](#get-parameter-and-response-data-types-for-a-rest-api-endpoint)
|
||||
- [Get response types from endpoint methods](#get-response-types-from-endpoint-methods)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
<!-- tocstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
See all exported types at https://octokit.github.io/types.ts
|
||||
|
||||
## Examples
|
||||
|
||||
### Get parameter and response data types for a REST API endpoint
|
||||
|
||||
```ts
|
||||
import { Endpoints } from "@octokit/types";
|
||||
|
||||
type listUserReposParameters = Endpoints["GET /repos/:owner/:repo"]["parameters"];
|
||||
type listUserReposResponse = Endpoints["GET /repos/:owner/:repo"]["response"];
|
||||
|
||||
async function listRepos(
|
||||
options: listUserReposParameters
|
||||
): listUserReposResponse["data"] {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
### Get response types from endpoint methods
|
||||
|
||||
```ts
|
||||
import {
|
||||
GetResponseTypeFromEndpointMethod,
|
||||
GetResponseDataTypeFromEndpointMethod,
|
||||
} from "@octokit/types";
|
||||
import { Octokit } from "@octokit/rest";
|
||||
|
||||
const octokit = new Octokit();
|
||||
type CreateLabelResponseType = GetResponseTypeFromEndpointMethod<
|
||||
typeof octokit.issues.createLabel
|
||||
>;
|
||||
type CreateLabelResponseDataType = GetResponseDataTypeFromEndpointMethod<
|
||||
typeof octokit.issues.createLabel
|
||||
>;
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
8
node_modules/@octokit/core/node_modules/@octokit/types/dist-node/index.js
сгенерированный
поставляемый
Normal file
8
node_modules/@octokit/core/node_modules/@octokit/types/dist-node/index.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const VERSION = "5.1.2";
|
||||
|
||||
exports.VERSION = VERSION;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@octokit/core/node_modules/@octokit/types/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/types/dist-node/index.js.map
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"index.js","sources":["../dist-src/VERSION.js"],"sourcesContent":["export const VERSION = \"0.0.0-development\";\n"],"names":["VERSION"],"mappings":";;;;MAAaA,OAAO,GAAG;;;;"}
|
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/AuthInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/AuthInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/EndpointDefaults.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/EndpointDefaults.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/EndpointInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/EndpointInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/EndpointOptions.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/EndpointOptions.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Fetch.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Fetch.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/GetResponseTypeFromEndpointMethod.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/GetResponseTypeFromEndpointMethod.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/OctokitResponse.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/OctokitResponse.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestHeaders.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestHeaders.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestMethod.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestMethod.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestOptions.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestOptions.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestParameters.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestParameters.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestRequestOptions.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/RequestRequestOptions.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/ResponseHeaders.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/ResponseHeaders.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Route.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Route.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Signal.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Signal.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/StrategyInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/StrategyInterface.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Url.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/Url.js
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/VERSION.js
сгенерированный
поставляемый
Normal file
1
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/VERSION.js
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1 @@
|
|||
export const VERSION = "5.1.2";
|
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/generated/Endpoints.js
сгенерированный
поставляемый
Normal file
0
node_modules/@octokit/core/node_modules/@octokit/types/dist-src/generated/Endpoints.js
сгенерированный
поставляемый
Normal file
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче