@octokit/plugin-rest-endpoint-methods
Advanced tools
Comparing version 7.1.2 to 7.1.3
@@ -1,60 +0,73 @@ | ||
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); | ||
} | ||
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; | ||
} | ||
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); | ||
const requestWithDefaults = octokit.request.defaults(defaults); | ||
function withDecorations(...args) { | ||
let options = requestWithDefaults.endpoint.merge(...args); | ||
if (decorations.mapToData) { | ||
options = Object.assign({}, options, { | ||
data: options[decorations.mapToData], | ||
[decorations.mapToData]: void 0 | ||
}); | ||
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) { | ||
const options2 = requestWithDefaults.endpoint.merge(...args); | ||
for (const [name, alias] of Object.entries( | ||
decorations.renamedParameters | ||
)) { | ||
if (name in options2) { | ||
octokit.log.warn( | ||
`"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead` | ||
); | ||
if (!(alias in options2)) { | ||
options2[alias] = options2[name]; | ||
} | ||
delete options2[name]; | ||
} | ||
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 requestWithDefaults(options2); | ||
} | ||
return Object.assign(withDecorations, requestWithDefaults); | ||
return requestWithDefaults(...args); | ||
} | ||
return Object.assign(withDecorations, requestWithDefaults); | ||
} | ||
export { | ||
endpointsToMethods | ||
}; |
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 { | ||
rest: api, | ||
}; | ||
function restEndpointMethods(octokit) { | ||
const api = endpointsToMethods(octokit, ENDPOINTS); | ||
return { | ||
rest: api | ||
}; | ||
} | ||
restEndpointMethods.VERSION = VERSION; | ||
export function legacyRestEndpointMethods(octokit) { | ||
const api = endpointsToMethods(octokit, ENDPOINTS); | ||
return { | ||
...api, | ||
rest: api, | ||
}; | ||
function legacyRestEndpointMethods(octokit) { | ||
const api = endpointsToMethods(octokit, ENDPOINTS); | ||
return { | ||
...api, | ||
rest: api | ||
}; | ||
} | ||
legacyRestEndpointMethods.VERSION = VERSION; | ||
export { | ||
legacyRestEndpointMethods, | ||
restEndpointMethods | ||
}; |
@@ -1,1 +0,4 @@ | ||
export const VERSION = "7.1.2"; | ||
const VERSION = "7.1.3"; | ||
export { | ||
VERSION | ||
}; |
@@ -1,4 +0,4 @@ | ||
import { Octokit } from "@octokit/core"; | ||
import { EndpointsDefaultsAndDecorations } from "./types"; | ||
import { RestEndpointMethods } from "./generated/method-types"; | ||
import type { Octokit } from "@octokit/core"; | ||
import type { EndpointsDefaultsAndDecorations } from "./types"; | ||
import type { RestEndpointMethods } from "./generated/method-types"; | ||
export declare function endpointsToMethods(octokit: Octokit, endpointsMap: EndpointsDefaultsAndDecorations): RestEndpointMethods; |
@@ -1,3 +0,3 @@ | ||
import { EndpointsDefaultsAndDecorations } from "../types"; | ||
import type { EndpointsDefaultsAndDecorations } from "../types"; | ||
declare const Endpoints: EndpointsDefaultsAndDecorations; | ||
export default Endpoints; |
@@ -1,4 +0,4 @@ | ||
import { Octokit } from "@octokit/core"; | ||
export { RestEndpointMethodTypes } from "./generated/parameters-and-response-types"; | ||
import { Api } from "./types"; | ||
import type { Octokit } from "@octokit/core"; | ||
export type { RestEndpointMethodTypes } from "./generated/parameters-and-response-types"; | ||
import type { Api } from "./types"; | ||
export declare function restEndpointMethods(octokit: Octokit): Api; | ||
@@ -5,0 +5,0 @@ export declare namespace restEndpointMethods { |
@@ -1,3 +0,3 @@ | ||
import { Route, RequestParameters } from "@octokit/types"; | ||
import { RestEndpointMethods } from "./generated/method-types"; | ||
import type { Route, RequestParameters } from "@octokit/types"; | ||
import type { RestEndpointMethods } from "./generated/method-types"; | ||
export type Api = { | ||
@@ -4,0 +4,0 @@ rest: RestEndpointMethods; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "7.1.2"; | ||
export declare const VERSION = "7.1.3"; |
{ | ||
"name": "@octokit/plugin-rest-endpoint-methods", | ||
"version": "7.1.3", | ||
"description": "Octokit plugin adding one method for all of api.github.com REST API endpoints", | ||
"version": "7.1.2", | ||
"license": "MIT", | ||
"files": [ | ||
"dist-*/**", | ||
"bin/**" | ||
], | ||
"source": "dist-src/index.js", | ||
"types": "dist-types/index.d.ts", | ||
"main": "dist-node/index.js", | ||
"module": "dist-web/index.js", | ||
"pika": true, | ||
"sideEffects": false, | ||
"repository": "github:octokit/plugin-rest-endpoint-methods.js", | ||
"keywords": [ | ||
@@ -22,23 +12,19 @@ "github", | ||
], | ||
"repository": "github:octokit/plugin-rest-endpoint-methods.js", | ||
"author": "Gregor Martynus (https://twitter.com/gr2m)", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@octokit/types": "^9.2.3", | ||
"deprecation": "^2.3.1" | ||
"@octokit/types": "^9.2.3" | ||
}, | ||
"peerDependencies": { | ||
"@octokit/core": ">=3" | ||
}, | ||
"devDependencies": { | ||
"@gimenete/type-writer": "^0.1.5", | ||
"@octokit/core": "^4.0.0", | ||
"@pika/pack": "^0.3.7", | ||
"@pika/plugin-build-node": "^0.9.0", | ||
"@pika/plugin-build-web": "^0.9.0", | ||
"@pika/plugin-ts-standard-pkg": "^0.9.0", | ||
"@octokit/tsconfig": "^2.0.0", | ||
"@types/fetch-mock": "^7.3.1", | ||
"@types/jest": "^29.0.0", | ||
"@types/node": "^18.0.0", | ||
"esbuild": "^0.17.19", | ||
"fetch-mock": "^9.0.0", | ||
"fs-extra": "^11.0.0", | ||
"github-openapi-graphql-query": "^4.0.0", | ||
"glob": "^10.2.6", | ||
"jest": "^29.0.0", | ||
@@ -57,8 +43,20 @@ "lodash.camelcase": "^4.3.0", | ||
}, | ||
"peerDependencies": { | ||
"@octokit/core": ">=3" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"engines": { | ||
"node": ">= 14" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
"files": [ | ||
"dist-*/**", | ||
"bin/**" | ||
], | ||
"main": "dist-node/index.js", | ||
"browser": "dist-web/index.js", | ||
"types": "dist-types/index.d.ts", | ||
"module": "dist-src/index.js", | ||
"sideEffects": false | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
2
23
21078
1
1488813
20
- Removeddeprecation@^2.3.1
- Removeddeprecation@2.3.1(transitive)