first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

624
build/node_modules/github/lib/definitions.json generated vendored Normal file
View File

@@ -0,0 +1,624 @@
{
"constants": {
"name": "Github",
"description": "A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.",
"protocol": "https",
"host": "api.github.com",
"port": 443,
"documentation": "https://developer.github.com/v3",
"dateFormat": "YYYY-MM-DDTHH:MM:SSZ",
"requestFormat": "json",
"requestMedia": "application/vnd.github.v3+json"
},
"response-headers": [
"X-RateLimit-Limit",
"X-RateLimit-Remaining",
"X-RateLimit-Reset",
"X-Oauth-Scopes",
"X-Poll-Interval",
"X-GitHub-Request-Id",
"X-GitHub-Media-Type",
"X-GitHub-SSO",
"Retry-After",
"Link",
"Location",
"Last-Modified",
"Etag",
"Status"
],
"request-headers": [
"Authorization",
"If-Modified-Since",
"If-None-Match",
"Cookie",
"User-Agent",
"Accept",
"X-GitHub-OTP"
],
"params": {
"files": {
"type": "Json",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content'"
},
"owner": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"username": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"org": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"repo": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"branch": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"sha": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"description": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": ""
},
"id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"gist_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Id (SHA1 hash) of the gist."
},
"installation_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"repository_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"commit_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "Sha of the commit to comment on.",
"description": "Sha of the commit to comment on."
},
"client_id": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "The 20 character OAuth app client key for which to create the token."
},
"column_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"project_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"repo_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"invitation_id": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"ref": {
"type": "String",
"required": true,
"allow-empty": true,
"validation": "",
"invalidmsg": "",
"description": "String of the name of the fully qualified reference (ie: heads/master). If it doesnt have at least one slash, it will be rejected."
},
"number": {
"type": "Number",
"required": true,
"validation": "^[0-9]+$",
"invalidmsg": "",
"description": ""
},
"issue_number": {
"type": "Number",
"required": true,
"validation": "^[0-9]+$",
"invalidmsg": "",
"description": ""
},
"name": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"direction": {
"type": "String",
"required": false,
"validation": "^(asc|desc)$",
"invalidmsg": "asc or desc, default: desc.",
"description": "",
"enum": [
"asc",
"desc"
],
"default": "desc"
},
"since": {
"type": "Date",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ"
},
"until": {
"type": "Date",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ"
},
"state": {
"type": "String",
"required": false,
"validation": "^(open|closed|all)$",
"invalidmsg": "open, closed, all, default: open",
"description": "",
"enum": [
"open",
"closed",
"all"
],
"default": "open"
},
"color": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "6 character hex code, without a leading #.",
"description": "6 character hex code, without a leading #."
},
"base": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "The branch (or git ref) you want your changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repo that requests a merge to a base of another repo."
},
"head": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "The branch (or git ref) where your changes are implemented."
},
"path": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "Relative path of the file to comment on.",
"description": "Relative path of the file to comment on."
},
"position": {
"type": "Number",
"required": true,
"validation": "",
"invalidmsg": "Column index in the diff to comment on.",
"description": "Column index in the diff to comment on."
},
"body": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"homepage": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": ""
},
"private": {
"type": "Boolean",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "True to create a private repository, false to create a public one. Creating private repositories requires a paid GitHub account. Default is false.",
"default": "false"
},
"has_issues": {
"type": "Boolean",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "True to enable issues for this repository, false to disable them. Default is true.",
"default": "true"
},
"has_projects": {
"type": "Boolean",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "True to enable projects for this repository, false to disable them. Default is true.",
"default": "true"
},
"has_wiki": {
"type": "Boolean",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "True to enable the wiki for this repository, false to disable it. Default is true.",
"default": "true"
},
"has_downloads": {
"type": "Boolean",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "True to enable downloads for this repository, false to disable them. Default is true.",
"default": "true"
},
"default_branch": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "Updates the default branch for this repository."
},
"title": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"key": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": ""
},
"page": {
"type": "Number",
"required": false,
"validation": "^[0-9]+$",
"invalidmsg": "",
"description": "Page number of the results to fetch."
},
"per_page": {
"type": "Number",
"required": false,
"validation": "^[0-9]+$",
"invalidmsg": "",
"description": "A custom page size up to 100. Default is 30.",
"default": "30"
},
"scopes": {
"type": "Array",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "A list of scopes that this authorization is in."
},
"note": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "A note to remind you what the OAuth token is for."
},
"note_url": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "A URL to remind you what app the OAuth token is for."
},
"auto_init": {
"type": "Boolean",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "True to create an initial commit with empty README. Default is false",
"default": "false"
},
"gitignore_template": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "Desired language or platform .gitignore template to apply. Ignored if auto_init parameter is not provided."
},
"license_template": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "Desired LICENSE template to apply. Use the name of the template without the extension. For example, \"mit\" or \"mozilla\"."
},
"order": {
"type": "String",
"required": false,
"validation": "^(asc|desc)$",
"invalidmsg": "The sort order if sort parameter is provided. One of asc or desc. Default: desc",
"description": "asc or desc",
"enum": [
"asc",
"desc"
],
"default": "desc"
},
"q": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Search Term",
"combined": true
},
"data": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Raw data to send as the body of the request"
},
"privacy": {
"type": "String",
"required": false,
"validation": "^(secret|closed)$",
"invalidmsg": "secret, closed, default: secret",
"description": "The level of privacy this team should have.",
"enum": [
"secret",
"closed"
],
"default": "secret"
},
"fingerprint": {
"type": "String",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "A unique string to distinguish an authorization from others created for the same client ID and user."
},
"access_token": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "OAuth token"
},
"assignees": {
"type": "Array",
"required": false,
"validation": "",
"invalidmsg": "",
"description": "Logins for Users to assign to this issue. NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise."
},
"url": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Dynamic URL for release asset uploads returned by the releases API response."
},
"contentType": {
"type": "String",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "The content type of a release asset upload."
},
"contentLength": {
"type": "Number",
"required": true,
"validation": "",
"invalidmsg": "",
"description": "Size of release asset upload in bytes."
}
},
"acceptTree": {
"application/vnd.github.giant-sentry-fist-preview+json": [
"/orgs/:org/blocks",
"/orgs/:org/blocks/:username",
"/user/blocks",
"/user/blocks/:username"
],
"application/vnd.github.scarlet-witch-preview+json": [
"/codes_of_conduct",
"/codes_of_conduct/:key",
"/repos/:owner/:repo",
"/repos/:owner/:repo/community/code_of_conduct"
],
"application/vnd.github.cloak-preview+json": [
"/search/commits"
],
"application/vnd.github.black-panther-preview+json": [
"/repos/:owner/:name/community/profile"
],
"application/vnd.github.ant-man-preview+json": [
"/repos/:owner/:repo/deployments",
"/repos/:owner/:repo/deployments/:id/statuses"
],
"application/vnd.github.cryptographer-preview": [
"/users/:username/gpg_keys",
"/user/gpg_keys",
"/user/gpg_keys/:id",
"/repos/:owner/:repo/commits/:sha"
],
"application/vnd.github.barred-rock-preview": [
"/repos/:owner/:repo/import/authors",
"/repos/:owner/:repo/import/authors/:author_id",
"/:owner/:name/import/lfs",
"/:owner/:name/import/large_files",
"/repos/:owner/:repo/import"
],
"application/vnd.github.machine-man-preview": [
"/app/installations",
"/installations/:installation_id/access_tokens",
"/installation/repositories",
"/installations/:installation_id/repositories/:repository_id",
"/apps/:app_slug",
"/app/installations/:installation_id",
"/user/installations",
"/user/installations/:installation_id/repositories/:repository_id"
],
"application/vnd.github.drax-preview+json": [
"/licenses",
"/licenses/:license",
"/repos/:owner/:repo",
"/repos/:owner/:repo/license"
],
"application/vnd.github.valkyrie-preview+json": [
"/marketplace_listing/plans",
"/marketplace_listing/stubbed/plans",
"/marketplace_listing/plans/:id/accounts",
"/marketplace_listing/stubbed/plans/:id/accounts",
"/marketplace_listing/accounts/:id",
"/marketplace_listing/stubbed/accounts/:id",
"/user/marketplace_purchases",
"/user/marketplace_purchases/stubbed"
],
"application/vnd.github.wyandotte-preview+json": [
"/orgs/:org/migrations",
"/orgs/:org/migrations/:id",
"/orgs/:org/migrations/:id/archive",
"/orgs/:org/migrations/:id/repos/:repo_name/lock"
],
"application/vnd.github.hellcat-preview+json": [
"/orgs/:org/teams",
"/teams/:id",
"/teams/:id/teams",
"/teams/:id/members",
"/teams/:id/memberships/:username",
"/teams/:id/repos",
"/teams/:id/repos/:owner/:repo",
"/teams/:id/repos/:org/:repo",
"/user/teams"
],
"application/vnd.github.mister-fantastic-preview+json": [
"/repos/:owner/:repo/pages",
"/repos/:owner/:repo/pages/builds",
"/repos/:owner/:repo/pages/builds/latest",
"/repos/:owner/:repo/pages/builds/:id"
],
"application/vnd.github.eye-scream-preview": [
"/admin/pre-receive-environments/:id",
"/admin/pre_receive_environments",
"/admin/pre-receive-environments/:id/downloads/latest",
"/admin/pre_receive_environments/:id/downloads",
"/admin/pre-receive-hooks/:id",
"/admin/pre-receive-hooks"
],
"application/vnd.github.inertia-preview+json": [
"/repos/:owner/:repo/projects",
"/orgs/:org/projects",
"/projects/:id",
"/projects/columns/:column_id/cards",
"/projects/columns/cards/:id",
"/projects/columns/cards/:id/moves",
"/projects/:project_id/columns",
"/projects/columns/:id",
"/projects/columns/:id/moves"
],
"application/vnd.github.polaris-preview": [
"/repos/:owner/:repo/pulls/:number/merge"
],
"application/vnd.github.squirrel-girl-preview": [
"/issues",
"/user/issues",
"/orgs/:org/issues",
"/repos/:owner/:repo/issues",
"/repos/:owner/:repo/issues/:number",
"/repos/:owner/:repo/comments/:id/reactions",
"/repos/:owner/:repo/issues/comments",
"/repos/:owner/:repo/issues/comments/:id",
"/repos/:owner/:repo/issues/:number/comments",
"/repos/:owner/:repo/issues/:number/reactions",
"/repos/:owner/:repo/issues/comments/:id/reactions",
"/repos/:owner/:repo/pulls/comments/:id/reactions",
"/reactions/:id",
"/repos/:owner/:repo/pulls/:number/comments",
"/repos/:owner/:repo/pulls/comments",
"/repos/:owner/:repo/pulls/comments/:id"
],
"application/vnd.github.thor-preview+json": [
"/repos/:owner/:repo/pulls/:number/requested_reviewers"
],
"application/vnd.github.v3.star+json": [
"/repos/:owner/:repo/stargazers",
"/users/:username/starred",
"/user/starred"
],
"application/vnd.github.mockingbird-preview": [
"/repos/:owner/:repo/issues/:issue_number/timeline"
],
"application/vnd.github.mercy-preview+json": [
"/repos/:owner/:repo/topics",
"/search/repositories"
]
}
}

110
build/node_modules/github/lib/error.js generated vendored Normal file
View File

@@ -0,0 +1,110 @@
/** section: github
* class HttpError
*
* Copyright 2012 Cloud9 IDE, Inc.
*
* This product includes software developed by
* Cloud9 IDE, Inc (http://c9.io).
*
* Author: Mike de Boer <mike@c9.io>
**/
var Util = require('util')
exports.HttpError = function (message, code, headers) {
Error.call(this, message)
this.message = message
this.code = code
this.status = statusCodes[code]
this.headers = headers
}
Util.inherits(exports.HttpError, Error);
(function () {
/**
* HttpError#toString() -> String
*
* Returns the stringified version of the error (i.e. the message).
**/
this.toString = function () {
return this.message
}
/**
* HttpError#toJSON() -> Object
*
* Returns a JSON object representation of the error.
**/
this.toJSON = function () {
return {
code: this.code,
status: this.status,
message: this.message
}
}
}).call(exports.HttpError.prototype)
var statusCodes = {
400: 'Bad Request',
401: 'Unauthorized',
402: 'Payment Required',
403: 'Forbidden',
404: 'Not Found',
405: 'Method Not Allowed',
406: 'Not Acceptable',
407: 'Proxy Authentication Required',
408: 'Request Timeout',
409: 'Conflict',
410: 'Gone',
411: 'Length Required',
412: 'Precondition Failed',
413: 'Request Entity Too Large',
414: 'Request-URI Too Long',
415: 'Unsupported Media Type',
416: 'Requested Range Not Satisfiable',
417: 'Expectation Failed',
420: 'Enhance Your Calm',
422: 'Unprocessable Entity',
423: 'Locked',
424: 'Failed Dependency',
425: 'Unordered Collection',
426: 'Upgrade Required',
428: 'Precondition Required',
429: 'Too Many Requests',
431: 'Request Header Fields Too Large',
444: 'No Response',
449: 'Retry With',
499: 'Client Closed Request',
500: 'Internal Server Error',
501: 'Not Implemented',
502: 'Bad Gateway',
503: 'Service Unavailable',
504: 'Gateway Timeout',
505: 'HTTP Version Not Supported',
506: 'Variant Also Negotiates',
507: 'Insufficient Storage',
508: 'Loop Detected',
509: 'Bandwidth Limit Exceeded',
510: 'Not Extended',
511: 'Network Authentication Required'
}
// XXX: Remove?
for (var status in statusCodes) {
var defaultMsg = statusCodes[status]
var error = (function (defaultMsg, status) {
return function (msg) {
this.defaultMessage = defaultMsg
exports.HttpError.call(this, msg, status)
if (status >= 500) { Error.captureStackTrace(this, arguments.callee) } // eslint-disable-line
}
})(defaultMsg, status)
Util.inherits(error, exports.HttpError)
var className = defaultMsg.replace(/\s/g, '')
exports[className] = error
exports[status] = error
}

3252
build/node_modules/github/lib/index.d.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

827
build/node_modules/github/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,827 @@
'use strict'
var HttpsProxyAgent = require('https-proxy-agent')
var getProxyForUrl = require('proxy-from-env').getProxyForUrl
var toCamelCase = require('lodash/camelCase')
var urlTemplate = require('url-template')
var error = require('./error')
var Url = require('url')
var debug = require('debug')('node-github')
var ROUTES = require('./routes.json')
var DEFINITIONS = require('./definitions.json')
/** section: github
* class Client
*
* Copyright 2012 Cloud9 IDE, Inc.
*
* This product includes software developed by
* Cloud9 IDE, Inc (http://c9.io).
*
* Author: Mike de Boer <mike@c9.io>
*
* Upon instantiation of the [[Client]] class, the routes.json file is loaded
* and parsed for the API HTTP endpoints. For each HTTP endpoint to the
* HTTP server, a method is generated which accepts a Javascript Object
* with parameters and an optional callback to be invoked when the API request
* returns from the server or when the parameters could not be validated.
*
* When an HTTP endpoint is processed and a method is generated as described
* above, [[Client]] also sets up parameter validation with the rules as
* defined in the routes.json.
*
* These definitions are parsed and methods are created that the client can call
* to make an HTTP request to the server.
*
* For example, the endpoint `gists/get-from-user` will be exposed as a member
* on the [[Client]] object and may be invoked with
*
* client.getFromUser({
* "user": "bob"
* }, function(err, ret) {
* // do something with the result here.
* });
*
* // or to fetch a specfic page:
* client.getFromUser({
* "user": "bob",
* "page": 2,
* "per_page": 100
* }, function(err, ret) {
* // do something with the result here.
* });
*
* All the parameters as specified in the Object that is passed to the function
* as first argument, will be validated according to the rules in the `params`
* block of the route definition.
* Thus, in the case of the `user` parameter, according to the definition in
* the `params` block, it's a variable that first needs to be looked up in the
* `params` block of `definitions.json`. Params
* that start with a `$` sign will be substituted with the param with the same
* name from the `params` section of `definitions.json`.
* There we see that it is a required parameter (needs to hold a value). In other
* words, if the validation requirements are not met, an HTTP error is passed as
* first argument of the callback.
*
* Implementation Notes: the `method` is NOT case sensitive, whereas `url` is.
* The `url` parameter also supports denoting parameters inside it as follows:
*
* "get-from-user": {
* "url": "/users/:owner/gists",
* "method": "GET"
* ...
* }
**/
var Client = module.exports = function (config) {
if (!(this instanceof Client)) {
return new Client(config)
}
config = config || {}
config.headers = config.headers || {}
this.config = config
if ('followRedirects' in config) {
console.warn('DEPRECATED: followRedirects option is no longer supported. All redirects are followed correctly')
}
if ('Promise' in config) {
console.warn('DEPRECATED: Promise option is no longer supported. The native Promise API is used')
}
var pathPrefix = ''
// Check if a prefix is passed in the config and strip any leading or trailing slashes from it.
if (typeof config.pathPrefix === 'string') {
pathPrefix = '/' + config.pathPrefix.replace(/(^[/]+|[/]+$)/g, '')
this.config.pathPrefix = pathPrefix
}
// store mapping of accept header to preview api endpoints
var mediaHash = DEFINITIONS.acceptTree
var mediaTypes = {}
for (var accept in mediaHash) {
for (var route in mediaHash[accept]) {
mediaTypes[mediaHash[accept][route]] = accept
}
}
this.acceptUrls = mediaTypes
this.setupRoutes()
};
(function () {
/**
* Client#setupRoutes() -> null
*
* Configures the routes as defined in routes.json.
*
* [[Client#setupRoutes]] is invoked by the constructor, takes the
* contents of the JSON document that contains the definitions of all the
* available API routes and iterates over them.
*
* It first recurses through each definition block until it reaches an API
* endpoint. It knows that an endpoint is found when the `url` and `param`
* definitions are found as a direct member of a definition block.
* Then the availability of an implementation by the API is checked; if it's
* not present, this means that a portion of the API as defined in the routes.json
* file is not implemented properly, thus an exception is thrown.
* After this check, a method is attached to the [[Client]] instance
* and becomes available for use. Inside this method, the parameter validation
* and typecasting is done, according to the definition of the parameters in
* the `params` block, upon invocation.
*
* This mechanism ensures that the handlers ALWAYS receive normalized data
* that is of the correct format and type. JSON parameters are parsed, Strings
* are trimmed, Numbers and Floats are casted and checked for NaN after that.
*
* Note: Query escaping for usage with SQL products is something that can be
* implemented additionally by adding an additional parameter type.
**/
this.setupRoutes = function () {
var self = this
this.requestHeaders = DEFINITIONS['request-headers'].map(function (header) {
return header.toLowerCase()
})
this.responseHeaders = DEFINITIONS['response-headers'].map(function (header) {
return header.toLowerCase()
})
function parseParams (msg, paramsStruct) {
var params = Object.keys(paramsStruct)
var paramName, def, value, type
for (var i = 0, l = params.length; i < l; ++i) {
paramName = params[i]
if (paramName.charAt(0) === '$') {
paramName = paramName.substr(1)
if (!DEFINITIONS.params[paramName]) {
throw new error.BadRequest("Invalid variable parameter name substitution; param '" +
paramName + "' not found in definitions.json")
} else {
def = paramsStruct[paramName] = DEFINITIONS.params[paramName]
delete paramsStruct['$' + paramName]
}
} else {
def = paramsStruct[paramName]
}
value = msg[paramName]
if (typeof value !== 'boolean' && !value) {
// we don't need validation for undefined parameter values
// that are not required.
if (!def.required ||
(def['allow-empty'] && value === '') ||
(def['allow-null'] && value === null)) {
continue
}
throw new error.BadRequest("Empty value for parameter '" +
paramName + "': " + value)
}
// validate the value and type of parameter:
if (def.validation) {
if (!new RegExp(def.validation).test(value)) {
throw new error.BadRequest("Invalid value for parameter '" +
paramName + "': " + value)
}
}
type = def.type.toLowerCase()
if (type === 'number') {
value = parseInt(value, 10)
if (isNaN(value)) {
throw new error.BadRequest("Invalid value for parameter '" +
paramName + "': " + msg[paramName] + ' is NaN')
}
} else if (type === 'json') {
if (typeof value === 'string') {
try {
value = JSON.parse(value)
} catch (ex) {
throw new error.BadRequest("JSON parse error of value for parameter '" +
paramName + "': " + value)
}
}
} else if (type === 'date') {
value = new Date(value)
}
msg[paramName] = value
}
}
function prepareApi (struct, baseType) {
if (!baseType) {
baseType = ''
}
Object.keys(struct).forEach(function (routePart) {
var block = struct[routePart]
var messageType = baseType + '/' + routePart
if (block.url && block.params) {
// we ended up at an API definition part!
var parts = messageType.split('/')
var section = toCamelCase(parts[1].toLowerCase())
parts.splice(0, 2)
var funcName = toCamelCase(parts.join('-'))
if (!self[section]) {
self[section] = {}
}
self[section][funcName] = function (msg, callback) {
if (block.deprecated) {
const caller = (new Error()).stack.split('\n')[2]
console.warn('DEPRECATED: ' + block.deprecated)
console.warn(caller)
}
try {
parseParams(msg, block.params)
} catch (ex) {
// when the message was sent to the client, we can
// reply with the error directly.
self.sendError(ex, block, msg, callback)
debug('fatal:', ex.message)
if (typeof callback !== 'function') {
return Promise.reject(ex)
}
// on error, there's no need to continue.
return
}
if (callback) {
return self.handler(msg, JSON.parse(JSON.stringify(block)), callback)
}
return new Promise(function (resolve, reject) {
var cb = function (err, obj) {
if (err) {
reject(err)
} else {
resolve(obj)
}
}
self.handler(msg, JSON.parse(JSON.stringify(block)), cb)
})
}
} else {
// recurse into this block next:
prepareApi(block, messageType)
}
})
}
prepareApi(ROUTES)
}
/**
* Client#authenticate(options) -> null
* - options (Object): Object containing the authentication type and credentials
* - type (String): One of the following: `basic`, `oauth`, `token`, or `integration`
* - username (String): Github username
* - password (String): Password to your account
* - token (String): oauth/jwt token
*
* Set an authentication method to have access to protected resources.
*
* ##### Example
*
* // basic
* github.authenticate({
* type: "basic",
* username: "mikedeboertest",
* password: "test1324"
* });
*
* // oauth
* github.authenticate({
* type: "oauth",
* token: "e5a4a27487c26e571892846366de023349321a73"
* });
*
* // oauth key/secret
* github.authenticate({
* type: "oauth",
* key: "clientID",
* secret: "clientSecret"
* });
*
* // user token
* github.authenticate({
* type: "token",
* token: "userToken",
* });
*
* // integration (jwt)
* github.authenticate({
* type: "integration",
* token: "jwt",
* });
**/
this.authenticate = function (options) {
if (!options) {
this.auth = false
return
}
if (!options.type || 'basic|oauth|client|token|integration'.indexOf(options.type) === -1) {
throw new Error("Invalid authentication type, must be 'basic', 'integration', 'oauth', or 'client'")
}
if (options.type === 'basic' && (!options.username || !options.password)) {
throw new Error('Basic authentication requires both a username and password to be set')
}
if (options.type === 'oauth') {
if (!options.token && !(options.key && options.secret)) {
throw new Error('OAuth2 authentication requires a token or key & secret to be set')
}
}
if ((options.type === 'token' || options.type === 'integration') && !options.token) {
throw new Error('Token authentication requires a token to be set')
}
this.auth = options
}
function getPageLinks (link) {
link = link.link || link.meta.link || ''
var links = {}
// link format:
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"'
link.replace(/<([^>]*)>;\s*rel="([\w]*)"/g, function (m, uri, type) {
links[type] = uri
})
return links
}
/**
* Client#hasNextPage(link) -> null
* - link (Object): response of a request
*
* Check if a request result contains a link to the next page
**/
this.hasNextPage = function (link) {
return getPageLinks(link).next
}
/**
* Client#hasPreviousPage(link) -> null
* - link (Object): response of a request
*
* Check if a request result contains a link to the previous page
**/
this.hasPreviousPage = function (link) {
return getPageLinks(link).prev
}
/**
* Client#hasLastPage(link) -> null
* - link (Object): response of a request
*
* Check if a request result contains a link to the last page
**/
this.hasLastPage = function (link) {
return getPageLinks(link).last
}
/**
* Client#hasFirstPage(link) -> null
* - link (Object): response of a request
*
* Check if a request result contains a link to the first page
**/
this.hasFirstPage = function (link) {
return getPageLinks(link).first
}
function getPage (link, which, headers, callback) {
if (typeof headers === 'function') {
callback = headers
headers = null
}
headers = applyAcceptHeader(link, headers)
var self = this
var url = getPageLinks(link)[which]
if (!url) {
var urlErr = new error.NotFound('No ' + which + ' page found')
if (callback) {
return callback(urlErr)
}
return Promise.reject(urlErr)
}
var parsedUrl = Url.parse(url, true)
var msg = Object.create(parsedUrl.query)
msg.headers = headers
var block = {
url: parsedUrl.pathname,
method: 'GET',
params: parsedUrl.query
}
if (callback) {
return self.handler(msg, JSON.parse(JSON.stringify(block)), callback)
}
return new Promise(function (resolve, reject) {
var cb = function (err, obj) {
if (err) {
reject(err)
} else {
resolve(obj)
}
}
self.handler(msg, JSON.parse(JSON.stringify(block)), cb)
})
}
/**
* Client#getNextPage(link, callback) -> null
* - link (Object): response of a request
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request.
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
*
* Get the next page, based on the contents of the `Link` header
**/
this.getNextPage = function (link, headers, callback) {
return getPage.call(this, link, 'next', headers, callback)
}
/**
* Client#getPreviousPage(link, callback) -> null
* - link (Object): response of a request
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request.
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
*
* Get the previous page, based on the contents of the `Link` header
**/
this.getPreviousPage = function (link, headers, callback) {
return getPage.call(this, link, 'prev', headers, callback)
}
/**
* Client#getLastPage(link, callback) -> null
* - link (Object): response of a request
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request.
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
*
* Get the last page, based on the contents of the `Link` header
**/
this.getLastPage = function (link, headers, callback) {
return getPage.call(this, link, 'last', headers, callback)
}
/**
* Client#getFirstPage(link, callback) -> null
* - link (Object): response of a request
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request.
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
*
* Get the first page, based on the contents of the `Link` header
**/
this.getFirstPage = function (link, headers, callback) {
return getPage.call(this, link, 'first', headers, callback)
}
function applyAcceptHeader (res, headers) {
var previous = res.meta && res.meta['x-github-media-type']
if (!previous || (headers && headers.accept)) {
return headers
}
headers = headers || {}
headers.accept = 'application/vnd.' + previous.replace('; format=', '+')
return headers
}
function getRequestFormat (hasBody, block) {
if (hasBody) {
return block.requestFormat || DEFINITIONS.constants.requestFormat
}
return 'query'
}
function getQueryAndUrl (msg, def, format, config) {
var url = def.url
if (msg.url) {
url = Url.parse(urlTemplate.parse(msg.url).expand(msg), true)
return {
url: url.path,
host: url.host
}
}
if (config.pathPrefix && url.indexOf(config.pathPrefix) !== 0) {
url = config.pathPrefix + def.url
}
var ret = {}
Object.keys(def.params).forEach(function (paramName) {
paramName = paramName.replace(/^[$]+/, '')
if (!(paramName in msg)) {
return
}
var isUrlParam = url.indexOf(':' + paramName) !== -1
var valFormat = isUrlParam || format !== 'json' ? 'query' : format
var val
if (valFormat === 'json') {
val = msg[paramName]
} else {
if (def.params[paramName] && def.params[paramName].combined) {
// Check if this is a combined (search) string.
val = msg[paramName].split(/[\s\t\r\n]*\+[\s\t\r\n]*/)
.map(function (part) {
return encodeURIComponent(part)
})
.join('+')
} else {
// the ref param is a path so we don't want to [fully] encode it but we do want to encode the # if there is one
// (see https://github.com/mikedeboer/node-github/issues/499#issuecomment-280093040)
if (paramName === 'ref') {
val = msg[paramName].replace(/#/g, '%23')
} else {
val = encodeURIComponent(msg[paramName])
}
}
}
if (isUrlParam) {
url = url.replace(':' + paramName, val)
} else {
if (format === 'json' && def.params[paramName].sendValueAsBody) {
ret.query = val
} else if (format === 'json') {
if (!ret.query) {
ret.query = {}
}
ret.query[paramName] = val
} else if (format !== 'raw') {
if (!ret.query) {
ret.query = []
}
ret.query.push(paramName + '=' + val)
}
}
})
ret.url = url
return ret
}
/**
* Client#httpSend(msg, block, callback) -> null
* - msg (Object): parameters to send as the request body
* - block (Object): parameter definition from the `routes.json` file that
* contains validation rules
* - callback (Function): function to be called when the request returns.
* If the the request returns with an error, the error is passed to
* the callback as its first argument (NodeJS-style).
*
* Send an HTTP request to the server and pass the result to a callback.
**/
this.httpSend = function (msg, block, callback) {
var self = this
var method = block.method.toLowerCase()
var hasFileBody = block.hasFileBody
var hasBody = typeof (msg.body) !== 'undefined' || 'head|get|delete'.indexOf(method) === -1
var format = getRequestFormat.call(this, hasBody, block)
var protocol = this.config.protocol || DEFINITIONS.constants.protocol
var port = this.config.port || (protocol === 'https' ? 443 : 80)
var host = this.config.host || DEFINITIONS.constants.host
var queryAndUrl = getQueryAndUrl(msg, block, format, self.config)
var query = queryAndUrl.query
var url = queryAndUrl.url
var path = url
if (!hasBody && query && query.length) {
path += '?' + query.join('&')
}
var proxyUrl
var agent
// proxy options will be removed: https://github.com/octokit/node-github/issues/656
/* istanbul ignore if */
if (this.config.proxy !== undefined) {
proxyUrl = this.config.proxy
} else {
proxyUrl = getProxyForUrl(url)
}
// proxy options will be removed: https://github.com/octokit/node-github/issues/656
/* istanbul ignore if */
if (proxyUrl) {
agent = new HttpsProxyAgent(proxyUrl)
}
var ca = this.config.ca
var headers = {}
if (hasFileBody) {
headers['content-length'] = msg.contentLength
headers['content-type'] = msg.contentType
delete msg.contentLength
delete msg.contentType
} else if (hasBody) {
if (format === 'raw') {
query = msg.data
} else {
query = JSON.stringify(query)
}
headers['content-length'] = Buffer.byteLength(query || '', 'utf8')
headers['content-type'] = format === 'raw'
? 'text/plain; charset=utf-8'
: 'application/json; charset=utf-8'
}
if (this.auth) {
var basic
switch (this.auth.type) {
case 'oauth':
if (this.auth.token) {
path += (path.indexOf('?') === -1 ? '?' : '&') +
'access_token=' + encodeURIComponent(this.auth.token)
} else {
path += (path.indexOf('?') === -1 ? '?' : '&') +
'client_id=' + encodeURIComponent(this.auth.key) +
'&client_secret=' + encodeURIComponent(this.auth.secret)
}
break
case 'token':
headers['Authorization'] = 'token ' + this.auth.token
break
case 'integration':
headers['Authorization'] = 'Bearer ' + this.auth.token
headers['accept'] = 'application/vnd.github.machine-man-preview+json'
break
case 'basic':
basic = Buffer.from(this.auth.username + ':' + this.auth.password, 'ascii').toString('base64')
headers['Authorization'] = 'Basic ' + basic
break
}
}
function callCallback (err, result) {
if (callback) {
var cb = callback
callback = undefined
cb(err, result)
}
}
function addCustomHeaders (customHeaders) {
Object.keys(customHeaders).forEach(function (header) {
var headerLC = header.toLowerCase()
if (self.requestHeaders.indexOf(headerLC) === -1) {
return
}
headers[headerLC] = customHeaders[header]
})
}
addCustomHeaders(Object.assign(msg.headers || {}, this.config.headers))
if (!headers['user-agent']) {
headers['user-agent'] = 'NodeJS HTTP Client'
}
if (!('accept' in headers)) {
headers['accept'] = this.acceptUrls[block.url] || this.config.requestMedia || DEFINITIONS.constants.requestMedia
}
headers.host = queryAndUrl.host || host
var options = {
agent: agent,
host: headers.host,
port: port,
path: path,
method: method,
headers: headers,
ca: ca,
family: this.config.family,
rejectUnauthorized: this.config.rejectUnauthorized
}
debug('REQUEST:', options)
function httpSendRequest () {
var reqModule = protocol === 'http' ? require('http') : require('https')
var req = reqModule.request(options, function (res) {
debug('STATUS: ' + res.statusCode)
debug('HEADERS: ' + JSON.stringify(res.headers))
res.setEncoding('utf8')
var data = ''
res.on('data', function (chunk) {
data += chunk
})
/* istanbul ignore next */
res.on('error', function (err) {
callCallback(err)
})
res.on('end', function () {
if (res.statusCode >= 301 && res.statusCode <= 307) {
options.path = Url.parse(res.headers.location, true).path
httpSendRequest()
return
}
if (res.statusCode >= 400 || res.statusCode < 10) {
callCallback(new error.HttpError(data, res.statusCode, res.headers))
} else {
res.data = data
callCallback(null, res)
}
})
})
var timeout = (block.timeout !== undefined) ? block.timeout : self.config.timeout
if (timeout) {
req.setTimeout(timeout)
}
req.on('error', function (e) {
debug('problem with request: ' + e.message)
callCallback(e.message)
})
req.on('timeout', function () {
debug('problem with request: timed out')
req.abort()
callCallback(new error.GatewayTimeout('Request timeout'))
})
// write data to request body
if (hasBody && query && query.length) {
debug('REQUEST BODY: ' + query + '\n')
req.write(query + '\n')
}
if (hasFileBody) {
req.write(Buffer.from(msg.file))
}
req.end()
};
httpSendRequest()
}
this.sendError = function (err, block, msg, callback) {
debug('error:', err, block, msg)
if (typeof err === 'string') {
err = new error.InternalServerError(err)
}
if (callback && typeof (callback) === 'function') {
callback(err)
}
}
this.handler = function (msg, block, callback) {
var self = this
this.httpSend(msg, block, function (err, res) {
if (err) {
return self.sendError(err, msg, null, callback)
}
var data = res.data
var contentType = res.headers['content-type']
if (contentType && contentType.indexOf('application/json') !== -1) {
data = res.data && JSON.parse(res.data)
}
var ret = {
data: data,
meta: {}
}
self.responseHeaders.forEach(function (header) {
if (res.headers[header]) {
ret.meta[header] = res.headers[header]
}
})
callback(null, ret)
})
}
}).call(Client.prototype)

3238
build/node_modules/github/lib/index.js.flow generated vendored Normal file

File diff suppressed because it is too large Load Diff

7412
build/node_modules/github/lib/routes.json generated vendored Normal file

File diff suppressed because it is too large Load Diff