mirror of
https://github.com/actions/labeler.git
synced 2025-12-15 14:37:35 +00:00
Bump actions/github to 2.2.0 to support GHES (#72)
* Bumping actions/github to 2.2.0 * Husky commit correct node modules
This commit is contained in:
7
node_modules/@octokit/plugin-paginate-rest/LICENSE
generated
vendored
Normal file
7
node_modules/@octokit/plugin-paginate-rest/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
MIT License Copyright (c) 2019 Octokit contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
135
node_modules/@octokit/plugin-paginate-rest/README.md
generated
vendored
Normal file
135
node_modules/@octokit/plugin-paginate-rest/README.md
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
# plugin-paginate-rest.js
|
||||
|
||||
> Octokit plugin to paginate REST API endpoint responses
|
||||
|
||||
[](https://www.npmjs.com/package/@octokit/plugin-paginate-rest)
|
||||
[](https://github.com/octokit/plugin-paginate-rest.js/actions?workflow=Test)
|
||||
[](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)
|
||||
142
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js
generated
vendored
Normal file
142
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const VERSION = "1.1.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:
|
||||
*
|
||||
* - https://developer.github.com/v3/search/#example (key `items`)
|
||||
* - https://developer.github.com/v3/checks/runs/#response-3 (key: `check_runs`)
|
||||
* - https://developer.github.com/v3/checks/suites/#response-1 (key: `check_suites`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-repositories (key: `repositories`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-installations-for-a-user (key `installations`)
|
||||
*
|
||||
* 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. For the exceptions with the namespace, a fallback check for the route
|
||||
* paths has to be added in order to normalize the response. We cannot check for the total_count
|
||||
* property because it also exists in the response of Get the combined status for a specific ref.
|
||||
*/
|
||||
const REGEX = [/^\/search\//, /^\/repos\/[^/]+\/[^/]+\/commits\/[^/]+\/(check-runs|check-suites)([^/]|$)/, /^\/installation\/repositories([^/]|$)/, /^\/user\/installations([^/]|$)/, /^\/repos\/[^/]+\/[^/]+\/actions\/secrets([^/]|$)/, /^\/repos\/[^/]+\/[^/]+\/actions\/workflows(\/[^/]+\/runs)?([^/]|$)/, /^\/repos\/[^/]+\/[^/]+\/actions\/runs(\/[^/]+\/(artifacts|jobs))?([^/]|$)/];
|
||||
function normalizePaginatedListResponse(octokit, url, response) {
|
||||
const path = url.replace(octokit.request.endpoint.DEFAULTS.baseUrl, "");
|
||||
const responseNeedsNormalization = REGEX.find(regex => regex.test(path));
|
||||
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;
|
||||
Object.defineProperty(response.data, namespaceKey, {
|
||||
get() {
|
||||
octokit.log.warn(`[@octokit/paginate-rest] "response.data.${namespaceKey}" is deprecated for "GET ${path}". Get the results directly from "response.data"`);
|
||||
return Array.from(data);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
1
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-node/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
15
node_modules/@octokit/plugin-paginate-rest/dist-src/index.js
generated
vendored
Normal file
15
node_modules/@octokit/plugin-paginate-rest/dist-src/index.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
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;
|
||||
26
node_modules/@octokit/plugin-paginate-rest/dist-src/iterator.js
generated
vendored
Normal file
26
node_modules/@octokit/plugin-paginate-rest/dist-src/iterator.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
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 };
|
||||
});
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
59
node_modules/@octokit/plugin-paginate-rest/dist-src/normalize-paginated-list-response.js
generated
vendored
Normal file
59
node_modules/@octokit/plugin-paginate-rest/dist-src/normalize-paginated-list-response.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 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:
|
||||
*
|
||||
* - https://developer.github.com/v3/search/#example (key `items`)
|
||||
* - https://developer.github.com/v3/checks/runs/#response-3 (key: `check_runs`)
|
||||
* - https://developer.github.com/v3/checks/suites/#response-1 (key: `check_suites`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-repositories (key: `repositories`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-installations-for-a-user (key `installations`)
|
||||
*
|
||||
* 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. For the exceptions with the namespace, a fallback check for the route
|
||||
* paths has to be added in order to normalize the response. We cannot check for the total_count
|
||||
* property because it also exists in the response of Get the combined status for a specific ref.
|
||||
*/
|
||||
const REGEX = [
|
||||
/^\/search\//,
|
||||
/^\/repos\/[^/]+\/[^/]+\/commits\/[^/]+\/(check-runs|check-suites)([^/]|$)/,
|
||||
/^\/installation\/repositories([^/]|$)/,
|
||||
/^\/user\/installations([^/]|$)/,
|
||||
/^\/repos\/[^/]+\/[^/]+\/actions\/secrets([^/]|$)/,
|
||||
/^\/repos\/[^/]+\/[^/]+\/actions\/workflows(\/[^/]+\/runs)?([^/]|$)/,
|
||||
/^\/repos\/[^/]+\/[^/]+\/actions\/runs(\/[^/]+\/(artifacts|jobs))?([^/]|$)/
|
||||
];
|
||||
export function normalizePaginatedListResponse(octokit, url, response) {
|
||||
const path = url.replace(octokit.request.endpoint.DEFAULTS.baseUrl, "");
|
||||
const responseNeedsNormalization = REGEX.find(regex => regex.test(path));
|
||||
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;
|
||||
Object.defineProperty(response.data, namespaceKey, {
|
||||
get() {
|
||||
octokit.log.warn(`[@octokit/paginate-rest] "response.data.${namespaceKey}" is deprecated for "GET ${path}". Get the results directly from "response.data"`);
|
||||
return Array.from(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
24
node_modules/@octokit/plugin-paginate-rest/dist-src/paginate.js
generated
vendored
Normal file
24
node_modules/@octokit/plugin-paginate-rest/dist-src/paginate.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import { iterator } from "./iterator";
|
||||
export function paginate(octokit, route, parameters, mapFn) {
|
||||
if (typeof parameters === "function") {
|
||||
mapFn = parameters;
|
||||
parameters = undefined;
|
||||
}
|
||||
return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);
|
||||
}
|
||||
function gather(octokit, results, iterator, mapFn) {
|
||||
return iterator.next().then(result => {
|
||||
if (result.done) {
|
||||
return results;
|
||||
}
|
||||
let earlyExit = false;
|
||||
function done() {
|
||||
earlyExit = true;
|
||||
}
|
||||
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);
|
||||
if (earlyExit) {
|
||||
return results;
|
||||
}
|
||||
return gather(octokit, results, iterator, mapFn);
|
||||
});
|
||||
}
|
||||
0
node_modules/@octokit/plugin-paginate-rest/dist-src/types.js
generated
vendored
Normal file
0
node_modules/@octokit/plugin-paginate-rest/dist-src/types.js
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-src/version.js
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-src/version.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const VERSION = "1.1.2";
|
||||
13
node_modules/@octokit/plugin-paginate-rest/dist-types/index.d.ts
generated
vendored
Normal file
13
node_modules/@octokit/plugin-paginate-rest/dist-types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
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;
|
||||
}
|
||||
11
node_modules/@octokit/plugin-paginate-rest/dist-types/iterator.d.ts
generated
vendored
Normal file
11
node_modules/@octokit/plugin-paginate-rest/dist-types/iterator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
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>;
|
||||
}>;
|
||||
};
|
||||
};
|
||||
23
node_modules/@octokit/plugin-paginate-rest/dist-types/normalize-paginated-list-response.d.ts
generated
vendored
Normal file
23
node_modules/@octokit/plugin-paginate-rest/dist-types/normalize-paginated-list-response.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 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:
|
||||
*
|
||||
* - https://developer.github.com/v3/search/#example (key `items`)
|
||||
* - https://developer.github.com/v3/checks/runs/#response-3 (key: `check_runs`)
|
||||
* - https://developer.github.com/v3/checks/suites/#response-1 (key: `check_suites`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-repositories (key: `repositories`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-installations-for-a-user (key `installations`)
|
||||
*
|
||||
* 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. For the exceptions with the namespace, a fallback check for the route
|
||||
* paths has to be added in order to normalize the response. We cannot check for the total_count
|
||||
* property because it also exists in the response of 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;
|
||||
3
node_modules/@octokit/plugin-paginate-rest/dist-types/paginate.d.ts
generated
vendored
Normal file
3
node_modules/@octokit/plugin-paginate-rest/dist-types/paginate.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
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>>;
|
||||
69
node_modules/@octokit/plugin-paginate-rest/dist-types/types.d.ts
generated
vendored
Normal file
69
node_modules/@octokit/plugin-paginate-rest/dist-types/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
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[];
|
||||
1
node_modules/@octokit/plugin-paginate-rest/dist-types/version.d.ts
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-types/version.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const VERSION = "1.1.2";
|
||||
127
node_modules/@octokit/plugin-paginate-rest/dist-web/index.js
generated
vendored
Normal file
127
node_modules/@octokit/plugin-paginate-rest/dist-web/index.js
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
const VERSION = "1.1.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:
|
||||
*
|
||||
* - https://developer.github.com/v3/search/#example (key `items`)
|
||||
* - https://developer.github.com/v3/checks/runs/#response-3 (key: `check_runs`)
|
||||
* - https://developer.github.com/v3/checks/suites/#response-1 (key: `check_suites`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-repositories (key: `repositories`)
|
||||
* - https://developer.github.com/v3/apps/installations/#list-installations-for-a-user (key `installations`)
|
||||
*
|
||||
* 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. For the exceptions with the namespace, a fallback check for the route
|
||||
* paths has to be added in order to normalize the response. We cannot check for the total_count
|
||||
* property because it also exists in the response of Get the combined status for a specific ref.
|
||||
*/
|
||||
const REGEX = [
|
||||
/^\/search\//,
|
||||
/^\/repos\/[^/]+\/[^/]+\/commits\/[^/]+\/(check-runs|check-suites)([^/]|$)/,
|
||||
/^\/installation\/repositories([^/]|$)/,
|
||||
/^\/user\/installations([^/]|$)/,
|
||||
/^\/repos\/[^/]+\/[^/]+\/actions\/secrets([^/]|$)/,
|
||||
/^\/repos\/[^/]+\/[^/]+\/actions\/workflows(\/[^/]+\/runs)?([^/]|$)/,
|
||||
/^\/repos\/[^/]+\/[^/]+\/actions\/runs(\/[^/]+\/(artifacts|jobs))?([^/]|$)/
|
||||
];
|
||||
function normalizePaginatedListResponse(octokit, url, response) {
|
||||
const path = url.replace(octokit.request.endpoint.DEFAULTS.baseUrl, "");
|
||||
const responseNeedsNormalization = REGEX.find(regex => regex.test(path));
|
||||
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;
|
||||
Object.defineProperty(response.data, namespaceKey, {
|
||||
get() {
|
||||
octokit.log.warn(`[@octokit/paginate-rest] "response.data.${namespaceKey}" is deprecated for "GET ${path}". Get the results directly from "response.data"`);
|
||||
return Array.from(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
1
node_modules/@octokit/plugin-paginate-rest/dist-web/index.js.map
generated
vendored
Normal file
1
node_modules/@octokit/plugin-paginate-rest/dist-web/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
79
node_modules/@octokit/plugin-paginate-rest/package.json
generated
vendored
Normal file
79
node_modules/@octokit/plugin-paginate-rest/package.json
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"_from": "@octokit/plugin-paginate-rest@^1.1.1",
|
||||
"_id": "@octokit/plugin-paginate-rest@1.1.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-jbsSoi5Q1pj63sC16XIUboklNw+8tL9VOnJsWycWYR78TKss5PVpIPb1TUUcMQ+bBh7cY579cVAWmf5qG+dw+Q==",
|
||||
"_location": "/@octokit/plugin-paginate-rest",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@octokit/plugin-paginate-rest@^1.1.1",
|
||||
"name": "@octokit/plugin-paginate-rest",
|
||||
"escapedName": "@octokit%2fplugin-paginate-rest",
|
||||
"scope": "@octokit",
|
||||
"rawSpec": "^1.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@octokit/rest"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-1.1.2.tgz",
|
||||
"_shasum": "004170acf8c2be535aba26727867d692f7b488fc",
|
||||
"_spec": "@octokit/plugin-paginate-rest@^1.1.1",
|
||||
"_where": "/Users/pjquirk/Source/GitHub/actions/labeler/node_modules/@octokit/rest",
|
||||
"bugs": {
|
||||
"url": "https://github.com/octokit/plugin-paginate-rest.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@octokit/types": "^2.0.1"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Octokit plugin to paginate REST API endpoint responses",
|
||||
"devDependencies": {
|
||||
"@octokit/core": "^2.0.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/fetch-mock": "^7.3.1",
|
||||
"@types/jest": "^24.0.18",
|
||||
"@types/node": "^13.1.0",
|
||||
"fetch-mock": "^8.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": "^24.1.0",
|
||||
"typescript": "^3.7.2"
|
||||
},
|
||||
"files": [
|
||||
"dist-*/",
|
||||
"bin/"
|
||||
],
|
||||
"homepage": "https://github.com/octokit/plugin-paginate-rest.js#readme",
|
||||
"keywords": [
|
||||
"github",
|
||||
"api",
|
||||
"sdk",
|
||||
"toolkit"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist-node/index.js",
|
||||
"module": "dist-web/index.js",
|
||||
"name": "@octokit/plugin-paginate-rest",
|
||||
"pika": true,
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/octokit/plugin-paginate-rest.js.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"source": "dist-src/index.js",
|
||||
"types": "dist-types/index.d.ts",
|
||||
"version": "1.1.2"
|
||||
}
|
||||
Reference in New Issue
Block a user