mirror of
https://github.com/anthropics/claude-code.git
synced 2026-04-24 06:36:50 +00:00
This commit adds a new tools for creating inline comments on GitHub pull requests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
16799 lines
610 KiB
JavaScript
16799 lines
610 KiB
JavaScript
var __create = Object.create;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __toESM = (mod, isNodeMode, target) => {
|
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
for (let key of __getOwnPropNames(mod))
|
|
if (!__hasOwnProp.call(to, key))
|
|
__defProp(to, key, {
|
|
get: () => mod[key],
|
|
enumerable: true
|
|
});
|
|
return to;
|
|
};
|
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, {
|
|
get: all[name],
|
|
enumerable: true,
|
|
configurable: true,
|
|
set: (newValue) => all[name] = () => newValue
|
|
});
|
|
};
|
|
|
|
// node_modules/uri-js/dist/es5/uri.all.js
|
|
var require_uri_all = __commonJS((exports, module) => {
|
|
(function(global, factory) {
|
|
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : factory(global.URI = global.URI || {});
|
|
})(exports, function(exports2) {
|
|
function merge() {
|
|
for (var _len = arguments.length, sets = Array(_len), _key = 0;_key < _len; _key++) {
|
|
sets[_key] = arguments[_key];
|
|
}
|
|
if (sets.length > 1) {
|
|
sets[0] = sets[0].slice(0, -1);
|
|
var xl = sets.length - 1;
|
|
for (var x = 1;x < xl; ++x) {
|
|
sets[x] = sets[x].slice(1, -1);
|
|
}
|
|
sets[xl] = sets[xl].slice(1);
|
|
return sets.join("");
|
|
} else {
|
|
return sets[0];
|
|
}
|
|
}
|
|
function subexp(str) {
|
|
return "(?:" + str + ")";
|
|
}
|
|
function typeOf(o) {
|
|
return o === undefined ? "undefined" : o === null ? "null" : Object.prototype.toString.call(o).split(" ").pop().split("]").shift().toLowerCase();
|
|
}
|
|
function toUpperCase(str) {
|
|
return str.toUpperCase();
|
|
}
|
|
function toArray(obj) {
|
|
return obj !== undefined && obj !== null ? obj instanceof Array ? obj : typeof obj.length !== "number" || obj.split || obj.setInterval || obj.call ? [obj] : Array.prototype.slice.call(obj) : [];
|
|
}
|
|
function assign(target, source) {
|
|
var obj = target;
|
|
if (source) {
|
|
for (var key in source) {
|
|
obj[key] = source[key];
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
function buildExps(isIRI2) {
|
|
var ALPHA$$ = "[A-Za-z]", CR$ = "[\\x0D]", DIGIT$$ = "[0-9]", DQUOTE$$ = "[\\x22]", HEXDIG$$2 = merge(DIGIT$$, "[A-Fa-f]"), LF$$ = "[\\x0A]", SP$$ = "[\\x20]", PCT_ENCODED$2 = subexp(subexp("%[EFef]" + HEXDIG$$2 + "%" + HEXDIG$$2 + HEXDIG$$2 + "%" + HEXDIG$$2 + HEXDIG$$2) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$2 + "%" + HEXDIG$$2 + HEXDIG$$2) + "|" + subexp("%" + HEXDIG$$2 + HEXDIG$$2)), GEN_DELIMS$$ = "[\\:\\/\\?\\#\\[\\]\\@]", SUB_DELIMS$$ = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]", RESERVED$$ = merge(GEN_DELIMS$$, SUB_DELIMS$$), UCSCHAR$$ = isIRI2 ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]", IPRIVATE$$ = isIRI2 ? "[\\uE000-\\uF8FF]" : "[]", UNRESERVED$$2 = merge(ALPHA$$, DIGIT$$, "[\\-\\.\\_\\~]", UCSCHAR$$), SCHEME$ = subexp(ALPHA$$ + merge(ALPHA$$, DIGIT$$, "[\\+\\-\\.]") + "*"), USERINFO$ = subexp(subexp(PCT_ENCODED$2 + "|" + merge(UNRESERVED$$2, SUB_DELIMS$$, "[\\:]")) + "*"), DEC_OCTET$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("[1-9]" + DIGIT$$) + "|" + DIGIT$$), DEC_OCTET_RELAXED$ = subexp(subexp("25[0-5]") + "|" + subexp("2[0-4]" + DIGIT$$) + "|" + subexp("1" + DIGIT$$ + DIGIT$$) + "|" + subexp("0?[1-9]" + DIGIT$$) + "|0?0?" + DIGIT$$), IPV4ADDRESS$ = subexp(DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$ + "\\." + DEC_OCTET_RELAXED$), H16$ = subexp(HEXDIG$$2 + "{1,4}"), LS32$ = subexp(subexp(H16$ + "\\:" + H16$) + "|" + IPV4ADDRESS$), IPV6ADDRESS1$ = subexp(subexp(H16$ + "\\:") + "{6}" + LS32$), IPV6ADDRESS2$ = subexp("\\:\\:" + subexp(H16$ + "\\:") + "{5}" + LS32$), IPV6ADDRESS3$ = subexp(subexp(H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{4}" + LS32$), IPV6ADDRESS4$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,1}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{3}" + LS32$), IPV6ADDRESS5$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,2}" + H16$) + "?\\:\\:" + subexp(H16$ + "\\:") + "{2}" + LS32$), IPV6ADDRESS6$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,3}" + H16$) + "?\\:\\:" + H16$ + "\\:" + LS32$), IPV6ADDRESS7$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,4}" + H16$) + "?\\:\\:" + LS32$), IPV6ADDRESS8$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,5}" + H16$) + "?\\:\\:" + H16$), IPV6ADDRESS9$ = subexp(subexp(subexp(H16$ + "\\:") + "{0,6}" + H16$) + "?\\:\\:"), IPV6ADDRESS$ = subexp([IPV6ADDRESS1$, IPV6ADDRESS2$, IPV6ADDRESS3$, IPV6ADDRESS4$, IPV6ADDRESS5$, IPV6ADDRESS6$, IPV6ADDRESS7$, IPV6ADDRESS8$, IPV6ADDRESS9$].join("|")), ZONEID$ = subexp(subexp(UNRESERVED$$2 + "|" + PCT_ENCODED$2) + "+"), IPV6ADDRZ$ = subexp(IPV6ADDRESS$ + "\\%25" + ZONEID$), IPV6ADDRZ_RELAXED$ = subexp(IPV6ADDRESS$ + subexp("\\%25|\\%(?!" + HEXDIG$$2 + "{2})") + ZONEID$), IPVFUTURE$ = subexp("[vV]" + HEXDIG$$2 + "+\\." + merge(UNRESERVED$$2, SUB_DELIMS$$, "[\\:]") + "+"), IP_LITERAL$ = subexp("\\[" + subexp(IPV6ADDRZ_RELAXED$ + "|" + IPV6ADDRESS$ + "|" + IPVFUTURE$) + "\\]"), REG_NAME$ = subexp(subexp(PCT_ENCODED$2 + "|" + merge(UNRESERVED$$2, SUB_DELIMS$$)) + "*"), HOST$ = subexp(IP_LITERAL$ + "|" + IPV4ADDRESS$ + "(?!" + REG_NAME$ + ")" + "|" + REG_NAME$), PORT$ = subexp(DIGIT$$ + "*"), AUTHORITY$ = subexp(subexp(USERINFO$ + "@") + "?" + HOST$ + subexp("\\:" + PORT$) + "?"), PCHAR$ = subexp(PCT_ENCODED$2 + "|" + merge(UNRESERVED$$2, SUB_DELIMS$$, "[\\:\\@]")), SEGMENT$ = subexp(PCHAR$ + "*"), SEGMENT_NZ$ = subexp(PCHAR$ + "+"), SEGMENT_NZ_NC$ = subexp(subexp(PCT_ENCODED$2 + "|" + merge(UNRESERVED$$2, SUB_DELIMS$$, "[\\@]")) + "+"), PATH_ABEMPTY$ = subexp(subexp("\\/" + SEGMENT$) + "*"), PATH_ABSOLUTE$ = subexp("\\/" + subexp(SEGMENT_NZ$ + PATH_ABEMPTY$) + "?"), PATH_NOSCHEME$ = subexp(SEGMENT_NZ_NC$ + PATH_ABEMPTY$), PATH_ROOTLESS$ = subexp(SEGMENT_NZ$ + PATH_ABEMPTY$), PATH_EMPTY$ = "(?!" + PCHAR$ + ")", PATH$ = subexp(PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$), QUERY$ = subexp(subexp(PCHAR$ + "|" + merge("[\\/\\?]", IPRIVATE$$)) + "*"), FRAGMENT$ = subexp(subexp(PCHAR$ + "|[\\/\\?]") + "*"), HIER_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$), URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"), RELATIVE_PART$ = subexp(subexp("\\/\\/" + AUTHORITY$ + PATH_ABEMPTY$) + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$), RELATIVE$ = subexp(RELATIVE_PART$ + subexp("\\?" + QUERY$) + "?" + subexp("\\#" + FRAGMENT$) + "?"), URI_REFERENCE$ = subexp(URI$ + "|" + RELATIVE$), ABSOLUTE_URI$ = subexp(SCHEME$ + "\\:" + HIER_PART$ + subexp("\\?" + QUERY$) + "?"), GENERIC_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$", RELATIVE_REF$ = "^(){0}" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_NOSCHEME$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?" + subexp("\\#(" + FRAGMENT$ + ")") + "?$", ABSOLUTE_REF$ = "^(" + SCHEME$ + ")\\:" + subexp(subexp("\\/\\/(" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?)") + "?(" + PATH_ABEMPTY$ + "|" + PATH_ABSOLUTE$ + "|" + PATH_ROOTLESS$ + "|" + PATH_EMPTY$ + ")") + subexp("\\?(" + QUERY$ + ")") + "?$", SAMEDOC_REF$ = "^" + subexp("\\#(" + FRAGMENT$ + ")") + "?$", AUTHORITY_REF$ = "^" + subexp("(" + USERINFO$ + ")@") + "?(" + HOST$ + ")" + subexp("\\:(" + PORT$ + ")") + "?$";
|
|
return {
|
|
NOT_SCHEME: new RegExp(merge("[^]", ALPHA$$, DIGIT$$, "[\\+\\-\\.]"), "g"),
|
|
NOT_USERINFO: new RegExp(merge("[^\\%\\:]", UNRESERVED$$2, SUB_DELIMS$$), "g"),
|
|
NOT_HOST: new RegExp(merge("[^\\%\\[\\]\\:]", UNRESERVED$$2, SUB_DELIMS$$), "g"),
|
|
NOT_PATH: new RegExp(merge("[^\\%\\/\\:\\@]", UNRESERVED$$2, SUB_DELIMS$$), "g"),
|
|
NOT_PATH_NOSCHEME: new RegExp(merge("[^\\%\\/\\@]", UNRESERVED$$2, SUB_DELIMS$$), "g"),
|
|
NOT_QUERY: new RegExp(merge("[^\\%]", UNRESERVED$$2, SUB_DELIMS$$, "[\\:\\@\\/\\?]", IPRIVATE$$), "g"),
|
|
NOT_FRAGMENT: new RegExp(merge("[^\\%]", UNRESERVED$$2, SUB_DELIMS$$, "[\\:\\@\\/\\?]"), "g"),
|
|
ESCAPE: new RegExp(merge("[^]", UNRESERVED$$2, SUB_DELIMS$$), "g"),
|
|
UNRESERVED: new RegExp(UNRESERVED$$2, "g"),
|
|
OTHER_CHARS: new RegExp(merge("[^\\%]", UNRESERVED$$2, RESERVED$$), "g"),
|
|
PCT_ENCODED: new RegExp(PCT_ENCODED$2, "g"),
|
|
IPV4ADDRESS: new RegExp("^(" + IPV4ADDRESS$ + ")$"),
|
|
IPV6ADDRESS: new RegExp("^\\[?(" + IPV6ADDRESS$ + ")" + subexp(subexp("\\%25|\\%(?!" + HEXDIG$$2 + "{2})") + "(" + ZONEID$ + ")") + "?\\]?$")
|
|
};
|
|
}
|
|
var URI_PROTOCOL = buildExps(false);
|
|
var IRI_PROTOCOL = buildExps(true);
|
|
var slicedToArray = function() {
|
|
function sliceIterator(arr, i) {
|
|
var _arr = [];
|
|
var _n = true;
|
|
var _d = false;
|
|
var _e = undefined;
|
|
try {
|
|
for (var _i = arr[Symbol.iterator](), _s;!(_n = (_s = _i.next()).done); _n = true) {
|
|
_arr.push(_s.value);
|
|
if (i && _arr.length === i)
|
|
break;
|
|
}
|
|
} catch (err) {
|
|
_d = true;
|
|
_e = err;
|
|
} finally {
|
|
try {
|
|
if (!_n && _i["return"])
|
|
_i["return"]();
|
|
} finally {
|
|
if (_d)
|
|
throw _e;
|
|
}
|
|
}
|
|
return _arr;
|
|
}
|
|
return function(arr, i) {
|
|
if (Array.isArray(arr)) {
|
|
return arr;
|
|
} else if (Symbol.iterator in Object(arr)) {
|
|
return sliceIterator(arr, i);
|
|
} else {
|
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
}
|
|
};
|
|
}();
|
|
var toConsumableArray = function(arr) {
|
|
if (Array.isArray(arr)) {
|
|
for (var i = 0, arr2 = Array(arr.length);i < arr.length; i++)
|
|
arr2[i] = arr[i];
|
|
return arr2;
|
|
} else {
|
|
return Array.from(arr);
|
|
}
|
|
};
|
|
var maxInt = 2147483647;
|
|
var base = 36;
|
|
var tMin = 1;
|
|
var tMax = 26;
|
|
var skew = 38;
|
|
var damp = 700;
|
|
var initialBias = 72;
|
|
var initialN = 128;
|
|
var delimiter = "-";
|
|
var regexPunycode = /^xn--/;
|
|
var regexNonASCII = /[^\0-\x7E]/;
|
|
var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
|
|
var errors2 = {
|
|
overflow: "Overflow: input needs wider integers to process",
|
|
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
"invalid-input": "Invalid input"
|
|
};
|
|
var baseMinusTMin = base - tMin;
|
|
var floor = Math.floor;
|
|
var stringFromCharCode = String.fromCharCode;
|
|
function error$1(type) {
|
|
throw new RangeError(errors2[type]);
|
|
}
|
|
function map(array, fn) {
|
|
var result = [];
|
|
var length = array.length;
|
|
while (length--) {
|
|
result[length] = fn(array[length]);
|
|
}
|
|
return result;
|
|
}
|
|
function mapDomain(string, fn) {
|
|
var parts = string.split("@");
|
|
var result = "";
|
|
if (parts.length > 1) {
|
|
result = parts[0] + "@";
|
|
string = parts[1];
|
|
}
|
|
string = string.replace(regexSeparators, ".");
|
|
var labels = string.split(".");
|
|
var encoded = map(labels, fn).join(".");
|
|
return result + encoded;
|
|
}
|
|
function ucs2decode(string) {
|
|
var output = [];
|
|
var counter = 0;
|
|
var length = string.length;
|
|
while (counter < length) {
|
|
var value = string.charCodeAt(counter++);
|
|
if (value >= 55296 && value <= 56319 && counter < length) {
|
|
var extra = string.charCodeAt(counter++);
|
|
if ((extra & 64512) == 56320) {
|
|
output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
|
|
} else {
|
|
output.push(value);
|
|
counter--;
|
|
}
|
|
} else {
|
|
output.push(value);
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
var ucs2encode = function ucs2encode(array) {
|
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
};
|
|
var basicToDigit = function basicToDigit(codePoint) {
|
|
if (codePoint - 48 < 10) {
|
|
return codePoint - 22;
|
|
}
|
|
if (codePoint - 65 < 26) {
|
|
return codePoint - 65;
|
|
}
|
|
if (codePoint - 97 < 26) {
|
|
return codePoint - 97;
|
|
}
|
|
return base;
|
|
};
|
|
var digitToBasic = function digitToBasic(digit, flag) {
|
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
};
|
|
var adapt = function adapt(delta, numPoints, firstTime) {
|
|
var k = 0;
|
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
delta += floor(delta / numPoints);
|
|
for (;delta > baseMinusTMin * tMax >> 1; k += base) {
|
|
delta = floor(delta / baseMinusTMin);
|
|
}
|
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
};
|
|
var decode = function decode(input) {
|
|
var output = [];
|
|
var inputLength = input.length;
|
|
var i = 0;
|
|
var n = initialN;
|
|
var bias = initialBias;
|
|
var basic = input.lastIndexOf(delimiter);
|
|
if (basic < 0) {
|
|
basic = 0;
|
|
}
|
|
for (var j = 0;j < basic; ++j) {
|
|
if (input.charCodeAt(j) >= 128) {
|
|
error$1("not-basic");
|
|
}
|
|
output.push(input.charCodeAt(j));
|
|
}
|
|
for (var index = basic > 0 ? basic + 1 : 0;index < inputLength; ) {
|
|
var oldi = i;
|
|
for (var w = 1, k = base;; k += base) {
|
|
if (index >= inputLength) {
|
|
error$1("invalid-input");
|
|
}
|
|
var digit = basicToDigit(input.charCodeAt(index++));
|
|
if (digit >= base || digit > floor((maxInt - i) / w)) {
|
|
error$1("overflow");
|
|
}
|
|
i += digit * w;
|
|
var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
if (digit < t) {
|
|
break;
|
|
}
|
|
var baseMinusT = base - t;
|
|
if (w > floor(maxInt / baseMinusT)) {
|
|
error$1("overflow");
|
|
}
|
|
w *= baseMinusT;
|
|
}
|
|
var out = output.length + 1;
|
|
bias = adapt(i - oldi, out, oldi == 0);
|
|
if (floor(i / out) > maxInt - n) {
|
|
error$1("overflow");
|
|
}
|
|
n += floor(i / out);
|
|
i %= out;
|
|
output.splice(i++, 0, n);
|
|
}
|
|
return String.fromCodePoint.apply(String, output);
|
|
};
|
|
var encode = function encode(input) {
|
|
var output = [];
|
|
input = ucs2decode(input);
|
|
var inputLength = input.length;
|
|
var n = initialN;
|
|
var delta = 0;
|
|
var bias = initialBias;
|
|
var _iteratorNormalCompletion = true;
|
|
var _didIteratorError = false;
|
|
var _iteratorError = undefined;
|
|
try {
|
|
for (var _iterator = input[Symbol.iterator](), _step;!(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
var _currentValue2 = _step.value;
|
|
if (_currentValue2 < 128) {
|
|
output.push(stringFromCharCode(_currentValue2));
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError = true;
|
|
_iteratorError = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
_iterator.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError) {
|
|
throw _iteratorError;
|
|
}
|
|
}
|
|
}
|
|
var basicLength = output.length;
|
|
var handledCPCount = basicLength;
|
|
if (basicLength) {
|
|
output.push(delimiter);
|
|
}
|
|
while (handledCPCount < inputLength) {
|
|
var m = maxInt;
|
|
var _iteratorNormalCompletion2 = true;
|
|
var _didIteratorError2 = false;
|
|
var _iteratorError2 = undefined;
|
|
try {
|
|
for (var _iterator2 = input[Symbol.iterator](), _step2;!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
var currentValue = _step2.value;
|
|
if (currentValue >= n && currentValue < m) {
|
|
m = currentValue;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError2 = true;
|
|
_iteratorError2 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
_iterator2.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError2) {
|
|
throw _iteratorError2;
|
|
}
|
|
}
|
|
}
|
|
var handledCPCountPlusOne = handledCPCount + 1;
|
|
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
error$1("overflow");
|
|
}
|
|
delta += (m - n) * handledCPCountPlusOne;
|
|
n = m;
|
|
var _iteratorNormalCompletion3 = true;
|
|
var _didIteratorError3 = false;
|
|
var _iteratorError3 = undefined;
|
|
try {
|
|
for (var _iterator3 = input[Symbol.iterator](), _step3;!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
var _currentValue = _step3.value;
|
|
if (_currentValue < n && ++delta > maxInt) {
|
|
error$1("overflow");
|
|
}
|
|
if (_currentValue == n) {
|
|
var q = delta;
|
|
for (var k = base;; k += base) {
|
|
var t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
if (q < t) {
|
|
break;
|
|
}
|
|
var qMinusT = q - t;
|
|
var baseMinusT = base - t;
|
|
output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)));
|
|
q = floor(qMinusT / baseMinusT);
|
|
}
|
|
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
delta = 0;
|
|
++handledCPCount;
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_didIteratorError3 = true;
|
|
_iteratorError3 = err;
|
|
} finally {
|
|
try {
|
|
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
|
_iterator3.return();
|
|
}
|
|
} finally {
|
|
if (_didIteratorError3) {
|
|
throw _iteratorError3;
|
|
}
|
|
}
|
|
}
|
|
++delta;
|
|
++n;
|
|
}
|
|
return output.join("");
|
|
};
|
|
var toUnicode = function toUnicode(input) {
|
|
return mapDomain(input, function(string) {
|
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
});
|
|
};
|
|
var toASCII = function toASCII(input) {
|
|
return mapDomain(input, function(string) {
|
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
});
|
|
};
|
|
var punycode = {
|
|
version: "2.1.0",
|
|
ucs2: {
|
|
decode: ucs2decode,
|
|
encode: ucs2encode
|
|
},
|
|
decode,
|
|
encode,
|
|
toASCII,
|
|
toUnicode
|
|
};
|
|
var SCHEMES = {};
|
|
function pctEncChar(chr) {
|
|
var c = chr.charCodeAt(0);
|
|
var e = undefined;
|
|
if (c < 16)
|
|
e = "%0" + c.toString(16).toUpperCase();
|
|
else if (c < 128)
|
|
e = "%" + c.toString(16).toUpperCase();
|
|
else if (c < 2048)
|
|
e = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
|
|
else
|
|
e = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase();
|
|
return e;
|
|
}
|
|
function pctDecChars(str) {
|
|
var newStr = "";
|
|
var i = 0;
|
|
var il = str.length;
|
|
while (i < il) {
|
|
var c = parseInt(str.substr(i + 1, 2), 16);
|
|
if (c < 128) {
|
|
newStr += String.fromCharCode(c);
|
|
i += 3;
|
|
} else if (c >= 194 && c < 224) {
|
|
if (il - i >= 6) {
|
|
var c2 = parseInt(str.substr(i + 4, 2), 16);
|
|
newStr += String.fromCharCode((c & 31) << 6 | c2 & 63);
|
|
} else {
|
|
newStr += str.substr(i, 6);
|
|
}
|
|
i += 6;
|
|
} else if (c >= 224) {
|
|
if (il - i >= 9) {
|
|
var _c = parseInt(str.substr(i + 4, 2), 16);
|
|
var c3 = parseInt(str.substr(i + 7, 2), 16);
|
|
newStr += String.fromCharCode((c & 15) << 12 | (_c & 63) << 6 | c3 & 63);
|
|
} else {
|
|
newStr += str.substr(i, 9);
|
|
}
|
|
i += 9;
|
|
} else {
|
|
newStr += str.substr(i, 3);
|
|
i += 3;
|
|
}
|
|
}
|
|
return newStr;
|
|
}
|
|
function _normalizeComponentEncoding(components, protocol) {
|
|
function decodeUnreserved2(str) {
|
|
var decStr = pctDecChars(str);
|
|
return !decStr.match(protocol.UNRESERVED) ? str : decStr;
|
|
}
|
|
if (components.scheme)
|
|
components.scheme = String(components.scheme).replace(protocol.PCT_ENCODED, decodeUnreserved2).toLowerCase().replace(protocol.NOT_SCHEME, "");
|
|
if (components.userinfo !== undefined)
|
|
components.userinfo = String(components.userinfo).replace(protocol.PCT_ENCODED, decodeUnreserved2).replace(protocol.NOT_USERINFO, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
if (components.host !== undefined)
|
|
components.host = String(components.host).replace(protocol.PCT_ENCODED, decodeUnreserved2).toLowerCase().replace(protocol.NOT_HOST, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
if (components.path !== undefined)
|
|
components.path = String(components.path).replace(protocol.PCT_ENCODED, decodeUnreserved2).replace(components.scheme ? protocol.NOT_PATH : protocol.NOT_PATH_NOSCHEME, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
if (components.query !== undefined)
|
|
components.query = String(components.query).replace(protocol.PCT_ENCODED, decodeUnreserved2).replace(protocol.NOT_QUERY, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
if (components.fragment !== undefined)
|
|
components.fragment = String(components.fragment).replace(protocol.PCT_ENCODED, decodeUnreserved2).replace(protocol.NOT_FRAGMENT, pctEncChar).replace(protocol.PCT_ENCODED, toUpperCase);
|
|
return components;
|
|
}
|
|
function _stripLeadingZeros(str) {
|
|
return str.replace(/^0*(.*)/, "$1") || "0";
|
|
}
|
|
function _normalizeIPv4(host, protocol) {
|
|
var matches = host.match(protocol.IPV4ADDRESS) || [];
|
|
var _matches = slicedToArray(matches, 2), address = _matches[1];
|
|
if (address) {
|
|
return address.split(".").map(_stripLeadingZeros).join(".");
|
|
} else {
|
|
return host;
|
|
}
|
|
}
|
|
function _normalizeIPv6(host, protocol) {
|
|
var matches = host.match(protocol.IPV6ADDRESS) || [];
|
|
var _matches2 = slicedToArray(matches, 3), address = _matches2[1], zone = _matches2[2];
|
|
if (address) {
|
|
var _address$toLowerCase$ = address.toLowerCase().split("::").reverse(), _address$toLowerCase$2 = slicedToArray(_address$toLowerCase$, 2), last = _address$toLowerCase$2[0], first = _address$toLowerCase$2[1];
|
|
var firstFields = first ? first.split(":").map(_stripLeadingZeros) : [];
|
|
var lastFields = last.split(":").map(_stripLeadingZeros);
|
|
var isLastFieldIPv4Address = protocol.IPV4ADDRESS.test(lastFields[lastFields.length - 1]);
|
|
var fieldCount = isLastFieldIPv4Address ? 7 : 8;
|
|
var lastFieldsStart = lastFields.length - fieldCount;
|
|
var fields = Array(fieldCount);
|
|
for (var x = 0;x < fieldCount; ++x) {
|
|
fields[x] = firstFields[x] || lastFields[lastFieldsStart + x] || "";
|
|
}
|
|
if (isLastFieldIPv4Address) {
|
|
fields[fieldCount - 1] = _normalizeIPv4(fields[fieldCount - 1], protocol);
|
|
}
|
|
var allZeroFields = fields.reduce(function(acc, field, index) {
|
|
if (!field || field === "0") {
|
|
var lastLongest = acc[acc.length - 1];
|
|
if (lastLongest && lastLongest.index + lastLongest.length === index) {
|
|
lastLongest.length++;
|
|
} else {
|
|
acc.push({ index, length: 1 });
|
|
}
|
|
}
|
|
return acc;
|
|
}, []);
|
|
var longestZeroFields = allZeroFields.sort(function(a, b) {
|
|
return b.length - a.length;
|
|
})[0];
|
|
var newHost = undefined;
|
|
if (longestZeroFields && longestZeroFields.length > 1) {
|
|
var newFirst = fields.slice(0, longestZeroFields.index);
|
|
var newLast = fields.slice(longestZeroFields.index + longestZeroFields.length);
|
|
newHost = newFirst.join(":") + "::" + newLast.join(":");
|
|
} else {
|
|
newHost = fields.join(":");
|
|
}
|
|
if (zone) {
|
|
newHost += "%" + zone;
|
|
}
|
|
return newHost;
|
|
} else {
|
|
return host;
|
|
}
|
|
}
|
|
var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
|
|
var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === undefined;
|
|
function parse(uriString) {
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
var components = {};
|
|
var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
if (options.reference === "suffix")
|
|
uriString = (options.scheme ? options.scheme + ":" : "") + "//" + uriString;
|
|
var matches = uriString.match(URI_PARSE);
|
|
if (matches) {
|
|
if (NO_MATCH_IS_UNDEFINED) {
|
|
components.scheme = matches[1];
|
|
components.userinfo = matches[3];
|
|
components.host = matches[4];
|
|
components.port = parseInt(matches[5], 10);
|
|
components.path = matches[6] || "";
|
|
components.query = matches[7];
|
|
components.fragment = matches[8];
|
|
if (isNaN(components.port)) {
|
|
components.port = matches[5];
|
|
}
|
|
} else {
|
|
components.scheme = matches[1] || undefined;
|
|
components.userinfo = uriString.indexOf("@") !== -1 ? matches[3] : undefined;
|
|
components.host = uriString.indexOf("//") !== -1 ? matches[4] : undefined;
|
|
components.port = parseInt(matches[5], 10);
|
|
components.path = matches[6] || "";
|
|
components.query = uriString.indexOf("?") !== -1 ? matches[7] : undefined;
|
|
components.fragment = uriString.indexOf("#") !== -1 ? matches[8] : undefined;
|
|
if (isNaN(components.port)) {
|
|
components.port = uriString.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? matches[4] : undefined;
|
|
}
|
|
}
|
|
if (components.host) {
|
|
components.host = _normalizeIPv6(_normalizeIPv4(components.host, protocol), protocol);
|
|
}
|
|
if (components.scheme === undefined && components.userinfo === undefined && components.host === undefined && components.port === undefined && !components.path && components.query === undefined) {
|
|
components.reference = "same-document";
|
|
} else if (components.scheme === undefined) {
|
|
components.reference = "relative";
|
|
} else if (components.fragment === undefined) {
|
|
components.reference = "absolute";
|
|
} else {
|
|
components.reference = "uri";
|
|
}
|
|
if (options.reference && options.reference !== "suffix" && options.reference !== components.reference) {
|
|
components.error = components.error || "URI is not a " + options.reference + " reference.";
|
|
}
|
|
var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
|
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
if (components.host && (options.domainHost || schemeHandler && schemeHandler.domainHost)) {
|
|
try {
|
|
components.host = punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase());
|
|
} catch (e) {
|
|
components.error = components.error || "Host's domain name can not be converted to ASCII via punycode: " + e;
|
|
}
|
|
}
|
|
_normalizeComponentEncoding(components, URI_PROTOCOL);
|
|
} else {
|
|
_normalizeComponentEncoding(components, protocol);
|
|
}
|
|
if (schemeHandler && schemeHandler.parse) {
|
|
schemeHandler.parse(components, options);
|
|
}
|
|
} else {
|
|
components.error = components.error || "URI can not be parsed.";
|
|
}
|
|
return components;
|
|
}
|
|
function _recomposeAuthority(components, options) {
|
|
var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
var uriTokens = [];
|
|
if (components.userinfo !== undefined) {
|
|
uriTokens.push(components.userinfo);
|
|
uriTokens.push("@");
|
|
}
|
|
if (components.host !== undefined) {
|
|
uriTokens.push(_normalizeIPv6(_normalizeIPv4(String(components.host), protocol), protocol).replace(protocol.IPV6ADDRESS, function(_, $1, $2) {
|
|
return "[" + $1 + ($2 ? "%25" + $2 : "") + "]";
|
|
}));
|
|
}
|
|
if (typeof components.port === "number" || typeof components.port === "string") {
|
|
uriTokens.push(":");
|
|
uriTokens.push(String(components.port));
|
|
}
|
|
return uriTokens.length ? uriTokens.join("") : undefined;
|
|
}
|
|
var RDS1 = /^\.\.?\//;
|
|
var RDS2 = /^\/\.(\/|$)/;
|
|
var RDS3 = /^\/\.\.(\/|$)/;
|
|
var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
|
|
function removeDotSegments(input) {
|
|
var output = [];
|
|
while (input.length) {
|
|
if (input.match(RDS1)) {
|
|
input = input.replace(RDS1, "");
|
|
} else if (input.match(RDS2)) {
|
|
input = input.replace(RDS2, "/");
|
|
} else if (input.match(RDS3)) {
|
|
input = input.replace(RDS3, "/");
|
|
output.pop();
|
|
} else if (input === "." || input === "..") {
|
|
input = "";
|
|
} else {
|
|
var im = input.match(RDS5);
|
|
if (im) {
|
|
var s = im[0];
|
|
input = input.slice(s.length);
|
|
output.push(s);
|
|
} else {
|
|
throw new Error("Unexpected dot segment condition");
|
|
}
|
|
}
|
|
}
|
|
return output.join("");
|
|
}
|
|
function serialize(components) {
|
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
var protocol = options.iri ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
var uriTokens = [];
|
|
var schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
|
|
if (schemeHandler && schemeHandler.serialize)
|
|
schemeHandler.serialize(components, options);
|
|
if (components.host) {
|
|
if (protocol.IPV6ADDRESS.test(components.host)) {} else if (options.domainHost || schemeHandler && schemeHandler.domainHost) {
|
|
try {
|
|
components.host = !options.iri ? punycode.toASCII(components.host.replace(protocol.PCT_ENCODED, pctDecChars).toLowerCase()) : punycode.toUnicode(components.host);
|
|
} catch (e) {
|
|
components.error = components.error || "Host's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
|
|
}
|
|
}
|
|
}
|
|
_normalizeComponentEncoding(components, protocol);
|
|
if (options.reference !== "suffix" && components.scheme) {
|
|
uriTokens.push(components.scheme);
|
|
uriTokens.push(":");
|
|
}
|
|
var authority = _recomposeAuthority(components, options);
|
|
if (authority !== undefined) {
|
|
if (options.reference !== "suffix") {
|
|
uriTokens.push("//");
|
|
}
|
|
uriTokens.push(authority);
|
|
if (components.path && components.path.charAt(0) !== "/") {
|
|
uriTokens.push("/");
|
|
}
|
|
}
|
|
if (components.path !== undefined) {
|
|
var s = components.path;
|
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
s = removeDotSegments(s);
|
|
}
|
|
if (authority === undefined) {
|
|
s = s.replace(/^\/\//, "/%2F");
|
|
}
|
|
uriTokens.push(s);
|
|
}
|
|
if (components.query !== undefined) {
|
|
uriTokens.push("?");
|
|
uriTokens.push(components.query);
|
|
}
|
|
if (components.fragment !== undefined) {
|
|
uriTokens.push("#");
|
|
uriTokens.push(components.fragment);
|
|
}
|
|
return uriTokens.join("");
|
|
}
|
|
function resolveComponents(base2, relative) {
|
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
var skipNormalization = arguments[3];
|
|
var target = {};
|
|
if (!skipNormalization) {
|
|
base2 = parse(serialize(base2, options), options);
|
|
relative = parse(serialize(relative, options), options);
|
|
}
|
|
options = options || {};
|
|
if (!options.tolerant && relative.scheme) {
|
|
target.scheme = relative.scheme;
|
|
target.userinfo = relative.userinfo;
|
|
target.host = relative.host;
|
|
target.port = relative.port;
|
|
target.path = removeDotSegments(relative.path || "");
|
|
target.query = relative.query;
|
|
} else {
|
|
if (relative.userinfo !== undefined || relative.host !== undefined || relative.port !== undefined) {
|
|
target.userinfo = relative.userinfo;
|
|
target.host = relative.host;
|
|
target.port = relative.port;
|
|
target.path = removeDotSegments(relative.path || "");
|
|
target.query = relative.query;
|
|
} else {
|
|
if (!relative.path) {
|
|
target.path = base2.path;
|
|
if (relative.query !== undefined) {
|
|
target.query = relative.query;
|
|
} else {
|
|
target.query = base2.query;
|
|
}
|
|
} else {
|
|
if (relative.path.charAt(0) === "/") {
|
|
target.path = removeDotSegments(relative.path);
|
|
} else {
|
|
if ((base2.userinfo !== undefined || base2.host !== undefined || base2.port !== undefined) && !base2.path) {
|
|
target.path = "/" + relative.path;
|
|
} else if (!base2.path) {
|
|
target.path = relative.path;
|
|
} else {
|
|
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative.path;
|
|
}
|
|
target.path = removeDotSegments(target.path);
|
|
}
|
|
target.query = relative.query;
|
|
}
|
|
target.userinfo = base2.userinfo;
|
|
target.host = base2.host;
|
|
target.port = base2.port;
|
|
}
|
|
target.scheme = base2.scheme;
|
|
}
|
|
target.fragment = relative.fragment;
|
|
return target;
|
|
}
|
|
function resolve(baseURI, relativeURI, options) {
|
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
return serialize(resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
}
|
|
function normalize(uri, options) {
|
|
if (typeof uri === "string") {
|
|
uri = serialize(parse(uri, options), options);
|
|
} else if (typeOf(uri) === "object") {
|
|
uri = parse(serialize(uri, options), options);
|
|
}
|
|
return uri;
|
|
}
|
|
function equal(uriA, uriB, options) {
|
|
if (typeof uriA === "string") {
|
|
uriA = serialize(parse(uriA, options), options);
|
|
} else if (typeOf(uriA) === "object") {
|
|
uriA = serialize(uriA, options);
|
|
}
|
|
if (typeof uriB === "string") {
|
|
uriB = serialize(parse(uriB, options), options);
|
|
} else if (typeOf(uriB) === "object") {
|
|
uriB = serialize(uriB, options);
|
|
}
|
|
return uriA === uriB;
|
|
}
|
|
function escapeComponent(str, options) {
|
|
return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.ESCAPE : IRI_PROTOCOL.ESCAPE, pctEncChar);
|
|
}
|
|
function unescapeComponent(str, options) {
|
|
return str && str.toString().replace(!options || !options.iri ? URI_PROTOCOL.PCT_ENCODED : IRI_PROTOCOL.PCT_ENCODED, pctDecChars);
|
|
}
|
|
var handler = {
|
|
scheme: "http",
|
|
domainHost: true,
|
|
parse: function parse(components, options) {
|
|
if (!components.host) {
|
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
}
|
|
return components;
|
|
},
|
|
serialize: function serialize(components, options) {
|
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
components.port = undefined;
|
|
}
|
|
if (!components.path) {
|
|
components.path = "/";
|
|
}
|
|
return components;
|
|
}
|
|
};
|
|
var handler$1 = {
|
|
scheme: "https",
|
|
domainHost: handler.domainHost,
|
|
parse: handler.parse,
|
|
serialize: handler.serialize
|
|
};
|
|
function isSecure(wsComponents) {
|
|
return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
|
|
}
|
|
var handler$2 = {
|
|
scheme: "ws",
|
|
domainHost: true,
|
|
parse: function parse(components, options) {
|
|
var wsComponents = components;
|
|
wsComponents.secure = isSecure(wsComponents);
|
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
wsComponents.path = undefined;
|
|
wsComponents.query = undefined;
|
|
return wsComponents;
|
|
},
|
|
serialize: function serialize(wsComponents, options) {
|
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
wsComponents.port = undefined;
|
|
}
|
|
if (typeof wsComponents.secure === "boolean") {
|
|
wsComponents.scheme = wsComponents.secure ? "wss" : "ws";
|
|
wsComponents.secure = undefined;
|
|
}
|
|
if (wsComponents.resourceName) {
|
|
var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path = _wsComponents$resourc2[0], query = _wsComponents$resourc2[1];
|
|
wsComponents.path = path && path !== "/" ? path : undefined;
|
|
wsComponents.query = query;
|
|
wsComponents.resourceName = undefined;
|
|
}
|
|
wsComponents.fragment = undefined;
|
|
return wsComponents;
|
|
}
|
|
};
|
|
var handler$3 = {
|
|
scheme: "wss",
|
|
domainHost: handler$2.domainHost,
|
|
parse: handler$2.parse,
|
|
serialize: handler$2.serialize
|
|
};
|
|
var O = {};
|
|
var isIRI = true;
|
|
var UNRESERVED$$ = "[A-Za-z0-9\\-\\.\\_\\~" + (isIRI ? "\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF" : "") + "]";
|
|
var HEXDIG$$ = "[0-9A-Fa-f]";
|
|
var PCT_ENCODED$ = subexp(subexp("%[EFef]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%[89A-Fa-f]" + HEXDIG$$ + "%" + HEXDIG$$ + HEXDIG$$) + "|" + subexp("%" + HEXDIG$$ + HEXDIG$$));
|
|
var ATEXT$$ = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]";
|
|
var QTEXT$$ = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]";
|
|
var VCHAR$$ = merge(QTEXT$$, "[\\\"\\\\]");
|
|
var SOME_DELIMS$$ = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]";
|
|
var UNRESERVED = new RegExp(UNRESERVED$$, "g");
|
|
var PCT_ENCODED = new RegExp(PCT_ENCODED$, "g");
|
|
var NOT_LOCAL_PART = new RegExp(merge("[^]", ATEXT$$, "[\\.]", "[\\\"]", VCHAR$$), "g");
|
|
var NOT_HFNAME = new RegExp(merge("[^]", UNRESERVED$$, SOME_DELIMS$$), "g");
|
|
var NOT_HFVALUE = NOT_HFNAME;
|
|
function decodeUnreserved(str) {
|
|
var decStr = pctDecChars(str);
|
|
return !decStr.match(UNRESERVED) ? str : decStr;
|
|
}
|
|
var handler$4 = {
|
|
scheme: "mailto",
|
|
parse: function parse$$1(components, options) {
|
|
var mailtoComponents = components;
|
|
var to = mailtoComponents.to = mailtoComponents.path ? mailtoComponents.path.split(",") : [];
|
|
mailtoComponents.path = undefined;
|
|
if (mailtoComponents.query) {
|
|
var unknownHeaders = false;
|
|
var headers = {};
|
|
var hfields = mailtoComponents.query.split("&");
|
|
for (var x = 0, xl = hfields.length;x < xl; ++x) {
|
|
var hfield = hfields[x].split("=");
|
|
switch (hfield[0]) {
|
|
case "to":
|
|
var toAddrs = hfield[1].split(",");
|
|
for (var _x = 0, _xl = toAddrs.length;_x < _xl; ++_x) {
|
|
to.push(toAddrs[_x]);
|
|
}
|
|
break;
|
|
case "subject":
|
|
mailtoComponents.subject = unescapeComponent(hfield[1], options);
|
|
break;
|
|
case "body":
|
|
mailtoComponents.body = unescapeComponent(hfield[1], options);
|
|
break;
|
|
default:
|
|
unknownHeaders = true;
|
|
headers[unescapeComponent(hfield[0], options)] = unescapeComponent(hfield[1], options);
|
|
break;
|
|
}
|
|
}
|
|
if (unknownHeaders)
|
|
mailtoComponents.headers = headers;
|
|
}
|
|
mailtoComponents.query = undefined;
|
|
for (var _x2 = 0, _xl2 = to.length;_x2 < _xl2; ++_x2) {
|
|
var addr = to[_x2].split("@");
|
|
addr[0] = unescapeComponent(addr[0]);
|
|
if (!options.unicodeSupport) {
|
|
try {
|
|
addr[1] = punycode.toASCII(unescapeComponent(addr[1], options).toLowerCase());
|
|
} catch (e) {
|
|
mailtoComponents.error = mailtoComponents.error || "Email address's domain name can not be converted to ASCII via punycode: " + e;
|
|
}
|
|
} else {
|
|
addr[1] = unescapeComponent(addr[1], options).toLowerCase();
|
|
}
|
|
to[_x2] = addr.join("@");
|
|
}
|
|
return mailtoComponents;
|
|
},
|
|
serialize: function serialize$$1(mailtoComponents, options) {
|
|
var components = mailtoComponents;
|
|
var to = toArray(mailtoComponents.to);
|
|
if (to) {
|
|
for (var x = 0, xl = to.length;x < xl; ++x) {
|
|
var toAddr = String(to[x]);
|
|
var atIdx = toAddr.lastIndexOf("@");
|
|
var localPart = toAddr.slice(0, atIdx).replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_LOCAL_PART, pctEncChar);
|
|
var domain = toAddr.slice(atIdx + 1);
|
|
try {
|
|
domain = !options.iri ? punycode.toASCII(unescapeComponent(domain, options).toLowerCase()) : punycode.toUnicode(domain);
|
|
} catch (e) {
|
|
components.error = components.error || "Email address's domain name can not be converted to " + (!options.iri ? "ASCII" : "Unicode") + " via punycode: " + e;
|
|
}
|
|
to[x] = localPart + "@" + domain;
|
|
}
|
|
components.path = to.join(",");
|
|
}
|
|
var headers = mailtoComponents.headers = mailtoComponents.headers || {};
|
|
if (mailtoComponents.subject)
|
|
headers["subject"] = mailtoComponents.subject;
|
|
if (mailtoComponents.body)
|
|
headers["body"] = mailtoComponents.body;
|
|
var fields = [];
|
|
for (var name in headers) {
|
|
if (headers[name] !== O[name]) {
|
|
fields.push(name.replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFNAME, pctEncChar) + "=" + headers[name].replace(PCT_ENCODED, decodeUnreserved).replace(PCT_ENCODED, toUpperCase).replace(NOT_HFVALUE, pctEncChar));
|
|
}
|
|
}
|
|
if (fields.length) {
|
|
components.query = fields.join("&");
|
|
}
|
|
return components;
|
|
}
|
|
};
|
|
var URN_PARSE = /^([^\:]+)\:(.*)/;
|
|
var handler$5 = {
|
|
scheme: "urn",
|
|
parse: function parse$$1(components, options) {
|
|
var matches = components.path && components.path.match(URN_PARSE);
|
|
var urnComponents = components;
|
|
if (matches) {
|
|
var scheme = options.scheme || urnComponents.scheme || "urn";
|
|
var nid = matches[1].toLowerCase();
|
|
var nss = matches[2];
|
|
var urnScheme = scheme + ":" + (options.nid || nid);
|
|
var schemeHandler = SCHEMES[urnScheme];
|
|
urnComponents.nid = nid;
|
|
urnComponents.nss = nss;
|
|
urnComponents.path = undefined;
|
|
if (schemeHandler) {
|
|
urnComponents = schemeHandler.parse(urnComponents, options);
|
|
}
|
|
} else {
|
|
urnComponents.error = urnComponents.error || "URN can not be parsed.";
|
|
}
|
|
return urnComponents;
|
|
},
|
|
serialize: function serialize$$1(urnComponents, options) {
|
|
var scheme = options.scheme || urnComponents.scheme || "urn";
|
|
var nid = urnComponents.nid;
|
|
var urnScheme = scheme + ":" + (options.nid || nid);
|
|
var schemeHandler = SCHEMES[urnScheme];
|
|
if (schemeHandler) {
|
|
urnComponents = schemeHandler.serialize(urnComponents, options);
|
|
}
|
|
var uriComponents = urnComponents;
|
|
var nss = urnComponents.nss;
|
|
uriComponents.path = (nid || options.nid) + ":" + nss;
|
|
return uriComponents;
|
|
}
|
|
};
|
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
var handler$6 = {
|
|
scheme: "urn:uuid",
|
|
parse: function parse(urnComponents, options) {
|
|
var uuidComponents = urnComponents;
|
|
uuidComponents.uuid = uuidComponents.nss;
|
|
uuidComponents.nss = undefined;
|
|
if (!options.tolerant && (!uuidComponents.uuid || !uuidComponents.uuid.match(UUID))) {
|
|
uuidComponents.error = uuidComponents.error || "UUID is not valid.";
|
|
}
|
|
return uuidComponents;
|
|
},
|
|
serialize: function serialize(uuidComponents, options) {
|
|
var urnComponents = uuidComponents;
|
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
return urnComponents;
|
|
}
|
|
};
|
|
SCHEMES[handler.scheme] = handler;
|
|
SCHEMES[handler$1.scheme] = handler$1;
|
|
SCHEMES[handler$2.scheme] = handler$2;
|
|
SCHEMES[handler$3.scheme] = handler$3;
|
|
SCHEMES[handler$4.scheme] = handler$4;
|
|
SCHEMES[handler$5.scheme] = handler$5;
|
|
SCHEMES[handler$6.scheme] = handler$6;
|
|
exports2.SCHEMES = SCHEMES;
|
|
exports2.pctEncChar = pctEncChar;
|
|
exports2.pctDecChars = pctDecChars;
|
|
exports2.parse = parse;
|
|
exports2.removeDotSegments = removeDotSegments;
|
|
exports2.serialize = serialize;
|
|
exports2.resolveComponents = resolveComponents;
|
|
exports2.resolve = resolve;
|
|
exports2.normalize = normalize;
|
|
exports2.equal = equal;
|
|
exports2.escapeComponent = escapeComponent;
|
|
exports2.unescapeComponent = unescapeComponent;
|
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
});
|
|
});
|
|
|
|
// node_modules/fast-deep-equal/index.js
|
|
var require_fast_deep_equal = __commonJS((exports, module) => {
|
|
module.exports = function equal(a, b) {
|
|
if (a === b)
|
|
return true;
|
|
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
if (a.constructor !== b.constructor)
|
|
return false;
|
|
var length, i, keys;
|
|
if (Array.isArray(a)) {
|
|
length = a.length;
|
|
if (length != b.length)
|
|
return false;
|
|
for (i = length;i-- !== 0; )
|
|
if (!equal(a[i], b[i]))
|
|
return false;
|
|
return true;
|
|
}
|
|
if (a.constructor === RegExp)
|
|
return a.source === b.source && a.flags === b.flags;
|
|
if (a.valueOf !== Object.prototype.valueOf)
|
|
return a.valueOf() === b.valueOf();
|
|
if (a.toString !== Object.prototype.toString)
|
|
return a.toString() === b.toString();
|
|
keys = Object.keys(a);
|
|
length = keys.length;
|
|
if (length !== Object.keys(b).length)
|
|
return false;
|
|
for (i = length;i-- !== 0; )
|
|
if (!Object.prototype.hasOwnProperty.call(b, keys[i]))
|
|
return false;
|
|
for (i = length;i-- !== 0; ) {
|
|
var key = keys[i];
|
|
if (!equal(a[key], b[key]))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
return a !== a && b !== b;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/ucs2length.js
|
|
var require_ucs2length = __commonJS((exports, module) => {
|
|
module.exports = function ucs2length(str) {
|
|
var length = 0, len = str.length, pos = 0, value;
|
|
while (pos < len) {
|
|
length++;
|
|
value = str.charCodeAt(pos++);
|
|
if (value >= 55296 && value <= 56319 && pos < len) {
|
|
value = str.charCodeAt(pos);
|
|
if ((value & 64512) == 56320)
|
|
pos++;
|
|
}
|
|
}
|
|
return length;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/util.js
|
|
var require_util = __commonJS((exports, module) => {
|
|
module.exports = {
|
|
copy,
|
|
checkDataType,
|
|
checkDataTypes,
|
|
coerceToTypes,
|
|
toHash,
|
|
getProperty,
|
|
escapeQuotes,
|
|
equal: require_fast_deep_equal(),
|
|
ucs2length: require_ucs2length(),
|
|
varOccurences,
|
|
varReplace,
|
|
schemaHasRules,
|
|
schemaHasRulesExcept,
|
|
schemaUnknownRules,
|
|
toQuotedString,
|
|
getPathExpr,
|
|
getPath,
|
|
getData,
|
|
unescapeFragment,
|
|
unescapeJsonPointer,
|
|
escapeFragment,
|
|
escapeJsonPointer
|
|
};
|
|
function copy(o, to) {
|
|
to = to || {};
|
|
for (var key in o)
|
|
to[key] = o[key];
|
|
return to;
|
|
}
|
|
function checkDataType(dataType, data, strictNumbers, negate) {
|
|
var EQUAL = negate ? " !== " : " === ", AND = negate ? " || " : " && ", OK2 = negate ? "!" : "", NOT = negate ? "" : "!";
|
|
switch (dataType) {
|
|
case "null":
|
|
return data + EQUAL + "null";
|
|
case "array":
|
|
return OK2 + "Array.isArray(" + data + ")";
|
|
case "object":
|
|
return "(" + OK2 + data + AND + "typeof " + data + EQUAL + '"object"' + AND + NOT + "Array.isArray(" + data + "))";
|
|
case "integer":
|
|
return "(typeof " + data + EQUAL + '"number"' + AND + NOT + "(" + data + " % 1)" + AND + data + EQUAL + data + (strictNumbers ? AND + OK2 + "isFinite(" + data + ")" : "") + ")";
|
|
case "number":
|
|
return "(typeof " + data + EQUAL + '"' + dataType + '"' + (strictNumbers ? AND + OK2 + "isFinite(" + data + ")" : "") + ")";
|
|
default:
|
|
return "typeof " + data + EQUAL + '"' + dataType + '"';
|
|
}
|
|
}
|
|
function checkDataTypes(dataTypes, data, strictNumbers) {
|
|
switch (dataTypes.length) {
|
|
case 1:
|
|
return checkDataType(dataTypes[0], data, strictNumbers, true);
|
|
default:
|
|
var code = "";
|
|
var types2 = toHash(dataTypes);
|
|
if (types2.array && types2.object) {
|
|
code = types2.null ? "(" : "(!" + data + " || ";
|
|
code += "typeof " + data + ' !== "object")';
|
|
delete types2.null;
|
|
delete types2.array;
|
|
delete types2.object;
|
|
}
|
|
if (types2.number)
|
|
delete types2.integer;
|
|
for (var t in types2)
|
|
code += (code ? " && " : "") + checkDataType(t, data, strictNumbers, true);
|
|
return code;
|
|
}
|
|
}
|
|
var COERCE_TO_TYPES = toHash(["string", "number", "integer", "boolean", "null"]);
|
|
function coerceToTypes(optionCoerceTypes, dataTypes) {
|
|
if (Array.isArray(dataTypes)) {
|
|
var types2 = [];
|
|
for (var i = 0;i < dataTypes.length; i++) {
|
|
var t = dataTypes[i];
|
|
if (COERCE_TO_TYPES[t])
|
|
types2[types2.length] = t;
|
|
else if (optionCoerceTypes === "array" && t === "array")
|
|
types2[types2.length] = t;
|
|
}
|
|
if (types2.length)
|
|
return types2;
|
|
} else if (COERCE_TO_TYPES[dataTypes]) {
|
|
return [dataTypes];
|
|
} else if (optionCoerceTypes === "array" && dataTypes === "array") {
|
|
return ["array"];
|
|
}
|
|
}
|
|
function toHash(arr) {
|
|
var hash = {};
|
|
for (var i = 0;i < arr.length; i++)
|
|
hash[arr[i]] = true;
|
|
return hash;
|
|
}
|
|
var IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
|
var SINGLE_QUOTE = /'|\\/g;
|
|
function getProperty(key) {
|
|
return typeof key == "number" ? "[" + key + "]" : IDENTIFIER.test(key) ? "." + key : "['" + escapeQuotes(key) + "']";
|
|
}
|
|
function escapeQuotes(str) {
|
|
return str.replace(SINGLE_QUOTE, "\\$&").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\f/g, "\\f").replace(/\t/g, "\\t");
|
|
}
|
|
function varOccurences(str, dataVar) {
|
|
dataVar += "[^0-9]";
|
|
var matches = str.match(new RegExp(dataVar, "g"));
|
|
return matches ? matches.length : 0;
|
|
}
|
|
function varReplace(str, dataVar, expr) {
|
|
dataVar += "([^0-9])";
|
|
expr = expr.replace(/\$/g, "$$$$");
|
|
return str.replace(new RegExp(dataVar, "g"), expr + "$1");
|
|
}
|
|
function schemaHasRules(schema, rules) {
|
|
if (typeof schema == "boolean")
|
|
return !schema;
|
|
for (var key in schema)
|
|
if (rules[key])
|
|
return true;
|
|
}
|
|
function schemaHasRulesExcept(schema, rules, exceptKeyword) {
|
|
if (typeof schema == "boolean")
|
|
return !schema && exceptKeyword != "not";
|
|
for (var key in schema)
|
|
if (key != exceptKeyword && rules[key])
|
|
return true;
|
|
}
|
|
function schemaUnknownRules(schema, rules) {
|
|
if (typeof schema == "boolean")
|
|
return;
|
|
for (var key in schema)
|
|
if (!rules[key])
|
|
return key;
|
|
}
|
|
function toQuotedString(str) {
|
|
return "'" + escapeQuotes(str) + "'";
|
|
}
|
|
function getPathExpr(currentPath, expr, jsonPointers, isNumber) {
|
|
var path = jsonPointers ? "'/' + " + expr + (isNumber ? "" : ".replace(/~/g, '~0').replace(/\\//g, '~1')") : isNumber ? "'[' + " + expr + " + ']'" : "'[\\'' + " + expr + " + '\\']'";
|
|
return joinPaths(currentPath, path);
|
|
}
|
|
function getPath(currentPath, prop, jsonPointers) {
|
|
var path = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
|
|
return joinPaths(currentPath, path);
|
|
}
|
|
var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
function getData($data, lvl, paths) {
|
|
var up, jsonPointer, data, matches;
|
|
if ($data === "")
|
|
return "rootData";
|
|
if ($data[0] == "/") {
|
|
if (!JSON_POINTER.test($data))
|
|
throw new Error("Invalid JSON-pointer: " + $data);
|
|
jsonPointer = $data;
|
|
data = "rootData";
|
|
} else {
|
|
matches = $data.match(RELATIVE_JSON_POINTER);
|
|
if (!matches)
|
|
throw new Error("Invalid JSON-pointer: " + $data);
|
|
up = +matches[1];
|
|
jsonPointer = matches[2];
|
|
if (jsonPointer == "#") {
|
|
if (up >= lvl)
|
|
throw new Error("Cannot access property/index " + up + " levels up, current level is " + lvl);
|
|
return paths[lvl - up];
|
|
}
|
|
if (up > lvl)
|
|
throw new Error("Cannot access data " + up + " levels up, current level is " + lvl);
|
|
data = "data" + (lvl - up || "");
|
|
if (!jsonPointer)
|
|
return data;
|
|
}
|
|
var expr = data;
|
|
var segments = jsonPointer.split("/");
|
|
for (var i = 0;i < segments.length; i++) {
|
|
var segment = segments[i];
|
|
if (segment) {
|
|
data += getProperty(unescapeJsonPointer(segment));
|
|
expr += " && " + data;
|
|
}
|
|
}
|
|
return expr;
|
|
}
|
|
function joinPaths(a, b) {
|
|
if (a == '""')
|
|
return b;
|
|
return (a + " + " + b).replace(/([^\\])' \+ '/g, "$1");
|
|
}
|
|
function unescapeFragment(str) {
|
|
return unescapeJsonPointer(decodeURIComponent(str));
|
|
}
|
|
function escapeFragment(str) {
|
|
return encodeURIComponent(escapeJsonPointer(str));
|
|
}
|
|
function escapeJsonPointer(str) {
|
|
return str.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
}
|
|
function unescapeJsonPointer(str) {
|
|
return str.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/schema_obj.js
|
|
var require_schema_obj = __commonJS((exports, module) => {
|
|
var util3 = require_util();
|
|
module.exports = SchemaObject;
|
|
function SchemaObject(obj) {
|
|
util3.copy(obj, this);
|
|
}
|
|
});
|
|
|
|
// node_modules/json-schema-traverse/index.js
|
|
var require_json_schema_traverse = __commonJS((exports, module) => {
|
|
var traverse = module.exports = function(schema, opts, cb) {
|
|
if (typeof opts == "function") {
|
|
cb = opts;
|
|
opts = {};
|
|
}
|
|
cb = opts.cb || cb;
|
|
var pre = typeof cb == "function" ? cb : cb.pre || function() {};
|
|
var post = cb.post || function() {};
|
|
_traverse(opts, pre, post, schema, "", schema);
|
|
};
|
|
traverse.keywords = {
|
|
additionalItems: true,
|
|
items: true,
|
|
contains: true,
|
|
additionalProperties: true,
|
|
propertyNames: true,
|
|
not: true
|
|
};
|
|
traverse.arrayKeywords = {
|
|
items: true,
|
|
allOf: true,
|
|
anyOf: true,
|
|
oneOf: true
|
|
};
|
|
traverse.propsKeywords = {
|
|
definitions: true,
|
|
properties: true,
|
|
patternProperties: true,
|
|
dependencies: true
|
|
};
|
|
traverse.skipKeywords = {
|
|
default: true,
|
|
enum: true,
|
|
const: true,
|
|
required: true,
|
|
maximum: true,
|
|
minimum: true,
|
|
exclusiveMaximum: true,
|
|
exclusiveMinimum: true,
|
|
multipleOf: true,
|
|
maxLength: true,
|
|
minLength: true,
|
|
pattern: true,
|
|
format: true,
|
|
maxItems: true,
|
|
minItems: true,
|
|
uniqueItems: true,
|
|
maxProperties: true,
|
|
minProperties: true
|
|
};
|
|
function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
if (schema && typeof schema == "object" && !Array.isArray(schema)) {
|
|
pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
for (var key in schema) {
|
|
var sch = schema[key];
|
|
if (Array.isArray(sch)) {
|
|
if (key in traverse.arrayKeywords) {
|
|
for (var i = 0;i < sch.length; i++)
|
|
_traverse(opts, pre, post, sch[i], jsonPtr + "/" + key + "/" + i, rootSchema, jsonPtr, key, schema, i);
|
|
}
|
|
} else if (key in traverse.propsKeywords) {
|
|
if (sch && typeof sch == "object") {
|
|
for (var prop in sch)
|
|
_traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
|
|
}
|
|
} else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) {
|
|
_traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
|
|
}
|
|
}
|
|
post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
|
|
}
|
|
}
|
|
function escapeJsonPtr(str) {
|
|
return str.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/resolve.js
|
|
var require_resolve = __commonJS((exports, module) => {
|
|
var URI = require_uri_all();
|
|
var equal = require_fast_deep_equal();
|
|
var util3 = require_util();
|
|
var SchemaObject = require_schema_obj();
|
|
var traverse = require_json_schema_traverse();
|
|
module.exports = resolve;
|
|
resolve.normalizeId = normalizeId;
|
|
resolve.fullPath = getFullPath;
|
|
resolve.url = resolveUrl;
|
|
resolve.ids = resolveIds;
|
|
resolve.inlineRef = inlineRef;
|
|
resolve.schema = resolveSchema;
|
|
function resolve(compile, root, ref) {
|
|
var refVal = this._refs[ref];
|
|
if (typeof refVal == "string") {
|
|
if (this._refs[refVal])
|
|
refVal = this._refs[refVal];
|
|
else
|
|
return resolve.call(this, compile, root, refVal);
|
|
}
|
|
refVal = refVal || this._schemas[ref];
|
|
if (refVal instanceof SchemaObject) {
|
|
return inlineRef(refVal.schema, this._opts.inlineRefs) ? refVal.schema : refVal.validate || this._compile(refVal);
|
|
}
|
|
var res = resolveSchema.call(this, root, ref);
|
|
var schema, v, baseId;
|
|
if (res) {
|
|
schema = res.schema;
|
|
root = res.root;
|
|
baseId = res.baseId;
|
|
}
|
|
if (schema instanceof SchemaObject) {
|
|
v = schema.validate || compile.call(this, schema.schema, root, undefined, baseId);
|
|
} else if (schema !== undefined) {
|
|
v = inlineRef(schema, this._opts.inlineRefs) ? schema : compile.call(this, schema, root, undefined, baseId);
|
|
}
|
|
return v;
|
|
}
|
|
function resolveSchema(root, ref) {
|
|
var p = URI.parse(ref), refPath = _getFullPath(p), baseId = getFullPath(this._getId(root.schema));
|
|
if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
|
|
var id = normalizeId(refPath);
|
|
var refVal = this._refs[id];
|
|
if (typeof refVal == "string") {
|
|
return resolveRecursive.call(this, root, refVal, p);
|
|
} else if (refVal instanceof SchemaObject) {
|
|
if (!refVal.validate)
|
|
this._compile(refVal);
|
|
root = refVal;
|
|
} else {
|
|
refVal = this._schemas[id];
|
|
if (refVal instanceof SchemaObject) {
|
|
if (!refVal.validate)
|
|
this._compile(refVal);
|
|
if (id == normalizeId(ref))
|
|
return { schema: refVal, root, baseId };
|
|
root = refVal;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (!root.schema)
|
|
return;
|
|
baseId = getFullPath(this._getId(root.schema));
|
|
}
|
|
return getJsonPointer.call(this, p, baseId, root.schema, root);
|
|
}
|
|
function resolveRecursive(root, ref, parsedRef) {
|
|
var res = resolveSchema.call(this, root, ref);
|
|
if (res) {
|
|
var schema = res.schema;
|
|
var baseId = res.baseId;
|
|
root = res.root;
|
|
var id = this._getId(schema);
|
|
if (id)
|
|
baseId = resolveUrl(baseId, id);
|
|
return getJsonPointer.call(this, parsedRef, baseId, schema, root);
|
|
}
|
|
}
|
|
var PREVENT_SCOPE_CHANGE = util3.toHash(["properties", "patternProperties", "enum", "dependencies", "definitions"]);
|
|
function getJsonPointer(parsedRef, baseId, schema, root) {
|
|
parsedRef.fragment = parsedRef.fragment || "";
|
|
if (parsedRef.fragment.slice(0, 1) != "/")
|
|
return;
|
|
var parts = parsedRef.fragment.split("/");
|
|
for (var i = 1;i < parts.length; i++) {
|
|
var part = parts[i];
|
|
if (part) {
|
|
part = util3.unescapeFragment(part);
|
|
schema = schema[part];
|
|
if (schema === undefined)
|
|
break;
|
|
var id;
|
|
if (!PREVENT_SCOPE_CHANGE[part]) {
|
|
id = this._getId(schema);
|
|
if (id)
|
|
baseId = resolveUrl(baseId, id);
|
|
if (schema.$ref) {
|
|
var $ref = resolveUrl(baseId, schema.$ref);
|
|
var res = resolveSchema.call(this, root, $ref);
|
|
if (res) {
|
|
schema = res.schema;
|
|
root = res.root;
|
|
baseId = res.baseId;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (schema !== undefined && schema !== root.schema)
|
|
return { schema, root, baseId };
|
|
}
|
|
var SIMPLE_INLINED = util3.toHash([
|
|
"type",
|
|
"format",
|
|
"pattern",
|
|
"maxLength",
|
|
"minLength",
|
|
"maxProperties",
|
|
"minProperties",
|
|
"maxItems",
|
|
"minItems",
|
|
"maximum",
|
|
"minimum",
|
|
"uniqueItems",
|
|
"multipleOf",
|
|
"required",
|
|
"enum"
|
|
]);
|
|
function inlineRef(schema, limit) {
|
|
if (limit === false)
|
|
return false;
|
|
if (limit === undefined || limit === true)
|
|
return checkNoRef(schema);
|
|
else if (limit)
|
|
return countKeys(schema) <= limit;
|
|
}
|
|
function checkNoRef(schema) {
|
|
var item;
|
|
if (Array.isArray(schema)) {
|
|
for (var i = 0;i < schema.length; i++) {
|
|
item = schema[i];
|
|
if (typeof item == "object" && !checkNoRef(item))
|
|
return false;
|
|
}
|
|
} else {
|
|
for (var key in schema) {
|
|
if (key == "$ref")
|
|
return false;
|
|
item = schema[key];
|
|
if (typeof item == "object" && !checkNoRef(item))
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function countKeys(schema) {
|
|
var count = 0, item;
|
|
if (Array.isArray(schema)) {
|
|
for (var i = 0;i < schema.length; i++) {
|
|
item = schema[i];
|
|
if (typeof item == "object")
|
|
count += countKeys(item);
|
|
if (count == Infinity)
|
|
return Infinity;
|
|
}
|
|
} else {
|
|
for (var key in schema) {
|
|
if (key == "$ref")
|
|
return Infinity;
|
|
if (SIMPLE_INLINED[key]) {
|
|
count++;
|
|
} else {
|
|
item = schema[key];
|
|
if (typeof item == "object")
|
|
count += countKeys(item) + 1;
|
|
if (count == Infinity)
|
|
return Infinity;
|
|
}
|
|
}
|
|
}
|
|
return count;
|
|
}
|
|
function getFullPath(id, normalize) {
|
|
if (normalize !== false)
|
|
id = normalizeId(id);
|
|
var p = URI.parse(id);
|
|
return _getFullPath(p);
|
|
}
|
|
function _getFullPath(p) {
|
|
return URI.serialize(p).split("#")[0] + "#";
|
|
}
|
|
var TRAILING_SLASH_HASH = /#\/?$/;
|
|
function normalizeId(id) {
|
|
return id ? id.replace(TRAILING_SLASH_HASH, "") : "";
|
|
}
|
|
function resolveUrl(baseId, id) {
|
|
id = normalizeId(id);
|
|
return URI.resolve(baseId, id);
|
|
}
|
|
function resolveIds(schema) {
|
|
var schemaId = normalizeId(this._getId(schema));
|
|
var baseIds = { "": schemaId };
|
|
var fullPaths = { "": getFullPath(schemaId, false) };
|
|
var localRefs = {};
|
|
var self = this;
|
|
traverse(schema, { allKeys: true }, function(sch, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
|
|
if (jsonPtr === "")
|
|
return;
|
|
var id = self._getId(sch);
|
|
var baseId = baseIds[parentJsonPtr];
|
|
var fullPath = fullPaths[parentJsonPtr] + "/" + parentKeyword;
|
|
if (keyIndex !== undefined)
|
|
fullPath += "/" + (typeof keyIndex == "number" ? keyIndex : util3.escapeFragment(keyIndex));
|
|
if (typeof id == "string") {
|
|
id = baseId = normalizeId(baseId ? URI.resolve(baseId, id) : id);
|
|
var refVal = self._refs[id];
|
|
if (typeof refVal == "string")
|
|
refVal = self._refs[refVal];
|
|
if (refVal && refVal.schema) {
|
|
if (!equal(sch, refVal.schema))
|
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
|
} else if (id != normalizeId(fullPath)) {
|
|
if (id[0] == "#") {
|
|
if (localRefs[id] && !equal(sch, localRefs[id]))
|
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
|
localRefs[id] = sch;
|
|
} else {
|
|
self._refs[id] = fullPath;
|
|
}
|
|
}
|
|
}
|
|
baseIds[jsonPtr] = baseId;
|
|
fullPaths[jsonPtr] = fullPath;
|
|
});
|
|
return localRefs;
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/error_classes.js
|
|
var require_error_classes = __commonJS((exports, module) => {
|
|
var resolve = require_resolve();
|
|
module.exports = {
|
|
Validation: errorSubclass(ValidationError),
|
|
MissingRef: errorSubclass(MissingRefError)
|
|
};
|
|
function ValidationError(errors2) {
|
|
this.message = "validation failed";
|
|
this.errors = errors2;
|
|
this.ajv = this.validation = true;
|
|
}
|
|
MissingRefError.message = function(baseId, ref) {
|
|
return "can't resolve reference " + ref + " from id " + baseId;
|
|
};
|
|
function MissingRefError(baseId, ref, message) {
|
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
this.missingRef = resolve.url(baseId, ref);
|
|
this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
|
|
}
|
|
function errorSubclass(Subclass) {
|
|
Subclass.prototype = Object.create(Error.prototype);
|
|
Subclass.prototype.constructor = Subclass;
|
|
return Subclass;
|
|
}
|
|
});
|
|
|
|
// node_modules/fast-json-stable-stringify/index.js
|
|
var require_fast_json_stable_stringify = __commonJS((exports, module) => {
|
|
module.exports = function(data, opts) {
|
|
if (!opts)
|
|
opts = {};
|
|
if (typeof opts === "function")
|
|
opts = { cmp: opts };
|
|
var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
|
|
var cmp = opts.cmp && function(f) {
|
|
return function(node) {
|
|
return function(a, b) {
|
|
var aobj = { key: a, value: node[a] };
|
|
var bobj = { key: b, value: node[b] };
|
|
return f(aobj, bobj);
|
|
};
|
|
};
|
|
}(opts.cmp);
|
|
var seen = [];
|
|
return function stringify(node) {
|
|
if (node && node.toJSON && typeof node.toJSON === "function") {
|
|
node = node.toJSON();
|
|
}
|
|
if (node === undefined)
|
|
return;
|
|
if (typeof node == "number")
|
|
return isFinite(node) ? "" + node : "null";
|
|
if (typeof node !== "object")
|
|
return JSON.stringify(node);
|
|
var i, out;
|
|
if (Array.isArray(node)) {
|
|
out = "[";
|
|
for (i = 0;i < node.length; i++) {
|
|
if (i)
|
|
out += ",";
|
|
out += stringify(node[i]) || "null";
|
|
}
|
|
return out + "]";
|
|
}
|
|
if (node === null)
|
|
return "null";
|
|
if (seen.indexOf(node) !== -1) {
|
|
if (cycles)
|
|
return JSON.stringify("__cycle__");
|
|
throw new TypeError("Converting circular structure to JSON");
|
|
}
|
|
var seenIndex = seen.push(node) - 1;
|
|
var keys = Object.keys(node).sort(cmp && cmp(node));
|
|
out = "";
|
|
for (i = 0;i < keys.length; i++) {
|
|
var key = keys[i];
|
|
var value = stringify(node[key]);
|
|
if (!value)
|
|
continue;
|
|
if (out)
|
|
out += ",";
|
|
out += JSON.stringify(key) + ":" + value;
|
|
}
|
|
seen.splice(seenIndex, 1);
|
|
return "{" + out + "}";
|
|
}(data);
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/validate.js
|
|
var require_validate = __commonJS((exports, module) => {
|
|
module.exports = function generate_validate(it, $keyword, $ruleType) {
|
|
var out = "";
|
|
var $async = it.schema.$async === true, $refKeywords = it.util.schemaHasRulesExcept(it.schema, it.RULES.all, "$ref"), $id = it.self._getId(it.schema);
|
|
if (it.opts.strictKeywords) {
|
|
var $unknownKwd = it.util.schemaUnknownRules(it.schema, it.RULES.keywords);
|
|
if ($unknownKwd) {
|
|
var $keywordsMsg = "unknown keyword: " + $unknownKwd;
|
|
if (it.opts.strictKeywords === "log")
|
|
it.logger.warn($keywordsMsg);
|
|
else
|
|
throw new Error($keywordsMsg);
|
|
}
|
|
}
|
|
if (it.isTop) {
|
|
out += " var validate = ";
|
|
if ($async) {
|
|
it.async = true;
|
|
out += "async ";
|
|
}
|
|
out += "function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ";
|
|
if ($id && (it.opts.sourceCode || it.opts.processCode)) {
|
|
out += " " + ("/*# sourceURL=" + $id + " */") + " ";
|
|
}
|
|
}
|
|
if (typeof it.schema == "boolean" || !($refKeywords || it.schema.$ref)) {
|
|
var $keyword = "false schema";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $errorKeyword;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
if (it.schema === false) {
|
|
if (it.isTop) {
|
|
$breakOnError = true;
|
|
} else {
|
|
out += " var " + $valid + " = false; ";
|
|
}
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "false schema") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: {} ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'boolean schema is false' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: false , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
} else {
|
|
if (it.isTop) {
|
|
if ($async) {
|
|
out += " return data; ";
|
|
} else {
|
|
out += " validate.errors = null; return true; ";
|
|
}
|
|
} else {
|
|
out += " var " + $valid + " = true; ";
|
|
}
|
|
}
|
|
if (it.isTop) {
|
|
out += " }; return validate; ";
|
|
}
|
|
return out;
|
|
}
|
|
if (it.isTop) {
|
|
var $top = it.isTop, $lvl = it.level = 0, $dataLvl = it.dataLevel = 0, $data = "data";
|
|
it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema));
|
|
it.baseId = it.baseId || it.rootId;
|
|
delete it.isTop;
|
|
it.dataPathArr = [""];
|
|
if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) {
|
|
var $defaultMsg = "default is ignored in the schema root";
|
|
if (it.opts.strictDefaults === "log")
|
|
it.logger.warn($defaultMsg);
|
|
else
|
|
throw new Error($defaultMsg);
|
|
}
|
|
out += " var vErrors = null; ";
|
|
out += " var errors = 0; ";
|
|
out += " if (rootData === undefined) rootData = data; ";
|
|
} else {
|
|
var { level: $lvl, dataLevel: $dataLvl } = it, $data = "data" + ($dataLvl || "");
|
|
if ($id)
|
|
it.baseId = it.resolve.url(it.baseId, $id);
|
|
if ($async && !it.async)
|
|
throw new Error("async schema in sync schema");
|
|
out += " var errs_" + $lvl + " = errors;";
|
|
}
|
|
var $valid = "valid" + $lvl, $breakOnError = !it.opts.allErrors, $closingBraces1 = "", $closingBraces2 = "";
|
|
var $errorKeyword;
|
|
var $typeSchema = it.schema.type, $typeIsArray = Array.isArray($typeSchema);
|
|
if ($typeSchema && it.opts.nullable && it.schema.nullable === true) {
|
|
if ($typeIsArray) {
|
|
if ($typeSchema.indexOf("null") == -1)
|
|
$typeSchema = $typeSchema.concat("null");
|
|
} else if ($typeSchema != "null") {
|
|
$typeSchema = [$typeSchema, "null"];
|
|
$typeIsArray = true;
|
|
}
|
|
}
|
|
if ($typeIsArray && $typeSchema.length == 1) {
|
|
$typeSchema = $typeSchema[0];
|
|
$typeIsArray = false;
|
|
}
|
|
if (it.schema.$ref && $refKeywords) {
|
|
if (it.opts.extendRefs == "fail") {
|
|
throw new Error('$ref: validation keywords used in schema at path "' + it.errSchemaPath + '" (see option extendRefs)');
|
|
} else if (it.opts.extendRefs !== true) {
|
|
$refKeywords = false;
|
|
it.logger.warn('$ref: keywords ignored in schema at path "' + it.errSchemaPath + '"');
|
|
}
|
|
}
|
|
if (it.schema.$comment && it.opts.$comment) {
|
|
out += " " + it.RULES.all.$comment.code(it, "$comment");
|
|
}
|
|
if ($typeSchema) {
|
|
if (it.opts.coerceTypes) {
|
|
var $coerceToTypes = it.util.coerceToTypes(it.opts.coerceTypes, $typeSchema);
|
|
}
|
|
var $rulesGroup = it.RULES.types[$typeSchema];
|
|
if ($coerceToTypes || $typeIsArray || $rulesGroup === true || $rulesGroup && !$shouldUseGroup($rulesGroup)) {
|
|
var $schemaPath = it.schemaPath + ".type", $errSchemaPath = it.errSchemaPath + "/type";
|
|
var $schemaPath = it.schemaPath + ".type", $errSchemaPath = it.errSchemaPath + "/type", $method = $typeIsArray ? "checkDataTypes" : "checkDataType";
|
|
out += " if (" + it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true) + ") { ";
|
|
if ($coerceToTypes) {
|
|
var $dataType = "dataType" + $lvl, $coerced = "coerced" + $lvl;
|
|
out += " var " + $dataType + " = typeof " + $data + "; var " + $coerced + " = undefined; ";
|
|
if (it.opts.coerceTypes == "array") {
|
|
out += " if (" + $dataType + " == 'object' && Array.isArray(" + $data + ") && " + $data + ".length == 1) { " + $data + " = " + $data + "[0]; " + $dataType + " = typeof " + $data + "; if (" + it.util.checkDataType(it.schema.type, $data, it.opts.strictNumbers) + ") " + $coerced + " = " + $data + "; } ";
|
|
}
|
|
out += " if (" + $coerced + " !== undefined) ; ";
|
|
var arr1 = $coerceToTypes;
|
|
if (arr1) {
|
|
var $type, $i = -1, l1 = arr1.length - 1;
|
|
while ($i < l1) {
|
|
$type = arr1[$i += 1];
|
|
if ($type == "string") {
|
|
out += " else if (" + $dataType + " == 'number' || " + $dataType + " == 'boolean') " + $coerced + " = '' + " + $data + "; else if (" + $data + " === null) " + $coerced + " = ''; ";
|
|
} else if ($type == "number" || $type == "integer") {
|
|
out += " else if (" + $dataType + " == 'boolean' || " + $data + " === null || (" + $dataType + " == 'string' && " + $data + " && " + $data + " == +" + $data + " ";
|
|
if ($type == "integer") {
|
|
out += " && !(" + $data + " % 1)";
|
|
}
|
|
out += ")) " + $coerced + " = +" + $data + "; ";
|
|
} else if ($type == "boolean") {
|
|
out += " else if (" + $data + " === 'false' || " + $data + " === 0 || " + $data + " === null) " + $coerced + " = false; else if (" + $data + " === 'true' || " + $data + " === 1) " + $coerced + " = true; ";
|
|
} else if ($type == "null") {
|
|
out += " else if (" + $data + " === '' || " + $data + " === 0 || " + $data + " === false) " + $coerced + " = null; ";
|
|
} else if (it.opts.coerceTypes == "array" && $type == "array") {
|
|
out += " else if (" + $dataType + " == 'string' || " + $dataType + " == 'number' || " + $dataType + " == 'boolean' || " + $data + " == null) " + $coerced + " = [" + $data + "]; ";
|
|
}
|
|
}
|
|
}
|
|
out += " else { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "type") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { type: '";
|
|
if ($typeIsArray) {
|
|
out += "" + $typeSchema.join(",");
|
|
} else {
|
|
out += "" + $typeSchema;
|
|
}
|
|
out += "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be ";
|
|
if ($typeIsArray) {
|
|
out += "" + $typeSchema.join(",");
|
|
} else {
|
|
out += "" + $typeSchema;
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } if (" + $coerced + " !== undefined) { ";
|
|
var $parentData = $dataLvl ? "data" + ($dataLvl - 1 || "") : "parentData", $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : "parentDataProperty";
|
|
out += " " + $data + " = " + $coerced + "; ";
|
|
if (!$dataLvl) {
|
|
out += "if (" + $parentData + " !== undefined)";
|
|
}
|
|
out += " " + $parentData + "[" + $parentDataProperty + "] = " + $coerced + "; } ";
|
|
} else {
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "type") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { type: '";
|
|
if ($typeIsArray) {
|
|
out += "" + $typeSchema.join(",");
|
|
} else {
|
|
out += "" + $typeSchema;
|
|
}
|
|
out += "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be ";
|
|
if ($typeIsArray) {
|
|
out += "" + $typeSchema.join(",");
|
|
} else {
|
|
out += "" + $typeSchema;
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
}
|
|
out += " } ";
|
|
}
|
|
}
|
|
if (it.schema.$ref && !$refKeywords) {
|
|
out += " " + it.RULES.all.$ref.code(it, "$ref") + " ";
|
|
if ($breakOnError) {
|
|
out += " } if (errors === ";
|
|
if ($top) {
|
|
out += "0";
|
|
} else {
|
|
out += "errs_" + $lvl;
|
|
}
|
|
out += ") { ";
|
|
$closingBraces2 += "}";
|
|
}
|
|
} else {
|
|
var arr2 = it.RULES;
|
|
if (arr2) {
|
|
var $rulesGroup, i2 = -1, l2 = arr2.length - 1;
|
|
while (i2 < l2) {
|
|
$rulesGroup = arr2[i2 += 1];
|
|
if ($shouldUseGroup($rulesGroup)) {
|
|
if ($rulesGroup.type) {
|
|
out += " if (" + it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers) + ") { ";
|
|
}
|
|
if (it.opts.useDefaults) {
|
|
if ($rulesGroup.type == "object" && it.schema.properties) {
|
|
var $schema = it.schema.properties, $schemaKeys = Object.keys($schema);
|
|
var arr3 = $schemaKeys;
|
|
if (arr3) {
|
|
var $propertyKey, i3 = -1, l3 = arr3.length - 1;
|
|
while (i3 < l3) {
|
|
$propertyKey = arr3[i3 += 1];
|
|
var $sch = $schema[$propertyKey];
|
|
if ($sch.default !== undefined) {
|
|
var $passData = $data + it.util.getProperty($propertyKey);
|
|
if (it.compositeRule) {
|
|
if (it.opts.strictDefaults) {
|
|
var $defaultMsg = "default is ignored for: " + $passData;
|
|
if (it.opts.strictDefaults === "log")
|
|
it.logger.warn($defaultMsg);
|
|
else
|
|
throw new Error($defaultMsg);
|
|
}
|
|
} else {
|
|
out += " if (" + $passData + " === undefined ";
|
|
if (it.opts.useDefaults == "empty") {
|
|
out += " || " + $passData + " === null || " + $passData + " === '' ";
|
|
}
|
|
out += " ) " + $passData + " = ";
|
|
if (it.opts.useDefaults == "shared") {
|
|
out += " " + it.useDefault($sch.default) + " ";
|
|
} else {
|
|
out += " " + JSON.stringify($sch.default) + " ";
|
|
}
|
|
out += "; ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if ($rulesGroup.type == "array" && Array.isArray(it.schema.items)) {
|
|
var arr4 = it.schema.items;
|
|
if (arr4) {
|
|
var $sch, $i = -1, l4 = arr4.length - 1;
|
|
while ($i < l4) {
|
|
$sch = arr4[$i += 1];
|
|
if ($sch.default !== undefined) {
|
|
var $passData = $data + "[" + $i + "]";
|
|
if (it.compositeRule) {
|
|
if (it.opts.strictDefaults) {
|
|
var $defaultMsg = "default is ignored for: " + $passData;
|
|
if (it.opts.strictDefaults === "log")
|
|
it.logger.warn($defaultMsg);
|
|
else
|
|
throw new Error($defaultMsg);
|
|
}
|
|
} else {
|
|
out += " if (" + $passData + " === undefined ";
|
|
if (it.opts.useDefaults == "empty") {
|
|
out += " || " + $passData + " === null || " + $passData + " === '' ";
|
|
}
|
|
out += " ) " + $passData + " = ";
|
|
if (it.opts.useDefaults == "shared") {
|
|
out += " " + it.useDefault($sch.default) + " ";
|
|
} else {
|
|
out += " " + JSON.stringify($sch.default) + " ";
|
|
}
|
|
out += "; ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var arr5 = $rulesGroup.rules;
|
|
if (arr5) {
|
|
var $rule, i5 = -1, l5 = arr5.length - 1;
|
|
while (i5 < l5) {
|
|
$rule = arr5[i5 += 1];
|
|
if ($shouldUseRule($rule)) {
|
|
var $code = $rule.code(it, $rule.keyword, $rulesGroup.type);
|
|
if ($code) {
|
|
out += " " + $code + " ";
|
|
if ($breakOnError) {
|
|
$closingBraces1 += "}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " " + $closingBraces1 + " ";
|
|
$closingBraces1 = "";
|
|
}
|
|
if ($rulesGroup.type) {
|
|
out += " } ";
|
|
if ($typeSchema && $typeSchema === $rulesGroup.type && !$coerceToTypes) {
|
|
out += " else { ";
|
|
var $schemaPath = it.schemaPath + ".type", $errSchemaPath = it.errSchemaPath + "/type";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "type") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { type: '";
|
|
if ($typeIsArray) {
|
|
out += "" + $typeSchema.join(",");
|
|
} else {
|
|
out += "" + $typeSchema;
|
|
}
|
|
out += "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be ";
|
|
if ($typeIsArray) {
|
|
out += "" + $typeSchema.join(",");
|
|
} else {
|
|
out += "" + $typeSchema;
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } ";
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (errors === ";
|
|
if ($top) {
|
|
out += "0";
|
|
} else {
|
|
out += "errs_" + $lvl;
|
|
}
|
|
out += ") { ";
|
|
$closingBraces2 += "}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " " + $closingBraces2 + " ";
|
|
}
|
|
if ($top) {
|
|
if ($async) {
|
|
out += " if (errors === 0) return data; ";
|
|
out += " else throw new ValidationError(vErrors); ";
|
|
} else {
|
|
out += " validate.errors = vErrors; ";
|
|
out += " return errors === 0; ";
|
|
}
|
|
out += " }; return validate;";
|
|
} else {
|
|
out += " var " + $valid + " = errors === errs_" + $lvl + ";";
|
|
}
|
|
function $shouldUseGroup($rulesGroup2) {
|
|
var rules = $rulesGroup2.rules;
|
|
for (var i = 0;i < rules.length; i++)
|
|
if ($shouldUseRule(rules[i]))
|
|
return true;
|
|
}
|
|
function $shouldUseRule($rule2) {
|
|
return it.schema[$rule2.keyword] !== undefined || $rule2.implements && $ruleImplementsSomeKeyword($rule2);
|
|
}
|
|
function $ruleImplementsSomeKeyword($rule2) {
|
|
var impl = $rule2.implements;
|
|
for (var i = 0;i < impl.length; i++)
|
|
if (it.schema[impl[i]] !== undefined)
|
|
return true;
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/index.js
|
|
var require_compile = __commonJS((exports, module) => {
|
|
var resolve = require_resolve();
|
|
var util3 = require_util();
|
|
var errorClasses = require_error_classes();
|
|
var stableStringify = require_fast_json_stable_stringify();
|
|
var validateGenerator = require_validate();
|
|
var ucs2length = util3.ucs2length;
|
|
var equal = require_fast_deep_equal();
|
|
var ValidationError = errorClasses.Validation;
|
|
module.exports = compile;
|
|
function compile(schema, root, localRefs, baseId) {
|
|
var self = this, opts = this._opts, refVal = [undefined], refs = {}, patterns = [], patternsHash = {}, defaults = [], defaultsHash = {}, customRules = [];
|
|
root = root || { schema, refVal, refs };
|
|
var c = checkCompiling.call(this, schema, root, baseId);
|
|
var compilation = this._compilations[c.index];
|
|
if (c.compiling)
|
|
return compilation.callValidate = callValidate;
|
|
var formats = this._formats;
|
|
var RULES = this.RULES;
|
|
try {
|
|
var v = localCompile(schema, root, localRefs, baseId);
|
|
compilation.validate = v;
|
|
var cv = compilation.callValidate;
|
|
if (cv) {
|
|
cv.schema = v.schema;
|
|
cv.errors = null;
|
|
cv.refs = v.refs;
|
|
cv.refVal = v.refVal;
|
|
cv.root = v.root;
|
|
cv.$async = v.$async;
|
|
if (opts.sourceCode)
|
|
cv.source = v.source;
|
|
}
|
|
return v;
|
|
} finally {
|
|
endCompiling.call(this, schema, root, baseId);
|
|
}
|
|
function callValidate() {
|
|
var validate = compilation.validate;
|
|
var result = validate.apply(this, arguments);
|
|
callValidate.errors = validate.errors;
|
|
return result;
|
|
}
|
|
function localCompile(_schema, _root, localRefs2, baseId2) {
|
|
var isRoot = !_root || _root && _root.schema == _schema;
|
|
if (_root.schema != root.schema)
|
|
return compile.call(self, _schema, _root, localRefs2, baseId2);
|
|
var $async = _schema.$async === true;
|
|
var sourceCode = validateGenerator({
|
|
isTop: true,
|
|
schema: _schema,
|
|
isRoot,
|
|
baseId: baseId2,
|
|
root: _root,
|
|
schemaPath: "",
|
|
errSchemaPath: "#",
|
|
errorPath: '""',
|
|
MissingRefError: errorClasses.MissingRef,
|
|
RULES,
|
|
validate: validateGenerator,
|
|
util: util3,
|
|
resolve,
|
|
resolveRef,
|
|
usePattern,
|
|
useDefault,
|
|
useCustomRule,
|
|
opts,
|
|
formats,
|
|
logger: self.logger,
|
|
self
|
|
});
|
|
sourceCode = vars(refVal, refValCode) + vars(patterns, patternCode) + vars(defaults, defaultCode) + vars(customRules, customRuleCode) + sourceCode;
|
|
if (opts.processCode)
|
|
sourceCode = opts.processCode(sourceCode, _schema);
|
|
var validate;
|
|
try {
|
|
var makeValidate = new Function("self", "RULES", "formats", "root", "refVal", "defaults", "customRules", "equal", "ucs2length", "ValidationError", sourceCode);
|
|
validate = makeValidate(self, RULES, formats, root, refVal, defaults, customRules, equal, ucs2length, ValidationError);
|
|
refVal[0] = validate;
|
|
} catch (e) {
|
|
self.logger.error("Error compiling schema, function code:", sourceCode);
|
|
throw e;
|
|
}
|
|
validate.schema = _schema;
|
|
validate.errors = null;
|
|
validate.refs = refs;
|
|
validate.refVal = refVal;
|
|
validate.root = isRoot ? validate : _root;
|
|
if ($async)
|
|
validate.$async = true;
|
|
if (opts.sourceCode === true) {
|
|
validate.source = {
|
|
code: sourceCode,
|
|
patterns,
|
|
defaults
|
|
};
|
|
}
|
|
return validate;
|
|
}
|
|
function resolveRef(baseId2, ref, isRoot) {
|
|
ref = resolve.url(baseId2, ref);
|
|
var refIndex = refs[ref];
|
|
var _refVal, refCode;
|
|
if (refIndex !== undefined) {
|
|
_refVal = refVal[refIndex];
|
|
refCode = "refVal[" + refIndex + "]";
|
|
return resolvedRef(_refVal, refCode);
|
|
}
|
|
if (!isRoot && root.refs) {
|
|
var rootRefId = root.refs[ref];
|
|
if (rootRefId !== undefined) {
|
|
_refVal = root.refVal[rootRefId];
|
|
refCode = addLocalRef(ref, _refVal);
|
|
return resolvedRef(_refVal, refCode);
|
|
}
|
|
}
|
|
refCode = addLocalRef(ref);
|
|
var v2 = resolve.call(self, localCompile, root, ref);
|
|
if (v2 === undefined) {
|
|
var localSchema = localRefs && localRefs[ref];
|
|
if (localSchema) {
|
|
v2 = resolve.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self, localSchema, root, localRefs, baseId2);
|
|
}
|
|
}
|
|
if (v2 === undefined) {
|
|
removeLocalRef(ref);
|
|
} else {
|
|
replaceLocalRef(ref, v2);
|
|
return resolvedRef(v2, refCode);
|
|
}
|
|
}
|
|
function addLocalRef(ref, v2) {
|
|
var refId = refVal.length;
|
|
refVal[refId] = v2;
|
|
refs[ref] = refId;
|
|
return "refVal" + refId;
|
|
}
|
|
function removeLocalRef(ref) {
|
|
delete refs[ref];
|
|
}
|
|
function replaceLocalRef(ref, v2) {
|
|
var refId = refs[ref];
|
|
refVal[refId] = v2;
|
|
}
|
|
function resolvedRef(refVal2, code) {
|
|
return typeof refVal2 == "object" || typeof refVal2 == "boolean" ? { code, schema: refVal2, inline: true } : { code, $async: refVal2 && !!refVal2.$async };
|
|
}
|
|
function usePattern(regexStr) {
|
|
var index = patternsHash[regexStr];
|
|
if (index === undefined) {
|
|
index = patternsHash[regexStr] = patterns.length;
|
|
patterns[index] = regexStr;
|
|
}
|
|
return "pattern" + index;
|
|
}
|
|
function useDefault(value) {
|
|
switch (typeof value) {
|
|
case "boolean":
|
|
case "number":
|
|
return "" + value;
|
|
case "string":
|
|
return util3.toQuotedString(value);
|
|
case "object":
|
|
if (value === null)
|
|
return "null";
|
|
var valueStr = stableStringify(value);
|
|
var index = defaultsHash[valueStr];
|
|
if (index === undefined) {
|
|
index = defaultsHash[valueStr] = defaults.length;
|
|
defaults[index] = value;
|
|
}
|
|
return "default" + index;
|
|
}
|
|
}
|
|
function useCustomRule(rule, schema2, parentSchema, it) {
|
|
if (self._opts.validateSchema !== false) {
|
|
var deps = rule.definition.dependencies;
|
|
if (deps && !deps.every(function(keyword) {
|
|
return Object.prototype.hasOwnProperty.call(parentSchema, keyword);
|
|
}))
|
|
throw new Error("parent schema must have all required keywords: " + deps.join(","));
|
|
var validateSchema = rule.definition.validateSchema;
|
|
if (validateSchema) {
|
|
var valid = validateSchema(schema2);
|
|
if (!valid) {
|
|
var message = "keyword schema is invalid: " + self.errorsText(validateSchema.errors);
|
|
if (self._opts.validateSchema == "log")
|
|
self.logger.error(message);
|
|
else
|
|
throw new Error(message);
|
|
}
|
|
}
|
|
}
|
|
var compile2 = rule.definition.compile, inline = rule.definition.inline, macro = rule.definition.macro;
|
|
var validate;
|
|
if (compile2) {
|
|
validate = compile2.call(self, schema2, parentSchema, it);
|
|
} else if (macro) {
|
|
validate = macro.call(self, schema2, parentSchema, it);
|
|
if (opts.validateSchema !== false)
|
|
self.validateSchema(validate, true);
|
|
} else if (inline) {
|
|
validate = inline.call(self, it, rule.keyword, schema2, parentSchema);
|
|
} else {
|
|
validate = rule.definition.validate;
|
|
if (!validate)
|
|
return;
|
|
}
|
|
if (validate === undefined)
|
|
throw new Error('custom keyword "' + rule.keyword + '"failed to compile');
|
|
var index = customRules.length;
|
|
customRules[index] = validate;
|
|
return {
|
|
code: "customRule" + index,
|
|
validate
|
|
};
|
|
}
|
|
}
|
|
function checkCompiling(schema, root, baseId) {
|
|
var index = compIndex.call(this, schema, root, baseId);
|
|
if (index >= 0)
|
|
return { index, compiling: true };
|
|
index = this._compilations.length;
|
|
this._compilations[index] = {
|
|
schema,
|
|
root,
|
|
baseId
|
|
};
|
|
return { index, compiling: false };
|
|
}
|
|
function endCompiling(schema, root, baseId) {
|
|
var i = compIndex.call(this, schema, root, baseId);
|
|
if (i >= 0)
|
|
this._compilations.splice(i, 1);
|
|
}
|
|
function compIndex(schema, root, baseId) {
|
|
for (var i = 0;i < this._compilations.length; i++) {
|
|
var c = this._compilations[i];
|
|
if (c.schema == schema && c.root == root && c.baseId == baseId)
|
|
return i;
|
|
}
|
|
return -1;
|
|
}
|
|
function patternCode(i, patterns) {
|
|
return "var pattern" + i + " = new RegExp(" + util3.toQuotedString(patterns[i]) + ");";
|
|
}
|
|
function defaultCode(i) {
|
|
return "var default" + i + " = defaults[" + i + "];";
|
|
}
|
|
function refValCode(i, refVal) {
|
|
return refVal[i] === undefined ? "" : "var refVal" + i + " = refVal[" + i + "];";
|
|
}
|
|
function customRuleCode(i) {
|
|
return "var customRule" + i + " = customRules[" + i + "];";
|
|
}
|
|
function vars(arr, statement) {
|
|
if (!arr.length)
|
|
return "";
|
|
var code = "";
|
|
for (var i = 0;i < arr.length; i++)
|
|
code += statement(i, arr);
|
|
return code;
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/cache.js
|
|
var require_cache = __commonJS((exports, module) => {
|
|
var Cache = module.exports = function Cache() {
|
|
this._cache = {};
|
|
};
|
|
Cache.prototype.put = function Cache_put(key, value) {
|
|
this._cache[key] = value;
|
|
};
|
|
Cache.prototype.get = function Cache_get(key) {
|
|
return this._cache[key];
|
|
};
|
|
Cache.prototype.del = function Cache_del(key) {
|
|
delete this._cache[key];
|
|
};
|
|
Cache.prototype.clear = function Cache_clear() {
|
|
this._cache = {};
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/formats.js
|
|
var require_formats = __commonJS((exports, module) => {
|
|
var util3 = require_util();
|
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
var DAYS = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
|
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
|
var URL2 = /^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i;
|
|
var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
module.exports = formats;
|
|
function formats(mode) {
|
|
mode = mode == "full" ? "full" : "fast";
|
|
return util3.copy(formats[mode]);
|
|
}
|
|
formats.fast = {
|
|
date: /^\d\d\d\d-[0-1]\d-[0-3]\d$/,
|
|
time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,
|
|
"date-time": /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,
|
|
uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
|
|
"uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
|
|
"uri-template": URITEMPLATE,
|
|
url: URL2,
|
|
email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,
|
|
hostname: HOSTNAME,
|
|
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
|
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
|
regex,
|
|
uuid: UUID,
|
|
"json-pointer": JSON_POINTER,
|
|
"json-pointer-uri-fragment": JSON_POINTER_URI_FRAGMENT,
|
|
"relative-json-pointer": RELATIVE_JSON_POINTER
|
|
};
|
|
formats.full = {
|
|
date,
|
|
time,
|
|
"date-time": date_time,
|
|
uri,
|
|
"uri-reference": URIREF,
|
|
"uri-template": URITEMPLATE,
|
|
url: URL2,
|
|
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
|
|
hostname: HOSTNAME,
|
|
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
|
|
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
|
|
regex,
|
|
uuid: UUID,
|
|
"json-pointer": JSON_POINTER,
|
|
"json-pointer-uri-fragment": JSON_POINTER_URI_FRAGMENT,
|
|
"relative-json-pointer": RELATIVE_JSON_POINTER
|
|
};
|
|
function isLeapYear(year) {
|
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
}
|
|
function date(str) {
|
|
var matches = str.match(DATE);
|
|
if (!matches)
|
|
return false;
|
|
var year = +matches[1];
|
|
var month = +matches[2];
|
|
var day = +matches[3];
|
|
return month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
|
|
}
|
|
function time(str, full) {
|
|
var matches = str.match(TIME);
|
|
if (!matches)
|
|
return false;
|
|
var hour = matches[1];
|
|
var minute = matches[2];
|
|
var second = matches[3];
|
|
var timeZone = matches[5];
|
|
return (hour <= 23 && minute <= 59 && second <= 59 || hour == 23 && minute == 59 && second == 60) && (!full || timeZone);
|
|
}
|
|
var DATE_TIME_SEPARATOR = /t|\s/i;
|
|
function date_time(str) {
|
|
var dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
return dateTime.length == 2 && date(dateTime[0]) && time(dateTime[1], true);
|
|
}
|
|
var NOT_URI_FRAGMENT = /\/|:/;
|
|
function uri(str) {
|
|
return NOT_URI_FRAGMENT.test(str) && URI.test(str);
|
|
}
|
|
var Z_ANCHOR = /[^\\]\\Z/;
|
|
function regex(str) {
|
|
if (Z_ANCHOR.test(str))
|
|
return false;
|
|
try {
|
|
new RegExp(str);
|
|
return true;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/ref.js
|
|
var require_ref = __commonJS((exports, module) => {
|
|
module.exports = function generate_ref(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $async, $refCode;
|
|
if ($schema == "#" || $schema == "#/") {
|
|
if (it.isRoot) {
|
|
$async = it.async;
|
|
$refCode = "validate";
|
|
} else {
|
|
$async = it.root.schema.$async === true;
|
|
$refCode = "root.refVal[0]";
|
|
}
|
|
} else {
|
|
var $refVal = it.resolveRef(it.baseId, $schema, it.isRoot);
|
|
if ($refVal === undefined) {
|
|
var $message = it.MissingRefError.message(it.baseId, $schema);
|
|
if (it.opts.missingRefs == "fail") {
|
|
it.logger.error($message);
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "$ref" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { ref: '" + it.util.escapeQuotes($schema) + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'can\\'t resolve reference " + it.util.escapeQuotes($schema) + "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: " + it.util.toQuotedString($schema) + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (false) { ";
|
|
}
|
|
} else if (it.opts.missingRefs == "ignore") {
|
|
it.logger.warn($message);
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
} else {
|
|
throw new it.MissingRefError(it.baseId, $schema, $message);
|
|
}
|
|
} else if ($refVal.inline) {
|
|
var $it = it.util.copy(it);
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
$it.schema = $refVal.schema;
|
|
$it.schemaPath = "";
|
|
$it.errSchemaPath = $schema;
|
|
var $code = it.validate($it).replace(/validate\.schema/g, $refVal.code);
|
|
out += " " + $code + " ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
}
|
|
} else {
|
|
$async = $refVal.$async === true || it.async && $refVal.$async !== false;
|
|
$refCode = $refVal.code;
|
|
}
|
|
}
|
|
if ($refCode) {
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.opts.passContext) {
|
|
out += " " + $refCode + ".call(this, ";
|
|
} else {
|
|
out += " " + $refCode + "( ";
|
|
}
|
|
out += " " + $data + ", (dataPath || '')";
|
|
if (it.errorPath != '""') {
|
|
out += " + " + it.errorPath;
|
|
}
|
|
var $parentData = $dataLvl ? "data" + ($dataLvl - 1 || "") : "parentData", $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : "parentDataProperty";
|
|
out += " , " + $parentData + " , " + $parentDataProperty + ", rootData) ";
|
|
var __callValidate = out;
|
|
out = $$outStack.pop();
|
|
if ($async) {
|
|
if (!it.async)
|
|
throw new Error("async schema referenced by sync schema");
|
|
if ($breakOnError) {
|
|
out += " var " + $valid + "; ";
|
|
}
|
|
out += " try { await " + __callValidate + "; ";
|
|
if ($breakOnError) {
|
|
out += " " + $valid + " = true; ";
|
|
}
|
|
out += " } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ";
|
|
if ($breakOnError) {
|
|
out += " " + $valid + " = false; ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $valid + ") { ";
|
|
}
|
|
} else {
|
|
out += " if (!" + __callValidate + ") { if (vErrors === null) vErrors = " + $refCode + ".errors; else vErrors = vErrors.concat(" + $refCode + ".errors); errors = vErrors.length; } ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/allOf.js
|
|
var require_allOf = __commonJS((exports, module) => {
|
|
module.exports = function generate_allOf(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $currentBaseId = $it.baseId, $allSchemasEmpty = true;
|
|
var arr1 = $schema;
|
|
if (arr1) {
|
|
var $sch, $i = -1, l1 = arr1.length - 1;
|
|
while ($i < l1) {
|
|
$sch = arr1[$i += 1];
|
|
if (it.opts.strictKeywords ? typeof $sch == "object" && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
$allSchemasEmpty = false;
|
|
$it.schema = $sch;
|
|
$it.schemaPath = $schemaPath + "[" + $i + "]";
|
|
$it.errSchemaPath = $errSchemaPath + "/" + $i;
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
if ($allSchemasEmpty) {
|
|
out += " if (true) { ";
|
|
} else {
|
|
out += " " + $closingBraces.slice(0, -1) + " ";
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/anyOf.js
|
|
var require_anyOf = __commonJS((exports, module) => {
|
|
module.exports = function generate_anyOf(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $noEmptySchema = $schema.every(function($sch2) {
|
|
return it.opts.strictKeywords ? typeof $sch2 == "object" && Object.keys($sch2).length > 0 || $sch2 === false : it.util.schemaHasRules($sch2, it.RULES.all);
|
|
});
|
|
if ($noEmptySchema) {
|
|
var $currentBaseId = $it.baseId;
|
|
out += " var " + $errs + " = errors; var " + $valid + " = false; ";
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
var arr1 = $schema;
|
|
if (arr1) {
|
|
var $sch, $i = -1, l1 = arr1.length - 1;
|
|
while ($i < l1) {
|
|
$sch = arr1[$i += 1];
|
|
$it.schema = $sch;
|
|
$it.schemaPath = $schemaPath + "[" + $i + "]";
|
|
$it.errSchemaPath = $errSchemaPath + "/" + $i;
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
out += " " + $valid + " = " + $valid + " || " + $nextValid + "; if (!" + $valid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
out += " " + $closingBraces + " if (!" + $valid + ") { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "anyOf" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: {} ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should match some schema in anyOf' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError(vErrors); ";
|
|
} else {
|
|
out += " validate.errors = vErrors; return false; ";
|
|
}
|
|
}
|
|
out += " } else { errors = " + $errs + "; if (vErrors !== null) { if (" + $errs + ") vErrors.length = " + $errs + "; else vErrors = null; } ";
|
|
if (it.opts.allErrors) {
|
|
out += " } ";
|
|
}
|
|
} else {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/comment.js
|
|
var require_comment = __commonJS((exports, module) => {
|
|
module.exports = function generate_comment(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $schema = it.schema[$keyword];
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $comment = it.util.toQuotedString($schema);
|
|
if (it.opts.$comment === true) {
|
|
out += " console.log(" + $comment + ");";
|
|
} else if (typeof it.opts.$comment == "function") {
|
|
out += " self._opts.$comment(" + $comment + ", " + it.util.toQuotedString($errSchemaPath) + ", validate.root.schema);";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/const.js
|
|
var require_const = __commonJS((exports, module) => {
|
|
module.exports = function generate_const(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
if (!$isData) {
|
|
out += " var schema" + $lvl + " = validate.schema" + $schemaPath + ";";
|
|
}
|
|
out += "var " + $valid + " = equal(" + $data + ", schema" + $lvl + "); if (!" + $valid + ") { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "const" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { allowedValue: schema" + $lvl + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be equal to constant' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " }";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/contains.js
|
|
var require_contains = __commonJS((exports, module) => {
|
|
module.exports = function generate_contains(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $idx = "i" + $lvl, $dataNxt = $it.dataLevel = it.dataLevel + 1, $nextData = "data" + $dataNxt, $currentBaseId = it.baseId, $nonEmptySchema = it.opts.strictKeywords ? typeof $schema == "object" && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all);
|
|
out += "var " + $errs + " = errors;var " + $valid + ";";
|
|
if ($nonEmptySchema) {
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
$it.schema = $schema;
|
|
$it.schemaPath = $schemaPath;
|
|
$it.errSchemaPath = $errSchemaPath;
|
|
out += " var " + $nextValid + " = false; for (var " + $idx + " = 0; " + $idx + " < " + $data + ".length; " + $idx + "++) { ";
|
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
|
var $passData = $data + "[" + $idx + "]";
|
|
$it.dataPathArr[$dataNxt] = $idx;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
out += " if (" + $nextValid + ") break; } ";
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
out += " " + $closingBraces + " if (!" + $nextValid + ") {";
|
|
} else {
|
|
out += " if (" + $data + ".length == 0) {";
|
|
}
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "contains" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: {} ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should contain a valid item' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } else { ";
|
|
if ($nonEmptySchema) {
|
|
out += " errors = " + $errs + "; if (vErrors !== null) { if (" + $errs + ") vErrors.length = " + $errs + "; else vErrors = null; } ";
|
|
}
|
|
if (it.opts.allErrors) {
|
|
out += " } ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/dependencies.js
|
|
var require_dependencies = __commonJS((exports, module) => {
|
|
module.exports = function generate_dependencies(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $schemaDeps = {}, $propertyDeps = {}, $ownProperties = it.opts.ownProperties;
|
|
for ($property in $schema) {
|
|
if ($property == "__proto__")
|
|
continue;
|
|
var $sch = $schema[$property];
|
|
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
|
|
$deps[$property] = $sch;
|
|
}
|
|
out += "var " + $errs + " = errors;";
|
|
var $currentErrorPath = it.errorPath;
|
|
out += "var missing" + $lvl + ";";
|
|
for (var $property in $propertyDeps) {
|
|
$deps = $propertyDeps[$property];
|
|
if ($deps.length) {
|
|
out += " if ( " + $data + it.util.getProperty($property) + " !== undefined ";
|
|
if ($ownProperties) {
|
|
out += " && Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($property) + "') ";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " && ( ";
|
|
var arr1 = $deps;
|
|
if (arr1) {
|
|
var $propertyKey, $i = -1, l1 = arr1.length - 1;
|
|
while ($i < l1) {
|
|
$propertyKey = arr1[$i += 1];
|
|
if ($i) {
|
|
out += " || ";
|
|
}
|
|
var $prop = it.util.getProperty($propertyKey), $useData = $data + $prop;
|
|
out += " ( ( " + $useData + " === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += ") && (missing" + $lvl + " = " + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ") ) ";
|
|
}
|
|
}
|
|
out += ")) { ";
|
|
var $propertyPath = "missing" + $lvl, $missingProperty = "' + " + $propertyPath + " + '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + " + " + $propertyPath;
|
|
}
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "dependencies" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { property: '" + it.util.escapeQuotes($property) + "', missingProperty: '" + $missingProperty + "', depsCount: " + $deps.length + ", deps: '" + it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", ")) + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should have ";
|
|
if ($deps.length == 1) {
|
|
out += "property " + it.util.escapeQuotes($deps[0]);
|
|
} else {
|
|
out += "properties " + it.util.escapeQuotes($deps.join(", "));
|
|
}
|
|
out += " when property " + it.util.escapeQuotes($property) + " is present' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
} else {
|
|
out += " ) { ";
|
|
var arr2 = $deps;
|
|
if (arr2) {
|
|
var $propertyKey, i2 = -1, l2 = arr2.length - 1;
|
|
while (i2 < l2) {
|
|
$propertyKey = arr2[i2 += 1];
|
|
var $prop = it.util.getProperty($propertyKey), $missingProperty = it.util.escapeQuotes($propertyKey), $useData = $data + $prop;
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
|
|
}
|
|
out += " if ( " + $useData + " === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += ") { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "dependencies" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { property: '" + it.util.escapeQuotes($property) + "', missingProperty: '" + $missingProperty + "', depsCount: " + $deps.length + ", deps: '" + it.util.escapeQuotes($deps.length == 1 ? $deps[0] : $deps.join(", ")) + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should have ";
|
|
if ($deps.length == 1) {
|
|
out += "property " + it.util.escapeQuotes($deps[0]);
|
|
} else {
|
|
out += "properties " + it.util.escapeQuotes($deps.join(", "));
|
|
}
|
|
out += " when property " + it.util.escapeQuotes($property) + " is present' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ";
|
|
}
|
|
}
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
$closingBraces += "}";
|
|
out += " else { ";
|
|
}
|
|
}
|
|
}
|
|
it.errorPath = $currentErrorPath;
|
|
var $currentBaseId = $it.baseId;
|
|
for (var $property in $schemaDeps) {
|
|
var $sch = $schemaDeps[$property];
|
|
if (it.opts.strictKeywords ? typeof $sch == "object" && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
out += " " + $nextValid + " = true; if ( " + $data + it.util.getProperty($property) + " !== undefined ";
|
|
if ($ownProperties) {
|
|
out += " && Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($property) + "') ";
|
|
}
|
|
out += ") { ";
|
|
$it.schema = $sch;
|
|
$it.schemaPath = $schemaPath + it.util.getProperty($property);
|
|
$it.errSchemaPath = $errSchemaPath + "/" + it.util.escapeFragment($property);
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " " + $closingBraces + " if (" + $errs + " == errors) {";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/enum.js
|
|
var require_enum = __commonJS((exports, module) => {
|
|
module.exports = function generate_enum(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
var $i = "i" + $lvl, $vSchema = "schema" + $lvl;
|
|
if (!$isData) {
|
|
out += " var " + $vSchema + " = validate.schema" + $schemaPath + ";";
|
|
}
|
|
out += "var " + $valid + ";";
|
|
if ($isData) {
|
|
out += " if (schema" + $lvl + " === undefined) " + $valid + " = true; else if (!Array.isArray(schema" + $lvl + ")) " + $valid + " = false; else {";
|
|
}
|
|
out += "" + $valid + " = false;for (var " + $i + "=0; " + $i + "<" + $vSchema + ".length; " + $i + "++) if (equal(" + $data + ", " + $vSchema + "[" + $i + "])) { " + $valid + " = true; break; }";
|
|
if ($isData) {
|
|
out += " } ";
|
|
}
|
|
out += " if (!" + $valid + ") { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "enum" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { allowedValues: schema" + $lvl + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be equal to one of the allowed values' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " }";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/format.js
|
|
var require_format = __commonJS((exports, module) => {
|
|
module.exports = function generate_format(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
if (it.opts.format === false) {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
return out;
|
|
}
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
var $unknownFormats = it.opts.unknownFormats, $allowUnknown = Array.isArray($unknownFormats);
|
|
if ($isData) {
|
|
var $format = "format" + $lvl, $isObject = "isObject" + $lvl, $formatType = "formatType" + $lvl;
|
|
out += " var " + $format + " = formats[" + $schemaValue + "]; var " + $isObject + " = typeof " + $format + " == 'object' && !(" + $format + " instanceof RegExp) && " + $format + ".validate; var " + $formatType + " = " + $isObject + " && " + $format + ".type || 'string'; if (" + $isObject + ") { ";
|
|
if (it.async) {
|
|
out += " var async" + $lvl + " = " + $format + ".async; ";
|
|
}
|
|
out += " " + $format + " = " + $format + ".validate; } if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'string') || ";
|
|
}
|
|
out += " (";
|
|
if ($unknownFormats != "ignore") {
|
|
out += " (" + $schemaValue + " && !" + $format + " ";
|
|
if ($allowUnknown) {
|
|
out += " && self._opts.unknownFormats.indexOf(" + $schemaValue + ") == -1 ";
|
|
}
|
|
out += ") || ";
|
|
}
|
|
out += " (" + $format + " && " + $formatType + " == '" + $ruleType + "' && !(typeof " + $format + " == 'function' ? ";
|
|
if (it.async) {
|
|
out += " (async" + $lvl + " ? await " + $format + "(" + $data + ") : " + $format + "(" + $data + ")) ";
|
|
} else {
|
|
out += " " + $format + "(" + $data + ") ";
|
|
}
|
|
out += " : " + $format + ".test(" + $data + "))))) {";
|
|
} else {
|
|
var $format = it.formats[$schema];
|
|
if (!$format) {
|
|
if ($unknownFormats == "ignore") {
|
|
it.logger.warn('unknown format "' + $schema + '" ignored in schema at path "' + it.errSchemaPath + '"');
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
return out;
|
|
} else if ($allowUnknown && $unknownFormats.indexOf($schema) >= 0) {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
return out;
|
|
} else {
|
|
throw new Error('unknown format "' + $schema + '" is used in schema at path "' + it.errSchemaPath + '"');
|
|
}
|
|
}
|
|
var $isObject = typeof $format == "object" && !($format instanceof RegExp) && $format.validate;
|
|
var $formatType = $isObject && $format.type || "string";
|
|
if ($isObject) {
|
|
var $async = $format.async === true;
|
|
$format = $format.validate;
|
|
}
|
|
if ($formatType != $ruleType) {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
return out;
|
|
}
|
|
if ($async) {
|
|
if (!it.async)
|
|
throw new Error("async format in sync schema");
|
|
var $formatRef = "formats" + it.util.getProperty($schema) + ".validate";
|
|
out += " if (!(await " + $formatRef + "(" + $data + "))) { ";
|
|
} else {
|
|
out += " if (! ";
|
|
var $formatRef = "formats" + it.util.getProperty($schema);
|
|
if ($isObject)
|
|
$formatRef += ".validate";
|
|
if (typeof $format == "function") {
|
|
out += " " + $formatRef + "(" + $data + ") ";
|
|
} else {
|
|
out += " " + $formatRef + ".test(" + $data + ") ";
|
|
}
|
|
out += ") { ";
|
|
}
|
|
}
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "format" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { format: ";
|
|
if ($isData) {
|
|
out += "" + $schemaValue;
|
|
} else {
|
|
out += "" + it.util.toQuotedString($schema);
|
|
}
|
|
out += " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += ` , message: 'should match format "`;
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue + " + '";
|
|
} else {
|
|
out += "" + it.util.escapeQuotes($schema);
|
|
}
|
|
out += `"' `;
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + it.util.toQuotedString($schema);
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/if.js
|
|
var require_if = __commonJS((exports, module) => {
|
|
module.exports = function generate_if(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $thenSch = it.schema["then"], $elseSch = it.schema["else"], $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == "object" && Object.keys($thenSch).length > 0 || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)), $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == "object" && Object.keys($elseSch).length > 0 || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)), $currentBaseId = $it.baseId;
|
|
if ($thenPresent || $elsePresent) {
|
|
var $ifClause;
|
|
$it.createErrors = false;
|
|
$it.schema = $schema;
|
|
$it.schemaPath = $schemaPath;
|
|
$it.errSchemaPath = $errSchemaPath;
|
|
out += " var " + $errs + " = errors; var " + $valid + " = true; ";
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
$it.createErrors = true;
|
|
out += " errors = " + $errs + "; if (vErrors !== null) { if (" + $errs + ") vErrors.length = " + $errs + "; else vErrors = null; } ";
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
if ($thenPresent) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$it.schema = it.schema["then"];
|
|
$it.schemaPath = it.schemaPath + ".then";
|
|
$it.errSchemaPath = it.errSchemaPath + "/then";
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
out += " " + $valid + " = " + $nextValid + "; ";
|
|
if ($thenPresent && $elsePresent) {
|
|
$ifClause = "ifClause" + $lvl;
|
|
out += " var " + $ifClause + " = 'then'; ";
|
|
} else {
|
|
$ifClause = "'then'";
|
|
}
|
|
out += " } ";
|
|
if ($elsePresent) {
|
|
out += " else { ";
|
|
}
|
|
} else {
|
|
out += " if (!" + $nextValid + ") { ";
|
|
}
|
|
if ($elsePresent) {
|
|
$it.schema = it.schema["else"];
|
|
$it.schemaPath = it.schemaPath + ".else";
|
|
$it.errSchemaPath = it.errSchemaPath + "/else";
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
out += " " + $valid + " = " + $nextValid + "; ";
|
|
if ($thenPresent && $elsePresent) {
|
|
$ifClause = "ifClause" + $lvl;
|
|
out += " var " + $ifClause + " = 'else'; ";
|
|
} else {
|
|
$ifClause = "'else'";
|
|
}
|
|
out += " } ";
|
|
}
|
|
out += " if (!" + $valid + ") { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "if" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { failingKeyword: " + $ifClause + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += ` , message: 'should match "' + ` + $ifClause + ` + '" schema' `;
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError(vErrors); ";
|
|
} else {
|
|
out += " validate.errors = vErrors; return false; ";
|
|
}
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
} else {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/items.js
|
|
var require_items = __commonJS((exports, module) => {
|
|
module.exports = function generate_items(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $idx = "i" + $lvl, $dataNxt = $it.dataLevel = it.dataLevel + 1, $nextData = "data" + $dataNxt, $currentBaseId = it.baseId;
|
|
out += "var " + $errs + " = errors;var " + $valid + ";";
|
|
if (Array.isArray($schema)) {
|
|
var $additionalItems = it.schema.additionalItems;
|
|
if ($additionalItems === false) {
|
|
out += " " + $valid + " = " + $data + ".length <= " + $schema.length + "; ";
|
|
var $currErrSchemaPath = $errSchemaPath;
|
|
$errSchemaPath = it.errSchemaPath + "/additionalItems";
|
|
out += " if (!" + $valid + ") { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "additionalItems" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { limit: " + $schema.length + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT have more than " + $schema.length + " items' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: false , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } ";
|
|
$errSchemaPath = $currErrSchemaPath;
|
|
if ($breakOnError) {
|
|
$closingBraces += "}";
|
|
out += " else { ";
|
|
}
|
|
}
|
|
var arr1 = $schema;
|
|
if (arr1) {
|
|
var $sch, $i = -1, l1 = arr1.length - 1;
|
|
while ($i < l1) {
|
|
$sch = arr1[$i += 1];
|
|
if (it.opts.strictKeywords ? typeof $sch == "object" && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
out += " " + $nextValid + " = true; if (" + $data + ".length > " + $i + ") { ";
|
|
var $passData = $data + "[" + $i + "]";
|
|
$it.schema = $sch;
|
|
$it.schemaPath = $schemaPath + "[" + $i + "]";
|
|
$it.errSchemaPath = $errSchemaPath + "/" + $i;
|
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $i, it.opts.jsonPointers, true);
|
|
$it.dataPathArr[$dataNxt] = $i;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (typeof $additionalItems == "object" && (it.opts.strictKeywords ? typeof $additionalItems == "object" && Object.keys($additionalItems).length > 0 || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) {
|
|
$it.schema = $additionalItems;
|
|
$it.schemaPath = it.schemaPath + ".additionalItems";
|
|
$it.errSchemaPath = it.errSchemaPath + "/additionalItems";
|
|
out += " " + $nextValid + " = true; if (" + $data + ".length > " + $schema.length + ") { for (var " + $idx + " = " + $schema.length + "; " + $idx + " < " + $data + ".length; " + $idx + "++) { ";
|
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
|
var $passData = $data + "[" + $idx + "]";
|
|
$it.dataPathArr[$dataNxt] = $idx;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (!" + $nextValid + ") break; ";
|
|
}
|
|
out += " } } ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
} else if (it.opts.strictKeywords ? typeof $schema == "object" && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)) {
|
|
$it.schema = $schema;
|
|
$it.schemaPath = $schemaPath;
|
|
$it.errSchemaPath = $errSchemaPath;
|
|
out += " for (var " + $idx + " = " + 0 + "; " + $idx + " < " + $data + ".length; " + $idx + "++) { ";
|
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $idx, it.opts.jsonPointers, true);
|
|
var $passData = $data + "[" + $idx + "]";
|
|
$it.dataPathArr[$dataNxt] = $idx;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (!" + $nextValid + ") break; ";
|
|
}
|
|
out += " }";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " " + $closingBraces + " if (" + $errs + " == errors) {";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/_limit.js
|
|
var require__limit = __commonJS((exports, module) => {
|
|
module.exports = function generate__limit(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $errorKeyword;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
var $isMax = $keyword == "maximum", $exclusiveKeyword = $isMax ? "exclusiveMaximum" : "exclusiveMinimum", $schemaExcl = it.schema[$exclusiveKeyword], $isDataExcl = it.opts.$data && $schemaExcl && $schemaExcl.$data, $op = $isMax ? "<" : ">", $notOp = $isMax ? ">" : "<", $errorKeyword = undefined;
|
|
if (!($isData || typeof $schema == "number" || $schema === undefined)) {
|
|
throw new Error($keyword + " must be number");
|
|
}
|
|
if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == "number" || typeof $schemaExcl == "boolean")) {
|
|
throw new Error($exclusiveKeyword + " must be number or boolean");
|
|
}
|
|
if ($isDataExcl) {
|
|
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr), $exclusive = "exclusive" + $lvl, $exclType = "exclType" + $lvl, $exclIsNumber = "exclIsNumber" + $lvl, $opExpr = "op" + $lvl, $opStr = "' + " + $opExpr + " + '";
|
|
out += " var schemaExcl" + $lvl + " = " + $schemaValueExcl + "; ";
|
|
$schemaValueExcl = "schemaExcl" + $lvl;
|
|
out += " var " + $exclusive + "; var " + $exclType + " = typeof " + $schemaValueExcl + "; if (" + $exclType + " != 'boolean' && " + $exclType + " != 'undefined' && " + $exclType + " != 'number') { ";
|
|
var $errorKeyword = $exclusiveKeyword;
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "_exclusiveLimit") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: {} ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '" + $exclusiveKeyword + " should be boolean' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } else if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'number') || ";
|
|
}
|
|
out += " " + $exclType + " == 'number' ? ( (" + $exclusive + " = " + $schemaValue + " === undefined || " + $schemaValueExcl + " " + $op + "= " + $schemaValue + ") ? " + $data + " " + $notOp + "= " + $schemaValueExcl + " : " + $data + " " + $notOp + " " + $schemaValue + " ) : ( (" + $exclusive + " = " + $schemaValueExcl + " === true) ? " + $data + " " + $notOp + "= " + $schemaValue + " : " + $data + " " + $notOp + " " + $schemaValue + " ) || " + $data + " !== " + $data + ") { var op" + $lvl + " = " + $exclusive + " ? '" + $op + "' : '" + $op + "='; ";
|
|
if ($schema === undefined) {
|
|
$errorKeyword = $exclusiveKeyword;
|
|
$errSchemaPath = it.errSchemaPath + "/" + $exclusiveKeyword;
|
|
$schemaValue = $schemaValueExcl;
|
|
$isData = $isDataExcl;
|
|
}
|
|
} else {
|
|
var $exclIsNumber = typeof $schemaExcl == "number", $opStr = $op;
|
|
if ($exclIsNumber && $isData) {
|
|
var $opExpr = "'" + $opStr + "'";
|
|
out += " if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'number') || ";
|
|
}
|
|
out += " ( " + $schemaValue + " === undefined || " + $schemaExcl + " " + $op + "= " + $schemaValue + " ? " + $data + " " + $notOp + "= " + $schemaExcl + " : " + $data + " " + $notOp + " " + $schemaValue + " ) || " + $data + " !== " + $data + ") { ";
|
|
} else {
|
|
if ($exclIsNumber && $schema === undefined) {
|
|
$exclusive = true;
|
|
$errorKeyword = $exclusiveKeyword;
|
|
$errSchemaPath = it.errSchemaPath + "/" + $exclusiveKeyword;
|
|
$schemaValue = $schemaExcl;
|
|
$notOp += "=";
|
|
} else {
|
|
if ($exclIsNumber)
|
|
$schemaValue = Math[$isMax ? "min" : "max"]($schemaExcl, $schema);
|
|
if ($schemaExcl === ($exclIsNumber ? $schemaValue : true)) {
|
|
$exclusive = true;
|
|
$errorKeyword = $exclusiveKeyword;
|
|
$errSchemaPath = it.errSchemaPath + "/" + $exclusiveKeyword;
|
|
$notOp += "=";
|
|
} else {
|
|
$exclusive = false;
|
|
$opStr += "=";
|
|
}
|
|
}
|
|
var $opExpr = "'" + $opStr + "'";
|
|
out += " if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'number') || ";
|
|
}
|
|
out += " " + $data + " " + $notOp + " " + $schemaValue + " || " + $data + " !== " + $data + ") { ";
|
|
}
|
|
}
|
|
$errorKeyword = $errorKeyword || $keyword;
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "_limit") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { comparison: " + $opExpr + ", limit: " + $schemaValue + ", exclusive: " + $exclusive + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be " + $opStr + " ";
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue;
|
|
} else {
|
|
out += "" + $schemaValue + "'";
|
|
}
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/_limitItems.js
|
|
var require__limitItems = __commonJS((exports, module) => {
|
|
module.exports = function generate__limitItems(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $errorKeyword;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
if (!($isData || typeof $schema == "number")) {
|
|
throw new Error($keyword + " must be number");
|
|
}
|
|
var $op = $keyword == "maxItems" ? ">" : "<";
|
|
out += "if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'number') || ";
|
|
}
|
|
out += " " + $data + ".length " + $op + " " + $schemaValue + ") { ";
|
|
var $errorKeyword = $keyword;
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "_limitItems") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { limit: " + $schemaValue + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT have ";
|
|
if ($keyword == "maxItems") {
|
|
out += "more";
|
|
} else {
|
|
out += "fewer";
|
|
}
|
|
out += " than ";
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue + " + '";
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " items' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += "} ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/_limitLength.js
|
|
var require__limitLength = __commonJS((exports, module) => {
|
|
module.exports = function generate__limitLength(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $errorKeyword;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
if (!($isData || typeof $schema == "number")) {
|
|
throw new Error($keyword + " must be number");
|
|
}
|
|
var $op = $keyword == "maxLength" ? ">" : "<";
|
|
out += "if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'number') || ";
|
|
}
|
|
if (it.opts.unicode === false) {
|
|
out += " " + $data + ".length ";
|
|
} else {
|
|
out += " ucs2length(" + $data + ") ";
|
|
}
|
|
out += " " + $op + " " + $schemaValue + ") { ";
|
|
var $errorKeyword = $keyword;
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "_limitLength") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { limit: " + $schemaValue + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT be ";
|
|
if ($keyword == "maxLength") {
|
|
out += "longer";
|
|
} else {
|
|
out += "shorter";
|
|
}
|
|
out += " than ";
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue + " + '";
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " characters' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += "} ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/_limitProperties.js
|
|
var require__limitProperties = __commonJS((exports, module) => {
|
|
module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $errorKeyword;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
if (!($isData || typeof $schema == "number")) {
|
|
throw new Error($keyword + " must be number");
|
|
}
|
|
var $op = $keyword == "maxProperties" ? ">" : "<";
|
|
out += "if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'number') || ";
|
|
}
|
|
out += " Object.keys(" + $data + ").length " + $op + " " + $schemaValue + ") { ";
|
|
var $errorKeyword = $keyword;
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "_limitProperties") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { limit: " + $schemaValue + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT have ";
|
|
if ($keyword == "maxProperties") {
|
|
out += "more";
|
|
} else {
|
|
out += "fewer";
|
|
}
|
|
out += " than ";
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue + " + '";
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " properties' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += "} ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/multipleOf.js
|
|
var require_multipleOf = __commonJS((exports, module) => {
|
|
module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
if (!($isData || typeof $schema == "number")) {
|
|
throw new Error($keyword + " must be number");
|
|
}
|
|
out += "var division" + $lvl + ";if (";
|
|
if ($isData) {
|
|
out += " " + $schemaValue + " !== undefined && ( typeof " + $schemaValue + " != 'number' || ";
|
|
}
|
|
out += " (division" + $lvl + " = " + $data + " / " + $schemaValue + ", ";
|
|
if (it.opts.multipleOfPrecision) {
|
|
out += " Math.abs(Math.round(division" + $lvl + ") - division" + $lvl + ") > 1e-" + it.opts.multipleOfPrecision + " ";
|
|
} else {
|
|
out += " division" + $lvl + " !== parseInt(division" + $lvl + ") ";
|
|
}
|
|
out += " ) ";
|
|
if ($isData) {
|
|
out += " ) ";
|
|
}
|
|
out += " ) { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "multipleOf" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { multipleOf: " + $schemaValue + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should be multiple of ";
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue;
|
|
} else {
|
|
out += "" + $schemaValue + "'";
|
|
}
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += "} ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/not.js
|
|
var require_not = __commonJS((exports, module) => {
|
|
module.exports = function generate_not(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
if (it.opts.strictKeywords ? typeof $schema == "object" && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)) {
|
|
$it.schema = $schema;
|
|
$it.schemaPath = $schemaPath;
|
|
$it.errSchemaPath = $errSchemaPath;
|
|
out += " var " + $errs + " = errors; ";
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
$it.createErrors = false;
|
|
var $allErrorsOption;
|
|
if ($it.opts.allErrors) {
|
|
$allErrorsOption = $it.opts.allErrors;
|
|
$it.opts.allErrors = false;
|
|
}
|
|
out += " " + it.validate($it) + " ";
|
|
$it.createErrors = true;
|
|
if ($allErrorsOption)
|
|
$it.opts.allErrors = $allErrorsOption;
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
out += " if (" + $nextValid + ") { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "not" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: {} ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT be valid' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } else { errors = " + $errs + "; if (vErrors !== null) { if (" + $errs + ") vErrors.length = " + $errs + "; else vErrors = null; } ";
|
|
if (it.opts.allErrors) {
|
|
out += " } ";
|
|
}
|
|
} else {
|
|
out += " var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "not" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: {} ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT be valid' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
if ($breakOnError) {
|
|
out += " if (false) { ";
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/oneOf.js
|
|
var require_oneOf = __commonJS((exports, module) => {
|
|
module.exports = function generate_oneOf(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $currentBaseId = $it.baseId, $prevValid = "prevValid" + $lvl, $passingSchemas = "passingSchemas" + $lvl;
|
|
out += "var " + $errs + " = errors , " + $prevValid + " = false , " + $valid + " = false , " + $passingSchemas + " = null; ";
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
var arr1 = $schema;
|
|
if (arr1) {
|
|
var $sch, $i = -1, l1 = arr1.length - 1;
|
|
while ($i < l1) {
|
|
$sch = arr1[$i += 1];
|
|
if (it.opts.strictKeywords ? typeof $sch == "object" && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
$it.schema = $sch;
|
|
$it.schemaPath = $schemaPath + "[" + $i + "]";
|
|
$it.errSchemaPath = $errSchemaPath + "/" + $i;
|
|
out += " " + it.validate($it) + " ";
|
|
$it.baseId = $currentBaseId;
|
|
} else {
|
|
out += " var " + $nextValid + " = true; ";
|
|
}
|
|
if ($i) {
|
|
out += " if (" + $nextValid + " && " + $prevValid + ") { " + $valid + " = false; " + $passingSchemas + " = [" + $passingSchemas + ", " + $i + "]; } else { ";
|
|
$closingBraces += "}";
|
|
}
|
|
out += " if (" + $nextValid + ") { " + $valid + " = " + $prevValid + " = true; " + $passingSchemas + " = " + $i + "; }";
|
|
}
|
|
}
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
out += "" + $closingBraces + "if (!" + $valid + ") { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "oneOf" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { passingSchemas: " + $passingSchemas + " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should match exactly one schema in oneOf' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError(vErrors); ";
|
|
} else {
|
|
out += " validate.errors = vErrors; return false; ";
|
|
}
|
|
}
|
|
out += "} else { errors = " + $errs + "; if (vErrors !== null) { if (" + $errs + ") vErrors.length = " + $errs + "; else vErrors = null; }";
|
|
if (it.opts.allErrors) {
|
|
out += " } ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/pattern.js
|
|
var require_pattern = __commonJS((exports, module) => {
|
|
module.exports = function generate_pattern(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
var $regexp = $isData ? "(new RegExp(" + $schemaValue + "))" : it.usePattern($schema);
|
|
out += "if ( ";
|
|
if ($isData) {
|
|
out += " (" + $schemaValue + " !== undefined && typeof " + $schemaValue + " != 'string') || ";
|
|
}
|
|
out += " !" + $regexp + ".test(" + $data + ") ) { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "pattern" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { pattern: ";
|
|
if ($isData) {
|
|
out += "" + $schemaValue;
|
|
} else {
|
|
out += "" + it.util.toQuotedString($schema);
|
|
}
|
|
out += " } ";
|
|
if (it.opts.messages !== false) {
|
|
out += ` , message: 'should match pattern "`;
|
|
if ($isData) {
|
|
out += "' + " + $schemaValue + " + '";
|
|
} else {
|
|
out += "" + it.util.escapeQuotes($schema);
|
|
}
|
|
out += `"' `;
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + it.util.toQuotedString($schema);
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += "} ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/properties.js
|
|
var require_properties = __commonJS((exports, module) => {
|
|
module.exports = function generate_properties(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
var $key = "key" + $lvl, $idx = "idx" + $lvl, $dataNxt = $it.dataLevel = it.dataLevel + 1, $nextData = "data" + $dataNxt, $dataProperties = "dataProperties" + $lvl;
|
|
var $schemaKeys = Object.keys($schema || {}).filter(notProto), $pProperties = it.schema.patternProperties || {}, $pPropertyKeys = Object.keys($pProperties).filter(notProto), $aProperties = it.schema.additionalProperties, $someProperties = $schemaKeys.length || $pPropertyKeys.length, $noAdditional = $aProperties === false, $additionalIsSchema = typeof $aProperties == "object" && Object.keys($aProperties).length, $removeAdditional = it.opts.removeAdditional, $checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional, $ownProperties = it.opts.ownProperties, $currentBaseId = it.baseId;
|
|
var $required = it.schema.required;
|
|
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
|
|
var $requiredHash = it.util.toHash($required);
|
|
}
|
|
function notProto(p) {
|
|
return p !== "__proto__";
|
|
}
|
|
out += "var " + $errs + " = errors;var " + $nextValid + " = true;";
|
|
if ($ownProperties) {
|
|
out += " var " + $dataProperties + " = undefined;";
|
|
}
|
|
if ($checkAdditional) {
|
|
if ($ownProperties) {
|
|
out += " " + $dataProperties + " = " + $dataProperties + " || Object.keys(" + $data + "); for (var " + $idx + "=0; " + $idx + "<" + $dataProperties + ".length; " + $idx + "++) { var " + $key + " = " + $dataProperties + "[" + $idx + "]; ";
|
|
} else {
|
|
out += " for (var " + $key + " in " + $data + ") { ";
|
|
}
|
|
if ($someProperties) {
|
|
out += " var isAdditional" + $lvl + " = !(false ";
|
|
if ($schemaKeys.length) {
|
|
if ($schemaKeys.length > 8) {
|
|
out += " || validate.schema" + $schemaPath + ".hasOwnProperty(" + $key + ") ";
|
|
} else {
|
|
var arr1 = $schemaKeys;
|
|
if (arr1) {
|
|
var $propertyKey, i1 = -1, l1 = arr1.length - 1;
|
|
while (i1 < l1) {
|
|
$propertyKey = arr1[i1 += 1];
|
|
out += " || " + $key + " == " + it.util.toQuotedString($propertyKey) + " ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($pPropertyKeys.length) {
|
|
var arr2 = $pPropertyKeys;
|
|
if (arr2) {
|
|
var $pProperty, $i = -1, l2 = arr2.length - 1;
|
|
while ($i < l2) {
|
|
$pProperty = arr2[$i += 1];
|
|
out += " || " + it.usePattern($pProperty) + ".test(" + $key + ") ";
|
|
}
|
|
}
|
|
}
|
|
out += " ); if (isAdditional" + $lvl + ") { ";
|
|
}
|
|
if ($removeAdditional == "all") {
|
|
out += " delete " + $data + "[" + $key + "]; ";
|
|
} else {
|
|
var $currentErrorPath = it.errorPath;
|
|
var $additionalProperty = "' + " + $key + " + '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
}
|
|
if ($noAdditional) {
|
|
if ($removeAdditional) {
|
|
out += " delete " + $data + "[" + $key + "]; ";
|
|
} else {
|
|
out += " " + $nextValid + " = false; ";
|
|
var $currErrSchemaPath = $errSchemaPath;
|
|
$errSchemaPath = it.errSchemaPath + "/additionalProperties";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "additionalProperties" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { additionalProperty: '" + $additionalProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is an invalid additional property";
|
|
} else {
|
|
out += "should NOT have additional properties";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: false , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
$errSchemaPath = $currErrSchemaPath;
|
|
if ($breakOnError) {
|
|
out += " break; ";
|
|
}
|
|
}
|
|
} else if ($additionalIsSchema) {
|
|
if ($removeAdditional == "failing") {
|
|
out += " var " + $errs + " = errors; ";
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
$it.schema = $aProperties;
|
|
$it.schemaPath = it.schemaPath + ".additionalProperties";
|
|
$it.errSchemaPath = it.errSchemaPath + "/additionalProperties";
|
|
$it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
var $passData = $data + "[" + $key + "]";
|
|
$it.dataPathArr[$dataNxt] = $key;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
out += " if (!" + $nextValid + ") { errors = " + $errs + "; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete " + $data + "[" + $key + "]; } ";
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
} else {
|
|
$it.schema = $aProperties;
|
|
$it.schemaPath = it.schemaPath + ".additionalProperties";
|
|
$it.errSchemaPath = it.errSchemaPath + "/additionalProperties";
|
|
$it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
var $passData = $data + "[" + $key + "]";
|
|
$it.dataPathArr[$dataNxt] = $key;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (!" + $nextValid + ") break; ";
|
|
}
|
|
}
|
|
}
|
|
it.errorPath = $currentErrorPath;
|
|
}
|
|
if ($someProperties) {
|
|
out += " } ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
var $useDefaults = it.opts.useDefaults && !it.compositeRule;
|
|
if ($schemaKeys.length) {
|
|
var arr3 = $schemaKeys;
|
|
if (arr3) {
|
|
var $propertyKey, i3 = -1, l3 = arr3.length - 1;
|
|
while (i3 < l3) {
|
|
$propertyKey = arr3[i3 += 1];
|
|
var $sch = $schema[$propertyKey];
|
|
if (it.opts.strictKeywords ? typeof $sch == "object" && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
var $prop = it.util.getProperty($propertyKey), $passData = $data + $prop, $hasDefault = $useDefaults && $sch.default !== undefined;
|
|
$it.schema = $sch;
|
|
$it.schemaPath = $schemaPath + $prop;
|
|
$it.errSchemaPath = $errSchemaPath + "/" + it.util.escapeFragment($propertyKey);
|
|
$it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
|
|
$it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
$code = it.util.varReplace($code, $nextData, $passData);
|
|
var $useData = $passData;
|
|
} else {
|
|
var $useData = $nextData;
|
|
out += " var " + $nextData + " = " + $passData + "; ";
|
|
}
|
|
if ($hasDefault) {
|
|
out += " " + $code + " ";
|
|
} else {
|
|
if ($requiredHash && $requiredHash[$propertyKey]) {
|
|
out += " if ( " + $useData + " === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += ") { " + $nextValid + " = false; ";
|
|
var $currentErrorPath = it.errorPath, $currErrSchemaPath = $errSchemaPath, $missingProperty = it.util.escapeQuotes($propertyKey);
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
|
|
}
|
|
$errSchemaPath = it.errSchemaPath + "/required";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "required" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { missingProperty: '" + $missingProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is a required property";
|
|
} else {
|
|
out += "should have required property \\'" + $missingProperty + "\\'";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
$errSchemaPath = $currErrSchemaPath;
|
|
it.errorPath = $currentErrorPath;
|
|
out += " } else { ";
|
|
} else {
|
|
if ($breakOnError) {
|
|
out += " if ( " + $useData + " === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += ") { " + $nextValid + " = true; } else { ";
|
|
} else {
|
|
out += " if (" + $useData + " !== undefined ";
|
|
if ($ownProperties) {
|
|
out += " && Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += " ) { ";
|
|
}
|
|
}
|
|
out += " " + $code + " } ";
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($pPropertyKeys.length) {
|
|
var arr4 = $pPropertyKeys;
|
|
if (arr4) {
|
|
var $pProperty, i4 = -1, l4 = arr4.length - 1;
|
|
while (i4 < l4) {
|
|
$pProperty = arr4[i4 += 1];
|
|
var $sch = $pProperties[$pProperty];
|
|
if (it.opts.strictKeywords ? typeof $sch == "object" && Object.keys($sch).length > 0 || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)) {
|
|
$it.schema = $sch;
|
|
$it.schemaPath = it.schemaPath + ".patternProperties" + it.util.getProperty($pProperty);
|
|
$it.errSchemaPath = it.errSchemaPath + "/patternProperties/" + it.util.escapeFragment($pProperty);
|
|
if ($ownProperties) {
|
|
out += " " + $dataProperties + " = " + $dataProperties + " || Object.keys(" + $data + "); for (var " + $idx + "=0; " + $idx + "<" + $dataProperties + ".length; " + $idx + "++) { var " + $key + " = " + $dataProperties + "[" + $idx + "]; ";
|
|
} else {
|
|
out += " for (var " + $key + " in " + $data + ") { ";
|
|
}
|
|
out += " if (" + it.usePattern($pProperty) + ".test(" + $key + ")) { ";
|
|
$it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
|
var $passData = $data + "[" + $key + "]";
|
|
$it.dataPathArr[$dataNxt] = $key;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " if (!" + $nextValid + ") break; ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " else " + $nextValid + " = true; ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " if (" + $nextValid + ") { ";
|
|
$closingBraces += "}";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " " + $closingBraces + " if (" + $errs + " == errors) {";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/propertyNames.js
|
|
var require_propertyNames = __commonJS((exports, module) => {
|
|
module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $errs = "errs__" + $lvl;
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
out += "var " + $errs + " = errors;";
|
|
if (it.opts.strictKeywords ? typeof $schema == "object" && Object.keys($schema).length > 0 || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)) {
|
|
$it.schema = $schema;
|
|
$it.schemaPath = $schemaPath;
|
|
$it.errSchemaPath = $errSchemaPath;
|
|
var $key = "key" + $lvl, $idx = "idx" + $lvl, $i = "i" + $lvl, $invalidName = "' + " + $key + " + '", $dataNxt = $it.dataLevel = it.dataLevel + 1, $nextData = "data" + $dataNxt, $dataProperties = "dataProperties" + $lvl, $ownProperties = it.opts.ownProperties, $currentBaseId = it.baseId;
|
|
if ($ownProperties) {
|
|
out += " var " + $dataProperties + " = undefined; ";
|
|
}
|
|
if ($ownProperties) {
|
|
out += " " + $dataProperties + " = " + $dataProperties + " || Object.keys(" + $data + "); for (var " + $idx + "=0; " + $idx + "<" + $dataProperties + ".length; " + $idx + "++) { var " + $key + " = " + $dataProperties + "[" + $idx + "]; ";
|
|
} else {
|
|
out += " for (var " + $key + " in " + $data + ") { ";
|
|
}
|
|
out += " var startErrs" + $lvl + " = errors; ";
|
|
var $passData = $key;
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
var $code = it.validate($it);
|
|
$it.baseId = $currentBaseId;
|
|
if (it.util.varOccurences($code, $nextData) < 2) {
|
|
out += " " + it.util.varReplace($code, $nextData, $passData) + " ";
|
|
} else {
|
|
out += " var " + $nextData + " = " + $passData + "; " + $code + " ";
|
|
}
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
out += " if (!" + $nextValid + ") { for (var " + $i + "=startErrs" + $lvl + "; " + $i + "<errors; " + $i + "++) { vErrors[" + $i + "].propertyName = " + $key + "; } var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "propertyNames" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { propertyName: '" + $invalidName + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'property name \\'" + $invalidName + "\\' is invalid' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError(vErrors); ";
|
|
} else {
|
|
out += " validate.errors = vErrors; return false; ";
|
|
}
|
|
}
|
|
if ($breakOnError) {
|
|
out += " break; ";
|
|
}
|
|
out += " } }";
|
|
}
|
|
if ($breakOnError) {
|
|
out += " " + $closingBraces + " if (" + $errs + " == errors) {";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/required.js
|
|
var require_required = __commonJS((exports, module) => {
|
|
module.exports = function generate_required(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
var $vSchema = "schema" + $lvl;
|
|
if (!$isData) {
|
|
if ($schema.length < it.opts.loopRequired && it.schema.properties && Object.keys(it.schema.properties).length) {
|
|
var $required = [];
|
|
var arr1 = $schema;
|
|
if (arr1) {
|
|
var $property, i1 = -1, l1 = arr1.length - 1;
|
|
while (i1 < l1) {
|
|
$property = arr1[i1 += 1];
|
|
var $propertySch = it.schema.properties[$property];
|
|
if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == "object" && Object.keys($propertySch).length > 0 || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) {
|
|
$required[$required.length] = $property;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
var $required = $schema;
|
|
}
|
|
}
|
|
if ($isData || $required.length) {
|
|
var $currentErrorPath = it.errorPath, $loopRequired = $isData || $required.length >= it.opts.loopRequired, $ownProperties = it.opts.ownProperties;
|
|
if ($breakOnError) {
|
|
out += " var missing" + $lvl + "; ";
|
|
if ($loopRequired) {
|
|
if (!$isData) {
|
|
out += " var " + $vSchema + " = validate.schema" + $schemaPath + "; ";
|
|
}
|
|
var $i = "i" + $lvl, $propertyPath = "schema" + $lvl + "[" + $i + "]", $missingProperty = "' + " + $propertyPath + " + '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
|
|
}
|
|
out += " var " + $valid + " = true; ";
|
|
if ($isData) {
|
|
out += " if (schema" + $lvl + " === undefined) " + $valid + " = true; else if (!Array.isArray(schema" + $lvl + ")) " + $valid + " = false; else {";
|
|
}
|
|
out += " for (var " + $i + " = 0; " + $i + " < " + $vSchema + ".length; " + $i + "++) { " + $valid + " = " + $data + "[" + $vSchema + "[" + $i + "]] !== undefined ";
|
|
if ($ownProperties) {
|
|
out += " && Object.prototype.hasOwnProperty.call(" + $data + ", " + $vSchema + "[" + $i + "]) ";
|
|
}
|
|
out += "; if (!" + $valid + ") break; } ";
|
|
if ($isData) {
|
|
out += " } ";
|
|
}
|
|
out += " if (!" + $valid + ") { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "required" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { missingProperty: '" + $missingProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is a required property";
|
|
} else {
|
|
out += "should have required property \\'" + $missingProperty + "\\'";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } else { ";
|
|
} else {
|
|
out += " if ( ";
|
|
var arr2 = $required;
|
|
if (arr2) {
|
|
var $propertyKey, $i = -1, l2 = arr2.length - 1;
|
|
while ($i < l2) {
|
|
$propertyKey = arr2[$i += 1];
|
|
if ($i) {
|
|
out += " || ";
|
|
}
|
|
var $prop = it.util.getProperty($propertyKey), $useData = $data + $prop;
|
|
out += " ( ( " + $useData + " === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += ") && (missing" + $lvl + " = " + it.util.toQuotedString(it.opts.jsonPointers ? $propertyKey : $prop) + ") ) ";
|
|
}
|
|
}
|
|
out += ") { ";
|
|
var $propertyPath = "missing" + $lvl, $missingProperty = "' + " + $propertyPath + " + '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.opts.jsonPointers ? it.util.getPathExpr($currentErrorPath, $propertyPath, true) : $currentErrorPath + " + " + $propertyPath;
|
|
}
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "required" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { missingProperty: '" + $missingProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is a required property";
|
|
} else {
|
|
out += "should have required property \\'" + $missingProperty + "\\'";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } else { ";
|
|
}
|
|
} else {
|
|
if ($loopRequired) {
|
|
if (!$isData) {
|
|
out += " var " + $vSchema + " = validate.schema" + $schemaPath + "; ";
|
|
}
|
|
var $i = "i" + $lvl, $propertyPath = "schema" + $lvl + "[" + $i + "]", $missingProperty = "' + " + $propertyPath + " + '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.util.getPathExpr($currentErrorPath, $propertyPath, it.opts.jsonPointers);
|
|
}
|
|
if ($isData) {
|
|
out += " if (" + $vSchema + " && !Array.isArray(" + $vSchema + ")) { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "required" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { missingProperty: '" + $missingProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is a required property";
|
|
} else {
|
|
out += "should have required property \\'" + $missingProperty + "\\'";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (" + $vSchema + " !== undefined) { ";
|
|
}
|
|
out += " for (var " + $i + " = 0; " + $i + " < " + $vSchema + ".length; " + $i + "++) { if (" + $data + "[" + $vSchema + "[" + $i + "]] === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", " + $vSchema + "[" + $i + "]) ";
|
|
}
|
|
out += ") { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "required" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { missingProperty: '" + $missingProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is a required property";
|
|
} else {
|
|
out += "should have required property \\'" + $missingProperty + "\\'";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ";
|
|
if ($isData) {
|
|
out += " } ";
|
|
}
|
|
} else {
|
|
var arr3 = $required;
|
|
if (arr3) {
|
|
var $propertyKey, i3 = -1, l3 = arr3.length - 1;
|
|
while (i3 < l3) {
|
|
$propertyKey = arr3[i3 += 1];
|
|
var $prop = it.util.getProperty($propertyKey), $missingProperty = it.util.escapeQuotes($propertyKey), $useData = $data + $prop;
|
|
if (it.opts._errorDataPathProperty) {
|
|
it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
|
|
}
|
|
out += " if ( " + $useData + " === undefined ";
|
|
if ($ownProperties) {
|
|
out += " || ! Object.prototype.hasOwnProperty.call(" + $data + ", '" + it.util.escapeQuotes($propertyKey) + "') ";
|
|
}
|
|
out += ") { var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "required" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { missingProperty: '" + $missingProperty + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: '";
|
|
if (it.opts._errorDataPathProperty) {
|
|
out += "is a required property";
|
|
} else {
|
|
out += "should have required property \\'" + $missingProperty + "\\'";
|
|
}
|
|
out += "' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
it.errorPath = $currentErrorPath;
|
|
} else if ($breakOnError) {
|
|
out += " if (true) {";
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/uniqueItems.js
|
|
var require_uniqueItems = __commonJS((exports, module) => {
|
|
module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
if (($schema || $isData) && it.opts.uniqueItems !== false) {
|
|
if ($isData) {
|
|
out += " var " + $valid + "; if (" + $schemaValue + " === false || " + $schemaValue + " === undefined) " + $valid + " = true; else if (typeof " + $schemaValue + " != 'boolean') " + $valid + " = false; else { ";
|
|
}
|
|
out += " var i = " + $data + ".length , " + $valid + " = true , j; if (i > 1) { ";
|
|
var $itemType = it.schema.items && it.schema.items.type, $typeIsArray = Array.isArray($itemType);
|
|
if (!$itemType || $itemType == "object" || $itemType == "array" || $typeIsArray && ($itemType.indexOf("object") >= 0 || $itemType.indexOf("array") >= 0)) {
|
|
out += " outer: for (;i--;) { for (j = i; j--;) { if (equal(" + $data + "[i], " + $data + "[j])) { " + $valid + " = false; break outer; } } } ";
|
|
} else {
|
|
out += " var itemIndices = {}, item; for (;i--;) { var item = " + $data + "[i]; ";
|
|
var $method = "checkDataType" + ($typeIsArray ? "s" : "");
|
|
out += " if (" + it.util[$method]($itemType, "item", it.opts.strictNumbers, true) + ") continue; ";
|
|
if ($typeIsArray) {
|
|
out += ` if (typeof item == 'string') item = '"' + item; `;
|
|
}
|
|
out += " if (typeof itemIndices[item] == 'number') { " + $valid + " = false; j = itemIndices[item]; break; } itemIndices[item] = i; } ";
|
|
}
|
|
out += " } ";
|
|
if ($isData) {
|
|
out += " } ";
|
|
}
|
|
out += " if (!" + $valid + ") { ";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + "uniqueItems" + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { i: i, j: j } ";
|
|
if (it.opts.messages !== false) {
|
|
out += " , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' ";
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: ";
|
|
if ($isData) {
|
|
out += "validate.schema" + $schemaPath;
|
|
} else {
|
|
out += "" + $schema;
|
|
}
|
|
out += " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
} else {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/index.js
|
|
var require_dotjs = __commonJS((exports, module) => {
|
|
module.exports = {
|
|
$ref: require_ref(),
|
|
allOf: require_allOf(),
|
|
anyOf: require_anyOf(),
|
|
$comment: require_comment(),
|
|
const: require_const(),
|
|
contains: require_contains(),
|
|
dependencies: require_dependencies(),
|
|
enum: require_enum(),
|
|
format: require_format(),
|
|
if: require_if(),
|
|
items: require_items(),
|
|
maximum: require__limit(),
|
|
minimum: require__limit(),
|
|
maxItems: require__limitItems(),
|
|
minItems: require__limitItems(),
|
|
maxLength: require__limitLength(),
|
|
minLength: require__limitLength(),
|
|
maxProperties: require__limitProperties(),
|
|
minProperties: require__limitProperties(),
|
|
multipleOf: require_multipleOf(),
|
|
not: require_not(),
|
|
oneOf: require_oneOf(),
|
|
pattern: require_pattern(),
|
|
properties: require_properties(),
|
|
propertyNames: require_propertyNames(),
|
|
required: require_required(),
|
|
uniqueItems: require_uniqueItems(),
|
|
validate: require_validate()
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/rules.js
|
|
var require_rules = __commonJS((exports, module) => {
|
|
var ruleModules = require_dotjs();
|
|
var toHash = require_util().toHash;
|
|
module.exports = function rules() {
|
|
var RULES = [
|
|
{
|
|
type: "number",
|
|
rules: [
|
|
{ maximum: ["exclusiveMaximum"] },
|
|
{ minimum: ["exclusiveMinimum"] },
|
|
"multipleOf",
|
|
"format"
|
|
]
|
|
},
|
|
{
|
|
type: "string",
|
|
rules: ["maxLength", "minLength", "pattern", "format"]
|
|
},
|
|
{
|
|
type: "array",
|
|
rules: ["maxItems", "minItems", "items", "contains", "uniqueItems"]
|
|
},
|
|
{
|
|
type: "object",
|
|
rules: [
|
|
"maxProperties",
|
|
"minProperties",
|
|
"required",
|
|
"dependencies",
|
|
"propertyNames",
|
|
{ properties: ["additionalProperties", "patternProperties"] }
|
|
]
|
|
},
|
|
{ rules: ["$ref", "const", "enum", "not", "anyOf", "oneOf", "allOf", "if"] }
|
|
];
|
|
var ALL = ["type", "$comment"];
|
|
var KEYWORDS = [
|
|
"$schema",
|
|
"$id",
|
|
"id",
|
|
"$data",
|
|
"$async",
|
|
"title",
|
|
"description",
|
|
"default",
|
|
"definitions",
|
|
"examples",
|
|
"readOnly",
|
|
"writeOnly",
|
|
"contentMediaType",
|
|
"contentEncoding",
|
|
"additionalItems",
|
|
"then",
|
|
"else"
|
|
];
|
|
var TYPES = ["number", "integer", "string", "array", "object", "boolean", "null"];
|
|
RULES.all = toHash(ALL);
|
|
RULES.types = toHash(TYPES);
|
|
RULES.forEach(function(group) {
|
|
group.rules = group.rules.map(function(keyword) {
|
|
var implKeywords;
|
|
if (typeof keyword == "object") {
|
|
var key = Object.keys(keyword)[0];
|
|
implKeywords = keyword[key];
|
|
keyword = key;
|
|
implKeywords.forEach(function(k) {
|
|
ALL.push(k);
|
|
RULES.all[k] = true;
|
|
});
|
|
}
|
|
ALL.push(keyword);
|
|
var rule = RULES.all[keyword] = {
|
|
keyword,
|
|
code: ruleModules[keyword],
|
|
implements: implKeywords
|
|
};
|
|
return rule;
|
|
});
|
|
RULES.all.$comment = {
|
|
keyword: "$comment",
|
|
code: ruleModules.$comment
|
|
};
|
|
if (group.type)
|
|
RULES.types[group.type] = group;
|
|
});
|
|
RULES.keywords = toHash(ALL.concat(KEYWORDS));
|
|
RULES.custom = {};
|
|
return RULES;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/data.js
|
|
var require_data = __commonJS((exports, module) => {
|
|
var KEYWORDS = [
|
|
"multipleOf",
|
|
"maximum",
|
|
"exclusiveMaximum",
|
|
"minimum",
|
|
"exclusiveMinimum",
|
|
"maxLength",
|
|
"minLength",
|
|
"pattern",
|
|
"additionalItems",
|
|
"maxItems",
|
|
"minItems",
|
|
"uniqueItems",
|
|
"maxProperties",
|
|
"minProperties",
|
|
"required",
|
|
"additionalProperties",
|
|
"enum",
|
|
"format",
|
|
"const"
|
|
];
|
|
module.exports = function(metaSchema, keywordsJsonPointers) {
|
|
for (var i = 0;i < keywordsJsonPointers.length; i++) {
|
|
metaSchema = JSON.parse(JSON.stringify(metaSchema));
|
|
var segments = keywordsJsonPointers[i].split("/");
|
|
var keywords = metaSchema;
|
|
var j;
|
|
for (j = 1;j < segments.length; j++)
|
|
keywords = keywords[segments[j]];
|
|
for (j = 0;j < KEYWORDS.length; j++) {
|
|
var key = KEYWORDS[j];
|
|
var schema = keywords[key];
|
|
if (schema) {
|
|
keywords[key] = {
|
|
anyOf: [
|
|
schema,
|
|
{ $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#" }
|
|
]
|
|
};
|
|
}
|
|
}
|
|
}
|
|
return metaSchema;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/compile/async.js
|
|
var require_async = __commonJS((exports, module) => {
|
|
var MissingRefError = require_error_classes().MissingRef;
|
|
module.exports = compileAsync;
|
|
function compileAsync(schema, meta, callback) {
|
|
var self = this;
|
|
if (typeof this._opts.loadSchema != "function")
|
|
throw new Error("options.loadSchema should be a function");
|
|
if (typeof meta == "function") {
|
|
callback = meta;
|
|
meta = undefined;
|
|
}
|
|
var p = loadMetaSchemaOf(schema).then(function() {
|
|
var schemaObj = self._addSchema(schema, undefined, meta);
|
|
return schemaObj.validate || _compileAsync(schemaObj);
|
|
});
|
|
if (callback) {
|
|
p.then(function(v) {
|
|
callback(null, v);
|
|
}, callback);
|
|
}
|
|
return p;
|
|
function loadMetaSchemaOf(sch) {
|
|
var $schema = sch.$schema;
|
|
return $schema && !self.getSchema($schema) ? compileAsync.call(self, { $ref: $schema }, true) : Promise.resolve();
|
|
}
|
|
function _compileAsync(schemaObj) {
|
|
try {
|
|
return self._compile(schemaObj);
|
|
} catch (e) {
|
|
if (e instanceof MissingRefError)
|
|
return loadMissingSchema(e);
|
|
throw e;
|
|
}
|
|
function loadMissingSchema(e) {
|
|
var ref = e.missingSchema;
|
|
if (added(ref))
|
|
throw new Error("Schema " + ref + " is loaded but " + e.missingRef + " cannot be resolved");
|
|
var schemaPromise = self._loadingSchemas[ref];
|
|
if (!schemaPromise) {
|
|
schemaPromise = self._loadingSchemas[ref] = self._opts.loadSchema(ref);
|
|
schemaPromise.then(removePromise, removePromise);
|
|
}
|
|
return schemaPromise.then(function(sch) {
|
|
if (!added(ref)) {
|
|
return loadMetaSchemaOf(sch).then(function() {
|
|
if (!added(ref))
|
|
self.addSchema(sch, ref, undefined, meta);
|
|
});
|
|
}
|
|
}).then(function() {
|
|
return _compileAsync(schemaObj);
|
|
});
|
|
function removePromise() {
|
|
delete self._loadingSchemas[ref];
|
|
}
|
|
function added(ref2) {
|
|
return self._refs[ref2] || self._schemas[ref2];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/dotjs/custom.js
|
|
var require_custom = __commonJS((exports, module) => {
|
|
module.exports = function generate_custom(it, $keyword, $ruleType) {
|
|
var out = " ";
|
|
var $lvl = it.level;
|
|
var $dataLvl = it.dataLevel;
|
|
var $schema = it.schema[$keyword];
|
|
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
|
var $errSchemaPath = it.errSchemaPath + "/" + $keyword;
|
|
var $breakOnError = !it.opts.allErrors;
|
|
var $errorKeyword;
|
|
var $data = "data" + ($dataLvl || "");
|
|
var $valid = "valid" + $lvl;
|
|
var $errs = "errs__" + $lvl;
|
|
var $isData = it.opts.$data && $schema && $schema.$data, $schemaValue;
|
|
if ($isData) {
|
|
out += " var schema" + $lvl + " = " + it.util.getData($schema.$data, $dataLvl, it.dataPathArr) + "; ";
|
|
$schemaValue = "schema" + $lvl;
|
|
} else {
|
|
$schemaValue = $schema;
|
|
}
|
|
var $rule = this, $definition = "definition" + $lvl, $rDef = $rule.definition, $closingBraces = "";
|
|
var $compile, $inline, $macro, $ruleValidate, $validateCode;
|
|
if ($isData && $rDef.$data) {
|
|
$validateCode = "keywordValidate" + $lvl;
|
|
var $validateSchema = $rDef.validateSchema;
|
|
out += " var " + $definition + " = RULES.custom['" + $keyword + "'].definition; var " + $validateCode + " = " + $definition + ".validate;";
|
|
} else {
|
|
$ruleValidate = it.useCustomRule($rule, $schema, it.schema, it);
|
|
if (!$ruleValidate)
|
|
return;
|
|
$schemaValue = "validate.schema" + $schemaPath;
|
|
$validateCode = $ruleValidate.code;
|
|
$compile = $rDef.compile;
|
|
$inline = $rDef.inline;
|
|
$macro = $rDef.macro;
|
|
}
|
|
var $ruleErrs = $validateCode + ".errors", $i = "i" + $lvl, $ruleErr = "ruleErr" + $lvl, $asyncKeyword = $rDef.async;
|
|
if ($asyncKeyword && !it.async)
|
|
throw new Error("async keyword in sync schema");
|
|
if (!($inline || $macro)) {
|
|
out += "" + $ruleErrs + " = null;";
|
|
}
|
|
out += "var " + $errs + " = errors;var " + $valid + ";";
|
|
if ($isData && $rDef.$data) {
|
|
$closingBraces += "}";
|
|
out += " if (" + $schemaValue + " === undefined) { " + $valid + " = true; } else { ";
|
|
if ($validateSchema) {
|
|
$closingBraces += "}";
|
|
out += " " + $valid + " = " + $definition + ".validateSchema(" + $schemaValue + "); if (" + $valid + ") { ";
|
|
}
|
|
}
|
|
if ($inline) {
|
|
if ($rDef.statements) {
|
|
out += " " + $ruleValidate.validate + " ";
|
|
} else {
|
|
out += " " + $valid + " = " + $ruleValidate.validate + "; ";
|
|
}
|
|
} else if ($macro) {
|
|
var $it = it.util.copy(it);
|
|
var $closingBraces = "";
|
|
$it.level++;
|
|
var $nextValid = "valid" + $it.level;
|
|
$it.schema = $ruleValidate.validate;
|
|
$it.schemaPath = "";
|
|
var $wasComposite = it.compositeRule;
|
|
it.compositeRule = $it.compositeRule = true;
|
|
var $code = it.validate($it).replace(/validate\.schema/g, $validateCode);
|
|
it.compositeRule = $it.compositeRule = $wasComposite;
|
|
out += " " + $code;
|
|
} else {
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
out += " " + $validateCode + ".call( ";
|
|
if (it.opts.passContext) {
|
|
out += "this";
|
|
} else {
|
|
out += "self";
|
|
}
|
|
if ($compile || $rDef.schema === false) {
|
|
out += " , " + $data + " ";
|
|
} else {
|
|
out += " , " + $schemaValue + " , " + $data + " , validate.schema" + it.schemaPath + " ";
|
|
}
|
|
out += " , (dataPath || '')";
|
|
if (it.errorPath != '""') {
|
|
out += " + " + it.errorPath;
|
|
}
|
|
var $parentData = $dataLvl ? "data" + ($dataLvl - 1 || "") : "parentData", $parentDataProperty = $dataLvl ? it.dataPathArr[$dataLvl] : "parentDataProperty";
|
|
out += " , " + $parentData + " , " + $parentDataProperty + " , rootData ) ";
|
|
var def_callRuleValidate = out;
|
|
out = $$outStack.pop();
|
|
if ($rDef.errors === false) {
|
|
out += " " + $valid + " = ";
|
|
if ($asyncKeyword) {
|
|
out += "await ";
|
|
}
|
|
out += "" + def_callRuleValidate + "; ";
|
|
} else {
|
|
if ($asyncKeyword) {
|
|
$ruleErrs = "customErrors" + $lvl;
|
|
out += " var " + $ruleErrs + " = null; try { " + $valid + " = await " + def_callRuleValidate + "; } catch (e) { " + $valid + " = false; if (e instanceof ValidationError) " + $ruleErrs + " = e.errors; else throw e; } ";
|
|
} else {
|
|
out += " " + $ruleErrs + " = null; " + $valid + " = " + def_callRuleValidate + "; ";
|
|
}
|
|
}
|
|
}
|
|
if ($rDef.modifying) {
|
|
out += " if (" + $parentData + ") " + $data + " = " + $parentData + "[" + $parentDataProperty + "];";
|
|
}
|
|
out += "" + $closingBraces;
|
|
if ($rDef.valid) {
|
|
if ($breakOnError) {
|
|
out += " if (true) { ";
|
|
}
|
|
} else {
|
|
out += " if ( ";
|
|
if ($rDef.valid === undefined) {
|
|
out += " !";
|
|
if ($macro) {
|
|
out += "" + $nextValid;
|
|
} else {
|
|
out += "" + $valid;
|
|
}
|
|
} else {
|
|
out += " " + !$rDef.valid + " ";
|
|
}
|
|
out += ") { ";
|
|
$errorKeyword = $rule.keyword;
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
var $$outStack = $$outStack || [];
|
|
$$outStack.push(out);
|
|
out = "";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "custom") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { keyword: '" + $rule.keyword + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += ` , message: 'should pass "` + $rule.keyword + `" keyword validation' `;
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
var __err = out;
|
|
out = $$outStack.pop();
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError([" + __err + "]); ";
|
|
} else {
|
|
out += " validate.errors = [" + __err + "]; return false; ";
|
|
}
|
|
} else {
|
|
out += " var err = " + __err + "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
}
|
|
var def_customError = out;
|
|
out = $$outStack.pop();
|
|
if ($inline) {
|
|
if ($rDef.errors) {
|
|
if ($rDef.errors != "full") {
|
|
out += " for (var " + $i + "=" + $errs + "; " + $i + "<errors; " + $i + "++) { var " + $ruleErr + " = vErrors[" + $i + "]; if (" + $ruleErr + ".dataPath === undefined) " + $ruleErr + ".dataPath = (dataPath || '') + " + it.errorPath + "; if (" + $ruleErr + ".schemaPath === undefined) { " + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; } ';
|
|
if (it.opts.verbose) {
|
|
out += " " + $ruleErr + ".schema = " + $schemaValue + "; " + $ruleErr + ".data = " + $data + "; ";
|
|
}
|
|
out += " } ";
|
|
}
|
|
} else {
|
|
if ($rDef.errors === false) {
|
|
out += " " + def_customError + " ";
|
|
} else {
|
|
out += " if (" + $errs + " == errors) { " + def_customError + " } else { for (var " + $i + "=" + $errs + "; " + $i + "<errors; " + $i + "++) { var " + $ruleErr + " = vErrors[" + $i + "]; if (" + $ruleErr + ".dataPath === undefined) " + $ruleErr + ".dataPath = (dataPath || '') + " + it.errorPath + "; if (" + $ruleErr + ".schemaPath === undefined) { " + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; } ';
|
|
if (it.opts.verbose) {
|
|
out += " " + $ruleErr + ".schema = " + $schemaValue + "; " + $ruleErr + ".data = " + $data + "; ";
|
|
}
|
|
out += " } } ";
|
|
}
|
|
}
|
|
} else if ($macro) {
|
|
out += " var err = ";
|
|
if (it.createErrors !== false) {
|
|
out += " { keyword: '" + ($errorKeyword || "custom") + "' , dataPath: (dataPath || '') + " + it.errorPath + " , schemaPath: " + it.util.toQuotedString($errSchemaPath) + " , params: { keyword: '" + $rule.keyword + "' } ";
|
|
if (it.opts.messages !== false) {
|
|
out += ` , message: 'should pass "` + $rule.keyword + `" keyword validation' `;
|
|
}
|
|
if (it.opts.verbose) {
|
|
out += " , schema: validate.schema" + $schemaPath + " , parentSchema: validate.schema" + it.schemaPath + " , data: " + $data + " ";
|
|
}
|
|
out += " } ";
|
|
} else {
|
|
out += " {} ";
|
|
}
|
|
out += "; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";
|
|
if (!it.compositeRule && $breakOnError) {
|
|
if (it.async) {
|
|
out += " throw new ValidationError(vErrors); ";
|
|
} else {
|
|
out += " validate.errors = vErrors; return false; ";
|
|
}
|
|
}
|
|
} else {
|
|
if ($rDef.errors === false) {
|
|
out += " " + def_customError + " ";
|
|
} else {
|
|
out += " if (Array.isArray(" + $ruleErrs + ")) { if (vErrors === null) vErrors = " + $ruleErrs + "; else vErrors = vErrors.concat(" + $ruleErrs + "); errors = vErrors.length; for (var " + $i + "=" + $errs + "; " + $i + "<errors; " + $i + "++) { var " + $ruleErr + " = vErrors[" + $i + "]; if (" + $ruleErr + ".dataPath === undefined) " + $ruleErr + ".dataPath = (dataPath || '') + " + it.errorPath + "; " + $ruleErr + '.schemaPath = "' + $errSchemaPath + '"; ';
|
|
if (it.opts.verbose) {
|
|
out += " " + $ruleErr + ".schema = " + $schemaValue + "; " + $ruleErr + ".data = " + $data + "; ";
|
|
}
|
|
out += " } } else { " + def_customError + " } ";
|
|
}
|
|
}
|
|
out += " } ";
|
|
if ($breakOnError) {
|
|
out += " else { ";
|
|
}
|
|
}
|
|
return out;
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/refs/json-schema-draft-07.json
|
|
var require_json_schema_draft_07 = __commonJS((exports, module) => {
|
|
module.exports = {
|
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
$id: "http://json-schema.org/draft-07/schema#",
|
|
title: "Core schema meta-schema",
|
|
definitions: {
|
|
schemaArray: {
|
|
type: "array",
|
|
minItems: 1,
|
|
items: { $ref: "#" }
|
|
},
|
|
nonNegativeInteger: {
|
|
type: "integer",
|
|
minimum: 0
|
|
},
|
|
nonNegativeIntegerDefault0: {
|
|
allOf: [
|
|
{ $ref: "#/definitions/nonNegativeInteger" },
|
|
{ default: 0 }
|
|
]
|
|
},
|
|
simpleTypes: {
|
|
enum: [
|
|
"array",
|
|
"boolean",
|
|
"integer",
|
|
"null",
|
|
"number",
|
|
"object",
|
|
"string"
|
|
]
|
|
},
|
|
stringArray: {
|
|
type: "array",
|
|
items: { type: "string" },
|
|
uniqueItems: true,
|
|
default: []
|
|
}
|
|
},
|
|
type: ["object", "boolean"],
|
|
properties: {
|
|
$id: {
|
|
type: "string",
|
|
format: "uri-reference"
|
|
},
|
|
$schema: {
|
|
type: "string",
|
|
format: "uri"
|
|
},
|
|
$ref: {
|
|
type: "string",
|
|
format: "uri-reference"
|
|
},
|
|
$comment: {
|
|
type: "string"
|
|
},
|
|
title: {
|
|
type: "string"
|
|
},
|
|
description: {
|
|
type: "string"
|
|
},
|
|
default: true,
|
|
readOnly: {
|
|
type: "boolean",
|
|
default: false
|
|
},
|
|
examples: {
|
|
type: "array",
|
|
items: true
|
|
},
|
|
multipleOf: {
|
|
type: "number",
|
|
exclusiveMinimum: 0
|
|
},
|
|
maximum: {
|
|
type: "number"
|
|
},
|
|
exclusiveMaximum: {
|
|
type: "number"
|
|
},
|
|
minimum: {
|
|
type: "number"
|
|
},
|
|
exclusiveMinimum: {
|
|
type: "number"
|
|
},
|
|
maxLength: { $ref: "#/definitions/nonNegativeInteger" },
|
|
minLength: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
pattern: {
|
|
type: "string",
|
|
format: "regex"
|
|
},
|
|
additionalItems: { $ref: "#" },
|
|
items: {
|
|
anyOf: [
|
|
{ $ref: "#" },
|
|
{ $ref: "#/definitions/schemaArray" }
|
|
],
|
|
default: true
|
|
},
|
|
maxItems: { $ref: "#/definitions/nonNegativeInteger" },
|
|
minItems: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
uniqueItems: {
|
|
type: "boolean",
|
|
default: false
|
|
},
|
|
contains: { $ref: "#" },
|
|
maxProperties: { $ref: "#/definitions/nonNegativeInteger" },
|
|
minProperties: { $ref: "#/definitions/nonNegativeIntegerDefault0" },
|
|
required: { $ref: "#/definitions/stringArray" },
|
|
additionalProperties: { $ref: "#" },
|
|
definitions: {
|
|
type: "object",
|
|
additionalProperties: { $ref: "#" },
|
|
default: {}
|
|
},
|
|
properties: {
|
|
type: "object",
|
|
additionalProperties: { $ref: "#" },
|
|
default: {}
|
|
},
|
|
patternProperties: {
|
|
type: "object",
|
|
additionalProperties: { $ref: "#" },
|
|
propertyNames: { format: "regex" },
|
|
default: {}
|
|
},
|
|
dependencies: {
|
|
type: "object",
|
|
additionalProperties: {
|
|
anyOf: [
|
|
{ $ref: "#" },
|
|
{ $ref: "#/definitions/stringArray" }
|
|
]
|
|
}
|
|
},
|
|
propertyNames: { $ref: "#" },
|
|
const: true,
|
|
enum: {
|
|
type: "array",
|
|
items: true,
|
|
minItems: 1,
|
|
uniqueItems: true
|
|
},
|
|
type: {
|
|
anyOf: [
|
|
{ $ref: "#/definitions/simpleTypes" },
|
|
{
|
|
type: "array",
|
|
items: { $ref: "#/definitions/simpleTypes" },
|
|
minItems: 1,
|
|
uniqueItems: true
|
|
}
|
|
]
|
|
},
|
|
format: { type: "string" },
|
|
contentMediaType: { type: "string" },
|
|
contentEncoding: { type: "string" },
|
|
if: { $ref: "#" },
|
|
then: { $ref: "#" },
|
|
else: { $ref: "#" },
|
|
allOf: { $ref: "#/definitions/schemaArray" },
|
|
anyOf: { $ref: "#/definitions/schemaArray" },
|
|
oneOf: { $ref: "#/definitions/schemaArray" },
|
|
not: { $ref: "#" }
|
|
},
|
|
default: true
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/definition_schema.js
|
|
var require_definition_schema = __commonJS((exports, module) => {
|
|
var metaSchema = require_json_schema_draft_07();
|
|
module.exports = {
|
|
$id: "https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",
|
|
definitions: {
|
|
simpleTypes: metaSchema.definitions.simpleTypes
|
|
},
|
|
type: "object",
|
|
dependencies: {
|
|
schema: ["validate"],
|
|
$data: ["validate"],
|
|
statements: ["inline"],
|
|
valid: { not: { required: ["macro"] } }
|
|
},
|
|
properties: {
|
|
type: metaSchema.properties.type,
|
|
schema: { type: "boolean" },
|
|
statements: { type: "boolean" },
|
|
dependencies: {
|
|
type: "array",
|
|
items: { type: "string" }
|
|
},
|
|
metaSchema: { type: "object" },
|
|
modifying: { type: "boolean" },
|
|
valid: { type: "boolean" },
|
|
$data: { type: "boolean" },
|
|
async: { type: "boolean" },
|
|
errors: {
|
|
anyOf: [
|
|
{ type: "boolean" },
|
|
{ const: "full" }
|
|
]
|
|
}
|
|
}
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/keyword.js
|
|
var require_keyword = __commonJS((exports, module) => {
|
|
var IDENTIFIER = /^[a-z_$][a-z0-9_$-]*$/i;
|
|
var customRuleCode = require_custom();
|
|
var definitionSchema = require_definition_schema();
|
|
module.exports = {
|
|
add: addKeyword,
|
|
get: getKeyword,
|
|
remove: removeKeyword,
|
|
validate: validateKeyword
|
|
};
|
|
function addKeyword(keyword, definition) {
|
|
var RULES = this.RULES;
|
|
if (RULES.keywords[keyword])
|
|
throw new Error("Keyword " + keyword + " is already defined");
|
|
if (!IDENTIFIER.test(keyword))
|
|
throw new Error("Keyword " + keyword + " is not a valid identifier");
|
|
if (definition) {
|
|
this.validateKeyword(definition, true);
|
|
var dataType = definition.type;
|
|
if (Array.isArray(dataType)) {
|
|
for (var i = 0;i < dataType.length; i++)
|
|
_addRule(keyword, dataType[i], definition);
|
|
} else {
|
|
_addRule(keyword, dataType, definition);
|
|
}
|
|
var metaSchema = definition.metaSchema;
|
|
if (metaSchema) {
|
|
if (definition.$data && this._opts.$data) {
|
|
metaSchema = {
|
|
anyOf: [
|
|
metaSchema,
|
|
{ $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#" }
|
|
]
|
|
};
|
|
}
|
|
definition.validateSchema = this.compile(metaSchema, true);
|
|
}
|
|
}
|
|
RULES.keywords[keyword] = RULES.all[keyword] = true;
|
|
function _addRule(keyword2, dataType2, definition2) {
|
|
var ruleGroup;
|
|
for (var i2 = 0;i2 < RULES.length; i2++) {
|
|
var rg = RULES[i2];
|
|
if (rg.type == dataType2) {
|
|
ruleGroup = rg;
|
|
break;
|
|
}
|
|
}
|
|
if (!ruleGroup) {
|
|
ruleGroup = { type: dataType2, rules: [] };
|
|
RULES.push(ruleGroup);
|
|
}
|
|
var rule = {
|
|
keyword: keyword2,
|
|
definition: definition2,
|
|
custom: true,
|
|
code: customRuleCode,
|
|
implements: definition2.implements
|
|
};
|
|
ruleGroup.rules.push(rule);
|
|
RULES.custom[keyword2] = rule;
|
|
}
|
|
return this;
|
|
}
|
|
function getKeyword(keyword) {
|
|
var rule = this.RULES.custom[keyword];
|
|
return rule ? rule.definition : this.RULES.keywords[keyword] || false;
|
|
}
|
|
function removeKeyword(keyword) {
|
|
var RULES = this.RULES;
|
|
delete RULES.keywords[keyword];
|
|
delete RULES.all[keyword];
|
|
delete RULES.custom[keyword];
|
|
for (var i = 0;i < RULES.length; i++) {
|
|
var rules = RULES[i].rules;
|
|
for (var j = 0;j < rules.length; j++) {
|
|
if (rules[j].keyword == keyword) {
|
|
rules.splice(j, 1);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
function validateKeyword(definition, throwError) {
|
|
validateKeyword.errors = null;
|
|
var v = this._validateKeyword = this._validateKeyword || this.compile(definitionSchema, true);
|
|
if (v(definition))
|
|
return true;
|
|
validateKeyword.errors = v.errors;
|
|
if (throwError)
|
|
throw new Error("custom keyword definition is invalid: " + this.errorsText(v.errors));
|
|
else
|
|
return false;
|
|
}
|
|
});
|
|
|
|
// node_modules/ajv/lib/refs/data.json
|
|
var require_data2 = __commonJS((exports, module) => {
|
|
module.exports = {
|
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
$id: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
|
|
description: "Meta-schema for $data reference (JSON Schema extension proposal)",
|
|
type: "object",
|
|
required: ["$data"],
|
|
properties: {
|
|
$data: {
|
|
type: "string",
|
|
anyOf: [
|
|
{ format: "relative-json-pointer" },
|
|
{ format: "json-pointer" }
|
|
]
|
|
}
|
|
},
|
|
additionalProperties: false
|
|
};
|
|
});
|
|
|
|
// node_modules/ajv/lib/ajv.js
|
|
var require_ajv = __commonJS((exports, module) => {
|
|
var compileSchema = require_compile();
|
|
var resolve = require_resolve();
|
|
var Cache = require_cache();
|
|
var SchemaObject = require_schema_obj();
|
|
var stableStringify = require_fast_json_stable_stringify();
|
|
var formats = require_formats();
|
|
var rules = require_rules();
|
|
var $dataMetaSchema = require_data();
|
|
var util3 = require_util();
|
|
module.exports = Ajv;
|
|
Ajv.prototype.validate = validate;
|
|
Ajv.prototype.compile = compile;
|
|
Ajv.prototype.addSchema = addSchema;
|
|
Ajv.prototype.addMetaSchema = addMetaSchema;
|
|
Ajv.prototype.validateSchema = validateSchema;
|
|
Ajv.prototype.getSchema = getSchema;
|
|
Ajv.prototype.removeSchema = removeSchema;
|
|
Ajv.prototype.addFormat = addFormat;
|
|
Ajv.prototype.errorsText = errorsText;
|
|
Ajv.prototype._addSchema = _addSchema;
|
|
Ajv.prototype._compile = _compile;
|
|
Ajv.prototype.compileAsync = require_async();
|
|
var customKeyword = require_keyword();
|
|
Ajv.prototype.addKeyword = customKeyword.add;
|
|
Ajv.prototype.getKeyword = customKeyword.get;
|
|
Ajv.prototype.removeKeyword = customKeyword.remove;
|
|
Ajv.prototype.validateKeyword = customKeyword.validate;
|
|
var errorClasses = require_error_classes();
|
|
Ajv.ValidationError = errorClasses.Validation;
|
|
Ajv.MissingRefError = errorClasses.MissingRef;
|
|
Ajv.$dataMetaSchema = $dataMetaSchema;
|
|
var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema";
|
|
var META_IGNORE_OPTIONS = ["removeAdditional", "useDefaults", "coerceTypes", "strictDefaults"];
|
|
var META_SUPPORT_DATA = ["/properties"];
|
|
function Ajv(opts) {
|
|
if (!(this instanceof Ajv))
|
|
return new Ajv(opts);
|
|
opts = this._opts = util3.copy(opts) || {};
|
|
setLogger(this);
|
|
this._schemas = {};
|
|
this._refs = {};
|
|
this._fragments = {};
|
|
this._formats = formats(opts.format);
|
|
this._cache = opts.cache || new Cache;
|
|
this._loadingSchemas = {};
|
|
this._compilations = [];
|
|
this.RULES = rules();
|
|
this._getId = chooseGetId(opts);
|
|
opts.loopRequired = opts.loopRequired || Infinity;
|
|
if (opts.errorDataPath == "property")
|
|
opts._errorDataPathProperty = true;
|
|
if (opts.serialize === undefined)
|
|
opts.serialize = stableStringify;
|
|
this._metaOpts = getMetaSchemaOptions(this);
|
|
if (opts.formats)
|
|
addInitialFormats(this);
|
|
if (opts.keywords)
|
|
addInitialKeywords(this);
|
|
addDefaultMetaSchema(this);
|
|
if (typeof opts.meta == "object")
|
|
this.addMetaSchema(opts.meta);
|
|
if (opts.nullable)
|
|
this.addKeyword("nullable", { metaSchema: { type: "boolean" } });
|
|
addInitialSchemas(this);
|
|
}
|
|
function validate(schemaKeyRef, data) {
|
|
var v;
|
|
if (typeof schemaKeyRef == "string") {
|
|
v = this.getSchema(schemaKeyRef);
|
|
if (!v)
|
|
throw new Error('no schema with key or ref "' + schemaKeyRef + '"');
|
|
} else {
|
|
var schemaObj = this._addSchema(schemaKeyRef);
|
|
v = schemaObj.validate || this._compile(schemaObj);
|
|
}
|
|
var valid = v(data);
|
|
if (v.$async !== true)
|
|
this.errors = v.errors;
|
|
return valid;
|
|
}
|
|
function compile(schema, _meta) {
|
|
var schemaObj = this._addSchema(schema, undefined, _meta);
|
|
return schemaObj.validate || this._compile(schemaObj);
|
|
}
|
|
function addSchema(schema, key, _skipValidation, _meta) {
|
|
if (Array.isArray(schema)) {
|
|
for (var i = 0;i < schema.length; i++)
|
|
this.addSchema(schema[i], undefined, _skipValidation, _meta);
|
|
return this;
|
|
}
|
|
var id = this._getId(schema);
|
|
if (id !== undefined && typeof id != "string")
|
|
throw new Error("schema id must be string");
|
|
key = resolve.normalizeId(key || id);
|
|
checkUnique(this, key);
|
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
return this;
|
|
}
|
|
function addMetaSchema(schema, key, skipValidation) {
|
|
this.addSchema(schema, key, skipValidation, true);
|
|
return this;
|
|
}
|
|
function validateSchema(schema, throwOrLogError) {
|
|
var $schema = schema.$schema;
|
|
if ($schema !== undefined && typeof $schema != "string")
|
|
throw new Error("$schema must be a string");
|
|
$schema = $schema || this._opts.defaultMeta || defaultMeta(this);
|
|
if (!$schema) {
|
|
this.logger.warn("meta-schema not available");
|
|
this.errors = null;
|
|
return true;
|
|
}
|
|
var valid = this.validate($schema, schema);
|
|
if (!valid && throwOrLogError) {
|
|
var message = "schema is invalid: " + this.errorsText();
|
|
if (this._opts.validateSchema == "log")
|
|
this.logger.error(message);
|
|
else
|
|
throw new Error(message);
|
|
}
|
|
return valid;
|
|
}
|
|
function defaultMeta(self) {
|
|
var meta = self._opts.meta;
|
|
self._opts.defaultMeta = typeof meta == "object" ? self._getId(meta) || meta : self.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : undefined;
|
|
return self._opts.defaultMeta;
|
|
}
|
|
function getSchema(keyRef) {
|
|
var schemaObj = _getSchemaObj(this, keyRef);
|
|
switch (typeof schemaObj) {
|
|
case "object":
|
|
return schemaObj.validate || this._compile(schemaObj);
|
|
case "string":
|
|
return this.getSchema(schemaObj);
|
|
case "undefined":
|
|
return _getSchemaFragment(this, keyRef);
|
|
}
|
|
}
|
|
function _getSchemaFragment(self, ref) {
|
|
var res = resolve.schema.call(self, { schema: {} }, ref);
|
|
if (res) {
|
|
var { schema, root, baseId } = res;
|
|
var v = compileSchema.call(self, schema, root, undefined, baseId);
|
|
self._fragments[ref] = new SchemaObject({
|
|
ref,
|
|
fragment: true,
|
|
schema,
|
|
root,
|
|
baseId,
|
|
validate: v
|
|
});
|
|
return v;
|
|
}
|
|
}
|
|
function _getSchemaObj(self, keyRef) {
|
|
keyRef = resolve.normalizeId(keyRef);
|
|
return self._schemas[keyRef] || self._refs[keyRef] || self._fragments[keyRef];
|
|
}
|
|
function removeSchema(schemaKeyRef) {
|
|
if (schemaKeyRef instanceof RegExp) {
|
|
_removeAllSchemas(this, this._schemas, schemaKeyRef);
|
|
_removeAllSchemas(this, this._refs, schemaKeyRef);
|
|
return this;
|
|
}
|
|
switch (typeof schemaKeyRef) {
|
|
case "undefined":
|
|
_removeAllSchemas(this, this._schemas);
|
|
_removeAllSchemas(this, this._refs);
|
|
this._cache.clear();
|
|
return this;
|
|
case "string":
|
|
var schemaObj = _getSchemaObj(this, schemaKeyRef);
|
|
if (schemaObj)
|
|
this._cache.del(schemaObj.cacheKey);
|
|
delete this._schemas[schemaKeyRef];
|
|
delete this._refs[schemaKeyRef];
|
|
return this;
|
|
case "object":
|
|
var serialize = this._opts.serialize;
|
|
var cacheKey = serialize ? serialize(schemaKeyRef) : schemaKeyRef;
|
|
this._cache.del(cacheKey);
|
|
var id = this._getId(schemaKeyRef);
|
|
if (id) {
|
|
id = resolve.normalizeId(id);
|
|
delete this._schemas[id];
|
|
delete this._refs[id];
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
function _removeAllSchemas(self, schemas, regex) {
|
|
for (var keyRef in schemas) {
|
|
var schemaObj = schemas[keyRef];
|
|
if (!schemaObj.meta && (!regex || regex.test(keyRef))) {
|
|
self._cache.del(schemaObj.cacheKey);
|
|
delete schemas[keyRef];
|
|
}
|
|
}
|
|
}
|
|
function _addSchema(schema, skipValidation, meta, shouldAddSchema) {
|
|
if (typeof schema != "object" && typeof schema != "boolean")
|
|
throw new Error("schema should be object or boolean");
|
|
var serialize = this._opts.serialize;
|
|
var cacheKey = serialize ? serialize(schema) : schema;
|
|
var cached = this._cache.get(cacheKey);
|
|
if (cached)
|
|
return cached;
|
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
var id = resolve.normalizeId(this._getId(schema));
|
|
if (id && shouldAddSchema)
|
|
checkUnique(this, id);
|
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
var recursiveMeta;
|
|
if (willValidate && !(recursiveMeta = id && id == resolve.normalizeId(schema.$schema)))
|
|
this.validateSchema(schema, true);
|
|
var localRefs = resolve.ids.call(this, schema);
|
|
var schemaObj = new SchemaObject({
|
|
id,
|
|
schema,
|
|
localRefs,
|
|
cacheKey,
|
|
meta
|
|
});
|
|
if (id[0] != "#" && shouldAddSchema)
|
|
this._refs[id] = schemaObj;
|
|
this._cache.put(cacheKey, schemaObj);
|
|
if (willValidate && recursiveMeta)
|
|
this.validateSchema(schema, true);
|
|
return schemaObj;
|
|
}
|
|
function _compile(schemaObj, root) {
|
|
if (schemaObj.compiling) {
|
|
schemaObj.validate = callValidate;
|
|
callValidate.schema = schemaObj.schema;
|
|
callValidate.errors = null;
|
|
callValidate.root = root ? root : callValidate;
|
|
if (schemaObj.schema.$async === true)
|
|
callValidate.$async = true;
|
|
return callValidate;
|
|
}
|
|
schemaObj.compiling = true;
|
|
var currentOpts;
|
|
if (schemaObj.meta) {
|
|
currentOpts = this._opts;
|
|
this._opts = this._metaOpts;
|
|
}
|
|
var v;
|
|
try {
|
|
v = compileSchema.call(this, schemaObj.schema, root, schemaObj.localRefs);
|
|
} catch (e) {
|
|
delete schemaObj.validate;
|
|
throw e;
|
|
} finally {
|
|
schemaObj.compiling = false;
|
|
if (schemaObj.meta)
|
|
this._opts = currentOpts;
|
|
}
|
|
schemaObj.validate = v;
|
|
schemaObj.refs = v.refs;
|
|
schemaObj.refVal = v.refVal;
|
|
schemaObj.root = v.root;
|
|
return v;
|
|
function callValidate() {
|
|
var _validate = schemaObj.validate;
|
|
var result = _validate.apply(this, arguments);
|
|
callValidate.errors = _validate.errors;
|
|
return result;
|
|
}
|
|
}
|
|
function chooseGetId(opts) {
|
|
switch (opts.schemaId) {
|
|
case "auto":
|
|
return _get$IdOrId;
|
|
case "id":
|
|
return _getId;
|
|
default:
|
|
return _get$Id;
|
|
}
|
|
}
|
|
function _getId(schema) {
|
|
if (schema.$id)
|
|
this.logger.warn("schema $id ignored", schema.$id);
|
|
return schema.id;
|
|
}
|
|
function _get$Id(schema) {
|
|
if (schema.id)
|
|
this.logger.warn("schema id ignored", schema.id);
|
|
return schema.$id;
|
|
}
|
|
function _get$IdOrId(schema) {
|
|
if (schema.$id && schema.id && schema.$id != schema.id)
|
|
throw new Error("schema $id is different from id");
|
|
return schema.$id || schema.id;
|
|
}
|
|
function errorsText(errors2, options) {
|
|
errors2 = errors2 || this.errors;
|
|
if (!errors2)
|
|
return "No errors";
|
|
options = options || {};
|
|
var separator = options.separator === undefined ? ", " : options.separator;
|
|
var dataVar = options.dataVar === undefined ? "data" : options.dataVar;
|
|
var text = "";
|
|
for (var i = 0;i < errors2.length; i++) {
|
|
var e = errors2[i];
|
|
if (e)
|
|
text += dataVar + e.dataPath + " " + e.message + separator;
|
|
}
|
|
return text.slice(0, -separator.length);
|
|
}
|
|
function addFormat(name, format) {
|
|
if (typeof format == "string")
|
|
format = new RegExp(format);
|
|
this._formats[name] = format;
|
|
return this;
|
|
}
|
|
function addDefaultMetaSchema(self) {
|
|
var $dataSchema;
|
|
if (self._opts.$data) {
|
|
$dataSchema = require_data2();
|
|
self.addMetaSchema($dataSchema, $dataSchema.$id, true);
|
|
}
|
|
if (self._opts.meta === false)
|
|
return;
|
|
var metaSchema = require_json_schema_draft_07();
|
|
if (self._opts.$data)
|
|
metaSchema = $dataMetaSchema(metaSchema, META_SUPPORT_DATA);
|
|
self.addMetaSchema(metaSchema, META_SCHEMA_ID, true);
|
|
self._refs["http://json-schema.org/schema"] = META_SCHEMA_ID;
|
|
}
|
|
function addInitialSchemas(self) {
|
|
var optsSchemas = self._opts.schemas;
|
|
if (!optsSchemas)
|
|
return;
|
|
if (Array.isArray(optsSchemas))
|
|
self.addSchema(optsSchemas);
|
|
else
|
|
for (var key in optsSchemas)
|
|
self.addSchema(optsSchemas[key], key);
|
|
}
|
|
function addInitialFormats(self) {
|
|
for (var name in self._opts.formats) {
|
|
var format = self._opts.formats[name];
|
|
self.addFormat(name, format);
|
|
}
|
|
}
|
|
function addInitialKeywords(self) {
|
|
for (var name in self._opts.keywords) {
|
|
var keyword = self._opts.keywords[name];
|
|
self.addKeyword(name, keyword);
|
|
}
|
|
}
|
|
function checkUnique(self, id) {
|
|
if (self._schemas[id] || self._refs[id])
|
|
throw new Error('schema with key or id "' + id + '" already exists');
|
|
}
|
|
function getMetaSchemaOptions(self) {
|
|
var metaOpts = util3.copy(self._opts);
|
|
for (var i = 0;i < META_IGNORE_OPTIONS.length; i++)
|
|
delete metaOpts[META_IGNORE_OPTIONS[i]];
|
|
return metaOpts;
|
|
}
|
|
function setLogger(self) {
|
|
var logger = self._opts.logger;
|
|
if (logger === false) {
|
|
self.logger = { log: noop, warn: noop, error: noop };
|
|
} else {
|
|
if (logger === undefined)
|
|
logger = console;
|
|
if (!(typeof logger == "object" && logger.log && logger.warn && logger.error))
|
|
throw new Error("logger must implement log, warn and error methods");
|
|
self.logger = logger;
|
|
}
|
|
}
|
|
function noop() {}
|
|
});
|
|
|
|
// node_modules/zod/v3/external.js
|
|
var exports_external = {};
|
|
__export(exports_external, {
|
|
void: () => voidType,
|
|
util: () => util,
|
|
unknown: () => unknownType,
|
|
union: () => unionType,
|
|
undefined: () => undefinedType,
|
|
tuple: () => tupleType,
|
|
transformer: () => effectsType,
|
|
symbol: () => symbolType,
|
|
string: () => stringType,
|
|
strictObject: () => strictObjectType,
|
|
setErrorMap: () => setErrorMap,
|
|
set: () => setType,
|
|
record: () => recordType,
|
|
quotelessJson: () => quotelessJson,
|
|
promise: () => promiseType,
|
|
preprocess: () => preprocessType,
|
|
pipeline: () => pipelineType,
|
|
ostring: () => ostring,
|
|
optional: () => optionalType,
|
|
onumber: () => onumber,
|
|
oboolean: () => oboolean,
|
|
objectUtil: () => objectUtil,
|
|
object: () => objectType,
|
|
number: () => numberType,
|
|
nullable: () => nullableType,
|
|
null: () => nullType,
|
|
never: () => neverType,
|
|
nativeEnum: () => nativeEnumType,
|
|
nan: () => nanType,
|
|
map: () => mapType,
|
|
makeIssue: () => makeIssue,
|
|
literal: () => literalType,
|
|
lazy: () => lazyType,
|
|
late: () => late,
|
|
isValid: () => isValid,
|
|
isDirty: () => isDirty,
|
|
isAsync: () => isAsync,
|
|
isAborted: () => isAborted,
|
|
intersection: () => intersectionType,
|
|
instanceof: () => instanceOfType,
|
|
getParsedType: () => getParsedType,
|
|
getErrorMap: () => getErrorMap,
|
|
function: () => functionType,
|
|
enum: () => enumType,
|
|
effect: () => effectsType,
|
|
discriminatedUnion: () => discriminatedUnionType,
|
|
defaultErrorMap: () => en_default,
|
|
datetimeRegex: () => datetimeRegex,
|
|
date: () => dateType,
|
|
custom: () => custom,
|
|
coerce: () => coerce,
|
|
boolean: () => booleanType,
|
|
bigint: () => bigIntType,
|
|
array: () => arrayType,
|
|
any: () => anyType,
|
|
addIssueToContext: () => addIssueToContext,
|
|
ZodVoid: () => ZodVoid,
|
|
ZodUnknown: () => ZodUnknown,
|
|
ZodUnion: () => ZodUnion,
|
|
ZodUndefined: () => ZodUndefined,
|
|
ZodType: () => ZodType,
|
|
ZodTuple: () => ZodTuple,
|
|
ZodTransformer: () => ZodEffects,
|
|
ZodSymbol: () => ZodSymbol,
|
|
ZodString: () => ZodString,
|
|
ZodSet: () => ZodSet,
|
|
ZodSchema: () => ZodType,
|
|
ZodRecord: () => ZodRecord,
|
|
ZodReadonly: () => ZodReadonly,
|
|
ZodPromise: () => ZodPromise,
|
|
ZodPipeline: () => ZodPipeline,
|
|
ZodParsedType: () => ZodParsedType,
|
|
ZodOptional: () => ZodOptional,
|
|
ZodObject: () => ZodObject,
|
|
ZodNumber: () => ZodNumber,
|
|
ZodNullable: () => ZodNullable,
|
|
ZodNull: () => ZodNull,
|
|
ZodNever: () => ZodNever,
|
|
ZodNativeEnum: () => ZodNativeEnum,
|
|
ZodNaN: () => ZodNaN,
|
|
ZodMap: () => ZodMap,
|
|
ZodLiteral: () => ZodLiteral,
|
|
ZodLazy: () => ZodLazy,
|
|
ZodIssueCode: () => ZodIssueCode,
|
|
ZodIntersection: () => ZodIntersection,
|
|
ZodFunction: () => ZodFunction,
|
|
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
ZodError: () => ZodError,
|
|
ZodEnum: () => ZodEnum,
|
|
ZodEffects: () => ZodEffects,
|
|
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
ZodDefault: () => ZodDefault,
|
|
ZodDate: () => ZodDate,
|
|
ZodCatch: () => ZodCatch,
|
|
ZodBranded: () => ZodBranded,
|
|
ZodBoolean: () => ZodBoolean,
|
|
ZodBigInt: () => ZodBigInt,
|
|
ZodArray: () => ZodArray,
|
|
ZodAny: () => ZodAny,
|
|
Schema: () => ZodType,
|
|
ParseStatus: () => ParseStatus,
|
|
OK: () => OK,
|
|
NEVER: () => NEVER,
|
|
INVALID: () => INVALID,
|
|
EMPTY_PATH: () => EMPTY_PATH,
|
|
DIRTY: () => DIRTY,
|
|
BRAND: () => BRAND
|
|
});
|
|
|
|
// node_modules/zod/v3/helpers/util.js
|
|
var util;
|
|
(function(util2) {
|
|
util2.assertEqual = (_) => {};
|
|
function assertIs(_arg) {}
|
|
util2.assertIs = assertIs;
|
|
function assertNever(_x) {
|
|
throw new Error;
|
|
}
|
|
util2.assertNever = assertNever;
|
|
util2.arrayToEnum = (items) => {
|
|
const obj = {};
|
|
for (const item of items) {
|
|
obj[item] = item;
|
|
}
|
|
return obj;
|
|
};
|
|
util2.getValidEnumValues = (obj) => {
|
|
const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
const filtered = {};
|
|
for (const k of validKeys) {
|
|
filtered[k] = obj[k];
|
|
}
|
|
return util2.objectValues(filtered);
|
|
};
|
|
util2.objectValues = (obj) => {
|
|
return util2.objectKeys(obj).map(function(e) {
|
|
return obj[e];
|
|
});
|
|
};
|
|
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
const keys = [];
|
|
for (const key in object) {
|
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
keys.push(key);
|
|
}
|
|
}
|
|
return keys;
|
|
};
|
|
util2.find = (arr, checker) => {
|
|
for (const item of arr) {
|
|
if (checker(item))
|
|
return item;
|
|
}
|
|
return;
|
|
};
|
|
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
function joinValues(array, separator = " | ") {
|
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
}
|
|
util2.joinValues = joinValues;
|
|
util2.jsonStringifyReplacer = (_, value) => {
|
|
if (typeof value === "bigint") {
|
|
return value.toString();
|
|
}
|
|
return value;
|
|
};
|
|
})(util || (util = {}));
|
|
var objectUtil;
|
|
(function(objectUtil2) {
|
|
objectUtil2.mergeShapes = (first, second) => {
|
|
return {
|
|
...first,
|
|
...second
|
|
};
|
|
};
|
|
})(objectUtil || (objectUtil = {}));
|
|
var ZodParsedType = util.arrayToEnum([
|
|
"string",
|
|
"nan",
|
|
"number",
|
|
"integer",
|
|
"float",
|
|
"boolean",
|
|
"date",
|
|
"bigint",
|
|
"symbol",
|
|
"function",
|
|
"undefined",
|
|
"null",
|
|
"array",
|
|
"object",
|
|
"unknown",
|
|
"promise",
|
|
"void",
|
|
"never",
|
|
"map",
|
|
"set"
|
|
]);
|
|
var getParsedType = (data) => {
|
|
const t = typeof data;
|
|
switch (t) {
|
|
case "undefined":
|
|
return ZodParsedType.undefined;
|
|
case "string":
|
|
return ZodParsedType.string;
|
|
case "number":
|
|
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
case "boolean":
|
|
return ZodParsedType.boolean;
|
|
case "function":
|
|
return ZodParsedType.function;
|
|
case "bigint":
|
|
return ZodParsedType.bigint;
|
|
case "symbol":
|
|
return ZodParsedType.symbol;
|
|
case "object":
|
|
if (Array.isArray(data)) {
|
|
return ZodParsedType.array;
|
|
}
|
|
if (data === null) {
|
|
return ZodParsedType.null;
|
|
}
|
|
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
return ZodParsedType.promise;
|
|
}
|
|
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
return ZodParsedType.map;
|
|
}
|
|
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
return ZodParsedType.set;
|
|
}
|
|
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
return ZodParsedType.date;
|
|
}
|
|
return ZodParsedType.object;
|
|
default:
|
|
return ZodParsedType.unknown;
|
|
}
|
|
};
|
|
|
|
// node_modules/zod/v3/ZodError.js
|
|
var ZodIssueCode = util.arrayToEnum([
|
|
"invalid_type",
|
|
"invalid_literal",
|
|
"custom",
|
|
"invalid_union",
|
|
"invalid_union_discriminator",
|
|
"invalid_enum_value",
|
|
"unrecognized_keys",
|
|
"invalid_arguments",
|
|
"invalid_return_type",
|
|
"invalid_date",
|
|
"invalid_string",
|
|
"too_small",
|
|
"too_big",
|
|
"invalid_intersection_types",
|
|
"not_multiple_of",
|
|
"not_finite"
|
|
]);
|
|
var quotelessJson = (obj) => {
|
|
const json = JSON.stringify(obj, null, 2);
|
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
};
|
|
|
|
class ZodError extends Error {
|
|
get errors() {
|
|
return this.issues;
|
|
}
|
|
constructor(issues) {
|
|
super();
|
|
this.issues = [];
|
|
this.addIssue = (sub) => {
|
|
this.issues = [...this.issues, sub];
|
|
};
|
|
this.addIssues = (subs = []) => {
|
|
this.issues = [...this.issues, ...subs];
|
|
};
|
|
const actualProto = new.target.prototype;
|
|
if (Object.setPrototypeOf) {
|
|
Object.setPrototypeOf(this, actualProto);
|
|
} else {
|
|
this.__proto__ = actualProto;
|
|
}
|
|
this.name = "ZodError";
|
|
this.issues = issues;
|
|
}
|
|
format(_mapper) {
|
|
const mapper = _mapper || function(issue) {
|
|
return issue.message;
|
|
};
|
|
const fieldErrors = { _errors: [] };
|
|
const processError = (error) => {
|
|
for (const issue of error.issues) {
|
|
if (issue.code === "invalid_union") {
|
|
issue.unionErrors.map(processError);
|
|
} else if (issue.code === "invalid_return_type") {
|
|
processError(issue.returnTypeError);
|
|
} else if (issue.code === "invalid_arguments") {
|
|
processError(issue.argumentsError);
|
|
} else if (issue.path.length === 0) {
|
|
fieldErrors._errors.push(mapper(issue));
|
|
} else {
|
|
let curr = fieldErrors;
|
|
let i = 0;
|
|
while (i < issue.path.length) {
|
|
const el = issue.path[i];
|
|
const terminal = i === issue.path.length - 1;
|
|
if (!terminal) {
|
|
curr[el] = curr[el] || { _errors: [] };
|
|
} else {
|
|
curr[el] = curr[el] || { _errors: [] };
|
|
curr[el]._errors.push(mapper(issue));
|
|
}
|
|
curr = curr[el];
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
};
|
|
processError(this);
|
|
return fieldErrors;
|
|
}
|
|
static assert(value) {
|
|
if (!(value instanceof ZodError)) {
|
|
throw new Error(`Not a ZodError: ${value}`);
|
|
}
|
|
}
|
|
toString() {
|
|
return this.message;
|
|
}
|
|
get message() {
|
|
return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
|
|
}
|
|
get isEmpty() {
|
|
return this.issues.length === 0;
|
|
}
|
|
flatten(mapper = (issue) => issue.message) {
|
|
const fieldErrors = {};
|
|
const formErrors = [];
|
|
for (const sub of this.issues) {
|
|
if (sub.path.length > 0) {
|
|
const firstEl = sub.path[0];
|
|
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
fieldErrors[firstEl].push(mapper(sub));
|
|
} else {
|
|
formErrors.push(mapper(sub));
|
|
}
|
|
}
|
|
return { formErrors, fieldErrors };
|
|
}
|
|
get formErrors() {
|
|
return this.flatten();
|
|
}
|
|
}
|
|
ZodError.create = (issues) => {
|
|
const error = new ZodError(issues);
|
|
return error;
|
|
};
|
|
|
|
// node_modules/zod/v3/locales/en.js
|
|
var errorMap = (issue, _ctx) => {
|
|
let message;
|
|
switch (issue.code) {
|
|
case ZodIssueCode.invalid_type:
|
|
if (issue.received === ZodParsedType.undefined) {
|
|
message = "Required";
|
|
} else {
|
|
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
}
|
|
break;
|
|
case ZodIssueCode.invalid_literal:
|
|
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
|
|
break;
|
|
case ZodIssueCode.unrecognized_keys:
|
|
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
|
break;
|
|
case ZodIssueCode.invalid_union:
|
|
message = `Invalid input`;
|
|
break;
|
|
case ZodIssueCode.invalid_union_discriminator:
|
|
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
|
break;
|
|
case ZodIssueCode.invalid_enum_value:
|
|
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
|
break;
|
|
case ZodIssueCode.invalid_arguments:
|
|
message = `Invalid function arguments`;
|
|
break;
|
|
case ZodIssueCode.invalid_return_type:
|
|
message = `Invalid function return type`;
|
|
break;
|
|
case ZodIssueCode.invalid_date:
|
|
message = `Invalid date`;
|
|
break;
|
|
case ZodIssueCode.invalid_string:
|
|
if (typeof issue.validation === "object") {
|
|
if ("includes" in issue.validation) {
|
|
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
if (typeof issue.validation.position === "number") {
|
|
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
}
|
|
} else if ("startsWith" in issue.validation) {
|
|
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
} else if ("endsWith" in issue.validation) {
|
|
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
} else {
|
|
util.assertNever(issue.validation);
|
|
}
|
|
} else if (issue.validation !== "regex") {
|
|
message = `Invalid ${issue.validation}`;
|
|
} else {
|
|
message = "Invalid";
|
|
}
|
|
break;
|
|
case ZodIssueCode.too_small:
|
|
if (issue.type === "array")
|
|
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
else if (issue.type === "string")
|
|
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
else if (issue.type === "number")
|
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
else if (issue.type === "bigint")
|
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
else if (issue.type === "date")
|
|
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
else
|
|
message = "Invalid input";
|
|
break;
|
|
case ZodIssueCode.too_big:
|
|
if (issue.type === "array")
|
|
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
else if (issue.type === "string")
|
|
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
else if (issue.type === "number")
|
|
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
else if (issue.type === "bigint")
|
|
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
else if (issue.type === "date")
|
|
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
else
|
|
message = "Invalid input";
|
|
break;
|
|
case ZodIssueCode.custom:
|
|
message = `Invalid input`;
|
|
break;
|
|
case ZodIssueCode.invalid_intersection_types:
|
|
message = `Intersection results could not be merged`;
|
|
break;
|
|
case ZodIssueCode.not_multiple_of:
|
|
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
break;
|
|
case ZodIssueCode.not_finite:
|
|
message = "Number must be finite";
|
|
break;
|
|
default:
|
|
message = _ctx.defaultError;
|
|
util.assertNever(issue);
|
|
}
|
|
return { message };
|
|
};
|
|
var en_default = errorMap;
|
|
|
|
// node_modules/zod/v3/errors.js
|
|
var overrideErrorMap = en_default;
|
|
function setErrorMap(map) {
|
|
overrideErrorMap = map;
|
|
}
|
|
function getErrorMap() {
|
|
return overrideErrorMap;
|
|
}
|
|
// node_modules/zod/v3/helpers/parseUtil.js
|
|
var makeIssue = (params) => {
|
|
const { data, path, errorMaps, issueData } = params;
|
|
const fullPath = [...path, ...issueData.path || []];
|
|
const fullIssue = {
|
|
...issueData,
|
|
path: fullPath
|
|
};
|
|
if (issueData.message !== undefined) {
|
|
return {
|
|
...issueData,
|
|
path: fullPath,
|
|
message: issueData.message
|
|
};
|
|
}
|
|
let errorMessage = "";
|
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
for (const map of maps) {
|
|
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
}
|
|
return {
|
|
...issueData,
|
|
path: fullPath,
|
|
message: errorMessage
|
|
};
|
|
};
|
|
var EMPTY_PATH = [];
|
|
function addIssueToContext(ctx, issueData) {
|
|
const overrideMap = getErrorMap();
|
|
const issue = makeIssue({
|
|
issueData,
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
errorMaps: [
|
|
ctx.common.contextualErrorMap,
|
|
ctx.schemaErrorMap,
|
|
overrideMap,
|
|
overrideMap === en_default ? undefined : en_default
|
|
].filter((x) => !!x)
|
|
});
|
|
ctx.common.issues.push(issue);
|
|
}
|
|
|
|
class ParseStatus {
|
|
constructor() {
|
|
this.value = "valid";
|
|
}
|
|
dirty() {
|
|
if (this.value === "valid")
|
|
this.value = "dirty";
|
|
}
|
|
abort() {
|
|
if (this.value !== "aborted")
|
|
this.value = "aborted";
|
|
}
|
|
static mergeArray(status, results) {
|
|
const arrayValue = [];
|
|
for (const s of results) {
|
|
if (s.status === "aborted")
|
|
return INVALID;
|
|
if (s.status === "dirty")
|
|
status.dirty();
|
|
arrayValue.push(s.value);
|
|
}
|
|
return { status: status.value, value: arrayValue };
|
|
}
|
|
static async mergeObjectAsync(status, pairs) {
|
|
const syncPairs = [];
|
|
for (const pair of pairs) {
|
|
const key = await pair.key;
|
|
const value = await pair.value;
|
|
syncPairs.push({
|
|
key,
|
|
value
|
|
});
|
|
}
|
|
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
}
|
|
static mergeObjectSync(status, pairs) {
|
|
const finalObject = {};
|
|
for (const pair of pairs) {
|
|
const { key, value } = pair;
|
|
if (key.status === "aborted")
|
|
return INVALID;
|
|
if (value.status === "aborted")
|
|
return INVALID;
|
|
if (key.status === "dirty")
|
|
status.dirty();
|
|
if (value.status === "dirty")
|
|
status.dirty();
|
|
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
finalObject[key.value] = value.value;
|
|
}
|
|
}
|
|
return { status: status.value, value: finalObject };
|
|
}
|
|
}
|
|
var INVALID = Object.freeze({
|
|
status: "aborted"
|
|
});
|
|
var DIRTY = (value) => ({ status: "dirty", value });
|
|
var OK = (value) => ({ status: "valid", value });
|
|
var isAborted = (x) => x.status === "aborted";
|
|
var isDirty = (x) => x.status === "dirty";
|
|
var isValid = (x) => x.status === "valid";
|
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
// node_modules/zod/v3/helpers/errorUtil.js
|
|
var errorUtil;
|
|
(function(errorUtil2) {
|
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
})(errorUtil || (errorUtil = {}));
|
|
|
|
// node_modules/zod/v3/types.js
|
|
class ParseInputLazyPath {
|
|
constructor(parent, value, path, key) {
|
|
this._cachedPath = [];
|
|
this.parent = parent;
|
|
this.data = value;
|
|
this._path = path;
|
|
this._key = key;
|
|
}
|
|
get path() {
|
|
if (!this._cachedPath.length) {
|
|
if (Array.isArray(this._key)) {
|
|
this._cachedPath.push(...this._path, ...this._key);
|
|
} else {
|
|
this._cachedPath.push(...this._path, this._key);
|
|
}
|
|
}
|
|
return this._cachedPath;
|
|
}
|
|
}
|
|
var handleResult = (ctx, result) => {
|
|
if (isValid(result)) {
|
|
return { success: true, data: result.value };
|
|
} else {
|
|
if (!ctx.common.issues.length) {
|
|
throw new Error("Validation failed but no issues detected.");
|
|
}
|
|
return {
|
|
success: false,
|
|
get error() {
|
|
if (this._error)
|
|
return this._error;
|
|
const error = new ZodError(ctx.common.issues);
|
|
this._error = error;
|
|
return this._error;
|
|
}
|
|
};
|
|
}
|
|
};
|
|
function processCreateParams(params) {
|
|
if (!params)
|
|
return {};
|
|
const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
|
|
if (errorMap2 && (invalid_type_error || required_error)) {
|
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
}
|
|
if (errorMap2)
|
|
return { errorMap: errorMap2, description };
|
|
const customMap = (iss, ctx) => {
|
|
const { message } = params;
|
|
if (iss.code === "invalid_enum_value") {
|
|
return { message: message ?? ctx.defaultError };
|
|
}
|
|
if (typeof ctx.data === "undefined") {
|
|
return { message: message ?? required_error ?? ctx.defaultError };
|
|
}
|
|
if (iss.code !== "invalid_type")
|
|
return { message: ctx.defaultError };
|
|
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
};
|
|
return { errorMap: customMap, description };
|
|
}
|
|
|
|
class ZodType {
|
|
get description() {
|
|
return this._def.description;
|
|
}
|
|
_getType(input) {
|
|
return getParsedType(input.data);
|
|
}
|
|
_getOrReturnCtx(input, ctx) {
|
|
return ctx || {
|
|
common: input.parent.common,
|
|
data: input.data,
|
|
parsedType: getParsedType(input.data),
|
|
schemaErrorMap: this._def.errorMap,
|
|
path: input.path,
|
|
parent: input.parent
|
|
};
|
|
}
|
|
_processInputParams(input) {
|
|
return {
|
|
status: new ParseStatus,
|
|
ctx: {
|
|
common: input.parent.common,
|
|
data: input.data,
|
|
parsedType: getParsedType(input.data),
|
|
schemaErrorMap: this._def.errorMap,
|
|
path: input.path,
|
|
parent: input.parent
|
|
}
|
|
};
|
|
}
|
|
_parseSync(input) {
|
|
const result = this._parse(input);
|
|
if (isAsync(result)) {
|
|
throw new Error("Synchronous parse encountered promise.");
|
|
}
|
|
return result;
|
|
}
|
|
_parseAsync(input) {
|
|
const result = this._parse(input);
|
|
return Promise.resolve(result);
|
|
}
|
|
parse(data, params) {
|
|
const result = this.safeParse(data, params);
|
|
if (result.success)
|
|
return result.data;
|
|
throw result.error;
|
|
}
|
|
safeParse(data, params) {
|
|
const ctx = {
|
|
common: {
|
|
issues: [],
|
|
async: params?.async ?? false,
|
|
contextualErrorMap: params?.errorMap
|
|
},
|
|
path: params?.path || [],
|
|
schemaErrorMap: this._def.errorMap,
|
|
parent: null,
|
|
data,
|
|
parsedType: getParsedType(data)
|
|
};
|
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
return handleResult(ctx, result);
|
|
}
|
|
"~validate"(data) {
|
|
const ctx = {
|
|
common: {
|
|
issues: [],
|
|
async: !!this["~standard"].async
|
|
},
|
|
path: [],
|
|
schemaErrorMap: this._def.errorMap,
|
|
parent: null,
|
|
data,
|
|
parsedType: getParsedType(data)
|
|
};
|
|
if (!this["~standard"].async) {
|
|
try {
|
|
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
return isValid(result) ? {
|
|
value: result.value
|
|
} : {
|
|
issues: ctx.common.issues
|
|
};
|
|
} catch (err) {
|
|
if (err?.message?.toLowerCase()?.includes("encountered")) {
|
|
this["~standard"].async = true;
|
|
}
|
|
ctx.common = {
|
|
issues: [],
|
|
async: true
|
|
};
|
|
}
|
|
}
|
|
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
value: result.value
|
|
} : {
|
|
issues: ctx.common.issues
|
|
});
|
|
}
|
|
async parseAsync(data, params) {
|
|
const result = await this.safeParseAsync(data, params);
|
|
if (result.success)
|
|
return result.data;
|
|
throw result.error;
|
|
}
|
|
async safeParseAsync(data, params) {
|
|
const ctx = {
|
|
common: {
|
|
issues: [],
|
|
contextualErrorMap: params?.errorMap,
|
|
async: true
|
|
},
|
|
path: params?.path || [],
|
|
schemaErrorMap: this._def.errorMap,
|
|
parent: null,
|
|
data,
|
|
parsedType: getParsedType(data)
|
|
};
|
|
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
return handleResult(ctx, result);
|
|
}
|
|
refine(check, message) {
|
|
const getIssueProperties = (val) => {
|
|
if (typeof message === "string" || typeof message === "undefined") {
|
|
return { message };
|
|
} else if (typeof message === "function") {
|
|
return message(val);
|
|
} else {
|
|
return message;
|
|
}
|
|
};
|
|
return this._refinement((val, ctx) => {
|
|
const result = check(val);
|
|
const setError = () => ctx.addIssue({
|
|
code: ZodIssueCode.custom,
|
|
...getIssueProperties(val)
|
|
});
|
|
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
return result.then((data) => {
|
|
if (!data) {
|
|
setError();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
if (!result) {
|
|
setError();
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
refinement(check, refinementData) {
|
|
return this._refinement((val, ctx) => {
|
|
if (!check(val)) {
|
|
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
}
|
|
_refinement(refinement) {
|
|
return new ZodEffects({
|
|
schema: this,
|
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
effect: { type: "refinement", refinement }
|
|
});
|
|
}
|
|
superRefine(refinement) {
|
|
return this._refinement(refinement);
|
|
}
|
|
constructor(def) {
|
|
this.spa = this.safeParseAsync;
|
|
this._def = def;
|
|
this.parse = this.parse.bind(this);
|
|
this.safeParse = this.safeParse.bind(this);
|
|
this.parseAsync = this.parseAsync.bind(this);
|
|
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
this.spa = this.spa.bind(this);
|
|
this.refine = this.refine.bind(this);
|
|
this.refinement = this.refinement.bind(this);
|
|
this.superRefine = this.superRefine.bind(this);
|
|
this.optional = this.optional.bind(this);
|
|
this.nullable = this.nullable.bind(this);
|
|
this.nullish = this.nullish.bind(this);
|
|
this.array = this.array.bind(this);
|
|
this.promise = this.promise.bind(this);
|
|
this.or = this.or.bind(this);
|
|
this.and = this.and.bind(this);
|
|
this.transform = this.transform.bind(this);
|
|
this.brand = this.brand.bind(this);
|
|
this.default = this.default.bind(this);
|
|
this.catch = this.catch.bind(this);
|
|
this.describe = this.describe.bind(this);
|
|
this.pipe = this.pipe.bind(this);
|
|
this.readonly = this.readonly.bind(this);
|
|
this.isNullable = this.isNullable.bind(this);
|
|
this.isOptional = this.isOptional.bind(this);
|
|
this["~standard"] = {
|
|
version: 1,
|
|
vendor: "zod",
|
|
validate: (data) => this["~validate"](data)
|
|
};
|
|
}
|
|
optional() {
|
|
return ZodOptional.create(this, this._def);
|
|
}
|
|
nullable() {
|
|
return ZodNullable.create(this, this._def);
|
|
}
|
|
nullish() {
|
|
return this.nullable().optional();
|
|
}
|
|
array() {
|
|
return ZodArray.create(this);
|
|
}
|
|
promise() {
|
|
return ZodPromise.create(this, this._def);
|
|
}
|
|
or(option) {
|
|
return ZodUnion.create([this, option], this._def);
|
|
}
|
|
and(incoming) {
|
|
return ZodIntersection.create(this, incoming, this._def);
|
|
}
|
|
transform(transform) {
|
|
return new ZodEffects({
|
|
...processCreateParams(this._def),
|
|
schema: this,
|
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
effect: { type: "transform", transform }
|
|
});
|
|
}
|
|
default(def) {
|
|
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
return new ZodDefault({
|
|
...processCreateParams(this._def),
|
|
innerType: this,
|
|
defaultValue: defaultValueFunc,
|
|
typeName: ZodFirstPartyTypeKind.ZodDefault
|
|
});
|
|
}
|
|
brand() {
|
|
return new ZodBranded({
|
|
typeName: ZodFirstPartyTypeKind.ZodBranded,
|
|
type: this,
|
|
...processCreateParams(this._def)
|
|
});
|
|
}
|
|
catch(def) {
|
|
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
return new ZodCatch({
|
|
...processCreateParams(this._def),
|
|
innerType: this,
|
|
catchValue: catchValueFunc,
|
|
typeName: ZodFirstPartyTypeKind.ZodCatch
|
|
});
|
|
}
|
|
describe(description) {
|
|
const This = this.constructor;
|
|
return new This({
|
|
...this._def,
|
|
description
|
|
});
|
|
}
|
|
pipe(target) {
|
|
return ZodPipeline.create(this, target);
|
|
}
|
|
readonly() {
|
|
return ZodReadonly.create(this);
|
|
}
|
|
isOptional() {
|
|
return this.safeParse(undefined).success;
|
|
}
|
|
isNullable() {
|
|
return this.safeParse(null).success;
|
|
}
|
|
}
|
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
var cuid2Regex = /^[0-9a-z]+$/;
|
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
var emojiRegex;
|
|
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
var ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
|
|
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
function timeRegexSource(args) {
|
|
let secondsRegexSource = `[0-5]\\d`;
|
|
if (args.precision) {
|
|
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
} else if (args.precision == null) {
|
|
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
}
|
|
const secondsQuantifier = args.precision ? "+" : "?";
|
|
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
}
|
|
function timeRegex(args) {
|
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
}
|
|
function datetimeRegex(args) {
|
|
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
const opts = [];
|
|
opts.push(args.local ? `Z?` : `Z`);
|
|
if (args.offset)
|
|
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
regex = `${regex}(${opts.join("|")})`;
|
|
return new RegExp(`^${regex}$`);
|
|
}
|
|
function isValidIP(ip, version) {
|
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
return true;
|
|
}
|
|
if ((version === "v6" || !version) && ipv6Regex.test(ip)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function isValidJWT(jwt, alg) {
|
|
if (!jwtRegex.test(jwt))
|
|
return false;
|
|
try {
|
|
const [header] = jwt.split(".");
|
|
if (!header)
|
|
return false;
|
|
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
const decoded = JSON.parse(atob(base64));
|
|
if (typeof decoded !== "object" || decoded === null)
|
|
return false;
|
|
if ("typ" in decoded && decoded?.typ !== "JWT")
|
|
return false;
|
|
if (!decoded.alg)
|
|
return false;
|
|
if (alg && decoded.alg !== alg)
|
|
return false;
|
|
return true;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
function isValidCidr(ip, version) {
|
|
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
|
return true;
|
|
}
|
|
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
class ZodString extends ZodType {
|
|
_parse(input) {
|
|
if (this._def.coerce) {
|
|
input.data = String(input.data);
|
|
}
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.string) {
|
|
const ctx2 = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx2, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.string,
|
|
received: ctx2.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const status = new ParseStatus;
|
|
let ctx = undefined;
|
|
for (const check of this._def.checks) {
|
|
if (check.kind === "min") {
|
|
if (input.data.length < check.value) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
minimum: check.value,
|
|
type: "string",
|
|
inclusive: true,
|
|
exact: false,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "max") {
|
|
if (input.data.length > check.value) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
maximum: check.value,
|
|
type: "string",
|
|
inclusive: true,
|
|
exact: false,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "length") {
|
|
const tooBig = input.data.length > check.value;
|
|
const tooSmall = input.data.length < check.value;
|
|
if (tooBig || tooSmall) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
if (tooBig) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
maximum: check.value,
|
|
type: "string",
|
|
inclusive: true,
|
|
exact: true,
|
|
message: check.message
|
|
});
|
|
} else if (tooSmall) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
minimum: check.value,
|
|
type: "string",
|
|
inclusive: true,
|
|
exact: true,
|
|
message: check.message
|
|
});
|
|
}
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "email") {
|
|
if (!emailRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "email",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "emoji") {
|
|
if (!emojiRegex) {
|
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
}
|
|
if (!emojiRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "emoji",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "uuid") {
|
|
if (!uuidRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "uuid",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "nanoid") {
|
|
if (!nanoidRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "nanoid",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "cuid") {
|
|
if (!cuidRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "cuid",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "cuid2") {
|
|
if (!cuid2Regex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "cuid2",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "ulid") {
|
|
if (!ulidRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "ulid",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "url") {
|
|
try {
|
|
new URL(input.data);
|
|
} catch {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "url",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "regex") {
|
|
check.regex.lastIndex = 0;
|
|
const testResult = check.regex.test(input.data);
|
|
if (!testResult) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "regex",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "trim") {
|
|
input.data = input.data.trim();
|
|
} else if (check.kind === "includes") {
|
|
if (!input.data.includes(check.value, check.position)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_string,
|
|
validation: { includes: check.value, position: check.position },
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "toLowerCase") {
|
|
input.data = input.data.toLowerCase();
|
|
} else if (check.kind === "toUpperCase") {
|
|
input.data = input.data.toUpperCase();
|
|
} else if (check.kind === "startsWith") {
|
|
if (!input.data.startsWith(check.value)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_string,
|
|
validation: { startsWith: check.value },
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "endsWith") {
|
|
if (!input.data.endsWith(check.value)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_string,
|
|
validation: { endsWith: check.value },
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "datetime") {
|
|
const regex = datetimeRegex(check);
|
|
if (!regex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_string,
|
|
validation: "datetime",
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "date") {
|
|
const regex = dateRegex;
|
|
if (!regex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_string,
|
|
validation: "date",
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "time") {
|
|
const regex = timeRegex(check);
|
|
if (!regex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_string,
|
|
validation: "time",
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "duration") {
|
|
if (!durationRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "duration",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "ip") {
|
|
if (!isValidIP(input.data, check.version)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "ip",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "jwt") {
|
|
if (!isValidJWT(input.data, check.alg)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "jwt",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "cidr") {
|
|
if (!isValidCidr(input.data, check.version)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "cidr",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "base64") {
|
|
if (!base64Regex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "base64",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "base64url") {
|
|
if (!base64urlRegex.test(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
validation: "base64url",
|
|
code: ZodIssueCode.invalid_string,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else {
|
|
util.assertNever(check);
|
|
}
|
|
}
|
|
return { status: status.value, value: input.data };
|
|
}
|
|
_regex(regex, validation, message) {
|
|
return this.refinement((data) => regex.test(data), {
|
|
validation,
|
|
code: ZodIssueCode.invalid_string,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
_addCheck(check) {
|
|
return new ZodString({
|
|
...this._def,
|
|
checks: [...this._def.checks, check]
|
|
});
|
|
}
|
|
email(message) {
|
|
return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
|
|
}
|
|
url(message) {
|
|
return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
|
|
}
|
|
emoji(message) {
|
|
return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
|
|
}
|
|
uuid(message) {
|
|
return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
|
|
}
|
|
nanoid(message) {
|
|
return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
|
|
}
|
|
cuid(message) {
|
|
return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
|
|
}
|
|
cuid2(message) {
|
|
return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
|
|
}
|
|
ulid(message) {
|
|
return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
|
|
}
|
|
base64(message) {
|
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
}
|
|
base64url(message) {
|
|
return this._addCheck({
|
|
kind: "base64url",
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
jwt(options) {
|
|
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
}
|
|
ip(options) {
|
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
}
|
|
cidr(options) {
|
|
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
}
|
|
datetime(options) {
|
|
if (typeof options === "string") {
|
|
return this._addCheck({
|
|
kind: "datetime",
|
|
precision: null,
|
|
offset: false,
|
|
local: false,
|
|
message: options
|
|
});
|
|
}
|
|
return this._addCheck({
|
|
kind: "datetime",
|
|
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
offset: options?.offset ?? false,
|
|
local: options?.local ?? false,
|
|
...errorUtil.errToObj(options?.message)
|
|
});
|
|
}
|
|
date(message) {
|
|
return this._addCheck({ kind: "date", message });
|
|
}
|
|
time(options) {
|
|
if (typeof options === "string") {
|
|
return this._addCheck({
|
|
kind: "time",
|
|
precision: null,
|
|
message: options
|
|
});
|
|
}
|
|
return this._addCheck({
|
|
kind: "time",
|
|
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
...errorUtil.errToObj(options?.message)
|
|
});
|
|
}
|
|
duration(message) {
|
|
return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
|
|
}
|
|
regex(regex, message) {
|
|
return this._addCheck({
|
|
kind: "regex",
|
|
regex,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
includes(value, options) {
|
|
return this._addCheck({
|
|
kind: "includes",
|
|
value,
|
|
position: options?.position,
|
|
...errorUtil.errToObj(options?.message)
|
|
});
|
|
}
|
|
startsWith(value, message) {
|
|
return this._addCheck({
|
|
kind: "startsWith",
|
|
value,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
endsWith(value, message) {
|
|
return this._addCheck({
|
|
kind: "endsWith",
|
|
value,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
min(minLength, message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
value: minLength,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
max(maxLength, message) {
|
|
return this._addCheck({
|
|
kind: "max",
|
|
value: maxLength,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
length(len, message) {
|
|
return this._addCheck({
|
|
kind: "length",
|
|
value: len,
|
|
...errorUtil.errToObj(message)
|
|
});
|
|
}
|
|
nonempty(message) {
|
|
return this.min(1, errorUtil.errToObj(message));
|
|
}
|
|
trim() {
|
|
return new ZodString({
|
|
...this._def,
|
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
});
|
|
}
|
|
toLowerCase() {
|
|
return new ZodString({
|
|
...this._def,
|
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
});
|
|
}
|
|
toUpperCase() {
|
|
return new ZodString({
|
|
...this._def,
|
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
});
|
|
}
|
|
get isDatetime() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
}
|
|
get isDate() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
}
|
|
get isTime() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
}
|
|
get isDuration() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
}
|
|
get isEmail() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
}
|
|
get isURL() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
}
|
|
get isEmoji() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
}
|
|
get isUUID() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
}
|
|
get isNANOID() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
}
|
|
get isCUID() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
}
|
|
get isCUID2() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
}
|
|
get isULID() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
}
|
|
get isIP() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
}
|
|
get isCIDR() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
}
|
|
get isBase64() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
}
|
|
get isBase64url() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
}
|
|
get minLength() {
|
|
let min = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "min") {
|
|
if (min === null || ch.value > min)
|
|
min = ch.value;
|
|
}
|
|
}
|
|
return min;
|
|
}
|
|
get maxLength() {
|
|
let max = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "max") {
|
|
if (max === null || ch.value < max)
|
|
max = ch.value;
|
|
}
|
|
}
|
|
return max;
|
|
}
|
|
}
|
|
ZodString.create = (params) => {
|
|
return new ZodString({
|
|
checks: [],
|
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
coerce: params?.coerce ?? false,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
function floatSafeRemainder(val, step) {
|
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
return valInt % stepInt / 10 ** decCount;
|
|
}
|
|
|
|
class ZodNumber extends ZodType {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.min = this.gte;
|
|
this.max = this.lte;
|
|
this.step = this.multipleOf;
|
|
}
|
|
_parse(input) {
|
|
if (this._def.coerce) {
|
|
input.data = Number(input.data);
|
|
}
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.number) {
|
|
const ctx2 = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx2, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.number,
|
|
received: ctx2.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
let ctx = undefined;
|
|
const status = new ParseStatus;
|
|
for (const check of this._def.checks) {
|
|
if (check.kind === "int") {
|
|
if (!util.isInteger(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: "integer",
|
|
received: "float",
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "min") {
|
|
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
if (tooSmall) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
minimum: check.value,
|
|
type: "number",
|
|
inclusive: check.inclusive,
|
|
exact: false,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "max") {
|
|
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
if (tooBig) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
maximum: check.value,
|
|
type: "number",
|
|
inclusive: check.inclusive,
|
|
exact: false,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "multipleOf") {
|
|
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.not_multiple_of,
|
|
multipleOf: check.value,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "finite") {
|
|
if (!Number.isFinite(input.data)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.not_finite,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else {
|
|
util.assertNever(check);
|
|
}
|
|
}
|
|
return { status: status.value, value: input.data };
|
|
}
|
|
gte(value, message) {
|
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
}
|
|
gt(value, message) {
|
|
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
}
|
|
lte(value, message) {
|
|
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
}
|
|
lt(value, message) {
|
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
}
|
|
setLimit(kind, value, inclusive, message) {
|
|
return new ZodNumber({
|
|
...this._def,
|
|
checks: [
|
|
...this._def.checks,
|
|
{
|
|
kind,
|
|
value,
|
|
inclusive,
|
|
message: errorUtil.toString(message)
|
|
}
|
|
]
|
|
});
|
|
}
|
|
_addCheck(check) {
|
|
return new ZodNumber({
|
|
...this._def,
|
|
checks: [...this._def.checks, check]
|
|
});
|
|
}
|
|
int(message) {
|
|
return this._addCheck({
|
|
kind: "int",
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
positive(message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
value: 0,
|
|
inclusive: false,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
negative(message) {
|
|
return this._addCheck({
|
|
kind: "max",
|
|
value: 0,
|
|
inclusive: false,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
nonpositive(message) {
|
|
return this._addCheck({
|
|
kind: "max",
|
|
value: 0,
|
|
inclusive: true,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
nonnegative(message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
value: 0,
|
|
inclusive: true,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
multipleOf(value, message) {
|
|
return this._addCheck({
|
|
kind: "multipleOf",
|
|
value,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
finite(message) {
|
|
return this._addCheck({
|
|
kind: "finite",
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
safe(message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
inclusive: true,
|
|
value: Number.MIN_SAFE_INTEGER,
|
|
message: errorUtil.toString(message)
|
|
})._addCheck({
|
|
kind: "max",
|
|
inclusive: true,
|
|
value: Number.MAX_SAFE_INTEGER,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
get minValue() {
|
|
let min = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "min") {
|
|
if (min === null || ch.value > min)
|
|
min = ch.value;
|
|
}
|
|
}
|
|
return min;
|
|
}
|
|
get maxValue() {
|
|
let max = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "max") {
|
|
if (max === null || ch.value < max)
|
|
max = ch.value;
|
|
}
|
|
}
|
|
return max;
|
|
}
|
|
get isInt() {
|
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
}
|
|
get isFinite() {
|
|
let max = null;
|
|
let min = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
return true;
|
|
} else if (ch.kind === "min") {
|
|
if (min === null || ch.value > min)
|
|
min = ch.value;
|
|
} else if (ch.kind === "max") {
|
|
if (max === null || ch.value < max)
|
|
max = ch.value;
|
|
}
|
|
}
|
|
return Number.isFinite(min) && Number.isFinite(max);
|
|
}
|
|
}
|
|
ZodNumber.create = (params) => {
|
|
return new ZodNumber({
|
|
checks: [],
|
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
coerce: params?.coerce || false,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodBigInt extends ZodType {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.min = this.gte;
|
|
this.max = this.lte;
|
|
}
|
|
_parse(input) {
|
|
if (this._def.coerce) {
|
|
try {
|
|
input.data = BigInt(input.data);
|
|
} catch {
|
|
return this._getInvalidInput(input);
|
|
}
|
|
}
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.bigint) {
|
|
return this._getInvalidInput(input);
|
|
}
|
|
let ctx = undefined;
|
|
const status = new ParseStatus;
|
|
for (const check of this._def.checks) {
|
|
if (check.kind === "min") {
|
|
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
if (tooSmall) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
type: "bigint",
|
|
minimum: check.value,
|
|
inclusive: check.inclusive,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "max") {
|
|
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
if (tooBig) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
type: "bigint",
|
|
maximum: check.value,
|
|
inclusive: check.inclusive,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "multipleOf") {
|
|
if (input.data % check.value !== BigInt(0)) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.not_multiple_of,
|
|
multipleOf: check.value,
|
|
message: check.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else {
|
|
util.assertNever(check);
|
|
}
|
|
}
|
|
return { status: status.value, value: input.data };
|
|
}
|
|
_getInvalidInput(input) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.bigint,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
gte(value, message) {
|
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
}
|
|
gt(value, message) {
|
|
return this.setLimit("min", value, false, errorUtil.toString(message));
|
|
}
|
|
lte(value, message) {
|
|
return this.setLimit("max", value, true, errorUtil.toString(message));
|
|
}
|
|
lt(value, message) {
|
|
return this.setLimit("max", value, false, errorUtil.toString(message));
|
|
}
|
|
setLimit(kind, value, inclusive, message) {
|
|
return new ZodBigInt({
|
|
...this._def,
|
|
checks: [
|
|
...this._def.checks,
|
|
{
|
|
kind,
|
|
value,
|
|
inclusive,
|
|
message: errorUtil.toString(message)
|
|
}
|
|
]
|
|
});
|
|
}
|
|
_addCheck(check) {
|
|
return new ZodBigInt({
|
|
...this._def,
|
|
checks: [...this._def.checks, check]
|
|
});
|
|
}
|
|
positive(message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
value: BigInt(0),
|
|
inclusive: false,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
negative(message) {
|
|
return this._addCheck({
|
|
kind: "max",
|
|
value: BigInt(0),
|
|
inclusive: false,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
nonpositive(message) {
|
|
return this._addCheck({
|
|
kind: "max",
|
|
value: BigInt(0),
|
|
inclusive: true,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
nonnegative(message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
value: BigInt(0),
|
|
inclusive: true,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
multipleOf(value, message) {
|
|
return this._addCheck({
|
|
kind: "multipleOf",
|
|
value,
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
get minValue() {
|
|
let min = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "min") {
|
|
if (min === null || ch.value > min)
|
|
min = ch.value;
|
|
}
|
|
}
|
|
return min;
|
|
}
|
|
get maxValue() {
|
|
let max = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "max") {
|
|
if (max === null || ch.value < max)
|
|
max = ch.value;
|
|
}
|
|
}
|
|
return max;
|
|
}
|
|
}
|
|
ZodBigInt.create = (params) => {
|
|
return new ZodBigInt({
|
|
checks: [],
|
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
coerce: params?.coerce ?? false,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodBoolean extends ZodType {
|
|
_parse(input) {
|
|
if (this._def.coerce) {
|
|
input.data = Boolean(input.data);
|
|
}
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.boolean) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.boolean,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodBoolean.create = (params) => {
|
|
return new ZodBoolean({
|
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
coerce: params?.coerce || false,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodDate extends ZodType {
|
|
_parse(input) {
|
|
if (this._def.coerce) {
|
|
input.data = new Date(input.data);
|
|
}
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.date) {
|
|
const ctx2 = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx2, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.date,
|
|
received: ctx2.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (Number.isNaN(input.data.getTime())) {
|
|
const ctx2 = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx2, {
|
|
code: ZodIssueCode.invalid_date
|
|
});
|
|
return INVALID;
|
|
}
|
|
const status = new ParseStatus;
|
|
let ctx = undefined;
|
|
for (const check of this._def.checks) {
|
|
if (check.kind === "min") {
|
|
if (input.data.getTime() < check.value) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
message: check.message,
|
|
inclusive: true,
|
|
exact: false,
|
|
minimum: check.value,
|
|
type: "date"
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (check.kind === "max") {
|
|
if (input.data.getTime() > check.value) {
|
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
message: check.message,
|
|
inclusive: true,
|
|
exact: false,
|
|
maximum: check.value,
|
|
type: "date"
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else {
|
|
util.assertNever(check);
|
|
}
|
|
}
|
|
return {
|
|
status: status.value,
|
|
value: new Date(input.data.getTime())
|
|
};
|
|
}
|
|
_addCheck(check) {
|
|
return new ZodDate({
|
|
...this._def,
|
|
checks: [...this._def.checks, check]
|
|
});
|
|
}
|
|
min(minDate, message) {
|
|
return this._addCheck({
|
|
kind: "min",
|
|
value: minDate.getTime(),
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
max(maxDate, message) {
|
|
return this._addCheck({
|
|
kind: "max",
|
|
value: maxDate.getTime(),
|
|
message: errorUtil.toString(message)
|
|
});
|
|
}
|
|
get minDate() {
|
|
let min = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "min") {
|
|
if (min === null || ch.value > min)
|
|
min = ch.value;
|
|
}
|
|
}
|
|
return min != null ? new Date(min) : null;
|
|
}
|
|
get maxDate() {
|
|
let max = null;
|
|
for (const ch of this._def.checks) {
|
|
if (ch.kind === "max") {
|
|
if (max === null || ch.value < max)
|
|
max = ch.value;
|
|
}
|
|
}
|
|
return max != null ? new Date(max) : null;
|
|
}
|
|
}
|
|
ZodDate.create = (params) => {
|
|
return new ZodDate({
|
|
checks: [],
|
|
coerce: params?.coerce || false,
|
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodSymbol extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.symbol) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.symbol,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodSymbol.create = (params) => {
|
|
return new ZodSymbol({
|
|
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodUndefined extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.undefined) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.undefined,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodUndefined.create = (params) => {
|
|
return new ZodUndefined({
|
|
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodNull extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.null) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.null,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodNull.create = (params) => {
|
|
return new ZodNull({
|
|
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodAny extends ZodType {
|
|
constructor() {
|
|
super(...arguments);
|
|
this._any = true;
|
|
}
|
|
_parse(input) {
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodAny.create = (params) => {
|
|
return new ZodAny({
|
|
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodUnknown extends ZodType {
|
|
constructor() {
|
|
super(...arguments);
|
|
this._unknown = true;
|
|
}
|
|
_parse(input) {
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodUnknown.create = (params) => {
|
|
return new ZodUnknown({
|
|
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodNever extends ZodType {
|
|
_parse(input) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.never,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
}
|
|
ZodNever.create = (params) => {
|
|
return new ZodNever({
|
|
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodVoid extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.undefined) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.void,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
}
|
|
ZodVoid.create = (params) => {
|
|
return new ZodVoid({
|
|
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodArray extends ZodType {
|
|
_parse(input) {
|
|
const { ctx, status } = this._processInputParams(input);
|
|
const def = this._def;
|
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.array,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (def.exactLength !== null) {
|
|
const tooBig = ctx.data.length > def.exactLength.value;
|
|
const tooSmall = ctx.data.length < def.exactLength.value;
|
|
if (tooBig || tooSmall) {
|
|
addIssueToContext(ctx, {
|
|
code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
|
|
minimum: tooSmall ? def.exactLength.value : undefined,
|
|
maximum: tooBig ? def.exactLength.value : undefined,
|
|
type: "array",
|
|
inclusive: true,
|
|
exact: true,
|
|
message: def.exactLength.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
}
|
|
if (def.minLength !== null) {
|
|
if (ctx.data.length < def.minLength.value) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
minimum: def.minLength.value,
|
|
type: "array",
|
|
inclusive: true,
|
|
exact: false,
|
|
message: def.minLength.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
}
|
|
if (def.maxLength !== null) {
|
|
if (ctx.data.length > def.maxLength.value) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
maximum: def.maxLength.value,
|
|
type: "array",
|
|
inclusive: true,
|
|
exact: false,
|
|
message: def.maxLength.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
}
|
|
if (ctx.common.async) {
|
|
return Promise.all([...ctx.data].map((item, i) => {
|
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
})).then((result2) => {
|
|
return ParseStatus.mergeArray(status, result2);
|
|
});
|
|
}
|
|
const result = [...ctx.data].map((item, i) => {
|
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
});
|
|
return ParseStatus.mergeArray(status, result);
|
|
}
|
|
get element() {
|
|
return this._def.type;
|
|
}
|
|
min(minLength, message) {
|
|
return new ZodArray({
|
|
...this._def,
|
|
minLength: { value: minLength, message: errorUtil.toString(message) }
|
|
});
|
|
}
|
|
max(maxLength, message) {
|
|
return new ZodArray({
|
|
...this._def,
|
|
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
|
});
|
|
}
|
|
length(len, message) {
|
|
return new ZodArray({
|
|
...this._def,
|
|
exactLength: { value: len, message: errorUtil.toString(message) }
|
|
});
|
|
}
|
|
nonempty(message) {
|
|
return this.min(1, message);
|
|
}
|
|
}
|
|
ZodArray.create = (schema, params) => {
|
|
return new ZodArray({
|
|
type: schema,
|
|
minLength: null,
|
|
maxLength: null,
|
|
exactLength: null,
|
|
typeName: ZodFirstPartyTypeKind.ZodArray,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
function deepPartialify(schema) {
|
|
if (schema instanceof ZodObject) {
|
|
const newShape = {};
|
|
for (const key in schema.shape) {
|
|
const fieldSchema = schema.shape[key];
|
|
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
}
|
|
return new ZodObject({
|
|
...schema._def,
|
|
shape: () => newShape
|
|
});
|
|
} else if (schema instanceof ZodArray) {
|
|
return new ZodArray({
|
|
...schema._def,
|
|
type: deepPartialify(schema.element)
|
|
});
|
|
} else if (schema instanceof ZodOptional) {
|
|
return ZodOptional.create(deepPartialify(schema.unwrap()));
|
|
} else if (schema instanceof ZodNullable) {
|
|
return ZodNullable.create(deepPartialify(schema.unwrap()));
|
|
} else if (schema instanceof ZodTuple) {
|
|
return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
|
|
} else {
|
|
return schema;
|
|
}
|
|
}
|
|
|
|
class ZodObject extends ZodType {
|
|
constructor() {
|
|
super(...arguments);
|
|
this._cached = null;
|
|
this.nonstrict = this.passthrough;
|
|
this.augment = this.extend;
|
|
}
|
|
_getCached() {
|
|
if (this._cached !== null)
|
|
return this._cached;
|
|
const shape = this._def.shape();
|
|
const keys = util.objectKeys(shape);
|
|
this._cached = { shape, keys };
|
|
return this._cached;
|
|
}
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.object) {
|
|
const ctx2 = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx2, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.object,
|
|
received: ctx2.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const { status, ctx } = this._processInputParams(input);
|
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
const extraKeys = [];
|
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
for (const key in ctx.data) {
|
|
if (!shapeKeys.includes(key)) {
|
|
extraKeys.push(key);
|
|
}
|
|
}
|
|
}
|
|
const pairs = [];
|
|
for (const key of shapeKeys) {
|
|
const keyValidator = shape[key];
|
|
const value = ctx.data[key];
|
|
pairs.push({
|
|
key: { status: "valid", value: key },
|
|
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
alwaysSet: key in ctx.data
|
|
});
|
|
}
|
|
if (this._def.catchall instanceof ZodNever) {
|
|
const unknownKeys = this._def.unknownKeys;
|
|
if (unknownKeys === "passthrough") {
|
|
for (const key of extraKeys) {
|
|
pairs.push({
|
|
key: { status: "valid", value: key },
|
|
value: { status: "valid", value: ctx.data[key] }
|
|
});
|
|
}
|
|
} else if (unknownKeys === "strict") {
|
|
if (extraKeys.length > 0) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.unrecognized_keys,
|
|
keys: extraKeys
|
|
});
|
|
status.dirty();
|
|
}
|
|
} else if (unknownKeys === "strip") {} else {
|
|
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
}
|
|
} else {
|
|
const catchall = this._def.catchall;
|
|
for (const key of extraKeys) {
|
|
const value = ctx.data[key];
|
|
pairs.push({
|
|
key: { status: "valid", value: key },
|
|
value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
alwaysSet: key in ctx.data
|
|
});
|
|
}
|
|
}
|
|
if (ctx.common.async) {
|
|
return Promise.resolve().then(async () => {
|
|
const syncPairs = [];
|
|
for (const pair of pairs) {
|
|
const key = await pair.key;
|
|
const value = await pair.value;
|
|
syncPairs.push({
|
|
key,
|
|
value,
|
|
alwaysSet: pair.alwaysSet
|
|
});
|
|
}
|
|
return syncPairs;
|
|
}).then((syncPairs) => {
|
|
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
});
|
|
} else {
|
|
return ParseStatus.mergeObjectSync(status, pairs);
|
|
}
|
|
}
|
|
get shape() {
|
|
return this._def.shape();
|
|
}
|
|
strict(message) {
|
|
errorUtil.errToObj;
|
|
return new ZodObject({
|
|
...this._def,
|
|
unknownKeys: "strict",
|
|
...message !== undefined ? {
|
|
errorMap: (issue, ctx) => {
|
|
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
if (issue.code === "unrecognized_keys")
|
|
return {
|
|
message: errorUtil.errToObj(message).message ?? defaultError
|
|
};
|
|
return {
|
|
message: defaultError
|
|
};
|
|
}
|
|
} : {}
|
|
});
|
|
}
|
|
strip() {
|
|
return new ZodObject({
|
|
...this._def,
|
|
unknownKeys: "strip"
|
|
});
|
|
}
|
|
passthrough() {
|
|
return new ZodObject({
|
|
...this._def,
|
|
unknownKeys: "passthrough"
|
|
});
|
|
}
|
|
extend(augmentation) {
|
|
return new ZodObject({
|
|
...this._def,
|
|
shape: () => ({
|
|
...this._def.shape(),
|
|
...augmentation
|
|
})
|
|
});
|
|
}
|
|
merge(merging) {
|
|
const merged = new ZodObject({
|
|
unknownKeys: merging._def.unknownKeys,
|
|
catchall: merging._def.catchall,
|
|
shape: () => ({
|
|
...this._def.shape(),
|
|
...merging._def.shape()
|
|
}),
|
|
typeName: ZodFirstPartyTypeKind.ZodObject
|
|
});
|
|
return merged;
|
|
}
|
|
setKey(key, schema) {
|
|
return this.augment({ [key]: schema });
|
|
}
|
|
catchall(index) {
|
|
return new ZodObject({
|
|
...this._def,
|
|
catchall: index
|
|
});
|
|
}
|
|
pick(mask) {
|
|
const shape = {};
|
|
for (const key of util.objectKeys(mask)) {
|
|
if (mask[key] && this.shape[key]) {
|
|
shape[key] = this.shape[key];
|
|
}
|
|
}
|
|
return new ZodObject({
|
|
...this._def,
|
|
shape: () => shape
|
|
});
|
|
}
|
|
omit(mask) {
|
|
const shape = {};
|
|
for (const key of util.objectKeys(this.shape)) {
|
|
if (!mask[key]) {
|
|
shape[key] = this.shape[key];
|
|
}
|
|
}
|
|
return new ZodObject({
|
|
...this._def,
|
|
shape: () => shape
|
|
});
|
|
}
|
|
deepPartial() {
|
|
return deepPartialify(this);
|
|
}
|
|
partial(mask) {
|
|
const newShape = {};
|
|
for (const key of util.objectKeys(this.shape)) {
|
|
const fieldSchema = this.shape[key];
|
|
if (mask && !mask[key]) {
|
|
newShape[key] = fieldSchema;
|
|
} else {
|
|
newShape[key] = fieldSchema.optional();
|
|
}
|
|
}
|
|
return new ZodObject({
|
|
...this._def,
|
|
shape: () => newShape
|
|
});
|
|
}
|
|
required(mask) {
|
|
const newShape = {};
|
|
for (const key of util.objectKeys(this.shape)) {
|
|
if (mask && !mask[key]) {
|
|
newShape[key] = this.shape[key];
|
|
} else {
|
|
const fieldSchema = this.shape[key];
|
|
let newField = fieldSchema;
|
|
while (newField instanceof ZodOptional) {
|
|
newField = newField._def.innerType;
|
|
}
|
|
newShape[key] = newField;
|
|
}
|
|
}
|
|
return new ZodObject({
|
|
...this._def,
|
|
shape: () => newShape
|
|
});
|
|
}
|
|
keyof() {
|
|
return createZodEnum(util.objectKeys(this.shape));
|
|
}
|
|
}
|
|
ZodObject.create = (shape, params) => {
|
|
return new ZodObject({
|
|
shape: () => shape,
|
|
unknownKeys: "strip",
|
|
catchall: ZodNever.create(),
|
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
ZodObject.strictCreate = (shape, params) => {
|
|
return new ZodObject({
|
|
shape: () => shape,
|
|
unknownKeys: "strict",
|
|
catchall: ZodNever.create(),
|
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
ZodObject.lazycreate = (shape, params) => {
|
|
return new ZodObject({
|
|
shape,
|
|
unknownKeys: "strip",
|
|
catchall: ZodNever.create(),
|
|
typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodUnion extends ZodType {
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
const options = this._def.options;
|
|
function handleResults(results) {
|
|
for (const result of results) {
|
|
if (result.result.status === "valid") {
|
|
return result.result;
|
|
}
|
|
}
|
|
for (const result of results) {
|
|
if (result.result.status === "dirty") {
|
|
ctx.common.issues.push(...result.ctx.common.issues);
|
|
return result.result;
|
|
}
|
|
}
|
|
const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_union,
|
|
unionErrors
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (ctx.common.async) {
|
|
return Promise.all(options.map(async (option) => {
|
|
const childCtx = {
|
|
...ctx,
|
|
common: {
|
|
...ctx.common,
|
|
issues: []
|
|
},
|
|
parent: null
|
|
};
|
|
return {
|
|
result: await option._parseAsync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: childCtx
|
|
}),
|
|
ctx: childCtx
|
|
};
|
|
})).then(handleResults);
|
|
} else {
|
|
let dirty = undefined;
|
|
const issues = [];
|
|
for (const option of options) {
|
|
const childCtx = {
|
|
...ctx,
|
|
common: {
|
|
...ctx.common,
|
|
issues: []
|
|
},
|
|
parent: null
|
|
};
|
|
const result = option._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: childCtx
|
|
});
|
|
if (result.status === "valid") {
|
|
return result;
|
|
} else if (result.status === "dirty" && !dirty) {
|
|
dirty = { result, ctx: childCtx };
|
|
}
|
|
if (childCtx.common.issues.length) {
|
|
issues.push(childCtx.common.issues);
|
|
}
|
|
}
|
|
if (dirty) {
|
|
ctx.common.issues.push(...dirty.ctx.common.issues);
|
|
return dirty.result;
|
|
}
|
|
const unionErrors = issues.map((issues2) => new ZodError(issues2));
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_union,
|
|
unionErrors
|
|
});
|
|
return INVALID;
|
|
}
|
|
}
|
|
get options() {
|
|
return this._def.options;
|
|
}
|
|
}
|
|
ZodUnion.create = (types, params) => {
|
|
return new ZodUnion({
|
|
options: types,
|
|
typeName: ZodFirstPartyTypeKind.ZodUnion,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
var getDiscriminator = (type) => {
|
|
if (type instanceof ZodLazy) {
|
|
return getDiscriminator(type.schema);
|
|
} else if (type instanceof ZodEffects) {
|
|
return getDiscriminator(type.innerType());
|
|
} else if (type instanceof ZodLiteral) {
|
|
return [type.value];
|
|
} else if (type instanceof ZodEnum) {
|
|
return type.options;
|
|
} else if (type instanceof ZodNativeEnum) {
|
|
return util.objectValues(type.enum);
|
|
} else if (type instanceof ZodDefault) {
|
|
return getDiscriminator(type._def.innerType);
|
|
} else if (type instanceof ZodUndefined) {
|
|
return [undefined];
|
|
} else if (type instanceof ZodNull) {
|
|
return [null];
|
|
} else if (type instanceof ZodOptional) {
|
|
return [undefined, ...getDiscriminator(type.unwrap())];
|
|
} else if (type instanceof ZodNullable) {
|
|
return [null, ...getDiscriminator(type.unwrap())];
|
|
} else if (type instanceof ZodBranded) {
|
|
return getDiscriminator(type.unwrap());
|
|
} else if (type instanceof ZodReadonly) {
|
|
return getDiscriminator(type.unwrap());
|
|
} else if (type instanceof ZodCatch) {
|
|
return getDiscriminator(type._def.innerType);
|
|
} else {
|
|
return [];
|
|
}
|
|
};
|
|
|
|
class ZodDiscriminatedUnion extends ZodType {
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.object,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const discriminator = this.discriminator;
|
|
const discriminatorValue = ctx.data[discriminator];
|
|
const option = this.optionsMap.get(discriminatorValue);
|
|
if (!option) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_union_discriminator,
|
|
options: Array.from(this.optionsMap.keys()),
|
|
path: [discriminator]
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (ctx.common.async) {
|
|
return option._parseAsync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
} else {
|
|
return option._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
}
|
|
}
|
|
get discriminator() {
|
|
return this._def.discriminator;
|
|
}
|
|
get options() {
|
|
return this._def.options;
|
|
}
|
|
get optionsMap() {
|
|
return this._def.optionsMap;
|
|
}
|
|
static create(discriminator, options, params) {
|
|
const optionsMap = new Map;
|
|
for (const type of options) {
|
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
if (!discriminatorValues.length) {
|
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
}
|
|
for (const value of discriminatorValues) {
|
|
if (optionsMap.has(value)) {
|
|
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
}
|
|
optionsMap.set(value, type);
|
|
}
|
|
}
|
|
return new ZodDiscriminatedUnion({
|
|
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
|
discriminator,
|
|
options,
|
|
optionsMap,
|
|
...processCreateParams(params)
|
|
});
|
|
}
|
|
}
|
|
function mergeValues(a, b) {
|
|
const aType = getParsedType(a);
|
|
const bType = getParsedType(b);
|
|
if (a === b) {
|
|
return { valid: true, data: a };
|
|
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
const bKeys = util.objectKeys(b);
|
|
const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
const newObj = { ...a, ...b };
|
|
for (const key of sharedKeys) {
|
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
if (!sharedValue.valid) {
|
|
return { valid: false };
|
|
}
|
|
newObj[key] = sharedValue.data;
|
|
}
|
|
return { valid: true, data: newObj };
|
|
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
if (a.length !== b.length) {
|
|
return { valid: false };
|
|
}
|
|
const newArray = [];
|
|
for (let index = 0;index < a.length; index++) {
|
|
const itemA = a[index];
|
|
const itemB = b[index];
|
|
const sharedValue = mergeValues(itemA, itemB);
|
|
if (!sharedValue.valid) {
|
|
return { valid: false };
|
|
}
|
|
newArray.push(sharedValue.data);
|
|
}
|
|
return { valid: true, data: newArray };
|
|
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
|
|
return { valid: true, data: a };
|
|
} else {
|
|
return { valid: false };
|
|
}
|
|
}
|
|
|
|
class ZodIntersection extends ZodType {
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
return INVALID;
|
|
}
|
|
const merged = mergeValues(parsedLeft.value, parsedRight.value);
|
|
if (!merged.valid) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_intersection_types
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
|
|
status.dirty();
|
|
}
|
|
return { status: status.value, value: merged.data };
|
|
};
|
|
if (ctx.common.async) {
|
|
return Promise.all([
|
|
this._def.left._parseAsync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
}),
|
|
this._def.right._parseAsync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
})
|
|
]).then(([left, right]) => handleParsed(left, right));
|
|
} else {
|
|
return handleParsed(this._def.left._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
}), this._def.right._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
ZodIntersection.create = (left, right, params) => {
|
|
return new ZodIntersection({
|
|
left,
|
|
right,
|
|
typeName: ZodFirstPartyTypeKind.ZodIntersection,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodTuple extends ZodType {
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.array,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (ctx.data.length < this._def.items.length) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
minimum: this._def.items.length,
|
|
inclusive: true,
|
|
exact: false,
|
|
type: "array"
|
|
});
|
|
return INVALID;
|
|
}
|
|
const rest = this._def.rest;
|
|
if (!rest && ctx.data.length > this._def.items.length) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
maximum: this._def.items.length,
|
|
inclusive: true,
|
|
exact: false,
|
|
type: "array"
|
|
});
|
|
status.dirty();
|
|
}
|
|
const items = [...ctx.data].map((item, itemIndex) => {
|
|
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
if (!schema)
|
|
return null;
|
|
return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
|
}).filter((x) => !!x);
|
|
if (ctx.common.async) {
|
|
return Promise.all(items).then((results) => {
|
|
return ParseStatus.mergeArray(status, results);
|
|
});
|
|
} else {
|
|
return ParseStatus.mergeArray(status, items);
|
|
}
|
|
}
|
|
get items() {
|
|
return this._def.items;
|
|
}
|
|
rest(rest) {
|
|
return new ZodTuple({
|
|
...this._def,
|
|
rest
|
|
});
|
|
}
|
|
}
|
|
ZodTuple.create = (schemas, params) => {
|
|
if (!Array.isArray(schemas)) {
|
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
}
|
|
return new ZodTuple({
|
|
items: schemas,
|
|
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
|
rest: null,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodRecord extends ZodType {
|
|
get keySchema() {
|
|
return this._def.keyType;
|
|
}
|
|
get valueSchema() {
|
|
return this._def.valueType;
|
|
}
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.object,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const pairs = [];
|
|
const keyType = this._def.keyType;
|
|
const valueType = this._def.valueType;
|
|
for (const key in ctx.data) {
|
|
pairs.push({
|
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
alwaysSet: key in ctx.data
|
|
});
|
|
}
|
|
if (ctx.common.async) {
|
|
return ParseStatus.mergeObjectAsync(status, pairs);
|
|
} else {
|
|
return ParseStatus.mergeObjectSync(status, pairs);
|
|
}
|
|
}
|
|
get element() {
|
|
return this._def.valueType;
|
|
}
|
|
static create(first, second, third) {
|
|
if (second instanceof ZodType) {
|
|
return new ZodRecord({
|
|
keyType: first,
|
|
valueType: second,
|
|
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
...processCreateParams(third)
|
|
});
|
|
}
|
|
return new ZodRecord({
|
|
keyType: ZodString.create(),
|
|
valueType: first,
|
|
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
...processCreateParams(second)
|
|
});
|
|
}
|
|
}
|
|
|
|
class ZodMap extends ZodType {
|
|
get keySchema() {
|
|
return this._def.keyType;
|
|
}
|
|
get valueSchema() {
|
|
return this._def.valueType;
|
|
}
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.map,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const keyType = this._def.keyType;
|
|
const valueType = this._def.valueType;
|
|
const pairs = [...ctx.data.entries()].map(([key, value], index) => {
|
|
return {
|
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
|
|
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
|
};
|
|
});
|
|
if (ctx.common.async) {
|
|
const finalMap = new Map;
|
|
return Promise.resolve().then(async () => {
|
|
for (const pair of pairs) {
|
|
const key = await pair.key;
|
|
const value = await pair.value;
|
|
if (key.status === "aborted" || value.status === "aborted") {
|
|
return INVALID;
|
|
}
|
|
if (key.status === "dirty" || value.status === "dirty") {
|
|
status.dirty();
|
|
}
|
|
finalMap.set(key.value, value.value);
|
|
}
|
|
return { status: status.value, value: finalMap };
|
|
});
|
|
} else {
|
|
const finalMap = new Map;
|
|
for (const pair of pairs) {
|
|
const key = pair.key;
|
|
const value = pair.value;
|
|
if (key.status === "aborted" || value.status === "aborted") {
|
|
return INVALID;
|
|
}
|
|
if (key.status === "dirty" || value.status === "dirty") {
|
|
status.dirty();
|
|
}
|
|
finalMap.set(key.value, value.value);
|
|
}
|
|
return { status: status.value, value: finalMap };
|
|
}
|
|
}
|
|
}
|
|
ZodMap.create = (keyType, valueType, params) => {
|
|
return new ZodMap({
|
|
valueType,
|
|
keyType,
|
|
typeName: ZodFirstPartyTypeKind.ZodMap,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodSet extends ZodType {
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.set,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const def = this._def;
|
|
if (def.minSize !== null) {
|
|
if (ctx.data.size < def.minSize.value) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_small,
|
|
minimum: def.minSize.value,
|
|
type: "set",
|
|
inclusive: true,
|
|
exact: false,
|
|
message: def.minSize.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
}
|
|
if (def.maxSize !== null) {
|
|
if (ctx.data.size > def.maxSize.value) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.too_big,
|
|
maximum: def.maxSize.value,
|
|
type: "set",
|
|
inclusive: true,
|
|
exact: false,
|
|
message: def.maxSize.message
|
|
});
|
|
status.dirty();
|
|
}
|
|
}
|
|
const valueType = this._def.valueType;
|
|
function finalizeSet(elements2) {
|
|
const parsedSet = new Set;
|
|
for (const element of elements2) {
|
|
if (element.status === "aborted")
|
|
return INVALID;
|
|
if (element.status === "dirty")
|
|
status.dirty();
|
|
parsedSet.add(element.value);
|
|
}
|
|
return { status: status.value, value: parsedSet };
|
|
}
|
|
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
if (ctx.common.async) {
|
|
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
|
} else {
|
|
return finalizeSet(elements);
|
|
}
|
|
}
|
|
min(minSize, message) {
|
|
return new ZodSet({
|
|
...this._def,
|
|
minSize: { value: minSize, message: errorUtil.toString(message) }
|
|
});
|
|
}
|
|
max(maxSize, message) {
|
|
return new ZodSet({
|
|
...this._def,
|
|
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
|
});
|
|
}
|
|
size(size, message) {
|
|
return this.min(size, message).max(size, message);
|
|
}
|
|
nonempty(message) {
|
|
return this.min(1, message);
|
|
}
|
|
}
|
|
ZodSet.create = (valueType, params) => {
|
|
return new ZodSet({
|
|
valueType,
|
|
minSize: null,
|
|
maxSize: null,
|
|
typeName: ZodFirstPartyTypeKind.ZodSet,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodFunction extends ZodType {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.validate = this.implement;
|
|
}
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.function,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
function makeArgsIssue(args, error) {
|
|
return makeIssue({
|
|
data: args,
|
|
path: ctx.path,
|
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
|
issueData: {
|
|
code: ZodIssueCode.invalid_arguments,
|
|
argumentsError: error
|
|
}
|
|
});
|
|
}
|
|
function makeReturnsIssue(returns, error) {
|
|
return makeIssue({
|
|
data: returns,
|
|
path: ctx.path,
|
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
|
issueData: {
|
|
code: ZodIssueCode.invalid_return_type,
|
|
returnTypeError: error
|
|
}
|
|
});
|
|
}
|
|
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
const fn = ctx.data;
|
|
if (this._def.returns instanceof ZodPromise) {
|
|
const me = this;
|
|
return OK(async function(...args) {
|
|
const error = new ZodError([]);
|
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
error.addIssue(makeArgsIssue(args, e));
|
|
throw error;
|
|
});
|
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
error.addIssue(makeReturnsIssue(result, e));
|
|
throw error;
|
|
});
|
|
return parsedReturns;
|
|
});
|
|
} else {
|
|
const me = this;
|
|
return OK(function(...args) {
|
|
const parsedArgs = me._def.args.safeParse(args, params);
|
|
if (!parsedArgs.success) {
|
|
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
}
|
|
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
if (!parsedReturns.success) {
|
|
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
}
|
|
return parsedReturns.data;
|
|
});
|
|
}
|
|
}
|
|
parameters() {
|
|
return this._def.args;
|
|
}
|
|
returnType() {
|
|
return this._def.returns;
|
|
}
|
|
args(...items) {
|
|
return new ZodFunction({
|
|
...this._def,
|
|
args: ZodTuple.create(items).rest(ZodUnknown.create())
|
|
});
|
|
}
|
|
returns(returnType) {
|
|
return new ZodFunction({
|
|
...this._def,
|
|
returns: returnType
|
|
});
|
|
}
|
|
implement(func) {
|
|
const validatedFunc = this.parse(func);
|
|
return validatedFunc;
|
|
}
|
|
strictImplement(func) {
|
|
const validatedFunc = this.parse(func);
|
|
return validatedFunc;
|
|
}
|
|
static create(args, returns, params) {
|
|
return new ZodFunction({
|
|
args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
|
|
returns: returns || ZodUnknown.create(),
|
|
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
...processCreateParams(params)
|
|
});
|
|
}
|
|
}
|
|
|
|
class ZodLazy extends ZodType {
|
|
get schema() {
|
|
return this._def.getter();
|
|
}
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
const lazySchema = this._def.getter();
|
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
}
|
|
}
|
|
ZodLazy.create = (getter, params) => {
|
|
return new ZodLazy({
|
|
getter,
|
|
typeName: ZodFirstPartyTypeKind.ZodLazy,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodLiteral extends ZodType {
|
|
_parse(input) {
|
|
if (input.data !== this._def.value) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
received: ctx.data,
|
|
code: ZodIssueCode.invalid_literal,
|
|
expected: this._def.value
|
|
});
|
|
return INVALID;
|
|
}
|
|
return { status: "valid", value: input.data };
|
|
}
|
|
get value() {
|
|
return this._def.value;
|
|
}
|
|
}
|
|
ZodLiteral.create = (value, params) => {
|
|
return new ZodLiteral({
|
|
value,
|
|
typeName: ZodFirstPartyTypeKind.ZodLiteral,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
function createZodEnum(values, params) {
|
|
return new ZodEnum({
|
|
values,
|
|
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
...processCreateParams(params)
|
|
});
|
|
}
|
|
|
|
class ZodEnum extends ZodType {
|
|
_parse(input) {
|
|
if (typeof input.data !== "string") {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
const expectedValues = this._def.values;
|
|
addIssueToContext(ctx, {
|
|
expected: util.joinValues(expectedValues),
|
|
received: ctx.parsedType,
|
|
code: ZodIssueCode.invalid_type
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (!this._cache) {
|
|
this._cache = new Set(this._def.values);
|
|
}
|
|
if (!this._cache.has(input.data)) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
const expectedValues = this._def.values;
|
|
addIssueToContext(ctx, {
|
|
received: ctx.data,
|
|
code: ZodIssueCode.invalid_enum_value,
|
|
options: expectedValues
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
get options() {
|
|
return this._def.values;
|
|
}
|
|
get enum() {
|
|
const enumValues = {};
|
|
for (const val of this._def.values) {
|
|
enumValues[val] = val;
|
|
}
|
|
return enumValues;
|
|
}
|
|
get Values() {
|
|
const enumValues = {};
|
|
for (const val of this._def.values) {
|
|
enumValues[val] = val;
|
|
}
|
|
return enumValues;
|
|
}
|
|
get Enum() {
|
|
const enumValues = {};
|
|
for (const val of this._def.values) {
|
|
enumValues[val] = val;
|
|
}
|
|
return enumValues;
|
|
}
|
|
extract(values, newDef = this._def) {
|
|
return ZodEnum.create(values, {
|
|
...this._def,
|
|
...newDef
|
|
});
|
|
}
|
|
exclude(values, newDef = this._def) {
|
|
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
...this._def,
|
|
...newDef
|
|
});
|
|
}
|
|
}
|
|
ZodEnum.create = createZodEnum;
|
|
|
|
class ZodNativeEnum extends ZodType {
|
|
_parse(input) {
|
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
const ctx = this._getOrReturnCtx(input);
|
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
addIssueToContext(ctx, {
|
|
expected: util.joinValues(expectedValues),
|
|
received: ctx.parsedType,
|
|
code: ZodIssueCode.invalid_type
|
|
});
|
|
return INVALID;
|
|
}
|
|
if (!this._cache) {
|
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
}
|
|
if (!this._cache.has(input.data)) {
|
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
addIssueToContext(ctx, {
|
|
received: ctx.data,
|
|
code: ZodIssueCode.invalid_enum_value,
|
|
options: expectedValues
|
|
});
|
|
return INVALID;
|
|
}
|
|
return OK(input.data);
|
|
}
|
|
get enum() {
|
|
return this._def.values;
|
|
}
|
|
}
|
|
ZodNativeEnum.create = (values, params) => {
|
|
return new ZodNativeEnum({
|
|
values,
|
|
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodPromise extends ZodType {
|
|
unwrap() {
|
|
return this._def.type;
|
|
}
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.promise,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
return OK(promisified.then((data) => {
|
|
return this._def.type.parseAsync(data, {
|
|
path: ctx.path,
|
|
errorMap: ctx.common.contextualErrorMap
|
|
});
|
|
}));
|
|
}
|
|
}
|
|
ZodPromise.create = (schema, params) => {
|
|
return new ZodPromise({
|
|
type: schema,
|
|
typeName: ZodFirstPartyTypeKind.ZodPromise,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodEffects extends ZodType {
|
|
innerType() {
|
|
return this._def.schema;
|
|
}
|
|
sourceType() {
|
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
}
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
const effect = this._def.effect || null;
|
|
const checkCtx = {
|
|
addIssue: (arg) => {
|
|
addIssueToContext(ctx, arg);
|
|
if (arg.fatal) {
|
|
status.abort();
|
|
} else {
|
|
status.dirty();
|
|
}
|
|
},
|
|
get path() {
|
|
return ctx.path;
|
|
}
|
|
};
|
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
if (effect.type === "preprocess") {
|
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
if (ctx.common.async) {
|
|
return Promise.resolve(processed).then(async (processed2) => {
|
|
if (status.value === "aborted")
|
|
return INVALID;
|
|
const result = await this._def.schema._parseAsync({
|
|
data: processed2,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
if (result.status === "aborted")
|
|
return INVALID;
|
|
if (result.status === "dirty")
|
|
return DIRTY(result.value);
|
|
if (status.value === "dirty")
|
|
return DIRTY(result.value);
|
|
return result;
|
|
});
|
|
} else {
|
|
if (status.value === "aborted")
|
|
return INVALID;
|
|
const result = this._def.schema._parseSync({
|
|
data: processed,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
if (result.status === "aborted")
|
|
return INVALID;
|
|
if (result.status === "dirty")
|
|
return DIRTY(result.value);
|
|
if (status.value === "dirty")
|
|
return DIRTY(result.value);
|
|
return result;
|
|
}
|
|
}
|
|
if (effect.type === "refinement") {
|
|
const executeRefinement = (acc) => {
|
|
const result = effect.refinement(acc, checkCtx);
|
|
if (ctx.common.async) {
|
|
return Promise.resolve(result);
|
|
}
|
|
if (result instanceof Promise) {
|
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
}
|
|
return acc;
|
|
};
|
|
if (ctx.common.async === false) {
|
|
const inner = this._def.schema._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
if (inner.status === "aborted")
|
|
return INVALID;
|
|
if (inner.status === "dirty")
|
|
status.dirty();
|
|
executeRefinement(inner.value);
|
|
return { status: status.value, value: inner.value };
|
|
} else {
|
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
if (inner.status === "aborted")
|
|
return INVALID;
|
|
if (inner.status === "dirty")
|
|
status.dirty();
|
|
return executeRefinement(inner.value).then(() => {
|
|
return { status: status.value, value: inner.value };
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if (effect.type === "transform") {
|
|
if (ctx.common.async === false) {
|
|
const base = this._def.schema._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
if (!isValid(base))
|
|
return INVALID;
|
|
const result = effect.transform(base.value, checkCtx);
|
|
if (result instanceof Promise) {
|
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
}
|
|
return { status: status.value, value: result };
|
|
} else {
|
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
if (!isValid(base))
|
|
return INVALID;
|
|
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
status: status.value,
|
|
value: result
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
util.assertNever(effect);
|
|
}
|
|
}
|
|
ZodEffects.create = (schema, effect, params) => {
|
|
return new ZodEffects({
|
|
schema,
|
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
effect,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
return new ZodEffects({
|
|
schema,
|
|
effect: { type: "preprocess", transform: preprocess },
|
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
class ZodOptional extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType === ZodParsedType.undefined) {
|
|
return OK(undefined);
|
|
}
|
|
return this._def.innerType._parse(input);
|
|
}
|
|
unwrap() {
|
|
return this._def.innerType;
|
|
}
|
|
}
|
|
ZodOptional.create = (type, params) => {
|
|
return new ZodOptional({
|
|
innerType: type,
|
|
typeName: ZodFirstPartyTypeKind.ZodOptional,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodNullable extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType === ZodParsedType.null) {
|
|
return OK(null);
|
|
}
|
|
return this._def.innerType._parse(input);
|
|
}
|
|
unwrap() {
|
|
return this._def.innerType;
|
|
}
|
|
}
|
|
ZodNullable.create = (type, params) => {
|
|
return new ZodNullable({
|
|
innerType: type,
|
|
typeName: ZodFirstPartyTypeKind.ZodNullable,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodDefault extends ZodType {
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
let data = ctx.data;
|
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
data = this._def.defaultValue();
|
|
}
|
|
return this._def.innerType._parse({
|
|
data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
}
|
|
removeDefault() {
|
|
return this._def.innerType;
|
|
}
|
|
}
|
|
ZodDefault.create = (type, params) => {
|
|
return new ZodDefault({
|
|
innerType: type,
|
|
typeName: ZodFirstPartyTypeKind.ZodDefault,
|
|
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodCatch extends ZodType {
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
const newCtx = {
|
|
...ctx,
|
|
common: {
|
|
...ctx.common,
|
|
issues: []
|
|
}
|
|
};
|
|
const result = this._def.innerType._parse({
|
|
data: newCtx.data,
|
|
path: newCtx.path,
|
|
parent: {
|
|
...newCtx
|
|
}
|
|
});
|
|
if (isAsync(result)) {
|
|
return result.then((result2) => {
|
|
return {
|
|
status: "valid",
|
|
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
get error() {
|
|
return new ZodError(newCtx.common.issues);
|
|
},
|
|
input: newCtx.data
|
|
})
|
|
};
|
|
});
|
|
} else {
|
|
return {
|
|
status: "valid",
|
|
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
get error() {
|
|
return new ZodError(newCtx.common.issues);
|
|
},
|
|
input: newCtx.data
|
|
})
|
|
};
|
|
}
|
|
}
|
|
removeCatch() {
|
|
return this._def.innerType;
|
|
}
|
|
}
|
|
ZodCatch.create = (type, params) => {
|
|
return new ZodCatch({
|
|
innerType: type,
|
|
typeName: ZodFirstPartyTypeKind.ZodCatch,
|
|
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
|
|
class ZodNaN extends ZodType {
|
|
_parse(input) {
|
|
const parsedType = this._getType(input);
|
|
if (parsedType !== ZodParsedType.nan) {
|
|
const ctx = this._getOrReturnCtx(input);
|
|
addIssueToContext(ctx, {
|
|
code: ZodIssueCode.invalid_type,
|
|
expected: ZodParsedType.nan,
|
|
received: ctx.parsedType
|
|
});
|
|
return INVALID;
|
|
}
|
|
return { status: "valid", value: input.data };
|
|
}
|
|
}
|
|
ZodNaN.create = (params) => {
|
|
return new ZodNaN({
|
|
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
var BRAND = Symbol("zod_brand");
|
|
|
|
class ZodBranded extends ZodType {
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
const data = ctx.data;
|
|
return this._def.type._parse({
|
|
data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
}
|
|
unwrap() {
|
|
return this._def.type;
|
|
}
|
|
}
|
|
|
|
class ZodPipeline extends ZodType {
|
|
_parse(input) {
|
|
const { status, ctx } = this._processInputParams(input);
|
|
if (ctx.common.async) {
|
|
const handleAsync = async () => {
|
|
const inResult = await this._def.in._parseAsync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
if (inResult.status === "aborted")
|
|
return INVALID;
|
|
if (inResult.status === "dirty") {
|
|
status.dirty();
|
|
return DIRTY(inResult.value);
|
|
} else {
|
|
return this._def.out._parseAsync({
|
|
data: inResult.value,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
}
|
|
};
|
|
return handleAsync();
|
|
} else {
|
|
const inResult = this._def.in._parseSync({
|
|
data: ctx.data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
if (inResult.status === "aborted")
|
|
return INVALID;
|
|
if (inResult.status === "dirty") {
|
|
status.dirty();
|
|
return {
|
|
status: "dirty",
|
|
value: inResult.value
|
|
};
|
|
} else {
|
|
return this._def.out._parseSync({
|
|
data: inResult.value,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
}
|
|
}
|
|
}
|
|
static create(a, b) {
|
|
return new ZodPipeline({
|
|
in: a,
|
|
out: b,
|
|
typeName: ZodFirstPartyTypeKind.ZodPipeline
|
|
});
|
|
}
|
|
}
|
|
|
|
class ZodReadonly extends ZodType {
|
|
_parse(input) {
|
|
const result = this._def.innerType._parse(input);
|
|
const freeze = (data) => {
|
|
if (isValid(data)) {
|
|
data.value = Object.freeze(data.value);
|
|
}
|
|
return data;
|
|
};
|
|
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
}
|
|
unwrap() {
|
|
return this._def.innerType;
|
|
}
|
|
}
|
|
ZodReadonly.create = (type, params) => {
|
|
return new ZodReadonly({
|
|
innerType: type,
|
|
typeName: ZodFirstPartyTypeKind.ZodReadonly,
|
|
...processCreateParams(params)
|
|
});
|
|
};
|
|
function cleanParams(params, data) {
|
|
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
const p2 = typeof p === "string" ? { message: p } : p;
|
|
return p2;
|
|
}
|
|
function custom(check, _params = {}, fatal) {
|
|
if (check)
|
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
const r = check(data);
|
|
if (r instanceof Promise) {
|
|
return r.then((r2) => {
|
|
if (!r2) {
|
|
const params = cleanParams(_params, data);
|
|
const _fatal = params.fatal ?? fatal ?? true;
|
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
}
|
|
});
|
|
}
|
|
if (!r) {
|
|
const params = cleanParams(_params, data);
|
|
const _fatal = params.fatal ?? fatal ?? true;
|
|
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
}
|
|
return;
|
|
});
|
|
return ZodAny.create();
|
|
}
|
|
var late = {
|
|
object: ZodObject.lazycreate
|
|
};
|
|
var ZodFirstPartyTypeKind;
|
|
(function(ZodFirstPartyTypeKind2) {
|
|
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
|
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
|
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
|
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
|
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
|
ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
|
|
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
|
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
|
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
|
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
|
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
|
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
|
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
|
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
|
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
|
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
|
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
|
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
|
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
|
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
|
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
|
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
|
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
|
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
|
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
|
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
|
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
|
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
|
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
|
ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
|
|
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
|
ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
|
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
var instanceOfType = (cls, params = {
|
|
message: `Input not instance of ${cls.name}`
|
|
}) => custom((data) => data instanceof cls, params);
|
|
var stringType = ZodString.create;
|
|
var numberType = ZodNumber.create;
|
|
var nanType = ZodNaN.create;
|
|
var bigIntType = ZodBigInt.create;
|
|
var booleanType = ZodBoolean.create;
|
|
var dateType = ZodDate.create;
|
|
var symbolType = ZodSymbol.create;
|
|
var undefinedType = ZodUndefined.create;
|
|
var nullType = ZodNull.create;
|
|
var anyType = ZodAny.create;
|
|
var unknownType = ZodUnknown.create;
|
|
var neverType = ZodNever.create;
|
|
var voidType = ZodVoid.create;
|
|
var arrayType = ZodArray.create;
|
|
var objectType = ZodObject.create;
|
|
var strictObjectType = ZodObject.strictCreate;
|
|
var unionType = ZodUnion.create;
|
|
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
|
var intersectionType = ZodIntersection.create;
|
|
var tupleType = ZodTuple.create;
|
|
var recordType = ZodRecord.create;
|
|
var mapType = ZodMap.create;
|
|
var setType = ZodSet.create;
|
|
var functionType = ZodFunction.create;
|
|
var lazyType = ZodLazy.create;
|
|
var literalType = ZodLiteral.create;
|
|
var enumType = ZodEnum.create;
|
|
var nativeEnumType = ZodNativeEnum.create;
|
|
var promiseType = ZodPromise.create;
|
|
var effectsType = ZodEffects.create;
|
|
var optionalType = ZodOptional.create;
|
|
var nullableType = ZodNullable.create;
|
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
var pipelineType = ZodPipeline.create;
|
|
var ostring = () => stringType().optional();
|
|
var onumber = () => numberType().optional();
|
|
var oboolean = () => booleanType().optional();
|
|
var coerce = {
|
|
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
boolean: (arg) => ZodBoolean.create({
|
|
...arg,
|
|
coerce: true
|
|
}),
|
|
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
};
|
|
var NEVER = INVALID;
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
var LATEST_PROTOCOL_VERSION = "2025-06-18";
|
|
var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
|
|
var JSONRPC_VERSION = "2.0";
|
|
var ProgressTokenSchema = exports_external.union([exports_external.string(), exports_external.number().int()]);
|
|
var CursorSchema = exports_external.string();
|
|
var RequestMetaSchema = exports_external.object({
|
|
progressToken: exports_external.optional(ProgressTokenSchema)
|
|
}).passthrough();
|
|
var BaseRequestParamsSchema = exports_external.object({
|
|
_meta: exports_external.optional(RequestMetaSchema)
|
|
}).passthrough();
|
|
var RequestSchema = exports_external.object({
|
|
method: exports_external.string(),
|
|
params: exports_external.optional(BaseRequestParamsSchema)
|
|
});
|
|
var BaseNotificationParamsSchema = exports_external.object({
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var NotificationSchema = exports_external.object({
|
|
method: exports_external.string(),
|
|
params: exports_external.optional(BaseNotificationParamsSchema)
|
|
});
|
|
var ResultSchema = exports_external.object({
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var RequestIdSchema = exports_external.union([exports_external.string(), exports_external.number().int()]);
|
|
var JSONRPCRequestSchema = exports_external.object({
|
|
jsonrpc: exports_external.literal(JSONRPC_VERSION),
|
|
id: RequestIdSchema
|
|
}).merge(RequestSchema).strict();
|
|
var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
|
|
var JSONRPCNotificationSchema = exports_external.object({
|
|
jsonrpc: exports_external.literal(JSONRPC_VERSION)
|
|
}).merge(NotificationSchema).strict();
|
|
var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
|
|
var JSONRPCResponseSchema = exports_external.object({
|
|
jsonrpc: exports_external.literal(JSONRPC_VERSION),
|
|
id: RequestIdSchema,
|
|
result: ResultSchema
|
|
}).strict();
|
|
var isJSONRPCResponse = (value) => JSONRPCResponseSchema.safeParse(value).success;
|
|
var ErrorCode;
|
|
(function(ErrorCode2) {
|
|
ErrorCode2[ErrorCode2["ConnectionClosed"] = -32000] = "ConnectionClosed";
|
|
ErrorCode2[ErrorCode2["RequestTimeout"] = -32001] = "RequestTimeout";
|
|
ErrorCode2[ErrorCode2["ParseError"] = -32700] = "ParseError";
|
|
ErrorCode2[ErrorCode2["InvalidRequest"] = -32600] = "InvalidRequest";
|
|
ErrorCode2[ErrorCode2["MethodNotFound"] = -32601] = "MethodNotFound";
|
|
ErrorCode2[ErrorCode2["InvalidParams"] = -32602] = "InvalidParams";
|
|
ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
|
|
})(ErrorCode || (ErrorCode = {}));
|
|
var JSONRPCErrorSchema = exports_external.object({
|
|
jsonrpc: exports_external.literal(JSONRPC_VERSION),
|
|
id: RequestIdSchema,
|
|
error: exports_external.object({
|
|
code: exports_external.number().int(),
|
|
message: exports_external.string(),
|
|
data: exports_external.optional(exports_external.unknown())
|
|
})
|
|
}).strict();
|
|
var isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
|
|
var JSONRPCMessageSchema = exports_external.union([JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResponseSchema, JSONRPCErrorSchema]);
|
|
var EmptyResultSchema = ResultSchema.strict();
|
|
var CancelledNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/cancelled"),
|
|
params: BaseNotificationParamsSchema.extend({
|
|
requestId: RequestIdSchema,
|
|
reason: exports_external.string().optional()
|
|
})
|
|
});
|
|
var IconSchema = exports_external.object({
|
|
src: exports_external.string(),
|
|
mimeType: exports_external.optional(exports_external.string()),
|
|
sizes: exports_external.optional(exports_external.array(exports_external.string()))
|
|
}).passthrough();
|
|
var IconsSchema = exports_external.object({
|
|
icons: exports_external.array(IconSchema).optional()
|
|
}).passthrough();
|
|
var BaseMetadataSchema = exports_external.object({
|
|
name: exports_external.string(),
|
|
title: exports_external.optional(exports_external.string())
|
|
}).passthrough();
|
|
var ImplementationSchema = BaseMetadataSchema.extend({
|
|
version: exports_external.string(),
|
|
websiteUrl: exports_external.optional(exports_external.string())
|
|
}).merge(IconsSchema);
|
|
var ClientCapabilitiesSchema = exports_external.object({
|
|
experimental: exports_external.optional(exports_external.object({}).passthrough()),
|
|
sampling: exports_external.optional(exports_external.object({}).passthrough()),
|
|
elicitation: exports_external.optional(exports_external.object({}).passthrough()),
|
|
roots: exports_external.optional(exports_external.object({
|
|
listChanged: exports_external.optional(exports_external.boolean())
|
|
}).passthrough())
|
|
}).passthrough();
|
|
var InitializeRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("initialize"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
protocolVersion: exports_external.string(),
|
|
capabilities: ClientCapabilitiesSchema,
|
|
clientInfo: ImplementationSchema
|
|
})
|
|
});
|
|
var ServerCapabilitiesSchema = exports_external.object({
|
|
experimental: exports_external.optional(exports_external.object({}).passthrough()),
|
|
logging: exports_external.optional(exports_external.object({}).passthrough()),
|
|
completions: exports_external.optional(exports_external.object({}).passthrough()),
|
|
prompts: exports_external.optional(exports_external.object({
|
|
listChanged: exports_external.optional(exports_external.boolean())
|
|
}).passthrough()),
|
|
resources: exports_external.optional(exports_external.object({
|
|
subscribe: exports_external.optional(exports_external.boolean()),
|
|
listChanged: exports_external.optional(exports_external.boolean())
|
|
}).passthrough()),
|
|
tools: exports_external.optional(exports_external.object({
|
|
listChanged: exports_external.optional(exports_external.boolean())
|
|
}).passthrough())
|
|
}).passthrough();
|
|
var InitializeResultSchema = ResultSchema.extend({
|
|
protocolVersion: exports_external.string(),
|
|
capabilities: ServerCapabilitiesSchema,
|
|
serverInfo: ImplementationSchema,
|
|
instructions: exports_external.optional(exports_external.string())
|
|
});
|
|
var InitializedNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/initialized")
|
|
});
|
|
var PingRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("ping")
|
|
});
|
|
var ProgressSchema = exports_external.object({
|
|
progress: exports_external.number(),
|
|
total: exports_external.optional(exports_external.number()),
|
|
message: exports_external.optional(exports_external.string())
|
|
}).passthrough();
|
|
var ProgressNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/progress"),
|
|
params: BaseNotificationParamsSchema.merge(ProgressSchema).extend({
|
|
progressToken: ProgressTokenSchema
|
|
})
|
|
});
|
|
var PaginatedRequestSchema = RequestSchema.extend({
|
|
params: BaseRequestParamsSchema.extend({
|
|
cursor: exports_external.optional(CursorSchema)
|
|
}).optional()
|
|
});
|
|
var PaginatedResultSchema = ResultSchema.extend({
|
|
nextCursor: exports_external.optional(CursorSchema)
|
|
});
|
|
var ResourceContentsSchema = exports_external.object({
|
|
uri: exports_external.string(),
|
|
mimeType: exports_external.optional(exports_external.string()),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
text: exports_external.string()
|
|
});
|
|
var Base64Schema = exports_external.string().refine((val) => {
|
|
try {
|
|
atob(val);
|
|
return true;
|
|
} catch (_a) {
|
|
return false;
|
|
}
|
|
}, { message: "Invalid Base64 string" });
|
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
blob: Base64Schema
|
|
});
|
|
var ResourceSchema = BaseMetadataSchema.extend({
|
|
uri: exports_external.string(),
|
|
description: exports_external.optional(exports_external.string()),
|
|
mimeType: exports_external.optional(exports_external.string()),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).merge(IconsSchema);
|
|
var ResourceTemplateSchema = BaseMetadataSchema.extend({
|
|
uriTemplate: exports_external.string(),
|
|
description: exports_external.optional(exports_external.string()),
|
|
mimeType: exports_external.optional(exports_external.string()),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).merge(IconsSchema);
|
|
var ListResourcesRequestSchema = PaginatedRequestSchema.extend({
|
|
method: exports_external.literal("resources/list")
|
|
});
|
|
var ListResourcesResultSchema = PaginatedResultSchema.extend({
|
|
resources: exports_external.array(ResourceSchema)
|
|
});
|
|
var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
|
|
method: exports_external.literal("resources/templates/list")
|
|
});
|
|
var ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
|
|
resourceTemplates: exports_external.array(ResourceTemplateSchema)
|
|
});
|
|
var ReadResourceRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("resources/read"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
uri: exports_external.string()
|
|
})
|
|
});
|
|
var ReadResourceResultSchema = ResultSchema.extend({
|
|
contents: exports_external.array(exports_external.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
|
|
});
|
|
var ResourceListChangedNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/resources/list_changed")
|
|
});
|
|
var SubscribeRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("resources/subscribe"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
uri: exports_external.string()
|
|
})
|
|
});
|
|
var UnsubscribeRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("resources/unsubscribe"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
uri: exports_external.string()
|
|
})
|
|
});
|
|
var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/resources/updated"),
|
|
params: BaseNotificationParamsSchema.extend({
|
|
uri: exports_external.string()
|
|
})
|
|
});
|
|
var PromptArgumentSchema = exports_external.object({
|
|
name: exports_external.string(),
|
|
description: exports_external.optional(exports_external.string()),
|
|
required: exports_external.optional(exports_external.boolean())
|
|
}).passthrough();
|
|
var PromptSchema = BaseMetadataSchema.extend({
|
|
description: exports_external.optional(exports_external.string()),
|
|
arguments: exports_external.optional(exports_external.array(PromptArgumentSchema)),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).merge(IconsSchema);
|
|
var ListPromptsRequestSchema = PaginatedRequestSchema.extend({
|
|
method: exports_external.literal("prompts/list")
|
|
});
|
|
var ListPromptsResultSchema = PaginatedResultSchema.extend({
|
|
prompts: exports_external.array(PromptSchema)
|
|
});
|
|
var GetPromptRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("prompts/get"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
name: exports_external.string(),
|
|
arguments: exports_external.optional(exports_external.record(exports_external.string()))
|
|
})
|
|
});
|
|
var TextContentSchema = exports_external.object({
|
|
type: exports_external.literal("text"),
|
|
text: exports_external.string(),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var ImageContentSchema = exports_external.object({
|
|
type: exports_external.literal("image"),
|
|
data: Base64Schema,
|
|
mimeType: exports_external.string(),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var AudioContentSchema = exports_external.object({
|
|
type: exports_external.literal("audio"),
|
|
data: Base64Schema,
|
|
mimeType: exports_external.string(),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var EmbeddedResourceSchema = exports_external.object({
|
|
type: exports_external.literal("resource"),
|
|
resource: exports_external.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var ResourceLinkSchema = ResourceSchema.extend({
|
|
type: exports_external.literal("resource_link")
|
|
});
|
|
var ContentBlockSchema = exports_external.union([
|
|
TextContentSchema,
|
|
ImageContentSchema,
|
|
AudioContentSchema,
|
|
ResourceLinkSchema,
|
|
EmbeddedResourceSchema
|
|
]);
|
|
var PromptMessageSchema = exports_external.object({
|
|
role: exports_external.enum(["user", "assistant"]),
|
|
content: ContentBlockSchema
|
|
}).passthrough();
|
|
var GetPromptResultSchema = ResultSchema.extend({
|
|
description: exports_external.optional(exports_external.string()),
|
|
messages: exports_external.array(PromptMessageSchema)
|
|
});
|
|
var PromptListChangedNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/prompts/list_changed")
|
|
});
|
|
var ToolAnnotationsSchema = exports_external.object({
|
|
title: exports_external.optional(exports_external.string()),
|
|
readOnlyHint: exports_external.optional(exports_external.boolean()),
|
|
destructiveHint: exports_external.optional(exports_external.boolean()),
|
|
idempotentHint: exports_external.optional(exports_external.boolean()),
|
|
openWorldHint: exports_external.optional(exports_external.boolean())
|
|
}).passthrough();
|
|
var ToolSchema = BaseMetadataSchema.extend({
|
|
description: exports_external.optional(exports_external.string()),
|
|
inputSchema: exports_external.object({
|
|
type: exports_external.literal("object"),
|
|
properties: exports_external.optional(exports_external.object({}).passthrough()),
|
|
required: exports_external.optional(exports_external.array(exports_external.string()))
|
|
}).passthrough(),
|
|
outputSchema: exports_external.optional(exports_external.object({
|
|
type: exports_external.literal("object"),
|
|
properties: exports_external.optional(exports_external.object({}).passthrough()),
|
|
required: exports_external.optional(exports_external.array(exports_external.string()))
|
|
}).passthrough()),
|
|
annotations: exports_external.optional(ToolAnnotationsSchema),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).merge(IconsSchema);
|
|
var ListToolsRequestSchema = PaginatedRequestSchema.extend({
|
|
method: exports_external.literal("tools/list")
|
|
});
|
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
tools: exports_external.array(ToolSchema)
|
|
});
|
|
var CallToolResultSchema = ResultSchema.extend({
|
|
content: exports_external.array(ContentBlockSchema).default([]),
|
|
structuredContent: exports_external.object({}).passthrough().optional(),
|
|
isError: exports_external.optional(exports_external.boolean())
|
|
});
|
|
var CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
|
|
toolResult: exports_external.unknown()
|
|
}));
|
|
var CallToolRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("tools/call"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
name: exports_external.string(),
|
|
arguments: exports_external.optional(exports_external.record(exports_external.unknown()))
|
|
})
|
|
});
|
|
var ToolListChangedNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/tools/list_changed")
|
|
});
|
|
var LoggingLevelSchema = exports_external.enum(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
|
|
var SetLevelRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("logging/setLevel"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
level: LoggingLevelSchema
|
|
})
|
|
});
|
|
var LoggingMessageNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/message"),
|
|
params: BaseNotificationParamsSchema.extend({
|
|
level: LoggingLevelSchema,
|
|
logger: exports_external.optional(exports_external.string()),
|
|
data: exports_external.unknown()
|
|
})
|
|
});
|
|
var ModelHintSchema = exports_external.object({
|
|
name: exports_external.string().optional()
|
|
}).passthrough();
|
|
var ModelPreferencesSchema = exports_external.object({
|
|
hints: exports_external.optional(exports_external.array(ModelHintSchema)),
|
|
costPriority: exports_external.optional(exports_external.number().min(0).max(1)),
|
|
speedPriority: exports_external.optional(exports_external.number().min(0).max(1)),
|
|
intelligencePriority: exports_external.optional(exports_external.number().min(0).max(1))
|
|
}).passthrough();
|
|
var SamplingMessageSchema = exports_external.object({
|
|
role: exports_external.enum(["user", "assistant"]),
|
|
content: exports_external.union([TextContentSchema, ImageContentSchema, AudioContentSchema])
|
|
}).passthrough();
|
|
var CreateMessageRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("sampling/createMessage"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
messages: exports_external.array(SamplingMessageSchema),
|
|
systemPrompt: exports_external.optional(exports_external.string()),
|
|
includeContext: exports_external.optional(exports_external.enum(["none", "thisServer", "allServers"])),
|
|
temperature: exports_external.optional(exports_external.number()),
|
|
maxTokens: exports_external.number().int(),
|
|
stopSequences: exports_external.optional(exports_external.array(exports_external.string())),
|
|
metadata: exports_external.optional(exports_external.object({}).passthrough()),
|
|
modelPreferences: exports_external.optional(ModelPreferencesSchema)
|
|
})
|
|
});
|
|
var CreateMessageResultSchema = ResultSchema.extend({
|
|
model: exports_external.string(),
|
|
stopReason: exports_external.optional(exports_external.enum(["endTurn", "stopSequence", "maxTokens"]).or(exports_external.string())),
|
|
role: exports_external.enum(["user", "assistant"]),
|
|
content: exports_external.discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema])
|
|
});
|
|
var BooleanSchemaSchema = exports_external.object({
|
|
type: exports_external.literal("boolean"),
|
|
title: exports_external.optional(exports_external.string()),
|
|
description: exports_external.optional(exports_external.string()),
|
|
default: exports_external.optional(exports_external.boolean())
|
|
}).passthrough();
|
|
var StringSchemaSchema = exports_external.object({
|
|
type: exports_external.literal("string"),
|
|
title: exports_external.optional(exports_external.string()),
|
|
description: exports_external.optional(exports_external.string()),
|
|
minLength: exports_external.optional(exports_external.number()),
|
|
maxLength: exports_external.optional(exports_external.number()),
|
|
format: exports_external.optional(exports_external.enum(["email", "uri", "date", "date-time"]))
|
|
}).passthrough();
|
|
var NumberSchemaSchema = exports_external.object({
|
|
type: exports_external.enum(["number", "integer"]),
|
|
title: exports_external.optional(exports_external.string()),
|
|
description: exports_external.optional(exports_external.string()),
|
|
minimum: exports_external.optional(exports_external.number()),
|
|
maximum: exports_external.optional(exports_external.number())
|
|
}).passthrough();
|
|
var EnumSchemaSchema = exports_external.object({
|
|
type: exports_external.literal("string"),
|
|
title: exports_external.optional(exports_external.string()),
|
|
description: exports_external.optional(exports_external.string()),
|
|
enum: exports_external.array(exports_external.string()),
|
|
enumNames: exports_external.optional(exports_external.array(exports_external.string()))
|
|
}).passthrough();
|
|
var PrimitiveSchemaDefinitionSchema = exports_external.union([BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, EnumSchemaSchema]);
|
|
var ElicitRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("elicitation/create"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
message: exports_external.string(),
|
|
requestedSchema: exports_external.object({
|
|
type: exports_external.literal("object"),
|
|
properties: exports_external.record(exports_external.string(), PrimitiveSchemaDefinitionSchema),
|
|
required: exports_external.optional(exports_external.array(exports_external.string()))
|
|
}).passthrough()
|
|
})
|
|
});
|
|
var ElicitResultSchema = ResultSchema.extend({
|
|
action: exports_external.enum(["accept", "decline", "cancel"]),
|
|
content: exports_external.optional(exports_external.record(exports_external.string(), exports_external.unknown()))
|
|
});
|
|
var ResourceTemplateReferenceSchema = exports_external.object({
|
|
type: exports_external.literal("ref/resource"),
|
|
uri: exports_external.string()
|
|
}).passthrough();
|
|
var PromptReferenceSchema = exports_external.object({
|
|
type: exports_external.literal("ref/prompt"),
|
|
name: exports_external.string()
|
|
}).passthrough();
|
|
var CompleteRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("completion/complete"),
|
|
params: BaseRequestParamsSchema.extend({
|
|
ref: exports_external.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
argument: exports_external.object({
|
|
name: exports_external.string(),
|
|
value: exports_external.string()
|
|
}).passthrough(),
|
|
context: exports_external.optional(exports_external.object({
|
|
arguments: exports_external.optional(exports_external.record(exports_external.string(), exports_external.string()))
|
|
}))
|
|
})
|
|
});
|
|
var CompleteResultSchema = ResultSchema.extend({
|
|
completion: exports_external.object({
|
|
values: exports_external.array(exports_external.string()).max(100),
|
|
total: exports_external.optional(exports_external.number().int()),
|
|
hasMore: exports_external.optional(exports_external.boolean())
|
|
}).passthrough()
|
|
});
|
|
var RootSchema = exports_external.object({
|
|
uri: exports_external.string().startsWith("file://"),
|
|
name: exports_external.optional(exports_external.string()),
|
|
_meta: exports_external.optional(exports_external.object({}).passthrough())
|
|
}).passthrough();
|
|
var ListRootsRequestSchema = RequestSchema.extend({
|
|
method: exports_external.literal("roots/list")
|
|
});
|
|
var ListRootsResultSchema = ResultSchema.extend({
|
|
roots: exports_external.array(RootSchema)
|
|
});
|
|
var RootsListChangedNotificationSchema = NotificationSchema.extend({
|
|
method: exports_external.literal("notifications/roots/list_changed")
|
|
});
|
|
var ClientRequestSchema = exports_external.union([
|
|
PingRequestSchema,
|
|
InitializeRequestSchema,
|
|
CompleteRequestSchema,
|
|
SetLevelRequestSchema,
|
|
GetPromptRequestSchema,
|
|
ListPromptsRequestSchema,
|
|
ListResourcesRequestSchema,
|
|
ListResourceTemplatesRequestSchema,
|
|
ReadResourceRequestSchema,
|
|
SubscribeRequestSchema,
|
|
UnsubscribeRequestSchema,
|
|
CallToolRequestSchema,
|
|
ListToolsRequestSchema
|
|
]);
|
|
var ClientNotificationSchema = exports_external.union([
|
|
CancelledNotificationSchema,
|
|
ProgressNotificationSchema,
|
|
InitializedNotificationSchema,
|
|
RootsListChangedNotificationSchema
|
|
]);
|
|
var ClientResultSchema = exports_external.union([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
|
|
var ServerRequestSchema = exports_external.union([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
|
|
var ServerNotificationSchema = exports_external.union([
|
|
CancelledNotificationSchema,
|
|
ProgressNotificationSchema,
|
|
LoggingMessageNotificationSchema,
|
|
ResourceUpdatedNotificationSchema,
|
|
ResourceListChangedNotificationSchema,
|
|
ToolListChangedNotificationSchema,
|
|
PromptListChangedNotificationSchema
|
|
]);
|
|
var ServerResultSchema = exports_external.union([
|
|
EmptyResultSchema,
|
|
InitializeResultSchema,
|
|
CompleteResultSchema,
|
|
GetPromptResultSchema,
|
|
ListPromptsResultSchema,
|
|
ListResourcesResultSchema,
|
|
ListResourceTemplatesResultSchema,
|
|
ReadResourceResultSchema,
|
|
CallToolResultSchema,
|
|
ListToolsResultSchema
|
|
]);
|
|
|
|
class McpError extends Error {
|
|
constructor(code, message, data) {
|
|
super(`MCP error ${code}: ${message}`);
|
|
this.code = code;
|
|
this.data = data;
|
|
this.name = "McpError";
|
|
}
|
|
}
|
|
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 60000;
|
|
|
|
class Protocol {
|
|
constructor(_options) {
|
|
this._options = _options;
|
|
this._requestMessageId = 0;
|
|
this._requestHandlers = new Map;
|
|
this._requestHandlerAbortControllers = new Map;
|
|
this._notificationHandlers = new Map;
|
|
this._responseHandlers = new Map;
|
|
this._progressHandlers = new Map;
|
|
this._timeoutInfo = new Map;
|
|
this._pendingDebouncedNotifications = new Set;
|
|
this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
|
|
const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
|
|
controller === null || controller === undefined || controller.abort(notification.params.reason);
|
|
});
|
|
this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
|
|
this._onprogress(notification);
|
|
});
|
|
this.setRequestHandler(PingRequestSchema, (_request) => ({}));
|
|
}
|
|
_setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
|
|
this._timeoutInfo.set(messageId, {
|
|
timeoutId: setTimeout(onTimeout, timeout),
|
|
startTime: Date.now(),
|
|
timeout,
|
|
maxTotalTimeout,
|
|
resetTimeoutOnProgress,
|
|
onTimeout
|
|
});
|
|
}
|
|
_resetTimeout(messageId) {
|
|
const info = this._timeoutInfo.get(messageId);
|
|
if (!info)
|
|
return false;
|
|
const totalElapsed = Date.now() - info.startTime;
|
|
if (info.maxTotalTimeout && totalElapsed >= info.maxTotalTimeout) {
|
|
this._timeoutInfo.delete(messageId);
|
|
throw new McpError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", {
|
|
maxTotalTimeout: info.maxTotalTimeout,
|
|
totalElapsed
|
|
});
|
|
}
|
|
clearTimeout(info.timeoutId);
|
|
info.timeoutId = setTimeout(info.onTimeout, info.timeout);
|
|
return true;
|
|
}
|
|
_cleanupTimeout(messageId) {
|
|
const info = this._timeoutInfo.get(messageId);
|
|
if (info) {
|
|
clearTimeout(info.timeoutId);
|
|
this._timeoutInfo.delete(messageId);
|
|
}
|
|
}
|
|
async connect(transport) {
|
|
var _a, _b, _c;
|
|
this._transport = transport;
|
|
const _onclose = (_a = this.transport) === null || _a === undefined ? undefined : _a.onclose;
|
|
this._transport.onclose = () => {
|
|
_onclose === null || _onclose === undefined || _onclose();
|
|
this._onclose();
|
|
};
|
|
const _onerror = (_b = this.transport) === null || _b === undefined ? undefined : _b.onerror;
|
|
this._transport.onerror = (error) => {
|
|
_onerror === null || _onerror === undefined || _onerror(error);
|
|
this._onerror(error);
|
|
};
|
|
const _onmessage = (_c = this._transport) === null || _c === undefined ? undefined : _c.onmessage;
|
|
this._transport.onmessage = (message, extra) => {
|
|
_onmessage === null || _onmessage === undefined || _onmessage(message, extra);
|
|
if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
|
|
this._onresponse(message);
|
|
} else if (isJSONRPCRequest(message)) {
|
|
this._onrequest(message, extra);
|
|
} else if (isJSONRPCNotification(message)) {
|
|
this._onnotification(message);
|
|
} else {
|
|
this._onerror(new Error(`Unknown message type: ${JSON.stringify(message)}`));
|
|
}
|
|
};
|
|
await this._transport.start();
|
|
}
|
|
_onclose() {
|
|
var _a;
|
|
const responseHandlers = this._responseHandlers;
|
|
this._responseHandlers = new Map;
|
|
this._progressHandlers.clear();
|
|
this._pendingDebouncedNotifications.clear();
|
|
this._transport = undefined;
|
|
(_a = this.onclose) === null || _a === undefined || _a.call(this);
|
|
const error = new McpError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
for (const handler of responseHandlers.values()) {
|
|
handler(error);
|
|
}
|
|
}
|
|
_onerror(error) {
|
|
var _a;
|
|
(_a = this.onerror) === null || _a === undefined || _a.call(this, error);
|
|
}
|
|
_onnotification(notification) {
|
|
var _a;
|
|
const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== undefined ? _a : this.fallbackNotificationHandler;
|
|
if (handler === undefined) {
|
|
return;
|
|
}
|
|
Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
|
|
}
|
|
_onrequest(request, extra) {
|
|
var _a, _b;
|
|
const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== undefined ? _a : this.fallbackRequestHandler;
|
|
const capturedTransport = this._transport;
|
|
if (handler === undefined) {
|
|
capturedTransport === null || capturedTransport === undefined || capturedTransport.send({
|
|
jsonrpc: "2.0",
|
|
id: request.id,
|
|
error: {
|
|
code: ErrorCode.MethodNotFound,
|
|
message: "Method not found"
|
|
}
|
|
}).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
|
|
return;
|
|
}
|
|
const abortController = new AbortController;
|
|
this._requestHandlerAbortControllers.set(request.id, abortController);
|
|
const fullExtra = {
|
|
signal: abortController.signal,
|
|
sessionId: capturedTransport === null || capturedTransport === undefined ? undefined : capturedTransport.sessionId,
|
|
_meta: (_b = request.params) === null || _b === undefined ? undefined : _b._meta,
|
|
sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
|
|
sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
|
|
authInfo: extra === null || extra === undefined ? undefined : extra.authInfo,
|
|
requestId: request.id,
|
|
requestInfo: extra === null || extra === undefined ? undefined : extra.requestInfo
|
|
};
|
|
Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
|
|
if (abortController.signal.aborted) {
|
|
return;
|
|
}
|
|
return capturedTransport === null || capturedTransport === undefined ? undefined : capturedTransport.send({
|
|
result,
|
|
jsonrpc: "2.0",
|
|
id: request.id
|
|
});
|
|
}, (error) => {
|
|
var _a2;
|
|
if (abortController.signal.aborted) {
|
|
return;
|
|
}
|
|
return capturedTransport === null || capturedTransport === undefined ? undefined : capturedTransport.send({
|
|
jsonrpc: "2.0",
|
|
id: request.id,
|
|
error: {
|
|
code: Number.isSafeInteger(error["code"]) ? error["code"] : ErrorCode.InternalError,
|
|
message: (_a2 = error.message) !== null && _a2 !== undefined ? _a2 : "Internal error"
|
|
}
|
|
});
|
|
}).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
|
|
this._requestHandlerAbortControllers.delete(request.id);
|
|
});
|
|
}
|
|
_onprogress(notification) {
|
|
const { progressToken, ...params } = notification.params;
|
|
const messageId = Number(progressToken);
|
|
const handler = this._progressHandlers.get(messageId);
|
|
if (!handler) {
|
|
this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(notification)}`));
|
|
return;
|
|
}
|
|
const responseHandler = this._responseHandlers.get(messageId);
|
|
const timeoutInfo = this._timeoutInfo.get(messageId);
|
|
if (timeoutInfo && responseHandler && timeoutInfo.resetTimeoutOnProgress) {
|
|
try {
|
|
this._resetTimeout(messageId);
|
|
} catch (error) {
|
|
responseHandler(error);
|
|
return;
|
|
}
|
|
}
|
|
handler(params);
|
|
}
|
|
_onresponse(response) {
|
|
const messageId = Number(response.id);
|
|
const handler = this._responseHandlers.get(messageId);
|
|
if (handler === undefined) {
|
|
this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
|
|
return;
|
|
}
|
|
this._responseHandlers.delete(messageId);
|
|
this._progressHandlers.delete(messageId);
|
|
this._cleanupTimeout(messageId);
|
|
if (isJSONRPCResponse(response)) {
|
|
handler(response);
|
|
} else {
|
|
const error = new McpError(response.error.code, response.error.message, response.error.data);
|
|
handler(error);
|
|
}
|
|
}
|
|
get transport() {
|
|
return this._transport;
|
|
}
|
|
async close() {
|
|
var _a;
|
|
await ((_a = this._transport) === null || _a === undefined ? undefined : _a.close());
|
|
}
|
|
request(request, resultSchema, options) {
|
|
const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== undefined ? options : {};
|
|
return new Promise((resolve, reject) => {
|
|
var _a, _b, _c, _d, _e, _f;
|
|
if (!this._transport) {
|
|
reject(new Error("Not connected"));
|
|
return;
|
|
}
|
|
if (((_a = this._options) === null || _a === undefined ? undefined : _a.enforceStrictCapabilities) === true) {
|
|
this.assertCapabilityForMethod(request.method);
|
|
}
|
|
(_b = options === null || options === undefined ? undefined : options.signal) === null || _b === undefined || _b.throwIfAborted();
|
|
const messageId = this._requestMessageId++;
|
|
const jsonrpcRequest = {
|
|
...request,
|
|
jsonrpc: "2.0",
|
|
id: messageId
|
|
};
|
|
if (options === null || options === undefined ? undefined : options.onprogress) {
|
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
jsonrpcRequest.params = {
|
|
...request.params,
|
|
_meta: {
|
|
...((_c = request.params) === null || _c === undefined ? undefined : _c._meta) || {},
|
|
progressToken: messageId
|
|
}
|
|
};
|
|
}
|
|
const cancel = (reason) => {
|
|
var _a2;
|
|
this._responseHandlers.delete(messageId);
|
|
this._progressHandlers.delete(messageId);
|
|
this._cleanupTimeout(messageId);
|
|
(_a2 = this._transport) === null || _a2 === undefined || _a2.send({
|
|
jsonrpc: "2.0",
|
|
method: "notifications/cancelled",
|
|
params: {
|
|
requestId: messageId,
|
|
reason: String(reason)
|
|
}
|
|
}, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => this._onerror(new Error(`Failed to send cancellation: ${error}`)));
|
|
reject(reason);
|
|
};
|
|
this._responseHandlers.set(messageId, (response) => {
|
|
var _a2;
|
|
if ((_a2 = options === null || options === undefined ? undefined : options.signal) === null || _a2 === undefined ? undefined : _a2.aborted) {
|
|
return;
|
|
}
|
|
if (response instanceof Error) {
|
|
return reject(response);
|
|
}
|
|
try {
|
|
const result = resultSchema.parse(response.result);
|
|
resolve(result);
|
|
} catch (error) {
|
|
reject(error);
|
|
}
|
|
});
|
|
(_d = options === null || options === undefined ? undefined : options.signal) === null || _d === undefined || _d.addEventListener("abort", () => {
|
|
var _a2;
|
|
cancel((_a2 = options === null || options === undefined ? undefined : options.signal) === null || _a2 === undefined ? undefined : _a2.reason);
|
|
});
|
|
const timeout = (_e = options === null || options === undefined ? undefined : options.timeout) !== null && _e !== undefined ? _e : DEFAULT_REQUEST_TIMEOUT_MSEC;
|
|
const timeoutHandler = () => cancel(new McpError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
|
|
this._setupTimeout(messageId, timeout, options === null || options === undefined ? undefined : options.maxTotalTimeout, timeoutHandler, (_f = options === null || options === undefined ? undefined : options.resetTimeoutOnProgress) !== null && _f !== undefined ? _f : false);
|
|
this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => {
|
|
this._cleanupTimeout(messageId);
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|
|
async notification(notification, options) {
|
|
var _a, _b;
|
|
if (!this._transport) {
|
|
throw new Error("Not connected");
|
|
}
|
|
this.assertNotificationCapability(notification.method);
|
|
const debouncedMethods = (_b = (_a = this._options) === null || _a === undefined ? undefined : _a.debouncedNotificationMethods) !== null && _b !== undefined ? _b : [];
|
|
const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options === null || options === undefined ? undefined : options.relatedRequestId);
|
|
if (canDebounce) {
|
|
if (this._pendingDebouncedNotifications.has(notification.method)) {
|
|
return;
|
|
}
|
|
this._pendingDebouncedNotifications.add(notification.method);
|
|
Promise.resolve().then(() => {
|
|
var _a2;
|
|
this._pendingDebouncedNotifications.delete(notification.method);
|
|
if (!this._transport) {
|
|
return;
|
|
}
|
|
const jsonrpcNotification2 = {
|
|
...notification,
|
|
jsonrpc: "2.0"
|
|
};
|
|
(_a2 = this._transport) === null || _a2 === undefined || _a2.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
|
|
});
|
|
return;
|
|
}
|
|
const jsonrpcNotification = {
|
|
...notification,
|
|
jsonrpc: "2.0"
|
|
};
|
|
await this._transport.send(jsonrpcNotification, options);
|
|
}
|
|
setRequestHandler(requestSchema, handler) {
|
|
const method = requestSchema.shape.method.value;
|
|
this.assertRequestHandlerCapability(method);
|
|
this._requestHandlers.set(method, (request, extra) => {
|
|
return Promise.resolve(handler(requestSchema.parse(request), extra));
|
|
});
|
|
}
|
|
removeRequestHandler(method) {
|
|
this._requestHandlers.delete(method);
|
|
}
|
|
assertCanSetRequestHandler(method) {
|
|
if (this._requestHandlers.has(method)) {
|
|
throw new Error(`A request handler for ${method} already exists, which would be overridden`);
|
|
}
|
|
}
|
|
setNotificationHandler(notificationSchema, handler) {
|
|
this._notificationHandlers.set(notificationSchema.shape.method.value, (notification) => Promise.resolve(handler(notificationSchema.parse(notification))));
|
|
}
|
|
removeNotificationHandler(method) {
|
|
this._notificationHandlers.delete(method);
|
|
}
|
|
}
|
|
function mergeCapabilities(base, additional) {
|
|
return Object.entries(additional).reduce((acc, [key, value]) => {
|
|
if (value && typeof value === "object") {
|
|
acc[key] = acc[key] ? { ...acc[key], ...value } : value;
|
|
} else {
|
|
acc[key] = value;
|
|
}
|
|
return acc;
|
|
}, { ...base });
|
|
}
|
|
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
var import_ajv = __toESM(require_ajv(), 1);
|
|
|
|
class Server extends Protocol {
|
|
constructor(_serverInfo, options) {
|
|
var _a;
|
|
super(options);
|
|
this._serverInfo = _serverInfo;
|
|
this._loggingLevels = new Map;
|
|
this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
|
|
this.isMessageIgnored = (level, sessionId) => {
|
|
const currentLevel = this._loggingLevels.get(sessionId);
|
|
return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
|
|
};
|
|
this._capabilities = (_a = options === null || options === undefined ? undefined : options.capabilities) !== null && _a !== undefined ? _a : {};
|
|
this._instructions = options === null || options === undefined ? undefined : options.instructions;
|
|
this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
|
|
this.setNotificationHandler(InitializedNotificationSchema, () => {
|
|
var _a2;
|
|
return (_a2 = this.oninitialized) === null || _a2 === undefined ? undefined : _a2.call(this);
|
|
});
|
|
if (this._capabilities.logging) {
|
|
this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
|
|
var _a2;
|
|
const transportSessionId = extra.sessionId || ((_a2 = extra.requestInfo) === null || _a2 === undefined ? undefined : _a2.headers["mcp-session-id"]) || undefined;
|
|
const { level } = request.params;
|
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
if (parseResult.success) {
|
|
this._loggingLevels.set(transportSessionId, parseResult.data);
|
|
}
|
|
return {};
|
|
});
|
|
}
|
|
}
|
|
registerCapabilities(capabilities) {
|
|
if (this.transport) {
|
|
throw new Error("Cannot register capabilities after connecting to transport");
|
|
}
|
|
this._capabilities = mergeCapabilities(this._capabilities, capabilities);
|
|
}
|
|
assertCapabilityForMethod(method) {
|
|
var _a, _b, _c;
|
|
switch (method) {
|
|
case "sampling/createMessage":
|
|
if (!((_a = this._clientCapabilities) === null || _a === undefined ? undefined : _a.sampling)) {
|
|
throw new Error(`Client does not support sampling (required for ${method})`);
|
|
}
|
|
break;
|
|
case "elicitation/create":
|
|
if (!((_b = this._clientCapabilities) === null || _b === undefined ? undefined : _b.elicitation)) {
|
|
throw new Error(`Client does not support elicitation (required for ${method})`);
|
|
}
|
|
break;
|
|
case "roots/list":
|
|
if (!((_c = this._clientCapabilities) === null || _c === undefined ? undefined : _c.roots)) {
|
|
throw new Error(`Client does not support listing roots (required for ${method})`);
|
|
}
|
|
break;
|
|
case "ping":
|
|
break;
|
|
}
|
|
}
|
|
assertNotificationCapability(method) {
|
|
switch (method) {
|
|
case "notifications/message":
|
|
if (!this._capabilities.logging) {
|
|
throw new Error(`Server does not support logging (required for ${method})`);
|
|
}
|
|
break;
|
|
case "notifications/resources/updated":
|
|
case "notifications/resources/list_changed":
|
|
if (!this._capabilities.resources) {
|
|
throw new Error(`Server does not support notifying about resources (required for ${method})`);
|
|
}
|
|
break;
|
|
case "notifications/tools/list_changed":
|
|
if (!this._capabilities.tools) {
|
|
throw new Error(`Server does not support notifying of tool list changes (required for ${method})`);
|
|
}
|
|
break;
|
|
case "notifications/prompts/list_changed":
|
|
if (!this._capabilities.prompts) {
|
|
throw new Error(`Server does not support notifying of prompt list changes (required for ${method})`);
|
|
}
|
|
break;
|
|
case "notifications/cancelled":
|
|
break;
|
|
case "notifications/progress":
|
|
break;
|
|
}
|
|
}
|
|
assertRequestHandlerCapability(method) {
|
|
switch (method) {
|
|
case "sampling/createMessage":
|
|
if (!this._capabilities.sampling) {
|
|
throw new Error(`Server does not support sampling (required for ${method})`);
|
|
}
|
|
break;
|
|
case "logging/setLevel":
|
|
if (!this._capabilities.logging) {
|
|
throw new Error(`Server does not support logging (required for ${method})`);
|
|
}
|
|
break;
|
|
case "prompts/get":
|
|
case "prompts/list":
|
|
if (!this._capabilities.prompts) {
|
|
throw new Error(`Server does not support prompts (required for ${method})`);
|
|
}
|
|
break;
|
|
case "resources/list":
|
|
case "resources/templates/list":
|
|
case "resources/read":
|
|
if (!this._capabilities.resources) {
|
|
throw new Error(`Server does not support resources (required for ${method})`);
|
|
}
|
|
break;
|
|
case "tools/call":
|
|
case "tools/list":
|
|
if (!this._capabilities.tools) {
|
|
throw new Error(`Server does not support tools (required for ${method})`);
|
|
}
|
|
break;
|
|
case "ping":
|
|
case "initialize":
|
|
break;
|
|
}
|
|
}
|
|
async _oninitialize(request) {
|
|
const requestedVersion = request.params.protocolVersion;
|
|
this._clientCapabilities = request.params.capabilities;
|
|
this._clientVersion = request.params.clientInfo;
|
|
const protocolVersion = SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION;
|
|
return {
|
|
protocolVersion,
|
|
capabilities: this.getCapabilities(),
|
|
serverInfo: this._serverInfo,
|
|
...this._instructions && { instructions: this._instructions }
|
|
};
|
|
}
|
|
getClientCapabilities() {
|
|
return this._clientCapabilities;
|
|
}
|
|
getClientVersion() {
|
|
return this._clientVersion;
|
|
}
|
|
getCapabilities() {
|
|
return this._capabilities;
|
|
}
|
|
async ping() {
|
|
return this.request({ method: "ping" }, EmptyResultSchema);
|
|
}
|
|
async createMessage(params, options) {
|
|
return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
|
|
}
|
|
async elicitInput(params, options) {
|
|
const result = await this.request({ method: "elicitation/create", params }, ElicitResultSchema, options);
|
|
if (result.action === "accept" && result.content) {
|
|
try {
|
|
const ajv = new import_ajv.default;
|
|
const validate = ajv.compile(params.requestedSchema);
|
|
const isValid2 = validate(result.content);
|
|
if (!isValid2) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${ajv.errorsText(validate.errors)}`);
|
|
}
|
|
} catch (error) {
|
|
if (error instanceof McpError) {
|
|
throw error;
|
|
}
|
|
throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error}`);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
async listRoots(params, options) {
|
|
return this.request({ method: "roots/list", params }, ListRootsResultSchema, options);
|
|
}
|
|
async sendLoggingMessage(params, sessionId) {
|
|
if (this._capabilities.logging) {
|
|
if (!this.isMessageIgnored(params.level, sessionId)) {
|
|
return this.notification({ method: "notifications/message", params });
|
|
}
|
|
}
|
|
}
|
|
async sendResourceUpdated(params) {
|
|
return this.notification({
|
|
method: "notifications/resources/updated",
|
|
params
|
|
});
|
|
}
|
|
async sendResourceListChanged() {
|
|
return this.notification({
|
|
method: "notifications/resources/list_changed"
|
|
});
|
|
}
|
|
async sendToolListChanged() {
|
|
return this.notification({ method: "notifications/tools/list_changed" });
|
|
}
|
|
async sendPromptListChanged() {
|
|
return this.notification({ method: "notifications/prompts/list_changed" });
|
|
}
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/Options.js
|
|
var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
var defaultOptions = {
|
|
name: undefined,
|
|
$refStrategy: "root",
|
|
basePath: ["#"],
|
|
effectStrategy: "input",
|
|
pipeStrategy: "all",
|
|
dateStrategy: "format:date-time",
|
|
mapStrategy: "entries",
|
|
removeAdditionalStrategy: "passthrough",
|
|
allowedAdditionalProperties: true,
|
|
rejectedAdditionalProperties: false,
|
|
definitionPath: "definitions",
|
|
target: "jsonSchema7",
|
|
strictUnions: false,
|
|
definitions: {},
|
|
errorMessages: false,
|
|
markdownDescription: false,
|
|
patternStrategy: "escape",
|
|
applyRegexFlags: false,
|
|
emailStrategy: "format:email",
|
|
base64Strategy: "contentEncoding:base64",
|
|
nameStrategy: "ref",
|
|
openAiAnyTypeName: "OpenAiAnyType"
|
|
};
|
|
var getDefaultOptions = (options) => typeof options === "string" ? {
|
|
...defaultOptions,
|
|
name: options
|
|
} : {
|
|
...defaultOptions,
|
|
...options
|
|
};
|
|
// node_modules/zod-to-json-schema/dist/esm/Refs.js
|
|
var getRefs = (options) => {
|
|
const _options = getDefaultOptions(options);
|
|
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
return {
|
|
..._options,
|
|
flags: { hasReferencedOpenAiAnyType: false },
|
|
currentPath,
|
|
propertyPath: undefined,
|
|
seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [
|
|
def._def,
|
|
{
|
|
def: def._def,
|
|
path: [..._options.basePath, _options.definitionPath, name],
|
|
jsonSchema: undefined
|
|
}
|
|
]))
|
|
};
|
|
};
|
|
// node_modules/zod-to-json-schema/dist/esm/errorMessages.js
|
|
function addErrorMessage(res, key, errorMessage, refs) {
|
|
if (!refs?.errorMessages)
|
|
return;
|
|
if (errorMessage) {
|
|
res.errorMessage = {
|
|
...res.errorMessage,
|
|
[key]: errorMessage
|
|
};
|
|
}
|
|
}
|
|
function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
res[key] = value;
|
|
addErrorMessage(res, key, errorMessage, refs);
|
|
}
|
|
// node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
|
|
var getRelativePath = (pathA, pathB) => {
|
|
let i = 0;
|
|
for (;i < pathA.length && i < pathB.length; i++) {
|
|
if (pathA[i] !== pathB[i])
|
|
break;
|
|
}
|
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
};
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/any.js
|
|
function parseAnyDef(refs) {
|
|
if (refs.target !== "openAi") {
|
|
return {};
|
|
}
|
|
const anyDefinitionPath = [
|
|
...refs.basePath,
|
|
refs.definitionPath,
|
|
refs.openAiAnyTypeName
|
|
];
|
|
refs.flags.hasReferencedOpenAiAnyType = true;
|
|
return {
|
|
$ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/")
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/array.js
|
|
function parseArrayDef(def, refs) {
|
|
const res = {
|
|
type: "array"
|
|
};
|
|
if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) {
|
|
res.items = parseDef(def.type._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "items"]
|
|
});
|
|
}
|
|
if (def.minLength) {
|
|
setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
|
|
}
|
|
if (def.maxLength) {
|
|
setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
|
|
}
|
|
if (def.exactLength) {
|
|
setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
|
|
setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
|
|
function parseBigintDef(def, refs) {
|
|
const res = {
|
|
type: "integer",
|
|
format: "int64"
|
|
};
|
|
if (!def.checks)
|
|
return res;
|
|
for (const check of def.checks) {
|
|
switch (check.kind) {
|
|
case "min":
|
|
if (refs.target === "jsonSchema7") {
|
|
if (check.inclusive) {
|
|
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
} else {
|
|
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
}
|
|
} else {
|
|
if (!check.inclusive) {
|
|
res.exclusiveMinimum = true;
|
|
}
|
|
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
}
|
|
break;
|
|
case "max":
|
|
if (refs.target === "jsonSchema7") {
|
|
if (check.inclusive) {
|
|
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
} else {
|
|
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
}
|
|
} else {
|
|
if (!check.inclusive) {
|
|
res.exclusiveMaximum = true;
|
|
}
|
|
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
}
|
|
break;
|
|
case "multipleOf":
|
|
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
break;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
|
|
function parseBooleanDef() {
|
|
return {
|
|
type: "boolean"
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
|
|
function parseBrandedDef(_def, refs) {
|
|
return parseDef(_def.type._def, refs);
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
|
|
var parseCatchDef = (def, refs) => {
|
|
return parseDef(def.innerType._def, refs);
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/date.js
|
|
function parseDateDef(def, refs, overrideDateStrategy) {
|
|
const strategy = overrideDateStrategy ?? refs.dateStrategy;
|
|
if (Array.isArray(strategy)) {
|
|
return {
|
|
anyOf: strategy.map((item, i) => parseDateDef(def, refs, item))
|
|
};
|
|
}
|
|
switch (strategy) {
|
|
case "string":
|
|
case "format:date-time":
|
|
return {
|
|
type: "string",
|
|
format: "date-time"
|
|
};
|
|
case "format:date":
|
|
return {
|
|
type: "string",
|
|
format: "date"
|
|
};
|
|
case "integer":
|
|
return integerDateParser(def, refs);
|
|
}
|
|
}
|
|
var integerDateParser = (def, refs) => {
|
|
const res = {
|
|
type: "integer",
|
|
format: "unix-time"
|
|
};
|
|
if (refs.target === "openApi3") {
|
|
return res;
|
|
}
|
|
for (const check of def.checks) {
|
|
switch (check.kind) {
|
|
case "min":
|
|
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
break;
|
|
case "max":
|
|
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
break;
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/default.js
|
|
function parseDefaultDef(_def, refs) {
|
|
return {
|
|
...parseDef(_def.innerType._def, refs),
|
|
default: _def.defaultValue()
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
|
|
function parseEffectsDef(_def, refs) {
|
|
return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
|
|
function parseEnumDef(def) {
|
|
return {
|
|
type: "string",
|
|
enum: Array.from(def.values)
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
|
|
var isJsonSchema7AllOfType = (type) => {
|
|
if ("type" in type && type.type === "string")
|
|
return false;
|
|
return "allOf" in type;
|
|
};
|
|
function parseIntersectionDef(def, refs) {
|
|
const allOf = [
|
|
parseDef(def.left._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
}),
|
|
parseDef(def.right._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
})
|
|
].filter((x) => !!x);
|
|
let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : undefined;
|
|
const mergedAllOf = [];
|
|
allOf.forEach((schema) => {
|
|
if (isJsonSchema7AllOfType(schema)) {
|
|
mergedAllOf.push(...schema.allOf);
|
|
if (schema.unevaluatedProperties === undefined) {
|
|
unevaluatedProperties = undefined;
|
|
}
|
|
} else {
|
|
let nestedSchema = schema;
|
|
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
const { additionalProperties, ...rest } = schema;
|
|
nestedSchema = rest;
|
|
} else {
|
|
unevaluatedProperties = undefined;
|
|
}
|
|
mergedAllOf.push(nestedSchema);
|
|
}
|
|
});
|
|
return mergedAllOf.length ? {
|
|
allOf: mergedAllOf,
|
|
...unevaluatedProperties
|
|
} : undefined;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
|
|
function parseLiteralDef(def, refs) {
|
|
const parsedType = typeof def.value;
|
|
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
return {
|
|
type: Array.isArray(def.value) ? "array" : "object"
|
|
};
|
|
}
|
|
if (refs.target === "openApi3") {
|
|
return {
|
|
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
enum: [def.value]
|
|
};
|
|
}
|
|
return {
|
|
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
const: def.value
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/string.js
|
|
var emojiRegex2 = undefined;
|
|
var zodPatterns = {
|
|
cuid: /^[cC][^\s-]{8,}$/,
|
|
cuid2: /^[0-9a-z]+$/,
|
|
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
emoji: () => {
|
|
if (emojiRegex2 === undefined) {
|
|
emojiRegex2 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
}
|
|
return emojiRegex2;
|
|
},
|
|
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
};
|
|
function parseStringDef(def, refs) {
|
|
const res = {
|
|
type: "string"
|
|
};
|
|
if (def.checks) {
|
|
for (const check of def.checks) {
|
|
switch (check.kind) {
|
|
case "min":
|
|
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
break;
|
|
case "max":
|
|
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
break;
|
|
case "email":
|
|
switch (refs.emailStrategy) {
|
|
case "format:email":
|
|
addFormat(res, "email", check.message, refs);
|
|
break;
|
|
case "format:idn-email":
|
|
addFormat(res, "idn-email", check.message, refs);
|
|
break;
|
|
case "pattern:zod":
|
|
addPattern(res, zodPatterns.email, check.message, refs);
|
|
break;
|
|
}
|
|
break;
|
|
case "url":
|
|
addFormat(res, "uri", check.message, refs);
|
|
break;
|
|
case "uuid":
|
|
addFormat(res, "uuid", check.message, refs);
|
|
break;
|
|
case "regex":
|
|
addPattern(res, check.regex, check.message, refs);
|
|
break;
|
|
case "cuid":
|
|
addPattern(res, zodPatterns.cuid, check.message, refs);
|
|
break;
|
|
case "cuid2":
|
|
addPattern(res, zodPatterns.cuid2, check.message, refs);
|
|
break;
|
|
case "startsWith":
|
|
addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
|
|
break;
|
|
case "endsWith":
|
|
addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
|
|
break;
|
|
case "datetime":
|
|
addFormat(res, "date-time", check.message, refs);
|
|
break;
|
|
case "date":
|
|
addFormat(res, "date", check.message, refs);
|
|
break;
|
|
case "time":
|
|
addFormat(res, "time", check.message, refs);
|
|
break;
|
|
case "duration":
|
|
addFormat(res, "duration", check.message, refs);
|
|
break;
|
|
case "length":
|
|
setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
|
|
setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
|
|
break;
|
|
case "includes": {
|
|
addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
|
|
break;
|
|
}
|
|
case "ip": {
|
|
if (check.version !== "v6") {
|
|
addFormat(res, "ipv4", check.message, refs);
|
|
}
|
|
if (check.version !== "v4") {
|
|
addFormat(res, "ipv6", check.message, refs);
|
|
}
|
|
break;
|
|
}
|
|
case "base64url":
|
|
addPattern(res, zodPatterns.base64url, check.message, refs);
|
|
break;
|
|
case "jwt":
|
|
addPattern(res, zodPatterns.jwt, check.message, refs);
|
|
break;
|
|
case "cidr": {
|
|
if (check.version !== "v6") {
|
|
addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
|
|
}
|
|
if (check.version !== "v4") {
|
|
addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
|
|
}
|
|
break;
|
|
}
|
|
case "emoji":
|
|
addPattern(res, zodPatterns.emoji(), check.message, refs);
|
|
break;
|
|
case "ulid": {
|
|
addPattern(res, zodPatterns.ulid, check.message, refs);
|
|
break;
|
|
}
|
|
case "base64": {
|
|
switch (refs.base64Strategy) {
|
|
case "format:binary": {
|
|
addFormat(res, "binary", check.message, refs);
|
|
break;
|
|
}
|
|
case "contentEncoding:base64": {
|
|
setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
|
|
break;
|
|
}
|
|
case "pattern:zod": {
|
|
addPattern(res, zodPatterns.base64, check.message, refs);
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case "nanoid": {
|
|
addPattern(res, zodPatterns.nanoid, check.message, refs);
|
|
}
|
|
case "toLowerCase":
|
|
case "toUpperCase":
|
|
case "trim":
|
|
break;
|
|
default:
|
|
((_) => {})(check);
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function escapeLiteralCheckValue(literal, refs) {
|
|
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
|
|
}
|
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
function escapeNonAlphaNumeric(source) {
|
|
let result = "";
|
|
for (let i = 0;i < source.length; i++) {
|
|
if (!ALPHA_NUMERIC.has(source[i])) {
|
|
result += "\\";
|
|
}
|
|
result += source[i];
|
|
}
|
|
return result;
|
|
}
|
|
function addFormat(schema, value, message, refs) {
|
|
if (schema.format || schema.anyOf?.some((x) => x.format)) {
|
|
if (!schema.anyOf) {
|
|
schema.anyOf = [];
|
|
}
|
|
if (schema.format) {
|
|
schema.anyOf.push({
|
|
format: schema.format,
|
|
...schema.errorMessage && refs.errorMessages && {
|
|
errorMessage: { format: schema.errorMessage.format }
|
|
}
|
|
});
|
|
delete schema.format;
|
|
if (schema.errorMessage) {
|
|
delete schema.errorMessage.format;
|
|
if (Object.keys(schema.errorMessage).length === 0) {
|
|
delete schema.errorMessage;
|
|
}
|
|
}
|
|
}
|
|
schema.anyOf.push({
|
|
format: value,
|
|
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
});
|
|
} else {
|
|
setResponseValueAndErrors(schema, "format", value, message, refs);
|
|
}
|
|
}
|
|
function addPattern(schema, regex, message, refs) {
|
|
if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
|
|
if (!schema.allOf) {
|
|
schema.allOf = [];
|
|
}
|
|
if (schema.pattern) {
|
|
schema.allOf.push({
|
|
pattern: schema.pattern,
|
|
...schema.errorMessage && refs.errorMessages && {
|
|
errorMessage: { pattern: schema.errorMessage.pattern }
|
|
}
|
|
});
|
|
delete schema.pattern;
|
|
if (schema.errorMessage) {
|
|
delete schema.errorMessage.pattern;
|
|
if (Object.keys(schema.errorMessage).length === 0) {
|
|
delete schema.errorMessage;
|
|
}
|
|
}
|
|
}
|
|
schema.allOf.push({
|
|
pattern: stringifyRegExpWithFlags(regex, refs),
|
|
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
});
|
|
} else {
|
|
setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
|
|
}
|
|
}
|
|
function stringifyRegExpWithFlags(regex, refs) {
|
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
return regex.source;
|
|
}
|
|
const flags = {
|
|
i: regex.flags.includes("i"),
|
|
m: regex.flags.includes("m"),
|
|
s: regex.flags.includes("s")
|
|
};
|
|
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
let pattern = "";
|
|
let isEscaped = false;
|
|
let inCharGroup = false;
|
|
let inCharRange = false;
|
|
for (let i = 0;i < source.length; i++) {
|
|
if (isEscaped) {
|
|
pattern += source[i];
|
|
isEscaped = false;
|
|
continue;
|
|
}
|
|
if (flags.i) {
|
|
if (inCharGroup) {
|
|
if (source[i].match(/[a-z]/)) {
|
|
if (inCharRange) {
|
|
pattern += source[i];
|
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
inCharRange = false;
|
|
} else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
|
|
pattern += source[i];
|
|
inCharRange = true;
|
|
} else {
|
|
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
}
|
|
continue;
|
|
}
|
|
} else if (source[i].match(/[a-z]/)) {
|
|
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
continue;
|
|
}
|
|
}
|
|
if (flags.m) {
|
|
if (source[i] === "^") {
|
|
pattern += `(^|(?<=[\r
|
|
]))`;
|
|
continue;
|
|
} else if (source[i] === "$") {
|
|
pattern += `($|(?=[\r
|
|
]))`;
|
|
continue;
|
|
}
|
|
}
|
|
if (flags.s && source[i] === ".") {
|
|
pattern += inCharGroup ? `${source[i]}\r
|
|
` : `[${source[i]}\r
|
|
]`;
|
|
continue;
|
|
}
|
|
pattern += source[i];
|
|
if (source[i] === "\\") {
|
|
isEscaped = true;
|
|
} else if (inCharGroup && source[i] === "]") {
|
|
inCharGroup = false;
|
|
} else if (!inCharGroup && source[i] === "[") {
|
|
inCharGroup = true;
|
|
}
|
|
}
|
|
try {
|
|
new RegExp(pattern);
|
|
} catch {
|
|
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
return regex.source;
|
|
}
|
|
return pattern;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/record.js
|
|
function parseRecordDef(def, refs) {
|
|
if (refs.target === "openAi") {
|
|
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
}
|
|
if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
return {
|
|
type: "object",
|
|
required: def.keyType._def.values,
|
|
properties: def.keyType._def.values.reduce((acc, key) => ({
|
|
...acc,
|
|
[key]: parseDef(def.valueType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "properties", key]
|
|
}) ?? parseAnyDef(refs)
|
|
}), {}),
|
|
additionalProperties: refs.rejectedAdditionalProperties
|
|
};
|
|
}
|
|
const schema = {
|
|
type: "object",
|
|
additionalProperties: parseDef(def.valueType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
}) ?? refs.allowedAdditionalProperties
|
|
};
|
|
if (refs.target === "openApi3") {
|
|
return schema;
|
|
}
|
|
if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
return {
|
|
...schema,
|
|
propertyNames: keyType
|
|
};
|
|
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) {
|
|
return {
|
|
...schema,
|
|
propertyNames: {
|
|
enum: def.keyType._def.values
|
|
}
|
|
};
|
|
} else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
return {
|
|
...schema,
|
|
propertyNames: keyType
|
|
};
|
|
}
|
|
return schema;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/map.js
|
|
function parseMapDef(def, refs) {
|
|
if (refs.mapStrategy === "record") {
|
|
return parseRecordDef(def, refs);
|
|
}
|
|
const keys = parseDef(def.keyType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
}) || parseAnyDef(refs);
|
|
const values = parseDef(def.valueType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
}) || parseAnyDef(refs);
|
|
return {
|
|
type: "array",
|
|
maxItems: 125,
|
|
items: {
|
|
type: "array",
|
|
items: [keys, values],
|
|
minItems: 2,
|
|
maxItems: 2
|
|
}
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
function parseNativeEnumDef(def) {
|
|
const object = def.values;
|
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
return typeof object[object[key]] !== "number";
|
|
});
|
|
const actualValues = actualKeys.map((key) => object[key]);
|
|
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
return {
|
|
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
enum: actualValues
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/never.js
|
|
function parseNeverDef(refs) {
|
|
return refs.target === "openAi" ? undefined : {
|
|
not: parseAnyDef({
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "not"]
|
|
})
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/null.js
|
|
function parseNullDef(refs) {
|
|
return refs.target === "openApi3" ? {
|
|
enum: ["null"],
|
|
nullable: true
|
|
} : {
|
|
type: "null"
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/union.js
|
|
var primitiveMappings = {
|
|
ZodString: "string",
|
|
ZodNumber: "number",
|
|
ZodBigInt: "integer",
|
|
ZodBoolean: "boolean",
|
|
ZodNull: "null"
|
|
};
|
|
function parseUnionDef(def, refs) {
|
|
if (refs.target === "openApi3")
|
|
return asAnyOf(def, refs);
|
|
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
if (options.every((x) => (x._def.typeName in primitiveMappings) && (!x._def.checks || !x._def.checks.length))) {
|
|
const types2 = options.reduce((types3, x) => {
|
|
const type = primitiveMappings[x._def.typeName];
|
|
return type && !types3.includes(type) ? [...types3, type] : types3;
|
|
}, []);
|
|
return {
|
|
type: types2.length > 1 ? types2 : types2[0]
|
|
};
|
|
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
const types2 = options.reduce((acc, x) => {
|
|
const type = typeof x._def.value;
|
|
switch (type) {
|
|
case "string":
|
|
case "number":
|
|
case "boolean":
|
|
return [...acc, type];
|
|
case "bigint":
|
|
return [...acc, "integer"];
|
|
case "object":
|
|
if (x._def.value === null)
|
|
return [...acc, "null"];
|
|
case "symbol":
|
|
case "undefined":
|
|
case "function":
|
|
default:
|
|
return acc;
|
|
}
|
|
}, []);
|
|
if (types2.length === options.length) {
|
|
const uniqueTypes = types2.filter((x, i, a) => a.indexOf(x) === i);
|
|
return {
|
|
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
enum: options.reduce((acc, x) => {
|
|
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
}, [])
|
|
};
|
|
}
|
|
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
return {
|
|
type: "string",
|
|
enum: options.reduce((acc, x) => [
|
|
...acc,
|
|
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
], [])
|
|
};
|
|
}
|
|
return asAnyOf(def, refs);
|
|
}
|
|
var asAnyOf = (def, refs) => {
|
|
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
return anyOf.length ? { anyOf } : undefined;
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
|
|
function parseNullableDef(def, refs) {
|
|
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
if (refs.target === "openApi3") {
|
|
return {
|
|
type: primitiveMappings[def.innerType._def.typeName],
|
|
nullable: true
|
|
};
|
|
}
|
|
return {
|
|
type: [
|
|
primitiveMappings[def.innerType._def.typeName],
|
|
"null"
|
|
]
|
|
};
|
|
}
|
|
if (refs.target === "openApi3") {
|
|
const base2 = parseDef(def.innerType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath]
|
|
});
|
|
if (base2 && "$ref" in base2)
|
|
return { allOf: [base2], nullable: true };
|
|
return base2 && { ...base2, nullable: true };
|
|
}
|
|
const base = parseDef(def.innerType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
});
|
|
return base && { anyOf: [base, { type: "null" }] };
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/number.js
|
|
function parseNumberDef(def, refs) {
|
|
const res = {
|
|
type: "number"
|
|
};
|
|
if (!def.checks)
|
|
return res;
|
|
for (const check of def.checks) {
|
|
switch (check.kind) {
|
|
case "int":
|
|
res.type = "integer";
|
|
addErrorMessage(res, "type", check.message, refs);
|
|
break;
|
|
case "min":
|
|
if (refs.target === "jsonSchema7") {
|
|
if (check.inclusive) {
|
|
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
} else {
|
|
setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
|
|
}
|
|
} else {
|
|
if (!check.inclusive) {
|
|
res.exclusiveMinimum = true;
|
|
}
|
|
setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
|
|
}
|
|
break;
|
|
case "max":
|
|
if (refs.target === "jsonSchema7") {
|
|
if (check.inclusive) {
|
|
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
} else {
|
|
setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
|
|
}
|
|
} else {
|
|
if (!check.inclusive) {
|
|
res.exclusiveMaximum = true;
|
|
}
|
|
setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
|
|
}
|
|
break;
|
|
case "multipleOf":
|
|
setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
|
|
break;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/object.js
|
|
function parseObjectDef(def, refs) {
|
|
const forceOptionalIntoNullable = refs.target === "openAi";
|
|
const result = {
|
|
type: "object",
|
|
properties: {}
|
|
};
|
|
const required = [];
|
|
const shape = def.shape();
|
|
for (const propName in shape) {
|
|
let propDef = shape[propName];
|
|
if (propDef === undefined || propDef._def === undefined) {
|
|
continue;
|
|
}
|
|
let propOptional = safeIsOptional(propDef);
|
|
if (propOptional && forceOptionalIntoNullable) {
|
|
if (propDef._def.typeName === "ZodOptional") {
|
|
propDef = propDef._def.innerType;
|
|
}
|
|
if (!propDef.isNullable()) {
|
|
propDef = propDef.nullable();
|
|
}
|
|
propOptional = false;
|
|
}
|
|
const parsedDef = parseDef(propDef._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "properties", propName],
|
|
propertyPath: [...refs.currentPath, "properties", propName]
|
|
});
|
|
if (parsedDef === undefined) {
|
|
continue;
|
|
}
|
|
result.properties[propName] = parsedDef;
|
|
if (!propOptional) {
|
|
required.push(propName);
|
|
}
|
|
}
|
|
if (required.length) {
|
|
result.required = required;
|
|
}
|
|
const additionalProperties = decideAdditionalProperties(def, refs);
|
|
if (additionalProperties !== undefined) {
|
|
result.additionalProperties = additionalProperties;
|
|
}
|
|
return result;
|
|
}
|
|
function decideAdditionalProperties(def, refs) {
|
|
if (def.catchall._def.typeName !== "ZodNever") {
|
|
return parseDef(def.catchall._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
});
|
|
}
|
|
switch (def.unknownKeys) {
|
|
case "passthrough":
|
|
return refs.allowedAdditionalProperties;
|
|
case "strict":
|
|
return refs.rejectedAdditionalProperties;
|
|
case "strip":
|
|
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
}
|
|
}
|
|
function safeIsOptional(schema) {
|
|
try {
|
|
return schema.isOptional();
|
|
} catch {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
|
|
var parseOptionalDef = (def, refs) => {
|
|
if (refs.currentPath.toString() === refs.propertyPath?.toString()) {
|
|
return parseDef(def.innerType._def, refs);
|
|
}
|
|
const innerSchema = parseDef(def.innerType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
});
|
|
return innerSchema ? {
|
|
anyOf: [
|
|
{
|
|
not: parseAnyDef(refs)
|
|
},
|
|
innerSchema
|
|
]
|
|
} : parseAnyDef(refs);
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
|
|
var parsePipelineDef = (def, refs) => {
|
|
if (refs.pipeStrategy === "input") {
|
|
return parseDef(def.in._def, refs);
|
|
} else if (refs.pipeStrategy === "output") {
|
|
return parseDef(def.out._def, refs);
|
|
}
|
|
const a = parseDef(def.in._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
});
|
|
const b = parseDef(def.out._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
});
|
|
return {
|
|
allOf: [a, b].filter((x) => x !== undefined)
|
|
};
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
|
|
function parsePromiseDef(def, refs) {
|
|
return parseDef(def.type._def, refs);
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/set.js
|
|
function parseSetDef(def, refs) {
|
|
const items = parseDef(def.valueType._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "items"]
|
|
});
|
|
const schema = {
|
|
type: "array",
|
|
uniqueItems: true,
|
|
items
|
|
};
|
|
if (def.minSize) {
|
|
setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
|
|
}
|
|
if (def.maxSize) {
|
|
setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
|
|
}
|
|
return schema;
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
|
|
function parseTupleDef(def, refs) {
|
|
if (def.rest) {
|
|
return {
|
|
type: "array",
|
|
minItems: def.items.length,
|
|
items: def.items.map((x, i) => parseDef(x._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
additionalItems: parseDef(def.rest._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "additionalItems"]
|
|
})
|
|
};
|
|
} else {
|
|
return {
|
|
type: "array",
|
|
minItems: def.items.length,
|
|
maxItems: def.items.length,
|
|
items: def.items.map((x, i) => parseDef(x._def, {
|
|
...refs,
|
|
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
};
|
|
}
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
|
|
function parseUndefinedDef(refs) {
|
|
return {
|
|
not: parseAnyDef(refs)
|
|
};
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
|
|
function parseUnknownDef(refs) {
|
|
return parseAnyDef(refs);
|
|
}
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
|
|
var parseReadonlyDef = (def, refs) => {
|
|
return parseDef(def.innerType._def, refs);
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/selectParser.js
|
|
var selectParser = (def, typeName, refs) => {
|
|
switch (typeName) {
|
|
case ZodFirstPartyTypeKind.ZodString:
|
|
return parseStringDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodNumber:
|
|
return parseNumberDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodObject:
|
|
return parseObjectDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
return parseBigintDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
return parseBooleanDef();
|
|
case ZodFirstPartyTypeKind.ZodDate:
|
|
return parseDateDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodUndefined:
|
|
return parseUndefinedDef(refs);
|
|
case ZodFirstPartyTypeKind.ZodNull:
|
|
return parseNullDef(refs);
|
|
case ZodFirstPartyTypeKind.ZodArray:
|
|
return parseArrayDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodUnion:
|
|
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
return parseUnionDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodIntersection:
|
|
return parseIntersectionDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodTuple:
|
|
return parseTupleDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodRecord:
|
|
return parseRecordDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
return parseLiteralDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodEnum:
|
|
return parseEnumDef(def);
|
|
case ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
return parseNativeEnumDef(def);
|
|
case ZodFirstPartyTypeKind.ZodNullable:
|
|
return parseNullableDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodOptional:
|
|
return parseOptionalDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodMap:
|
|
return parseMapDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodSet:
|
|
return parseSetDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodLazy:
|
|
return () => def.getter()._def;
|
|
case ZodFirstPartyTypeKind.ZodPromise:
|
|
return parsePromiseDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodNaN:
|
|
case ZodFirstPartyTypeKind.ZodNever:
|
|
return parseNeverDef(refs);
|
|
case ZodFirstPartyTypeKind.ZodEffects:
|
|
return parseEffectsDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodAny:
|
|
return parseAnyDef(refs);
|
|
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
return parseUnknownDef(refs);
|
|
case ZodFirstPartyTypeKind.ZodDefault:
|
|
return parseDefaultDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodBranded:
|
|
return parseBrandedDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodReadonly:
|
|
return parseReadonlyDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodCatch:
|
|
return parseCatchDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodPipeline:
|
|
return parsePipelineDef(def, refs);
|
|
case ZodFirstPartyTypeKind.ZodFunction:
|
|
case ZodFirstPartyTypeKind.ZodVoid:
|
|
case ZodFirstPartyTypeKind.ZodSymbol:
|
|
return;
|
|
default:
|
|
return ((_) => {
|
|
return;
|
|
})(typeName);
|
|
}
|
|
};
|
|
|
|
// node_modules/zod-to-json-schema/dist/esm/parseDef.js
|
|
function parseDef(def, refs, forceResolution = false) {
|
|
const seenItem = refs.seen.get(def);
|
|
if (refs.override) {
|
|
const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
|
|
if (overrideResult !== ignoreOverride) {
|
|
return overrideResult;
|
|
}
|
|
}
|
|
if (seenItem && !forceResolution) {
|
|
const seenSchema = get$ref(seenItem, refs);
|
|
if (seenSchema !== undefined) {
|
|
return seenSchema;
|
|
}
|
|
}
|
|
const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
|
|
refs.seen.set(def, newItem);
|
|
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
if (jsonSchema) {
|
|
addMeta(def, refs, jsonSchema);
|
|
}
|
|
if (refs.postProcess) {
|
|
const postProcessResult = refs.postProcess(jsonSchema, def, refs);
|
|
newItem.jsonSchema = jsonSchema;
|
|
return postProcessResult;
|
|
}
|
|
newItem.jsonSchema = jsonSchema;
|
|
return jsonSchema;
|
|
}
|
|
var get$ref = (item, refs) => {
|
|
switch (refs.$refStrategy) {
|
|
case "root":
|
|
return { $ref: item.path.join("/") };
|
|
case "relative":
|
|
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
|
case "none":
|
|
case "seen": {
|
|
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
return parseAnyDef(refs);
|
|
}
|
|
return refs.$refStrategy === "seen" ? parseAnyDef(refs) : undefined;
|
|
}
|
|
}
|
|
};
|
|
var addMeta = (def, refs, jsonSchema) => {
|
|
if (def.description) {
|
|
jsonSchema.description = def.description;
|
|
if (refs.markdownDescription) {
|
|
jsonSchema.markdownDescription = def.description;
|
|
}
|
|
}
|
|
return jsonSchema;
|
|
};
|
|
// node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
var zodToJsonSchema = (schema, options) => {
|
|
const refs = getRefs(options);
|
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name2, schema2]) => ({
|
|
...acc,
|
|
[name2]: parseDef(schema2._def, {
|
|
...refs,
|
|
currentPath: [...refs.basePath, refs.definitionPath, name2]
|
|
}, true) ?? parseAnyDef(refs)
|
|
}), {}) : undefined;
|
|
const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? undefined : options?.name;
|
|
const main = parseDef(schema._def, name === undefined ? refs : {
|
|
...refs,
|
|
currentPath: [...refs.basePath, refs.definitionPath, name]
|
|
}, false) ?? parseAnyDef(refs);
|
|
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
if (title !== undefined) {
|
|
main.title = title;
|
|
}
|
|
if (refs.flags.hasReferencedOpenAiAnyType) {
|
|
if (!definitions) {
|
|
definitions = {};
|
|
}
|
|
if (!definitions[refs.openAiAnyTypeName]) {
|
|
definitions[refs.openAiAnyTypeName] = {
|
|
type: ["string", "number", "integer", "boolean", "array", "null"],
|
|
items: {
|
|
$ref: refs.$refStrategy === "relative" ? "1" : [
|
|
...refs.basePath,
|
|
refs.definitionPath,
|
|
refs.openAiAnyTypeName
|
|
].join("/")
|
|
}
|
|
};
|
|
}
|
|
}
|
|
const combined = name === undefined ? definitions ? {
|
|
...main,
|
|
[refs.definitionPath]: definitions
|
|
} : main : {
|
|
$ref: [
|
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
refs.definitionPath,
|
|
name
|
|
].join("/"),
|
|
[refs.definitionPath]: {
|
|
...definitions,
|
|
[name]: main
|
|
}
|
|
};
|
|
if (refs.target === "jsonSchema7") {
|
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
} else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") {
|
|
combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
|
|
}
|
|
if (refs.target === "openAi" && (("anyOf" in combined) || ("oneOf" in combined) || ("allOf" in combined) || ("type" in combined) && Array.isArray(combined.type))) {
|
|
console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
|
|
}
|
|
return combined;
|
|
};
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
var McpZodTypeKind;
|
|
(function(McpZodTypeKind2) {
|
|
McpZodTypeKind2["Completable"] = "McpCompletable";
|
|
})(McpZodTypeKind || (McpZodTypeKind = {}));
|
|
|
|
class Completable extends ZodType {
|
|
_parse(input) {
|
|
const { ctx } = this._processInputParams(input);
|
|
const data = ctx.data;
|
|
return this._def.type._parse({
|
|
data,
|
|
path: ctx.path,
|
|
parent: ctx
|
|
});
|
|
}
|
|
unwrap() {
|
|
return this._def.type;
|
|
}
|
|
}
|
|
Completable.create = (type, params) => {
|
|
return new Completable({
|
|
type,
|
|
typeName: McpZodTypeKind.Completable,
|
|
complete: params.complete,
|
|
...processCreateParams2(params)
|
|
});
|
|
};
|
|
function processCreateParams2(params) {
|
|
if (!params)
|
|
return {};
|
|
const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
|
|
if (errorMap2 && (invalid_type_error || required_error)) {
|
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
}
|
|
if (errorMap2)
|
|
return { errorMap: errorMap2, description };
|
|
const customMap = (iss, ctx) => {
|
|
var _a, _b;
|
|
const { message } = params;
|
|
if (iss.code === "invalid_enum_value") {
|
|
return { message: message !== null && message !== undefined ? message : ctx.defaultError };
|
|
}
|
|
if (typeof ctx.data === "undefined") {
|
|
return { message: (_a = message !== null && message !== undefined ? message : required_error) !== null && _a !== undefined ? _a : ctx.defaultError };
|
|
}
|
|
if (iss.code !== "invalid_type")
|
|
return { message: ctx.defaultError };
|
|
return { message: (_b = message !== null && message !== undefined ? message : invalid_type_error) !== null && _b !== undefined ? _b : ctx.defaultError };
|
|
};
|
|
return { errorMap: customMap, description };
|
|
}
|
|
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
|
|
class McpServer {
|
|
constructor(serverInfo, options) {
|
|
this._registeredResources = {};
|
|
this._registeredResourceTemplates = {};
|
|
this._registeredTools = {};
|
|
this._registeredPrompts = {};
|
|
this._toolHandlersInitialized = false;
|
|
this._completionHandlerInitialized = false;
|
|
this._resourceHandlersInitialized = false;
|
|
this._promptHandlersInitialized = false;
|
|
this.server = new Server(serverInfo, options);
|
|
}
|
|
async connect(transport) {
|
|
return await this.server.connect(transport);
|
|
}
|
|
async close() {
|
|
await this.server.close();
|
|
}
|
|
setToolRequestHandlers() {
|
|
if (this._toolHandlersInitialized) {
|
|
return;
|
|
}
|
|
this.server.assertCanSetRequestHandler(ListToolsRequestSchema.shape.method.value);
|
|
this.server.assertCanSetRequestHandler(CallToolRequestSchema.shape.method.value);
|
|
this.server.registerCapabilities({
|
|
tools: {
|
|
listChanged: true
|
|
}
|
|
});
|
|
this.server.setRequestHandler(ListToolsRequestSchema, () => ({
|
|
tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
|
|
const toolDefinition = {
|
|
name,
|
|
title: tool.title,
|
|
description: tool.description,
|
|
inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
|
|
strictUnions: true
|
|
}) : EMPTY_OBJECT_JSON_SCHEMA,
|
|
annotations: tool.annotations,
|
|
_meta: tool._meta
|
|
};
|
|
if (tool.outputSchema) {
|
|
toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, {
|
|
strictUnions: true
|
|
});
|
|
}
|
|
return toolDefinition;
|
|
})
|
|
}));
|
|
this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
const tool = this._registeredTools[request.params.name];
|
|
if (!tool) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
|
|
}
|
|
if (!tool.enabled) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
|
|
}
|
|
let result;
|
|
if (tool.inputSchema) {
|
|
const parseResult = await tool.inputSchema.safeParseAsync(request.params.arguments);
|
|
if (!parseResult.success) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${request.params.name}: ${parseResult.error.message}`);
|
|
}
|
|
const args = parseResult.data;
|
|
const cb = tool.callback;
|
|
try {
|
|
result = await Promise.resolve(cb(args, extra));
|
|
} catch (error) {
|
|
result = {
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: error instanceof Error ? error.message : String(error)
|
|
}
|
|
],
|
|
isError: true
|
|
};
|
|
}
|
|
} else {
|
|
const cb = tool.callback;
|
|
try {
|
|
result = await Promise.resolve(cb(extra));
|
|
} catch (error) {
|
|
result = {
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: error instanceof Error ? error.message : String(error)
|
|
}
|
|
],
|
|
isError: true
|
|
};
|
|
}
|
|
}
|
|
if (tool.outputSchema && !result.isError) {
|
|
if (!result.structuredContent) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} has an output schema but no structured content was provided`);
|
|
}
|
|
const parseResult = await tool.outputSchema.safeParseAsync(result.structuredContent);
|
|
if (!parseResult.success) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Invalid structured content for tool ${request.params.name}: ${parseResult.error.message}`);
|
|
}
|
|
}
|
|
return result;
|
|
});
|
|
this._toolHandlersInitialized = true;
|
|
}
|
|
setCompletionRequestHandler() {
|
|
if (this._completionHandlerInitialized) {
|
|
return;
|
|
}
|
|
this.server.assertCanSetRequestHandler(CompleteRequestSchema.shape.method.value);
|
|
this.server.registerCapabilities({
|
|
completions: {}
|
|
});
|
|
this.server.setRequestHandler(CompleteRequestSchema, async (request) => {
|
|
switch (request.params.ref.type) {
|
|
case "ref/prompt":
|
|
return this.handlePromptCompletion(request, request.params.ref);
|
|
case "ref/resource":
|
|
return this.handleResourceCompletion(request, request.params.ref);
|
|
default:
|
|
throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${request.params.ref}`);
|
|
}
|
|
});
|
|
this._completionHandlerInitialized = true;
|
|
}
|
|
async handlePromptCompletion(request, ref) {
|
|
const prompt = this._registeredPrompts[ref.name];
|
|
if (!prompt) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
|
|
}
|
|
if (!prompt.enabled) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
|
|
}
|
|
if (!prompt.argsSchema) {
|
|
return EMPTY_COMPLETION_RESULT;
|
|
}
|
|
const field = prompt.argsSchema.shape[request.params.argument.name];
|
|
if (!(field instanceof Completable)) {
|
|
return EMPTY_COMPLETION_RESULT;
|
|
}
|
|
const def = field._def;
|
|
const suggestions = await def.complete(request.params.argument.value, request.params.context);
|
|
return createCompletionResult(suggestions);
|
|
}
|
|
async handleResourceCompletion(request, ref) {
|
|
const template = Object.values(this._registeredResourceTemplates).find((t) => t.resourceTemplate.uriTemplate.toString() === ref.uri);
|
|
if (!template) {
|
|
if (this._registeredResources[ref.uri]) {
|
|
return EMPTY_COMPLETION_RESULT;
|
|
}
|
|
throw new McpError(ErrorCode.InvalidParams, `Resource template ${request.params.ref.uri} not found`);
|
|
}
|
|
const completer = template.resourceTemplate.completeCallback(request.params.argument.name);
|
|
if (!completer) {
|
|
return EMPTY_COMPLETION_RESULT;
|
|
}
|
|
const suggestions = await completer(request.params.argument.value, request.params.context);
|
|
return createCompletionResult(suggestions);
|
|
}
|
|
setResourceRequestHandlers() {
|
|
if (this._resourceHandlersInitialized) {
|
|
return;
|
|
}
|
|
this.server.assertCanSetRequestHandler(ListResourcesRequestSchema.shape.method.value);
|
|
this.server.assertCanSetRequestHandler(ListResourceTemplatesRequestSchema.shape.method.value);
|
|
this.server.assertCanSetRequestHandler(ReadResourceRequestSchema.shape.method.value);
|
|
this.server.registerCapabilities({
|
|
resources: {
|
|
listChanged: true
|
|
}
|
|
});
|
|
this.server.setRequestHandler(ListResourcesRequestSchema, async (request, extra) => {
|
|
const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
|
|
uri,
|
|
name: resource.name,
|
|
...resource.metadata
|
|
}));
|
|
const templateResources = [];
|
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
if (!template.resourceTemplate.listCallback) {
|
|
continue;
|
|
}
|
|
const result = await template.resourceTemplate.listCallback(extra);
|
|
for (const resource of result.resources) {
|
|
templateResources.push({
|
|
...template.metadata,
|
|
...resource
|
|
});
|
|
}
|
|
}
|
|
return { resources: [...resources, ...templateResources] };
|
|
});
|
|
this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
|
|
const resourceTemplates = Object.entries(this._registeredResourceTemplates).map(([name, template]) => ({
|
|
name,
|
|
uriTemplate: template.resourceTemplate.uriTemplate.toString(),
|
|
...template.metadata
|
|
}));
|
|
return { resourceTemplates };
|
|
});
|
|
this.server.setRequestHandler(ReadResourceRequestSchema, async (request, extra) => {
|
|
const uri = new URL(request.params.uri);
|
|
const resource = this._registeredResources[uri.toString()];
|
|
if (resource) {
|
|
if (!resource.enabled) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} disabled`);
|
|
}
|
|
return resource.readCallback(uri, extra);
|
|
}
|
|
for (const template of Object.values(this._registeredResourceTemplates)) {
|
|
const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
|
|
if (variables) {
|
|
return template.readCallback(uri, variables, extra);
|
|
}
|
|
}
|
|
throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} not found`);
|
|
});
|
|
this.setCompletionRequestHandler();
|
|
this._resourceHandlersInitialized = true;
|
|
}
|
|
setPromptRequestHandlers() {
|
|
if (this._promptHandlersInitialized) {
|
|
return;
|
|
}
|
|
this.server.assertCanSetRequestHandler(ListPromptsRequestSchema.shape.method.value);
|
|
this.server.assertCanSetRequestHandler(GetPromptRequestSchema.shape.method.value);
|
|
this.server.registerCapabilities({
|
|
prompts: {
|
|
listChanged: true
|
|
}
|
|
});
|
|
this.server.setRequestHandler(ListPromptsRequestSchema, () => ({
|
|
prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
|
|
return {
|
|
name,
|
|
title: prompt.title,
|
|
description: prompt.description,
|
|
arguments: prompt.argsSchema ? promptArgumentsFromSchema(prompt.argsSchema) : undefined
|
|
};
|
|
})
|
|
}));
|
|
this.server.setRequestHandler(GetPromptRequestSchema, async (request, extra) => {
|
|
const prompt = this._registeredPrompts[request.params.name];
|
|
if (!prompt) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
|
|
}
|
|
if (!prompt.enabled) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
|
|
}
|
|
if (prompt.argsSchema) {
|
|
const parseResult = await prompt.argsSchema.safeParseAsync(request.params.arguments);
|
|
if (!parseResult.success) {
|
|
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${parseResult.error.message}`);
|
|
}
|
|
const args = parseResult.data;
|
|
const cb = prompt.callback;
|
|
return await Promise.resolve(cb(args, extra));
|
|
} else {
|
|
const cb = prompt.callback;
|
|
return await Promise.resolve(cb(extra));
|
|
}
|
|
});
|
|
this.setCompletionRequestHandler();
|
|
this._promptHandlersInitialized = true;
|
|
}
|
|
resource(name, uriOrTemplate, ...rest) {
|
|
let metadata;
|
|
if (typeof rest[0] === "object") {
|
|
metadata = rest.shift();
|
|
}
|
|
const readCallback = rest[0];
|
|
if (typeof uriOrTemplate === "string") {
|
|
if (this._registeredResources[uriOrTemplate]) {
|
|
throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
}
|
|
const registeredResource = this._createRegisteredResource(name, undefined, uriOrTemplate, metadata, readCallback);
|
|
this.setResourceRequestHandlers();
|
|
this.sendResourceListChanged();
|
|
return registeredResource;
|
|
} else {
|
|
if (this._registeredResourceTemplates[name]) {
|
|
throw new Error(`Resource template ${name} is already registered`);
|
|
}
|
|
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, undefined, uriOrTemplate, metadata, readCallback);
|
|
this.setResourceRequestHandlers();
|
|
this.sendResourceListChanged();
|
|
return registeredResourceTemplate;
|
|
}
|
|
}
|
|
registerResource(name, uriOrTemplate, config, readCallback) {
|
|
if (typeof uriOrTemplate === "string") {
|
|
if (this._registeredResources[uriOrTemplate]) {
|
|
throw new Error(`Resource ${uriOrTemplate} is already registered`);
|
|
}
|
|
const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, config, readCallback);
|
|
this.setResourceRequestHandlers();
|
|
this.sendResourceListChanged();
|
|
return registeredResource;
|
|
} else {
|
|
if (this._registeredResourceTemplates[name]) {
|
|
throw new Error(`Resource template ${name} is already registered`);
|
|
}
|
|
const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, config, readCallback);
|
|
this.setResourceRequestHandlers();
|
|
this.sendResourceListChanged();
|
|
return registeredResourceTemplate;
|
|
}
|
|
}
|
|
_createRegisteredResource(name, title, uri, metadata, readCallback) {
|
|
const registeredResource = {
|
|
name,
|
|
title,
|
|
metadata,
|
|
readCallback,
|
|
enabled: true,
|
|
disable: () => registeredResource.update({ enabled: false }),
|
|
enable: () => registeredResource.update({ enabled: true }),
|
|
remove: () => registeredResource.update({ uri: null }),
|
|
update: (updates) => {
|
|
if (typeof updates.uri !== "undefined" && updates.uri !== uri) {
|
|
delete this._registeredResources[uri];
|
|
if (updates.uri)
|
|
this._registeredResources[updates.uri] = registeredResource;
|
|
}
|
|
if (typeof updates.name !== "undefined")
|
|
registeredResource.name = updates.name;
|
|
if (typeof updates.title !== "undefined")
|
|
registeredResource.title = updates.title;
|
|
if (typeof updates.metadata !== "undefined")
|
|
registeredResource.metadata = updates.metadata;
|
|
if (typeof updates.callback !== "undefined")
|
|
registeredResource.readCallback = updates.callback;
|
|
if (typeof updates.enabled !== "undefined")
|
|
registeredResource.enabled = updates.enabled;
|
|
this.sendResourceListChanged();
|
|
}
|
|
};
|
|
this._registeredResources[uri] = registeredResource;
|
|
return registeredResource;
|
|
}
|
|
_createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
|
|
const registeredResourceTemplate = {
|
|
resourceTemplate: template,
|
|
title,
|
|
metadata,
|
|
readCallback,
|
|
enabled: true,
|
|
disable: () => registeredResourceTemplate.update({ enabled: false }),
|
|
enable: () => registeredResourceTemplate.update({ enabled: true }),
|
|
remove: () => registeredResourceTemplate.update({ name: null }),
|
|
update: (updates) => {
|
|
if (typeof updates.name !== "undefined" && updates.name !== name) {
|
|
delete this._registeredResourceTemplates[name];
|
|
if (updates.name)
|
|
this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
|
|
}
|
|
if (typeof updates.title !== "undefined")
|
|
registeredResourceTemplate.title = updates.title;
|
|
if (typeof updates.template !== "undefined")
|
|
registeredResourceTemplate.resourceTemplate = updates.template;
|
|
if (typeof updates.metadata !== "undefined")
|
|
registeredResourceTemplate.metadata = updates.metadata;
|
|
if (typeof updates.callback !== "undefined")
|
|
registeredResourceTemplate.readCallback = updates.callback;
|
|
if (typeof updates.enabled !== "undefined")
|
|
registeredResourceTemplate.enabled = updates.enabled;
|
|
this.sendResourceListChanged();
|
|
}
|
|
};
|
|
this._registeredResourceTemplates[name] = registeredResourceTemplate;
|
|
return registeredResourceTemplate;
|
|
}
|
|
_createRegisteredPrompt(name, title, description, argsSchema, callback) {
|
|
const registeredPrompt = {
|
|
title,
|
|
description,
|
|
argsSchema: argsSchema === undefined ? undefined : exports_external.object(argsSchema),
|
|
callback,
|
|
enabled: true,
|
|
disable: () => registeredPrompt.update({ enabled: false }),
|
|
enable: () => registeredPrompt.update({ enabled: true }),
|
|
remove: () => registeredPrompt.update({ name: null }),
|
|
update: (updates) => {
|
|
if (typeof updates.name !== "undefined" && updates.name !== name) {
|
|
delete this._registeredPrompts[name];
|
|
if (updates.name)
|
|
this._registeredPrompts[updates.name] = registeredPrompt;
|
|
}
|
|
if (typeof updates.title !== "undefined")
|
|
registeredPrompt.title = updates.title;
|
|
if (typeof updates.description !== "undefined")
|
|
registeredPrompt.description = updates.description;
|
|
if (typeof updates.argsSchema !== "undefined")
|
|
registeredPrompt.argsSchema = exports_external.object(updates.argsSchema);
|
|
if (typeof updates.callback !== "undefined")
|
|
registeredPrompt.callback = updates.callback;
|
|
if (typeof updates.enabled !== "undefined")
|
|
registeredPrompt.enabled = updates.enabled;
|
|
this.sendPromptListChanged();
|
|
}
|
|
};
|
|
this._registeredPrompts[name] = registeredPrompt;
|
|
return registeredPrompt;
|
|
}
|
|
_createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, callback) {
|
|
const registeredTool = {
|
|
title,
|
|
description,
|
|
inputSchema: inputSchema === undefined ? undefined : exports_external.object(inputSchema),
|
|
outputSchema: outputSchema === undefined ? undefined : exports_external.object(outputSchema),
|
|
annotations,
|
|
_meta,
|
|
callback,
|
|
enabled: true,
|
|
disable: () => registeredTool.update({ enabled: false }),
|
|
enable: () => registeredTool.update({ enabled: true }),
|
|
remove: () => registeredTool.update({ name: null }),
|
|
update: (updates) => {
|
|
if (typeof updates.name !== "undefined" && updates.name !== name) {
|
|
delete this._registeredTools[name];
|
|
if (updates.name)
|
|
this._registeredTools[updates.name] = registeredTool;
|
|
}
|
|
if (typeof updates.title !== "undefined")
|
|
registeredTool.title = updates.title;
|
|
if (typeof updates.description !== "undefined")
|
|
registeredTool.description = updates.description;
|
|
if (typeof updates.paramsSchema !== "undefined")
|
|
registeredTool.inputSchema = exports_external.object(updates.paramsSchema);
|
|
if (typeof updates.callback !== "undefined")
|
|
registeredTool.callback = updates.callback;
|
|
if (typeof updates.annotations !== "undefined")
|
|
registeredTool.annotations = updates.annotations;
|
|
if (typeof updates._meta !== "undefined")
|
|
registeredTool._meta = updates._meta;
|
|
if (typeof updates.enabled !== "undefined")
|
|
registeredTool.enabled = updates.enabled;
|
|
this.sendToolListChanged();
|
|
}
|
|
};
|
|
this._registeredTools[name] = registeredTool;
|
|
this.setToolRequestHandlers();
|
|
this.sendToolListChanged();
|
|
return registeredTool;
|
|
}
|
|
tool(name, ...rest) {
|
|
if (this._registeredTools[name]) {
|
|
throw new Error(`Tool ${name} is already registered`);
|
|
}
|
|
let description;
|
|
let inputSchema;
|
|
let outputSchema;
|
|
let annotations;
|
|
if (typeof rest[0] === "string") {
|
|
description = rest.shift();
|
|
}
|
|
if (rest.length > 1) {
|
|
const firstArg = rest[0];
|
|
if (isZodRawShape(firstArg)) {
|
|
inputSchema = rest.shift();
|
|
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
|
|
annotations = rest.shift();
|
|
}
|
|
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
annotations = rest.shift();
|
|
}
|
|
}
|
|
const callback = rest[0];
|
|
return this._createRegisteredTool(name, undefined, description, inputSchema, outputSchema, annotations, undefined, callback);
|
|
}
|
|
registerTool(name, config, cb) {
|
|
if (this._registeredTools[name]) {
|
|
throw new Error(`Tool ${name} is already registered`);
|
|
}
|
|
const { title, description, inputSchema, outputSchema, annotations, _meta } = config;
|
|
return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, _meta, cb);
|
|
}
|
|
prompt(name, ...rest) {
|
|
if (this._registeredPrompts[name]) {
|
|
throw new Error(`Prompt ${name} is already registered`);
|
|
}
|
|
let description;
|
|
if (typeof rest[0] === "string") {
|
|
description = rest.shift();
|
|
}
|
|
let argsSchema;
|
|
if (rest.length > 1) {
|
|
argsSchema = rest.shift();
|
|
}
|
|
const cb = rest[0];
|
|
const registeredPrompt = this._createRegisteredPrompt(name, undefined, description, argsSchema, cb);
|
|
this.setPromptRequestHandlers();
|
|
this.sendPromptListChanged();
|
|
return registeredPrompt;
|
|
}
|
|
registerPrompt(name, config, cb) {
|
|
if (this._registeredPrompts[name]) {
|
|
throw new Error(`Prompt ${name} is already registered`);
|
|
}
|
|
const { title, description, argsSchema } = config;
|
|
const registeredPrompt = this._createRegisteredPrompt(name, title, description, argsSchema, cb);
|
|
this.setPromptRequestHandlers();
|
|
this.sendPromptListChanged();
|
|
return registeredPrompt;
|
|
}
|
|
isConnected() {
|
|
return this.server.transport !== undefined;
|
|
}
|
|
async sendLoggingMessage(params, sessionId) {
|
|
return this.server.sendLoggingMessage(params, sessionId);
|
|
}
|
|
sendResourceListChanged() {
|
|
if (this.isConnected()) {
|
|
this.server.sendResourceListChanged();
|
|
}
|
|
}
|
|
sendToolListChanged() {
|
|
if (this.isConnected()) {
|
|
this.server.sendToolListChanged();
|
|
}
|
|
}
|
|
sendPromptListChanged() {
|
|
if (this.isConnected()) {
|
|
this.server.sendPromptListChanged();
|
|
}
|
|
}
|
|
}
|
|
var EMPTY_OBJECT_JSON_SCHEMA = {
|
|
type: "object",
|
|
properties: {}
|
|
};
|
|
function isZodRawShape(obj) {
|
|
if (typeof obj !== "object" || obj === null)
|
|
return false;
|
|
const isEmptyObject = Object.keys(obj).length === 0;
|
|
return isEmptyObject || Object.values(obj).some(isZodTypeLike);
|
|
}
|
|
function isZodTypeLike(value) {
|
|
return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
|
|
}
|
|
function promptArgumentsFromSchema(schema) {
|
|
return Object.entries(schema.shape).map(([name, field]) => ({
|
|
name,
|
|
description: field.description,
|
|
required: !field.isOptional()
|
|
}));
|
|
}
|
|
function createCompletionResult(suggestions) {
|
|
return {
|
|
completion: {
|
|
values: suggestions.slice(0, 100),
|
|
total: suggestions.length,
|
|
hasMore: suggestions.length > 100
|
|
}
|
|
};
|
|
}
|
|
var EMPTY_COMPLETION_RESULT = {
|
|
completion: {
|
|
values: [],
|
|
hasMore: false
|
|
}
|
|
};
|
|
|
|
// node:process
|
|
var C = Object.create;
|
|
var T = Object.defineProperty;
|
|
var q = Object.getOwnPropertyDescriptor;
|
|
var A = Object.getOwnPropertyNames;
|
|
var I = Object.getPrototypeOf;
|
|
var Q = Object.prototype.hasOwnProperty;
|
|
var S = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
|
|
var N = (e, t) => {
|
|
for (var n in t)
|
|
T(e, n, { get: t[n], enumerable: true });
|
|
};
|
|
var d = (e, t, n, w) => {
|
|
if (t && typeof t == "object" || typeof t == "function")
|
|
for (let l of A(t))
|
|
!Q.call(e, l) && l !== n && T(e, l, { get: () => t[l], enumerable: !(w = q(t, l)) || w.enumerable });
|
|
return e;
|
|
};
|
|
var h = (e, t, n) => (d(e, t, "default"), n && d(n, t, "default"));
|
|
var y = (e, t, n) => (n = e != null ? C(I(e)) : {}, d(t || !e || !e.__esModule ? T(n, "default", { value: e, enumerable: true }) : n, e));
|
|
var v = S((B, E) => {
|
|
var r = E.exports = {}, i, u;
|
|
function p() {
|
|
throw new Error("setTimeout has not been defined");
|
|
}
|
|
function g() {
|
|
throw new Error("clearTimeout has not been defined");
|
|
}
|
|
(function() {
|
|
try {
|
|
typeof setTimeout == "function" ? i = setTimeout : i = p;
|
|
} catch {
|
|
i = p;
|
|
}
|
|
try {
|
|
typeof clearTimeout == "function" ? u = clearTimeout : u = g;
|
|
} catch {
|
|
u = g;
|
|
}
|
|
})();
|
|
function b(e) {
|
|
if (i === setTimeout)
|
|
return setTimeout(e, 0);
|
|
if ((i === p || !i) && setTimeout)
|
|
return i = setTimeout, setTimeout(e, 0);
|
|
try {
|
|
return i(e, 0);
|
|
} catch {
|
|
try {
|
|
return i.call(null, e, 0);
|
|
} catch {
|
|
return i.call(this, e, 0);
|
|
}
|
|
}
|
|
}
|
|
function O(e) {
|
|
if (u === clearTimeout)
|
|
return clearTimeout(e);
|
|
if ((u === g || !u) && clearTimeout)
|
|
return u = clearTimeout, clearTimeout(e);
|
|
try {
|
|
return u(e);
|
|
} catch {
|
|
try {
|
|
return u.call(null, e);
|
|
} catch {
|
|
return u.call(this, e);
|
|
}
|
|
}
|
|
}
|
|
var o = [], s = false, a, m = -1;
|
|
function U() {
|
|
!s || !a || (s = false, a.length ? o = a.concat(o) : m = -1, o.length && x());
|
|
}
|
|
function x() {
|
|
if (!s) {
|
|
var e = b(U);
|
|
s = true;
|
|
for (var t = o.length;t; ) {
|
|
for (a = o, o = [];++m < t; )
|
|
a && a[m].run();
|
|
m = -1, t = o.length;
|
|
}
|
|
a = null, s = false, O(e);
|
|
}
|
|
}
|
|
r.nextTick = function(e) {
|
|
var t = new Array(arguments.length - 1);
|
|
if (arguments.length > 1)
|
|
for (var n = 1;n < arguments.length; n++)
|
|
t[n - 1] = arguments[n];
|
|
o.push(new L(e, t)), o.length === 1 && !s && b(x);
|
|
};
|
|
function L(e, t) {
|
|
this.fun = e, this.array = t;
|
|
}
|
|
L.prototype.run = function() {
|
|
this.fun.apply(null, this.array);
|
|
};
|
|
r.title = "browser";
|
|
r.browser = true;
|
|
r.env = {};
|
|
r.argv = [];
|
|
r.version = "";
|
|
r.versions = {};
|
|
function c() {}
|
|
r.on = c;
|
|
r.addListener = c;
|
|
r.once = c;
|
|
r.off = c;
|
|
r.removeListener = c;
|
|
r.removeAllListeners = c;
|
|
r.emit = c;
|
|
r.prependListener = c;
|
|
r.prependOnceListener = c;
|
|
r.listeners = function(e) {
|
|
return [];
|
|
};
|
|
r.binding = function(e) {
|
|
throw new Error("process.binding is not supported");
|
|
};
|
|
r.cwd = function() {
|
|
return "/";
|
|
};
|
|
r.chdir = function(e) {
|
|
throw new Error("process.chdir is not supported");
|
|
};
|
|
r.umask = function() {
|
|
return 0;
|
|
};
|
|
});
|
|
var f = {};
|
|
N(f, { default: () => j });
|
|
h(f, y(v()));
|
|
var j = y(v());
|
|
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
class ReadBuffer {
|
|
append(chunk) {
|
|
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
}
|
|
readMessage() {
|
|
if (!this._buffer) {
|
|
return null;
|
|
}
|
|
const index = this._buffer.indexOf(`
|
|
`);
|
|
if (index === -1) {
|
|
return null;
|
|
}
|
|
const line = this._buffer.toString("utf8", 0, index).replace(/\r$/, "");
|
|
this._buffer = this._buffer.subarray(index + 1);
|
|
return deserializeMessage(line);
|
|
}
|
|
clear() {
|
|
this._buffer = undefined;
|
|
}
|
|
}
|
|
function deserializeMessage(line) {
|
|
return JSONRPCMessageSchema.parse(JSON.parse(line));
|
|
}
|
|
function serializeMessage(message) {
|
|
return JSON.stringify(message) + `
|
|
`;
|
|
}
|
|
|
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
class StdioServerTransport {
|
|
constructor(_stdin = j.stdin, _stdout = j.stdout) {
|
|
this._stdin = _stdin;
|
|
this._stdout = _stdout;
|
|
this._readBuffer = new ReadBuffer;
|
|
this._started = false;
|
|
this._ondata = (chunk) => {
|
|
this._readBuffer.append(chunk);
|
|
this.processReadBuffer();
|
|
};
|
|
this._onerror = (error) => {
|
|
var _a;
|
|
(_a = this.onerror) === null || _a === undefined || _a.call(this, error);
|
|
};
|
|
}
|
|
async start() {
|
|
if (this._started) {
|
|
throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");
|
|
}
|
|
this._started = true;
|
|
this._stdin.on("data", this._ondata);
|
|
this._stdin.on("error", this._onerror);
|
|
}
|
|
processReadBuffer() {
|
|
var _a, _b;
|
|
while (true) {
|
|
try {
|
|
const message = this._readBuffer.readMessage();
|
|
if (message === null) {
|
|
break;
|
|
}
|
|
(_a = this.onmessage) === null || _a === undefined || _a.call(this, message);
|
|
} catch (error) {
|
|
(_b = this.onerror) === null || _b === undefined || _b.call(this, error);
|
|
}
|
|
}
|
|
}
|
|
async close() {
|
|
var _a;
|
|
this._stdin.off("data", this._ondata);
|
|
this._stdin.off("error", this._onerror);
|
|
const remainingDataListeners = this._stdin.listenerCount("data");
|
|
if (remainingDataListeners === 0) {
|
|
this._stdin.pause();
|
|
}
|
|
this._readBuffer.clear();
|
|
(_a = this.onclose) === null || _a === undefined || _a.call(this);
|
|
}
|
|
send(message) {
|
|
return new Promise((resolve) => {
|
|
const json = serializeMessage(message);
|
|
if (this._stdout.write(json)) {
|
|
resolve();
|
|
} else {
|
|
this._stdout.once("drain", resolve);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
// node_modules/universal-user-agent/index.js
|
|
function getUserAgent() {
|
|
if (typeof navigator === "object" && "userAgent" in navigator) {
|
|
return navigator.userAgent;
|
|
}
|
|
if (typeof process === "object" && process.version !== undefined) {
|
|
return `Node.js/${process.version.substr(1)} (${process.platform}; ${process.arch})`;
|
|
}
|
|
return "<environment undetectable>";
|
|
}
|
|
|
|
// node_modules/before-after-hook/lib/register.js
|
|
function register(state, name, method, options) {
|
|
if (typeof method !== "function") {
|
|
throw new Error("method for before hook must be a function");
|
|
}
|
|
if (!options) {
|
|
options = {};
|
|
}
|
|
if (Array.isArray(name)) {
|
|
return name.reverse().reduce((callback, name2) => {
|
|
return register.bind(null, state, name2, callback, options);
|
|
}, method)();
|
|
}
|
|
return Promise.resolve().then(() => {
|
|
if (!state.registry[name]) {
|
|
return method(options);
|
|
}
|
|
return state.registry[name].reduce((method2, registered) => {
|
|
return registered.hook.bind(null, method2, options);
|
|
}, method)();
|
|
});
|
|
}
|
|
|
|
// node_modules/before-after-hook/lib/add.js
|
|
function addHook(state, kind, name, hook) {
|
|
const orig = hook;
|
|
if (!state.registry[name]) {
|
|
state.registry[name] = [];
|
|
}
|
|
if (kind === "before") {
|
|
hook = (method, options) => {
|
|
return Promise.resolve().then(orig.bind(null, options)).then(method.bind(null, options));
|
|
};
|
|
}
|
|
if (kind === "after") {
|
|
hook = (method, options) => {
|
|
let result;
|
|
return Promise.resolve().then(method.bind(null, options)).then((result_) => {
|
|
result = result_;
|
|
return orig(result, options);
|
|
}).then(() => {
|
|
return result;
|
|
});
|
|
};
|
|
}
|
|
if (kind === "error") {
|
|
hook = (method, options) => {
|
|
return Promise.resolve().then(method.bind(null, options)).catch((error) => {
|
|
return orig(error, options);
|
|
});
|
|
};
|
|
}
|
|
state.registry[name].push({
|
|
hook,
|
|
orig
|
|
});
|
|
}
|
|
|
|
// node_modules/before-after-hook/lib/remove.js
|
|
function removeHook(state, name, method) {
|
|
if (!state.registry[name]) {
|
|
return;
|
|
}
|
|
const index = state.registry[name].map((registered) => {
|
|
return registered.orig;
|
|
}).indexOf(method);
|
|
if (index === -1) {
|
|
return;
|
|
}
|
|
state.registry[name].splice(index, 1);
|
|
}
|
|
|
|
// node_modules/before-after-hook/index.js
|
|
var bind = Function.bind;
|
|
var bindable = bind.bind(bind);
|
|
function bindApi(hook, state, name) {
|
|
const removeHookRef = bindable(removeHook, null).apply(null, name ? [state, name] : [state]);
|
|
hook.api = { remove: removeHookRef };
|
|
hook.remove = removeHookRef;
|
|
["before", "error", "after", "wrap"].forEach((kind) => {
|
|
const args = name ? [state, kind, name] : [state, kind];
|
|
hook[kind] = hook.api[kind] = bindable(addHook, null).apply(null, args);
|
|
});
|
|
}
|
|
function Singular() {
|
|
const singularHookName = Symbol("Singular");
|
|
const singularHookState = {
|
|
registry: {}
|
|
};
|
|
const singularHook = register.bind(null, singularHookState, singularHookName);
|
|
bindApi(singularHook, singularHookState, singularHookName);
|
|
return singularHook;
|
|
}
|
|
function Collection() {
|
|
const state = {
|
|
registry: {}
|
|
};
|
|
const hook = register.bind(null, state);
|
|
bindApi(hook, state);
|
|
return hook;
|
|
}
|
|
var before_after_hook_default = { Singular, Collection };
|
|
|
|
// node_modules/@octokit/endpoint/dist-bundle/index.js
|
|
var VERSION = "0.0.0-development";
|
|
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: ""
|
|
}
|
|
};
|
|
function lowercaseKeys(object2) {
|
|
if (!object2) {
|
|
return {};
|
|
}
|
|
return Object.keys(object2).reduce((newObj, key) => {
|
|
newObj[key.toLowerCase()] = object2[key];
|
|
return newObj;
|
|
}, {});
|
|
}
|
|
function isPlainObject(value) {
|
|
if (typeof value !== "object" || value === null)
|
|
return false;
|
|
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
return false;
|
|
const proto = Object.getPrototypeOf(value);
|
|
if (proto === null)
|
|
return true;
|
|
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
}
|
|
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 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(" ");
|
|
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 (options.url === "/graphql") {
|
|
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 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 `${name}=${encodeURIComponent(parameters[name])}`;
|
|
}).join("&");
|
|
}
|
|
var urlVariableRegex = /\{[^{}}]+\}/g;
|
|
function removeNonChars(variableName) {
|
|
return variableName.replace(/(?:^\W+)|(?:(?<!\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), []);
|
|
}
|
|
function omit(object2, keysToOmit) {
|
|
const result = { __proto__: null };
|
|
for (const key of Object.keys(object2)) {
|
|
if (keysToOmit.indexOf(key) === -1) {
|
|
result[key] = object2[key];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
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("");
|
|
}
|
|
function encodeUnreserved(str) {
|
|
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;
|
|
}
|
|
}
|
|
function isDefined(value) {
|
|
return value !== undefined && value !== null;
|
|
}
|
|
function isKeyOperator(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));
|
|
}
|
|
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));
|
|
}
|
|
});
|
|
}
|
|
} 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()));
|
|
}
|
|
});
|
|
}
|
|
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));
|
|
}
|
|
} 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)
|
|
};
|
|
}
|
|
function expand(template, context) {
|
|
var operators = ["+", "#", ".", "/", ";", "?", "&"];
|
|
template = template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function(_, expression, literal2) {
|
|
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(",");
|
|
}
|
|
} else {
|
|
return encodeReserved(literal2);
|
|
}
|
|
});
|
|
if (template === "/") {
|
|
return template;
|
|
} else {
|
|
return template.replace(/\/$/, "");
|
|
}
|
|
}
|
|
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((format) => format.replace(/application\/vnd(\.\w+)(\.v3)?(\.\w+)?(\+json)?$/, `application/vnd$1$2.${options.mediaType.format}`)).join(",");
|
|
}
|
|
if (url.endsWith("/graphql")) {
|
|
if (options.mediaType.previews?.length) {
|
|
const previewsFromAcceptHeader = headers.accept.match(/(?<![\w-])[\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 (["GET", "HEAD"].includes(method)) {
|
|
url = addQueryParameters(url, remainingParameters);
|
|
} else {
|
|
if ("data" in remainingParameters) {
|
|
body = remainingParameters.data;
|
|
} else {
|
|
if (Object.keys(remainingParameters).length) {
|
|
body = remainingParameters;
|
|
}
|
|
}
|
|
}
|
|
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);
|
|
}
|
|
function endpointWithDefaults(defaults, route, options) {
|
|
return parse(merge(defaults, route, options));
|
|
}
|
|
function withDefaults(oldDefaults, newDefaults) {
|
|
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
|
|
});
|
|
}
|
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
|
|
// node_modules/fast-content-type-parse/index.js
|
|
var NullObject = function NullObject2() {};
|
|
NullObject.prototype = Object.create(null);
|
|
var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu;
|
|
var quotedPairRE = /\\([\v\u0020-\u00ff])/gu;
|
|
var mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u;
|
|
var defaultContentType = { type: "", parameters: new NullObject };
|
|
Object.freeze(defaultContentType.parameters);
|
|
Object.freeze(defaultContentType);
|
|
function safeParse(header) {
|
|
if (typeof header !== "string") {
|
|
return defaultContentType;
|
|
}
|
|
let index = header.indexOf(";");
|
|
const type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
if (mediaTypeRE.test(type) === false) {
|
|
return defaultContentType;
|
|
}
|
|
const result = {
|
|
type: type.toLowerCase(),
|
|
parameters: new NullObject
|
|
};
|
|
if (index === -1) {
|
|
return result;
|
|
}
|
|
let key;
|
|
let match;
|
|
let value;
|
|
paramRE.lastIndex = index;
|
|
while (match = paramRE.exec(header)) {
|
|
if (match.index !== index) {
|
|
return defaultContentType;
|
|
}
|
|
index += match[0].length;
|
|
key = match[1].toLowerCase();
|
|
value = match[2];
|
|
if (value[0] === '"') {
|
|
value = value.slice(1, value.length - 1);
|
|
quotedPairRE.test(value) && (value = value.replace(quotedPairRE, "$1"));
|
|
}
|
|
result.parameters[key] = value;
|
|
}
|
|
if (index !== header.length) {
|
|
return defaultContentType;
|
|
}
|
|
return result;
|
|
}
|
|
var $safeParse = safeParse;
|
|
|
|
// node_modules/@octokit/request-error/dist-src/index.js
|
|
class RequestError extends Error {
|
|
name;
|
|
status;
|
|
request;
|
|
response;
|
|
constructor(message, statusCode, options) {
|
|
super(message);
|
|
this.name = "HttpError";
|
|
this.status = Number.parseInt(statusCode);
|
|
if (Number.isNaN(this.status)) {
|
|
this.status = 0;
|
|
}
|
|
if ("response" in options) {
|
|
this.response = options.response;
|
|
}
|
|
const requestCopy = Object.assign({}, options.request);
|
|
if (options.request.headers.authorization) {
|
|
requestCopy.headers = Object.assign({}, options.request.headers, {
|
|
authorization: options.request.headers.authorization.replace(/(?<! ) .*$/, " [REDACTED]")
|
|
});
|
|
}
|
|
requestCopy.url = requestCopy.url.replace(/\bclient_secret=\w+/g, "client_secret=[REDACTED]").replace(/\baccess_token=\w+/g, "access_token=[REDACTED]");
|
|
this.request = requestCopy;
|
|
}
|
|
}
|
|
|
|
// node_modules/@octokit/request/dist-bundle/index.js
|
|
var VERSION2 = "10.0.5";
|
|
var defaults_default = {
|
|
headers: {
|
|
"user-agent": `octokit-request.js/${VERSION2} ${getUserAgent()}`
|
|
}
|
|
};
|
|
function isPlainObject2(value) {
|
|
if (typeof value !== "object" || value === null)
|
|
return false;
|
|
if (Object.prototype.toString.call(value) !== "[object Object]")
|
|
return false;
|
|
const proto = Object.getPrototypeOf(value);
|
|
if (proto === null)
|
|
return true;
|
|
const Ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
return typeof Ctor === "function" && Ctor instanceof Ctor && Function.prototype.call(Ctor) === Function.prototype.call(value);
|
|
}
|
|
async function fetchWrapper(requestOptions) {
|
|
const fetch = requestOptions.request?.fetch || globalThis.fetch;
|
|
if (!fetch) {
|
|
throw new Error("fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). Learn more at https://github.com/octokit/octokit.js/#fetch-missing");
|
|
}
|
|
const log = requestOptions.request?.log || console;
|
|
const parseSuccessResponseBody = requestOptions.request?.parseSuccessResponseBody !== false;
|
|
const body = isPlainObject2(requestOptions.body) || Array.isArray(requestOptions.body) ? JSON.stringify(requestOptions.body) : requestOptions.body;
|
|
const requestHeaders = Object.fromEntries(Object.entries(requestOptions.headers).map(([name, value]) => [
|
|
name,
|
|
String(value)
|
|
]));
|
|
let fetchResponse;
|
|
try {
|
|
fetchResponse = await fetch(requestOptions.url, {
|
|
method: requestOptions.method,
|
|
body,
|
|
redirect: requestOptions.request?.redirect,
|
|
headers: requestHeaders,
|
|
signal: requestOptions.request?.signal,
|
|
...requestOptions.body && { duplex: "half" }
|
|
});
|
|
} catch (error) {
|
|
let message = "Unknown Error";
|
|
if (error instanceof Error) {
|
|
if (error.name === "AbortError") {
|
|
error.status = 500;
|
|
throw error;
|
|
}
|
|
message = error.message;
|
|
if (error.name === "TypeError" && "cause" in error) {
|
|
if (error.cause instanceof Error) {
|
|
message = error.cause.message;
|
|
} else if (typeof error.cause === "string") {
|
|
message = error.cause;
|
|
}
|
|
}
|
|
}
|
|
const requestError = new RequestError(message, 500, {
|
|
request: requestOptions
|
|
});
|
|
requestError.cause = error;
|
|
throw requestError;
|
|
}
|
|
const status = fetchResponse.status;
|
|
const url = fetchResponse.url;
|
|
const responseHeaders = {};
|
|
for (const [key, value] of fetchResponse.headers) {
|
|
responseHeaders[key] = value;
|
|
}
|
|
const octokitResponse = {
|
|
url,
|
|
status,
|
|
headers: responseHeaders,
|
|
data: ""
|
|
};
|
|
if ("deprecation" in responseHeaders) {
|
|
const matches = responseHeaders.link && responseHeaders.link.match(/<([^<>]+)>; rel="deprecation"/);
|
|
const deprecationLink = matches && matches.pop();
|
|
log.warn(`[@octokit/request] "${requestOptions.method} ${requestOptions.url}" is deprecated. It is scheduled to be removed on ${responseHeaders.sunset}${deprecationLink ? `. See ${deprecationLink}` : ""}`);
|
|
}
|
|
if (status === 204 || status === 205) {
|
|
return octokitResponse;
|
|
}
|
|
if (requestOptions.method === "HEAD") {
|
|
if (status < 400) {
|
|
return octokitResponse;
|
|
}
|
|
throw new RequestError(fetchResponse.statusText, status, {
|
|
response: octokitResponse,
|
|
request: requestOptions
|
|
});
|
|
}
|
|
if (status === 304) {
|
|
octokitResponse.data = await getResponseData(fetchResponse);
|
|
throw new RequestError("Not modified", status, {
|
|
response: octokitResponse,
|
|
request: requestOptions
|
|
});
|
|
}
|
|
if (status >= 400) {
|
|
octokitResponse.data = await getResponseData(fetchResponse);
|
|
throw new RequestError(toErrorMessage(octokitResponse.data), status, {
|
|
response: octokitResponse,
|
|
request: requestOptions
|
|
});
|
|
}
|
|
octokitResponse.data = parseSuccessResponseBody ? await getResponseData(fetchResponse) : fetchResponse.body;
|
|
return octokitResponse;
|
|
}
|
|
async function getResponseData(response) {
|
|
const contentType = response.headers.get("content-type");
|
|
if (!contentType) {
|
|
return response.text().catch(() => "");
|
|
}
|
|
const mimetype = $safeParse(contentType);
|
|
if (isJSONResponse(mimetype)) {
|
|
let text = "";
|
|
try {
|
|
text = await response.text();
|
|
return JSON.parse(text);
|
|
} catch (err) {
|
|
return text;
|
|
}
|
|
} else if (mimetype.type.startsWith("text/") || mimetype.parameters.charset?.toLowerCase() === "utf-8") {
|
|
return response.text().catch(() => "");
|
|
} else {
|
|
return response.arrayBuffer().catch(() => new ArrayBuffer(0));
|
|
}
|
|
}
|
|
function isJSONResponse(mimetype) {
|
|
return mimetype.type === "application/json" || mimetype.type === "application/scim+json";
|
|
}
|
|
function toErrorMessage(data) {
|
|
if (typeof data === "string") {
|
|
return data;
|
|
}
|
|
if (data instanceof ArrayBuffer) {
|
|
return "Unknown error";
|
|
}
|
|
if ("message" in data) {
|
|
const suffix = "documentation_url" in data ? ` - ${data.documentation_url}` : "";
|
|
return Array.isArray(data.errors) ? `${data.message}: ${data.errors.map((v2) => JSON.stringify(v2)).join(", ")}${suffix}` : `${data.message}${suffix}`;
|
|
}
|
|
return `Unknown error: ${JSON.stringify(data)}`;
|
|
}
|
|
function withDefaults2(oldEndpoint, newDefaults) {
|
|
const endpoint2 = oldEndpoint.defaults(newDefaults);
|
|
const newApi = function(route, parameters) {
|
|
const endpointOptions = endpoint2.merge(route, parameters);
|
|
if (!endpointOptions.request || !endpointOptions.request.hook) {
|
|
return fetchWrapper(endpoint2.parse(endpointOptions));
|
|
}
|
|
const request2 = (route2, parameters2) => {
|
|
return fetchWrapper(endpoint2.parse(endpoint2.merge(route2, parameters2)));
|
|
};
|
|
Object.assign(request2, {
|
|
endpoint: endpoint2,
|
|
defaults: withDefaults2.bind(null, endpoint2)
|
|
});
|
|
return endpointOptions.request.hook(request2, endpointOptions);
|
|
};
|
|
return Object.assign(newApi, {
|
|
endpoint: endpoint2,
|
|
defaults: withDefaults2.bind(null, endpoint2)
|
|
});
|
|
}
|
|
var request = withDefaults2(endpoint, defaults_default);
|
|
|
|
// node_modules/@octokit/graphql/dist-bundle/index.js
|
|
var VERSION3 = "0.0.0-development";
|
|
function _buildMessageForResponseErrors(data) {
|
|
return `Request failed due to following response errors:
|
|
` + data.errors.map((e) => ` - ${e.message}`).join(`
|
|
`);
|
|
}
|
|
var GraphqlResponseError = class extends Error {
|
|
constructor(request2, headers, response) {
|
|
super(_buildMessageForResponseErrors(response));
|
|
this.request = request2;
|
|
this.headers = headers;
|
|
this.response = response;
|
|
this.errors = response.errors;
|
|
this.data = response.data;
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, this.constructor);
|
|
}
|
|
}
|
|
name = "GraphqlResponseError";
|
|
errors;
|
|
data;
|
|
};
|
|
var NON_VARIABLE_OPTIONS = [
|
|
"method",
|
|
"baseUrl",
|
|
"url",
|
|
"headers",
|
|
"request",
|
|
"query",
|
|
"mediaType",
|
|
"operationName"
|
|
];
|
|
var FORBIDDEN_VARIABLE_OPTIONS = ["query", "method", "url"];
|
|
var GHES_V3_SUFFIX_REGEX = /\/api\/v3\/?$/;
|
|
function graphql(request2, query, options) {
|
|
if (options) {
|
|
if (typeof query === "string" && "query" in options) {
|
|
return Promise.reject(new Error(`[@octokit/graphql] "query" cannot be used as variable name`));
|
|
}
|
|
for (const key in options) {
|
|
if (!FORBIDDEN_VARIABLE_OPTIONS.includes(key))
|
|
continue;
|
|
return Promise.reject(new Error(`[@octokit/graphql] "${key}" cannot be used as variable name`));
|
|
}
|
|
}
|
|
const parsedOptions = typeof query === "string" ? Object.assign({ query }, options) : query;
|
|
const requestOptions = Object.keys(parsedOptions).reduce((result, key) => {
|
|
if (NON_VARIABLE_OPTIONS.includes(key)) {
|
|
result[key] = parsedOptions[key];
|
|
return result;
|
|
}
|
|
if (!result.variables) {
|
|
result.variables = {};
|
|
}
|
|
result.variables[key] = parsedOptions[key];
|
|
return result;
|
|
}, {});
|
|
const baseUrl = parsedOptions.baseUrl || request2.endpoint.DEFAULTS.baseUrl;
|
|
if (GHES_V3_SUFFIX_REGEX.test(baseUrl)) {
|
|
requestOptions.url = baseUrl.replace(GHES_V3_SUFFIX_REGEX, "/api/graphql");
|
|
}
|
|
return request2(requestOptions).then((response) => {
|
|
if (response.data.errors) {
|
|
const headers = {};
|
|
for (const key of Object.keys(response.headers)) {
|
|
headers[key] = response.headers[key];
|
|
}
|
|
throw new GraphqlResponseError(requestOptions, headers, response.data);
|
|
}
|
|
return response.data.data;
|
|
});
|
|
}
|
|
function withDefaults3(request2, newDefaults) {
|
|
const newRequest = request2.defaults(newDefaults);
|
|
const newApi = (query, options) => {
|
|
return graphql(newRequest, query, options);
|
|
};
|
|
return Object.assign(newApi, {
|
|
defaults: withDefaults3.bind(null, newRequest),
|
|
endpoint: newRequest.endpoint
|
|
});
|
|
}
|
|
var graphql2 = withDefaults3(request, {
|
|
headers: {
|
|
"user-agent": `octokit-graphql.js/${VERSION3} ${getUserAgent()}`
|
|
},
|
|
method: "POST",
|
|
url: "/graphql"
|
|
});
|
|
function withCustomRequest(customRequest) {
|
|
return withDefaults3(customRequest, {
|
|
method: "POST",
|
|
url: "/graphql"
|
|
});
|
|
}
|
|
|
|
// node_modules/@octokit/auth-token/dist-bundle/index.js
|
|
var b64url = "(?:[a-zA-Z0-9_-]+)";
|
|
var sep = "\\.";
|
|
var jwtRE = new RegExp(`^${b64url}${sep}${b64url}${sep}${b64url}$`);
|
|
var isJWT = jwtRE.test.bind(jwtRE);
|
|
async function auth(token) {
|
|
const isApp = isJWT(token);
|
|
const isInstallation = token.startsWith("v1.") || token.startsWith("ghs_");
|
|
const isUserToServer = token.startsWith("ghu_");
|
|
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
|
return {
|
|
type: "token",
|
|
token,
|
|
tokenType
|
|
};
|
|
}
|
|
function withAuthorizationPrefix(token) {
|
|
if (token.split(/\./).length === 3) {
|
|
return `bearer ${token}`;
|
|
}
|
|
return `token ${token}`;
|
|
}
|
|
async function hook(token, request2, route, parameters) {
|
|
const endpoint2 = request2.endpoint.merge(route, parameters);
|
|
endpoint2.headers.authorization = withAuthorizationPrefix(token);
|
|
return request2(endpoint2);
|
|
}
|
|
var createTokenAuth = function createTokenAuth2(token) {
|
|
if (!token) {
|
|
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
|
}
|
|
if (typeof token !== "string") {
|
|
throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
|
|
}
|
|
token = token.replace(/^(token|bearer) +/i, "");
|
|
return Object.assign(auth.bind(null, token), {
|
|
hook: hook.bind(null, token)
|
|
});
|
|
};
|
|
|
|
// node_modules/@octokit/core/dist-src/version.js
|
|
var VERSION4 = "7.0.5";
|
|
|
|
// node_modules/@octokit/core/dist-src/index.js
|
|
var noop = () => {};
|
|
var consoleWarn = console.warn.bind(console);
|
|
var consoleError = console.error.bind(console);
|
|
function createLogger(logger = {}) {
|
|
if (typeof logger.debug !== "function") {
|
|
logger.debug = noop;
|
|
}
|
|
if (typeof logger.info !== "function") {
|
|
logger.info = noop;
|
|
}
|
|
if (typeof logger.warn !== "function") {
|
|
logger.warn = consoleWarn;
|
|
}
|
|
if (typeof logger.error !== "function") {
|
|
logger.error = consoleError;
|
|
}
|
|
return logger;
|
|
}
|
|
var userAgentTrail = `octokit-core.js/${VERSION4} ${getUserAgent()}`;
|
|
|
|
class Octokit {
|
|
static VERSION = VERSION4;
|
|
static defaults(defaults) {
|
|
const OctokitWithDefaults = class extends this {
|
|
constructor(...args) {
|
|
const options = args[0] || {};
|
|
if (typeof defaults === "function") {
|
|
super(defaults(options));
|
|
return;
|
|
}
|
|
super(Object.assign({}, defaults, options, options.userAgent && defaults.userAgent ? {
|
|
userAgent: `${options.userAgent} ${defaults.userAgent}`
|
|
} : null));
|
|
}
|
|
};
|
|
return OctokitWithDefaults;
|
|
}
|
|
static plugins = [];
|
|
static plugin(...newPlugins) {
|
|
const currentPlugins = this.plugins;
|
|
const NewOctokit = class extends this {
|
|
static plugins = currentPlugins.concat(newPlugins.filter((plugin) => !currentPlugins.includes(plugin)));
|
|
};
|
|
return NewOctokit;
|
|
}
|
|
constructor(options = {}) {
|
|
const hook2 = new before_after_hook_default.Collection;
|
|
const requestDefaults = {
|
|
baseUrl: request.endpoint.DEFAULTS.baseUrl,
|
|
headers: {},
|
|
request: Object.assign({}, options.request, {
|
|
hook: hook2.bind(null, "request")
|
|
}),
|
|
mediaType: {
|
|
previews: [],
|
|
format: ""
|
|
}
|
|
};
|
|
requestDefaults.headers["user-agent"] = options.userAgent ? `${options.userAgent} ${userAgentTrail}` : userAgentTrail;
|
|
if (options.baseUrl) {
|
|
requestDefaults.baseUrl = options.baseUrl;
|
|
}
|
|
if (options.previews) {
|
|
requestDefaults.mediaType.previews = options.previews;
|
|
}
|
|
if (options.timeZone) {
|
|
requestDefaults.headers["time-zone"] = options.timeZone;
|
|
}
|
|
this.request = request.defaults(requestDefaults);
|
|
this.graphql = withCustomRequest(this.request).defaults(requestDefaults);
|
|
this.log = createLogger(options.log);
|
|
this.hook = hook2;
|
|
if (!options.authStrategy) {
|
|
if (!options.auth) {
|
|
this.auth = async () => ({
|
|
type: "unauthenticated"
|
|
});
|
|
} else {
|
|
const auth2 = createTokenAuth(options.auth);
|
|
hook2.wrap("request", auth2.hook);
|
|
this.auth = auth2;
|
|
}
|
|
} else {
|
|
const { authStrategy, ...otherOptions } = options;
|
|
const auth2 = authStrategy(Object.assign({
|
|
request: this.request,
|
|
log: this.log,
|
|
octokit: this,
|
|
octokitOptions: otherOptions
|
|
}, options.auth));
|
|
hook2.wrap("request", auth2.hook);
|
|
this.auth = auth2;
|
|
}
|
|
const classConstructor = this.constructor;
|
|
for (let i = 0;i < classConstructor.plugins.length; ++i) {
|
|
Object.assign(this, classConstructor.plugins[i](this, options));
|
|
}
|
|
}
|
|
request;
|
|
graphql;
|
|
log;
|
|
hook;
|
|
auth;
|
|
}
|
|
|
|
// node_modules/@octokit/plugin-request-log/dist-src/version.js
|
|
var VERSION5 = "6.0.0";
|
|
|
|
// node_modules/@octokit/plugin-request-log/dist-src/index.js
|
|
function requestLog(octokit) {
|
|
octokit.hook.wrap("request", (request2, options) => {
|
|
octokit.log.debug("request", options);
|
|
const start = Date.now();
|
|
const requestOptions = octokit.request.endpoint.parse(options);
|
|
const path = requestOptions.url.replace(options.baseUrl, "");
|
|
return request2(options).then((response) => {
|
|
const requestId = response.headers["x-github-request-id"];
|
|
octokit.log.info(`${requestOptions.method} ${path} - ${response.status} with id ${requestId} in ${Date.now() - start}ms`);
|
|
return response;
|
|
}).catch((error) => {
|
|
const requestId = error.response?.headers["x-github-request-id"] || "UNKNOWN";
|
|
octokit.log.error(`${requestOptions.method} ${path} - ${error.status} with id ${requestId} in ${Date.now() - start}ms`);
|
|
throw error;
|
|
});
|
|
});
|
|
}
|
|
requestLog.VERSION = VERSION5;
|
|
|
|
// node_modules/@octokit/plugin-paginate-rest/dist-bundle/index.js
|
|
var VERSION6 = "0.0.0-development";
|
|
function normalizePaginatedListResponse(response) {
|
|
if (!response.data) {
|
|
return {
|
|
...response,
|
|
data: []
|
|
};
|
|
}
|
|
const responseNeedsNormalization = (("total_count" in response.data) || ("total_commits" in response.data)) && !("url" in response.data);
|
|
if (!responseNeedsNormalization)
|
|
return response;
|
|
const incompleteResults = response.data.incomplete_results;
|
|
const repositorySelection = response.data.repository_selection;
|
|
const totalCount = response.data.total_count;
|
|
const totalCommits = response.data.total_commits;
|
|
delete response.data.incomplete_results;
|
|
delete response.data.repository_selection;
|
|
delete response.data.total_count;
|
|
delete response.data.total_commits;
|
|
const namespaceKey = Object.keys(response.data)[0];
|
|
const data = response.data[namespaceKey];
|
|
response.data = data;
|
|
if (typeof incompleteResults !== "undefined") {
|
|
response.data.incomplete_results = incompleteResults;
|
|
}
|
|
if (typeof repositorySelection !== "undefined") {
|
|
response.data.repository_selection = repositorySelection;
|
|
}
|
|
response.data.total_count = totalCount;
|
|
response.data.total_commits = totalCommits;
|
|
return response;
|
|
}
|
|
function iterator(octokit, route, parameters) {
|
|
const options = typeof route === "function" ? route.endpoint(parameters) : octokit.request.endpoint(route, parameters);
|
|
const requestMethod = typeof route === "function" ? route : octokit.request;
|
|
const method = options.method;
|
|
const headers = options.headers;
|
|
let url = options.url;
|
|
return {
|
|
[Symbol.asyncIterator]: () => ({
|
|
async next() {
|
|
if (!url)
|
|
return { done: true };
|
|
try {
|
|
const response = await requestMethod({ method, url, headers });
|
|
const normalizedResponse = normalizePaginatedListResponse(response);
|
|
url = ((normalizedResponse.headers.link || "").match(/<([^<>]+)>;\s*rel="next"/) || [])[1];
|
|
if (!url && "total_commits" in normalizedResponse.data) {
|
|
const parsedUrl = new URL(normalizedResponse.url);
|
|
const params = parsedUrl.searchParams;
|
|
const page = parseInt(params.get("page") || "1", 10);
|
|
const per_page = parseInt(params.get("per_page") || "250", 10);
|
|
if (page * per_page < normalizedResponse.data.total_commits) {
|
|
params.set("page", String(page + 1));
|
|
url = parsedUrl.toString();
|
|
}
|
|
}
|
|
return { value: normalizedResponse };
|
|
} catch (error) {
|
|
if (error.status !== 409)
|
|
throw error;
|
|
url = "";
|
|
return {
|
|
value: {
|
|
status: 200,
|
|
headers: {},
|
|
data: []
|
|
}
|
|
};
|
|
}
|
|
}
|
|
})
|
|
};
|
|
}
|
|
function paginate(octokit, route, parameters, mapFn) {
|
|
if (typeof parameters === "function") {
|
|
mapFn = parameters;
|
|
parameters = undefined;
|
|
}
|
|
return gather(octokit, [], iterator(octokit, route, parameters)[Symbol.asyncIterator](), mapFn);
|
|
}
|
|
function gather(octokit, results, iterator2, mapFn) {
|
|
return iterator2.next().then((result) => {
|
|
if (result.done) {
|
|
return results;
|
|
}
|
|
let earlyExit = false;
|
|
function done() {
|
|
earlyExit = true;
|
|
}
|
|
results = results.concat(mapFn ? mapFn(result.value, done) : result.value.data);
|
|
if (earlyExit) {
|
|
return results;
|
|
}
|
|
return gather(octokit, results, iterator2, mapFn);
|
|
});
|
|
}
|
|
var composePaginateRest = Object.assign(paginate, {
|
|
iterator
|
|
});
|
|
function paginateRest(octokit) {
|
|
return {
|
|
paginate: Object.assign(paginate.bind(null, octokit), {
|
|
iterator: iterator.bind(null, octokit)
|
|
})
|
|
};
|
|
}
|
|
paginateRest.VERSION = VERSION6;
|
|
|
|
// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/version.js
|
|
var VERSION7 = "16.1.0";
|
|
|
|
// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/generated/endpoints.js
|
|
var Endpoints = {
|
|
actions: {
|
|
addCustomLabelsToSelfHostedRunnerForOrg: [
|
|
"POST /orgs/{org}/actions/runners/{runner_id}/labels"
|
|
],
|
|
addCustomLabelsToSelfHostedRunnerForRepo: [
|
|
"POST /repos/{owner}/{repo}/actions/runners/{runner_id}/labels"
|
|
],
|
|
addRepoAccessToSelfHostedRunnerGroupInOrg: [
|
|
"PUT /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories/{repository_id}"
|
|
],
|
|
addSelectedRepoToOrgSecret: [
|
|
"PUT /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
addSelectedRepoToOrgVariable: [
|
|
"PUT /orgs/{org}/actions/variables/{name}/repositories/{repository_id}"
|
|
],
|
|
approveWorkflowRun: [
|
|
"POST /repos/{owner}/{repo}/actions/runs/{run_id}/approve"
|
|
],
|
|
cancelWorkflowRun: [
|
|
"POST /repos/{owner}/{repo}/actions/runs/{run_id}/cancel"
|
|
],
|
|
createEnvironmentVariable: [
|
|
"POST /repos/{owner}/{repo}/environments/{environment_name}/variables"
|
|
],
|
|
createHostedRunnerForOrg: ["POST /orgs/{org}/actions/hosted-runners"],
|
|
createOrUpdateEnvironmentSecret: [
|
|
"PUT /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}"
|
|
],
|
|
createOrUpdateOrgSecret: ["PUT /orgs/{org}/actions/secrets/{secret_name}"],
|
|
createOrUpdateRepoSecret: [
|
|
"PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}"
|
|
],
|
|
createOrgVariable: ["POST /orgs/{org}/actions/variables"],
|
|
createRegistrationTokenForOrg: [
|
|
"POST /orgs/{org}/actions/runners/registration-token"
|
|
],
|
|
createRegistrationTokenForRepo: [
|
|
"POST /repos/{owner}/{repo}/actions/runners/registration-token"
|
|
],
|
|
createRemoveTokenForOrg: ["POST /orgs/{org}/actions/runners/remove-token"],
|
|
createRemoveTokenForRepo: [
|
|
"POST /repos/{owner}/{repo}/actions/runners/remove-token"
|
|
],
|
|
createRepoVariable: ["POST /repos/{owner}/{repo}/actions/variables"],
|
|
createWorkflowDispatch: [
|
|
"POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches"
|
|
],
|
|
deleteActionsCacheById: [
|
|
"DELETE /repos/{owner}/{repo}/actions/caches/{cache_id}"
|
|
],
|
|
deleteActionsCacheByKey: [
|
|
"DELETE /repos/{owner}/{repo}/actions/caches{?key,ref}"
|
|
],
|
|
deleteArtifact: [
|
|
"DELETE /repos/{owner}/{repo}/actions/artifacts/{artifact_id}"
|
|
],
|
|
deleteEnvironmentSecret: [
|
|
"DELETE /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}"
|
|
],
|
|
deleteEnvironmentVariable: [
|
|
"DELETE /repos/{owner}/{repo}/environments/{environment_name}/variables/{name}"
|
|
],
|
|
deleteHostedRunnerForOrg: [
|
|
"DELETE /orgs/{org}/actions/hosted-runners/{hosted_runner_id}"
|
|
],
|
|
deleteOrgSecret: ["DELETE /orgs/{org}/actions/secrets/{secret_name}"],
|
|
deleteOrgVariable: ["DELETE /orgs/{org}/actions/variables/{name}"],
|
|
deleteRepoSecret: [
|
|
"DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}"
|
|
],
|
|
deleteRepoVariable: [
|
|
"DELETE /repos/{owner}/{repo}/actions/variables/{name}"
|
|
],
|
|
deleteSelfHostedRunnerFromOrg: [
|
|
"DELETE /orgs/{org}/actions/runners/{runner_id}"
|
|
],
|
|
deleteSelfHostedRunnerFromRepo: [
|
|
"DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}"
|
|
],
|
|
deleteWorkflowRun: ["DELETE /repos/{owner}/{repo}/actions/runs/{run_id}"],
|
|
deleteWorkflowRunLogs: [
|
|
"DELETE /repos/{owner}/{repo}/actions/runs/{run_id}/logs"
|
|
],
|
|
disableSelectedRepositoryGithubActionsOrganization: [
|
|
"DELETE /orgs/{org}/actions/permissions/repositories/{repository_id}"
|
|
],
|
|
disableWorkflow: [
|
|
"PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/disable"
|
|
],
|
|
downloadArtifact: [
|
|
"GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}/{archive_format}"
|
|
],
|
|
downloadJobLogsForWorkflowRun: [
|
|
"GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs"
|
|
],
|
|
downloadWorkflowRunAttemptLogs: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/logs"
|
|
],
|
|
downloadWorkflowRunLogs: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs"
|
|
],
|
|
enableSelectedRepositoryGithubActionsOrganization: [
|
|
"PUT /orgs/{org}/actions/permissions/repositories/{repository_id}"
|
|
],
|
|
enableWorkflow: [
|
|
"PUT /repos/{owner}/{repo}/actions/workflows/{workflow_id}/enable"
|
|
],
|
|
forceCancelWorkflowRun: [
|
|
"POST /repos/{owner}/{repo}/actions/runs/{run_id}/force-cancel"
|
|
],
|
|
generateRunnerJitconfigForOrg: [
|
|
"POST /orgs/{org}/actions/runners/generate-jitconfig"
|
|
],
|
|
generateRunnerJitconfigForRepo: [
|
|
"POST /repos/{owner}/{repo}/actions/runners/generate-jitconfig"
|
|
],
|
|
getActionsCacheList: ["GET /repos/{owner}/{repo}/actions/caches"],
|
|
getActionsCacheUsage: ["GET /repos/{owner}/{repo}/actions/cache/usage"],
|
|
getActionsCacheUsageByRepoForOrg: [
|
|
"GET /orgs/{org}/actions/cache/usage-by-repository"
|
|
],
|
|
getActionsCacheUsageForOrg: ["GET /orgs/{org}/actions/cache/usage"],
|
|
getAllowedActionsOrganization: [
|
|
"GET /orgs/{org}/actions/permissions/selected-actions"
|
|
],
|
|
getAllowedActionsRepository: [
|
|
"GET /repos/{owner}/{repo}/actions/permissions/selected-actions"
|
|
],
|
|
getArtifact: ["GET /repos/{owner}/{repo}/actions/artifacts/{artifact_id}"],
|
|
getCustomOidcSubClaimForRepo: [
|
|
"GET /repos/{owner}/{repo}/actions/oidc/customization/sub"
|
|
],
|
|
getEnvironmentPublicKey: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/secrets/public-key"
|
|
],
|
|
getEnvironmentSecret: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/secrets/{secret_name}"
|
|
],
|
|
getEnvironmentVariable: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/variables/{name}"
|
|
],
|
|
getGithubActionsDefaultWorkflowPermissionsOrganization: [
|
|
"GET /orgs/{org}/actions/permissions/workflow"
|
|
],
|
|
getGithubActionsDefaultWorkflowPermissionsRepository: [
|
|
"GET /repos/{owner}/{repo}/actions/permissions/workflow"
|
|
],
|
|
getGithubActionsPermissionsOrganization: [
|
|
"GET /orgs/{org}/actions/permissions"
|
|
],
|
|
getGithubActionsPermissionsRepository: [
|
|
"GET /repos/{owner}/{repo}/actions/permissions"
|
|
],
|
|
getHostedRunnerForOrg: [
|
|
"GET /orgs/{org}/actions/hosted-runners/{hosted_runner_id}"
|
|
],
|
|
getHostedRunnersGithubOwnedImagesForOrg: [
|
|
"GET /orgs/{org}/actions/hosted-runners/images/github-owned"
|
|
],
|
|
getHostedRunnersLimitsForOrg: [
|
|
"GET /orgs/{org}/actions/hosted-runners/limits"
|
|
],
|
|
getHostedRunnersMachineSpecsForOrg: [
|
|
"GET /orgs/{org}/actions/hosted-runners/machine-sizes"
|
|
],
|
|
getHostedRunnersPartnerImagesForOrg: [
|
|
"GET /orgs/{org}/actions/hosted-runners/images/partner"
|
|
],
|
|
getHostedRunnersPlatformsForOrg: [
|
|
"GET /orgs/{org}/actions/hosted-runners/platforms"
|
|
],
|
|
getJobForWorkflowRun: ["GET /repos/{owner}/{repo}/actions/jobs/{job_id}"],
|
|
getOrgPublicKey: ["GET /orgs/{org}/actions/secrets/public-key"],
|
|
getOrgSecret: ["GET /orgs/{org}/actions/secrets/{secret_name}"],
|
|
getOrgVariable: ["GET /orgs/{org}/actions/variables/{name}"],
|
|
getPendingDeploymentsForRun: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments"
|
|
],
|
|
getRepoPermissions: [
|
|
"GET /repos/{owner}/{repo}/actions/permissions",
|
|
{},
|
|
{ renamed: ["actions", "getGithubActionsPermissionsRepository"] }
|
|
],
|
|
getRepoPublicKey: ["GET /repos/{owner}/{repo}/actions/secrets/public-key"],
|
|
getRepoSecret: ["GET /repos/{owner}/{repo}/actions/secrets/{secret_name}"],
|
|
getRepoVariable: ["GET /repos/{owner}/{repo}/actions/variables/{name}"],
|
|
getReviewsForRun: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/approvals"
|
|
],
|
|
getSelfHostedRunnerForOrg: ["GET /orgs/{org}/actions/runners/{runner_id}"],
|
|
getSelfHostedRunnerForRepo: [
|
|
"GET /repos/{owner}/{repo}/actions/runners/{runner_id}"
|
|
],
|
|
getWorkflow: ["GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}"],
|
|
getWorkflowAccessToRepository: [
|
|
"GET /repos/{owner}/{repo}/actions/permissions/access"
|
|
],
|
|
getWorkflowRun: ["GET /repos/{owner}/{repo}/actions/runs/{run_id}"],
|
|
getWorkflowRunAttempt: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}"
|
|
],
|
|
getWorkflowRunUsage: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/timing"
|
|
],
|
|
getWorkflowUsage: [
|
|
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing"
|
|
],
|
|
listArtifactsForRepo: ["GET /repos/{owner}/{repo}/actions/artifacts"],
|
|
listEnvironmentSecrets: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/secrets"
|
|
],
|
|
listEnvironmentVariables: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/variables"
|
|
],
|
|
listGithubHostedRunnersInGroupForOrg: [
|
|
"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/hosted-runners"
|
|
],
|
|
listHostedRunnersForOrg: ["GET /orgs/{org}/actions/hosted-runners"],
|
|
listJobsForWorkflowRun: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs"
|
|
],
|
|
listJobsForWorkflowRunAttempt: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs"
|
|
],
|
|
listLabelsForSelfHostedRunnerForOrg: [
|
|
"GET /orgs/{org}/actions/runners/{runner_id}/labels"
|
|
],
|
|
listLabelsForSelfHostedRunnerForRepo: [
|
|
"GET /repos/{owner}/{repo}/actions/runners/{runner_id}/labels"
|
|
],
|
|
listOrgSecrets: ["GET /orgs/{org}/actions/secrets"],
|
|
listOrgVariables: ["GET /orgs/{org}/actions/variables"],
|
|
listRepoOrganizationSecrets: [
|
|
"GET /repos/{owner}/{repo}/actions/organization-secrets"
|
|
],
|
|
listRepoOrganizationVariables: [
|
|
"GET /repos/{owner}/{repo}/actions/organization-variables"
|
|
],
|
|
listRepoSecrets: ["GET /repos/{owner}/{repo}/actions/secrets"],
|
|
listRepoVariables: ["GET /repos/{owner}/{repo}/actions/variables"],
|
|
listRepoWorkflows: ["GET /repos/{owner}/{repo}/actions/workflows"],
|
|
listRunnerApplicationsForOrg: ["GET /orgs/{org}/actions/runners/downloads"],
|
|
listRunnerApplicationsForRepo: [
|
|
"GET /repos/{owner}/{repo}/actions/runners/downloads"
|
|
],
|
|
listSelectedReposForOrgSecret: [
|
|
"GET /orgs/{org}/actions/secrets/{secret_name}/repositories"
|
|
],
|
|
listSelectedReposForOrgVariable: [
|
|
"GET /orgs/{org}/actions/variables/{name}/repositories"
|
|
],
|
|
listSelectedRepositoriesEnabledGithubActionsOrganization: [
|
|
"GET /orgs/{org}/actions/permissions/repositories"
|
|
],
|
|
listSelfHostedRunnersForOrg: ["GET /orgs/{org}/actions/runners"],
|
|
listSelfHostedRunnersForRepo: ["GET /repos/{owner}/{repo}/actions/runners"],
|
|
listWorkflowRunArtifacts: [
|
|
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts"
|
|
],
|
|
listWorkflowRuns: [
|
|
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs"
|
|
],
|
|
listWorkflowRunsForRepo: ["GET /repos/{owner}/{repo}/actions/runs"],
|
|
reRunJobForWorkflowRun: [
|
|
"POST /repos/{owner}/{repo}/actions/jobs/{job_id}/rerun"
|
|
],
|
|
reRunWorkflow: ["POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun"],
|
|
reRunWorkflowFailedJobs: [
|
|
"POST /repos/{owner}/{repo}/actions/runs/{run_id}/rerun-failed-jobs"
|
|
],
|
|
removeAllCustomLabelsFromSelfHostedRunnerForOrg: [
|
|
"DELETE /orgs/{org}/actions/runners/{runner_id}/labels"
|
|
],
|
|
removeAllCustomLabelsFromSelfHostedRunnerForRepo: [
|
|
"DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}/labels"
|
|
],
|
|
removeCustomLabelFromSelfHostedRunnerForOrg: [
|
|
"DELETE /orgs/{org}/actions/runners/{runner_id}/labels/{name}"
|
|
],
|
|
removeCustomLabelFromSelfHostedRunnerForRepo: [
|
|
"DELETE /repos/{owner}/{repo}/actions/runners/{runner_id}/labels/{name}"
|
|
],
|
|
removeSelectedRepoFromOrgSecret: [
|
|
"DELETE /orgs/{org}/actions/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
removeSelectedRepoFromOrgVariable: [
|
|
"DELETE /orgs/{org}/actions/variables/{name}/repositories/{repository_id}"
|
|
],
|
|
reviewCustomGatesForRun: [
|
|
"POST /repos/{owner}/{repo}/actions/runs/{run_id}/deployment_protection_rule"
|
|
],
|
|
reviewPendingDeploymentsForRun: [
|
|
"POST /repos/{owner}/{repo}/actions/runs/{run_id}/pending_deployments"
|
|
],
|
|
setAllowedActionsOrganization: [
|
|
"PUT /orgs/{org}/actions/permissions/selected-actions"
|
|
],
|
|
setAllowedActionsRepository: [
|
|
"PUT /repos/{owner}/{repo}/actions/permissions/selected-actions"
|
|
],
|
|
setCustomLabelsForSelfHostedRunnerForOrg: [
|
|
"PUT /orgs/{org}/actions/runners/{runner_id}/labels"
|
|
],
|
|
setCustomLabelsForSelfHostedRunnerForRepo: [
|
|
"PUT /repos/{owner}/{repo}/actions/runners/{runner_id}/labels"
|
|
],
|
|
setCustomOidcSubClaimForRepo: [
|
|
"PUT /repos/{owner}/{repo}/actions/oidc/customization/sub"
|
|
],
|
|
setGithubActionsDefaultWorkflowPermissionsOrganization: [
|
|
"PUT /orgs/{org}/actions/permissions/workflow"
|
|
],
|
|
setGithubActionsDefaultWorkflowPermissionsRepository: [
|
|
"PUT /repos/{owner}/{repo}/actions/permissions/workflow"
|
|
],
|
|
setGithubActionsPermissionsOrganization: [
|
|
"PUT /orgs/{org}/actions/permissions"
|
|
],
|
|
setGithubActionsPermissionsRepository: [
|
|
"PUT /repos/{owner}/{repo}/actions/permissions"
|
|
],
|
|
setSelectedReposForOrgSecret: [
|
|
"PUT /orgs/{org}/actions/secrets/{secret_name}/repositories"
|
|
],
|
|
setSelectedReposForOrgVariable: [
|
|
"PUT /orgs/{org}/actions/variables/{name}/repositories"
|
|
],
|
|
setSelectedRepositoriesEnabledGithubActionsOrganization: [
|
|
"PUT /orgs/{org}/actions/permissions/repositories"
|
|
],
|
|
setWorkflowAccessToRepository: [
|
|
"PUT /repos/{owner}/{repo}/actions/permissions/access"
|
|
],
|
|
updateEnvironmentVariable: [
|
|
"PATCH /repos/{owner}/{repo}/environments/{environment_name}/variables/{name}"
|
|
],
|
|
updateHostedRunnerForOrg: [
|
|
"PATCH /orgs/{org}/actions/hosted-runners/{hosted_runner_id}"
|
|
],
|
|
updateOrgVariable: ["PATCH /orgs/{org}/actions/variables/{name}"],
|
|
updateRepoVariable: [
|
|
"PATCH /repos/{owner}/{repo}/actions/variables/{name}"
|
|
]
|
|
},
|
|
activity: {
|
|
checkRepoIsStarredByAuthenticatedUser: ["GET /user/starred/{owner}/{repo}"],
|
|
deleteRepoSubscription: ["DELETE /repos/{owner}/{repo}/subscription"],
|
|
deleteThreadSubscription: [
|
|
"DELETE /notifications/threads/{thread_id}/subscription"
|
|
],
|
|
getFeeds: ["GET /feeds"],
|
|
getRepoSubscription: ["GET /repos/{owner}/{repo}/subscription"],
|
|
getThread: ["GET /notifications/threads/{thread_id}"],
|
|
getThreadSubscriptionForAuthenticatedUser: [
|
|
"GET /notifications/threads/{thread_id}/subscription"
|
|
],
|
|
listEventsForAuthenticatedUser: ["GET /users/{username}/events"],
|
|
listNotificationsForAuthenticatedUser: ["GET /notifications"],
|
|
listOrgEventsForAuthenticatedUser: [
|
|
"GET /users/{username}/events/orgs/{org}"
|
|
],
|
|
listPublicEvents: ["GET /events"],
|
|
listPublicEventsForRepoNetwork: ["GET /networks/{owner}/{repo}/events"],
|
|
listPublicEventsForUser: ["GET /users/{username}/events/public"],
|
|
listPublicOrgEvents: ["GET /orgs/{org}/events"],
|
|
listReceivedEventsForUser: ["GET /users/{username}/received_events"],
|
|
listReceivedPublicEventsForUser: [
|
|
"GET /users/{username}/received_events/public"
|
|
],
|
|
listRepoEvents: ["GET /repos/{owner}/{repo}/events"],
|
|
listRepoNotificationsForAuthenticatedUser: [
|
|
"GET /repos/{owner}/{repo}/notifications"
|
|
],
|
|
listReposStarredByAuthenticatedUser: ["GET /user/starred"],
|
|
listReposStarredByUser: ["GET /users/{username}/starred"],
|
|
listReposWatchedByUser: ["GET /users/{username}/subscriptions"],
|
|
listStargazersForRepo: ["GET /repos/{owner}/{repo}/stargazers"],
|
|
listWatchedReposForAuthenticatedUser: ["GET /user/subscriptions"],
|
|
listWatchersForRepo: ["GET /repos/{owner}/{repo}/subscribers"],
|
|
markNotificationsAsRead: ["PUT /notifications"],
|
|
markRepoNotificationsAsRead: ["PUT /repos/{owner}/{repo}/notifications"],
|
|
markThreadAsDone: ["DELETE /notifications/threads/{thread_id}"],
|
|
markThreadAsRead: ["PATCH /notifications/threads/{thread_id}"],
|
|
setRepoSubscription: ["PUT /repos/{owner}/{repo}/subscription"],
|
|
setThreadSubscription: [
|
|
"PUT /notifications/threads/{thread_id}/subscription"
|
|
],
|
|
starRepoForAuthenticatedUser: ["PUT /user/starred/{owner}/{repo}"],
|
|
unstarRepoForAuthenticatedUser: ["DELETE /user/starred/{owner}/{repo}"]
|
|
},
|
|
apps: {
|
|
addRepoToInstallation: [
|
|
"PUT /user/installations/{installation_id}/repositories/{repository_id}",
|
|
{},
|
|
{ renamed: ["apps", "addRepoToInstallationForAuthenticatedUser"] }
|
|
],
|
|
addRepoToInstallationForAuthenticatedUser: [
|
|
"PUT /user/installations/{installation_id}/repositories/{repository_id}"
|
|
],
|
|
checkToken: ["POST /applications/{client_id}/token"],
|
|
createFromManifest: ["POST /app-manifests/{code}/conversions"],
|
|
createInstallationAccessToken: [
|
|
"POST /app/installations/{installation_id}/access_tokens"
|
|
],
|
|
deleteAuthorization: ["DELETE /applications/{client_id}/grant"],
|
|
deleteInstallation: ["DELETE /app/installations/{installation_id}"],
|
|
deleteToken: ["DELETE /applications/{client_id}/token"],
|
|
getAuthenticated: ["GET /app"],
|
|
getBySlug: ["GET /apps/{app_slug}"],
|
|
getInstallation: ["GET /app/installations/{installation_id}"],
|
|
getOrgInstallation: ["GET /orgs/{org}/installation"],
|
|
getRepoInstallation: ["GET /repos/{owner}/{repo}/installation"],
|
|
getSubscriptionPlanForAccount: [
|
|
"GET /marketplace_listing/accounts/{account_id}"
|
|
],
|
|
getSubscriptionPlanForAccountStubbed: [
|
|
"GET /marketplace_listing/stubbed/accounts/{account_id}"
|
|
],
|
|
getUserInstallation: ["GET /users/{username}/installation"],
|
|
getWebhookConfigForApp: ["GET /app/hook/config"],
|
|
getWebhookDelivery: ["GET /app/hook/deliveries/{delivery_id}"],
|
|
listAccountsForPlan: ["GET /marketplace_listing/plans/{plan_id}/accounts"],
|
|
listAccountsForPlanStubbed: [
|
|
"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts"
|
|
],
|
|
listInstallationReposForAuthenticatedUser: [
|
|
"GET /user/installations/{installation_id}/repositories"
|
|
],
|
|
listInstallationRequestsForAuthenticatedApp: [
|
|
"GET /app/installation-requests"
|
|
],
|
|
listInstallations: ["GET /app/installations"],
|
|
listInstallationsForAuthenticatedUser: ["GET /user/installations"],
|
|
listPlans: ["GET /marketplace_listing/plans"],
|
|
listPlansStubbed: ["GET /marketplace_listing/stubbed/plans"],
|
|
listReposAccessibleToInstallation: ["GET /installation/repositories"],
|
|
listSubscriptionsForAuthenticatedUser: ["GET /user/marketplace_purchases"],
|
|
listSubscriptionsForAuthenticatedUserStubbed: [
|
|
"GET /user/marketplace_purchases/stubbed"
|
|
],
|
|
listWebhookDeliveries: ["GET /app/hook/deliveries"],
|
|
redeliverWebhookDelivery: [
|
|
"POST /app/hook/deliveries/{delivery_id}/attempts"
|
|
],
|
|
removeRepoFromInstallation: [
|
|
"DELETE /user/installations/{installation_id}/repositories/{repository_id}",
|
|
{},
|
|
{ renamed: ["apps", "removeRepoFromInstallationForAuthenticatedUser"] }
|
|
],
|
|
removeRepoFromInstallationForAuthenticatedUser: [
|
|
"DELETE /user/installations/{installation_id}/repositories/{repository_id}"
|
|
],
|
|
resetToken: ["PATCH /applications/{client_id}/token"],
|
|
revokeInstallationAccessToken: ["DELETE /installation/token"],
|
|
scopeToken: ["POST /applications/{client_id}/token/scoped"],
|
|
suspendInstallation: ["PUT /app/installations/{installation_id}/suspended"],
|
|
unsuspendInstallation: [
|
|
"DELETE /app/installations/{installation_id}/suspended"
|
|
],
|
|
updateWebhookConfigForApp: ["PATCH /app/hook/config"]
|
|
},
|
|
billing: {
|
|
getGithubActionsBillingOrg: ["GET /orgs/{org}/settings/billing/actions"],
|
|
getGithubActionsBillingUser: [
|
|
"GET /users/{username}/settings/billing/actions"
|
|
],
|
|
getGithubBillingUsageReportOrg: [
|
|
"GET /organizations/{org}/settings/billing/usage"
|
|
],
|
|
getGithubBillingUsageReportUser: [
|
|
"GET /users/{username}/settings/billing/usage"
|
|
],
|
|
getGithubPackagesBillingOrg: ["GET /orgs/{org}/settings/billing/packages"],
|
|
getGithubPackagesBillingUser: [
|
|
"GET /users/{username}/settings/billing/packages"
|
|
],
|
|
getSharedStorageBillingOrg: [
|
|
"GET /orgs/{org}/settings/billing/shared-storage"
|
|
],
|
|
getSharedStorageBillingUser: [
|
|
"GET /users/{username}/settings/billing/shared-storage"
|
|
]
|
|
},
|
|
campaigns: {
|
|
createCampaign: ["POST /orgs/{org}/campaigns"],
|
|
deleteCampaign: ["DELETE /orgs/{org}/campaigns/{campaign_number}"],
|
|
getCampaignSummary: ["GET /orgs/{org}/campaigns/{campaign_number}"],
|
|
listOrgCampaigns: ["GET /orgs/{org}/campaigns"],
|
|
updateCampaign: ["PATCH /orgs/{org}/campaigns/{campaign_number}"]
|
|
},
|
|
checks: {
|
|
create: ["POST /repos/{owner}/{repo}/check-runs"],
|
|
createSuite: ["POST /repos/{owner}/{repo}/check-suites"],
|
|
get: ["GET /repos/{owner}/{repo}/check-runs/{check_run_id}"],
|
|
getSuite: ["GET /repos/{owner}/{repo}/check-suites/{check_suite_id}"],
|
|
listAnnotations: [
|
|
"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations"
|
|
],
|
|
listForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/check-runs"],
|
|
listForSuite: [
|
|
"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs"
|
|
],
|
|
listSuitesForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/check-suites"],
|
|
rerequestRun: [
|
|
"POST /repos/{owner}/{repo}/check-runs/{check_run_id}/rerequest"
|
|
],
|
|
rerequestSuite: [
|
|
"POST /repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest"
|
|
],
|
|
setSuitesPreferences: [
|
|
"PATCH /repos/{owner}/{repo}/check-suites/preferences"
|
|
],
|
|
update: ["PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}"]
|
|
},
|
|
codeScanning: {
|
|
commitAutofix: [
|
|
"POST /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix/commits"
|
|
],
|
|
createAutofix: [
|
|
"POST /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix"
|
|
],
|
|
createVariantAnalysis: [
|
|
"POST /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses"
|
|
],
|
|
deleteAnalysis: [
|
|
"DELETE /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}{?confirm_delete}"
|
|
],
|
|
deleteCodeqlDatabase: [
|
|
"DELETE /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}"
|
|
],
|
|
getAlert: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}",
|
|
{},
|
|
{ renamedParameters: { alert_id: "alert_number" } }
|
|
],
|
|
getAnalysis: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}"
|
|
],
|
|
getAutofix: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix"
|
|
],
|
|
getCodeqlDatabase: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}"
|
|
],
|
|
getDefaultSetup: ["GET /repos/{owner}/{repo}/code-scanning/default-setup"],
|
|
getSarif: ["GET /repos/{owner}/{repo}/code-scanning/sarifs/{sarif_id}"],
|
|
getVariantAnalysis: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}"
|
|
],
|
|
getVariantAnalysisRepoTask: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses/{codeql_variant_analysis_id}/repos/{repo_owner}/{repo_name}"
|
|
],
|
|
listAlertInstances: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances"
|
|
],
|
|
listAlertsForOrg: ["GET /orgs/{org}/code-scanning/alerts"],
|
|
listAlertsForRepo: ["GET /repos/{owner}/{repo}/code-scanning/alerts"],
|
|
listAlertsInstances: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances",
|
|
{},
|
|
{ renamed: ["codeScanning", "listAlertInstances"] }
|
|
],
|
|
listCodeqlDatabases: [
|
|
"GET /repos/{owner}/{repo}/code-scanning/codeql/databases"
|
|
],
|
|
listRecentAnalyses: ["GET /repos/{owner}/{repo}/code-scanning/analyses"],
|
|
updateAlert: [
|
|
"PATCH /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}"
|
|
],
|
|
updateDefaultSetup: [
|
|
"PATCH /repos/{owner}/{repo}/code-scanning/default-setup"
|
|
],
|
|
uploadSarif: ["POST /repos/{owner}/{repo}/code-scanning/sarifs"]
|
|
},
|
|
codeSecurity: {
|
|
attachConfiguration: [
|
|
"POST /orgs/{org}/code-security/configurations/{configuration_id}/attach"
|
|
],
|
|
attachEnterpriseConfiguration: [
|
|
"POST /enterprises/{enterprise}/code-security/configurations/{configuration_id}/attach"
|
|
],
|
|
createConfiguration: ["POST /orgs/{org}/code-security/configurations"],
|
|
createConfigurationForEnterprise: [
|
|
"POST /enterprises/{enterprise}/code-security/configurations"
|
|
],
|
|
deleteConfiguration: [
|
|
"DELETE /orgs/{org}/code-security/configurations/{configuration_id}"
|
|
],
|
|
deleteConfigurationForEnterprise: [
|
|
"DELETE /enterprises/{enterprise}/code-security/configurations/{configuration_id}"
|
|
],
|
|
detachConfiguration: [
|
|
"DELETE /orgs/{org}/code-security/configurations/detach"
|
|
],
|
|
getConfiguration: [
|
|
"GET /orgs/{org}/code-security/configurations/{configuration_id}"
|
|
],
|
|
getConfigurationForRepository: [
|
|
"GET /repos/{owner}/{repo}/code-security-configuration"
|
|
],
|
|
getConfigurationsForEnterprise: [
|
|
"GET /enterprises/{enterprise}/code-security/configurations"
|
|
],
|
|
getConfigurationsForOrg: ["GET /orgs/{org}/code-security/configurations"],
|
|
getDefaultConfigurations: [
|
|
"GET /orgs/{org}/code-security/configurations/defaults"
|
|
],
|
|
getDefaultConfigurationsForEnterprise: [
|
|
"GET /enterprises/{enterprise}/code-security/configurations/defaults"
|
|
],
|
|
getRepositoriesForConfiguration: [
|
|
"GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories"
|
|
],
|
|
getRepositoriesForEnterpriseConfiguration: [
|
|
"GET /enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories"
|
|
],
|
|
getSingleConfigurationForEnterprise: [
|
|
"GET /enterprises/{enterprise}/code-security/configurations/{configuration_id}"
|
|
],
|
|
setConfigurationAsDefault: [
|
|
"PUT /orgs/{org}/code-security/configurations/{configuration_id}/defaults"
|
|
],
|
|
setConfigurationAsDefaultForEnterprise: [
|
|
"PUT /enterprises/{enterprise}/code-security/configurations/{configuration_id}/defaults"
|
|
],
|
|
updateConfiguration: [
|
|
"PATCH /orgs/{org}/code-security/configurations/{configuration_id}"
|
|
],
|
|
updateEnterpriseConfiguration: [
|
|
"PATCH /enterprises/{enterprise}/code-security/configurations/{configuration_id}"
|
|
]
|
|
},
|
|
codesOfConduct: {
|
|
getAllCodesOfConduct: ["GET /codes_of_conduct"],
|
|
getConductCode: ["GET /codes_of_conduct/{key}"]
|
|
},
|
|
codespaces: {
|
|
addRepositoryForSecretForAuthenticatedUser: [
|
|
"PUT /user/codespaces/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
addSelectedRepoToOrgSecret: [
|
|
"PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
checkPermissionsForDevcontainer: [
|
|
"GET /repos/{owner}/{repo}/codespaces/permissions_check"
|
|
],
|
|
codespaceMachinesForAuthenticatedUser: [
|
|
"GET /user/codespaces/{codespace_name}/machines"
|
|
],
|
|
createForAuthenticatedUser: ["POST /user/codespaces"],
|
|
createOrUpdateOrgSecret: [
|
|
"PUT /orgs/{org}/codespaces/secrets/{secret_name}"
|
|
],
|
|
createOrUpdateRepoSecret: [
|
|
"PUT /repos/{owner}/{repo}/codespaces/secrets/{secret_name}"
|
|
],
|
|
createOrUpdateSecretForAuthenticatedUser: [
|
|
"PUT /user/codespaces/secrets/{secret_name}"
|
|
],
|
|
createWithPrForAuthenticatedUser: [
|
|
"POST /repos/{owner}/{repo}/pulls/{pull_number}/codespaces"
|
|
],
|
|
createWithRepoForAuthenticatedUser: [
|
|
"POST /repos/{owner}/{repo}/codespaces"
|
|
],
|
|
deleteForAuthenticatedUser: ["DELETE /user/codespaces/{codespace_name}"],
|
|
deleteFromOrganization: [
|
|
"DELETE /orgs/{org}/members/{username}/codespaces/{codespace_name}"
|
|
],
|
|
deleteOrgSecret: ["DELETE /orgs/{org}/codespaces/secrets/{secret_name}"],
|
|
deleteRepoSecret: [
|
|
"DELETE /repos/{owner}/{repo}/codespaces/secrets/{secret_name}"
|
|
],
|
|
deleteSecretForAuthenticatedUser: [
|
|
"DELETE /user/codespaces/secrets/{secret_name}"
|
|
],
|
|
exportForAuthenticatedUser: [
|
|
"POST /user/codespaces/{codespace_name}/exports"
|
|
],
|
|
getCodespacesForUserInOrg: [
|
|
"GET /orgs/{org}/members/{username}/codespaces"
|
|
],
|
|
getExportDetailsForAuthenticatedUser: [
|
|
"GET /user/codespaces/{codespace_name}/exports/{export_id}"
|
|
],
|
|
getForAuthenticatedUser: ["GET /user/codespaces/{codespace_name}"],
|
|
getOrgPublicKey: ["GET /orgs/{org}/codespaces/secrets/public-key"],
|
|
getOrgSecret: ["GET /orgs/{org}/codespaces/secrets/{secret_name}"],
|
|
getPublicKeyForAuthenticatedUser: [
|
|
"GET /user/codespaces/secrets/public-key"
|
|
],
|
|
getRepoPublicKey: [
|
|
"GET /repos/{owner}/{repo}/codespaces/secrets/public-key"
|
|
],
|
|
getRepoSecret: [
|
|
"GET /repos/{owner}/{repo}/codespaces/secrets/{secret_name}"
|
|
],
|
|
getSecretForAuthenticatedUser: [
|
|
"GET /user/codespaces/secrets/{secret_name}"
|
|
],
|
|
listDevcontainersInRepositoryForAuthenticatedUser: [
|
|
"GET /repos/{owner}/{repo}/codespaces/devcontainers"
|
|
],
|
|
listForAuthenticatedUser: ["GET /user/codespaces"],
|
|
listInOrganization: [
|
|
"GET /orgs/{org}/codespaces",
|
|
{},
|
|
{ renamedParameters: { org_id: "org" } }
|
|
],
|
|
listInRepositoryForAuthenticatedUser: [
|
|
"GET /repos/{owner}/{repo}/codespaces"
|
|
],
|
|
listOrgSecrets: ["GET /orgs/{org}/codespaces/secrets"],
|
|
listRepoSecrets: ["GET /repos/{owner}/{repo}/codespaces/secrets"],
|
|
listRepositoriesForSecretForAuthenticatedUser: [
|
|
"GET /user/codespaces/secrets/{secret_name}/repositories"
|
|
],
|
|
listSecretsForAuthenticatedUser: ["GET /user/codespaces/secrets"],
|
|
listSelectedReposForOrgSecret: [
|
|
"GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories"
|
|
],
|
|
preFlightWithRepoForAuthenticatedUser: [
|
|
"GET /repos/{owner}/{repo}/codespaces/new"
|
|
],
|
|
publishForAuthenticatedUser: [
|
|
"POST /user/codespaces/{codespace_name}/publish"
|
|
],
|
|
removeRepositoryForSecretForAuthenticatedUser: [
|
|
"DELETE /user/codespaces/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
removeSelectedRepoFromOrgSecret: [
|
|
"DELETE /orgs/{org}/codespaces/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
repoMachinesForAuthenticatedUser: [
|
|
"GET /repos/{owner}/{repo}/codespaces/machines"
|
|
],
|
|
setRepositoriesForSecretForAuthenticatedUser: [
|
|
"PUT /user/codespaces/secrets/{secret_name}/repositories"
|
|
],
|
|
setSelectedReposForOrgSecret: [
|
|
"PUT /orgs/{org}/codespaces/secrets/{secret_name}/repositories"
|
|
],
|
|
startForAuthenticatedUser: ["POST /user/codespaces/{codespace_name}/start"],
|
|
stopForAuthenticatedUser: ["POST /user/codespaces/{codespace_name}/stop"],
|
|
stopInOrganization: [
|
|
"POST /orgs/{org}/members/{username}/codespaces/{codespace_name}/stop"
|
|
],
|
|
updateForAuthenticatedUser: ["PATCH /user/codespaces/{codespace_name}"]
|
|
},
|
|
copilot: {
|
|
addCopilotSeatsForTeams: [
|
|
"POST /orgs/{org}/copilot/billing/selected_teams"
|
|
],
|
|
addCopilotSeatsForUsers: [
|
|
"POST /orgs/{org}/copilot/billing/selected_users"
|
|
],
|
|
cancelCopilotSeatAssignmentForTeams: [
|
|
"DELETE /orgs/{org}/copilot/billing/selected_teams"
|
|
],
|
|
cancelCopilotSeatAssignmentForUsers: [
|
|
"DELETE /orgs/{org}/copilot/billing/selected_users"
|
|
],
|
|
copilotMetricsForOrganization: ["GET /orgs/{org}/copilot/metrics"],
|
|
copilotMetricsForTeam: ["GET /orgs/{org}/team/{team_slug}/copilot/metrics"],
|
|
getCopilotOrganizationDetails: ["GET /orgs/{org}/copilot/billing"],
|
|
getCopilotSeatDetailsForUser: [
|
|
"GET /orgs/{org}/members/{username}/copilot"
|
|
],
|
|
listCopilotSeats: ["GET /orgs/{org}/copilot/billing/seats"]
|
|
},
|
|
credentials: { revoke: ["POST /credentials/revoke"] },
|
|
dependabot: {
|
|
addSelectedRepoToOrgSecret: [
|
|
"PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
createOrUpdateOrgSecret: [
|
|
"PUT /orgs/{org}/dependabot/secrets/{secret_name}"
|
|
],
|
|
createOrUpdateRepoSecret: [
|
|
"PUT /repos/{owner}/{repo}/dependabot/secrets/{secret_name}"
|
|
],
|
|
deleteOrgSecret: ["DELETE /orgs/{org}/dependabot/secrets/{secret_name}"],
|
|
deleteRepoSecret: [
|
|
"DELETE /repos/{owner}/{repo}/dependabot/secrets/{secret_name}"
|
|
],
|
|
getAlert: ["GET /repos/{owner}/{repo}/dependabot/alerts/{alert_number}"],
|
|
getOrgPublicKey: ["GET /orgs/{org}/dependabot/secrets/public-key"],
|
|
getOrgSecret: ["GET /orgs/{org}/dependabot/secrets/{secret_name}"],
|
|
getRepoPublicKey: [
|
|
"GET /repos/{owner}/{repo}/dependabot/secrets/public-key"
|
|
],
|
|
getRepoSecret: [
|
|
"GET /repos/{owner}/{repo}/dependabot/secrets/{secret_name}"
|
|
],
|
|
listAlertsForEnterprise: [
|
|
"GET /enterprises/{enterprise}/dependabot/alerts"
|
|
],
|
|
listAlertsForOrg: ["GET /orgs/{org}/dependabot/alerts"],
|
|
listAlertsForRepo: ["GET /repos/{owner}/{repo}/dependabot/alerts"],
|
|
listOrgSecrets: ["GET /orgs/{org}/dependabot/secrets"],
|
|
listRepoSecrets: ["GET /repos/{owner}/{repo}/dependabot/secrets"],
|
|
listSelectedReposForOrgSecret: [
|
|
"GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories"
|
|
],
|
|
removeSelectedRepoFromOrgSecret: [
|
|
"DELETE /orgs/{org}/dependabot/secrets/{secret_name}/repositories/{repository_id}"
|
|
],
|
|
repositoryAccessForOrg: [
|
|
"GET /organizations/{org}/dependabot/repository-access"
|
|
],
|
|
setRepositoryAccessDefaultLevel: [
|
|
"PUT /organizations/{org}/dependabot/repository-access/default-level"
|
|
],
|
|
setSelectedReposForOrgSecret: [
|
|
"PUT /orgs/{org}/dependabot/secrets/{secret_name}/repositories"
|
|
],
|
|
updateAlert: [
|
|
"PATCH /repos/{owner}/{repo}/dependabot/alerts/{alert_number}"
|
|
],
|
|
updateRepositoryAccessForOrg: [
|
|
"PATCH /organizations/{org}/dependabot/repository-access"
|
|
]
|
|
},
|
|
dependencyGraph: {
|
|
createRepositorySnapshot: [
|
|
"POST /repos/{owner}/{repo}/dependency-graph/snapshots"
|
|
],
|
|
diffRange: [
|
|
"GET /repos/{owner}/{repo}/dependency-graph/compare/{basehead}"
|
|
],
|
|
exportSbom: ["GET /repos/{owner}/{repo}/dependency-graph/sbom"]
|
|
},
|
|
emojis: { get: ["GET /emojis"] },
|
|
gists: {
|
|
checkIsStarred: ["GET /gists/{gist_id}/star"],
|
|
create: ["POST /gists"],
|
|
createComment: ["POST /gists/{gist_id}/comments"],
|
|
delete: ["DELETE /gists/{gist_id}"],
|
|
deleteComment: ["DELETE /gists/{gist_id}/comments/{comment_id}"],
|
|
fork: ["POST /gists/{gist_id}/forks"],
|
|
get: ["GET /gists/{gist_id}"],
|
|
getComment: ["GET /gists/{gist_id}/comments/{comment_id}"],
|
|
getRevision: ["GET /gists/{gist_id}/{sha}"],
|
|
list: ["GET /gists"],
|
|
listComments: ["GET /gists/{gist_id}/comments"],
|
|
listCommits: ["GET /gists/{gist_id}/commits"],
|
|
listForUser: ["GET /users/{username}/gists"],
|
|
listForks: ["GET /gists/{gist_id}/forks"],
|
|
listPublic: ["GET /gists/public"],
|
|
listStarred: ["GET /gists/starred"],
|
|
star: ["PUT /gists/{gist_id}/star"],
|
|
unstar: ["DELETE /gists/{gist_id}/star"],
|
|
update: ["PATCH /gists/{gist_id}"],
|
|
updateComment: ["PATCH /gists/{gist_id}/comments/{comment_id}"]
|
|
},
|
|
git: {
|
|
createBlob: ["POST /repos/{owner}/{repo}/git/blobs"],
|
|
createCommit: ["POST /repos/{owner}/{repo}/git/commits"],
|
|
createRef: ["POST /repos/{owner}/{repo}/git/refs"],
|
|
createTag: ["POST /repos/{owner}/{repo}/git/tags"],
|
|
createTree: ["POST /repos/{owner}/{repo}/git/trees"],
|
|
deleteRef: ["DELETE /repos/{owner}/{repo}/git/refs/{ref}"],
|
|
getBlob: ["GET /repos/{owner}/{repo}/git/blobs/{file_sha}"],
|
|
getCommit: ["GET /repos/{owner}/{repo}/git/commits/{commit_sha}"],
|
|
getRef: ["GET /repos/{owner}/{repo}/git/ref/{ref}"],
|
|
getTag: ["GET /repos/{owner}/{repo}/git/tags/{tag_sha}"],
|
|
getTree: ["GET /repos/{owner}/{repo}/git/trees/{tree_sha}"],
|
|
listMatchingRefs: ["GET /repos/{owner}/{repo}/git/matching-refs/{ref}"],
|
|
updateRef: ["PATCH /repos/{owner}/{repo}/git/refs/{ref}"]
|
|
},
|
|
gitignore: {
|
|
getAllTemplates: ["GET /gitignore/templates"],
|
|
getTemplate: ["GET /gitignore/templates/{name}"]
|
|
},
|
|
hostedCompute: {
|
|
createNetworkConfigurationForOrg: [
|
|
"POST /orgs/{org}/settings/network-configurations"
|
|
],
|
|
deleteNetworkConfigurationFromOrg: [
|
|
"DELETE /orgs/{org}/settings/network-configurations/{network_configuration_id}"
|
|
],
|
|
getNetworkConfigurationForOrg: [
|
|
"GET /orgs/{org}/settings/network-configurations/{network_configuration_id}"
|
|
],
|
|
getNetworkSettingsForOrg: [
|
|
"GET /orgs/{org}/settings/network-settings/{network_settings_id}"
|
|
],
|
|
listNetworkConfigurationsForOrg: [
|
|
"GET /orgs/{org}/settings/network-configurations"
|
|
],
|
|
updateNetworkConfigurationForOrg: [
|
|
"PATCH /orgs/{org}/settings/network-configurations/{network_configuration_id}"
|
|
]
|
|
},
|
|
interactions: {
|
|
getRestrictionsForAuthenticatedUser: ["GET /user/interaction-limits"],
|
|
getRestrictionsForOrg: ["GET /orgs/{org}/interaction-limits"],
|
|
getRestrictionsForRepo: ["GET /repos/{owner}/{repo}/interaction-limits"],
|
|
getRestrictionsForYourPublicRepos: [
|
|
"GET /user/interaction-limits",
|
|
{},
|
|
{ renamed: ["interactions", "getRestrictionsForAuthenticatedUser"] }
|
|
],
|
|
removeRestrictionsForAuthenticatedUser: ["DELETE /user/interaction-limits"],
|
|
removeRestrictionsForOrg: ["DELETE /orgs/{org}/interaction-limits"],
|
|
removeRestrictionsForRepo: [
|
|
"DELETE /repos/{owner}/{repo}/interaction-limits"
|
|
],
|
|
removeRestrictionsForYourPublicRepos: [
|
|
"DELETE /user/interaction-limits",
|
|
{},
|
|
{ renamed: ["interactions", "removeRestrictionsForAuthenticatedUser"] }
|
|
],
|
|
setRestrictionsForAuthenticatedUser: ["PUT /user/interaction-limits"],
|
|
setRestrictionsForOrg: ["PUT /orgs/{org}/interaction-limits"],
|
|
setRestrictionsForRepo: ["PUT /repos/{owner}/{repo}/interaction-limits"],
|
|
setRestrictionsForYourPublicRepos: [
|
|
"PUT /user/interaction-limits",
|
|
{},
|
|
{ renamed: ["interactions", "setRestrictionsForAuthenticatedUser"] }
|
|
]
|
|
},
|
|
issues: {
|
|
addAssignees: [
|
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/assignees"
|
|
],
|
|
addBlockedByDependency: [
|
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by"
|
|
],
|
|
addLabels: ["POST /repos/{owner}/{repo}/issues/{issue_number}/labels"],
|
|
addSubIssue: [
|
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/sub_issues"
|
|
],
|
|
checkUserCanBeAssigned: ["GET /repos/{owner}/{repo}/assignees/{assignee}"],
|
|
checkUserCanBeAssignedToIssue: [
|
|
"GET /repos/{owner}/{repo}/issues/{issue_number}/assignees/{assignee}"
|
|
],
|
|
create: ["POST /repos/{owner}/{repo}/issues"],
|
|
createComment: [
|
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments"
|
|
],
|
|
createLabel: ["POST /repos/{owner}/{repo}/labels"],
|
|
createMilestone: ["POST /repos/{owner}/{repo}/milestones"],
|
|
deleteComment: [
|
|
"DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}"
|
|
],
|
|
deleteLabel: ["DELETE /repos/{owner}/{repo}/labels/{name}"],
|
|
deleteMilestone: [
|
|
"DELETE /repos/{owner}/{repo}/milestones/{milestone_number}"
|
|
],
|
|
get: ["GET /repos/{owner}/{repo}/issues/{issue_number}"],
|
|
getComment: ["GET /repos/{owner}/{repo}/issues/comments/{comment_id}"],
|
|
getEvent: ["GET /repos/{owner}/{repo}/issues/events/{event_id}"],
|
|
getLabel: ["GET /repos/{owner}/{repo}/labels/{name}"],
|
|
getMilestone: ["GET /repos/{owner}/{repo}/milestones/{milestone_number}"],
|
|
getParent: ["GET /repos/{owner}/{repo}/issues/{issue_number}/parent"],
|
|
list: ["GET /issues"],
|
|
listAssignees: ["GET /repos/{owner}/{repo}/assignees"],
|
|
listComments: ["GET /repos/{owner}/{repo}/issues/{issue_number}/comments"],
|
|
listCommentsForRepo: ["GET /repos/{owner}/{repo}/issues/comments"],
|
|
listDependenciesBlockedBy: [
|
|
"GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by"
|
|
],
|
|
listDependenciesBlocking: [
|
|
"GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking"
|
|
],
|
|
listEvents: ["GET /repos/{owner}/{repo}/issues/{issue_number}/events"],
|
|
listEventsForRepo: ["GET /repos/{owner}/{repo}/issues/events"],
|
|
listEventsForTimeline: [
|
|
"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline"
|
|
],
|
|
listForAuthenticatedUser: ["GET /user/issues"],
|
|
listForOrg: ["GET /orgs/{org}/issues"],
|
|
listForRepo: ["GET /repos/{owner}/{repo}/issues"],
|
|
listLabelsForMilestone: [
|
|
"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels"
|
|
],
|
|
listLabelsForRepo: ["GET /repos/{owner}/{repo}/labels"],
|
|
listLabelsOnIssue: [
|
|
"GET /repos/{owner}/{repo}/issues/{issue_number}/labels"
|
|
],
|
|
listMilestones: ["GET /repos/{owner}/{repo}/milestones"],
|
|
listSubIssues: [
|
|
"GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues"
|
|
],
|
|
lock: ["PUT /repos/{owner}/{repo}/issues/{issue_number}/lock"],
|
|
removeAllLabels: [
|
|
"DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels"
|
|
],
|
|
removeAssignees: [
|
|
"DELETE /repos/{owner}/{repo}/issues/{issue_number}/assignees"
|
|
],
|
|
removeDependencyBlockedBy: [
|
|
"DELETE /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by/{issue_id}"
|
|
],
|
|
removeLabel: [
|
|
"DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}"
|
|
],
|
|
removeSubIssue: [
|
|
"DELETE /repos/{owner}/{repo}/issues/{issue_number}/sub_issue"
|
|
],
|
|
reprioritizeSubIssue: [
|
|
"PATCH /repos/{owner}/{repo}/issues/{issue_number}/sub_issues/priority"
|
|
],
|
|
setLabels: ["PUT /repos/{owner}/{repo}/issues/{issue_number}/labels"],
|
|
unlock: ["DELETE /repos/{owner}/{repo}/issues/{issue_number}/lock"],
|
|
update: ["PATCH /repos/{owner}/{repo}/issues/{issue_number}"],
|
|
updateComment: ["PATCH /repos/{owner}/{repo}/issues/comments/{comment_id}"],
|
|
updateLabel: ["PATCH /repos/{owner}/{repo}/labels/{name}"],
|
|
updateMilestone: [
|
|
"PATCH /repos/{owner}/{repo}/milestones/{milestone_number}"
|
|
]
|
|
},
|
|
licenses: {
|
|
get: ["GET /licenses/{license}"],
|
|
getAllCommonlyUsed: ["GET /licenses"],
|
|
getForRepo: ["GET /repos/{owner}/{repo}/license"]
|
|
},
|
|
markdown: {
|
|
render: ["POST /markdown"],
|
|
renderRaw: [
|
|
"POST /markdown/raw",
|
|
{ headers: { "content-type": "text/plain; charset=utf-8" } }
|
|
]
|
|
},
|
|
meta: {
|
|
get: ["GET /meta"],
|
|
getAllVersions: ["GET /versions"],
|
|
getOctocat: ["GET /octocat"],
|
|
getZen: ["GET /zen"],
|
|
root: ["GET /"]
|
|
},
|
|
migrations: {
|
|
deleteArchiveForAuthenticatedUser: [
|
|
"DELETE /user/migrations/{migration_id}/archive"
|
|
],
|
|
deleteArchiveForOrg: [
|
|
"DELETE /orgs/{org}/migrations/{migration_id}/archive"
|
|
],
|
|
downloadArchiveForOrg: [
|
|
"GET /orgs/{org}/migrations/{migration_id}/archive"
|
|
],
|
|
getArchiveForAuthenticatedUser: [
|
|
"GET /user/migrations/{migration_id}/archive"
|
|
],
|
|
getStatusForAuthenticatedUser: ["GET /user/migrations/{migration_id}"],
|
|
getStatusForOrg: ["GET /orgs/{org}/migrations/{migration_id}"],
|
|
listForAuthenticatedUser: ["GET /user/migrations"],
|
|
listForOrg: ["GET /orgs/{org}/migrations"],
|
|
listReposForAuthenticatedUser: [
|
|
"GET /user/migrations/{migration_id}/repositories"
|
|
],
|
|
listReposForOrg: ["GET /orgs/{org}/migrations/{migration_id}/repositories"],
|
|
listReposForUser: [
|
|
"GET /user/migrations/{migration_id}/repositories",
|
|
{},
|
|
{ renamed: ["migrations", "listReposForAuthenticatedUser"] }
|
|
],
|
|
startForAuthenticatedUser: ["POST /user/migrations"],
|
|
startForOrg: ["POST /orgs/{org}/migrations"],
|
|
unlockRepoForAuthenticatedUser: [
|
|
"DELETE /user/migrations/{migration_id}/repos/{repo_name}/lock"
|
|
],
|
|
unlockRepoForOrg: [
|
|
"DELETE /orgs/{org}/migrations/{migration_id}/repos/{repo_name}/lock"
|
|
]
|
|
},
|
|
oidc: {
|
|
getOidcCustomSubTemplateForOrg: [
|
|
"GET /orgs/{org}/actions/oidc/customization/sub"
|
|
],
|
|
updateOidcCustomSubTemplateForOrg: [
|
|
"PUT /orgs/{org}/actions/oidc/customization/sub"
|
|
]
|
|
},
|
|
orgs: {
|
|
addSecurityManagerTeam: [
|
|
"PUT /orgs/{org}/security-managers/teams/{team_slug}",
|
|
{},
|
|
{
|
|
deprecated: "octokit.rest.orgs.addSecurityManagerTeam() is deprecated, see https://docs.github.com/rest/orgs/security-managers#add-a-security-manager-team"
|
|
}
|
|
],
|
|
assignTeamToOrgRole: [
|
|
"PUT /orgs/{org}/organization-roles/teams/{team_slug}/{role_id}"
|
|
],
|
|
assignUserToOrgRole: [
|
|
"PUT /orgs/{org}/organization-roles/users/{username}/{role_id}"
|
|
],
|
|
blockUser: ["PUT /orgs/{org}/blocks/{username}"],
|
|
cancelInvitation: ["DELETE /orgs/{org}/invitations/{invitation_id}"],
|
|
checkBlockedUser: ["GET /orgs/{org}/blocks/{username}"],
|
|
checkMembershipForUser: ["GET /orgs/{org}/members/{username}"],
|
|
checkPublicMembershipForUser: ["GET /orgs/{org}/public_members/{username}"],
|
|
convertMemberToOutsideCollaborator: [
|
|
"PUT /orgs/{org}/outside_collaborators/{username}"
|
|
],
|
|
createArtifactStorageRecord: [
|
|
"POST /orgs/{org}/artifacts/metadata/storage-record"
|
|
],
|
|
createInvitation: ["POST /orgs/{org}/invitations"],
|
|
createIssueType: ["POST /orgs/{org}/issue-types"],
|
|
createOrUpdateCustomProperties: ["PATCH /orgs/{org}/properties/schema"],
|
|
createOrUpdateCustomPropertiesValuesForRepos: [
|
|
"PATCH /orgs/{org}/properties/values"
|
|
],
|
|
createOrUpdateCustomProperty: [
|
|
"PUT /orgs/{org}/properties/schema/{custom_property_name}"
|
|
],
|
|
createWebhook: ["POST /orgs/{org}/hooks"],
|
|
delete: ["DELETE /orgs/{org}"],
|
|
deleteAttestationsBulk: ["POST /orgs/{org}/attestations/delete-request"],
|
|
deleteAttestationsById: [
|
|
"DELETE /orgs/{org}/attestations/{attestation_id}"
|
|
],
|
|
deleteAttestationsBySubjectDigest: [
|
|
"DELETE /orgs/{org}/attestations/digest/{subject_digest}"
|
|
],
|
|
deleteIssueType: ["DELETE /orgs/{org}/issue-types/{issue_type_id}"],
|
|
deleteWebhook: ["DELETE /orgs/{org}/hooks/{hook_id}"],
|
|
get: ["GET /orgs/{org}"],
|
|
getAllCustomProperties: ["GET /orgs/{org}/properties/schema"],
|
|
getCustomProperty: [
|
|
"GET /orgs/{org}/properties/schema/{custom_property_name}"
|
|
],
|
|
getMembershipForAuthenticatedUser: ["GET /user/memberships/orgs/{org}"],
|
|
getMembershipForUser: ["GET /orgs/{org}/memberships/{username}"],
|
|
getOrgRole: ["GET /orgs/{org}/organization-roles/{role_id}"],
|
|
getOrgRulesetHistory: ["GET /orgs/{org}/rulesets/{ruleset_id}/history"],
|
|
getOrgRulesetVersion: [
|
|
"GET /orgs/{org}/rulesets/{ruleset_id}/history/{version_id}"
|
|
],
|
|
getWebhook: ["GET /orgs/{org}/hooks/{hook_id}"],
|
|
getWebhookConfigForOrg: ["GET /orgs/{org}/hooks/{hook_id}/config"],
|
|
getWebhookDelivery: [
|
|
"GET /orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}"
|
|
],
|
|
list: ["GET /organizations"],
|
|
listAppInstallations: ["GET /orgs/{org}/installations"],
|
|
listArtifactStorageRecords: [
|
|
"GET /orgs/{org}/artifacts/{subject_digest}/metadata/storage-records"
|
|
],
|
|
listAttestations: ["GET /orgs/{org}/attestations/{subject_digest}"],
|
|
listAttestationsBulk: [
|
|
"POST /orgs/{org}/attestations/bulk-list{?per_page,before,after}"
|
|
],
|
|
listBlockedUsers: ["GET /orgs/{org}/blocks"],
|
|
listCustomPropertiesValuesForRepos: ["GET /orgs/{org}/properties/values"],
|
|
listFailedInvitations: ["GET /orgs/{org}/failed_invitations"],
|
|
listForAuthenticatedUser: ["GET /user/orgs"],
|
|
listForUser: ["GET /users/{username}/orgs"],
|
|
listInvitationTeams: ["GET /orgs/{org}/invitations/{invitation_id}/teams"],
|
|
listIssueTypes: ["GET /orgs/{org}/issue-types"],
|
|
listMembers: ["GET /orgs/{org}/members"],
|
|
listMembershipsForAuthenticatedUser: ["GET /user/memberships/orgs"],
|
|
listOrgRoleTeams: ["GET /orgs/{org}/organization-roles/{role_id}/teams"],
|
|
listOrgRoleUsers: ["GET /orgs/{org}/organization-roles/{role_id}/users"],
|
|
listOrgRoles: ["GET /orgs/{org}/organization-roles"],
|
|
listOrganizationFineGrainedPermissions: [
|
|
"GET /orgs/{org}/organization-fine-grained-permissions"
|
|
],
|
|
listOutsideCollaborators: ["GET /orgs/{org}/outside_collaborators"],
|
|
listPatGrantRepositories: [
|
|
"GET /orgs/{org}/personal-access-tokens/{pat_id}/repositories"
|
|
],
|
|
listPatGrantRequestRepositories: [
|
|
"GET /orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories"
|
|
],
|
|
listPatGrantRequests: ["GET /orgs/{org}/personal-access-token-requests"],
|
|
listPatGrants: ["GET /orgs/{org}/personal-access-tokens"],
|
|
listPendingInvitations: ["GET /orgs/{org}/invitations"],
|
|
listPublicMembers: ["GET /orgs/{org}/public_members"],
|
|
listSecurityManagerTeams: [
|
|
"GET /orgs/{org}/security-managers",
|
|
{},
|
|
{
|
|
deprecated: "octokit.rest.orgs.listSecurityManagerTeams() is deprecated, see https://docs.github.com/rest/orgs/security-managers#list-security-manager-teams"
|
|
}
|
|
],
|
|
listWebhookDeliveries: ["GET /orgs/{org}/hooks/{hook_id}/deliveries"],
|
|
listWebhooks: ["GET /orgs/{org}/hooks"],
|
|
pingWebhook: ["POST /orgs/{org}/hooks/{hook_id}/pings"],
|
|
redeliverWebhookDelivery: [
|
|
"POST /orgs/{org}/hooks/{hook_id}/deliveries/{delivery_id}/attempts"
|
|
],
|
|
removeCustomProperty: [
|
|
"DELETE /orgs/{org}/properties/schema/{custom_property_name}"
|
|
],
|
|
removeMember: ["DELETE /orgs/{org}/members/{username}"],
|
|
removeMembershipForUser: ["DELETE /orgs/{org}/memberships/{username}"],
|
|
removeOutsideCollaborator: [
|
|
"DELETE /orgs/{org}/outside_collaborators/{username}"
|
|
],
|
|
removePublicMembershipForAuthenticatedUser: [
|
|
"DELETE /orgs/{org}/public_members/{username}"
|
|
],
|
|
removeSecurityManagerTeam: [
|
|
"DELETE /orgs/{org}/security-managers/teams/{team_slug}",
|
|
{},
|
|
{
|
|
deprecated: "octokit.rest.orgs.removeSecurityManagerTeam() is deprecated, see https://docs.github.com/rest/orgs/security-managers#remove-a-security-manager-team"
|
|
}
|
|
],
|
|
reviewPatGrantRequest: [
|
|
"POST /orgs/{org}/personal-access-token-requests/{pat_request_id}"
|
|
],
|
|
reviewPatGrantRequestsInBulk: [
|
|
"POST /orgs/{org}/personal-access-token-requests"
|
|
],
|
|
revokeAllOrgRolesTeam: [
|
|
"DELETE /orgs/{org}/organization-roles/teams/{team_slug}"
|
|
],
|
|
revokeAllOrgRolesUser: [
|
|
"DELETE /orgs/{org}/organization-roles/users/{username}"
|
|
],
|
|
revokeOrgRoleTeam: [
|
|
"DELETE /orgs/{org}/organization-roles/teams/{team_slug}/{role_id}"
|
|
],
|
|
revokeOrgRoleUser: [
|
|
"DELETE /orgs/{org}/organization-roles/users/{username}/{role_id}"
|
|
],
|
|
setMembershipForUser: ["PUT /orgs/{org}/memberships/{username}"],
|
|
setPublicMembershipForAuthenticatedUser: [
|
|
"PUT /orgs/{org}/public_members/{username}"
|
|
],
|
|
unblockUser: ["DELETE /orgs/{org}/blocks/{username}"],
|
|
update: ["PATCH /orgs/{org}"],
|
|
updateIssueType: ["PUT /orgs/{org}/issue-types/{issue_type_id}"],
|
|
updateMembershipForAuthenticatedUser: [
|
|
"PATCH /user/memberships/orgs/{org}"
|
|
],
|
|
updatePatAccess: ["POST /orgs/{org}/personal-access-tokens/{pat_id}"],
|
|
updatePatAccesses: ["POST /orgs/{org}/personal-access-tokens"],
|
|
updateWebhook: ["PATCH /orgs/{org}/hooks/{hook_id}"],
|
|
updateWebhookConfigForOrg: ["PATCH /orgs/{org}/hooks/{hook_id}/config"]
|
|
},
|
|
packages: {
|
|
deletePackageForAuthenticatedUser: [
|
|
"DELETE /user/packages/{package_type}/{package_name}"
|
|
],
|
|
deletePackageForOrg: [
|
|
"DELETE /orgs/{org}/packages/{package_type}/{package_name}"
|
|
],
|
|
deletePackageForUser: [
|
|
"DELETE /users/{username}/packages/{package_type}/{package_name}"
|
|
],
|
|
deletePackageVersionForAuthenticatedUser: [
|
|
"DELETE /user/packages/{package_type}/{package_name}/versions/{package_version_id}"
|
|
],
|
|
deletePackageVersionForOrg: [
|
|
"DELETE /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}"
|
|
],
|
|
deletePackageVersionForUser: [
|
|
"DELETE /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}"
|
|
],
|
|
getAllPackageVersionsForAPackageOwnedByAnOrg: [
|
|
"GET /orgs/{org}/packages/{package_type}/{package_name}/versions",
|
|
{},
|
|
{ renamed: ["packages", "getAllPackageVersionsForPackageOwnedByOrg"] }
|
|
],
|
|
getAllPackageVersionsForAPackageOwnedByTheAuthenticatedUser: [
|
|
"GET /user/packages/{package_type}/{package_name}/versions",
|
|
{},
|
|
{
|
|
renamed: [
|
|
"packages",
|
|
"getAllPackageVersionsForPackageOwnedByAuthenticatedUser"
|
|
]
|
|
}
|
|
],
|
|
getAllPackageVersionsForPackageOwnedByAuthenticatedUser: [
|
|
"GET /user/packages/{package_type}/{package_name}/versions"
|
|
],
|
|
getAllPackageVersionsForPackageOwnedByOrg: [
|
|
"GET /orgs/{org}/packages/{package_type}/{package_name}/versions"
|
|
],
|
|
getAllPackageVersionsForPackageOwnedByUser: [
|
|
"GET /users/{username}/packages/{package_type}/{package_name}/versions"
|
|
],
|
|
getPackageForAuthenticatedUser: [
|
|
"GET /user/packages/{package_type}/{package_name}"
|
|
],
|
|
getPackageForOrganization: [
|
|
"GET /orgs/{org}/packages/{package_type}/{package_name}"
|
|
],
|
|
getPackageForUser: [
|
|
"GET /users/{username}/packages/{package_type}/{package_name}"
|
|
],
|
|
getPackageVersionForAuthenticatedUser: [
|
|
"GET /user/packages/{package_type}/{package_name}/versions/{package_version_id}"
|
|
],
|
|
getPackageVersionForOrganization: [
|
|
"GET /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}"
|
|
],
|
|
getPackageVersionForUser: [
|
|
"GET /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}"
|
|
],
|
|
listDockerMigrationConflictingPackagesForAuthenticatedUser: [
|
|
"GET /user/docker/conflicts"
|
|
],
|
|
listDockerMigrationConflictingPackagesForOrganization: [
|
|
"GET /orgs/{org}/docker/conflicts"
|
|
],
|
|
listDockerMigrationConflictingPackagesForUser: [
|
|
"GET /users/{username}/docker/conflicts"
|
|
],
|
|
listPackagesForAuthenticatedUser: ["GET /user/packages"],
|
|
listPackagesForOrganization: ["GET /orgs/{org}/packages"],
|
|
listPackagesForUser: ["GET /users/{username}/packages"],
|
|
restorePackageForAuthenticatedUser: [
|
|
"POST /user/packages/{package_type}/{package_name}/restore{?token}"
|
|
],
|
|
restorePackageForOrg: [
|
|
"POST /orgs/{org}/packages/{package_type}/{package_name}/restore{?token}"
|
|
],
|
|
restorePackageForUser: [
|
|
"POST /users/{username}/packages/{package_type}/{package_name}/restore{?token}"
|
|
],
|
|
restorePackageVersionForAuthenticatedUser: [
|
|
"POST /user/packages/{package_type}/{package_name}/versions/{package_version_id}/restore"
|
|
],
|
|
restorePackageVersionForOrg: [
|
|
"POST /orgs/{org}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore"
|
|
],
|
|
restorePackageVersionForUser: [
|
|
"POST /users/{username}/packages/{package_type}/{package_name}/versions/{package_version_id}/restore"
|
|
]
|
|
},
|
|
privateRegistries: {
|
|
createOrgPrivateRegistry: ["POST /orgs/{org}/private-registries"],
|
|
deleteOrgPrivateRegistry: [
|
|
"DELETE /orgs/{org}/private-registries/{secret_name}"
|
|
],
|
|
getOrgPrivateRegistry: ["GET /orgs/{org}/private-registries/{secret_name}"],
|
|
getOrgPublicKey: ["GET /orgs/{org}/private-registries/public-key"],
|
|
listOrgPrivateRegistries: ["GET /orgs/{org}/private-registries"],
|
|
updateOrgPrivateRegistry: [
|
|
"PATCH /orgs/{org}/private-registries/{secret_name}"
|
|
]
|
|
},
|
|
projects: {
|
|
addItemForOrg: ["POST /orgs/{org}/projectsV2/{project_number}/items"],
|
|
addItemForUser: ["POST /users/{user_id}/projectsV2/{project_number}/items"],
|
|
deleteItemForOrg: [
|
|
"DELETE /orgs/{org}/projectsV2/{project_number}/items/{item_id}"
|
|
],
|
|
deleteItemForUser: [
|
|
"DELETE /users/{user_id}/projectsV2/{project_number}/items/{item_id}"
|
|
],
|
|
getFieldForOrg: [
|
|
"GET /orgs/{org}/projectsV2/{project_number}/fields/{field_id}"
|
|
],
|
|
getFieldForUser: [
|
|
"GET /users/{user_id}/projectsV2/{project_number}/fields/{field_id}"
|
|
],
|
|
getForOrg: ["GET /orgs/{org}/projectsV2/{project_number}"],
|
|
getForUser: ["GET /users/{user_id}/projectsV2/{project_number}"],
|
|
getOrgItem: ["GET /orgs/{org}/projectsV2/{project_number}/items/{item_id}"],
|
|
getUserItem: [
|
|
"GET /users/{user_id}/projectsV2/{project_number}/items/{item_id}"
|
|
],
|
|
listFieldsForOrg: ["GET /orgs/{org}/projectsV2/{project_number}/fields"],
|
|
listFieldsForUser: [
|
|
"GET /users/{user_id}/projectsV2/{project_number}/fields"
|
|
],
|
|
listForOrg: ["GET /orgs/{org}/projectsV2"],
|
|
listForUser: ["GET /users/{username}/projectsV2"],
|
|
listItemsForOrg: ["GET /orgs/{org}/projectsV2/{project_number}/items"],
|
|
listItemsForUser: [
|
|
"GET /users/{user_id}/projectsV2/{project_number}/items"
|
|
],
|
|
updateItemForOrg: [
|
|
"PATCH /orgs/{org}/projectsV2/{project_number}/items/{item_id}"
|
|
],
|
|
updateItemForUser: [
|
|
"PATCH /users/{user_id}/projectsV2/{project_number}/items/{item_id}"
|
|
]
|
|
},
|
|
pulls: {
|
|
checkIfMerged: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/merge"],
|
|
create: ["POST /repos/{owner}/{repo}/pulls"],
|
|
createReplyForReviewComment: [
|
|
"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies"
|
|
],
|
|
createReview: ["POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews"],
|
|
createReviewComment: [
|
|
"POST /repos/{owner}/{repo}/pulls/{pull_number}/comments"
|
|
],
|
|
deletePendingReview: [
|
|
"DELETE /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}"
|
|
],
|
|
deleteReviewComment: [
|
|
"DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}"
|
|
],
|
|
dismissReview: [
|
|
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals"
|
|
],
|
|
get: ["GET /repos/{owner}/{repo}/pulls/{pull_number}"],
|
|
getReview: [
|
|
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}"
|
|
],
|
|
getReviewComment: ["GET /repos/{owner}/{repo}/pulls/comments/{comment_id}"],
|
|
list: ["GET /repos/{owner}/{repo}/pulls"],
|
|
listCommentsForReview: [
|
|
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments"
|
|
],
|
|
listCommits: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/commits"],
|
|
listFiles: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/files"],
|
|
listRequestedReviewers: [
|
|
"GET /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers"
|
|
],
|
|
listReviewComments: [
|
|
"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments"
|
|
],
|
|
listReviewCommentsForRepo: ["GET /repos/{owner}/{repo}/pulls/comments"],
|
|
listReviews: ["GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews"],
|
|
merge: ["PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge"],
|
|
removeRequestedReviewers: [
|
|
"DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers"
|
|
],
|
|
requestReviewers: [
|
|
"POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers"
|
|
],
|
|
submitReview: [
|
|
"POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events"
|
|
],
|
|
update: ["PATCH /repos/{owner}/{repo}/pulls/{pull_number}"],
|
|
updateBranch: [
|
|
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/update-branch"
|
|
],
|
|
updateReview: [
|
|
"PUT /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}"
|
|
],
|
|
updateReviewComment: [
|
|
"PATCH /repos/{owner}/{repo}/pulls/comments/{comment_id}"
|
|
]
|
|
},
|
|
rateLimit: { get: ["GET /rate_limit"] },
|
|
reactions: {
|
|
createForCommitComment: [
|
|
"POST /repos/{owner}/{repo}/comments/{comment_id}/reactions"
|
|
],
|
|
createForIssue: [
|
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/reactions"
|
|
],
|
|
createForIssueComment: [
|
|
"POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions"
|
|
],
|
|
createForPullRequestReviewComment: [
|
|
"POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions"
|
|
],
|
|
createForRelease: [
|
|
"POST /repos/{owner}/{repo}/releases/{release_id}/reactions"
|
|
],
|
|
createForTeamDiscussionCommentInOrg: [
|
|
"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions"
|
|
],
|
|
createForTeamDiscussionInOrg: [
|
|
"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions"
|
|
],
|
|
deleteForCommitComment: [
|
|
"DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id}"
|
|
],
|
|
deleteForIssue: [
|
|
"DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id}"
|
|
],
|
|
deleteForIssueComment: [
|
|
"DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}"
|
|
],
|
|
deleteForPullRequestComment: [
|
|
"DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id}"
|
|
],
|
|
deleteForRelease: [
|
|
"DELETE /repos/{owner}/{repo}/releases/{release_id}/reactions/{reaction_id}"
|
|
],
|
|
deleteForTeamDiscussion: [
|
|
"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id}"
|
|
],
|
|
deleteForTeamDiscussionComment: [
|
|
"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id}"
|
|
],
|
|
listForCommitComment: [
|
|
"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions"
|
|
],
|
|
listForIssue: ["GET /repos/{owner}/{repo}/issues/{issue_number}/reactions"],
|
|
listForIssueComment: [
|
|
"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions"
|
|
],
|
|
listForPullRequestReviewComment: [
|
|
"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions"
|
|
],
|
|
listForRelease: [
|
|
"GET /repos/{owner}/{repo}/releases/{release_id}/reactions"
|
|
],
|
|
listForTeamDiscussionCommentInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions"
|
|
],
|
|
listForTeamDiscussionInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions"
|
|
]
|
|
},
|
|
repos: {
|
|
acceptInvitation: [
|
|
"PATCH /user/repository_invitations/{invitation_id}",
|
|
{},
|
|
{ renamed: ["repos", "acceptInvitationForAuthenticatedUser"] }
|
|
],
|
|
acceptInvitationForAuthenticatedUser: [
|
|
"PATCH /user/repository_invitations/{invitation_id}"
|
|
],
|
|
addAppAccessRestrictions: [
|
|
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps",
|
|
{},
|
|
{ mapToData: "apps" }
|
|
],
|
|
addCollaborator: ["PUT /repos/{owner}/{repo}/collaborators/{username}"],
|
|
addStatusCheckContexts: [
|
|
"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts",
|
|
{},
|
|
{ mapToData: "contexts" }
|
|
],
|
|
addTeamAccessRestrictions: [
|
|
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams",
|
|
{},
|
|
{ mapToData: "teams" }
|
|
],
|
|
addUserAccessRestrictions: [
|
|
"POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users",
|
|
{},
|
|
{ mapToData: "users" }
|
|
],
|
|
cancelPagesDeployment: [
|
|
"POST /repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}/cancel"
|
|
],
|
|
checkAutomatedSecurityFixes: [
|
|
"GET /repos/{owner}/{repo}/automated-security-fixes"
|
|
],
|
|
checkCollaborator: ["GET /repos/{owner}/{repo}/collaborators/{username}"],
|
|
checkPrivateVulnerabilityReporting: [
|
|
"GET /repos/{owner}/{repo}/private-vulnerability-reporting"
|
|
],
|
|
checkVulnerabilityAlerts: [
|
|
"GET /repos/{owner}/{repo}/vulnerability-alerts"
|
|
],
|
|
codeownersErrors: ["GET /repos/{owner}/{repo}/codeowners/errors"],
|
|
compareCommits: ["GET /repos/{owner}/{repo}/compare/{base}...{head}"],
|
|
compareCommitsWithBasehead: [
|
|
"GET /repos/{owner}/{repo}/compare/{basehead}"
|
|
],
|
|
createAttestation: ["POST /repos/{owner}/{repo}/attestations"],
|
|
createAutolink: ["POST /repos/{owner}/{repo}/autolinks"],
|
|
createCommitComment: [
|
|
"POST /repos/{owner}/{repo}/commits/{commit_sha}/comments"
|
|
],
|
|
createCommitSignatureProtection: [
|
|
"POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures"
|
|
],
|
|
createCommitStatus: ["POST /repos/{owner}/{repo}/statuses/{sha}"],
|
|
createDeployKey: ["POST /repos/{owner}/{repo}/keys"],
|
|
createDeployment: ["POST /repos/{owner}/{repo}/deployments"],
|
|
createDeploymentBranchPolicy: [
|
|
"POST /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies"
|
|
],
|
|
createDeploymentProtectionRule: [
|
|
"POST /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules"
|
|
],
|
|
createDeploymentStatus: [
|
|
"POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses"
|
|
],
|
|
createDispatchEvent: ["POST /repos/{owner}/{repo}/dispatches"],
|
|
createForAuthenticatedUser: ["POST /user/repos"],
|
|
createFork: ["POST /repos/{owner}/{repo}/forks"],
|
|
createInOrg: ["POST /orgs/{org}/repos"],
|
|
createOrUpdateCustomPropertiesValues: [
|
|
"PATCH /repos/{owner}/{repo}/properties/values"
|
|
],
|
|
createOrUpdateEnvironment: [
|
|
"PUT /repos/{owner}/{repo}/environments/{environment_name}"
|
|
],
|
|
createOrUpdateFileContents: ["PUT /repos/{owner}/{repo}/contents/{path}"],
|
|
createOrgRuleset: ["POST /orgs/{org}/rulesets"],
|
|
createPagesDeployment: ["POST /repos/{owner}/{repo}/pages/deployments"],
|
|
createPagesSite: ["POST /repos/{owner}/{repo}/pages"],
|
|
createRelease: ["POST /repos/{owner}/{repo}/releases"],
|
|
createRepoRuleset: ["POST /repos/{owner}/{repo}/rulesets"],
|
|
createUsingTemplate: [
|
|
"POST /repos/{template_owner}/{template_repo}/generate"
|
|
],
|
|
createWebhook: ["POST /repos/{owner}/{repo}/hooks"],
|
|
declineInvitation: [
|
|
"DELETE /user/repository_invitations/{invitation_id}",
|
|
{},
|
|
{ renamed: ["repos", "declineInvitationForAuthenticatedUser"] }
|
|
],
|
|
declineInvitationForAuthenticatedUser: [
|
|
"DELETE /user/repository_invitations/{invitation_id}"
|
|
],
|
|
delete: ["DELETE /repos/{owner}/{repo}"],
|
|
deleteAccessRestrictions: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions"
|
|
],
|
|
deleteAdminBranchProtection: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"
|
|
],
|
|
deleteAnEnvironment: [
|
|
"DELETE /repos/{owner}/{repo}/environments/{environment_name}"
|
|
],
|
|
deleteAutolink: ["DELETE /repos/{owner}/{repo}/autolinks/{autolink_id}"],
|
|
deleteBranchProtection: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection"
|
|
],
|
|
deleteCommitComment: ["DELETE /repos/{owner}/{repo}/comments/{comment_id}"],
|
|
deleteCommitSignatureProtection: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures"
|
|
],
|
|
deleteDeployKey: ["DELETE /repos/{owner}/{repo}/keys/{key_id}"],
|
|
deleteDeployment: [
|
|
"DELETE /repos/{owner}/{repo}/deployments/{deployment_id}"
|
|
],
|
|
deleteDeploymentBranchPolicy: [
|
|
"DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}"
|
|
],
|
|
deleteFile: ["DELETE /repos/{owner}/{repo}/contents/{path}"],
|
|
deleteInvitation: [
|
|
"DELETE /repos/{owner}/{repo}/invitations/{invitation_id}"
|
|
],
|
|
deleteOrgRuleset: ["DELETE /orgs/{org}/rulesets/{ruleset_id}"],
|
|
deletePagesSite: ["DELETE /repos/{owner}/{repo}/pages"],
|
|
deletePullRequestReviewProtection: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"
|
|
],
|
|
deleteRelease: ["DELETE /repos/{owner}/{repo}/releases/{release_id}"],
|
|
deleteReleaseAsset: [
|
|
"DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}"
|
|
],
|
|
deleteRepoRuleset: ["DELETE /repos/{owner}/{repo}/rulesets/{ruleset_id}"],
|
|
deleteWebhook: ["DELETE /repos/{owner}/{repo}/hooks/{hook_id}"],
|
|
disableAutomatedSecurityFixes: [
|
|
"DELETE /repos/{owner}/{repo}/automated-security-fixes"
|
|
],
|
|
disableDeploymentProtectionRule: [
|
|
"DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}"
|
|
],
|
|
disablePrivateVulnerabilityReporting: [
|
|
"DELETE /repos/{owner}/{repo}/private-vulnerability-reporting"
|
|
],
|
|
disableVulnerabilityAlerts: [
|
|
"DELETE /repos/{owner}/{repo}/vulnerability-alerts"
|
|
],
|
|
downloadArchive: [
|
|
"GET /repos/{owner}/{repo}/zipball/{ref}",
|
|
{},
|
|
{ renamed: ["repos", "downloadZipballArchive"] }
|
|
],
|
|
downloadTarballArchive: ["GET /repos/{owner}/{repo}/tarball/{ref}"],
|
|
downloadZipballArchive: ["GET /repos/{owner}/{repo}/zipball/{ref}"],
|
|
enableAutomatedSecurityFixes: [
|
|
"PUT /repos/{owner}/{repo}/automated-security-fixes"
|
|
],
|
|
enablePrivateVulnerabilityReporting: [
|
|
"PUT /repos/{owner}/{repo}/private-vulnerability-reporting"
|
|
],
|
|
enableVulnerabilityAlerts: [
|
|
"PUT /repos/{owner}/{repo}/vulnerability-alerts"
|
|
],
|
|
generateReleaseNotes: [
|
|
"POST /repos/{owner}/{repo}/releases/generate-notes"
|
|
],
|
|
get: ["GET /repos/{owner}/{repo}"],
|
|
getAccessRestrictions: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions"
|
|
],
|
|
getAdminBranchProtection: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"
|
|
],
|
|
getAllDeploymentProtectionRules: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules"
|
|
],
|
|
getAllEnvironments: ["GET /repos/{owner}/{repo}/environments"],
|
|
getAllStatusCheckContexts: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts"
|
|
],
|
|
getAllTopics: ["GET /repos/{owner}/{repo}/topics"],
|
|
getAppsWithAccessToProtectedBranch: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps"
|
|
],
|
|
getAutolink: ["GET /repos/{owner}/{repo}/autolinks/{autolink_id}"],
|
|
getBranch: ["GET /repos/{owner}/{repo}/branches/{branch}"],
|
|
getBranchProtection: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection"
|
|
],
|
|
getBranchRules: ["GET /repos/{owner}/{repo}/rules/branches/{branch}"],
|
|
getClones: ["GET /repos/{owner}/{repo}/traffic/clones"],
|
|
getCodeFrequencyStats: ["GET /repos/{owner}/{repo}/stats/code_frequency"],
|
|
getCollaboratorPermissionLevel: [
|
|
"GET /repos/{owner}/{repo}/collaborators/{username}/permission"
|
|
],
|
|
getCombinedStatusForRef: ["GET /repos/{owner}/{repo}/commits/{ref}/status"],
|
|
getCommit: ["GET /repos/{owner}/{repo}/commits/{ref}"],
|
|
getCommitActivityStats: ["GET /repos/{owner}/{repo}/stats/commit_activity"],
|
|
getCommitComment: ["GET /repos/{owner}/{repo}/comments/{comment_id}"],
|
|
getCommitSignatureProtection: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures"
|
|
],
|
|
getCommunityProfileMetrics: ["GET /repos/{owner}/{repo}/community/profile"],
|
|
getContent: ["GET /repos/{owner}/{repo}/contents/{path}"],
|
|
getContributorsStats: ["GET /repos/{owner}/{repo}/stats/contributors"],
|
|
getCustomDeploymentProtectionRule: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}"
|
|
],
|
|
getCustomPropertiesValues: ["GET /repos/{owner}/{repo}/properties/values"],
|
|
getDeployKey: ["GET /repos/{owner}/{repo}/keys/{key_id}"],
|
|
getDeployment: ["GET /repos/{owner}/{repo}/deployments/{deployment_id}"],
|
|
getDeploymentBranchPolicy: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}"
|
|
],
|
|
getDeploymentStatus: [
|
|
"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}"
|
|
],
|
|
getEnvironment: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}"
|
|
],
|
|
getLatestPagesBuild: ["GET /repos/{owner}/{repo}/pages/builds/latest"],
|
|
getLatestRelease: ["GET /repos/{owner}/{repo}/releases/latest"],
|
|
getOrgRuleSuite: ["GET /orgs/{org}/rulesets/rule-suites/{rule_suite_id}"],
|
|
getOrgRuleSuites: ["GET /orgs/{org}/rulesets/rule-suites"],
|
|
getOrgRuleset: ["GET /orgs/{org}/rulesets/{ruleset_id}"],
|
|
getOrgRulesets: ["GET /orgs/{org}/rulesets"],
|
|
getPages: ["GET /repos/{owner}/{repo}/pages"],
|
|
getPagesBuild: ["GET /repos/{owner}/{repo}/pages/builds/{build_id}"],
|
|
getPagesDeployment: [
|
|
"GET /repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}"
|
|
],
|
|
getPagesHealthCheck: ["GET /repos/{owner}/{repo}/pages/health"],
|
|
getParticipationStats: ["GET /repos/{owner}/{repo}/stats/participation"],
|
|
getPullRequestReviewProtection: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"
|
|
],
|
|
getPunchCardStats: ["GET /repos/{owner}/{repo}/stats/punch_card"],
|
|
getReadme: ["GET /repos/{owner}/{repo}/readme"],
|
|
getReadmeInDirectory: ["GET /repos/{owner}/{repo}/readme/{dir}"],
|
|
getRelease: ["GET /repos/{owner}/{repo}/releases/{release_id}"],
|
|
getReleaseAsset: ["GET /repos/{owner}/{repo}/releases/assets/{asset_id}"],
|
|
getReleaseByTag: ["GET /repos/{owner}/{repo}/releases/tags/{tag}"],
|
|
getRepoRuleSuite: [
|
|
"GET /repos/{owner}/{repo}/rulesets/rule-suites/{rule_suite_id}"
|
|
],
|
|
getRepoRuleSuites: ["GET /repos/{owner}/{repo}/rulesets/rule-suites"],
|
|
getRepoRuleset: ["GET /repos/{owner}/{repo}/rulesets/{ruleset_id}"],
|
|
getRepoRulesetHistory: [
|
|
"GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history"
|
|
],
|
|
getRepoRulesetVersion: [
|
|
"GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history/{version_id}"
|
|
],
|
|
getRepoRulesets: ["GET /repos/{owner}/{repo}/rulesets"],
|
|
getStatusChecksProtection: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"
|
|
],
|
|
getTeamsWithAccessToProtectedBranch: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams"
|
|
],
|
|
getTopPaths: ["GET /repos/{owner}/{repo}/traffic/popular/paths"],
|
|
getTopReferrers: ["GET /repos/{owner}/{repo}/traffic/popular/referrers"],
|
|
getUsersWithAccessToProtectedBranch: [
|
|
"GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users"
|
|
],
|
|
getViews: ["GET /repos/{owner}/{repo}/traffic/views"],
|
|
getWebhook: ["GET /repos/{owner}/{repo}/hooks/{hook_id}"],
|
|
getWebhookConfigForRepo: [
|
|
"GET /repos/{owner}/{repo}/hooks/{hook_id}/config"
|
|
],
|
|
getWebhookDelivery: [
|
|
"GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}"
|
|
],
|
|
listActivities: ["GET /repos/{owner}/{repo}/activity"],
|
|
listAttestations: [
|
|
"GET /repos/{owner}/{repo}/attestations/{subject_digest}"
|
|
],
|
|
listAutolinks: ["GET /repos/{owner}/{repo}/autolinks"],
|
|
listBranches: ["GET /repos/{owner}/{repo}/branches"],
|
|
listBranchesForHeadCommit: [
|
|
"GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head"
|
|
],
|
|
listCollaborators: ["GET /repos/{owner}/{repo}/collaborators"],
|
|
listCommentsForCommit: [
|
|
"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments"
|
|
],
|
|
listCommitCommentsForRepo: ["GET /repos/{owner}/{repo}/comments"],
|
|
listCommitStatusesForRef: [
|
|
"GET /repos/{owner}/{repo}/commits/{ref}/statuses"
|
|
],
|
|
listCommits: ["GET /repos/{owner}/{repo}/commits"],
|
|
listContributors: ["GET /repos/{owner}/{repo}/contributors"],
|
|
listCustomDeploymentRuleIntegrations: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps"
|
|
],
|
|
listDeployKeys: ["GET /repos/{owner}/{repo}/keys"],
|
|
listDeploymentBranchPolicies: [
|
|
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies"
|
|
],
|
|
listDeploymentStatuses: [
|
|
"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses"
|
|
],
|
|
listDeployments: ["GET /repos/{owner}/{repo}/deployments"],
|
|
listForAuthenticatedUser: ["GET /user/repos"],
|
|
listForOrg: ["GET /orgs/{org}/repos"],
|
|
listForUser: ["GET /users/{username}/repos"],
|
|
listForks: ["GET /repos/{owner}/{repo}/forks"],
|
|
listInvitations: ["GET /repos/{owner}/{repo}/invitations"],
|
|
listInvitationsForAuthenticatedUser: ["GET /user/repository_invitations"],
|
|
listLanguages: ["GET /repos/{owner}/{repo}/languages"],
|
|
listPagesBuilds: ["GET /repos/{owner}/{repo}/pages/builds"],
|
|
listPublic: ["GET /repositories"],
|
|
listPullRequestsAssociatedWithCommit: [
|
|
"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls"
|
|
],
|
|
listReleaseAssets: [
|
|
"GET /repos/{owner}/{repo}/releases/{release_id}/assets"
|
|
],
|
|
listReleases: ["GET /repos/{owner}/{repo}/releases"],
|
|
listTags: ["GET /repos/{owner}/{repo}/tags"],
|
|
listTeams: ["GET /repos/{owner}/{repo}/teams"],
|
|
listWebhookDeliveries: [
|
|
"GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries"
|
|
],
|
|
listWebhooks: ["GET /repos/{owner}/{repo}/hooks"],
|
|
merge: ["POST /repos/{owner}/{repo}/merges"],
|
|
mergeUpstream: ["POST /repos/{owner}/{repo}/merge-upstream"],
|
|
pingWebhook: ["POST /repos/{owner}/{repo}/hooks/{hook_id}/pings"],
|
|
redeliverWebhookDelivery: [
|
|
"POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts"
|
|
],
|
|
removeAppAccessRestrictions: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps",
|
|
{},
|
|
{ mapToData: "apps" }
|
|
],
|
|
removeCollaborator: [
|
|
"DELETE /repos/{owner}/{repo}/collaborators/{username}"
|
|
],
|
|
removeStatusCheckContexts: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts",
|
|
{},
|
|
{ mapToData: "contexts" }
|
|
],
|
|
removeStatusCheckProtection: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"
|
|
],
|
|
removeTeamAccessRestrictions: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams",
|
|
{},
|
|
{ mapToData: "teams" }
|
|
],
|
|
removeUserAccessRestrictions: [
|
|
"DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users",
|
|
{},
|
|
{ mapToData: "users" }
|
|
],
|
|
renameBranch: ["POST /repos/{owner}/{repo}/branches/{branch}/rename"],
|
|
replaceAllTopics: ["PUT /repos/{owner}/{repo}/topics"],
|
|
requestPagesBuild: ["POST /repos/{owner}/{repo}/pages/builds"],
|
|
setAdminBranchProtection: [
|
|
"POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins"
|
|
],
|
|
setAppAccessRestrictions: [
|
|
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps",
|
|
{},
|
|
{ mapToData: "apps" }
|
|
],
|
|
setStatusCheckContexts: [
|
|
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/contexts",
|
|
{},
|
|
{ mapToData: "contexts" }
|
|
],
|
|
setTeamAccessRestrictions: [
|
|
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams",
|
|
{},
|
|
{ mapToData: "teams" }
|
|
],
|
|
setUserAccessRestrictions: [
|
|
"PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users",
|
|
{},
|
|
{ mapToData: "users" }
|
|
],
|
|
testPushWebhook: ["POST /repos/{owner}/{repo}/hooks/{hook_id}/tests"],
|
|
transfer: ["POST /repos/{owner}/{repo}/transfer"],
|
|
update: ["PATCH /repos/{owner}/{repo}"],
|
|
updateBranchProtection: [
|
|
"PUT /repos/{owner}/{repo}/branches/{branch}/protection"
|
|
],
|
|
updateCommitComment: ["PATCH /repos/{owner}/{repo}/comments/{comment_id}"],
|
|
updateDeploymentBranchPolicy: [
|
|
"PUT /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}"
|
|
],
|
|
updateInformationAboutPagesSite: ["PUT /repos/{owner}/{repo}/pages"],
|
|
updateInvitation: [
|
|
"PATCH /repos/{owner}/{repo}/invitations/{invitation_id}"
|
|
],
|
|
updateOrgRuleset: ["PUT /orgs/{org}/rulesets/{ruleset_id}"],
|
|
updatePullRequestReviewProtection: [
|
|
"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews"
|
|
],
|
|
updateRelease: ["PATCH /repos/{owner}/{repo}/releases/{release_id}"],
|
|
updateReleaseAsset: [
|
|
"PATCH /repos/{owner}/{repo}/releases/assets/{asset_id}"
|
|
],
|
|
updateRepoRuleset: ["PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}"],
|
|
updateStatusCheckPotection: [
|
|
"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks",
|
|
{},
|
|
{ renamed: ["repos", "updateStatusCheckProtection"] }
|
|
],
|
|
updateStatusCheckProtection: [
|
|
"PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks"
|
|
],
|
|
updateWebhook: ["PATCH /repos/{owner}/{repo}/hooks/{hook_id}"],
|
|
updateWebhookConfigForRepo: [
|
|
"PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config"
|
|
],
|
|
uploadReleaseAsset: [
|
|
"POST /repos/{owner}/{repo}/releases/{release_id}/assets{?name,label}",
|
|
{ baseUrl: "https://uploads.github.com" }
|
|
]
|
|
},
|
|
search: {
|
|
code: ["GET /search/code"],
|
|
commits: ["GET /search/commits"],
|
|
issuesAndPullRequests: [
|
|
"GET /search/issues",
|
|
{},
|
|
{
|
|
deprecated: "octokit.rest.search.issuesAndPullRequests() is deprecated, see https://docs.github.com/rest/search/search#search-issues-and-pull-requests"
|
|
}
|
|
],
|
|
labels: ["GET /search/labels"],
|
|
repos: ["GET /search/repositories"],
|
|
topics: ["GET /search/topics"],
|
|
users: ["GET /search/users"]
|
|
},
|
|
secretScanning: {
|
|
createPushProtectionBypass: [
|
|
"POST /repos/{owner}/{repo}/secret-scanning/push-protection-bypasses"
|
|
],
|
|
getAlert: [
|
|
"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}"
|
|
],
|
|
getScanHistory: ["GET /repos/{owner}/{repo}/secret-scanning/scan-history"],
|
|
listAlertsForEnterprise: [
|
|
"GET /enterprises/{enterprise}/secret-scanning/alerts"
|
|
],
|
|
listAlertsForOrg: ["GET /orgs/{org}/secret-scanning/alerts"],
|
|
listAlertsForRepo: ["GET /repos/{owner}/{repo}/secret-scanning/alerts"],
|
|
listLocationsForAlert: [
|
|
"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations"
|
|
],
|
|
listOrgPatternConfigs: [
|
|
"GET /orgs/{org}/secret-scanning/pattern-configurations"
|
|
],
|
|
updateAlert: [
|
|
"PATCH /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}"
|
|
],
|
|
updateOrgPatternConfigs: [
|
|
"PATCH /orgs/{org}/secret-scanning/pattern-configurations"
|
|
]
|
|
},
|
|
securityAdvisories: {
|
|
createFork: [
|
|
"POST /repos/{owner}/{repo}/security-advisories/{ghsa_id}/forks"
|
|
],
|
|
createPrivateVulnerabilityReport: [
|
|
"POST /repos/{owner}/{repo}/security-advisories/reports"
|
|
],
|
|
createRepositoryAdvisory: [
|
|
"POST /repos/{owner}/{repo}/security-advisories"
|
|
],
|
|
createRepositoryAdvisoryCveRequest: [
|
|
"POST /repos/{owner}/{repo}/security-advisories/{ghsa_id}/cve"
|
|
],
|
|
getGlobalAdvisory: ["GET /advisories/{ghsa_id}"],
|
|
getRepositoryAdvisory: [
|
|
"GET /repos/{owner}/{repo}/security-advisories/{ghsa_id}"
|
|
],
|
|
listGlobalAdvisories: ["GET /advisories"],
|
|
listOrgRepositoryAdvisories: ["GET /orgs/{org}/security-advisories"],
|
|
listRepositoryAdvisories: ["GET /repos/{owner}/{repo}/security-advisories"],
|
|
updateRepositoryAdvisory: [
|
|
"PATCH /repos/{owner}/{repo}/security-advisories/{ghsa_id}"
|
|
]
|
|
},
|
|
teams: {
|
|
addOrUpdateMembershipForUserInOrg: [
|
|
"PUT /orgs/{org}/teams/{team_slug}/memberships/{username}"
|
|
],
|
|
addOrUpdateRepoPermissionsInOrg: [
|
|
"PUT /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"
|
|
],
|
|
checkPermissionsForRepoInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"
|
|
],
|
|
create: ["POST /orgs/{org}/teams"],
|
|
createDiscussionCommentInOrg: [
|
|
"POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments"
|
|
],
|
|
createDiscussionInOrg: ["POST /orgs/{org}/teams/{team_slug}/discussions"],
|
|
deleteDiscussionCommentInOrg: [
|
|
"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}"
|
|
],
|
|
deleteDiscussionInOrg: [
|
|
"DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}"
|
|
],
|
|
deleteInOrg: ["DELETE /orgs/{org}/teams/{team_slug}"],
|
|
getByName: ["GET /orgs/{org}/teams/{team_slug}"],
|
|
getDiscussionCommentInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}"
|
|
],
|
|
getDiscussionInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}"
|
|
],
|
|
getMembershipForUserInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/memberships/{username}"
|
|
],
|
|
list: ["GET /orgs/{org}/teams"],
|
|
listChildInOrg: ["GET /orgs/{org}/teams/{team_slug}/teams"],
|
|
listDiscussionCommentsInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments"
|
|
],
|
|
listDiscussionsInOrg: ["GET /orgs/{org}/teams/{team_slug}/discussions"],
|
|
listForAuthenticatedUser: ["GET /user/teams"],
|
|
listMembersInOrg: ["GET /orgs/{org}/teams/{team_slug}/members"],
|
|
listPendingInvitationsInOrg: [
|
|
"GET /orgs/{org}/teams/{team_slug}/invitations"
|
|
],
|
|
listReposInOrg: ["GET /orgs/{org}/teams/{team_slug}/repos"],
|
|
removeMembershipForUserInOrg: [
|
|
"DELETE /orgs/{org}/teams/{team_slug}/memberships/{username}"
|
|
],
|
|
removeRepoInOrg: [
|
|
"DELETE /orgs/{org}/teams/{team_slug}/repos/{owner}/{repo}"
|
|
],
|
|
updateDiscussionCommentInOrg: [
|
|
"PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}"
|
|
],
|
|
updateDiscussionInOrg: [
|
|
"PATCH /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}"
|
|
],
|
|
updateInOrg: ["PATCH /orgs/{org}/teams/{team_slug}"]
|
|
},
|
|
users: {
|
|
addEmailForAuthenticated: [
|
|
"POST /user/emails",
|
|
{},
|
|
{ renamed: ["users", "addEmailForAuthenticatedUser"] }
|
|
],
|
|
addEmailForAuthenticatedUser: ["POST /user/emails"],
|
|
addSocialAccountForAuthenticatedUser: ["POST /user/social_accounts"],
|
|
block: ["PUT /user/blocks/{username}"],
|
|
checkBlocked: ["GET /user/blocks/{username}"],
|
|
checkFollowingForUser: ["GET /users/{username}/following/{target_user}"],
|
|
checkPersonIsFollowedByAuthenticated: ["GET /user/following/{username}"],
|
|
createGpgKeyForAuthenticated: [
|
|
"POST /user/gpg_keys",
|
|
{},
|
|
{ renamed: ["users", "createGpgKeyForAuthenticatedUser"] }
|
|
],
|
|
createGpgKeyForAuthenticatedUser: ["POST /user/gpg_keys"],
|
|
createPublicSshKeyForAuthenticated: [
|
|
"POST /user/keys",
|
|
{},
|
|
{ renamed: ["users", "createPublicSshKeyForAuthenticatedUser"] }
|
|
],
|
|
createPublicSshKeyForAuthenticatedUser: ["POST /user/keys"],
|
|
createSshSigningKeyForAuthenticatedUser: ["POST /user/ssh_signing_keys"],
|
|
deleteAttestationsBulk: [
|
|
"POST /users/{username}/attestations/delete-request"
|
|
],
|
|
deleteAttestationsById: [
|
|
"DELETE /users/{username}/attestations/{attestation_id}"
|
|
],
|
|
deleteAttestationsBySubjectDigest: [
|
|
"DELETE /users/{username}/attestations/digest/{subject_digest}"
|
|
],
|
|
deleteEmailForAuthenticated: [
|
|
"DELETE /user/emails",
|
|
{},
|
|
{ renamed: ["users", "deleteEmailForAuthenticatedUser"] }
|
|
],
|
|
deleteEmailForAuthenticatedUser: ["DELETE /user/emails"],
|
|
deleteGpgKeyForAuthenticated: [
|
|
"DELETE /user/gpg_keys/{gpg_key_id}",
|
|
{},
|
|
{ renamed: ["users", "deleteGpgKeyForAuthenticatedUser"] }
|
|
],
|
|
deleteGpgKeyForAuthenticatedUser: ["DELETE /user/gpg_keys/{gpg_key_id}"],
|
|
deletePublicSshKeyForAuthenticated: [
|
|
"DELETE /user/keys/{key_id}",
|
|
{},
|
|
{ renamed: ["users", "deletePublicSshKeyForAuthenticatedUser"] }
|
|
],
|
|
deletePublicSshKeyForAuthenticatedUser: ["DELETE /user/keys/{key_id}"],
|
|
deleteSocialAccountForAuthenticatedUser: ["DELETE /user/social_accounts"],
|
|
deleteSshSigningKeyForAuthenticatedUser: [
|
|
"DELETE /user/ssh_signing_keys/{ssh_signing_key_id}"
|
|
],
|
|
follow: ["PUT /user/following/{username}"],
|
|
getAuthenticated: ["GET /user"],
|
|
getById: ["GET /user/{account_id}"],
|
|
getByUsername: ["GET /users/{username}"],
|
|
getContextForUser: ["GET /users/{username}/hovercard"],
|
|
getGpgKeyForAuthenticated: [
|
|
"GET /user/gpg_keys/{gpg_key_id}",
|
|
{},
|
|
{ renamed: ["users", "getGpgKeyForAuthenticatedUser"] }
|
|
],
|
|
getGpgKeyForAuthenticatedUser: ["GET /user/gpg_keys/{gpg_key_id}"],
|
|
getPublicSshKeyForAuthenticated: [
|
|
"GET /user/keys/{key_id}",
|
|
{},
|
|
{ renamed: ["users", "getPublicSshKeyForAuthenticatedUser"] }
|
|
],
|
|
getPublicSshKeyForAuthenticatedUser: ["GET /user/keys/{key_id}"],
|
|
getSshSigningKeyForAuthenticatedUser: [
|
|
"GET /user/ssh_signing_keys/{ssh_signing_key_id}"
|
|
],
|
|
list: ["GET /users"],
|
|
listAttestations: ["GET /users/{username}/attestations/{subject_digest}"],
|
|
listAttestationsBulk: [
|
|
"POST /users/{username}/attestations/bulk-list{?per_page,before,after}"
|
|
],
|
|
listBlockedByAuthenticated: [
|
|
"GET /user/blocks",
|
|
{},
|
|
{ renamed: ["users", "listBlockedByAuthenticatedUser"] }
|
|
],
|
|
listBlockedByAuthenticatedUser: ["GET /user/blocks"],
|
|
listEmailsForAuthenticated: [
|
|
"GET /user/emails",
|
|
{},
|
|
{ renamed: ["users", "listEmailsForAuthenticatedUser"] }
|
|
],
|
|
listEmailsForAuthenticatedUser: ["GET /user/emails"],
|
|
listFollowedByAuthenticated: [
|
|
"GET /user/following",
|
|
{},
|
|
{ renamed: ["users", "listFollowedByAuthenticatedUser"] }
|
|
],
|
|
listFollowedByAuthenticatedUser: ["GET /user/following"],
|
|
listFollowersForAuthenticatedUser: ["GET /user/followers"],
|
|
listFollowersForUser: ["GET /users/{username}/followers"],
|
|
listFollowingForUser: ["GET /users/{username}/following"],
|
|
listGpgKeysForAuthenticated: [
|
|
"GET /user/gpg_keys",
|
|
{},
|
|
{ renamed: ["users", "listGpgKeysForAuthenticatedUser"] }
|
|
],
|
|
listGpgKeysForAuthenticatedUser: ["GET /user/gpg_keys"],
|
|
listGpgKeysForUser: ["GET /users/{username}/gpg_keys"],
|
|
listPublicEmailsForAuthenticated: [
|
|
"GET /user/public_emails",
|
|
{},
|
|
{ renamed: ["users", "listPublicEmailsForAuthenticatedUser"] }
|
|
],
|
|
listPublicEmailsForAuthenticatedUser: ["GET /user/public_emails"],
|
|
listPublicKeysForUser: ["GET /users/{username}/keys"],
|
|
listPublicSshKeysForAuthenticated: [
|
|
"GET /user/keys",
|
|
{},
|
|
{ renamed: ["users", "listPublicSshKeysForAuthenticatedUser"] }
|
|
],
|
|
listPublicSshKeysForAuthenticatedUser: ["GET /user/keys"],
|
|
listSocialAccountsForAuthenticatedUser: ["GET /user/social_accounts"],
|
|
listSocialAccountsForUser: ["GET /users/{username}/social_accounts"],
|
|
listSshSigningKeysForAuthenticatedUser: ["GET /user/ssh_signing_keys"],
|
|
listSshSigningKeysForUser: ["GET /users/{username}/ssh_signing_keys"],
|
|
setPrimaryEmailVisibilityForAuthenticated: [
|
|
"PATCH /user/email/visibility",
|
|
{},
|
|
{ renamed: ["users", "setPrimaryEmailVisibilityForAuthenticatedUser"] }
|
|
],
|
|
setPrimaryEmailVisibilityForAuthenticatedUser: [
|
|
"PATCH /user/email/visibility"
|
|
],
|
|
unblock: ["DELETE /user/blocks/{username}"],
|
|
unfollow: ["DELETE /user/following/{username}"],
|
|
updateAuthenticated: ["PATCH /user"]
|
|
}
|
|
};
|
|
var endpoints_default = Endpoints;
|
|
|
|
// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/endpoints-to-methods.js
|
|
var endpointMethodsMap = /* @__PURE__ */ new Map;
|
|
for (const [scope, endpoints] of Object.entries(endpoints_default)) {
|
|
for (const [methodName, endpoint2] of Object.entries(endpoints)) {
|
|
const [route, defaults, decorations] = endpoint2;
|
|
const [method, url] = route.split(/ /);
|
|
const endpointDefaults = Object.assign({
|
|
method,
|
|
url
|
|
}, defaults);
|
|
if (!endpointMethodsMap.has(scope)) {
|
|
endpointMethodsMap.set(scope, /* @__PURE__ */ new Map);
|
|
}
|
|
endpointMethodsMap.get(scope).set(methodName, {
|
|
scope,
|
|
methodName,
|
|
endpointDefaults,
|
|
decorations
|
|
});
|
|
}
|
|
}
|
|
var handler = {
|
|
has({ scope }, methodName) {
|
|
return endpointMethodsMap.get(scope).has(methodName);
|
|
},
|
|
getOwnPropertyDescriptor(target, methodName) {
|
|
return {
|
|
value: this.get(target, methodName),
|
|
configurable: true,
|
|
writable: true,
|
|
enumerable: true
|
|
};
|
|
},
|
|
defineProperty(target, methodName, descriptor) {
|
|
Object.defineProperty(target.cache, methodName, descriptor);
|
|
return true;
|
|
},
|
|
deleteProperty(target, methodName) {
|
|
delete target.cache[methodName];
|
|
return true;
|
|
},
|
|
ownKeys({ scope }) {
|
|
return [...endpointMethodsMap.get(scope).keys()];
|
|
},
|
|
set(target, methodName, value) {
|
|
return target.cache[methodName] = value;
|
|
},
|
|
get({ octokit, scope, cache }, methodName) {
|
|
if (cache[methodName]) {
|
|
return cache[methodName];
|
|
}
|
|
const method = endpointMethodsMap.get(scope).get(methodName);
|
|
if (!method) {
|
|
return;
|
|
}
|
|
const { endpointDefaults, decorations } = method;
|
|
if (decorations) {
|
|
cache[methodName] = decorate(octokit, scope, methodName, endpointDefaults, decorations);
|
|
} else {
|
|
cache[methodName] = octokit.request.defaults(endpointDefaults);
|
|
}
|
|
return cache[methodName];
|
|
}
|
|
};
|
|
function endpointsToMethods(octokit) {
|
|
const newMethods = {};
|
|
for (const scope of endpointMethodsMap.keys()) {
|
|
newMethods[scope] = new Proxy({ octokit, scope, cache: {} }, handler);
|
|
}
|
|
return newMethods;
|
|
}
|
|
function decorate(octokit, scope, methodName, defaults, decorations) {
|
|
const requestWithDefaults = octokit.request.defaults(defaults);
|
|
function withDecorations(...args) {
|
|
let options = requestWithDefaults.endpoint.merge(...args);
|
|
if (decorations.mapToData) {
|
|
options = Object.assign({}, options, {
|
|
data: options[decorations.mapToData],
|
|
[decorations.mapToData]: undefined
|
|
});
|
|
return requestWithDefaults(options);
|
|
}
|
|
if (decorations.renamed) {
|
|
const [newScope, newMethodName] = decorations.renamed;
|
|
octokit.log.warn(`octokit.${scope}.${methodName}() has been renamed to octokit.${newScope}.${newMethodName}()`);
|
|
}
|
|
if (decorations.deprecated) {
|
|
octokit.log.warn(decorations.deprecated);
|
|
}
|
|
if (decorations.renamedParameters) {
|
|
const options2 = requestWithDefaults.endpoint.merge(...args);
|
|
for (const [name, alias] of Object.entries(decorations.renamedParameters)) {
|
|
if (name in options2) {
|
|
octokit.log.warn(`"${name}" parameter is deprecated for "octokit.${scope}.${methodName}()". Use "${alias}" instead`);
|
|
if (!(alias in options2)) {
|
|
options2[alias] = options2[name];
|
|
}
|
|
delete options2[name];
|
|
}
|
|
}
|
|
return requestWithDefaults(options2);
|
|
}
|
|
return requestWithDefaults(...args);
|
|
}
|
|
return Object.assign(withDecorations, requestWithDefaults);
|
|
}
|
|
|
|
// node_modules/@octokit/plugin-rest-endpoint-methods/dist-src/index.js
|
|
function restEndpointMethods(octokit) {
|
|
const api = endpointsToMethods(octokit);
|
|
return {
|
|
rest: api
|
|
};
|
|
}
|
|
restEndpointMethods.VERSION = VERSION7;
|
|
function legacyRestEndpointMethods(octokit) {
|
|
const api = endpointsToMethods(octokit);
|
|
return {
|
|
...api,
|
|
rest: api
|
|
};
|
|
}
|
|
legacyRestEndpointMethods.VERSION = VERSION7;
|
|
|
|
// node_modules/@octokit/rest/dist-src/version.js
|
|
var VERSION8 = "22.0.0";
|
|
|
|
// node_modules/@octokit/rest/dist-src/index.js
|
|
var Octokit2 = Octokit.plugin(requestLog, legacyRestEndpointMethods, paginateRest).defaults({
|
|
userAgent: `octokit-rest.js/${VERSION8}`
|
|
});
|
|
|
|
// inline-comment.ts
|
|
var githubToken = process.env.GITHUB_TOKEN;
|
|
if (!githubToken) {
|
|
throw new Error("GITHUB_TOKEN environment variable is required");
|
|
}
|
|
function sanitizeContent(content) {
|
|
const patterns = [
|
|
/ghp_[a-zA-Z0-9]{36}/g,
|
|
/gho_[a-zA-Z0-9]{36}/g,
|
|
/ghs_[a-zA-Z0-9]{36}/g,
|
|
/ghr_[a-zA-Z0-9]{36}/g,
|
|
/github_pat_[a-zA-Z0-9_]{82}/g
|
|
];
|
|
let sanitized = content;
|
|
for (const pattern of patterns) {
|
|
sanitized = sanitized.replace(pattern, "[REDACTED_TOKEN]");
|
|
}
|
|
return sanitized;
|
|
}
|
|
var server = new McpServer({
|
|
name: "GitHub Inline Comment Server",
|
|
version: "0.0.1"
|
|
});
|
|
server.tool("create_inline_comment", "Create an inline comment on a specific line or lines in a PR file. Use this tool to provide code suggestions or feedback directly in the PR diff.", {
|
|
owner: exports_external.string().describe("Repository owner (e.g., 'anthropics')"),
|
|
repo: exports_external.string().describe("Repository name (e.g., 'claude-code-action')"),
|
|
pull_number: exports_external.number().positive().describe("Pull request number (e.g., 42)"),
|
|
path: exports_external.string().describe("The file path to comment on (e.g., 'src/index.js')"),
|
|
body: exports_external.string().describe("The comment text (supports markdown and GitHub code suggestion blocks). " + "For code suggestions, use: ```suggestion\\nreplacement code\\n```. " + "IMPORTANT: The suggestion block will REPLACE the ENTIRE line range (single line or startLine to line). " + "Ensure the replacement is syntactically complete and valid - it must work as a drop-in replacement for the selected lines."),
|
|
line: exports_external.number().nonnegative().optional().describe("Line number for single-line comments (required if startLine is not provided)"),
|
|
startLine: exports_external.number().nonnegative().optional().describe("Start line for multi-line comments (use with line parameter for the end line)"),
|
|
side: exports_external.enum(["LEFT", "RIGHT"]).optional().default("RIGHT").describe("Side of the diff to comment on: LEFT (old code) or RIGHT (new code)"),
|
|
commit_id: exports_external.string().optional().describe("Specific commit SHA to comment on (defaults to latest commit)")
|
|
}, async ({
|
|
owner,
|
|
repo,
|
|
pull_number,
|
|
path,
|
|
body,
|
|
line,
|
|
startLine,
|
|
side,
|
|
commit_id
|
|
}) => {
|
|
try {
|
|
const octokit = new Octokit2({ auth: githubToken });
|
|
const sanitizedBody = sanitizeContent(body);
|
|
if (!line && !startLine) {
|
|
throw new Error("Either 'line' for single-line comments or both 'startLine' and 'line' for multi-line comments must be provided");
|
|
}
|
|
const isSingleLine = !startLine;
|
|
const pr = await octokit.rest.pulls.get({
|
|
owner,
|
|
repo,
|
|
pull_number
|
|
});
|
|
const params = {
|
|
owner,
|
|
repo,
|
|
pull_number,
|
|
body: sanitizedBody,
|
|
path,
|
|
side: side || "RIGHT",
|
|
commit_id: commit_id || pr.data.head.sha
|
|
};
|
|
if (isSingleLine) {
|
|
params.line = line;
|
|
} else {
|
|
params.start_line = startLine;
|
|
params.start_side = side || "RIGHT";
|
|
params.line = line;
|
|
}
|
|
const result = await octokit.rest.pulls.createReviewComment(params);
|
|
return {
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: JSON.stringify({
|
|
success: true,
|
|
comment_id: result.data.id,
|
|
html_url: result.data.html_url,
|
|
path: result.data.path,
|
|
line: result.data.line || result.data.original_line,
|
|
message: `Inline comment created successfully on ${path}${isSingleLine ? ` at line ${line}` : ` from line ${startLine} to ${line}`}`
|
|
}, null, 2)
|
|
}
|
|
]
|
|
};
|
|
} catch (error) {
|
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
let helpMessage = "";
|
|
if (errorMessage.includes("Validation Failed")) {
|
|
helpMessage = `
|
|
|
|
This usually means the line number doesn't exist in the diff or the file path is incorrect. Make sure you're commenting on lines that are part of the PR's changes.`;
|
|
} else if (errorMessage.includes("Not Found")) {
|
|
helpMessage = `
|
|
|
|
This usually means the PR number, repository, or file path is incorrect.`;
|
|
}
|
|
return {
|
|
content: [
|
|
{
|
|
type: "text",
|
|
text: `Error creating inline comment: ${errorMessage}${helpMessage}`
|
|
}
|
|
],
|
|
error: errorMessage,
|
|
isError: true
|
|
};
|
|
}
|
|
});
|
|
async function runServer() {
|
|
const transport = new StdioServerTransport;
|
|
await server.connect(transport);
|
|
process.on("exit", () => {
|
|
server.close();
|
|
});
|
|
}
|
|
runServer().catch(console.error);
|