use @actions/github

This commit is contained in:
Robert Brignull 2020-07-06 16:04:02 +01:00
parent 9da537eb33
commit 0086c2ecdb
199 changed files with 95598 additions and 6141 deletions

21
node_modules/@octokit/core/LICENSE generated vendored
View file

@ -1,21 +0,0 @@
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.

407
node_modules/@octokit/core/README.md generated vendored
View file

@ -1,407 +0,0 @@
# 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)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/core.js.svg)](https://greenkeeper.io/)
<!-- 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, than `@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();
```
## 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
Octokits functionality can be extended using plugins. THe `Octokit.plugin()` method accepts a function or an array of functions 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 MyOctokit = require("@octokit/core").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 MyActionOctokit = require("@octokit/core")
.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)

View file

@ -1,113 +0,0 @@
'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');
const VERSION = "2.4.2";
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(requestDefaults);
this.log = Object.assign({
debug: () => {},
info: () => {},
warn: console.warn.bind(console),
error: console.error.bind(console)
}, options.log);
this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance
// is unauthenticated. The `this.auth()` method is a no-op and no request hook is 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] || {};
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent ? {
userAgent: `${options.userAgent} ${defaults.userAgent}`
} : null));
}
};
return OctokitWithDefaults;
}
static plugin(pluginOrPlugins) {
var _a;
const currentPlugins = this.plugins;
const newPlugins = Array.isArray(pluginOrPlugins) ? pluginOrPlugins : [pluginOrPlugins];
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

File diff suppressed because one or more lines are too long

View file

@ -1,108 +0,0 @@
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);
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] || {};
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent
? {
userAgent: `${options.userAgent} ${defaults.userAgent}`
}
: null));
}
};
return OctokitWithDefaults;
}
static plugin(pluginOrPlugins) {
var _a;
const currentPlugins = this.plugins;
const newPlugins = Array.isArray(pluginOrPlugins)
? pluginOrPlugins
: [pluginOrPlugins];
const NewOctokit = (_a = class extends this {
},
_a.plugins = currentPlugins.concat(newPlugins.filter(plugin => !currentPlugins.includes(plugin))),
_a);
return NewOctokit;
}
}
Octokit.VERSION = VERSION;
Octokit.plugins = [];

View file

View file

@ -1 +0,0 @@
export const VERSION = "2.4.2";

View file

@ -1,34 +0,0 @@
import { HookCollection } from "before-after-hook";
import { request } from "@octokit/request";
import { graphql } from "@octokit/graphql";
import { Constructor, OctokitOptions, OctokitPlugin, ReturnTypeOf } from "./types";
export declare class Octokit {
static VERSION: string;
static defaults<S extends Constructor<any>>(this: S, defaults: OctokitOptions): {
new (...args: any[]): {
[x: string]: any;
};
} & S;
static plugins: OctokitPlugin[];
static plugin<S extends Constructor<any> & {
plugins: any[];
}, T extends OctokitPlugin | OctokitPlugin[]>(this: S, pluginOrPlugins: T): {
new (...args: any[]): {
[x: string]: any;
};
plugins: any[];
} & S & Constructor<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;
}

View file

@ -1,22 +0,0 @@
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
*/
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 {};

View file

@ -1 +0,0 @@
export declare const VERSION = "2.4.2";

View file

@ -1,113 +0,0 @@
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 = "2.4.2";
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);
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] || {};
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent
? {
userAgent: `${options.userAgent} ${defaults.userAgent}`
}
: null));
}
};
return OctokitWithDefaults;
}
static plugin(pluginOrPlugins) {
var _a;
const currentPlugins = this.plugins;
const newPlugins = Array.isArray(pluginOrPlugins)
? pluginOrPlugins
: [pluginOrPlugins];
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

File diff suppressed because one or more lines are too long

View file

@ -1,57 +0,0 @@
{
"name": "@octokit/core",
"description": "Extendable client for GitHub's REST & GraphQL APIs",
"version": "2.4.2",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"pika": true,
"sideEffects": false,
"keywords": [
"octokit",
"github",
"api",
"sdk",
"toolkit"
],
"repository": "https://github.com/octokit/core.js",
"dependencies": {
"@octokit/auth-token": "^2.4.0",
"@octokit/graphql": "^4.3.1",
"@octokit/request": "^5.3.1",
"@octokit/types": "^2.0.0",
"before-after-hook": "^2.1.0",
"universal-user-agent": "^5.0.0"
},
"devDependencies": {
"@octokit/auth": "^1.1.0",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.9.0",
"@pika/plugin-build-web": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^25.1.0",
"@types/lolex": "^5.1.0",
"@types/node": "^13.1.0",
"@types/node-fetch": "^2.5.0",
"fetch-mock": "^8.3.2",
"http-proxy-agent": "^4.0.1",
"jest": "^25.1.0",
"lolex": "^6.0.0",
"prettier": "^1.19.1",
"proxy": "^1.0.1",
"semantic-release": "^17.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^25.1.0",
"typescript": "^3.5.3"
},
"publishConfig": {
"access": "public"
},
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"module": "dist-web/index.js"
}

View file

@ -1,7 +0,0 @@
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.

View file

@ -1,138 +0,0 @@
# plugin-paginate-rest.js
> Octokit plugin to paginate REST API endpoint responses
[![@latest](https://img.shields.io/npm/v/@octokit/plugin-paginate-rest.svg)](https://www.npmjs.com/package/@octokit/plugin-paginate-rest)
[![Build Status](https://github.com/octokit/plugin-paginate-rest.js/workflows/Test/badge.svg)](https://github.com/octokit/plugin-paginate-rest.js/actions?workflow=Test)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/plugin-paginate-rest.js.svg)](https://greenkeeper.io/)
## Usage
<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>
Load `@octokit/plugin-paginate-rest` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [cdn.pika.dev](https://cdn.pika.dev)
```html
<script type="module">
import { Octokit } from "https://cdn.pika.dev/@octokit/core";
import { paginateRest } from "https://cdn.pika.dev/@octokit/plugin-paginate-rest";
</script>
```
</td></tr>
<tr><th>
Node
</th><td>
Install with `npm install @octokit/core @octokit/plugin-paginate-rest`. Optionally replace `@octokit/core` with a core-compatible module
```js
const { Octokit } = require("@octokit/core");
const { paginateRest } = require("@octokit/plugin-paginate-rest");
```
</td></tr>
</tbody>
</table>
```js
const MyOctokit = Octokit.plugin(paginateRest);
const octokit = new MyOctokit({ auth: "secret123" });
// See https://developer.github.com/v3/issues/#list-issues-for-a-repository
const issues = await octokit.paginate("GET /repos/:owner/:repo/issues", {
owner: "octocat",
repo: "hello-world",
since: "2010-10-01",
per_page: 100
});
```
## `octokit.paginate(route, parameters, mapFunction)` or `octokit.paginate(options, mapFunction)`
The `paginateRest` plugin adds a new `octokit.paginate()` method which accepts the same parameters as [`octokit.request`](https://github.com/octokit/request.js#request). Only "List ..." endpoints such as [List issues for a repository](https://developer.github.com/v3/issues/#list-issues-for-a-repository) are supporting pagination. Their [response includes a Link header](https://developer.github.com/v3/issues/#response-1). For other endpoints, `octokit.paginate()` behaves the same as `octokit.request()`.
The `per_page` parameter is usually defaulting to `30`, and can be set to up to `100`, which helps retrieving a big amount of data without hitting the rate limits too soon.
An optional `mapFunction` can be passed to map each page response to a new value, usually an array with only the data you need. This can help to reduce memory usage, as only the relevant data has to be kept in memory until the pagination is complete.
```js
const issueTitles = await octokit.paginate(
"GET /repos/:owner/:repo/issues",
{
owner: "octocat",
repo: "hello-world",
since: "2010-10-01",
per_page: 100
},
response => response.data.map(issue => issue.title)
);
```
The `mapFunction` gets a 2nd argument `done` which can be called to end the pagination early.
```js
const issues = await octokit.paginate(
"GET /repos/:owner/:repo/issues",
{
owner: "octocat",
repo: "hello-world",
since: "2010-10-01",
per_page: 100
},
(response, done) => {
if (response.data.find(issues => issue.title.includes("something"))) {
done();
}
return response.data;
}
);
```
## `octokit.paginate.iterator(route, parameters)` or `octokit.paginate.iterator(options)`
If your target runtime environments supports async iterators (such as most modern browsers and Node 10+), you can iterate through each response
```js
const parameters = {
owner: "octocat",
repo: "hello-world",
since: "2010-10-01",
per_page: 100
};
for await (const response of octokit.paginate.iterator(
"GET /repos/:owner/:repo/issues",
parameters
)) {
// do whatever you want with each response, break out of the loop, etc.
console.log(response.data.title);
}
```
## How it works
`octokit.paginate()` wraps `octokit.request()`. As long as a `rel="next"` link value is present in the response's `Link` header, it sends another request for that URL, and so on.
Most of GitHub's paginating REST API endpoints return an array, but there are a few exceptions which return an object with a key that includes the items array.
- [Search repositories](https://developer.github.com/v3/search/#example) (key `items`)
- [List check runs for a specific ref](https://developer.github.com/v3/checks/runs/#response-3) (key: `check_runs`)
- [List check suites for a specific ref](https://developer.github.com/v3/checks/suites/#response-1) (key: `check_suites`)
- [List repositories](https://developer.github.com/v3/apps/installations/#list-repositories) for an installation (key: `repositories`)
- [List installations for a user](https://developer.github.com/v3/apps/installations/#response-1) (key `installations`)
`octokit.paginate()` is working around these inconsistencies so you don't have to worry about it.
If a response is lacking the `Link` header, `octokit.paginate()` still resolves with an array, even if the response returns a single object.
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## License
[MIT](LICENSE)

View file

@ -1,129 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const VERSION = "2.0.2";
/**
* Some list response that can be paginated have a different response structure
*
* They have a `total_count` key in the response (search also has `incomplete_results`,
* /installation/repositories also has `repository_selection`), as well as a key with
* the list of the items which name varies from endpoint to endpoint.
*
* Octokit normalizes these responses so that paginated results are always returned following
* the same structure. One challenge is that if the list response has only one page, no Link
* header is provided, so this header alone is not sufficient to check wether a response is
* paginated or not.
*
* We check if a "total_count" key is present in the response data, but also make sure that
* a "url" property is not, as the "Get the combined status for a specific ref" endpoint would
* otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
*/
function normalizePaginatedListResponse(octokit, url, response) {
const responseNeedsNormalization = "total_count" in response.data && !("url" in response.data);
if (!responseNeedsNormalization) return; // keep the additional properties intact as there is currently no other way
// to retrieve the same information.
const incompleteResults = response.data.incomplete_results;
const repositorySelection = response.data.repository_selection;
const totalCount = response.data.total_count;
delete response.data.incomplete_results;
delete response.data.repository_selection;
delete response.data.total_count;
const namespaceKey = Object.keys(response.data)[0];
const data = response.data[namespaceKey];
response.data = data;
if (typeof incompleteResults !== "undefined") {
response.data.incomplete_results = incompleteResults;
}
if (typeof repositorySelection !== "undefined") {
response.data.repository_selection = repositorySelection;
}
response.data.total_count = totalCount;
}
function iterator(octokit, route, parameters) {
const options = octokit.request.endpoint(route, parameters);
const method = options.method;
const headers = options.headers;
let url = options.url;
return {
[Symbol.asyncIterator]: () => ({
next() {
if (!url) {
return Promise.resolve({
done: true
});
}
return octokit.request({
method,
url,
headers
}).then(response => {
normalizePaginatedListResponse(octokit, url, response); // `response.headers.link` format:
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
// sets `url` to undefined if "next" URL is not present or `link` header is not set
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1];
return {
value: response
};
});
}
})
};
}
function paginate(octokit, route, parameters, mapFn) {
if (typeof parameters === "function") {
mapFn = parameters;
parameters = undefined;
}
return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);
}
function gather(octokit, results, iterator, mapFn) {
return iterator.next().then(result => {
if (result.done) {
return results;
}
let earlyExit = false;
function done() {
earlyExit = true;
}
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);
if (earlyExit) {
return results;
}
return gather(octokit, results, iterator, mapFn);
});
}
/**
* @param octokit Octokit instance
* @param options Options passed to Octokit constructor
*/
function paginateRest(octokit) {
return {
paginate: Object.assign(paginate.bind(null, octokit), {
iterator: iterator.bind(null, octokit)
})
};
}
paginateRest.VERSION = VERSION;
exports.paginateRest = paginateRest;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,15 +0,0 @@
import { VERSION } from "./version";
import { paginate } from "./paginate";
import { iterator } from "./iterator";
/**
* @param octokit Octokit instance
* @param options Options passed to Octokit constructor
*/
export function paginateRest(octokit) {
return {
paginate: Object.assign(paginate.bind(null, octokit), {
iterator: iterator.bind(null, octokit)
})
};
}
paginateRest.VERSION = VERSION;

View file

@ -1,26 +0,0 @@
import { normalizePaginatedListResponse } from "./normalize-paginated-list-response";
export function iterator(octokit, route, parameters) {
const options = octokit.request.endpoint(route, parameters);
const method = options.method;
const headers = options.headers;
let url = options.url;
return {
[Symbol.asyncIterator]: () => ({
next() {
if (!url) {
return Promise.resolve({ done: true });
}
return octokit
.request({ method, url, headers })
.then((response) => {
normalizePaginatedListResponse(octokit, url, response);
// `response.headers.link` format:
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
// sets `url` to undefined if "next" URL is not present or `link` header is not set
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1];
return { value: response };
});
}
})
};
}

View file

@ -1,39 +0,0 @@
/**
* Some list response that can be paginated have a different response structure
*
* They have a `total_count` key in the response (search also has `incomplete_results`,
* /installation/repositories also has `repository_selection`), as well as a key with
* the list of the items which name varies from endpoint to endpoint.
*
* Octokit normalizes these responses so that paginated results are always returned following
* the same structure. One challenge is that if the list response has only one page, no Link
* header is provided, so this header alone is not sufficient to check wether a response is
* paginated or not.
*
* We check if a "total_count" key is present in the response data, but also make sure that
* a "url" property is not, as the "Get the combined status for a specific ref" endpoint would
* otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
*/
export function normalizePaginatedListResponse(octokit, url, response) {
const responseNeedsNormalization = "total_count" in response.data && !("url" in response.data);
if (!responseNeedsNormalization)
return;
// keep the additional properties intact as there is currently no other way
// to retrieve the same information.
const incompleteResults = response.data.incomplete_results;
const repositorySelection = response.data.repository_selection;
const totalCount = response.data.total_count;
delete response.data.incomplete_results;
delete response.data.repository_selection;
delete response.data.total_count;
const namespaceKey = Object.keys(response.data)[0];
const data = response.data[namespaceKey];
response.data = data;
if (typeof incompleteResults !== "undefined") {
response.data.incomplete_results = incompleteResults;
}
if (typeof repositorySelection !== "undefined") {
response.data.repository_selection = repositorySelection;
}
response.data.total_count = totalCount;
}

View file

@ -1,24 +0,0 @@
import { iterator } from "./iterator";
export function paginate(octokit, route, parameters, mapFn) {
if (typeof parameters === "function") {
mapFn = parameters;
parameters = undefined;
}
return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);
}
function gather(octokit, results, iterator, mapFn) {
return iterator.next().then(result => {
if (result.done) {
return results;
}
let earlyExit = false;
function done() {
earlyExit = true;
}
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);
if (earlyExit) {
return results;
}
return gather(octokit, results, iterator, mapFn);
});
}

View file

@ -1 +0,0 @@
export const VERSION = "2.0.2";

View file

@ -1,13 +0,0 @@
import { PaginateInterface } from "./types";
export { PaginateInterface } from "./types";
import { Octokit } from "@octokit/core";
/**
* @param octokit Octokit instance
* @param options Options passed to Octokit constructor
*/
export declare function paginateRest(octokit: Octokit): {
paginate: PaginateInterface;
};
export declare namespace paginateRest {
var VERSION: string;
}

View file

@ -1,11 +0,0 @@
import { Octokit } from "@octokit/core";
import { OctokitResponse, RequestParameters, Route } from "./types";
export declare function iterator(octokit: Octokit, route: Route, parameters?: RequestParameters): {
[Symbol.asyncIterator]: () => {
next(): Promise<{
done: boolean;
}> | Promise<{
value: OctokitResponse<any>;
}>;
};
};

View file

@ -1,19 +0,0 @@
/**
* Some list response that can be paginated have a different response structure
*
* They have a `total_count` key in the response (search also has `incomplete_results`,
* /installation/repositories also has `repository_selection`), as well as a key with
* the list of the items which name varies from endpoint to endpoint.
*
* Octokit normalizes these responses so that paginated results are always returned following
* the same structure. One challenge is that if the list response has only one page, no Link
* header is provided, so this header alone is not sufficient to check wether a response is
* paginated or not.
*
* We check if a "total_count" key is present in the response data, but also make sure that
* a "url" property is not, as the "Get the combined status for a specific ref" endpoint would
* otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
*/
import { Octokit } from "@octokit/core";
import { OctokitResponse } from "./types";
export declare function normalizePaginatedListResponse(octokit: Octokit, url: string, response: OctokitResponse<any>): void;

View file

@ -1,3 +0,0 @@
import { Octokit } from "@octokit/core";
import { MapFunction, PaginationResults, RequestParameters, Route } from "./types";
export declare function paginate(octokit: Octokit, route: Route, parameters?: RequestParameters, mapFn?: MapFunction): Promise<PaginationResults<any>>;

View file

@ -1,69 +0,0 @@
import * as OctokitTypes from "@octokit/types";
export { EndpointOptions } from "@octokit/types";
export { OctokitResponse } from "@octokit/types";
export { RequestParameters } from "@octokit/types";
export { Route } from "@octokit/types";
export interface PaginateInterface {
/**
* Sends a request based on endpoint options
*
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
* @param {function} mapFn Optional method to map each response to a custom array
*/
<T, R>(options: OctokitTypes.EndpointOptions, mapFn: MapFunction<T, R>): Promise<PaginationResults<R>>;
/**
* Sends a request based on endpoint options
*
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T>(options: OctokitTypes.EndpointOptions): Promise<PaginationResults<T>>;
/**
* Sends a request based on endpoint options
*
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
* @param {function} mapFn Optional method to map each response to a custom array
*/
<T, R>(route: OctokitTypes.Route, mapFn: MapFunction<T>): Promise<PaginationResults<R>>;
/**
* Sends a request based on endpoint options
*
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
* @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
* @param {function} mapFn Optional method to map each response to a custom array
*/
<T, R>(route: OctokitTypes.Route, parameters: OctokitTypes.RequestParameters, mapFn: MapFunction<T>): Promise<PaginationResults<R>>;
/**
* Sends a request based on endpoint options
*
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
* @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T>(route: OctokitTypes.Route, parameters: OctokitTypes.RequestParameters): Promise<PaginationResults<T>>;
/**
* Sends a request based on endpoint options
*
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
*/
<T>(route: OctokitTypes.Route): Promise<PaginationResults<T>>;
iterator: {
/**
* Get an asynchronous iterator for use with `for await()`,
*
* @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T>(EndpointOptions: OctokitTypes.EndpointOptions): AsyncIterableIterator<OctokitTypes.OctokitResponse<PaginationResults<T>>>;
/**
* Get an asynchronous iterator for use with `for await()`,
*
* @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<T>(route: OctokitTypes.Route, parameters?: OctokitTypes.RequestParameters): AsyncIterableIterator<OctokitTypes.OctokitResponse<PaginationResults<T>>>;
};
}
export interface MapFunction<T = any, R = any> {
(response: OctokitTypes.OctokitResponse<PaginationResults<T>>, done: () => void): R[];
}
export declare type PaginationResults<T = any> = T[];

View file

@ -1 +0,0 @@
export declare const VERSION = "2.0.2";

View file

@ -1,107 +0,0 @@
const VERSION = "2.0.2";
/**
* Some list response that can be paginated have a different response structure
*
* They have a `total_count` key in the response (search also has `incomplete_results`,
* /installation/repositories also has `repository_selection`), as well as a key with
* the list of the items which name varies from endpoint to endpoint.
*
* Octokit normalizes these responses so that paginated results are always returned following
* the same structure. One challenge is that if the list response has only one page, no Link
* header is provided, so this header alone is not sufficient to check wether a response is
* paginated or not.
*
* We check if a "total_count" key is present in the response data, but also make sure that
* a "url" property is not, as the "Get the combined status for a specific ref" endpoint would
* otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
*/
function normalizePaginatedListResponse(octokit, url, response) {
const responseNeedsNormalization = "total_count" in response.data && !("url" in response.data);
if (!responseNeedsNormalization)
return;
// keep the additional properties intact as there is currently no other way
// to retrieve the same information.
const incompleteResults = response.data.incomplete_results;
const repositorySelection = response.data.repository_selection;
const totalCount = response.data.total_count;
delete response.data.incomplete_results;
delete response.data.repository_selection;
delete response.data.total_count;
const namespaceKey = Object.keys(response.data)[0];
const data = response.data[namespaceKey];
response.data = data;
if (typeof incompleteResults !== "undefined") {
response.data.incomplete_results = incompleteResults;
}
if (typeof repositorySelection !== "undefined") {
response.data.repository_selection = repositorySelection;
}
response.data.total_count = totalCount;
}
function iterator(octokit, route, parameters) {
const options = octokit.request.endpoint(route, parameters);
const method = options.method;
const headers = options.headers;
let url = options.url;
return {
[Symbol.asyncIterator]: () => ({
next() {
if (!url) {
return Promise.resolve({ done: true });
}
return octokit
.request({ method, url, headers })
.then((response) => {
normalizePaginatedListResponse(octokit, url, response);
// `response.headers.link` format:
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
// sets `url` to undefined if "next" URL is not present or `link` header is not set
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1];
return { value: response };
});
}
})
};
}
function paginate(octokit, route, parameters, mapFn) {
if (typeof parameters === "function") {
mapFn = parameters;
parameters = undefined;
}
return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);
}
function gather(octokit, results, iterator, mapFn) {
return iterator.next().then(result => {
if (result.done) {
return results;
}
let earlyExit = false;
function done() {
earlyExit = true;
}
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);
if (earlyExit) {
return results;
}
return gather(octokit, results, iterator, mapFn);
});
}
/**
* @param octokit Octokit instance
* @param options Options passed to Octokit constructor
*/
function paginateRest(octokit) {
return {
paginate: Object.assign(paginate.bind(null, octokit), {
iterator: iterator.bind(null, octokit)
})
};
}
paginateRest.VERSION = VERSION;
export { paginateRest };
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -1,46 +0,0 @@
{
"name": "@octokit/plugin-paginate-rest",
"description": "Octokit plugin to paginate REST API endpoint responses",
"version": "2.0.2",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"pika": true,
"sideEffects": false,
"keywords": [
"github",
"api",
"sdk",
"toolkit"
],
"repository": "https://github.com/octokit/plugin-paginate-rest.js",
"dependencies": {
"@octokit/types": "^2.0.1"
},
"devDependencies": {
"@octokit/core": "^2.0.0",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.9.0",
"@pika/plugin-build-web": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^25.1.0",
"@types/node": "^13.1.0",
"fetch-mock": "^9.0.0",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"semantic-release": "^17.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^25.1.0",
"typescript": "^3.7.2"
},
"publishConfig": {
"access": "public"
},
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"module": "dist-web/index.js"
}

View file

@ -1,7 +0,0 @@
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.

View file

@ -1,60 +0,0 @@
# plugin-rest-endpoint-methods.js
> Octokit plugin adding one method for all of api.github.com REST API endpoints
[![@latest](https://img.shields.io/npm/v/@octokit/plugin-rest-endpoint-methods.svg)](https://www.npmjs.com/package/@octokit/plugin-rest-endpoint-methods)
[![Build Status](https://github.com/octokit/plugin-rest-endpoint-methods.js/workflows/Test/badge.svg)](https://github.com/octokit/plugin-rest-endpoint-methods.js/actions?workflow=Test)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/plugin-rest-endpoint-methods.js.svg)](https://greenkeeper.io/)
## Usage
<table>
<tbody valign=top align=left>
<tr><th>
Browsers
</th><td width=100%>
Load `@octokit/plugin-rest-endpoint-methods` and [`@octokit/core`](https://github.com/octokit/core.js) (or core-compatible module) directly from [cdn.pika.dev](https://cdn.pika.dev)
```html
<script type="module">
import { Octokit } from "https://cdn.pika.dev/@octokit/core";
import { restEndpointMethods } from "https://cdn.pika.dev/@octokit/plugin-rest-endpoint-methods";
</script>
```
</td></tr>
<tr><th>
Node
</th><td>
Install with `npm install @octokit/core @octokit/plugin-rest-endpoint-methods`. Optionally replace `@octokit/core` with a compatible module
```js
const { Octokit } = require("@octokit/core");
const {
restEndpointMethods
} = require("@octokit/plugin-rest-endpoint-methods");
```
</td></tr>
</tbody>
</table>
```js
const MyOctokit = Octokit.plugin(restEndpointMethods);
const octokit = new MyOctokit({ auth: "secret123" });
// https://developer.github.com/v3/users/#get-the-authenticated-user
octokit.users.getAuthenticated();
```
There is one method for each REST API endpoint documented at [https://developer.github.com/v3](https://developer.github.com/v3). All endpoint methods are documented in the [docs/](docs/) folder, e.g. [docs/users/getAuthenticated.md](docs/users/getAuthenticated.md)
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md)
## License
[MIT](LICENSE)

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,66 +0,0 @@
export function endpointsToMethods(octokit, endpointsMap) {
const newMethods = {};
for (const [scope, endpoints] of Object.entries(endpointsMap)) {
for (const [methodName, endpoint] of Object.entries(endpoints)) {
const [route, defaults, decorations] = endpoint;
const [method, url] = route.split(/ /);
const endpointDefaults = Object.assign({ method, url }, defaults);
if (!newMethods[scope]) {
newMethods[scope] = {};
}
const scopeMethods = newMethods[scope];
if (decorations) {
scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations);
continue;
}
scopeMethods[methodName] = octokit.request.defaults(endpointDefaults);
}
}
return newMethods;
}
function decorate(octokit, scope, methodName, defaults, decorations) {
const requestWithDefaults = octokit.request.defaults(defaults);
function withDecorations(...args) {
// @ts-ignore https://github.com/microsoft/TypeScript/issues/25488
let options = requestWithDefaults.endpoint.merge(...args);
// There are currently no other decorations than `.mapToData`
if (decorations.mapToData) {
options = Object.assign({}, options, {
data: options[decorations.mapToData],
[decorations.mapToData]: undefined
});
return requestWithDefaults(options);
}
// NOTE: there are currently no deprecations. But we keep the code
// below for future reference
if (decorations.renamed) {
const [newScope, newMethodName] = decorations.renamed;
octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`);
}
if (decorations.deprecated) {
octokit.log.warn(decorations.deprecated);
}
// There currently are no renamed parameters
// if (decorations.renamedParameters) {
// // @ts-ignore https://github.com/microsoft/TypeScript/issues/25488
// const options = requestWithDefaults.endpoint.merge(...args);
// for (const [name, alias] of Object.entries(
// decorations.renamedParameters
// )) {
// if (name in options) {
// octokit.log.warn(
// `"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead`
// );
// if (!(alias in options)) {
// options[alias] = options[name];
// }
// delete options[name];
// }
// }
// return requestWithDefaults(options);
// }
// @ts-ignore https://github.com/microsoft/TypeScript/issues/25488
return requestWithDefaults(...args);
}
return Object.assign(withDecorations, requestWithDefaults);
}

File diff suppressed because it is too large Load diff

View file

@ -1,17 +0,0 @@
import ENDPOINTS from "./generated/endpoints";
import { VERSION } from "./version";
import { endpointsToMethods } from "./endpoints-to-methods";
/**
* This plugin is a 1:1 copy of internal @octokit/rest plugins. The primary
* goal is to rebuild @octokit/rest on top of @octokit/core. Once that is
* done, we will remove the registerEndpoints methods and return the methods
* directly as with the other plugins. At that point we will also remove the
* legacy workarounds and deprecations.
*
* See the plan at
* https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/1
*/
export function restEndpointMethods(octokit) {
return endpointsToMethods(octokit, ENDPOINTS);
}
restEndpointMethods.VERSION = VERSION;

View file

@ -1 +0,0 @@
export const VERSION = "3.3.1";

View file

@ -1,4 +0,0 @@
import { Octokit } from "@octokit/core";
import { EndpointsDefaultsAndDecorations } from "./types";
import { RestEndpointMethods } from "./generated/types";
export declare function endpointsToMethods(octokit: Octokit, endpointsMap: EndpointsDefaultsAndDecorations): RestEndpointMethods;

View file

@ -1,3 +0,0 @@
import { EndpointsDefaultsAndDecorations } from "../types";
declare const Endpoints: EndpointsDefaultsAndDecorations;
export default Endpoints;

File diff suppressed because it is too large Load diff

View file

@ -1,16 +0,0 @@
import { Octokit } from "@octokit/core";
import { Api } from "./types";
/**
* This plugin is a 1:1 copy of internal @octokit/rest plugins. The primary
* goal is to rebuild @octokit/rest on top of @octokit/core. Once that is
* done, we will remove the registerEndpoints methods and return the methods
* directly as with the other plugins. At that point we will also remove the
* legacy workarounds and deprecations.
*
* See the plan at
* https://github.com/octokit/plugin-rest-endpoint-methods.js/pull/1
*/
export declare function restEndpointMethods(octokit: Octokit): Api;
export declare namespace restEndpointMethods {
var VERSION: string;
}

View file

@ -1,16 +0,0 @@
import { Route, RequestParameters } from "@octokit/types";
import { RestEndpointMethods } from "./generated/types";
export declare type Api = RestEndpointMethods;
export declare type EndpointDecorations = {
mapToData?: string;
deprecated?: string;
renamed?: [string, string];
renamedParameters?: {
[name: string]: string;
};
};
export declare type EndpointsDefaultsAndDecorations = {
[scope: string]: {
[methodName: string]: [Route, RequestParameters?, EndpointDecorations?];
};
};

View file

@ -1 +0,0 @@
export declare const VERSION = "3.3.1";

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -1,57 +0,0 @@
{
"name": "@octokit/plugin-rest-endpoint-methods",
"description": "Octokit plugin adding one method for all of api.github.com REST API endpoints",
"version": "3.3.1",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"pika": true,
"sideEffects": false,
"keywords": [
"github",
"api",
"sdk",
"toolkit"
],
"repository": "https://github.com/octokit/plugin-rest-endpoint-methods.js",
"dependencies": {
"@octokit/types": "^2.0.1",
"deprecation": "^2.3.1"
},
"devDependencies": {
"@gimenete/type-writer": "^0.1.4",
"@octokit/core": "^2.1.2",
"@octokit/graphql": "^4.3.1",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.9.0",
"@pika/plugin-build-web": "^0.9.0",
"@pika/plugin-ts-standard-pkg": "^0.9.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^25.1.0",
"@types/node": "^13.1.0",
"fetch-mock": "^9.0.0",
"fs-extra": "^8.1.0",
"jest": "^25.1.0",
"lodash.camelcase": "^4.3.0",
"lodash.set": "^4.3.2",
"lodash.upperfirst": "^4.3.1",
"mustache": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"semantic-release": "^17.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"sort-keys": "^4.0.0",
"string-to-jsdoc-comment": "^1.0.0",
"ts-jest": "^25.1.0",
"typescript": "^3.7.2"
},
"publishConfig": {
"access": "public"
},
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"module": "dist-web/index.js"
}

22
node_modules/@octokit/rest/LICENSE generated vendored
View file

@ -1,22 +0,0 @@
The MIT License
Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer)
Copyright (c) 2017-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.

46
node_modules/@octokit/rest/README.md generated vendored
View file

@ -1,46 +0,0 @@
# rest.js
> GitHub REST API client for JavaScript
[![@latest](https://img.shields.io/npm/v/@octokit/rest.svg)](https://www.npmjs.com/package/@octokit/rest)
![Build Status](https://github.com/octokit/rest.js/workflows/Test/badge.svg)
[![Greenkeeper](https://badges.greenkeeper.io/octokit/rest.js.svg)](https://greenkeeper.io/)
## Installation
```shell
npm install @octokit/rest
```
## Usage
```js
const { Octokit } = require("@octokit/rest");
const octokit = new Octokit();
// Compare: https://developer.github.com/v3/repos/#list-organization-repositories
octokit.repos
.listForOrg({
org: "octokit",
type: "public"
})
.then(({ data }) => {
// handle data
});
```
See https://octokit.github.io/rest.js/ for full documentation.
## Contributing
We would love you to contribute to `@octokit/rest`, pull requests are very welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
## Credits
`@octokit/rest` was originally created as [`node-github`](https://www.npmjs.com/package/github) in 2012 by Mike de Boer from Cloud9 IDE, Inc.
It was adopted and renamed by GitHub in 2017
## LICENSE
[MIT](LICENSE)

View file

@ -1,22 +0,0 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@octokit/core');
var pluginRequestLog = require('@octokit/plugin-request-log');
var pluginPaginateRest = require('@octokit/plugin-paginate-rest');
var pluginRestEndpointMethods = require('@octokit/plugin-rest-endpoint-methods');
const VERSION = "17.1.0";
const Octokit = core.Octokit.plugin([// Workaround to prevent TypeScript from widening the inferred return type of
// plugins passed to Octokit, which would result in type information (e.g.
// methods provided by plugins) not being added to Octokit instances.
//
// See https://github.com/octokit/core.js/issues/51#issuecomment-596846088
pluginRequestLog.requestLog, pluginRestEndpointMethods.restEndpointMethods, pluginPaginateRest.paginateRest]).defaults({
userAgent: `octokit-rest.js/${VERSION}`
});
exports.Octokit = Octokit;
//# sourceMappingURL=index.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.js","sources":["../dist-src/version.js","../dist-src/index.js"],"sourcesContent":["export const VERSION = \"17.1.0\";\n","import { Octokit as Core } from \"@octokit/core\";\nimport { requestLog } from \"@octokit/plugin-request-log\";\nimport { paginateRest } from \"@octokit/plugin-paginate-rest\";\nimport { restEndpointMethods } from \"@octokit/plugin-rest-endpoint-methods\";\nimport { VERSION } from \"./version\";\nexport const Octokit = Core.plugin([\n // Workaround to prevent TypeScript from widening the inferred return type of\n // plugins passed to Octokit, which would result in type information (e.g.\n // methods provided by plugins) not being added to Octokit instances.\n //\n // See https://github.com/octokit/core.js/issues/51#issuecomment-596846088\n requestLog,\n restEndpointMethods,\n paginateRest\n]).defaults({\n userAgent: `octokit-rest.js/${VERSION}`\n});\n"],"names":["VERSION","Octokit","Core","plugin","requestLog","restEndpointMethods","paginateRest","defaults","userAgent"],"mappings":";;;;;;;;;AAAO,MAAMA,OAAO,GAAG,mBAAhB;;MCKMC,OAAO,GAAGC,YAAI,CAACC,MAAL,CAAY;AAE/B;AACA;AACA;AACA;AACAC,2BAN+B,EAO/BC,6CAP+B,EAQ/BC,+BAR+B,CAAZ,EASpBC,QAToB,CASX;AACRC,EAAAA,SAAS,EAAG,mBAAkBR,OAAQ;AAD9B,CATW,CAAhB;;;;"}

View file

@ -1,17 +0,0 @@
import { Octokit as Core } from "@octokit/core";
import { requestLog } from "@octokit/plugin-request-log";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
import { VERSION } from "./version";
export const Octokit = Core.plugin([
// Workaround to prevent TypeScript from widening the inferred return type of
// plugins passed to Octokit, which would result in type information (e.g.
// methods provided by plugins) not being added to Octokit instances.
//
// See https://github.com/octokit/core.js/issues/51#issuecomment-596846088
requestLog,
restEndpointMethods,
paginateRest
]).defaults({
userAgent: `octokit-rest.js/${VERSION}`
});

View file

@ -1 +0,0 @@
export const VERSION = "17.1.0";

View file

@ -1,11 +0,0 @@
import { Octokit as Core } from "@octokit/core";
export declare const Octokit: (new (...args: any[]) => {
[x: string]: any;
}) & {
new (...args: any[]): {
[x: string]: any;
};
plugins: any[];
} & typeof Core & import("@octokit/core/dist-types/types").Constructor<void & {
paginate: import("@octokit/plugin-paginate-rest").PaginateInterface;
} & import("@octokit/plugin-rest-endpoint-methods/dist-types/generated/types").RestEndpointMethods>;

View file

@ -1 +0,0 @@
export declare const VERSION = "17.1.0";

View file

@ -1,22 +0,0 @@
import { Octokit as Octokit$1 } from '@octokit/core';
import { requestLog } from '@octokit/plugin-request-log';
import { paginateRest } from '@octokit/plugin-paginate-rest';
import { restEndpointMethods } from '@octokit/plugin-rest-endpoint-methods';
const VERSION = "17.1.0";
const Octokit = Octokit$1.plugin([
// Workaround to prevent TypeScript from widening the inferred return type of
// plugins passed to Octokit, which would result in type information (e.g.
// methods provided by plugins) not being added to Octokit instances.
//
// See https://github.com/octokit/core.js/issues/51#issuecomment-596846088
requestLog,
restEndpointMethods,
paginateRest
]).defaults({
userAgent: `octokit-rest.js/${VERSION}`
});
export { Octokit };
//# sourceMappingURL=index.js.map

View file

@ -1 +0,0 @@
{"version":3,"file":"index.js","sources":["../dist-src/version.js","../dist-src/index.js"],"sourcesContent":["export const VERSION = \"17.1.0\";\n","import { Octokit as Core } from \"@octokit/core\";\nimport { requestLog } from \"@octokit/plugin-request-log\";\nimport { paginateRest } from \"@octokit/plugin-paginate-rest\";\nimport { restEndpointMethods } from \"@octokit/plugin-rest-endpoint-methods\";\nimport { VERSION } from \"./version\";\nexport const Octokit = Core.plugin([\n // Workaround to prevent TypeScript from widening the inferred return type of\n // plugins passed to Octokit, which would result in type information (e.g.\n // methods provided by plugins) not being added to Octokit instances.\n //\n // See https://github.com/octokit/core.js/issues/51#issuecomment-596846088\n requestLog,\n restEndpointMethods,\n paginateRest\n]).defaults({\n userAgent: `octokit-rest.js/${VERSION}`\n});\n"],"names":["Core"],"mappings":";;;;;AAAO,MAAM,OAAO,GAAG,mBAAmB;;ACK9B,MAAC,OAAO,GAAGA,SAAI,CAAC,MAAM,CAAC;AACnC;AACA;AACA;AACA;AACA;AACA,IAAI,UAAU;AACd,IAAI,mBAAmB;AACvB,IAAI,YAAY;AAChB,CAAC,CAAC,CAAC,QAAQ,CAAC;AACZ,IAAI,SAAS,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC,CAAC;;;;"}

View file

@ -1,68 +0,0 @@
{
"name": "@octokit/rest",
"description": "GitHub REST API client for Node.js",
"version": "17.1.0",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"pika": true,
"sideEffects": false,
"keywords": [
"octokit",
"github",
"rest",
"api-client"
],
"contributors": [
{
"name": "Mike de Boer",
"email": "info@mikedeboer.nl"
},
{
"name": "Fabian Jakobs",
"email": "fabian@c9.io"
},
{
"name": "Joe Gallo",
"email": "joe@brassafrax.com"
},
{
"name": "Gregor Martynus",
"url": "https://github.com/gr2m"
}
],
"repository": "https://github.com/octokit/rest.js",
"dependencies": {
"@octokit/core": "^2.4.0",
"@octokit/plugin-paginate-rest": "^2.0.0",
"@octokit/plugin-request-log": "^1.0.0",
"@octokit/plugin-rest-endpoint-methods": "^3.3.0"
},
"devDependencies": {
"@octokit/auth": "^2.0.0",
"@octokit/fixtures-server": "^6.0.0",
"@octokit/request": "^5.2.0",
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.8.1",
"@pika/plugin-build-web": "^0.8.1",
"@pika/plugin-ts-standard-pkg": "^0.8.1",
"@types/jest": "^25.1.2",
"@types/node": "^13.1.0",
"fetch-mock": "^9.0.0",
"jest": "^25.1.0",
"prettier": "^1.14.2",
"semantic-release": "^17.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^25.2.0",
"typescript": "^3.7.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"
}