diff --git a/dist/index.js b/dist/index.js index f62ea44ee..64a2c174a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1909,56 +1909,43 @@ var request = __webpack_require__(234); var graphql = __webpack_require__(668); var authToken = __webpack_require__(334); -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; } - return obj; + return target; } -function ownKeys(object, enumerableOnly) { - var keys = Object.keys(object); +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; - if (Object.getOwnPropertySymbols) { - var symbols = Object.getOwnPropertySymbols(object); - if (enumerableOnly) symbols = symbols.filter(function (sym) { - return Object.getOwnPropertyDescriptor(object, sym).enumerable; - }); - keys.push.apply(keys, symbols); - } + var target = _objectWithoutPropertiesLoose(source, excluded); - return keys; -} + var key, i; -function _objectSpread2(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? arguments[i] : {}; + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); - if (i % 2) { - ownKeys(Object(source), true).forEach(function (key) { - _defineProperty(target, key, source[key]); - }); - } else if (Object.getOwnPropertyDescriptors) { - Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); - } else { - ownKeys(Object(source)).forEach(function (key) { - Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); - }); + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; } } return target; } -const VERSION = "3.1.2"; +const VERSION = "3.2.1"; class Octokit { constructor(options = {}) { @@ -1990,9 +1977,7 @@ class Octokit { } this.request = request.request.defaults(requestDefaults); - this.graphql = graphql.withCustomRequest(this.request).defaults(_objectSpread2(_objectSpread2({}, requestDefaults), {}, { - baseUrl: requestDefaults.baseUrl.replace(/\/api\/v3$/, "/api") - })); + this.graphql = graphql.withCustomRequest(this.request).defaults(requestDefaults); this.log = Object.assign({ debug: () => {}, info: () => {}, @@ -2000,7 +1985,7 @@ class Octokit { error: console.error.bind(console) }, options.log); this.hook = hook; // (1) If neither `options.authStrategy` nor `options.auth` are set, the `octokit` instance - // is unauthenticated. The `this.auth()` method is a no-op and no request hook is registred. + // is unauthenticated. The `this.auth()` method is a no-op and no request hook is registered. // (2) If only `options.auth` is set, use the default token authentication strategy. // (3) If `options.authStrategy` is set then use it and pass in `options.auth`. Always pass own request as many strategies accept a custom request instance. // TODO: type `options.auth` based on `options.authStrategy`. @@ -2019,8 +2004,21 @@ class Octokit { this.auth = auth; } } else { - const auth = options.authStrategy(Object.assign({ - request: this.request + const { + authStrategy + } = options, + otherOptions = _objectWithoutProperties(options, ["authStrategy"]); + + const auth = authStrategy(Object.assign({ + request: this.request, + log: this.log, + // we pass the current octokit instance as well as its constructor options + // to allow for authentication strategies that return a new octokit instance + // that shares the same internal state as the current one. The original + // requirement for this was the "event-octokit" authentication strategy + // of https://github.com/probot/octokit-auth-probot. + octokit: this, + octokitOptions: otherOptions }, options.auth)); // @ts-ignore ¯\_(ツ)_/¯ hook.wrap("request", auth.hook); @@ -2117,6 +2115,16 @@ function mergeDeep(defaults, options) { return result; } +function removeUndefinedProperties(obj) { + for (const key in obj) { + if (obj[key] === undefined) { + delete obj[key]; + } + } + + return obj; +} + function merge(defaults, route, options) { if (typeof route === "string") { let [method, url] = route.split(" "); @@ -2131,7 +2139,10 @@ function merge(defaults, route, options) { } // lowercase header names before merging with defaults to avoid duplicates - options.headers = lowercaseKeys(options.headers); + options.headers = lowercaseKeys(options.headers); // remove properties with undefined values before merging + + removeUndefinedProperties(options); + removeUndefinedProperties(options.headers); const mergedOptions = mergeDeep(defaults || {}, options); // mediaType.previews arrays are merged, instead of overwritten if (defaults && defaults.mediaType.previews.length) { @@ -2353,7 +2364,7 @@ function parse(options) { // https://fetch.spec.whatwg.org/#methods let method = options.method.toUpperCase(); // replace :varname with {varname} to make it RFC 6570 compatible - let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{+$1}"); + let url = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}"); let headers = Object.assign({}, options.headers); let body; let parameters = omit(options, ["method", "baseUrl", "url", "headers", "request", "mediaType"]); // extract variable names from URL to calculate remaining variables later @@ -2438,7 +2449,7 @@ function withDefaults(oldDefaults, newDefaults) { }); } -const VERSION = "6.0.6"; +const VERSION = "6.0.9"; const userAgent = `octokit-endpoint.js/${VERSION} ${universalUserAgent.getUserAgent()}`; // DEFAULTS has all properties set that EndpointOptions has, except url. // So we use RequestParameters and add method as additional required property. @@ -2475,7 +2486,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); var request = __webpack_require__(234); var universalUserAgent = __webpack_require__(429); -const VERSION = "4.5.6"; +const VERSION = "4.5.7"; class GraphqlError extends Error { constructor(request, response) { @@ -2588,7 +2599,7 @@ exports.withCustomRequest = withCustomRequest; Object.defineProperty(exports, "__esModule", ({ value: true })); -const VERSION = "2.4.0"; +const VERSION = "2.6.0"; /** * Some “list” response that can be paginated have a different response structure @@ -2641,26 +2652,23 @@ function iterator(octokit, route, parameters) { let url = options.url; return { [Symbol.asyncIterator]: () => ({ - next() { - if (!url) { - return Promise.resolve({ - done: true - }); - } - - return requestMethod({ + async next() { + if (!url) return { + done: true + }; + const response = await requestMethod({ method, url, headers - }).then(normalizePaginatedListResponse).then(response => { - // `response.headers.link` format: - // '; rel="next", ; 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 - }; }); + const normalizedResponse = normalizePaginatedListResponse(response); // `response.headers.link` format: + // '; rel="next", ; rel="last"' + // sets `url` to undefined if "next" URL is not present or `link` header is not set + + url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; + return { + value: normalizedResponse + }; } }) @@ -2698,6 +2706,10 @@ function gather(octokit, results, iterator, mapFn) { }); } +const composePaginateRest = Object.assign(paginate, { + iterator +}); + /** * @param octokit Octokit instance * @param options Options passed to Octokit constructor @@ -2712,6 +2724,7 @@ function paginateRest(octokit) { } paginateRest.VERSION = VERSION; +exports.composePaginateRest = composePaginateRest; exports.paginateRest = paginateRest; //# sourceMappingURL=index.js.map @@ -3775,7 +3788,7 @@ const Endpoints = { } }; -const VERSION = "4.2.0"; +const VERSION = "4.2.1"; function endpointsToMethods(octokit, endpointsMap) { const newMethods = {}; @@ -3959,7 +3972,7 @@ var isPlainObject = __webpack_require__(287); var nodeFetch = _interopDefault(__webpack_require__(467)); var requestError = __webpack_require__(537); -const VERSION = "5.4.9"; +const VERSION = "5.4.10"; function getBufferResponse(response) { return response.arrayBuffer(); @@ -6413,7 +6426,7 @@ module.exports = eval("require")("encoding"); /***/ ((module) => { "use strict"; -module.exports = require("assert"); +module.exports = require("assert");; /***/ }), @@ -6421,7 +6434,7 @@ module.exports = require("assert"); /***/ ((module) => { "use strict"; -module.exports = require("events"); +module.exports = require("events");; /***/ }), @@ -6429,7 +6442,7 @@ module.exports = require("events"); /***/ ((module) => { "use strict"; -module.exports = require("fs"); +module.exports = require("fs");; /***/ }), @@ -6437,7 +6450,7 @@ module.exports = require("fs"); /***/ ((module) => { "use strict"; -module.exports = require("http"); +module.exports = require("http");; /***/ }), @@ -6445,7 +6458,7 @@ module.exports = require("http"); /***/ ((module) => { "use strict"; -module.exports = require("https"); +module.exports = require("https");; /***/ }), @@ -6453,7 +6466,7 @@ module.exports = require("https"); /***/ ((module) => { "use strict"; -module.exports = require("net"); +module.exports = require("net");; /***/ }), @@ -6461,7 +6474,7 @@ module.exports = require("net"); /***/ ((module) => { "use strict"; -module.exports = require("os"); +module.exports = require("os");; /***/ }), @@ -6469,7 +6482,7 @@ module.exports = require("os"); /***/ ((module) => { "use strict"; -module.exports = require("path"); +module.exports = require("path");; /***/ }), @@ -6477,7 +6490,7 @@ module.exports = require("path"); /***/ ((module) => { "use strict"; -module.exports = require("stream"); +module.exports = require("stream");; /***/ }), @@ -6485,7 +6498,7 @@ module.exports = require("stream"); /***/ ((module) => { "use strict"; -module.exports = require("tls"); +module.exports = require("tls");; /***/ }), @@ -6493,7 +6506,7 @@ module.exports = require("tls"); /***/ ((module) => { "use strict"; -module.exports = require("url"); +module.exports = require("url");; /***/ }), @@ -6501,7 +6514,7 @@ module.exports = require("url"); /***/ ((module) => { "use strict"; -module.exports = require("util"); +module.exports = require("util");; /***/ }), @@ -6509,7 +6522,7 @@ module.exports = require("util"); /***/ ((module) => { "use strict"; -module.exports = require("zlib"); +module.exports = require("zlib");; /***/ })