@octokit/endpoint
Advanced tools
Comparing version
@@ -1,8 +0,28 @@ | ||
'use strict'; | ||
"use strict"; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
// pkg/dist-src/index.js | ||
var dist_src_exports = {}; | ||
__export(dist_src_exports, { | ||
endpoint: () => endpoint | ||
}); | ||
module.exports = __toCommonJS(dist_src_exports); | ||
var isPlainObject = require('is-plain-object'); | ||
var universalUserAgent = require('universal-user-agent'); | ||
// pkg/dist-src/util/lowercase-keys.js | ||
function lowercaseKeys(object) { | ||
@@ -18,13 +38,14 @@ if (!object) { | ||
// pkg/dist-src/util/merge-deep.js | ||
var import_is_plain_object = require("is-plain-object"); | ||
function mergeDeep(defaults, options) { | ||
const result = Object.assign({}, defaults); | ||
Object.keys(options).forEach(key => { | ||
if (isPlainObject.isPlainObject(options[key])) { | ||
if (!(key in defaults)) Object.assign(result, { | ||
[key]: options[key] | ||
});else result[key] = mergeDeep(defaults[key], options[key]); | ||
Object.keys(options).forEach((key) => { | ||
if ((0, import_is_plain_object.isPlainObject)(options[key])) { | ||
if (!(key in defaults)) | ||
Object.assign(result, { [key]: options[key] }); | ||
else | ||
result[key] = mergeDeep(defaults[key], options[key]); | ||
} else { | ||
Object.assign(result, { | ||
[key]: options[key] | ||
}); | ||
Object.assign(result, { [key]: options[key] }); | ||
} | ||
@@ -35,5 +56,6 @@ }); | ||
// pkg/dist-src/util/remove-undefined-properties.js | ||
function removeUndefinedProperties(obj) { | ||
for (const key in obj) { | ||
if (obj[key] === undefined) { | ||
if (obj[key] === void 0) { | ||
delete obj[key]; | ||
@@ -45,28 +67,24 @@ } | ||
// pkg/dist-src/merge.js | ||
function merge(defaults, route, options) { | ||
if (typeof route === "string") { | ||
let [method, url] = route.split(" "); | ||
options = Object.assign(url ? { | ||
method, | ||
url | ||
} : { | ||
url: method | ||
}, options); | ||
options = Object.assign(url ? { method, url } : { url: method }, options); | ||
} else { | ||
options = Object.assign({}, route); | ||
} | ||
// lowercase header names before merging with defaults to avoid duplicates | ||
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) { | ||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter(preview => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); | ||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); | ||
} | ||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map(preview => preview.replace(/-preview/, "")); | ||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map( | ||
(preview) => preview.replace(/-preview/, "") | ||
); | ||
return mergedOptions; | ||
} | ||
// pkg/dist-src/util/add-query-parameters.js | ||
function addQueryParameters(url, parameters) { | ||
@@ -78,3 +96,3 @@ const separator = /\?/.test(url) ? "&" : "?"; | ||
} | ||
return url + separator + names.map(name => { | ||
return url + separator + names.map((name) => { | ||
if (name === "q") { | ||
@@ -87,3 +105,4 @@ return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); | ||
const urlVariableRegex = /\{[^}]+\}/g; | ||
// pkg/dist-src/util/extract-url-variable-names.js | ||
var urlVariableRegex = /\{[^}]+\}/g; | ||
function removeNonChars(variableName) { | ||
@@ -100,4 +119,5 @@ return variableName.replace(/^\W+|\W+$/g, "").split(/,/); | ||
// pkg/dist-src/util/omit.js | ||
function omit(object, keysToOmit) { | ||
return Object.keys(object).filter(option => !keysToOmit.includes(option)).reduce((obj, key) => { | ||
return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => { | ||
obj[key] = object[key]; | ||
@@ -108,30 +128,5 @@ return obj; | ||
// Based on https://github.com/bramstein/url-template, licensed under BSD | ||
// TODO: create separate package. | ||
// | ||
// Copyright (c) 2012-2014, Bram Stein | ||
// All rights reserved. | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions | ||
// are met: | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// 3. The name of the author may not be used to endorse or promote products | ||
// derived from this software without specific prior written permission. | ||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED | ||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
/* istanbul ignore file */ | ||
// pkg/dist-src/util/url-template.js | ||
function encodeReserved(str) { | ||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) { | ||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) { | ||
if (!/%[0-9A-Fa-f]/.test(part)) { | ||
@@ -144,3 +139,3 @@ part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); | ||
function encodeUnreserved(str) { | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { | ||
return "%" + c.charCodeAt(0).toString(16).toUpperCase(); | ||
@@ -158,3 +153,3 @@ }); | ||
function isDefined(value) { | ||
return value !== undefined && value !== null; | ||
return value !== void 0 && value !== null; | ||
} | ||
@@ -165,4 +160,3 @@ function isKeyOperator(operator) { | ||
function getValues(context, operator, key, modifier) { | ||
var value = context[key], | ||
result = []; | ||
var value = context[key], result = []; | ||
if (isDefined(value) && value !== "") { | ||
@@ -174,11 +168,15 @@ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { | ||
} | ||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); | ||
result.push( | ||
encodeValue(operator, value, isKeyOperator(operator) ? key : "") | ||
); | ||
} else { | ||
if (modifier === "*") { | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function (value) { | ||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); | ||
value.filter(isDefined).forEach(function(value2) { | ||
result.push( | ||
encodeValue(operator, value2, isKeyOperator(operator) ? key : "") | ||
); | ||
}); | ||
} else { | ||
Object.keys(value).forEach(function (k) { | ||
Object.keys(value).forEach(function(k) { | ||
if (isDefined(value[k])) { | ||
@@ -192,7 +190,7 @@ result.push(encodeValue(operator, value[k], k)); | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function (value) { | ||
tmp.push(encodeValue(operator, value)); | ||
value.filter(isDefined).forEach(function(value2) { | ||
tmp.push(encodeValue(operator, value2)); | ||
}); | ||
} else { | ||
Object.keys(value).forEach(function (k) { | ||
Object.keys(value).forEach(function(k) { | ||
if (isDefined(value[k])) { | ||
@@ -231,40 +229,48 @@ tmp.push(encodeUnreserved(k)); | ||
var operators = ["+", "#", ".", "/", ";", "?", "&"]; | ||
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { | ||
if (expression) { | ||
let operator = ""; | ||
const values = []; | ||
if (operators.indexOf(expression.charAt(0)) !== -1) { | ||
operator = expression.charAt(0); | ||
expression = expression.substr(1); | ||
} | ||
expression.split(/,/g).forEach(function (variable) { | ||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); | ||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); | ||
}); | ||
if (operator && operator !== "+") { | ||
var separator = ","; | ||
if (operator === "?") { | ||
separator = "&"; | ||
} else if (operator !== "#") { | ||
separator = operator; | ||
return template.replace( | ||
/\{([^\{\}]+)\}|([^\{\}]+)/g, | ||
function(_, expression, literal) { | ||
if (expression) { | ||
let operator = ""; | ||
const values = []; | ||
if (operators.indexOf(expression.charAt(0)) !== -1) { | ||
operator = expression.charAt(0); | ||
expression = expression.substr(1); | ||
} | ||
return (values.length !== 0 ? operator : "") + values.join(separator); | ||
expression.split(/,/g).forEach(function(variable) { | ||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); | ||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); | ||
}); | ||
if (operator && operator !== "+") { | ||
var separator = ","; | ||
if (operator === "?") { | ||
separator = "&"; | ||
} else if (operator !== "#") { | ||
separator = operator; | ||
} | ||
return (values.length !== 0 ? operator : "") + values.join(separator); | ||
} else { | ||
return values.join(","); | ||
} | ||
} else { | ||
return values.join(","); | ||
return encodeReserved(literal); | ||
} | ||
} else { | ||
return encodeReserved(literal); | ||
} | ||
}); | ||
); | ||
} | ||
// pkg/dist-src/parse.js | ||
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 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 | ||
let parameters = omit(options, [ | ||
"method", | ||
"baseUrl", | ||
"url", | ||
"headers", | ||
"request", | ||
"mediaType" | ||
]); | ||
const urlVariableNames = extractUrlVariableNames(url); | ||
@@ -275,3 +281,3 @@ url = parseUrl(url).expand(parameters); | ||
} | ||
const omittedParameters = Object.keys(options).filter(option => urlVariableNames.includes(option)).concat("baseUrl"); | ||
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl"); | ||
const remainingParameters = omit(parameters, omittedParameters); | ||
@@ -281,8 +287,12 @@ const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); | ||
if (options.mediaType.format) { | ||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw | ||
headers.accept = headers.accept.split(/,/).map(preview => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(","); | ||
headers.accept = headers.accept.split(/,/).map( | ||
(preview) => preview.replace( | ||
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, | ||
`application/vnd$1$2.${options.mediaType.format}` | ||
) | ||
).join(","); | ||
} | ||
if (options.mediaType.previews.length) { | ||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; | ||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map(preview => { | ||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => { | ||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json"; | ||
@@ -293,4 +303,2 @@ return `application/vnd.github.${preview}-preview${format}`; | ||
} | ||
// for GET/HEAD requests, set URL query parameters from remaining parameters | ||
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters | ||
if (["GET", "HEAD"].includes(method)) { | ||
@@ -307,23 +315,16 @@ url = addQueryParameters(url, remainingParameters); | ||
} | ||
// default content-type for JSON if body is set | ||
if (!headers["content-type"] && typeof body !== "undefined") { | ||
headers["content-type"] = "application/json; charset=utf-8"; | ||
} | ||
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. | ||
// fetch does not allow to set `content-length` header, but we can set body to an empty string | ||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { | ||
body = ""; | ||
} | ||
// Only return body/request keys if present | ||
return Object.assign({ | ||
method, | ||
url, | ||
headers | ||
}, typeof body !== "undefined" ? { | ||
body | ||
} : null, options.request ? { | ||
request: options.request | ||
} : null); | ||
return Object.assign( | ||
{ method, url, headers }, | ||
typeof body !== "undefined" ? { body } : null, | ||
options.request ? { request: options.request } : null | ||
); | ||
} | ||
// pkg/dist-src/endpoint-with-defaults.js | ||
function endpointWithDefaults(defaults, route, options) { | ||
@@ -333,9 +334,10 @@ return parse(merge(defaults, route, options)); | ||
// pkg/dist-src/with-defaults.js | ||
function withDefaults(oldDefaults, newDefaults) { | ||
const DEFAULTS = merge(oldDefaults, newDefaults); | ||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS); | ||
return Object.assign(endpoint, { | ||
DEFAULTS, | ||
defaults: withDefaults.bind(null, DEFAULTS), | ||
merge: merge.bind(null, DEFAULTS), | ||
const DEFAULTS2 = merge(oldDefaults, newDefaults); | ||
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2); | ||
return Object.assign(endpoint2, { | ||
DEFAULTS: DEFAULTS2, | ||
defaults: withDefaults.bind(null, DEFAULTS2), | ||
merge: merge.bind(null, DEFAULTS2), | ||
parse | ||
@@ -345,8 +347,11 @@ }); | ||
const VERSION = "7.0.5"; | ||
// pkg/dist-src/defaults.js | ||
var import_universal_user_agent = require("universal-user-agent"); | ||
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. | ||
const DEFAULTS = { | ||
// pkg/dist-src/version.js | ||
var VERSION = "7.0.6"; | ||
// pkg/dist-src/defaults.js | ||
var userAgent = `octokit-endpoint.js/${VERSION} ${(0, import_universal_user_agent.getUserAgent)()}`; | ||
var DEFAULTS = { | ||
method: "GET", | ||
@@ -364,5 +369,7 @@ baseUrl: "https://api.github.com", | ||
const endpoint = withDefaults(null, DEFAULTS); | ||
exports.endpoint = endpoint; | ||
//# sourceMappingURL=index.js.map | ||
// pkg/dist-src/index.js | ||
var endpoint = withDefaults(null, DEFAULTS); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
endpoint | ||
}); |
import { getUserAgent } from "universal-user-agent"; | ||
import { VERSION } from "./version"; | ||
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`; | ||
// DEFAULTS has all properties set that EndpointOptions has, except url. | ||
// So we use RequestParameters and add method as additional required property. | ||
export const DEFAULTS = { | ||
method: "GET", | ||
baseUrl: "https://api.github.com", | ||
headers: { | ||
accept: "application/vnd.github.v3+json", | ||
"user-agent": userAgent, | ||
}, | ||
mediaType: { | ||
format: "", | ||
previews: [], | ||
}, | ||
const DEFAULTS = { | ||
method: "GET", | ||
baseUrl: "https://api.github.com", | ||
headers: { | ||
accept: "application/vnd.github.v3+json", | ||
"user-agent": userAgent | ||
}, | ||
mediaType: { | ||
format: "", | ||
previews: [] | ||
} | ||
}; | ||
export { | ||
DEFAULTS | ||
}; |
import { merge } from "./merge"; | ||
import { parse } from "./parse"; | ||
export function endpointWithDefaults(defaults, route, options) { | ||
return parse(merge(defaults, route, options)); | ||
function endpointWithDefaults(defaults, route, options) { | ||
return parse(merge(defaults, route, options)); | ||
} | ||
export { | ||
endpointWithDefaults | ||
}; |
import { withDefaults } from "./with-defaults"; | ||
import { DEFAULTS } from "./defaults"; | ||
export const endpoint = withDefaults(null, DEFAULTS); | ||
const endpoint = withDefaults(null, DEFAULTS); | ||
export { | ||
endpoint | ||
}; |
import { lowercaseKeys } from "./util/lowercase-keys"; | ||
import { mergeDeep } from "./util/merge-deep"; | ||
import { removeUndefinedProperties } from "./util/remove-undefined-properties"; | ||
export function merge(defaults, route, options) { | ||
if (typeof route === "string") { | ||
let [method, url] = route.split(" "); | ||
options = Object.assign(url ? { method, url } : { url: method }, options); | ||
} | ||
else { | ||
options = Object.assign({}, route); | ||
} | ||
// lowercase header names before merging with defaults to avoid duplicates | ||
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) { | ||
mergedOptions.mediaType.previews = defaults.mediaType.previews | ||
.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)) | ||
.concat(mergedOptions.mediaType.previews); | ||
} | ||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, "")); | ||
return mergedOptions; | ||
function merge(defaults, route, options) { | ||
if (typeof route === "string") { | ||
let [method, url] = route.split(" "); | ||
options = Object.assign(url ? { method, url } : { url: method }, options); | ||
} else { | ||
options = Object.assign({}, route); | ||
} | ||
options.headers = lowercaseKeys(options.headers); | ||
removeUndefinedProperties(options); | ||
removeUndefinedProperties(options.headers); | ||
const mergedOptions = mergeDeep(defaults || {}, options); | ||
if (defaults && defaults.mediaType.previews.length) { | ||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); | ||
} | ||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map( | ||
(preview) => preview.replace(/-preview/, "") | ||
); | ||
return mergedOptions; | ||
} | ||
export { | ||
merge | ||
}; |
@@ -5,75 +5,65 @@ import { addQueryParameters } from "./util/add-query-parameters"; | ||
import { parseUrl } from "./util/url-template"; | ||
export 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 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 | ||
const urlVariableNames = extractUrlVariableNames(url); | ||
url = parseUrl(url).expand(parameters); | ||
if (!/^http/.test(url)) { | ||
url = options.baseUrl + url; | ||
function parse(options) { | ||
let method = options.method.toUpperCase(); | ||
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" | ||
]); | ||
const urlVariableNames = extractUrlVariableNames(url); | ||
url = parseUrl(url).expand(parameters); | ||
if (!/^http/.test(url)) { | ||
url = options.baseUrl + url; | ||
} | ||
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl"); | ||
const remainingParameters = omit(parameters, omittedParameters); | ||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); | ||
if (!isBinaryRequest) { | ||
if (options.mediaType.format) { | ||
headers.accept = headers.accept.split(/,/).map( | ||
(preview) => preview.replace( | ||
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, | ||
`application/vnd$1$2.${options.mediaType.format}` | ||
) | ||
).join(","); | ||
} | ||
const omittedParameters = Object.keys(options) | ||
.filter((option) => urlVariableNames.includes(option)) | ||
.concat("baseUrl"); | ||
const remainingParameters = omit(parameters, omittedParameters); | ||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); | ||
if (!isBinaryRequest) { | ||
if (options.mediaType.format) { | ||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw | ||
headers.accept = headers.accept | ||
.split(/,/) | ||
.map((preview) => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)) | ||
.join(","); | ||
} | ||
if (options.mediaType.previews.length) { | ||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; | ||
headers.accept = previewsFromAcceptHeader | ||
.concat(options.mediaType.previews) | ||
.map((preview) => { | ||
const format = options.mediaType.format | ||
? `.${options.mediaType.format}` | ||
: "+json"; | ||
return `application/vnd.github.${preview}-preview${format}`; | ||
}) | ||
.join(","); | ||
} | ||
if (options.mediaType.previews.length) { | ||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; | ||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => { | ||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json"; | ||
return `application/vnd.github.${preview}-preview${format}`; | ||
}).join(","); | ||
} | ||
// for GET/HEAD requests, set URL query parameters from remaining parameters | ||
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters | ||
if (["GET", "HEAD"].includes(method)) { | ||
url = addQueryParameters(url, remainingParameters); | ||
} | ||
if (["GET", "HEAD"].includes(method)) { | ||
url = addQueryParameters(url, remainingParameters); | ||
} else { | ||
if ("data" in remainingParameters) { | ||
body = remainingParameters.data; | ||
} else { | ||
if (Object.keys(remainingParameters).length) { | ||
body = remainingParameters; | ||
} | ||
} | ||
else { | ||
if ("data" in remainingParameters) { | ||
body = remainingParameters.data; | ||
} | ||
else { | ||
if (Object.keys(remainingParameters).length) { | ||
body = remainingParameters; | ||
} | ||
} | ||
} | ||
// default content-type for JSON if body is set | ||
if (!headers["content-type"] && typeof body !== "undefined") { | ||
headers["content-type"] = "application/json; charset=utf-8"; | ||
} | ||
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. | ||
// fetch does not allow to set `content-length` header, but we can set body to an empty string | ||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { | ||
body = ""; | ||
} | ||
// Only return body/request keys if present | ||
return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null); | ||
} | ||
if (!headers["content-type"] && typeof body !== "undefined") { | ||
headers["content-type"] = "application/json; charset=utf-8"; | ||
} | ||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { | ||
body = ""; | ||
} | ||
return Object.assign( | ||
{ method, url, headers }, | ||
typeof body !== "undefined" ? { body } : null, | ||
options.request ? { request: options.request } : null | ||
); | ||
} | ||
export { | ||
parse | ||
}; |
@@ -1,17 +0,16 @@ | ||
export function addQueryParameters(url, parameters) { | ||
const separator = /\?/.test(url) ? "&" : "?"; | ||
const names = Object.keys(parameters); | ||
if (names.length === 0) { | ||
return url; | ||
function addQueryParameters(url, parameters) { | ||
const separator = /\?/.test(url) ? "&" : "?"; | ||
const names = Object.keys(parameters); | ||
if (names.length === 0) { | ||
return url; | ||
} | ||
return url + separator + names.map((name) => { | ||
if (name === "q") { | ||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); | ||
} | ||
return (url + | ||
separator + | ||
names | ||
.map((name) => { | ||
if (name === "q") { | ||
return ("q=" + parameters.q.split("+").map(encodeURIComponent).join("+")); | ||
} | ||
return `${name}=${encodeURIComponent(parameters[name])}`; | ||
}) | ||
.join("&")); | ||
return `${name}=${encodeURIComponent(parameters[name])}`; | ||
}).join("&"); | ||
} | ||
export { | ||
addQueryParameters | ||
}; |
const urlVariableRegex = /\{[^}]+\}/g; | ||
function removeNonChars(variableName) { | ||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/); | ||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/); | ||
} | ||
export function extractUrlVariableNames(url) { | ||
const matches = url.match(urlVariableRegex); | ||
if (!matches) { | ||
return []; | ||
} | ||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); | ||
function extractUrlVariableNames(url) { | ||
const matches = url.match(urlVariableRegex); | ||
if (!matches) { | ||
return []; | ||
} | ||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); | ||
} | ||
export { | ||
extractUrlVariableNames | ||
}; |
@@ -1,9 +0,12 @@ | ||
export function lowercaseKeys(object) { | ||
if (!object) { | ||
return {}; | ||
} | ||
return Object.keys(object).reduce((newObj, key) => { | ||
newObj[key.toLowerCase()] = object[key]; | ||
return newObj; | ||
}, {}); | ||
function lowercaseKeys(object) { | ||
if (!object) { | ||
return {}; | ||
} | ||
return Object.keys(object).reduce((newObj, key) => { | ||
newObj[key.toLowerCase()] = object[key]; | ||
return newObj; | ||
}, {}); | ||
} | ||
export { | ||
lowercaseKeys | ||
}; |
import { isPlainObject } from "is-plain-object"; | ||
export function mergeDeep(defaults, options) { | ||
const result = Object.assign({}, defaults); | ||
Object.keys(options).forEach((key) => { | ||
if (isPlainObject(options[key])) { | ||
if (!(key in defaults)) | ||
Object.assign(result, { [key]: options[key] }); | ||
else | ||
result[key] = mergeDeep(defaults[key], options[key]); | ||
} | ||
else { | ||
Object.assign(result, { [key]: options[key] }); | ||
} | ||
}); | ||
return result; | ||
function mergeDeep(defaults, options) { | ||
const result = Object.assign({}, defaults); | ||
Object.keys(options).forEach((key) => { | ||
if (isPlainObject(options[key])) { | ||
if (!(key in defaults)) | ||
Object.assign(result, { [key]: options[key] }); | ||
else | ||
result[key] = mergeDeep(defaults[key], options[key]); | ||
} else { | ||
Object.assign(result, { [key]: options[key] }); | ||
} | ||
}); | ||
return result; | ||
} | ||
export { | ||
mergeDeep | ||
}; |
@@ -1,8 +0,9 @@ | ||
export function omit(object, keysToOmit) { | ||
return Object.keys(object) | ||
.filter((option) => !keysToOmit.includes(option)) | ||
.reduce((obj, key) => { | ||
obj[key] = object[key]; | ||
return obj; | ||
}, {}); | ||
function omit(object, keysToOmit) { | ||
return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => { | ||
obj[key] = object[key]; | ||
return obj; | ||
}, {}); | ||
} | ||
export { | ||
omit | ||
}; |
@@ -1,8 +0,11 @@ | ||
export function removeUndefinedProperties(obj) { | ||
for (const key in obj) { | ||
if (obj[key] === undefined) { | ||
delete obj[key]; | ||
} | ||
function removeUndefinedProperties(obj) { | ||
for (const key in obj) { | ||
if (obj[key] === void 0) { | ||
delete obj[key]; | ||
} | ||
return obj; | ||
} | ||
return obj; | ||
} | ||
export { | ||
removeUndefinedProperties | ||
}; |
@@ -1,164 +0,128 @@ | ||
// Based on https://github.com/bramstein/url-template, licensed under BSD | ||
// TODO: create separate package. | ||
// | ||
// Copyright (c) 2012-2014, Bram Stein | ||
// All rights reserved. | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions | ||
// are met: | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// 3. The name of the author may not be used to endorse or promote products | ||
// derived from this software without specific prior written permission. | ||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED | ||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
/* istanbul ignore file */ | ||
function encodeReserved(str) { | ||
return str | ||
.split(/(%[0-9A-Fa-f]{2})/g) | ||
.map(function (part) { | ||
if (!/%[0-9A-Fa-f]/.test(part)) { | ||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); | ||
} | ||
return part; | ||
}) | ||
.join(""); | ||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) { | ||
if (!/%[0-9A-Fa-f]/.test(part)) { | ||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); | ||
} | ||
return part; | ||
}).join(""); | ||
} | ||
function encodeUnreserved(str) { | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { | ||
return "%" + c.charCodeAt(0).toString(16).toUpperCase(); | ||
}); | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { | ||
return "%" + c.charCodeAt(0).toString(16).toUpperCase(); | ||
}); | ||
} | ||
function encodeValue(operator, value, key) { | ||
value = | ||
operator === "+" || operator === "#" | ||
? encodeReserved(value) | ||
: encodeUnreserved(value); | ||
if (key) { | ||
return encodeUnreserved(key) + "=" + value; | ||
} | ||
else { | ||
return value; | ||
} | ||
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value); | ||
if (key) { | ||
return encodeUnreserved(key) + "=" + value; | ||
} else { | ||
return value; | ||
} | ||
} | ||
function isDefined(value) { | ||
return value !== undefined && value !== null; | ||
return value !== void 0 && value !== null; | ||
} | ||
function isKeyOperator(operator) { | ||
return operator === ";" || operator === "&" || operator === "?"; | ||
return operator === ";" || operator === "&" || operator === "?"; | ||
} | ||
function getValues(context, operator, key, modifier) { | ||
var value = context[key], result = []; | ||
if (isDefined(value) && value !== "") { | ||
if (typeof value === "string" || | ||
typeof value === "number" || | ||
typeof value === "boolean") { | ||
value = value.toString(); | ||
if (modifier && modifier !== "*") { | ||
value = value.substring(0, parseInt(modifier, 10)); | ||
var value = context[key], result = []; | ||
if (isDefined(value) && value !== "") { | ||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { | ||
value = value.toString(); | ||
if (modifier && modifier !== "*") { | ||
value = value.substring(0, parseInt(modifier, 10)); | ||
} | ||
result.push( | ||
encodeValue(operator, value, isKeyOperator(operator) ? key : "") | ||
); | ||
} else { | ||
if (modifier === "*") { | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function(value2) { | ||
result.push( | ||
encodeValue(operator, value2, isKeyOperator(operator) ? key : "") | ||
); | ||
}); | ||
} else { | ||
Object.keys(value).forEach(function(k) { | ||
if (isDefined(value[k])) { | ||
result.push(encodeValue(operator, value[k], k)); | ||
} | ||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); | ||
}); | ||
} | ||
else { | ||
if (modifier === "*") { | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function (value) { | ||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); | ||
}); | ||
} | ||
else { | ||
Object.keys(value).forEach(function (k) { | ||
if (isDefined(value[k])) { | ||
result.push(encodeValue(operator, value[k], k)); | ||
} | ||
}); | ||
} | ||
} else { | ||
const tmp = []; | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function(value2) { | ||
tmp.push(encodeValue(operator, value2)); | ||
}); | ||
} else { | ||
Object.keys(value).forEach(function(k) { | ||
if (isDefined(value[k])) { | ||
tmp.push(encodeUnreserved(k)); | ||
tmp.push(encodeValue(operator, value[k].toString())); | ||
} | ||
else { | ||
const tmp = []; | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function (value) { | ||
tmp.push(encodeValue(operator, value)); | ||
}); | ||
} | ||
else { | ||
Object.keys(value).forEach(function (k) { | ||
if (isDefined(value[k])) { | ||
tmp.push(encodeUnreserved(k)); | ||
tmp.push(encodeValue(operator, value[k].toString())); | ||
} | ||
}); | ||
} | ||
if (isKeyOperator(operator)) { | ||
result.push(encodeUnreserved(key) + "=" + tmp.join(",")); | ||
} | ||
else if (tmp.length !== 0) { | ||
result.push(tmp.join(",")); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
else { | ||
if (operator === ";") { | ||
if (isDefined(value)) { | ||
result.push(encodeUnreserved(key)); | ||
} | ||
if (isKeyOperator(operator)) { | ||
result.push(encodeUnreserved(key) + "=" + tmp.join(",")); | ||
} else if (tmp.length !== 0) { | ||
result.push(tmp.join(",")); | ||
} | ||
else if (value === "" && (operator === "&" || operator === "?")) { | ||
result.push(encodeUnreserved(key) + "="); | ||
} | ||
else if (value === "") { | ||
result.push(""); | ||
} | ||
} | ||
} | ||
return result; | ||
} else { | ||
if (operator === ";") { | ||
if (isDefined(value)) { | ||
result.push(encodeUnreserved(key)); | ||
} | ||
} else if (value === "" && (operator === "&" || operator === "?")) { | ||
result.push(encodeUnreserved(key) + "="); | ||
} else if (value === "") { | ||
result.push(""); | ||
} | ||
} | ||
return result; | ||
} | ||
export function parseUrl(template) { | ||
return { | ||
expand: expand.bind(null, template), | ||
}; | ||
function parseUrl(template) { | ||
return { | ||
expand: expand.bind(null, template) | ||
}; | ||
} | ||
function expand(template, context) { | ||
var operators = ["+", "#", ".", "/", ";", "?", "&"]; | ||
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { | ||
if (expression) { | ||
let operator = ""; | ||
const values = []; | ||
if (operators.indexOf(expression.charAt(0)) !== -1) { | ||
operator = expression.charAt(0); | ||
expression = expression.substr(1); | ||
} | ||
expression.split(/,/g).forEach(function (variable) { | ||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); | ||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); | ||
}); | ||
if (operator && operator !== "+") { | ||
var separator = ","; | ||
if (operator === "?") { | ||
separator = "&"; | ||
} | ||
else if (operator !== "#") { | ||
separator = operator; | ||
} | ||
return (values.length !== 0 ? operator : "") + values.join(separator); | ||
} | ||
else { | ||
return values.join(","); | ||
} | ||
var operators = ["+", "#", ".", "/", ";", "?", "&"]; | ||
return template.replace( | ||
/\{([^\{\}]+)\}|([^\{\}]+)/g, | ||
function(_, expression, literal) { | ||
if (expression) { | ||
let operator = ""; | ||
const values = []; | ||
if (operators.indexOf(expression.charAt(0)) !== -1) { | ||
operator = expression.charAt(0); | ||
expression = expression.substr(1); | ||
} | ||
else { | ||
return encodeReserved(literal); | ||
expression.split(/,/g).forEach(function(variable) { | ||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); | ||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); | ||
}); | ||
if (operator && operator !== "+") { | ||
var separator = ","; | ||
if (operator === "?") { | ||
separator = "&"; | ||
} else if (operator !== "#") { | ||
separator = operator; | ||
} | ||
return (values.length !== 0 ? operator : "") + values.join(separator); | ||
} else { | ||
return values.join(","); | ||
} | ||
}); | ||
} else { | ||
return encodeReserved(literal); | ||
} | ||
} | ||
); | ||
} | ||
export { | ||
parseUrl | ||
}; |
@@ -1,1 +0,4 @@ | ||
export const VERSION = "7.0.5"; | ||
const VERSION = "7.0.6"; | ||
export { | ||
VERSION | ||
}; |
import { endpointWithDefaults } from "./endpoint-with-defaults"; | ||
import { merge } from "./merge"; | ||
import { parse } from "./parse"; | ||
export function withDefaults(oldDefaults, newDefaults) { | ||
const DEFAULTS = merge(oldDefaults, newDefaults); | ||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS); | ||
return Object.assign(endpoint, { | ||
DEFAULTS, | ||
defaults: withDefaults.bind(null, DEFAULTS), | ||
merge: merge.bind(null, DEFAULTS), | ||
parse, | ||
}); | ||
function withDefaults(oldDefaults, newDefaults) { | ||
const DEFAULTS = merge(oldDefaults, newDefaults); | ||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS); | ||
return Object.assign(endpoint, { | ||
DEFAULTS, | ||
defaults: withDefaults.bind(null, DEFAULTS), | ||
merge: merge.bind(null, DEFAULTS), | ||
parse | ||
}); | ||
} | ||
export { | ||
withDefaults | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { EndpointDefaults } from "@octokit/types"; | ||
import type { EndpointDefaults } from "@octokit/types"; | ||
export declare const DEFAULTS: EndpointDefaults; |
@@ -1,3 +0,3 @@ | ||
import { EndpointOptions, RequestParameters, Route } from "@octokit/types"; | ||
import type { EndpointOptions, RequestParameters, Route } from "@octokit/types"; | ||
import { DEFAULTS } from "./defaults"; | ||
export declare function endpointWithDefaults(defaults: typeof DEFAULTS, route: Route | EndpointOptions, options?: RequestParameters): import("@octokit/types").RequestOptions; |
@@ -1,2 +0,2 @@ | ||
import { EndpointDefaults, RequestParameters, Route } from "@octokit/types"; | ||
import type { EndpointDefaults, RequestParameters, Route } from "@octokit/types"; | ||
export declare function merge(defaults: EndpointDefaults | null, route?: Route | RequestParameters, options?: RequestParameters): EndpointDefaults; |
@@ -1,2 +0,2 @@ | ||
import { EndpointDefaults, RequestOptions } from "@octokit/types"; | ||
import type { EndpointDefaults, RequestOptions } from "@octokit/types"; | ||
export declare function parse(options: EndpointDefaults): RequestOptions; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "7.0.5"; | ||
export declare const VERSION = "7.0.6"; |
@@ -1,2 +0,2 @@ | ||
import { EndpointInterface, RequestParameters, EndpointDefaults } from "@octokit/types"; | ||
import type { EndpointInterface, RequestParameters, EndpointDefaults } from "@octokit/types"; | ||
export declare function withDefaults(oldDefaults: EndpointDefaults | null, newDefaults: RequestParameters): EndpointInterface; |
@@ -1,378 +0,328 @@ | ||
import { isPlainObject } from 'is-plain-object'; | ||
import { getUserAgent } from 'universal-user-agent'; | ||
// pkg/dist-src/util/lowercase-keys.js | ||
function lowercaseKeys(object) { | ||
if (!object) { | ||
return {}; | ||
} | ||
return Object.keys(object).reduce((newObj, key) => { | ||
newObj[key.toLowerCase()] = object[key]; | ||
return newObj; | ||
}, {}); | ||
if (!object) { | ||
return {}; | ||
} | ||
return Object.keys(object).reduce((newObj, key) => { | ||
newObj[key.toLowerCase()] = object[key]; | ||
return newObj; | ||
}, {}); | ||
} | ||
// pkg/dist-src/util/merge-deep.js | ||
import { isPlainObject } from "is-plain-object"; | ||
function mergeDeep(defaults, options) { | ||
const result = Object.assign({}, defaults); | ||
Object.keys(options).forEach((key) => { | ||
if (isPlainObject(options[key])) { | ||
if (!(key in defaults)) | ||
Object.assign(result, { [key]: options[key] }); | ||
else | ||
result[key] = mergeDeep(defaults[key], options[key]); | ||
} | ||
else { | ||
Object.assign(result, { [key]: options[key] }); | ||
} | ||
}); | ||
return result; | ||
const result = Object.assign({}, defaults); | ||
Object.keys(options).forEach((key) => { | ||
if (isPlainObject(options[key])) { | ||
if (!(key in defaults)) | ||
Object.assign(result, { [key]: options[key] }); | ||
else | ||
result[key] = mergeDeep(defaults[key], options[key]); | ||
} else { | ||
Object.assign(result, { [key]: options[key] }); | ||
} | ||
}); | ||
return result; | ||
} | ||
// pkg/dist-src/util/remove-undefined-properties.js | ||
function removeUndefinedProperties(obj) { | ||
for (const key in obj) { | ||
if (obj[key] === undefined) { | ||
delete obj[key]; | ||
} | ||
for (const key in obj) { | ||
if (obj[key] === void 0) { | ||
delete obj[key]; | ||
} | ||
return obj; | ||
} | ||
return obj; | ||
} | ||
// pkg/dist-src/merge.js | ||
function merge(defaults, route, options) { | ||
if (typeof route === "string") { | ||
let [method, url] = route.split(" "); | ||
options = Object.assign(url ? { method, url } : { url: method }, options); | ||
} | ||
else { | ||
options = Object.assign({}, route); | ||
} | ||
// lowercase header names before merging with defaults to avoid duplicates | ||
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) { | ||
mergedOptions.mediaType.previews = defaults.mediaType.previews | ||
.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)) | ||
.concat(mergedOptions.mediaType.previews); | ||
} | ||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map((preview) => preview.replace(/-preview/, "")); | ||
return mergedOptions; | ||
if (typeof route === "string") { | ||
let [method, url] = route.split(" "); | ||
options = Object.assign(url ? { method, url } : { url: method }, options); | ||
} else { | ||
options = Object.assign({}, route); | ||
} | ||
options.headers = lowercaseKeys(options.headers); | ||
removeUndefinedProperties(options); | ||
removeUndefinedProperties(options.headers); | ||
const mergedOptions = mergeDeep(defaults || {}, options); | ||
if (defaults && defaults.mediaType.previews.length) { | ||
mergedOptions.mediaType.previews = defaults.mediaType.previews.filter((preview) => !mergedOptions.mediaType.previews.includes(preview)).concat(mergedOptions.mediaType.previews); | ||
} | ||
mergedOptions.mediaType.previews = mergedOptions.mediaType.previews.map( | ||
(preview) => preview.replace(/-preview/, "") | ||
); | ||
return mergedOptions; | ||
} | ||
// pkg/dist-src/util/add-query-parameters.js | ||
function addQueryParameters(url, parameters) { | ||
const separator = /\?/.test(url) ? "&" : "?"; | ||
const names = Object.keys(parameters); | ||
if (names.length === 0) { | ||
return url; | ||
const separator = /\?/.test(url) ? "&" : "?"; | ||
const names = Object.keys(parameters); | ||
if (names.length === 0) { | ||
return url; | ||
} | ||
return url + separator + names.map((name) => { | ||
if (name === "q") { | ||
return "q=" + parameters.q.split("+").map(encodeURIComponent).join("+"); | ||
} | ||
return (url + | ||
separator + | ||
names | ||
.map((name) => { | ||
if (name === "q") { | ||
return ("q=" + parameters.q.split("+").map(encodeURIComponent).join("+")); | ||
} | ||
return `${name}=${encodeURIComponent(parameters[name])}`; | ||
}) | ||
.join("&")); | ||
return `${name}=${encodeURIComponent(parameters[name])}`; | ||
}).join("&"); | ||
} | ||
const urlVariableRegex = /\{[^}]+\}/g; | ||
// pkg/dist-src/util/extract-url-variable-names.js | ||
var urlVariableRegex = /\{[^}]+\}/g; | ||
function removeNonChars(variableName) { | ||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/); | ||
return variableName.replace(/^\W+|\W+$/g, "").split(/,/); | ||
} | ||
function extractUrlVariableNames(url) { | ||
const matches = url.match(urlVariableRegex); | ||
if (!matches) { | ||
return []; | ||
} | ||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); | ||
const matches = url.match(urlVariableRegex); | ||
if (!matches) { | ||
return []; | ||
} | ||
return matches.map(removeNonChars).reduce((a, b) => a.concat(b), []); | ||
} | ||
// pkg/dist-src/util/omit.js | ||
function omit(object, keysToOmit) { | ||
return Object.keys(object) | ||
.filter((option) => !keysToOmit.includes(option)) | ||
.reduce((obj, key) => { | ||
obj[key] = object[key]; | ||
return obj; | ||
}, {}); | ||
return Object.keys(object).filter((option) => !keysToOmit.includes(option)).reduce((obj, key) => { | ||
obj[key] = object[key]; | ||
return obj; | ||
}, {}); | ||
} | ||
// Based on https://github.com/bramstein/url-template, licensed under BSD | ||
// TODO: create separate package. | ||
// | ||
// Copyright (c) 2012-2014, Bram Stein | ||
// All rights reserved. | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions | ||
// are met: | ||
// 1. Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// 2. Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// 3. The name of the author may not be used to endorse or promote products | ||
// derived from this software without specific prior written permission. | ||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED | ||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | ||
// EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
/* istanbul ignore file */ | ||
// pkg/dist-src/util/url-template.js | ||
function encodeReserved(str) { | ||
return str | ||
.split(/(%[0-9A-Fa-f]{2})/g) | ||
.map(function (part) { | ||
if (!/%[0-9A-Fa-f]/.test(part)) { | ||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); | ||
} | ||
return part; | ||
}) | ||
.join(""); | ||
return str.split(/(%[0-9A-Fa-f]{2})/g).map(function(part) { | ||
if (!/%[0-9A-Fa-f]/.test(part)) { | ||
part = encodeURI(part).replace(/%5B/g, "[").replace(/%5D/g, "]"); | ||
} | ||
return part; | ||
}).join(""); | ||
} | ||
function encodeUnreserved(str) { | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { | ||
return "%" + c.charCodeAt(0).toString(16).toUpperCase(); | ||
}); | ||
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) { | ||
return "%" + c.charCodeAt(0).toString(16).toUpperCase(); | ||
}); | ||
} | ||
function encodeValue(operator, value, key) { | ||
value = | ||
operator === "+" || operator === "#" | ||
? encodeReserved(value) | ||
: encodeUnreserved(value); | ||
if (key) { | ||
return encodeUnreserved(key) + "=" + value; | ||
} | ||
else { | ||
return value; | ||
} | ||
value = operator === "+" || operator === "#" ? encodeReserved(value) : encodeUnreserved(value); | ||
if (key) { | ||
return encodeUnreserved(key) + "=" + value; | ||
} else { | ||
return value; | ||
} | ||
} | ||
function isDefined(value) { | ||
return value !== undefined && value !== null; | ||
return value !== void 0 && value !== null; | ||
} | ||
function isKeyOperator(operator) { | ||
return operator === ";" || operator === "&" || operator === "?"; | ||
return operator === ";" || operator === "&" || operator === "?"; | ||
} | ||
function getValues(context, operator, key, modifier) { | ||
var value = context[key], result = []; | ||
if (isDefined(value) && value !== "") { | ||
if (typeof value === "string" || | ||
typeof value === "number" || | ||
typeof value === "boolean") { | ||
value = value.toString(); | ||
if (modifier && modifier !== "*") { | ||
value = value.substring(0, parseInt(modifier, 10)); | ||
var value = context[key], result = []; | ||
if (isDefined(value) && value !== "") { | ||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { | ||
value = value.toString(); | ||
if (modifier && modifier !== "*") { | ||
value = value.substring(0, parseInt(modifier, 10)); | ||
} | ||
result.push( | ||
encodeValue(operator, value, isKeyOperator(operator) ? key : "") | ||
); | ||
} else { | ||
if (modifier === "*") { | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function(value2) { | ||
result.push( | ||
encodeValue(operator, value2, isKeyOperator(operator) ? key : "") | ||
); | ||
}); | ||
} else { | ||
Object.keys(value).forEach(function(k) { | ||
if (isDefined(value[k])) { | ||
result.push(encodeValue(operator, value[k], k)); | ||
} | ||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); | ||
}); | ||
} | ||
else { | ||
if (modifier === "*") { | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function (value) { | ||
result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : "")); | ||
}); | ||
} | ||
else { | ||
Object.keys(value).forEach(function (k) { | ||
if (isDefined(value[k])) { | ||
result.push(encodeValue(operator, value[k], k)); | ||
} | ||
}); | ||
} | ||
} else { | ||
const tmp = []; | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function(value2) { | ||
tmp.push(encodeValue(operator, value2)); | ||
}); | ||
} else { | ||
Object.keys(value).forEach(function(k) { | ||
if (isDefined(value[k])) { | ||
tmp.push(encodeUnreserved(k)); | ||
tmp.push(encodeValue(operator, value[k].toString())); | ||
} | ||
else { | ||
const tmp = []; | ||
if (Array.isArray(value)) { | ||
value.filter(isDefined).forEach(function (value) { | ||
tmp.push(encodeValue(operator, value)); | ||
}); | ||
} | ||
else { | ||
Object.keys(value).forEach(function (k) { | ||
if (isDefined(value[k])) { | ||
tmp.push(encodeUnreserved(k)); | ||
tmp.push(encodeValue(operator, value[k].toString())); | ||
} | ||
}); | ||
} | ||
if (isKeyOperator(operator)) { | ||
result.push(encodeUnreserved(key) + "=" + tmp.join(",")); | ||
} | ||
else if (tmp.length !== 0) { | ||
result.push(tmp.join(",")); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
else { | ||
if (operator === ";") { | ||
if (isDefined(value)) { | ||
result.push(encodeUnreserved(key)); | ||
} | ||
if (isKeyOperator(operator)) { | ||
result.push(encodeUnreserved(key) + "=" + tmp.join(",")); | ||
} else if (tmp.length !== 0) { | ||
result.push(tmp.join(",")); | ||
} | ||
else if (value === "" && (operator === "&" || operator === "?")) { | ||
result.push(encodeUnreserved(key) + "="); | ||
} | ||
else if (value === "") { | ||
result.push(""); | ||
} | ||
} | ||
} | ||
return result; | ||
} else { | ||
if (operator === ";") { | ||
if (isDefined(value)) { | ||
result.push(encodeUnreserved(key)); | ||
} | ||
} else if (value === "" && (operator === "&" || operator === "?")) { | ||
result.push(encodeUnreserved(key) + "="); | ||
} else if (value === "") { | ||
result.push(""); | ||
} | ||
} | ||
return result; | ||
} | ||
function parseUrl(template) { | ||
return { | ||
expand: expand.bind(null, template), | ||
}; | ||
return { | ||
expand: expand.bind(null, template) | ||
}; | ||
} | ||
function expand(template, context) { | ||
var operators = ["+", "#", ".", "/", ";", "?", "&"]; | ||
return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { | ||
if (expression) { | ||
let operator = ""; | ||
const values = []; | ||
if (operators.indexOf(expression.charAt(0)) !== -1) { | ||
operator = expression.charAt(0); | ||
expression = expression.substr(1); | ||
} | ||
expression.split(/,/g).forEach(function (variable) { | ||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); | ||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); | ||
}); | ||
if (operator && operator !== "+") { | ||
var separator = ","; | ||
if (operator === "?") { | ||
separator = "&"; | ||
} | ||
else if (operator !== "#") { | ||
separator = operator; | ||
} | ||
return (values.length !== 0 ? operator : "") + values.join(separator); | ||
} | ||
else { | ||
return values.join(","); | ||
} | ||
var operators = ["+", "#", ".", "/", ";", "?", "&"]; | ||
return template.replace( | ||
/\{([^\{\}]+)\}|([^\{\}]+)/g, | ||
function(_, expression, literal) { | ||
if (expression) { | ||
let operator = ""; | ||
const values = []; | ||
if (operators.indexOf(expression.charAt(0)) !== -1) { | ||
operator = expression.charAt(0); | ||
expression = expression.substr(1); | ||
} | ||
else { | ||
return encodeReserved(literal); | ||
expression.split(/,/g).forEach(function(variable) { | ||
var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); | ||
values.push(getValues(context, operator, tmp[1], tmp[2] || tmp[3])); | ||
}); | ||
if (operator && operator !== "+") { | ||
var separator = ","; | ||
if (operator === "?") { | ||
separator = "&"; | ||
} else if (operator !== "#") { | ||
separator = operator; | ||
} | ||
return (values.length !== 0 ? operator : "") + values.join(separator); | ||
} else { | ||
return values.join(","); | ||
} | ||
}); | ||
} else { | ||
return encodeReserved(literal); | ||
} | ||
} | ||
); | ||
} | ||
// pkg/dist-src/parse.js | ||
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 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 | ||
const urlVariableNames = extractUrlVariableNames(url); | ||
url = parseUrl(url).expand(parameters); | ||
if (!/^http/.test(url)) { | ||
url = options.baseUrl + url; | ||
let method = options.method.toUpperCase(); | ||
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" | ||
]); | ||
const urlVariableNames = extractUrlVariableNames(url); | ||
url = parseUrl(url).expand(parameters); | ||
if (!/^http/.test(url)) { | ||
url = options.baseUrl + url; | ||
} | ||
const omittedParameters = Object.keys(options).filter((option) => urlVariableNames.includes(option)).concat("baseUrl"); | ||
const remainingParameters = omit(parameters, omittedParameters); | ||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); | ||
if (!isBinaryRequest) { | ||
if (options.mediaType.format) { | ||
headers.accept = headers.accept.split(/,/).map( | ||
(preview) => preview.replace( | ||
/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, | ||
`application/vnd$1$2.${options.mediaType.format}` | ||
) | ||
).join(","); | ||
} | ||
const omittedParameters = Object.keys(options) | ||
.filter((option) => urlVariableNames.includes(option)) | ||
.concat("baseUrl"); | ||
const remainingParameters = omit(parameters, omittedParameters); | ||
const isBinaryRequest = /application\/octet-stream/i.test(headers.accept); | ||
if (!isBinaryRequest) { | ||
if (options.mediaType.format) { | ||
// e.g. application/vnd.github.v3+json => application/vnd.github.v3.raw | ||
headers.accept = headers.accept | ||
.split(/,/) | ||
.map((preview) => preview.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)) | ||
.join(","); | ||
} | ||
if (options.mediaType.previews.length) { | ||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; | ||
headers.accept = previewsFromAcceptHeader | ||
.concat(options.mediaType.previews) | ||
.map((preview) => { | ||
const format = options.mediaType.format | ||
? `.${options.mediaType.format}` | ||
: "+json"; | ||
return `application/vnd.github.${preview}-preview${format}`; | ||
}) | ||
.join(","); | ||
} | ||
if (options.mediaType.previews.length) { | ||
const previewsFromAcceptHeader = headers.accept.match(/[\w-]+(?=-preview)/g) || []; | ||
headers.accept = previewsFromAcceptHeader.concat(options.mediaType.previews).map((preview) => { | ||
const format = options.mediaType.format ? `.${options.mediaType.format}` : "+json"; | ||
return `application/vnd.github.${preview}-preview${format}`; | ||
}).join(","); | ||
} | ||
// for GET/HEAD requests, set URL query parameters from remaining parameters | ||
// for PATCH/POST/PUT/DELETE requests, set request body from remaining parameters | ||
if (["GET", "HEAD"].includes(method)) { | ||
url = addQueryParameters(url, remainingParameters); | ||
} | ||
if (["GET", "HEAD"].includes(method)) { | ||
url = addQueryParameters(url, remainingParameters); | ||
} else { | ||
if ("data" in remainingParameters) { | ||
body = remainingParameters.data; | ||
} else { | ||
if (Object.keys(remainingParameters).length) { | ||
body = remainingParameters; | ||
} | ||
} | ||
else { | ||
if ("data" in remainingParameters) { | ||
body = remainingParameters.data; | ||
} | ||
else { | ||
if (Object.keys(remainingParameters).length) { | ||
body = remainingParameters; | ||
} | ||
} | ||
} | ||
// default content-type for JSON if body is set | ||
if (!headers["content-type"] && typeof body !== "undefined") { | ||
headers["content-type"] = "application/json; charset=utf-8"; | ||
} | ||
// GitHub expects 'content-length: 0' header for PUT/PATCH requests without body. | ||
// fetch does not allow to set `content-length` header, but we can set body to an empty string | ||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { | ||
body = ""; | ||
} | ||
// Only return body/request keys if present | ||
return Object.assign({ method, url, headers }, typeof body !== "undefined" ? { body } : null, options.request ? { request: options.request } : null); | ||
} | ||
if (!headers["content-type"] && typeof body !== "undefined") { | ||
headers["content-type"] = "application/json; charset=utf-8"; | ||
} | ||
if (["PATCH", "PUT"].includes(method) && typeof body === "undefined") { | ||
body = ""; | ||
} | ||
return Object.assign( | ||
{ method, url, headers }, | ||
typeof body !== "undefined" ? { body } : null, | ||
options.request ? { request: options.request } : null | ||
); | ||
} | ||
// pkg/dist-src/endpoint-with-defaults.js | ||
function endpointWithDefaults(defaults, route, options) { | ||
return parse(merge(defaults, route, options)); | ||
return parse(merge(defaults, route, options)); | ||
} | ||
// pkg/dist-src/with-defaults.js | ||
function withDefaults(oldDefaults, newDefaults) { | ||
const DEFAULTS = merge(oldDefaults, newDefaults); | ||
const endpoint = endpointWithDefaults.bind(null, DEFAULTS); | ||
return Object.assign(endpoint, { | ||
DEFAULTS, | ||
defaults: withDefaults.bind(null, DEFAULTS), | ||
merge: merge.bind(null, DEFAULTS), | ||
parse, | ||
}); | ||
const DEFAULTS2 = merge(oldDefaults, newDefaults); | ||
const endpoint2 = endpointWithDefaults.bind(null, DEFAULTS2); | ||
return Object.assign(endpoint2, { | ||
DEFAULTS: DEFAULTS2, | ||
defaults: withDefaults.bind(null, DEFAULTS2), | ||
merge: merge.bind(null, DEFAULTS2), | ||
parse | ||
}); | ||
} | ||
const VERSION = "7.0.5"; | ||
// pkg/dist-src/defaults.js | ||
import { getUserAgent } from "universal-user-agent"; | ||
const userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`; | ||
// DEFAULTS has all properties set that EndpointOptions has, except url. | ||
// So we use RequestParameters and add method as additional required property. | ||
const DEFAULTS = { | ||
method: "GET", | ||
baseUrl: "https://api.github.com", | ||
headers: { | ||
accept: "application/vnd.github.v3+json", | ||
"user-agent": userAgent, | ||
}, | ||
mediaType: { | ||
format: "", | ||
previews: [], | ||
}, | ||
// pkg/dist-src/version.js | ||
var VERSION = "7.0.6"; | ||
// pkg/dist-src/defaults.js | ||
var userAgent = `octokit-endpoint.js/${VERSION} ${getUserAgent()}`; | ||
var DEFAULTS = { | ||
method: "GET", | ||
baseUrl: "https://api.github.com", | ||
headers: { | ||
accept: "application/vnd.github.v3+json", | ||
"user-agent": userAgent | ||
}, | ||
mediaType: { | ||
format: "", | ||
previews: [] | ||
} | ||
}; | ||
const endpoint = withDefaults(null, DEFAULTS); | ||
export { endpoint }; | ||
//# sourceMappingURL=index.js.map | ||
// pkg/dist-src/index.js | ||
var endpoint = withDefaults(null, DEFAULTS); | ||
export { | ||
endpoint | ||
}; |
{ | ||
"name": "@octokit/endpoint", | ||
"version": "7.0.6", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"description": "Turns REST API endpoints into generic request options", | ||
"version": "7.0.5", | ||
"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/endpoint.js", | ||
"keywords": [ | ||
@@ -22,27 +15,33 @@ "octokit", | ||
], | ||
"repository": "github:octokit/endpoint.js", | ||
"dependencies": { | ||
"@octokit/types": "^9.0.0", | ||
"is-plain-object": "^5.0.0", | ||
"universal-user-agent": "^6.0.0" | ||
}, | ||
"author": "Gregor Martynus (https://github.com/gr2m)", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@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/jest": "^29.0.0", | ||
"esbuild": "^0.17.19", | ||
"glob": "^10.2.7", | ||
"jest": "^29.0.0", | ||
"prettier": "2.8.3", | ||
"semantic-release": "^20.0.0", | ||
"prettier": "2.8.8", | ||
"semantic-release": "^21.0.0", | ||
"semantic-release-plugin-update-version-in-files": "^1.0.0", | ||
"ts-jest": "^29.0.0", | ||
"typescript": "^4.0.2" | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@octokit/types": "^9.0.0", | ||
"is-plain-object": "^5.0.0", | ||
"universal-user-agent": "^6.0.0" | ||
}, | ||
"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 not supported yet
Sorry, the diff of this file is not supported yet
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
10
-9.09%1
-50%87415
-23.71%1039
-5.8%