Added the node modules.
Some checks failed
Auto Maintenance Cycle / pre-commit Autoupdate (push) Failing after 33s

This commit is contained in:
2023-11-19 03:45:16 +01:00
parent cdc71fe250
commit 6e037d6837
416 changed files with 108059 additions and 0 deletions

View 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.

View File

@ -0,0 +1,74 @@
# 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)
## 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.skypack.dev](https://cdn.skypack.dev)
```html
<script type="module">
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
import { restEndpointMethods } from "https://cdn.skypack.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.rest.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)
## TypeScript
Parameter and response types for all endpoint methods exported as `{ RestEndpointMethodTypes }`.
Example
```ts
import { RestEndpointMethodTypes } from "@octokit/plugin-rest-endpoint-methods";
type UpdateLabelParameters = RestEndpointMethodTypes["issues"]["updateLabel"]["parameters"];
type UpdateLabelResponse = RestEndpointMethodTypes["issues"]["updateLabel"]["response"];
```
In order to get types beyond parameters and responses, check out [`@octokit/openapi-types`](https://github.com/octokit/openapi-types.ts/#readme), which is a direct transpliation from GitHub's official OpenAPI specification.
## 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

@ -0,0 +1,60 @@
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);
/* istanbul ignore next */
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);
}
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);
}
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

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,11 @@
import ENDPOINTS from "./generated/endpoints";
import { VERSION } from "./version";
import { endpointsToMethods } from "./endpoints-to-methods";
export function restEndpointMethods(octokit) {
const api = endpointsToMethods(octokit, ENDPOINTS);
return {
...api,
rest: api,
};
}
restEndpointMethods.VERSION = VERSION;

View File

@ -0,0 +1 @@
export {};

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
import { Octokit } from "@octokit/core";
export { RestEndpointMethodTypes } from "./generated/parameters-and-response-types";
import { Api } from "./types";
export declare function restEndpointMethods(octokit: Octokit): Api;
export declare namespace restEndpointMethods {
var VERSION: string;
}

View File

@ -0,0 +1,18 @@
import { Route, RequestParameters } from "@octokit/types";
import { RestEndpointMethods } from "./generated/method-types";
export declare type Api = RestEndpointMethods & {
rest: 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

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

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,60 @@
{
"name": "@octokit/plugin-rest-endpoint-methods",
"description": "Octokit plugin adding one method for all of api.github.com REST API endpoints",
"version": "4.15.1",
"license": "MIT",
"files": [
"dist-*/",
"bin/"
],
"pika": true,
"sideEffects": false,
"keywords": [
"github",
"api",
"sdk",
"toolkit"
],
"repository": "github:octokit/plugin-rest-endpoint-methods.js",
"dependencies": {
"@octokit/types": "^6.13.0",
"deprecation": "^2.3.1"
},
"peerDependencies": {
"@octokit/core": ">=3"
},
"devDependencies": {
"@gimenete/type-writer": "^0.1.5",
"@octokit/core": "^3.0.0",
"@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": "^26.0.0",
"@types/node": "^14.0.4",
"fetch-mock": "^9.0.0",
"fs-extra": "^9.0.0",
"jest": "^26.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": "^2.0.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": "^26.1.3",
"typescript": "^4.0.2"
},
"publishConfig": {
"access": "public"
},
"source": "dist-src/index.js",
"types": "dist-types/index.d.ts",
"main": "dist-node/index.js",
"module": "dist-web/index.js"
}