@octokit/plugin-rest-endpoint-methods
Advanced tools
Comparing version 3.0.0-beta.1 to 3.0.0-beta.2
@@ -21,2 +21,3 @@ 'use strict'; | ||
getWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}"], | ||
listDownloadsForSelfHostedRunnerApplication: ["GET /repos/{owner}/{repo}/actions/runners/downloads"], | ||
listJobsForWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs"], | ||
@@ -741,3 +742,5 @@ listRepoWorkflowRuns: ["GET /repos/{owner}/{repo}/actions/runs"], | ||
addProtectedBranchAdminEnforcement: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"], | ||
addProtectedBranchAppRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps"], | ||
addProtectedBranchAppRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", {}, { | ||
mapToData: "apps" | ||
}], | ||
addProtectedBranchRequiredSignatures: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures", { | ||
@@ -748,5 +751,11 @@ mediaType: { | ||
}], | ||
addProtectedBranchRequiredStatusChecksContexts: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts"], | ||
addProtectedBranchTeamRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams"], | ||
addProtectedBranchUserRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users"], | ||
addProtectedBranchRequiredStatusChecksContexts: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", {}, { | ||
mapToData: "contexts" | ||
}], | ||
addProtectedBranchTeamRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", {}, { | ||
mapToData: "teams" | ||
}], | ||
addProtectedBranchUserRestrictions: ["POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", {}, { | ||
mapToData: "users" | ||
}], | ||
checkCollaborator: ["GET /repos/{owner}/{repo}/collaborators/{username}"], | ||
@@ -904,3 +913,5 @@ checkVulnerabilityAlerts: ["GET /repos/{owner}/{repo}/vulnerability-alerts", { | ||
removeProtectedBranchAdminEnforcement: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"], | ||
removeProtectedBranchAppRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps"], | ||
removeProtectedBranchAppRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", {}, { | ||
mapToData: "apps" | ||
}], | ||
removeProtectedBranchPullRequestReviewEnforcement: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"], | ||
@@ -913,10 +924,24 @@ removeProtectedBranchRequiredSignatures: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures", { | ||
removeProtectedBranchRequiredStatusChecks: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"], | ||
removeProtectedBranchRequiredStatusChecksContexts: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts"], | ||
removeProtectedBranchRequiredStatusChecksContexts: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", {}, { | ||
mapToData: "contexts" | ||
}], | ||
removeProtectedBranchRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions"], | ||
removeProtectedBranchTeamRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams"], | ||
removeProtectedBranchUserRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users"], | ||
replaceProtectedBranchAppRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps"], | ||
replaceProtectedBranchRequiredStatusChecksContexts: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts"], | ||
replaceProtectedBranchTeamRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams"], | ||
replaceProtectedBranchUserRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users"], | ||
removeProtectedBranchTeamRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", {}, { | ||
mapToData: "teams" | ||
}], | ||
removeProtectedBranchUserRestrictions: ["DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", {}, { | ||
mapToData: "users" | ||
}], | ||
replaceProtectedBranchAppRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", {}, { | ||
mapToData: "apps" | ||
}], | ||
replaceProtectedBranchRequiredStatusChecksContexts: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", {}, { | ||
mapToData: "contexts" | ||
}], | ||
replaceProtectedBranchTeamRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", {}, { | ||
mapToData: "teams" | ||
}], | ||
replaceProtectedBranchUserRestrictions: ["PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", {}, { | ||
mapToData: "users" | ||
}], | ||
replaceTopics: ["PUT /repos/{owner}/{repo}/topics", { | ||
@@ -1038,3 +1063,3 @@ mediaType: { | ||
const VERSION = "3.0.0-beta.1"; | ||
const VERSION = "3.0.0-beta.2"; | ||
@@ -1057,13 +1082,9 @@ function endpointsToMethods(octokit, endpointsMap) { | ||
const scopeMethods = newMethods[scope]; // if (decorations) { | ||
// scopeMethods[methodName] = decorate( | ||
// octokit, | ||
// scope, | ||
// methodName, | ||
// endpointDefaults, | ||
// decorations | ||
// ); | ||
// continue; | ||
// } | ||
const scopeMethods = newMethods[scope]; | ||
if (decorations) { | ||
scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations); | ||
continue; | ||
} | ||
scopeMethods[methodName] = octokit.request.defaults(endpointDefaults); | ||
@@ -1074,48 +1095,56 @@ } | ||
return newMethods; | ||
} // NOTE: there are currently no deprecations. But we keep the code | ||
// below for future reference | ||
// function decorate( | ||
// octokit: Octokit, | ||
// scope: string, | ||
// methodName: string, | ||
// defaults: EndpointOptions, | ||
// decorations: EndpointDecorations | ||
// ) { | ||
// const requestWithDefaults = octokit.request.defaults(defaults); | ||
// function withDeprecations( | ||
// ...args: [Route, RequestParameters?] | [EndpointOptions] | ||
// ) { | ||
// 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(withDeprecations, requestWithDefaults); | ||
// } | ||
} | ||
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` | ||
/* istanbul ignore else */ | ||
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); | ||
// } | ||
// 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); | ||
} | ||
/** | ||
@@ -1122,0 +1151,0 @@ * This plugin is a 1:1 copy of internal @octokit/rest plugins. The primary |
@@ -12,12 +12,6 @@ export function endpointsToMethods(octokit, endpointsMap) { | ||
const scopeMethods = newMethods[scope]; | ||
// if (decorations) { | ||
// scopeMethods[methodName] = decorate( | ||
// octokit, | ||
// scope, | ||
// methodName, | ||
// endpointDefaults, | ||
// decorations | ||
// ); | ||
// continue; | ||
// } | ||
if (decorations) { | ||
scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations); | ||
continue; | ||
} | ||
scopeMethods[methodName] = octokit.request.defaults(endpointDefaults); | ||
@@ -28,46 +22,49 @@ } | ||
} | ||
// NOTE: there are currently no deprecations. But we keep the code | ||
// below for future reference | ||
// function decorate( | ||
// octokit: Octokit, | ||
// scope: string, | ||
// methodName: string, | ||
// defaults: EndpointOptions, | ||
// decorations: EndpointDecorations | ||
// ) { | ||
// const requestWithDefaults = octokit.request.defaults(defaults); | ||
// function withDeprecations( | ||
// ...args: [Route, RequestParameters?] | [EndpointOptions] | ||
// ) { | ||
// 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(withDeprecations, requestWithDefaults); | ||
// } | ||
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` | ||
/* istanbul ignore else */ | ||
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); | ||
// } | ||
// 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); | ||
} |
@@ -33,2 +33,5 @@ const Endpoints = { | ||
getWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}"], | ||
listDownloadsForSelfHostedRunnerApplication: [ | ||
"GET /repos/{owner}/{repo}/actions/runners/downloads" | ||
], | ||
listJobsForWorkflowRun: [ | ||
@@ -729,3 +732,5 @@ "GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs" | ||
addProtectedBranchAppRestrictions: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", | ||
{}, | ||
{ mapToData: "apps" } | ||
], | ||
@@ -737,9 +742,15 @@ addProtectedBranchRequiredSignatures: [ | ||
addProtectedBranchRequiredStatusChecksContexts: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", | ||
{}, | ||
{ mapToData: "contexts" } | ||
], | ||
addProtectedBranchTeamRestrictions: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", | ||
{}, | ||
{ mapToData: "teams" } | ||
], | ||
addProtectedBranchUserRestrictions: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", | ||
{}, | ||
{ mapToData: "users" } | ||
], | ||
@@ -929,3 +940,5 @@ checkCollaborator: ["GET /repos/{owner}/{repo}/collaborators/{username}"], | ||
removeProtectedBranchAppRestrictions: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", | ||
{}, | ||
{ mapToData: "apps" } | ||
], | ||
@@ -943,3 +956,5 @@ removeProtectedBranchPullRequestReviewEnforcement: [ | ||
removeProtectedBranchRequiredStatusChecksContexts: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", | ||
{}, | ||
{ mapToData: "contexts" } | ||
], | ||
@@ -950,18 +965,30 @@ removeProtectedBranchRestrictions: [ | ||
removeProtectedBranchTeamRestrictions: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", | ||
{}, | ||
{ mapToData: "teams" } | ||
], | ||
removeProtectedBranchUserRestrictions: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", | ||
{}, | ||
{ mapToData: "users" } | ||
], | ||
replaceProtectedBranchAppRestrictions: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", | ||
{}, | ||
{ mapToData: "apps" } | ||
], | ||
replaceProtectedBranchRequiredStatusChecksContexts: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", | ||
{}, | ||
{ mapToData: "contexts" } | ||
], | ||
replaceProtectedBranchTeamRestrictions: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", | ||
{}, | ||
{ mapToData: "teams" } | ||
], | ||
replaceProtectedBranchUserRestrictions: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", | ||
{}, | ||
{ mapToData: "users" } | ||
], | ||
@@ -968,0 +995,0 @@ replaceTopics: [ |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "3.0.0-beta.1"; | ||
export const VERSION = "3.0.0-beta.2"; |
@@ -5,2 +5,3 @@ import { Route, RequestParameters } from "@octokit/types"; | ||
export declare type EndpointDecorations = { | ||
mapToData?: string; | ||
deprecated?: string; | ||
@@ -7,0 +8,0 @@ renamed?: [string, string]; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "3.0.0-beta.1"; | ||
export declare const VERSION = "3.0.0-beta.2"; |
@@ -33,2 +33,5 @@ const Endpoints = { | ||
getWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}"], | ||
listDownloadsForSelfHostedRunnerApplication: [ | ||
"GET /repos/{owner}/{repo}/actions/runners/downloads" | ||
], | ||
listJobsForWorkflowRun: [ | ||
@@ -729,3 +732,5 @@ "GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs" | ||
addProtectedBranchAppRestrictions: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", | ||
{}, | ||
{ mapToData: "apps" } | ||
], | ||
@@ -737,9 +742,15 @@ addProtectedBranchRequiredSignatures: [ | ||
addProtectedBranchRequiredStatusChecksContexts: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", | ||
{}, | ||
{ mapToData: "contexts" } | ||
], | ||
addProtectedBranchTeamRestrictions: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", | ||
{}, | ||
{ mapToData: "teams" } | ||
], | ||
addProtectedBranchUserRestrictions: [ | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" | ||
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", | ||
{}, | ||
{ mapToData: "users" } | ||
], | ||
@@ -929,3 +940,5 @@ checkCollaborator: ["GET /repos/{owner}/{repo}/collaborators/{username}"], | ||
removeProtectedBranchAppRestrictions: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", | ||
{}, | ||
{ mapToData: "apps" } | ||
], | ||
@@ -943,3 +956,5 @@ removeProtectedBranchPullRequestReviewEnforcement: [ | ||
removeProtectedBranchRequiredStatusChecksContexts: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", | ||
{}, | ||
{ mapToData: "contexts" } | ||
], | ||
@@ -950,18 +965,30 @@ removeProtectedBranchRestrictions: [ | ||
removeProtectedBranchTeamRestrictions: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", | ||
{}, | ||
{ mapToData: "teams" } | ||
], | ||
removeProtectedBranchUserRestrictions: [ | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" | ||
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", | ||
{}, | ||
{ mapToData: "users" } | ||
], | ||
replaceProtectedBranchAppRestrictions: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps", | ||
{}, | ||
{ mapToData: "apps" } | ||
], | ||
replaceProtectedBranchRequiredStatusChecksContexts: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts", | ||
{}, | ||
{ mapToData: "contexts" } | ||
], | ||
replaceProtectedBranchTeamRestrictions: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams", | ||
{}, | ||
{ mapToData: "teams" } | ||
], | ||
replaceProtectedBranchUserRestrictions: [ | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users" | ||
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users", | ||
{}, | ||
{ mapToData: "users" } | ||
], | ||
@@ -1121,3 +1148,3 @@ replaceTopics: [ | ||
const VERSION = "3.0.0-beta.1"; | ||
const VERSION = "3.0.0-beta.2"; | ||
@@ -1135,12 +1162,6 @@ function endpointsToMethods(octokit, endpointsMap) { | ||
const scopeMethods = newMethods[scope]; | ||
// if (decorations) { | ||
// scopeMethods[methodName] = decorate( | ||
// octokit, | ||
// scope, | ||
// methodName, | ||
// endpointDefaults, | ||
// decorations | ||
// ); | ||
// continue; | ||
// } | ||
if (decorations) { | ||
scopeMethods[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations); | ||
continue; | ||
} | ||
scopeMethods[methodName] = octokit.request.defaults(endpointDefaults); | ||
@@ -1151,47 +1172,50 @@ } | ||
} | ||
// NOTE: there are currently no deprecations. But we keep the code | ||
// below for future reference | ||
// function decorate( | ||
// octokit: Octokit, | ||
// scope: string, | ||
// methodName: string, | ||
// defaults: EndpointOptions, | ||
// decorations: EndpointDecorations | ||
// ) { | ||
// const requestWithDefaults = octokit.request.defaults(defaults); | ||
// function withDeprecations( | ||
// ...args: [Route, RequestParameters?] | [EndpointOptions] | ||
// ) { | ||
// 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(withDeprecations, requestWithDefaults); | ||
// } | ||
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` | ||
/* istanbul ignore else */ | ||
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); | ||
// } | ||
// 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); | ||
} | ||
@@ -1198,0 +1222,0 @@ /** |
{ | ||
"name": "@octokit/plugin-rest-endpoint-methods", | ||
"description": "Octokit plugin adding one method for all of api.github.com REST API endpoints", | ||
"version": "3.0.0-beta.1", | ||
"version": "3.0.0-beta.2", | ||
"license": "MIT", | ||
@@ -28,5 +28,5 @@ "files": [ | ||
"@pika/pack": "^0.5.0", | ||
"@pika/plugin-build-node": "^0.7.1", | ||
"@pika/plugin-build-web": "^0.7.1", | ||
"@pika/plugin-ts-standard-pkg": "^0.7.1", | ||
"@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", | ||
@@ -33,0 +33,0 @@ "@types/jest": "^25.1.0", |
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 not supported yet
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1504035
35502
2218
0