@ivotoby/openapi-mcp-server 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +116 -39
- package/dist/bundle.js +3814 -379
- package/package.json +3 -7
package/dist/bundle.js
CHANGED
|
@@ -8844,11 +8844,11 @@ var require_mime_types = __commonJS({
|
|
|
8844
8844
|
exports.lookup = lookup;
|
|
8845
8845
|
exports.types = /* @__PURE__ */ Object.create(null);
|
|
8846
8846
|
populateMaps(exports.extensions, exports.types);
|
|
8847
|
-
function charset(
|
|
8848
|
-
if (!
|
|
8847
|
+
function charset(type2) {
|
|
8848
|
+
if (!type2 || typeof type2 !== "string") {
|
|
8849
8849
|
return false;
|
|
8850
8850
|
}
|
|
8851
|
-
var match = EXTRACT_TYPE_REGEXP.exec(
|
|
8851
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type2);
|
|
8852
8852
|
var mime = match && db[match[1].toLowerCase()];
|
|
8853
8853
|
if (mime && mime.charset) {
|
|
8854
8854
|
return mime.charset;
|
|
@@ -8858,11 +8858,11 @@ var require_mime_types = __commonJS({
|
|
|
8858
8858
|
}
|
|
8859
8859
|
return false;
|
|
8860
8860
|
}
|
|
8861
|
-
function contentType(
|
|
8862
|
-
if (!
|
|
8861
|
+
function contentType(str2) {
|
|
8862
|
+
if (!str2 || typeof str2 !== "string") {
|
|
8863
8863
|
return false;
|
|
8864
8864
|
}
|
|
8865
|
-
var mime =
|
|
8865
|
+
var mime = str2.indexOf("/") === -1 ? exports.lookup(str2) : str2;
|
|
8866
8866
|
if (!mime) {
|
|
8867
8867
|
return false;
|
|
8868
8868
|
}
|
|
@@ -8872,11 +8872,11 @@ var require_mime_types = __commonJS({
|
|
|
8872
8872
|
}
|
|
8873
8873
|
return mime;
|
|
8874
8874
|
}
|
|
8875
|
-
function extension(
|
|
8876
|
-
if (!
|
|
8875
|
+
function extension(type2) {
|
|
8876
|
+
if (!type2 || typeof type2 !== "string") {
|
|
8877
8877
|
return false;
|
|
8878
8878
|
}
|
|
8879
|
-
var match = EXTRACT_TYPE_REGEXP.exec(
|
|
8879
|
+
var match = EXTRACT_TYPE_REGEXP.exec(type2);
|
|
8880
8880
|
var exts = match && exports.extensions[match[1].toLowerCase()];
|
|
8881
8881
|
if (!exts || !exts.length) {
|
|
8882
8882
|
return false;
|
|
@@ -8893,25 +8893,25 @@ var require_mime_types = __commonJS({
|
|
|
8893
8893
|
}
|
|
8894
8894
|
return exports.types[extension2] || false;
|
|
8895
8895
|
}
|
|
8896
|
-
function populateMaps(extensions,
|
|
8896
|
+
function populateMaps(extensions, types2) {
|
|
8897
8897
|
var preference = ["nginx", "apache", void 0, "iana"];
|
|
8898
|
-
Object.keys(db).forEach(function forEachMimeType(
|
|
8899
|
-
var mime = db[
|
|
8898
|
+
Object.keys(db).forEach(function forEachMimeType(type2) {
|
|
8899
|
+
var mime = db[type2];
|
|
8900
8900
|
var exts = mime.extensions;
|
|
8901
8901
|
if (!exts || !exts.length) {
|
|
8902
8902
|
return;
|
|
8903
8903
|
}
|
|
8904
|
-
extensions[
|
|
8904
|
+
extensions[type2] = exts;
|
|
8905
8905
|
for (var i = 0; i < exts.length; i++) {
|
|
8906
8906
|
var extension2 = exts[i];
|
|
8907
|
-
if (
|
|
8908
|
-
var from = preference.indexOf(db[
|
|
8907
|
+
if (types2[extension2]) {
|
|
8908
|
+
var from = preference.indexOf(db[types2[extension2]].source);
|
|
8909
8909
|
var to = preference.indexOf(mime.source);
|
|
8910
|
-
if (
|
|
8910
|
+
if (types2[extension2] !== "application/octet-stream" && (from > to || from === to && types2[extension2].substr(0, 12) === "application/")) {
|
|
8911
8911
|
continue;
|
|
8912
8912
|
}
|
|
8913
8913
|
}
|
|
8914
|
-
|
|
8914
|
+
types2[extension2] = type2;
|
|
8915
8915
|
}
|
|
8916
8916
|
});
|
|
8917
8917
|
}
|
|
@@ -9425,14 +9425,14 @@ var require_implementation = __commonJS({
|
|
|
9425
9425
|
return arr;
|
|
9426
9426
|
};
|
|
9427
9427
|
var joiny = function(arr, joiner) {
|
|
9428
|
-
var
|
|
9428
|
+
var str2 = "";
|
|
9429
9429
|
for (var i = 0; i < arr.length; i += 1) {
|
|
9430
|
-
|
|
9430
|
+
str2 += arr[i];
|
|
9431
9431
|
if (i + 1 < arr.length) {
|
|
9432
|
-
|
|
9432
|
+
str2 += joiner;
|
|
9433
9433
|
}
|
|
9434
9434
|
}
|
|
9435
|
-
return
|
|
9435
|
+
return str2;
|
|
9436
9436
|
};
|
|
9437
9437
|
module.exports = function bind2(that) {
|
|
9438
9438
|
var target = this;
|
|
@@ -9991,7 +9991,7 @@ var require_form_data = __commonJS({
|
|
|
9991
9991
|
var CombinedStream = require_combined_stream();
|
|
9992
9992
|
var util3 = __require("util");
|
|
9993
9993
|
var path = __require("path");
|
|
9994
|
-
var
|
|
9994
|
+
var http3 = __require("http");
|
|
9995
9995
|
var https2 = __require("https");
|
|
9996
9996
|
var parseUrl = __require("url").parse;
|
|
9997
9997
|
var fs = __require("fs");
|
|
@@ -10263,7 +10263,7 @@ var require_form_data = __commonJS({
|
|
|
10263
10263
|
if (options.protocol == "https:") {
|
|
10264
10264
|
request = https2.request(options);
|
|
10265
10265
|
} else {
|
|
10266
|
-
request =
|
|
10266
|
+
request = http3.request(options);
|
|
10267
10267
|
}
|
|
10268
10268
|
this.getLength(function(err, length) {
|
|
10269
10269
|
if (err && err !== "Unknown stream") {
|
|
@@ -10383,30 +10383,30 @@ var require_ms = __commonJS({
|
|
|
10383
10383
|
var y = d * 365.25;
|
|
10384
10384
|
module.exports = function(val, options) {
|
|
10385
10385
|
options = options || {};
|
|
10386
|
-
var
|
|
10387
|
-
if (
|
|
10386
|
+
var type2 = typeof val;
|
|
10387
|
+
if (type2 === "string" && val.length > 0) {
|
|
10388
10388
|
return parse(val);
|
|
10389
|
-
} else if (
|
|
10389
|
+
} else if (type2 === "number" && isFinite(val)) {
|
|
10390
10390
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
10391
10391
|
}
|
|
10392
10392
|
throw new Error(
|
|
10393
10393
|
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
10394
10394
|
);
|
|
10395
10395
|
};
|
|
10396
|
-
function parse(
|
|
10397
|
-
|
|
10398
|
-
if (
|
|
10396
|
+
function parse(str2) {
|
|
10397
|
+
str2 = String(str2);
|
|
10398
|
+
if (str2.length > 100) {
|
|
10399
10399
|
return;
|
|
10400
10400
|
}
|
|
10401
10401
|
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
10402
|
-
|
|
10402
|
+
str2
|
|
10403
10403
|
);
|
|
10404
10404
|
if (!match) {
|
|
10405
10405
|
return;
|
|
10406
10406
|
}
|
|
10407
10407
|
var n = parseFloat(match[1]);
|
|
10408
|
-
var
|
|
10409
|
-
switch (
|
|
10408
|
+
var type2 = (match[2] || "ms").toLowerCase();
|
|
10409
|
+
switch (type2) {
|
|
10410
10410
|
case "years":
|
|
10411
10411
|
case "year":
|
|
10412
10412
|
case "yrs":
|
|
@@ -10557,7 +10557,7 @@ var require_common = __commonJS({
|
|
|
10557
10557
|
debug.namespace = namespace;
|
|
10558
10558
|
debug.useColors = createDebug.useColors();
|
|
10559
10559
|
debug.color = createDebug.selectColor(namespace);
|
|
10560
|
-
debug.extend =
|
|
10560
|
+
debug.extend = extend4;
|
|
10561
10561
|
debug.destroy = createDebug.destroy;
|
|
10562
10562
|
Object.defineProperty(debug, "enabled", {
|
|
10563
10563
|
enumerable: true,
|
|
@@ -10581,7 +10581,7 @@ var require_common = __commonJS({
|
|
|
10581
10581
|
}
|
|
10582
10582
|
return debug;
|
|
10583
10583
|
}
|
|
10584
|
-
function
|
|
10584
|
+
function extend4(namespace, delimiter) {
|
|
10585
10585
|
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
10586
10586
|
newDebug.log = this.log;
|
|
10587
10587
|
return newDebug;
|
|
@@ -10670,7 +10670,7 @@ var require_browser = __commonJS({
|
|
|
10670
10670
|
"node_modules/debug/src/browser.js"(exports, module) {
|
|
10671
10671
|
exports.formatArgs = formatArgs;
|
|
10672
10672
|
exports.save = save;
|
|
10673
|
-
exports.load =
|
|
10673
|
+
exports.load = load2;
|
|
10674
10674
|
exports.useColors = useColors;
|
|
10675
10675
|
exports.storage = localstorage();
|
|
10676
10676
|
exports.destroy = /* @__PURE__ */ (() => {
|
|
@@ -10806,7 +10806,7 @@ var require_browser = __commonJS({
|
|
|
10806
10806
|
} catch (error) {
|
|
10807
10807
|
}
|
|
10808
10808
|
}
|
|
10809
|
-
function
|
|
10809
|
+
function load2() {
|
|
10810
10810
|
let r;
|
|
10811
10811
|
try {
|
|
10812
10812
|
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
@@ -10959,7 +10959,7 @@ var require_node = __commonJS({
|
|
|
10959
10959
|
exports.log = log;
|
|
10960
10960
|
exports.formatArgs = formatArgs;
|
|
10961
10961
|
exports.save = save;
|
|
10962
|
-
exports.load =
|
|
10962
|
+
exports.load = load2;
|
|
10963
10963
|
exports.useColors = useColors;
|
|
10964
10964
|
exports.destroy = util3.deprecate(
|
|
10965
10965
|
() => {
|
|
@@ -11101,7 +11101,7 @@ var require_node = __commonJS({
|
|
|
11101
11101
|
delete process.env.DEBUG;
|
|
11102
11102
|
}
|
|
11103
11103
|
}
|
|
11104
|
-
function
|
|
11104
|
+
function load2() {
|
|
11105
11105
|
return process.env.DEBUG;
|
|
11106
11106
|
}
|
|
11107
11107
|
function init(debug) {
|
|
@@ -11115,7 +11115,7 @@ var require_node = __commonJS({
|
|
|
11115
11115
|
var { formatters } = module.exports;
|
|
11116
11116
|
formatters.o = function(v) {
|
|
11117
11117
|
this.inspectOpts.colors = this.useColors;
|
|
11118
|
-
return util3.inspect(v, this.inspectOpts).split("\n").map((
|
|
11118
|
+
return util3.inspect(v, this.inspectOpts).split("\n").map((str2) => str2.trim()).join(" ");
|
|
11119
11119
|
};
|
|
11120
11120
|
formatters.O = function(v) {
|
|
11121
11121
|
this.inspectOpts.colors = this.useColors;
|
|
@@ -11160,7 +11160,7 @@ var require_follow_redirects = __commonJS({
|
|
|
11160
11160
|
"node_modules/follow-redirects/index.js"(exports, module) {
|
|
11161
11161
|
var url2 = __require("url");
|
|
11162
11162
|
var URL2 = url2.URL;
|
|
11163
|
-
var
|
|
11163
|
+
var http3 = __require("http");
|
|
11164
11164
|
var https2 = __require("https");
|
|
11165
11165
|
var Writable = __require("stream").Writable;
|
|
11166
11166
|
var assert = __require("assert");
|
|
@@ -11646,7 +11646,7 @@ var require_follow_redirects = __commonJS({
|
|
|
11646
11646
|
function isURL(value) {
|
|
11647
11647
|
return URL2 && value instanceof URL2;
|
|
11648
11648
|
}
|
|
11649
|
-
module.exports = wrap2({ http:
|
|
11649
|
+
module.exports = wrap2({ http: http3, https: https2 });
|
|
11650
11650
|
module.exports.wrap = wrap2;
|
|
11651
11651
|
}
|
|
11652
11652
|
});
|
|
@@ -11658,6 +11658,2959 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
11658
11658
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
11659
11659
|
import { ListToolsRequestSchema, CallToolRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
11660
11660
|
|
|
11661
|
+
// src/openapi-loader.ts
|
|
11662
|
+
import { readFile } from "fs/promises";
|
|
11663
|
+
|
|
11664
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
11665
|
+
function isNothing(subject) {
|
|
11666
|
+
return typeof subject === "undefined" || subject === null;
|
|
11667
|
+
}
|
|
11668
|
+
function isObject(subject) {
|
|
11669
|
+
return typeof subject === "object" && subject !== null;
|
|
11670
|
+
}
|
|
11671
|
+
function toArray(sequence) {
|
|
11672
|
+
if (Array.isArray(sequence)) return sequence;
|
|
11673
|
+
else if (isNothing(sequence)) return [];
|
|
11674
|
+
return [sequence];
|
|
11675
|
+
}
|
|
11676
|
+
function extend(target, source) {
|
|
11677
|
+
var index, length, key, sourceKeys;
|
|
11678
|
+
if (source) {
|
|
11679
|
+
sourceKeys = Object.keys(source);
|
|
11680
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
11681
|
+
key = sourceKeys[index];
|
|
11682
|
+
target[key] = source[key];
|
|
11683
|
+
}
|
|
11684
|
+
}
|
|
11685
|
+
return target;
|
|
11686
|
+
}
|
|
11687
|
+
function repeat(string, count) {
|
|
11688
|
+
var result = "", cycle;
|
|
11689
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
11690
|
+
result += string;
|
|
11691
|
+
}
|
|
11692
|
+
return result;
|
|
11693
|
+
}
|
|
11694
|
+
function isNegativeZero(number) {
|
|
11695
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
11696
|
+
}
|
|
11697
|
+
var isNothing_1 = isNothing;
|
|
11698
|
+
var isObject_1 = isObject;
|
|
11699
|
+
var toArray_1 = toArray;
|
|
11700
|
+
var repeat_1 = repeat;
|
|
11701
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
11702
|
+
var extend_1 = extend;
|
|
11703
|
+
var common = {
|
|
11704
|
+
isNothing: isNothing_1,
|
|
11705
|
+
isObject: isObject_1,
|
|
11706
|
+
toArray: toArray_1,
|
|
11707
|
+
repeat: repeat_1,
|
|
11708
|
+
isNegativeZero: isNegativeZero_1,
|
|
11709
|
+
extend: extend_1
|
|
11710
|
+
};
|
|
11711
|
+
function formatError(exception2, compact) {
|
|
11712
|
+
var where = "", message = exception2.reason || "(unknown reason)";
|
|
11713
|
+
if (!exception2.mark) return message;
|
|
11714
|
+
if (exception2.mark.name) {
|
|
11715
|
+
where += 'in "' + exception2.mark.name + '" ';
|
|
11716
|
+
}
|
|
11717
|
+
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
11718
|
+
if (!compact && exception2.mark.snippet) {
|
|
11719
|
+
where += "\n\n" + exception2.mark.snippet;
|
|
11720
|
+
}
|
|
11721
|
+
return message + " " + where;
|
|
11722
|
+
}
|
|
11723
|
+
function YAMLException$1(reason, mark) {
|
|
11724
|
+
Error.call(this);
|
|
11725
|
+
this.name = "YAMLException";
|
|
11726
|
+
this.reason = reason;
|
|
11727
|
+
this.mark = mark;
|
|
11728
|
+
this.message = formatError(this, false);
|
|
11729
|
+
if (Error.captureStackTrace) {
|
|
11730
|
+
Error.captureStackTrace(this, this.constructor);
|
|
11731
|
+
} else {
|
|
11732
|
+
this.stack = new Error().stack || "";
|
|
11733
|
+
}
|
|
11734
|
+
}
|
|
11735
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
11736
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
11737
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
11738
|
+
return this.name + ": " + formatError(this, compact);
|
|
11739
|
+
};
|
|
11740
|
+
var exception = YAMLException$1;
|
|
11741
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
11742
|
+
var head = "";
|
|
11743
|
+
var tail = "";
|
|
11744
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
11745
|
+
if (position - lineStart > maxHalfLength) {
|
|
11746
|
+
head = " ... ";
|
|
11747
|
+
lineStart = position - maxHalfLength + head.length;
|
|
11748
|
+
}
|
|
11749
|
+
if (lineEnd - position > maxHalfLength) {
|
|
11750
|
+
tail = " ...";
|
|
11751
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
11752
|
+
}
|
|
11753
|
+
return {
|
|
11754
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
11755
|
+
pos: position - lineStart + head.length
|
|
11756
|
+
// relative position
|
|
11757
|
+
};
|
|
11758
|
+
}
|
|
11759
|
+
function padStart(string, max) {
|
|
11760
|
+
return common.repeat(" ", max - string.length) + string;
|
|
11761
|
+
}
|
|
11762
|
+
function makeSnippet(mark, options) {
|
|
11763
|
+
options = Object.create(options || null);
|
|
11764
|
+
if (!mark.buffer) return null;
|
|
11765
|
+
if (!options.maxLength) options.maxLength = 79;
|
|
11766
|
+
if (typeof options.indent !== "number") options.indent = 1;
|
|
11767
|
+
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
11768
|
+
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
11769
|
+
var re = /\r?\n|\r|\0/g;
|
|
11770
|
+
var lineStarts = [0];
|
|
11771
|
+
var lineEnds = [];
|
|
11772
|
+
var match;
|
|
11773
|
+
var foundLineNo = -1;
|
|
11774
|
+
while (match = re.exec(mark.buffer)) {
|
|
11775
|
+
lineEnds.push(match.index);
|
|
11776
|
+
lineStarts.push(match.index + match[0].length);
|
|
11777
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
11778
|
+
foundLineNo = lineStarts.length - 2;
|
|
11779
|
+
}
|
|
11780
|
+
}
|
|
11781
|
+
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
11782
|
+
var result = "", i, line;
|
|
11783
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
11784
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
11785
|
+
for (i = 1; i <= options.linesBefore; i++) {
|
|
11786
|
+
if (foundLineNo - i < 0) break;
|
|
11787
|
+
line = getLine(
|
|
11788
|
+
mark.buffer,
|
|
11789
|
+
lineStarts[foundLineNo - i],
|
|
11790
|
+
lineEnds[foundLineNo - i],
|
|
11791
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
11792
|
+
maxLineLength
|
|
11793
|
+
);
|
|
11794
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
11795
|
+
}
|
|
11796
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
11797
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
11798
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
11799
|
+
for (i = 1; i <= options.linesAfter; i++) {
|
|
11800
|
+
if (foundLineNo + i >= lineEnds.length) break;
|
|
11801
|
+
line = getLine(
|
|
11802
|
+
mark.buffer,
|
|
11803
|
+
lineStarts[foundLineNo + i],
|
|
11804
|
+
lineEnds[foundLineNo + i],
|
|
11805
|
+
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
11806
|
+
maxLineLength
|
|
11807
|
+
);
|
|
11808
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
11809
|
+
}
|
|
11810
|
+
return result.replace(/\n$/, "");
|
|
11811
|
+
}
|
|
11812
|
+
var snippet = makeSnippet;
|
|
11813
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
11814
|
+
"kind",
|
|
11815
|
+
"multi",
|
|
11816
|
+
"resolve",
|
|
11817
|
+
"construct",
|
|
11818
|
+
"instanceOf",
|
|
11819
|
+
"predicate",
|
|
11820
|
+
"represent",
|
|
11821
|
+
"representName",
|
|
11822
|
+
"defaultStyle",
|
|
11823
|
+
"styleAliases"
|
|
11824
|
+
];
|
|
11825
|
+
var YAML_NODE_KINDS = [
|
|
11826
|
+
"scalar",
|
|
11827
|
+
"sequence",
|
|
11828
|
+
"mapping"
|
|
11829
|
+
];
|
|
11830
|
+
function compileStyleAliases(map2) {
|
|
11831
|
+
var result = {};
|
|
11832
|
+
if (map2 !== null) {
|
|
11833
|
+
Object.keys(map2).forEach(function(style) {
|
|
11834
|
+
map2[style].forEach(function(alias) {
|
|
11835
|
+
result[String(alias)] = style;
|
|
11836
|
+
});
|
|
11837
|
+
});
|
|
11838
|
+
}
|
|
11839
|
+
return result;
|
|
11840
|
+
}
|
|
11841
|
+
function Type$1(tag, options) {
|
|
11842
|
+
options = options || {};
|
|
11843
|
+
Object.keys(options).forEach(function(name) {
|
|
11844
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
11845
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
11846
|
+
}
|
|
11847
|
+
});
|
|
11848
|
+
this.options = options;
|
|
11849
|
+
this.tag = tag;
|
|
11850
|
+
this.kind = options["kind"] || null;
|
|
11851
|
+
this.resolve = options["resolve"] || function() {
|
|
11852
|
+
return true;
|
|
11853
|
+
};
|
|
11854
|
+
this.construct = options["construct"] || function(data) {
|
|
11855
|
+
return data;
|
|
11856
|
+
};
|
|
11857
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
11858
|
+
this.predicate = options["predicate"] || null;
|
|
11859
|
+
this.represent = options["represent"] || null;
|
|
11860
|
+
this.representName = options["representName"] || null;
|
|
11861
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
11862
|
+
this.multi = options["multi"] || false;
|
|
11863
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
11864
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
11865
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
11866
|
+
}
|
|
11867
|
+
}
|
|
11868
|
+
var type = Type$1;
|
|
11869
|
+
function compileList(schema2, name) {
|
|
11870
|
+
var result = [];
|
|
11871
|
+
schema2[name].forEach(function(currentType) {
|
|
11872
|
+
var newIndex = result.length;
|
|
11873
|
+
result.forEach(function(previousType, previousIndex) {
|
|
11874
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
11875
|
+
newIndex = previousIndex;
|
|
11876
|
+
}
|
|
11877
|
+
});
|
|
11878
|
+
result[newIndex] = currentType;
|
|
11879
|
+
});
|
|
11880
|
+
return result;
|
|
11881
|
+
}
|
|
11882
|
+
function compileMap() {
|
|
11883
|
+
var result = {
|
|
11884
|
+
scalar: {},
|
|
11885
|
+
sequence: {},
|
|
11886
|
+
mapping: {},
|
|
11887
|
+
fallback: {},
|
|
11888
|
+
multi: {
|
|
11889
|
+
scalar: [],
|
|
11890
|
+
sequence: [],
|
|
11891
|
+
mapping: [],
|
|
11892
|
+
fallback: []
|
|
11893
|
+
}
|
|
11894
|
+
}, index, length;
|
|
11895
|
+
function collectType(type2) {
|
|
11896
|
+
if (type2.multi) {
|
|
11897
|
+
result.multi[type2.kind].push(type2);
|
|
11898
|
+
result.multi["fallback"].push(type2);
|
|
11899
|
+
} else {
|
|
11900
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
11901
|
+
}
|
|
11902
|
+
}
|
|
11903
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
11904
|
+
arguments[index].forEach(collectType);
|
|
11905
|
+
}
|
|
11906
|
+
return result;
|
|
11907
|
+
}
|
|
11908
|
+
function Schema$1(definition) {
|
|
11909
|
+
return this.extend(definition);
|
|
11910
|
+
}
|
|
11911
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
11912
|
+
var implicit = [];
|
|
11913
|
+
var explicit = [];
|
|
11914
|
+
if (definition instanceof type) {
|
|
11915
|
+
explicit.push(definition);
|
|
11916
|
+
} else if (Array.isArray(definition)) {
|
|
11917
|
+
explicit = explicit.concat(definition);
|
|
11918
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
11919
|
+
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
11920
|
+
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
11921
|
+
} else {
|
|
11922
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
11923
|
+
}
|
|
11924
|
+
implicit.forEach(function(type$1) {
|
|
11925
|
+
if (!(type$1 instanceof type)) {
|
|
11926
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
11927
|
+
}
|
|
11928
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
11929
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
11930
|
+
}
|
|
11931
|
+
if (type$1.multi) {
|
|
11932
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
11933
|
+
}
|
|
11934
|
+
});
|
|
11935
|
+
explicit.forEach(function(type$1) {
|
|
11936
|
+
if (!(type$1 instanceof type)) {
|
|
11937
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
11938
|
+
}
|
|
11939
|
+
});
|
|
11940
|
+
var result = Object.create(Schema$1.prototype);
|
|
11941
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
11942
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
11943
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
11944
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
11945
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
11946
|
+
return result;
|
|
11947
|
+
};
|
|
11948
|
+
var schema = Schema$1;
|
|
11949
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
11950
|
+
kind: "scalar",
|
|
11951
|
+
construct: function(data) {
|
|
11952
|
+
return data !== null ? data : "";
|
|
11953
|
+
}
|
|
11954
|
+
});
|
|
11955
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
11956
|
+
kind: "sequence",
|
|
11957
|
+
construct: function(data) {
|
|
11958
|
+
return data !== null ? data : [];
|
|
11959
|
+
}
|
|
11960
|
+
});
|
|
11961
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
11962
|
+
kind: "mapping",
|
|
11963
|
+
construct: function(data) {
|
|
11964
|
+
return data !== null ? data : {};
|
|
11965
|
+
}
|
|
11966
|
+
});
|
|
11967
|
+
var failsafe = new schema({
|
|
11968
|
+
explicit: [
|
|
11969
|
+
str,
|
|
11970
|
+
seq,
|
|
11971
|
+
map
|
|
11972
|
+
]
|
|
11973
|
+
});
|
|
11974
|
+
function resolveYamlNull(data) {
|
|
11975
|
+
if (data === null) return true;
|
|
11976
|
+
var max = data.length;
|
|
11977
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
11978
|
+
}
|
|
11979
|
+
function constructYamlNull() {
|
|
11980
|
+
return null;
|
|
11981
|
+
}
|
|
11982
|
+
function isNull(object) {
|
|
11983
|
+
return object === null;
|
|
11984
|
+
}
|
|
11985
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
11986
|
+
kind: "scalar",
|
|
11987
|
+
resolve: resolveYamlNull,
|
|
11988
|
+
construct: constructYamlNull,
|
|
11989
|
+
predicate: isNull,
|
|
11990
|
+
represent: {
|
|
11991
|
+
canonical: function() {
|
|
11992
|
+
return "~";
|
|
11993
|
+
},
|
|
11994
|
+
lowercase: function() {
|
|
11995
|
+
return "null";
|
|
11996
|
+
},
|
|
11997
|
+
uppercase: function() {
|
|
11998
|
+
return "NULL";
|
|
11999
|
+
},
|
|
12000
|
+
camelcase: function() {
|
|
12001
|
+
return "Null";
|
|
12002
|
+
},
|
|
12003
|
+
empty: function() {
|
|
12004
|
+
return "";
|
|
12005
|
+
}
|
|
12006
|
+
},
|
|
12007
|
+
defaultStyle: "lowercase"
|
|
12008
|
+
});
|
|
12009
|
+
function resolveYamlBoolean(data) {
|
|
12010
|
+
if (data === null) return false;
|
|
12011
|
+
var max = data.length;
|
|
12012
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
12013
|
+
}
|
|
12014
|
+
function constructYamlBoolean(data) {
|
|
12015
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
12016
|
+
}
|
|
12017
|
+
function isBoolean(object) {
|
|
12018
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
12019
|
+
}
|
|
12020
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
12021
|
+
kind: "scalar",
|
|
12022
|
+
resolve: resolveYamlBoolean,
|
|
12023
|
+
construct: constructYamlBoolean,
|
|
12024
|
+
predicate: isBoolean,
|
|
12025
|
+
represent: {
|
|
12026
|
+
lowercase: function(object) {
|
|
12027
|
+
return object ? "true" : "false";
|
|
12028
|
+
},
|
|
12029
|
+
uppercase: function(object) {
|
|
12030
|
+
return object ? "TRUE" : "FALSE";
|
|
12031
|
+
},
|
|
12032
|
+
camelcase: function(object) {
|
|
12033
|
+
return object ? "True" : "False";
|
|
12034
|
+
}
|
|
12035
|
+
},
|
|
12036
|
+
defaultStyle: "lowercase"
|
|
12037
|
+
});
|
|
12038
|
+
function isHexCode(c) {
|
|
12039
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
12040
|
+
}
|
|
12041
|
+
function isOctCode(c) {
|
|
12042
|
+
return 48 <= c && c <= 55;
|
|
12043
|
+
}
|
|
12044
|
+
function isDecCode(c) {
|
|
12045
|
+
return 48 <= c && c <= 57;
|
|
12046
|
+
}
|
|
12047
|
+
function resolveYamlInteger(data) {
|
|
12048
|
+
if (data === null) return false;
|
|
12049
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
12050
|
+
if (!max) return false;
|
|
12051
|
+
ch = data[index];
|
|
12052
|
+
if (ch === "-" || ch === "+") {
|
|
12053
|
+
ch = data[++index];
|
|
12054
|
+
}
|
|
12055
|
+
if (ch === "0") {
|
|
12056
|
+
if (index + 1 === max) return true;
|
|
12057
|
+
ch = data[++index];
|
|
12058
|
+
if (ch === "b") {
|
|
12059
|
+
index++;
|
|
12060
|
+
for (; index < max; index++) {
|
|
12061
|
+
ch = data[index];
|
|
12062
|
+
if (ch === "_") continue;
|
|
12063
|
+
if (ch !== "0" && ch !== "1") return false;
|
|
12064
|
+
hasDigits = true;
|
|
12065
|
+
}
|
|
12066
|
+
return hasDigits && ch !== "_";
|
|
12067
|
+
}
|
|
12068
|
+
if (ch === "x") {
|
|
12069
|
+
index++;
|
|
12070
|
+
for (; index < max; index++) {
|
|
12071
|
+
ch = data[index];
|
|
12072
|
+
if (ch === "_") continue;
|
|
12073
|
+
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
12074
|
+
hasDigits = true;
|
|
12075
|
+
}
|
|
12076
|
+
return hasDigits && ch !== "_";
|
|
12077
|
+
}
|
|
12078
|
+
if (ch === "o") {
|
|
12079
|
+
index++;
|
|
12080
|
+
for (; index < max; index++) {
|
|
12081
|
+
ch = data[index];
|
|
12082
|
+
if (ch === "_") continue;
|
|
12083
|
+
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
12084
|
+
hasDigits = true;
|
|
12085
|
+
}
|
|
12086
|
+
return hasDigits && ch !== "_";
|
|
12087
|
+
}
|
|
12088
|
+
}
|
|
12089
|
+
if (ch === "_") return false;
|
|
12090
|
+
for (; index < max; index++) {
|
|
12091
|
+
ch = data[index];
|
|
12092
|
+
if (ch === "_") continue;
|
|
12093
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
12094
|
+
return false;
|
|
12095
|
+
}
|
|
12096
|
+
hasDigits = true;
|
|
12097
|
+
}
|
|
12098
|
+
if (!hasDigits || ch === "_") return false;
|
|
12099
|
+
return true;
|
|
12100
|
+
}
|
|
12101
|
+
function constructYamlInteger(data) {
|
|
12102
|
+
var value = data, sign = 1, ch;
|
|
12103
|
+
if (value.indexOf("_") !== -1) {
|
|
12104
|
+
value = value.replace(/_/g, "");
|
|
12105
|
+
}
|
|
12106
|
+
ch = value[0];
|
|
12107
|
+
if (ch === "-" || ch === "+") {
|
|
12108
|
+
if (ch === "-") sign = -1;
|
|
12109
|
+
value = value.slice(1);
|
|
12110
|
+
ch = value[0];
|
|
12111
|
+
}
|
|
12112
|
+
if (value === "0") return 0;
|
|
12113
|
+
if (ch === "0") {
|
|
12114
|
+
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
12115
|
+
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
12116
|
+
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
12117
|
+
}
|
|
12118
|
+
return sign * parseInt(value, 10);
|
|
12119
|
+
}
|
|
12120
|
+
function isInteger(object) {
|
|
12121
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
12122
|
+
}
|
|
12123
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
12124
|
+
kind: "scalar",
|
|
12125
|
+
resolve: resolveYamlInteger,
|
|
12126
|
+
construct: constructYamlInteger,
|
|
12127
|
+
predicate: isInteger,
|
|
12128
|
+
represent: {
|
|
12129
|
+
binary: function(obj) {
|
|
12130
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
12131
|
+
},
|
|
12132
|
+
octal: function(obj) {
|
|
12133
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
12134
|
+
},
|
|
12135
|
+
decimal: function(obj) {
|
|
12136
|
+
return obj.toString(10);
|
|
12137
|
+
},
|
|
12138
|
+
/* eslint-disable max-len */
|
|
12139
|
+
hexadecimal: function(obj) {
|
|
12140
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
12141
|
+
}
|
|
12142
|
+
},
|
|
12143
|
+
defaultStyle: "decimal",
|
|
12144
|
+
styleAliases: {
|
|
12145
|
+
binary: [2, "bin"],
|
|
12146
|
+
octal: [8, "oct"],
|
|
12147
|
+
decimal: [10, "dec"],
|
|
12148
|
+
hexadecimal: [16, "hex"]
|
|
12149
|
+
}
|
|
12150
|
+
});
|
|
12151
|
+
var YAML_FLOAT_PATTERN = new RegExp(
|
|
12152
|
+
// 2.5e4, 2.5 and integers
|
|
12153
|
+
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
12154
|
+
);
|
|
12155
|
+
function resolveYamlFloat(data) {
|
|
12156
|
+
if (data === null) return false;
|
|
12157
|
+
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
12158
|
+
// Probably should update regexp & check speed
|
|
12159
|
+
data[data.length - 1] === "_") {
|
|
12160
|
+
return false;
|
|
12161
|
+
}
|
|
12162
|
+
return true;
|
|
12163
|
+
}
|
|
12164
|
+
function constructYamlFloat(data) {
|
|
12165
|
+
var value, sign;
|
|
12166
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
12167
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
12168
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
12169
|
+
value = value.slice(1);
|
|
12170
|
+
}
|
|
12171
|
+
if (value === ".inf") {
|
|
12172
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
12173
|
+
} else if (value === ".nan") {
|
|
12174
|
+
return NaN;
|
|
12175
|
+
}
|
|
12176
|
+
return sign * parseFloat(value, 10);
|
|
12177
|
+
}
|
|
12178
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
12179
|
+
function representYamlFloat(object, style) {
|
|
12180
|
+
var res;
|
|
12181
|
+
if (isNaN(object)) {
|
|
12182
|
+
switch (style) {
|
|
12183
|
+
case "lowercase":
|
|
12184
|
+
return ".nan";
|
|
12185
|
+
case "uppercase":
|
|
12186
|
+
return ".NAN";
|
|
12187
|
+
case "camelcase":
|
|
12188
|
+
return ".NaN";
|
|
12189
|
+
}
|
|
12190
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
12191
|
+
switch (style) {
|
|
12192
|
+
case "lowercase":
|
|
12193
|
+
return ".inf";
|
|
12194
|
+
case "uppercase":
|
|
12195
|
+
return ".INF";
|
|
12196
|
+
case "camelcase":
|
|
12197
|
+
return ".Inf";
|
|
12198
|
+
}
|
|
12199
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
12200
|
+
switch (style) {
|
|
12201
|
+
case "lowercase":
|
|
12202
|
+
return "-.inf";
|
|
12203
|
+
case "uppercase":
|
|
12204
|
+
return "-.INF";
|
|
12205
|
+
case "camelcase":
|
|
12206
|
+
return "-.Inf";
|
|
12207
|
+
}
|
|
12208
|
+
} else if (common.isNegativeZero(object)) {
|
|
12209
|
+
return "-0.0";
|
|
12210
|
+
}
|
|
12211
|
+
res = object.toString(10);
|
|
12212
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
12213
|
+
}
|
|
12214
|
+
function isFloat(object) {
|
|
12215
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
12216
|
+
}
|
|
12217
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
12218
|
+
kind: "scalar",
|
|
12219
|
+
resolve: resolveYamlFloat,
|
|
12220
|
+
construct: constructYamlFloat,
|
|
12221
|
+
predicate: isFloat,
|
|
12222
|
+
represent: representYamlFloat,
|
|
12223
|
+
defaultStyle: "lowercase"
|
|
12224
|
+
});
|
|
12225
|
+
var json = failsafe.extend({
|
|
12226
|
+
implicit: [
|
|
12227
|
+
_null,
|
|
12228
|
+
bool,
|
|
12229
|
+
int,
|
|
12230
|
+
float
|
|
12231
|
+
]
|
|
12232
|
+
});
|
|
12233
|
+
var core = json;
|
|
12234
|
+
var YAML_DATE_REGEXP = new RegExp(
|
|
12235
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
12236
|
+
);
|
|
12237
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
12238
|
+
"^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
|
|
12239
|
+
);
|
|
12240
|
+
function resolveYamlTimestamp(data) {
|
|
12241
|
+
if (data === null) return false;
|
|
12242
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
12243
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
12244
|
+
return false;
|
|
12245
|
+
}
|
|
12246
|
+
function constructYamlTimestamp(data) {
|
|
12247
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
12248
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
12249
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
12250
|
+
if (match === null) throw new Error("Date resolve error");
|
|
12251
|
+
year = +match[1];
|
|
12252
|
+
month = +match[2] - 1;
|
|
12253
|
+
day = +match[3];
|
|
12254
|
+
if (!match[4]) {
|
|
12255
|
+
return new Date(Date.UTC(year, month, day));
|
|
12256
|
+
}
|
|
12257
|
+
hour = +match[4];
|
|
12258
|
+
minute = +match[5];
|
|
12259
|
+
second = +match[6];
|
|
12260
|
+
if (match[7]) {
|
|
12261
|
+
fraction = match[7].slice(0, 3);
|
|
12262
|
+
while (fraction.length < 3) {
|
|
12263
|
+
fraction += "0";
|
|
12264
|
+
}
|
|
12265
|
+
fraction = +fraction;
|
|
12266
|
+
}
|
|
12267
|
+
if (match[9]) {
|
|
12268
|
+
tz_hour = +match[10];
|
|
12269
|
+
tz_minute = +(match[11] || 0);
|
|
12270
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
12271
|
+
if (match[9] === "-") delta = -delta;
|
|
12272
|
+
}
|
|
12273
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
12274
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
12275
|
+
return date;
|
|
12276
|
+
}
|
|
12277
|
+
function representYamlTimestamp(object) {
|
|
12278
|
+
return object.toISOString();
|
|
12279
|
+
}
|
|
12280
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
12281
|
+
kind: "scalar",
|
|
12282
|
+
resolve: resolveYamlTimestamp,
|
|
12283
|
+
construct: constructYamlTimestamp,
|
|
12284
|
+
instanceOf: Date,
|
|
12285
|
+
represent: representYamlTimestamp
|
|
12286
|
+
});
|
|
12287
|
+
function resolveYamlMerge(data) {
|
|
12288
|
+
return data === "<<" || data === null;
|
|
12289
|
+
}
|
|
12290
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
12291
|
+
kind: "scalar",
|
|
12292
|
+
resolve: resolveYamlMerge
|
|
12293
|
+
});
|
|
12294
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
12295
|
+
function resolveYamlBinary(data) {
|
|
12296
|
+
if (data === null) return false;
|
|
12297
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
12298
|
+
for (idx = 0; idx < max; idx++) {
|
|
12299
|
+
code = map2.indexOf(data.charAt(idx));
|
|
12300
|
+
if (code > 64) continue;
|
|
12301
|
+
if (code < 0) return false;
|
|
12302
|
+
bitlen += 6;
|
|
12303
|
+
}
|
|
12304
|
+
return bitlen % 8 === 0;
|
|
12305
|
+
}
|
|
12306
|
+
function constructYamlBinary(data) {
|
|
12307
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
12308
|
+
for (idx = 0; idx < max; idx++) {
|
|
12309
|
+
if (idx % 4 === 0 && idx) {
|
|
12310
|
+
result.push(bits >> 16 & 255);
|
|
12311
|
+
result.push(bits >> 8 & 255);
|
|
12312
|
+
result.push(bits & 255);
|
|
12313
|
+
}
|
|
12314
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
12315
|
+
}
|
|
12316
|
+
tailbits = max % 4 * 6;
|
|
12317
|
+
if (tailbits === 0) {
|
|
12318
|
+
result.push(bits >> 16 & 255);
|
|
12319
|
+
result.push(bits >> 8 & 255);
|
|
12320
|
+
result.push(bits & 255);
|
|
12321
|
+
} else if (tailbits === 18) {
|
|
12322
|
+
result.push(bits >> 10 & 255);
|
|
12323
|
+
result.push(bits >> 2 & 255);
|
|
12324
|
+
} else if (tailbits === 12) {
|
|
12325
|
+
result.push(bits >> 4 & 255);
|
|
12326
|
+
}
|
|
12327
|
+
return new Uint8Array(result);
|
|
12328
|
+
}
|
|
12329
|
+
function representYamlBinary(object) {
|
|
12330
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
12331
|
+
for (idx = 0; idx < max; idx++) {
|
|
12332
|
+
if (idx % 3 === 0 && idx) {
|
|
12333
|
+
result += map2[bits >> 18 & 63];
|
|
12334
|
+
result += map2[bits >> 12 & 63];
|
|
12335
|
+
result += map2[bits >> 6 & 63];
|
|
12336
|
+
result += map2[bits & 63];
|
|
12337
|
+
}
|
|
12338
|
+
bits = (bits << 8) + object[idx];
|
|
12339
|
+
}
|
|
12340
|
+
tail = max % 3;
|
|
12341
|
+
if (tail === 0) {
|
|
12342
|
+
result += map2[bits >> 18 & 63];
|
|
12343
|
+
result += map2[bits >> 12 & 63];
|
|
12344
|
+
result += map2[bits >> 6 & 63];
|
|
12345
|
+
result += map2[bits & 63];
|
|
12346
|
+
} else if (tail === 2) {
|
|
12347
|
+
result += map2[bits >> 10 & 63];
|
|
12348
|
+
result += map2[bits >> 4 & 63];
|
|
12349
|
+
result += map2[bits << 2 & 63];
|
|
12350
|
+
result += map2[64];
|
|
12351
|
+
} else if (tail === 1) {
|
|
12352
|
+
result += map2[bits >> 2 & 63];
|
|
12353
|
+
result += map2[bits << 4 & 63];
|
|
12354
|
+
result += map2[64];
|
|
12355
|
+
result += map2[64];
|
|
12356
|
+
}
|
|
12357
|
+
return result;
|
|
12358
|
+
}
|
|
12359
|
+
function isBinary(obj) {
|
|
12360
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
12361
|
+
}
|
|
12362
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
12363
|
+
kind: "scalar",
|
|
12364
|
+
resolve: resolveYamlBinary,
|
|
12365
|
+
construct: constructYamlBinary,
|
|
12366
|
+
predicate: isBinary,
|
|
12367
|
+
represent: representYamlBinary
|
|
12368
|
+
});
|
|
12369
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
12370
|
+
var _toString$2 = Object.prototype.toString;
|
|
12371
|
+
function resolveYamlOmap(data) {
|
|
12372
|
+
if (data === null) return true;
|
|
12373
|
+
var objectKeys2 = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
12374
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
12375
|
+
pair = object[index];
|
|
12376
|
+
pairHasKey = false;
|
|
12377
|
+
if (_toString$2.call(pair) !== "[object Object]") return false;
|
|
12378
|
+
for (pairKey in pair) {
|
|
12379
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
12380
|
+
if (!pairHasKey) pairHasKey = true;
|
|
12381
|
+
else return false;
|
|
12382
|
+
}
|
|
12383
|
+
}
|
|
12384
|
+
if (!pairHasKey) return false;
|
|
12385
|
+
if (objectKeys2.indexOf(pairKey) === -1) objectKeys2.push(pairKey);
|
|
12386
|
+
else return false;
|
|
12387
|
+
}
|
|
12388
|
+
return true;
|
|
12389
|
+
}
|
|
12390
|
+
function constructYamlOmap(data) {
|
|
12391
|
+
return data !== null ? data : [];
|
|
12392
|
+
}
|
|
12393
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
12394
|
+
kind: "sequence",
|
|
12395
|
+
resolve: resolveYamlOmap,
|
|
12396
|
+
construct: constructYamlOmap
|
|
12397
|
+
});
|
|
12398
|
+
var _toString$1 = Object.prototype.toString;
|
|
12399
|
+
function resolveYamlPairs(data) {
|
|
12400
|
+
if (data === null) return true;
|
|
12401
|
+
var index, length, pair, keys, result, object = data;
|
|
12402
|
+
result = new Array(object.length);
|
|
12403
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
12404
|
+
pair = object[index];
|
|
12405
|
+
if (_toString$1.call(pair) !== "[object Object]") return false;
|
|
12406
|
+
keys = Object.keys(pair);
|
|
12407
|
+
if (keys.length !== 1) return false;
|
|
12408
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
12409
|
+
}
|
|
12410
|
+
return true;
|
|
12411
|
+
}
|
|
12412
|
+
function constructYamlPairs(data) {
|
|
12413
|
+
if (data === null) return [];
|
|
12414
|
+
var index, length, pair, keys, result, object = data;
|
|
12415
|
+
result = new Array(object.length);
|
|
12416
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
12417
|
+
pair = object[index];
|
|
12418
|
+
keys = Object.keys(pair);
|
|
12419
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
12420
|
+
}
|
|
12421
|
+
return result;
|
|
12422
|
+
}
|
|
12423
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
12424
|
+
kind: "sequence",
|
|
12425
|
+
resolve: resolveYamlPairs,
|
|
12426
|
+
construct: constructYamlPairs
|
|
12427
|
+
});
|
|
12428
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
12429
|
+
function resolveYamlSet(data) {
|
|
12430
|
+
if (data === null) return true;
|
|
12431
|
+
var key, object = data;
|
|
12432
|
+
for (key in object) {
|
|
12433
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
12434
|
+
if (object[key] !== null) return false;
|
|
12435
|
+
}
|
|
12436
|
+
}
|
|
12437
|
+
return true;
|
|
12438
|
+
}
|
|
12439
|
+
function constructYamlSet(data) {
|
|
12440
|
+
return data !== null ? data : {};
|
|
12441
|
+
}
|
|
12442
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
12443
|
+
kind: "mapping",
|
|
12444
|
+
resolve: resolveYamlSet,
|
|
12445
|
+
construct: constructYamlSet
|
|
12446
|
+
});
|
|
12447
|
+
var _default = core.extend({
|
|
12448
|
+
implicit: [
|
|
12449
|
+
timestamp,
|
|
12450
|
+
merge
|
|
12451
|
+
],
|
|
12452
|
+
explicit: [
|
|
12453
|
+
binary,
|
|
12454
|
+
omap,
|
|
12455
|
+
pairs,
|
|
12456
|
+
set
|
|
12457
|
+
]
|
|
12458
|
+
});
|
|
12459
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
12460
|
+
var CONTEXT_FLOW_IN = 1;
|
|
12461
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
12462
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
12463
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
12464
|
+
var CHOMPING_CLIP = 1;
|
|
12465
|
+
var CHOMPING_STRIP = 2;
|
|
12466
|
+
var CHOMPING_KEEP = 3;
|
|
12467
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
12468
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
12469
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
12470
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
12471
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
12472
|
+
function _class(obj) {
|
|
12473
|
+
return Object.prototype.toString.call(obj);
|
|
12474
|
+
}
|
|
12475
|
+
function is_EOL(c) {
|
|
12476
|
+
return c === 10 || c === 13;
|
|
12477
|
+
}
|
|
12478
|
+
function is_WHITE_SPACE(c) {
|
|
12479
|
+
return c === 9 || c === 32;
|
|
12480
|
+
}
|
|
12481
|
+
function is_WS_OR_EOL(c) {
|
|
12482
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
12483
|
+
}
|
|
12484
|
+
function is_FLOW_INDICATOR(c) {
|
|
12485
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
12486
|
+
}
|
|
12487
|
+
function fromHexCode(c) {
|
|
12488
|
+
var lc;
|
|
12489
|
+
if (48 <= c && c <= 57) {
|
|
12490
|
+
return c - 48;
|
|
12491
|
+
}
|
|
12492
|
+
lc = c | 32;
|
|
12493
|
+
if (97 <= lc && lc <= 102) {
|
|
12494
|
+
return lc - 97 + 10;
|
|
12495
|
+
}
|
|
12496
|
+
return -1;
|
|
12497
|
+
}
|
|
12498
|
+
function escapedHexLen(c) {
|
|
12499
|
+
if (c === 120) {
|
|
12500
|
+
return 2;
|
|
12501
|
+
}
|
|
12502
|
+
if (c === 117) {
|
|
12503
|
+
return 4;
|
|
12504
|
+
}
|
|
12505
|
+
if (c === 85) {
|
|
12506
|
+
return 8;
|
|
12507
|
+
}
|
|
12508
|
+
return 0;
|
|
12509
|
+
}
|
|
12510
|
+
function fromDecimalCode(c) {
|
|
12511
|
+
if (48 <= c && c <= 57) {
|
|
12512
|
+
return c - 48;
|
|
12513
|
+
}
|
|
12514
|
+
return -1;
|
|
12515
|
+
}
|
|
12516
|
+
function simpleEscapeSequence(c) {
|
|
12517
|
+
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
12518
|
+
}
|
|
12519
|
+
function charFromCodepoint(c) {
|
|
12520
|
+
if (c <= 65535) {
|
|
12521
|
+
return String.fromCharCode(c);
|
|
12522
|
+
}
|
|
12523
|
+
return String.fromCharCode(
|
|
12524
|
+
(c - 65536 >> 10) + 55296,
|
|
12525
|
+
(c - 65536 & 1023) + 56320
|
|
12526
|
+
);
|
|
12527
|
+
}
|
|
12528
|
+
var simpleEscapeCheck = new Array(256);
|
|
12529
|
+
var simpleEscapeMap = new Array(256);
|
|
12530
|
+
for (i = 0; i < 256; i++) {
|
|
12531
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
12532
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
12533
|
+
}
|
|
12534
|
+
var i;
|
|
12535
|
+
function State$1(input, options) {
|
|
12536
|
+
this.input = input;
|
|
12537
|
+
this.filename = options["filename"] || null;
|
|
12538
|
+
this.schema = options["schema"] || _default;
|
|
12539
|
+
this.onWarning = options["onWarning"] || null;
|
|
12540
|
+
this.legacy = options["legacy"] || false;
|
|
12541
|
+
this.json = options["json"] || false;
|
|
12542
|
+
this.listener = options["listener"] || null;
|
|
12543
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
12544
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
12545
|
+
this.length = input.length;
|
|
12546
|
+
this.position = 0;
|
|
12547
|
+
this.line = 0;
|
|
12548
|
+
this.lineStart = 0;
|
|
12549
|
+
this.lineIndent = 0;
|
|
12550
|
+
this.firstTabInLine = -1;
|
|
12551
|
+
this.documents = [];
|
|
12552
|
+
}
|
|
12553
|
+
function generateError(state, message) {
|
|
12554
|
+
var mark = {
|
|
12555
|
+
name: state.filename,
|
|
12556
|
+
buffer: state.input.slice(0, -1),
|
|
12557
|
+
// omit trailing \0
|
|
12558
|
+
position: state.position,
|
|
12559
|
+
line: state.line,
|
|
12560
|
+
column: state.position - state.lineStart
|
|
12561
|
+
};
|
|
12562
|
+
mark.snippet = snippet(mark);
|
|
12563
|
+
return new exception(message, mark);
|
|
12564
|
+
}
|
|
12565
|
+
function throwError(state, message) {
|
|
12566
|
+
throw generateError(state, message);
|
|
12567
|
+
}
|
|
12568
|
+
function throwWarning(state, message) {
|
|
12569
|
+
if (state.onWarning) {
|
|
12570
|
+
state.onWarning.call(null, generateError(state, message));
|
|
12571
|
+
}
|
|
12572
|
+
}
|
|
12573
|
+
var directiveHandlers = {
|
|
12574
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
12575
|
+
var match, major, minor;
|
|
12576
|
+
if (state.version !== null) {
|
|
12577
|
+
throwError(state, "duplication of %YAML directive");
|
|
12578
|
+
}
|
|
12579
|
+
if (args.length !== 1) {
|
|
12580
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
12581
|
+
}
|
|
12582
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
12583
|
+
if (match === null) {
|
|
12584
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
12585
|
+
}
|
|
12586
|
+
major = parseInt(match[1], 10);
|
|
12587
|
+
minor = parseInt(match[2], 10);
|
|
12588
|
+
if (major !== 1) {
|
|
12589
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
12590
|
+
}
|
|
12591
|
+
state.version = args[0];
|
|
12592
|
+
state.checkLineBreaks = minor < 2;
|
|
12593
|
+
if (minor !== 1 && minor !== 2) {
|
|
12594
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
12595
|
+
}
|
|
12596
|
+
},
|
|
12597
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
12598
|
+
var handle, prefix;
|
|
12599
|
+
if (args.length !== 2) {
|
|
12600
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
12601
|
+
}
|
|
12602
|
+
handle = args[0];
|
|
12603
|
+
prefix = args[1];
|
|
12604
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
12605
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
12606
|
+
}
|
|
12607
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
12608
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
12609
|
+
}
|
|
12610
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
12611
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
12612
|
+
}
|
|
12613
|
+
try {
|
|
12614
|
+
prefix = decodeURIComponent(prefix);
|
|
12615
|
+
} catch (err) {
|
|
12616
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
12617
|
+
}
|
|
12618
|
+
state.tagMap[handle] = prefix;
|
|
12619
|
+
}
|
|
12620
|
+
};
|
|
12621
|
+
function captureSegment(state, start, end, checkJson) {
|
|
12622
|
+
var _position, _length, _character, _result;
|
|
12623
|
+
if (start < end) {
|
|
12624
|
+
_result = state.input.slice(start, end);
|
|
12625
|
+
if (checkJson) {
|
|
12626
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
12627
|
+
_character = _result.charCodeAt(_position);
|
|
12628
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
12629
|
+
throwError(state, "expected valid JSON character");
|
|
12630
|
+
}
|
|
12631
|
+
}
|
|
12632
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
12633
|
+
throwError(state, "the stream contains non-printable characters");
|
|
12634
|
+
}
|
|
12635
|
+
state.result += _result;
|
|
12636
|
+
}
|
|
12637
|
+
}
|
|
12638
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
12639
|
+
var sourceKeys, key, index, quantity;
|
|
12640
|
+
if (!common.isObject(source)) {
|
|
12641
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
12642
|
+
}
|
|
12643
|
+
sourceKeys = Object.keys(source);
|
|
12644
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
12645
|
+
key = sourceKeys[index];
|
|
12646
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
12647
|
+
destination[key] = source[key];
|
|
12648
|
+
overridableKeys[key] = true;
|
|
12649
|
+
}
|
|
12650
|
+
}
|
|
12651
|
+
}
|
|
12652
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
12653
|
+
var index, quantity;
|
|
12654
|
+
if (Array.isArray(keyNode)) {
|
|
12655
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
12656
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
12657
|
+
if (Array.isArray(keyNode[index])) {
|
|
12658
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
12659
|
+
}
|
|
12660
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
12661
|
+
keyNode[index] = "[object Object]";
|
|
12662
|
+
}
|
|
12663
|
+
}
|
|
12664
|
+
}
|
|
12665
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
12666
|
+
keyNode = "[object Object]";
|
|
12667
|
+
}
|
|
12668
|
+
keyNode = String(keyNode);
|
|
12669
|
+
if (_result === null) {
|
|
12670
|
+
_result = {};
|
|
12671
|
+
}
|
|
12672
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
12673
|
+
if (Array.isArray(valueNode)) {
|
|
12674
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
12675
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
12676
|
+
}
|
|
12677
|
+
} else {
|
|
12678
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
12679
|
+
}
|
|
12680
|
+
} else {
|
|
12681
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
12682
|
+
state.line = startLine || state.line;
|
|
12683
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
12684
|
+
state.position = startPos || state.position;
|
|
12685
|
+
throwError(state, "duplicated mapping key");
|
|
12686
|
+
}
|
|
12687
|
+
if (keyNode === "__proto__") {
|
|
12688
|
+
Object.defineProperty(_result, keyNode, {
|
|
12689
|
+
configurable: true,
|
|
12690
|
+
enumerable: true,
|
|
12691
|
+
writable: true,
|
|
12692
|
+
value: valueNode
|
|
12693
|
+
});
|
|
12694
|
+
} else {
|
|
12695
|
+
_result[keyNode] = valueNode;
|
|
12696
|
+
}
|
|
12697
|
+
delete overridableKeys[keyNode];
|
|
12698
|
+
}
|
|
12699
|
+
return _result;
|
|
12700
|
+
}
|
|
12701
|
+
function readLineBreak(state) {
|
|
12702
|
+
var ch;
|
|
12703
|
+
ch = state.input.charCodeAt(state.position);
|
|
12704
|
+
if (ch === 10) {
|
|
12705
|
+
state.position++;
|
|
12706
|
+
} else if (ch === 13) {
|
|
12707
|
+
state.position++;
|
|
12708
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
12709
|
+
state.position++;
|
|
12710
|
+
}
|
|
12711
|
+
} else {
|
|
12712
|
+
throwError(state, "a line break is expected");
|
|
12713
|
+
}
|
|
12714
|
+
state.line += 1;
|
|
12715
|
+
state.lineStart = state.position;
|
|
12716
|
+
state.firstTabInLine = -1;
|
|
12717
|
+
}
|
|
12718
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
12719
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
12720
|
+
while (ch !== 0) {
|
|
12721
|
+
while (is_WHITE_SPACE(ch)) {
|
|
12722
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
12723
|
+
state.firstTabInLine = state.position;
|
|
12724
|
+
}
|
|
12725
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12726
|
+
}
|
|
12727
|
+
if (allowComments && ch === 35) {
|
|
12728
|
+
do {
|
|
12729
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12730
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
12731
|
+
}
|
|
12732
|
+
if (is_EOL(ch)) {
|
|
12733
|
+
readLineBreak(state);
|
|
12734
|
+
ch = state.input.charCodeAt(state.position);
|
|
12735
|
+
lineBreaks++;
|
|
12736
|
+
state.lineIndent = 0;
|
|
12737
|
+
while (ch === 32) {
|
|
12738
|
+
state.lineIndent++;
|
|
12739
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12740
|
+
}
|
|
12741
|
+
} else {
|
|
12742
|
+
break;
|
|
12743
|
+
}
|
|
12744
|
+
}
|
|
12745
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
12746
|
+
throwWarning(state, "deficient indentation");
|
|
12747
|
+
}
|
|
12748
|
+
return lineBreaks;
|
|
12749
|
+
}
|
|
12750
|
+
function testDocumentSeparator(state) {
|
|
12751
|
+
var _position = state.position, ch;
|
|
12752
|
+
ch = state.input.charCodeAt(_position);
|
|
12753
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
12754
|
+
_position += 3;
|
|
12755
|
+
ch = state.input.charCodeAt(_position);
|
|
12756
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
12757
|
+
return true;
|
|
12758
|
+
}
|
|
12759
|
+
}
|
|
12760
|
+
return false;
|
|
12761
|
+
}
|
|
12762
|
+
function writeFoldedLines(state, count) {
|
|
12763
|
+
if (count === 1) {
|
|
12764
|
+
state.result += " ";
|
|
12765
|
+
} else if (count > 1) {
|
|
12766
|
+
state.result += common.repeat("\n", count - 1);
|
|
12767
|
+
}
|
|
12768
|
+
}
|
|
12769
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
12770
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
12771
|
+
ch = state.input.charCodeAt(state.position);
|
|
12772
|
+
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
12773
|
+
return false;
|
|
12774
|
+
}
|
|
12775
|
+
if (ch === 63 || ch === 45) {
|
|
12776
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
12777
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
12778
|
+
return false;
|
|
12779
|
+
}
|
|
12780
|
+
}
|
|
12781
|
+
state.kind = "scalar";
|
|
12782
|
+
state.result = "";
|
|
12783
|
+
captureStart = captureEnd = state.position;
|
|
12784
|
+
hasPendingContent = false;
|
|
12785
|
+
while (ch !== 0) {
|
|
12786
|
+
if (ch === 58) {
|
|
12787
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
12788
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
12789
|
+
break;
|
|
12790
|
+
}
|
|
12791
|
+
} else if (ch === 35) {
|
|
12792
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
12793
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
12794
|
+
break;
|
|
12795
|
+
}
|
|
12796
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
12797
|
+
break;
|
|
12798
|
+
} else if (is_EOL(ch)) {
|
|
12799
|
+
_line = state.line;
|
|
12800
|
+
_lineStart = state.lineStart;
|
|
12801
|
+
_lineIndent = state.lineIndent;
|
|
12802
|
+
skipSeparationSpace(state, false, -1);
|
|
12803
|
+
if (state.lineIndent >= nodeIndent) {
|
|
12804
|
+
hasPendingContent = true;
|
|
12805
|
+
ch = state.input.charCodeAt(state.position);
|
|
12806
|
+
continue;
|
|
12807
|
+
} else {
|
|
12808
|
+
state.position = captureEnd;
|
|
12809
|
+
state.line = _line;
|
|
12810
|
+
state.lineStart = _lineStart;
|
|
12811
|
+
state.lineIndent = _lineIndent;
|
|
12812
|
+
break;
|
|
12813
|
+
}
|
|
12814
|
+
}
|
|
12815
|
+
if (hasPendingContent) {
|
|
12816
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
12817
|
+
writeFoldedLines(state, state.line - _line);
|
|
12818
|
+
captureStart = captureEnd = state.position;
|
|
12819
|
+
hasPendingContent = false;
|
|
12820
|
+
}
|
|
12821
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
12822
|
+
captureEnd = state.position + 1;
|
|
12823
|
+
}
|
|
12824
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12825
|
+
}
|
|
12826
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
12827
|
+
if (state.result) {
|
|
12828
|
+
return true;
|
|
12829
|
+
}
|
|
12830
|
+
state.kind = _kind;
|
|
12831
|
+
state.result = _result;
|
|
12832
|
+
return false;
|
|
12833
|
+
}
|
|
12834
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
12835
|
+
var ch, captureStart, captureEnd;
|
|
12836
|
+
ch = state.input.charCodeAt(state.position);
|
|
12837
|
+
if (ch !== 39) {
|
|
12838
|
+
return false;
|
|
12839
|
+
}
|
|
12840
|
+
state.kind = "scalar";
|
|
12841
|
+
state.result = "";
|
|
12842
|
+
state.position++;
|
|
12843
|
+
captureStart = captureEnd = state.position;
|
|
12844
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
12845
|
+
if (ch === 39) {
|
|
12846
|
+
captureSegment(state, captureStart, state.position, true);
|
|
12847
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12848
|
+
if (ch === 39) {
|
|
12849
|
+
captureStart = state.position;
|
|
12850
|
+
state.position++;
|
|
12851
|
+
captureEnd = state.position;
|
|
12852
|
+
} else {
|
|
12853
|
+
return true;
|
|
12854
|
+
}
|
|
12855
|
+
} else if (is_EOL(ch)) {
|
|
12856
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
12857
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
12858
|
+
captureStart = captureEnd = state.position;
|
|
12859
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
12860
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
12861
|
+
} else {
|
|
12862
|
+
state.position++;
|
|
12863
|
+
captureEnd = state.position;
|
|
12864
|
+
}
|
|
12865
|
+
}
|
|
12866
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
12867
|
+
}
|
|
12868
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
12869
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
12870
|
+
ch = state.input.charCodeAt(state.position);
|
|
12871
|
+
if (ch !== 34) {
|
|
12872
|
+
return false;
|
|
12873
|
+
}
|
|
12874
|
+
state.kind = "scalar";
|
|
12875
|
+
state.result = "";
|
|
12876
|
+
state.position++;
|
|
12877
|
+
captureStart = captureEnd = state.position;
|
|
12878
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
12879
|
+
if (ch === 34) {
|
|
12880
|
+
captureSegment(state, captureStart, state.position, true);
|
|
12881
|
+
state.position++;
|
|
12882
|
+
return true;
|
|
12883
|
+
} else if (ch === 92) {
|
|
12884
|
+
captureSegment(state, captureStart, state.position, true);
|
|
12885
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12886
|
+
if (is_EOL(ch)) {
|
|
12887
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
12888
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
12889
|
+
state.result += simpleEscapeMap[ch];
|
|
12890
|
+
state.position++;
|
|
12891
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
12892
|
+
hexLength = tmp;
|
|
12893
|
+
hexResult = 0;
|
|
12894
|
+
for (; hexLength > 0; hexLength--) {
|
|
12895
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12896
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
12897
|
+
hexResult = (hexResult << 4) + tmp;
|
|
12898
|
+
} else {
|
|
12899
|
+
throwError(state, "expected hexadecimal character");
|
|
12900
|
+
}
|
|
12901
|
+
}
|
|
12902
|
+
state.result += charFromCodepoint(hexResult);
|
|
12903
|
+
state.position++;
|
|
12904
|
+
} else {
|
|
12905
|
+
throwError(state, "unknown escape sequence");
|
|
12906
|
+
}
|
|
12907
|
+
captureStart = captureEnd = state.position;
|
|
12908
|
+
} else if (is_EOL(ch)) {
|
|
12909
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
12910
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
12911
|
+
captureStart = captureEnd = state.position;
|
|
12912
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
12913
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
12914
|
+
} else {
|
|
12915
|
+
state.position++;
|
|
12916
|
+
captureEnd = state.position;
|
|
12917
|
+
}
|
|
12918
|
+
}
|
|
12919
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
12920
|
+
}
|
|
12921
|
+
function readFlowCollection(state, nodeIndent) {
|
|
12922
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
12923
|
+
ch = state.input.charCodeAt(state.position);
|
|
12924
|
+
if (ch === 91) {
|
|
12925
|
+
terminator = 93;
|
|
12926
|
+
isMapping = false;
|
|
12927
|
+
_result = [];
|
|
12928
|
+
} else if (ch === 123) {
|
|
12929
|
+
terminator = 125;
|
|
12930
|
+
isMapping = true;
|
|
12931
|
+
_result = {};
|
|
12932
|
+
} else {
|
|
12933
|
+
return false;
|
|
12934
|
+
}
|
|
12935
|
+
if (state.anchor !== null) {
|
|
12936
|
+
state.anchorMap[state.anchor] = _result;
|
|
12937
|
+
}
|
|
12938
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12939
|
+
while (ch !== 0) {
|
|
12940
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
12941
|
+
ch = state.input.charCodeAt(state.position);
|
|
12942
|
+
if (ch === terminator) {
|
|
12943
|
+
state.position++;
|
|
12944
|
+
state.tag = _tag;
|
|
12945
|
+
state.anchor = _anchor;
|
|
12946
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
12947
|
+
state.result = _result;
|
|
12948
|
+
return true;
|
|
12949
|
+
} else if (!readNext) {
|
|
12950
|
+
throwError(state, "missed comma between flow collection entries");
|
|
12951
|
+
} else if (ch === 44) {
|
|
12952
|
+
throwError(state, "expected the node content, but found ','");
|
|
12953
|
+
}
|
|
12954
|
+
keyTag = keyNode = valueNode = null;
|
|
12955
|
+
isPair = isExplicitPair = false;
|
|
12956
|
+
if (ch === 63) {
|
|
12957
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
12958
|
+
if (is_WS_OR_EOL(following)) {
|
|
12959
|
+
isPair = isExplicitPair = true;
|
|
12960
|
+
state.position++;
|
|
12961
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
12962
|
+
}
|
|
12963
|
+
}
|
|
12964
|
+
_line = state.line;
|
|
12965
|
+
_lineStart = state.lineStart;
|
|
12966
|
+
_pos = state.position;
|
|
12967
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
12968
|
+
keyTag = state.tag;
|
|
12969
|
+
keyNode = state.result;
|
|
12970
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
12971
|
+
ch = state.input.charCodeAt(state.position);
|
|
12972
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
12973
|
+
isPair = true;
|
|
12974
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12975
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
12976
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
12977
|
+
valueNode = state.result;
|
|
12978
|
+
}
|
|
12979
|
+
if (isMapping) {
|
|
12980
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
12981
|
+
} else if (isPair) {
|
|
12982
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
12983
|
+
} else {
|
|
12984
|
+
_result.push(keyNode);
|
|
12985
|
+
}
|
|
12986
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
12987
|
+
ch = state.input.charCodeAt(state.position);
|
|
12988
|
+
if (ch === 44) {
|
|
12989
|
+
readNext = true;
|
|
12990
|
+
ch = state.input.charCodeAt(++state.position);
|
|
12991
|
+
} else {
|
|
12992
|
+
readNext = false;
|
|
12993
|
+
}
|
|
12994
|
+
}
|
|
12995
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
12996
|
+
}
|
|
12997
|
+
function readBlockScalar(state, nodeIndent) {
|
|
12998
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
12999
|
+
ch = state.input.charCodeAt(state.position);
|
|
13000
|
+
if (ch === 124) {
|
|
13001
|
+
folding = false;
|
|
13002
|
+
} else if (ch === 62) {
|
|
13003
|
+
folding = true;
|
|
13004
|
+
} else {
|
|
13005
|
+
return false;
|
|
13006
|
+
}
|
|
13007
|
+
state.kind = "scalar";
|
|
13008
|
+
state.result = "";
|
|
13009
|
+
while (ch !== 0) {
|
|
13010
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13011
|
+
if (ch === 43 || ch === 45) {
|
|
13012
|
+
if (CHOMPING_CLIP === chomping) {
|
|
13013
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
13014
|
+
} else {
|
|
13015
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
13016
|
+
}
|
|
13017
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
13018
|
+
if (tmp === 0) {
|
|
13019
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
13020
|
+
} else if (!detectedIndent) {
|
|
13021
|
+
textIndent = nodeIndent + tmp - 1;
|
|
13022
|
+
detectedIndent = true;
|
|
13023
|
+
} else {
|
|
13024
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
13025
|
+
}
|
|
13026
|
+
} else {
|
|
13027
|
+
break;
|
|
13028
|
+
}
|
|
13029
|
+
}
|
|
13030
|
+
if (is_WHITE_SPACE(ch)) {
|
|
13031
|
+
do {
|
|
13032
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13033
|
+
} while (is_WHITE_SPACE(ch));
|
|
13034
|
+
if (ch === 35) {
|
|
13035
|
+
do {
|
|
13036
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13037
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
13038
|
+
}
|
|
13039
|
+
}
|
|
13040
|
+
while (ch !== 0) {
|
|
13041
|
+
readLineBreak(state);
|
|
13042
|
+
state.lineIndent = 0;
|
|
13043
|
+
ch = state.input.charCodeAt(state.position);
|
|
13044
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
13045
|
+
state.lineIndent++;
|
|
13046
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13047
|
+
}
|
|
13048
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
13049
|
+
textIndent = state.lineIndent;
|
|
13050
|
+
}
|
|
13051
|
+
if (is_EOL(ch)) {
|
|
13052
|
+
emptyLines++;
|
|
13053
|
+
continue;
|
|
13054
|
+
}
|
|
13055
|
+
if (state.lineIndent < textIndent) {
|
|
13056
|
+
if (chomping === CHOMPING_KEEP) {
|
|
13057
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
13058
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
13059
|
+
if (didReadContent) {
|
|
13060
|
+
state.result += "\n";
|
|
13061
|
+
}
|
|
13062
|
+
}
|
|
13063
|
+
break;
|
|
13064
|
+
}
|
|
13065
|
+
if (folding) {
|
|
13066
|
+
if (is_WHITE_SPACE(ch)) {
|
|
13067
|
+
atMoreIndented = true;
|
|
13068
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
13069
|
+
} else if (atMoreIndented) {
|
|
13070
|
+
atMoreIndented = false;
|
|
13071
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
13072
|
+
} else if (emptyLines === 0) {
|
|
13073
|
+
if (didReadContent) {
|
|
13074
|
+
state.result += " ";
|
|
13075
|
+
}
|
|
13076
|
+
} else {
|
|
13077
|
+
state.result += common.repeat("\n", emptyLines);
|
|
13078
|
+
}
|
|
13079
|
+
} else {
|
|
13080
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
13081
|
+
}
|
|
13082
|
+
didReadContent = true;
|
|
13083
|
+
detectedIndent = true;
|
|
13084
|
+
emptyLines = 0;
|
|
13085
|
+
captureStart = state.position;
|
|
13086
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
13087
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13088
|
+
}
|
|
13089
|
+
captureSegment(state, captureStart, state.position, false);
|
|
13090
|
+
}
|
|
13091
|
+
return true;
|
|
13092
|
+
}
|
|
13093
|
+
function readBlockSequence(state, nodeIndent) {
|
|
13094
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
13095
|
+
if (state.firstTabInLine !== -1) return false;
|
|
13096
|
+
if (state.anchor !== null) {
|
|
13097
|
+
state.anchorMap[state.anchor] = _result;
|
|
13098
|
+
}
|
|
13099
|
+
ch = state.input.charCodeAt(state.position);
|
|
13100
|
+
while (ch !== 0) {
|
|
13101
|
+
if (state.firstTabInLine !== -1) {
|
|
13102
|
+
state.position = state.firstTabInLine;
|
|
13103
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
13104
|
+
}
|
|
13105
|
+
if (ch !== 45) {
|
|
13106
|
+
break;
|
|
13107
|
+
}
|
|
13108
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13109
|
+
if (!is_WS_OR_EOL(following)) {
|
|
13110
|
+
break;
|
|
13111
|
+
}
|
|
13112
|
+
detected = true;
|
|
13113
|
+
state.position++;
|
|
13114
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
13115
|
+
if (state.lineIndent <= nodeIndent) {
|
|
13116
|
+
_result.push(null);
|
|
13117
|
+
ch = state.input.charCodeAt(state.position);
|
|
13118
|
+
continue;
|
|
13119
|
+
}
|
|
13120
|
+
}
|
|
13121
|
+
_line = state.line;
|
|
13122
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
13123
|
+
_result.push(state.result);
|
|
13124
|
+
skipSeparationSpace(state, true, -1);
|
|
13125
|
+
ch = state.input.charCodeAt(state.position);
|
|
13126
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
13127
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
13128
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
13129
|
+
break;
|
|
13130
|
+
}
|
|
13131
|
+
}
|
|
13132
|
+
if (detected) {
|
|
13133
|
+
state.tag = _tag;
|
|
13134
|
+
state.anchor = _anchor;
|
|
13135
|
+
state.kind = "sequence";
|
|
13136
|
+
state.result = _result;
|
|
13137
|
+
return true;
|
|
13138
|
+
}
|
|
13139
|
+
return false;
|
|
13140
|
+
}
|
|
13141
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
13142
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
13143
|
+
if (state.firstTabInLine !== -1) return false;
|
|
13144
|
+
if (state.anchor !== null) {
|
|
13145
|
+
state.anchorMap[state.anchor] = _result;
|
|
13146
|
+
}
|
|
13147
|
+
ch = state.input.charCodeAt(state.position);
|
|
13148
|
+
while (ch !== 0) {
|
|
13149
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
13150
|
+
state.position = state.firstTabInLine;
|
|
13151
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
13152
|
+
}
|
|
13153
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
13154
|
+
_line = state.line;
|
|
13155
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
13156
|
+
if (ch === 63) {
|
|
13157
|
+
if (atExplicitKey) {
|
|
13158
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
13159
|
+
keyTag = keyNode = valueNode = null;
|
|
13160
|
+
}
|
|
13161
|
+
detected = true;
|
|
13162
|
+
atExplicitKey = true;
|
|
13163
|
+
allowCompact = true;
|
|
13164
|
+
} else if (atExplicitKey) {
|
|
13165
|
+
atExplicitKey = false;
|
|
13166
|
+
allowCompact = true;
|
|
13167
|
+
} else {
|
|
13168
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
13169
|
+
}
|
|
13170
|
+
state.position += 1;
|
|
13171
|
+
ch = following;
|
|
13172
|
+
} else {
|
|
13173
|
+
_keyLine = state.line;
|
|
13174
|
+
_keyLineStart = state.lineStart;
|
|
13175
|
+
_keyPos = state.position;
|
|
13176
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
13177
|
+
break;
|
|
13178
|
+
}
|
|
13179
|
+
if (state.line === _line) {
|
|
13180
|
+
ch = state.input.charCodeAt(state.position);
|
|
13181
|
+
while (is_WHITE_SPACE(ch)) {
|
|
13182
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13183
|
+
}
|
|
13184
|
+
if (ch === 58) {
|
|
13185
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13186
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
13187
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
13188
|
+
}
|
|
13189
|
+
if (atExplicitKey) {
|
|
13190
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
13191
|
+
keyTag = keyNode = valueNode = null;
|
|
13192
|
+
}
|
|
13193
|
+
detected = true;
|
|
13194
|
+
atExplicitKey = false;
|
|
13195
|
+
allowCompact = false;
|
|
13196
|
+
keyTag = state.tag;
|
|
13197
|
+
keyNode = state.result;
|
|
13198
|
+
} else if (detected) {
|
|
13199
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
13200
|
+
} else {
|
|
13201
|
+
state.tag = _tag;
|
|
13202
|
+
state.anchor = _anchor;
|
|
13203
|
+
return true;
|
|
13204
|
+
}
|
|
13205
|
+
} else if (detected) {
|
|
13206
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
13207
|
+
} else {
|
|
13208
|
+
state.tag = _tag;
|
|
13209
|
+
state.anchor = _anchor;
|
|
13210
|
+
return true;
|
|
13211
|
+
}
|
|
13212
|
+
}
|
|
13213
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
13214
|
+
if (atExplicitKey) {
|
|
13215
|
+
_keyLine = state.line;
|
|
13216
|
+
_keyLineStart = state.lineStart;
|
|
13217
|
+
_keyPos = state.position;
|
|
13218
|
+
}
|
|
13219
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
13220
|
+
if (atExplicitKey) {
|
|
13221
|
+
keyNode = state.result;
|
|
13222
|
+
} else {
|
|
13223
|
+
valueNode = state.result;
|
|
13224
|
+
}
|
|
13225
|
+
}
|
|
13226
|
+
if (!atExplicitKey) {
|
|
13227
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
13228
|
+
keyTag = keyNode = valueNode = null;
|
|
13229
|
+
}
|
|
13230
|
+
skipSeparationSpace(state, true, -1);
|
|
13231
|
+
ch = state.input.charCodeAt(state.position);
|
|
13232
|
+
}
|
|
13233
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
13234
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
13235
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
13236
|
+
break;
|
|
13237
|
+
}
|
|
13238
|
+
}
|
|
13239
|
+
if (atExplicitKey) {
|
|
13240
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
13241
|
+
}
|
|
13242
|
+
if (detected) {
|
|
13243
|
+
state.tag = _tag;
|
|
13244
|
+
state.anchor = _anchor;
|
|
13245
|
+
state.kind = "mapping";
|
|
13246
|
+
state.result = _result;
|
|
13247
|
+
}
|
|
13248
|
+
return detected;
|
|
13249
|
+
}
|
|
13250
|
+
function readTagProperty(state) {
|
|
13251
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
13252
|
+
ch = state.input.charCodeAt(state.position);
|
|
13253
|
+
if (ch !== 33) return false;
|
|
13254
|
+
if (state.tag !== null) {
|
|
13255
|
+
throwError(state, "duplication of a tag property");
|
|
13256
|
+
}
|
|
13257
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13258
|
+
if (ch === 60) {
|
|
13259
|
+
isVerbatim = true;
|
|
13260
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13261
|
+
} else if (ch === 33) {
|
|
13262
|
+
isNamed = true;
|
|
13263
|
+
tagHandle = "!!";
|
|
13264
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13265
|
+
} else {
|
|
13266
|
+
tagHandle = "!";
|
|
13267
|
+
}
|
|
13268
|
+
_position = state.position;
|
|
13269
|
+
if (isVerbatim) {
|
|
13270
|
+
do {
|
|
13271
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13272
|
+
} while (ch !== 0 && ch !== 62);
|
|
13273
|
+
if (state.position < state.length) {
|
|
13274
|
+
tagName = state.input.slice(_position, state.position);
|
|
13275
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13276
|
+
} else {
|
|
13277
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
13278
|
+
}
|
|
13279
|
+
} else {
|
|
13280
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
13281
|
+
if (ch === 33) {
|
|
13282
|
+
if (!isNamed) {
|
|
13283
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
13284
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
13285
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
13286
|
+
}
|
|
13287
|
+
isNamed = true;
|
|
13288
|
+
_position = state.position + 1;
|
|
13289
|
+
} else {
|
|
13290
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
13291
|
+
}
|
|
13292
|
+
}
|
|
13293
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13294
|
+
}
|
|
13295
|
+
tagName = state.input.slice(_position, state.position);
|
|
13296
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
13297
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
13298
|
+
}
|
|
13299
|
+
}
|
|
13300
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
13301
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
13302
|
+
}
|
|
13303
|
+
try {
|
|
13304
|
+
tagName = decodeURIComponent(tagName);
|
|
13305
|
+
} catch (err) {
|
|
13306
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
13307
|
+
}
|
|
13308
|
+
if (isVerbatim) {
|
|
13309
|
+
state.tag = tagName;
|
|
13310
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
13311
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
13312
|
+
} else if (tagHandle === "!") {
|
|
13313
|
+
state.tag = "!" + tagName;
|
|
13314
|
+
} else if (tagHandle === "!!") {
|
|
13315
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
13316
|
+
} else {
|
|
13317
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
13318
|
+
}
|
|
13319
|
+
return true;
|
|
13320
|
+
}
|
|
13321
|
+
function readAnchorProperty(state) {
|
|
13322
|
+
var _position, ch;
|
|
13323
|
+
ch = state.input.charCodeAt(state.position);
|
|
13324
|
+
if (ch !== 38) return false;
|
|
13325
|
+
if (state.anchor !== null) {
|
|
13326
|
+
throwError(state, "duplication of an anchor property");
|
|
13327
|
+
}
|
|
13328
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13329
|
+
_position = state.position;
|
|
13330
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
13331
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13332
|
+
}
|
|
13333
|
+
if (state.position === _position) {
|
|
13334
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
13335
|
+
}
|
|
13336
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
13337
|
+
return true;
|
|
13338
|
+
}
|
|
13339
|
+
function readAlias(state) {
|
|
13340
|
+
var _position, alias, ch;
|
|
13341
|
+
ch = state.input.charCodeAt(state.position);
|
|
13342
|
+
if (ch !== 42) return false;
|
|
13343
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13344
|
+
_position = state.position;
|
|
13345
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
13346
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13347
|
+
}
|
|
13348
|
+
if (state.position === _position) {
|
|
13349
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
13350
|
+
}
|
|
13351
|
+
alias = state.input.slice(_position, state.position);
|
|
13352
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
13353
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
13354
|
+
}
|
|
13355
|
+
state.result = state.anchorMap[alias];
|
|
13356
|
+
skipSeparationSpace(state, true, -1);
|
|
13357
|
+
return true;
|
|
13358
|
+
}
|
|
13359
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
13360
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
13361
|
+
if (state.listener !== null) {
|
|
13362
|
+
state.listener("open", state);
|
|
13363
|
+
}
|
|
13364
|
+
state.tag = null;
|
|
13365
|
+
state.anchor = null;
|
|
13366
|
+
state.kind = null;
|
|
13367
|
+
state.result = null;
|
|
13368
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
13369
|
+
if (allowToSeek) {
|
|
13370
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
13371
|
+
atNewLine = true;
|
|
13372
|
+
if (state.lineIndent > parentIndent) {
|
|
13373
|
+
indentStatus = 1;
|
|
13374
|
+
} else if (state.lineIndent === parentIndent) {
|
|
13375
|
+
indentStatus = 0;
|
|
13376
|
+
} else if (state.lineIndent < parentIndent) {
|
|
13377
|
+
indentStatus = -1;
|
|
13378
|
+
}
|
|
13379
|
+
}
|
|
13380
|
+
}
|
|
13381
|
+
if (indentStatus === 1) {
|
|
13382
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
13383
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
13384
|
+
atNewLine = true;
|
|
13385
|
+
allowBlockCollections = allowBlockStyles;
|
|
13386
|
+
if (state.lineIndent > parentIndent) {
|
|
13387
|
+
indentStatus = 1;
|
|
13388
|
+
} else if (state.lineIndent === parentIndent) {
|
|
13389
|
+
indentStatus = 0;
|
|
13390
|
+
} else if (state.lineIndent < parentIndent) {
|
|
13391
|
+
indentStatus = -1;
|
|
13392
|
+
}
|
|
13393
|
+
} else {
|
|
13394
|
+
allowBlockCollections = false;
|
|
13395
|
+
}
|
|
13396
|
+
}
|
|
13397
|
+
}
|
|
13398
|
+
if (allowBlockCollections) {
|
|
13399
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
13400
|
+
}
|
|
13401
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
13402
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
13403
|
+
flowIndent = parentIndent;
|
|
13404
|
+
} else {
|
|
13405
|
+
flowIndent = parentIndent + 1;
|
|
13406
|
+
}
|
|
13407
|
+
blockIndent = state.position - state.lineStart;
|
|
13408
|
+
if (indentStatus === 1) {
|
|
13409
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
13410
|
+
hasContent = true;
|
|
13411
|
+
} else {
|
|
13412
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
13413
|
+
hasContent = true;
|
|
13414
|
+
} else if (readAlias(state)) {
|
|
13415
|
+
hasContent = true;
|
|
13416
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
13417
|
+
throwError(state, "alias node should not have any properties");
|
|
13418
|
+
}
|
|
13419
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
13420
|
+
hasContent = true;
|
|
13421
|
+
if (state.tag === null) {
|
|
13422
|
+
state.tag = "?";
|
|
13423
|
+
}
|
|
13424
|
+
}
|
|
13425
|
+
if (state.anchor !== null) {
|
|
13426
|
+
state.anchorMap[state.anchor] = state.result;
|
|
13427
|
+
}
|
|
13428
|
+
}
|
|
13429
|
+
} else if (indentStatus === 0) {
|
|
13430
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
13431
|
+
}
|
|
13432
|
+
}
|
|
13433
|
+
if (state.tag === null) {
|
|
13434
|
+
if (state.anchor !== null) {
|
|
13435
|
+
state.anchorMap[state.anchor] = state.result;
|
|
13436
|
+
}
|
|
13437
|
+
} else if (state.tag === "?") {
|
|
13438
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
13439
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
13440
|
+
}
|
|
13441
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
13442
|
+
type2 = state.implicitTypes[typeIndex];
|
|
13443
|
+
if (type2.resolve(state.result)) {
|
|
13444
|
+
state.result = type2.construct(state.result);
|
|
13445
|
+
state.tag = type2.tag;
|
|
13446
|
+
if (state.anchor !== null) {
|
|
13447
|
+
state.anchorMap[state.anchor] = state.result;
|
|
13448
|
+
}
|
|
13449
|
+
break;
|
|
13450
|
+
}
|
|
13451
|
+
}
|
|
13452
|
+
} else if (state.tag !== "!") {
|
|
13453
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
13454
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
13455
|
+
} else {
|
|
13456
|
+
type2 = null;
|
|
13457
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
13458
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
13459
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
13460
|
+
type2 = typeList[typeIndex];
|
|
13461
|
+
break;
|
|
13462
|
+
}
|
|
13463
|
+
}
|
|
13464
|
+
}
|
|
13465
|
+
if (!type2) {
|
|
13466
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
13467
|
+
}
|
|
13468
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
13469
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
13470
|
+
}
|
|
13471
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
13472
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
13473
|
+
} else {
|
|
13474
|
+
state.result = type2.construct(state.result, state.tag);
|
|
13475
|
+
if (state.anchor !== null) {
|
|
13476
|
+
state.anchorMap[state.anchor] = state.result;
|
|
13477
|
+
}
|
|
13478
|
+
}
|
|
13479
|
+
}
|
|
13480
|
+
if (state.listener !== null) {
|
|
13481
|
+
state.listener("close", state);
|
|
13482
|
+
}
|
|
13483
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
13484
|
+
}
|
|
13485
|
+
function readDocument(state) {
|
|
13486
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
13487
|
+
state.version = null;
|
|
13488
|
+
state.checkLineBreaks = state.legacy;
|
|
13489
|
+
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
13490
|
+
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
13491
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
13492
|
+
skipSeparationSpace(state, true, -1);
|
|
13493
|
+
ch = state.input.charCodeAt(state.position);
|
|
13494
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
13495
|
+
break;
|
|
13496
|
+
}
|
|
13497
|
+
hasDirectives = true;
|
|
13498
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13499
|
+
_position = state.position;
|
|
13500
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
13501
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13502
|
+
}
|
|
13503
|
+
directiveName = state.input.slice(_position, state.position);
|
|
13504
|
+
directiveArgs = [];
|
|
13505
|
+
if (directiveName.length < 1) {
|
|
13506
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
13507
|
+
}
|
|
13508
|
+
while (ch !== 0) {
|
|
13509
|
+
while (is_WHITE_SPACE(ch)) {
|
|
13510
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13511
|
+
}
|
|
13512
|
+
if (ch === 35) {
|
|
13513
|
+
do {
|
|
13514
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13515
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
13516
|
+
break;
|
|
13517
|
+
}
|
|
13518
|
+
if (is_EOL(ch)) break;
|
|
13519
|
+
_position = state.position;
|
|
13520
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
13521
|
+
ch = state.input.charCodeAt(++state.position);
|
|
13522
|
+
}
|
|
13523
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
13524
|
+
}
|
|
13525
|
+
if (ch !== 0) readLineBreak(state);
|
|
13526
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
13527
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
13528
|
+
} else {
|
|
13529
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
13530
|
+
}
|
|
13531
|
+
}
|
|
13532
|
+
skipSeparationSpace(state, true, -1);
|
|
13533
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
13534
|
+
state.position += 3;
|
|
13535
|
+
skipSeparationSpace(state, true, -1);
|
|
13536
|
+
} else if (hasDirectives) {
|
|
13537
|
+
throwError(state, "directives end mark is expected");
|
|
13538
|
+
}
|
|
13539
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
13540
|
+
skipSeparationSpace(state, true, -1);
|
|
13541
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
13542
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
13543
|
+
}
|
|
13544
|
+
state.documents.push(state.result);
|
|
13545
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
13546
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
13547
|
+
state.position += 3;
|
|
13548
|
+
skipSeparationSpace(state, true, -1);
|
|
13549
|
+
}
|
|
13550
|
+
return;
|
|
13551
|
+
}
|
|
13552
|
+
if (state.position < state.length - 1) {
|
|
13553
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
13554
|
+
} else {
|
|
13555
|
+
return;
|
|
13556
|
+
}
|
|
13557
|
+
}
|
|
13558
|
+
function loadDocuments(input, options) {
|
|
13559
|
+
input = String(input);
|
|
13560
|
+
options = options || {};
|
|
13561
|
+
if (input.length !== 0) {
|
|
13562
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
13563
|
+
input += "\n";
|
|
13564
|
+
}
|
|
13565
|
+
if (input.charCodeAt(0) === 65279) {
|
|
13566
|
+
input = input.slice(1);
|
|
13567
|
+
}
|
|
13568
|
+
}
|
|
13569
|
+
var state = new State$1(input, options);
|
|
13570
|
+
var nullpos = input.indexOf("\0");
|
|
13571
|
+
if (nullpos !== -1) {
|
|
13572
|
+
state.position = nullpos;
|
|
13573
|
+
throwError(state, "null byte is not allowed in input");
|
|
13574
|
+
}
|
|
13575
|
+
state.input += "\0";
|
|
13576
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
13577
|
+
state.lineIndent += 1;
|
|
13578
|
+
state.position += 1;
|
|
13579
|
+
}
|
|
13580
|
+
while (state.position < state.length - 1) {
|
|
13581
|
+
readDocument(state);
|
|
13582
|
+
}
|
|
13583
|
+
return state.documents;
|
|
13584
|
+
}
|
|
13585
|
+
function loadAll$1(input, iterator2, options) {
|
|
13586
|
+
if (iterator2 !== null && typeof iterator2 === "object" && typeof options === "undefined") {
|
|
13587
|
+
options = iterator2;
|
|
13588
|
+
iterator2 = null;
|
|
13589
|
+
}
|
|
13590
|
+
var documents = loadDocuments(input, options);
|
|
13591
|
+
if (typeof iterator2 !== "function") {
|
|
13592
|
+
return documents;
|
|
13593
|
+
}
|
|
13594
|
+
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
13595
|
+
iterator2(documents[index]);
|
|
13596
|
+
}
|
|
13597
|
+
}
|
|
13598
|
+
function load$1(input, options) {
|
|
13599
|
+
var documents = loadDocuments(input, options);
|
|
13600
|
+
if (documents.length === 0) {
|
|
13601
|
+
return void 0;
|
|
13602
|
+
} else if (documents.length === 1) {
|
|
13603
|
+
return documents[0];
|
|
13604
|
+
}
|
|
13605
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
13606
|
+
}
|
|
13607
|
+
var loadAll_1 = loadAll$1;
|
|
13608
|
+
var load_1 = load$1;
|
|
13609
|
+
var loader = {
|
|
13610
|
+
loadAll: loadAll_1,
|
|
13611
|
+
load: load_1
|
|
13612
|
+
};
|
|
13613
|
+
var _toString = Object.prototype.toString;
|
|
13614
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
13615
|
+
var CHAR_BOM = 65279;
|
|
13616
|
+
var CHAR_TAB = 9;
|
|
13617
|
+
var CHAR_LINE_FEED = 10;
|
|
13618
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
13619
|
+
var CHAR_SPACE = 32;
|
|
13620
|
+
var CHAR_EXCLAMATION = 33;
|
|
13621
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
13622
|
+
var CHAR_SHARP = 35;
|
|
13623
|
+
var CHAR_PERCENT = 37;
|
|
13624
|
+
var CHAR_AMPERSAND = 38;
|
|
13625
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
13626
|
+
var CHAR_ASTERISK = 42;
|
|
13627
|
+
var CHAR_COMMA = 44;
|
|
13628
|
+
var CHAR_MINUS = 45;
|
|
13629
|
+
var CHAR_COLON = 58;
|
|
13630
|
+
var CHAR_EQUALS = 61;
|
|
13631
|
+
var CHAR_GREATER_THAN = 62;
|
|
13632
|
+
var CHAR_QUESTION = 63;
|
|
13633
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
13634
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
13635
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
13636
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
13637
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
13638
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
13639
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
13640
|
+
var ESCAPE_SEQUENCES = {};
|
|
13641
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
13642
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
13643
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
13644
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
13645
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
13646
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
13647
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
13648
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
13649
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
13650
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
13651
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
13652
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
13653
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
13654
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
13655
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
13656
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
13657
|
+
"y",
|
|
13658
|
+
"Y",
|
|
13659
|
+
"yes",
|
|
13660
|
+
"Yes",
|
|
13661
|
+
"YES",
|
|
13662
|
+
"on",
|
|
13663
|
+
"On",
|
|
13664
|
+
"ON",
|
|
13665
|
+
"n",
|
|
13666
|
+
"N",
|
|
13667
|
+
"no",
|
|
13668
|
+
"No",
|
|
13669
|
+
"NO",
|
|
13670
|
+
"off",
|
|
13671
|
+
"Off",
|
|
13672
|
+
"OFF"
|
|
13673
|
+
];
|
|
13674
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
13675
|
+
function compileStyleMap(schema2, map2) {
|
|
13676
|
+
var result, keys, index, length, tag, style, type2;
|
|
13677
|
+
if (map2 === null) return {};
|
|
13678
|
+
result = {};
|
|
13679
|
+
keys = Object.keys(map2);
|
|
13680
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
13681
|
+
tag = keys[index];
|
|
13682
|
+
style = String(map2[tag]);
|
|
13683
|
+
if (tag.slice(0, 2) === "!!") {
|
|
13684
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
13685
|
+
}
|
|
13686
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
13687
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
13688
|
+
style = type2.styleAliases[style];
|
|
13689
|
+
}
|
|
13690
|
+
result[tag] = style;
|
|
13691
|
+
}
|
|
13692
|
+
return result;
|
|
13693
|
+
}
|
|
13694
|
+
function encodeHex(character) {
|
|
13695
|
+
var string, handle, length;
|
|
13696
|
+
string = character.toString(16).toUpperCase();
|
|
13697
|
+
if (character <= 255) {
|
|
13698
|
+
handle = "x";
|
|
13699
|
+
length = 2;
|
|
13700
|
+
} else if (character <= 65535) {
|
|
13701
|
+
handle = "u";
|
|
13702
|
+
length = 4;
|
|
13703
|
+
} else if (character <= 4294967295) {
|
|
13704
|
+
handle = "U";
|
|
13705
|
+
length = 8;
|
|
13706
|
+
} else {
|
|
13707
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
13708
|
+
}
|
|
13709
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
13710
|
+
}
|
|
13711
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
13712
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
13713
|
+
function State(options) {
|
|
13714
|
+
this.schema = options["schema"] || _default;
|
|
13715
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
13716
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
13717
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
13718
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
13719
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
13720
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
13721
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
13722
|
+
this.noRefs = options["noRefs"] || false;
|
|
13723
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
13724
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
13725
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
13726
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
13727
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
13728
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
13729
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
13730
|
+
this.tag = null;
|
|
13731
|
+
this.result = "";
|
|
13732
|
+
this.duplicates = [];
|
|
13733
|
+
this.usedDuplicates = null;
|
|
13734
|
+
}
|
|
13735
|
+
function indentString(string, spaces) {
|
|
13736
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
13737
|
+
while (position < length) {
|
|
13738
|
+
next = string.indexOf("\n", position);
|
|
13739
|
+
if (next === -1) {
|
|
13740
|
+
line = string.slice(position);
|
|
13741
|
+
position = length;
|
|
13742
|
+
} else {
|
|
13743
|
+
line = string.slice(position, next + 1);
|
|
13744
|
+
position = next + 1;
|
|
13745
|
+
}
|
|
13746
|
+
if (line.length && line !== "\n") result += ind;
|
|
13747
|
+
result += line;
|
|
13748
|
+
}
|
|
13749
|
+
return result;
|
|
13750
|
+
}
|
|
13751
|
+
function generateNextLine(state, level) {
|
|
13752
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
13753
|
+
}
|
|
13754
|
+
function testImplicitResolving(state, str2) {
|
|
13755
|
+
var index, length, type2;
|
|
13756
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
13757
|
+
type2 = state.implicitTypes[index];
|
|
13758
|
+
if (type2.resolve(str2)) {
|
|
13759
|
+
return true;
|
|
13760
|
+
}
|
|
13761
|
+
}
|
|
13762
|
+
return false;
|
|
13763
|
+
}
|
|
13764
|
+
function isWhitespace(c) {
|
|
13765
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
13766
|
+
}
|
|
13767
|
+
function isPrintable(c) {
|
|
13768
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
13769
|
+
}
|
|
13770
|
+
function isNsCharOrWhitespace(c) {
|
|
13771
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
13772
|
+
}
|
|
13773
|
+
function isPlainSafe(c, prev, inblock) {
|
|
13774
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
13775
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
13776
|
+
return (
|
|
13777
|
+
// ns-plain-safe
|
|
13778
|
+
(inblock ? (
|
|
13779
|
+
// c = flow-in
|
|
13780
|
+
cIsNsCharOrWhitespace
|
|
13781
|
+
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
13782
|
+
);
|
|
13783
|
+
}
|
|
13784
|
+
function isPlainSafeFirst(c) {
|
|
13785
|
+
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
13786
|
+
}
|
|
13787
|
+
function isPlainSafeLast(c) {
|
|
13788
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
13789
|
+
}
|
|
13790
|
+
function codePointAt(string, pos) {
|
|
13791
|
+
var first = string.charCodeAt(pos), second;
|
|
13792
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
13793
|
+
second = string.charCodeAt(pos + 1);
|
|
13794
|
+
if (second >= 56320 && second <= 57343) {
|
|
13795
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
13796
|
+
}
|
|
13797
|
+
}
|
|
13798
|
+
return first;
|
|
13799
|
+
}
|
|
13800
|
+
function needIndentIndicator(string) {
|
|
13801
|
+
var leadingSpaceRe = /^\n* /;
|
|
13802
|
+
return leadingSpaceRe.test(string);
|
|
13803
|
+
}
|
|
13804
|
+
var STYLE_PLAIN = 1;
|
|
13805
|
+
var STYLE_SINGLE = 2;
|
|
13806
|
+
var STYLE_LITERAL = 3;
|
|
13807
|
+
var STYLE_FOLDED = 4;
|
|
13808
|
+
var STYLE_DOUBLE = 5;
|
|
13809
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
13810
|
+
var i;
|
|
13811
|
+
var char = 0;
|
|
13812
|
+
var prevChar = null;
|
|
13813
|
+
var hasLineBreak = false;
|
|
13814
|
+
var hasFoldableLine = false;
|
|
13815
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
13816
|
+
var previousLineBreak = -1;
|
|
13817
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
13818
|
+
if (singleLineOnly || forceQuotes) {
|
|
13819
|
+
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
13820
|
+
char = codePointAt(string, i);
|
|
13821
|
+
if (!isPrintable(char)) {
|
|
13822
|
+
return STYLE_DOUBLE;
|
|
13823
|
+
}
|
|
13824
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
13825
|
+
prevChar = char;
|
|
13826
|
+
}
|
|
13827
|
+
} else {
|
|
13828
|
+
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
13829
|
+
char = codePointAt(string, i);
|
|
13830
|
+
if (char === CHAR_LINE_FEED) {
|
|
13831
|
+
hasLineBreak = true;
|
|
13832
|
+
if (shouldTrackWidth) {
|
|
13833
|
+
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
13834
|
+
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
13835
|
+
previousLineBreak = i;
|
|
13836
|
+
}
|
|
13837
|
+
} else if (!isPrintable(char)) {
|
|
13838
|
+
return STYLE_DOUBLE;
|
|
13839
|
+
}
|
|
13840
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
13841
|
+
prevChar = char;
|
|
13842
|
+
}
|
|
13843
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
13844
|
+
}
|
|
13845
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
13846
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
13847
|
+
return STYLE_PLAIN;
|
|
13848
|
+
}
|
|
13849
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
13850
|
+
}
|
|
13851
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
13852
|
+
return STYLE_DOUBLE;
|
|
13853
|
+
}
|
|
13854
|
+
if (!forceQuotes) {
|
|
13855
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
13856
|
+
}
|
|
13857
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
13858
|
+
}
|
|
13859
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
13860
|
+
state.dump = function() {
|
|
13861
|
+
if (string.length === 0) {
|
|
13862
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
13863
|
+
}
|
|
13864
|
+
if (!state.noCompatMode) {
|
|
13865
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
13866
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
13867
|
+
}
|
|
13868
|
+
}
|
|
13869
|
+
var indent = state.indent * Math.max(1, level);
|
|
13870
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
13871
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
13872
|
+
function testAmbiguity(string2) {
|
|
13873
|
+
return testImplicitResolving(state, string2);
|
|
13874
|
+
}
|
|
13875
|
+
switch (chooseScalarStyle(
|
|
13876
|
+
string,
|
|
13877
|
+
singleLineOnly,
|
|
13878
|
+
state.indent,
|
|
13879
|
+
lineWidth,
|
|
13880
|
+
testAmbiguity,
|
|
13881
|
+
state.quotingType,
|
|
13882
|
+
state.forceQuotes && !iskey,
|
|
13883
|
+
inblock
|
|
13884
|
+
)) {
|
|
13885
|
+
case STYLE_PLAIN:
|
|
13886
|
+
return string;
|
|
13887
|
+
case STYLE_SINGLE:
|
|
13888
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
13889
|
+
case STYLE_LITERAL:
|
|
13890
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
13891
|
+
case STYLE_FOLDED:
|
|
13892
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
13893
|
+
case STYLE_DOUBLE:
|
|
13894
|
+
return '"' + escapeString(string) + '"';
|
|
13895
|
+
default:
|
|
13896
|
+
throw new exception("impossible error: invalid scalar style");
|
|
13897
|
+
}
|
|
13898
|
+
}();
|
|
13899
|
+
}
|
|
13900
|
+
function blockHeader(string, indentPerLevel) {
|
|
13901
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
13902
|
+
var clip = string[string.length - 1] === "\n";
|
|
13903
|
+
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
13904
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
13905
|
+
return indentIndicator + chomp + "\n";
|
|
13906
|
+
}
|
|
13907
|
+
function dropEndingNewline(string) {
|
|
13908
|
+
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
13909
|
+
}
|
|
13910
|
+
function foldString(string, width) {
|
|
13911
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
13912
|
+
var result = function() {
|
|
13913
|
+
var nextLF = string.indexOf("\n");
|
|
13914
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
13915
|
+
lineRe.lastIndex = nextLF;
|
|
13916
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
13917
|
+
}();
|
|
13918
|
+
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
13919
|
+
var moreIndented;
|
|
13920
|
+
var match;
|
|
13921
|
+
while (match = lineRe.exec(string)) {
|
|
13922
|
+
var prefix = match[1], line = match[2];
|
|
13923
|
+
moreIndented = line[0] === " ";
|
|
13924
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
13925
|
+
prevMoreIndented = moreIndented;
|
|
13926
|
+
}
|
|
13927
|
+
return result;
|
|
13928
|
+
}
|
|
13929
|
+
function foldLine(line, width) {
|
|
13930
|
+
if (line === "" || line[0] === " ") return line;
|
|
13931
|
+
var breakRe = / [^ ]/g;
|
|
13932
|
+
var match;
|
|
13933
|
+
var start = 0, end, curr = 0, next = 0;
|
|
13934
|
+
var result = "";
|
|
13935
|
+
while (match = breakRe.exec(line)) {
|
|
13936
|
+
next = match.index;
|
|
13937
|
+
if (next - start > width) {
|
|
13938
|
+
end = curr > start ? curr : next;
|
|
13939
|
+
result += "\n" + line.slice(start, end);
|
|
13940
|
+
start = end + 1;
|
|
13941
|
+
}
|
|
13942
|
+
curr = next;
|
|
13943
|
+
}
|
|
13944
|
+
result += "\n";
|
|
13945
|
+
if (line.length - start > width && curr > start) {
|
|
13946
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
13947
|
+
} else {
|
|
13948
|
+
result += line.slice(start);
|
|
13949
|
+
}
|
|
13950
|
+
return result.slice(1);
|
|
13951
|
+
}
|
|
13952
|
+
function escapeString(string) {
|
|
13953
|
+
var result = "";
|
|
13954
|
+
var char = 0;
|
|
13955
|
+
var escapeSeq;
|
|
13956
|
+
for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
13957
|
+
char = codePointAt(string, i);
|
|
13958
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
13959
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
13960
|
+
result += string[i];
|
|
13961
|
+
if (char >= 65536) result += string[i + 1];
|
|
13962
|
+
} else {
|
|
13963
|
+
result += escapeSeq || encodeHex(char);
|
|
13964
|
+
}
|
|
13965
|
+
}
|
|
13966
|
+
return result;
|
|
13967
|
+
}
|
|
13968
|
+
function writeFlowSequence(state, level, object) {
|
|
13969
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
13970
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
13971
|
+
value = object[index];
|
|
13972
|
+
if (state.replacer) {
|
|
13973
|
+
value = state.replacer.call(object, String(index), value);
|
|
13974
|
+
}
|
|
13975
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
13976
|
+
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
13977
|
+
_result += state.dump;
|
|
13978
|
+
}
|
|
13979
|
+
}
|
|
13980
|
+
state.tag = _tag;
|
|
13981
|
+
state.dump = "[" + _result + "]";
|
|
13982
|
+
}
|
|
13983
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
13984
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
13985
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
13986
|
+
value = object[index];
|
|
13987
|
+
if (state.replacer) {
|
|
13988
|
+
value = state.replacer.call(object, String(index), value);
|
|
13989
|
+
}
|
|
13990
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
13991
|
+
if (!compact || _result !== "") {
|
|
13992
|
+
_result += generateNextLine(state, level);
|
|
13993
|
+
}
|
|
13994
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
13995
|
+
_result += "-";
|
|
13996
|
+
} else {
|
|
13997
|
+
_result += "- ";
|
|
13998
|
+
}
|
|
13999
|
+
_result += state.dump;
|
|
14000
|
+
}
|
|
14001
|
+
}
|
|
14002
|
+
state.tag = _tag;
|
|
14003
|
+
state.dump = _result || "[]";
|
|
14004
|
+
}
|
|
14005
|
+
function writeFlowMapping(state, level, object) {
|
|
14006
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
14007
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
14008
|
+
pairBuffer = "";
|
|
14009
|
+
if (_result !== "") pairBuffer += ", ";
|
|
14010
|
+
if (state.condenseFlow) pairBuffer += '"';
|
|
14011
|
+
objectKey = objectKeyList[index];
|
|
14012
|
+
objectValue = object[objectKey];
|
|
14013
|
+
if (state.replacer) {
|
|
14014
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
14015
|
+
}
|
|
14016
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
14017
|
+
continue;
|
|
14018
|
+
}
|
|
14019
|
+
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
14020
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
14021
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
14022
|
+
continue;
|
|
14023
|
+
}
|
|
14024
|
+
pairBuffer += state.dump;
|
|
14025
|
+
_result += pairBuffer;
|
|
14026
|
+
}
|
|
14027
|
+
state.tag = _tag;
|
|
14028
|
+
state.dump = "{" + _result + "}";
|
|
14029
|
+
}
|
|
14030
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
14031
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
14032
|
+
if (state.sortKeys === true) {
|
|
14033
|
+
objectKeyList.sort();
|
|
14034
|
+
} else if (typeof state.sortKeys === "function") {
|
|
14035
|
+
objectKeyList.sort(state.sortKeys);
|
|
14036
|
+
} else if (state.sortKeys) {
|
|
14037
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
14038
|
+
}
|
|
14039
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
14040
|
+
pairBuffer = "";
|
|
14041
|
+
if (!compact || _result !== "") {
|
|
14042
|
+
pairBuffer += generateNextLine(state, level);
|
|
14043
|
+
}
|
|
14044
|
+
objectKey = objectKeyList[index];
|
|
14045
|
+
objectValue = object[objectKey];
|
|
14046
|
+
if (state.replacer) {
|
|
14047
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
14048
|
+
}
|
|
14049
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
14050
|
+
continue;
|
|
14051
|
+
}
|
|
14052
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
14053
|
+
if (explicitPair) {
|
|
14054
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
14055
|
+
pairBuffer += "?";
|
|
14056
|
+
} else {
|
|
14057
|
+
pairBuffer += "? ";
|
|
14058
|
+
}
|
|
14059
|
+
}
|
|
14060
|
+
pairBuffer += state.dump;
|
|
14061
|
+
if (explicitPair) {
|
|
14062
|
+
pairBuffer += generateNextLine(state, level);
|
|
14063
|
+
}
|
|
14064
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
14065
|
+
continue;
|
|
14066
|
+
}
|
|
14067
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
14068
|
+
pairBuffer += ":";
|
|
14069
|
+
} else {
|
|
14070
|
+
pairBuffer += ": ";
|
|
14071
|
+
}
|
|
14072
|
+
pairBuffer += state.dump;
|
|
14073
|
+
_result += pairBuffer;
|
|
14074
|
+
}
|
|
14075
|
+
state.tag = _tag;
|
|
14076
|
+
state.dump = _result || "{}";
|
|
14077
|
+
}
|
|
14078
|
+
function detectType(state, object, explicit) {
|
|
14079
|
+
var _result, typeList, index, length, type2, style;
|
|
14080
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
14081
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
14082
|
+
type2 = typeList[index];
|
|
14083
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
14084
|
+
if (explicit) {
|
|
14085
|
+
if (type2.multi && type2.representName) {
|
|
14086
|
+
state.tag = type2.representName(object);
|
|
14087
|
+
} else {
|
|
14088
|
+
state.tag = type2.tag;
|
|
14089
|
+
}
|
|
14090
|
+
} else {
|
|
14091
|
+
state.tag = "?";
|
|
14092
|
+
}
|
|
14093
|
+
if (type2.represent) {
|
|
14094
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
14095
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
14096
|
+
_result = type2.represent(object, style);
|
|
14097
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
14098
|
+
_result = type2.represent[style](object, style);
|
|
14099
|
+
} else {
|
|
14100
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
14101
|
+
}
|
|
14102
|
+
state.dump = _result;
|
|
14103
|
+
}
|
|
14104
|
+
return true;
|
|
14105
|
+
}
|
|
14106
|
+
}
|
|
14107
|
+
return false;
|
|
14108
|
+
}
|
|
14109
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
14110
|
+
state.tag = null;
|
|
14111
|
+
state.dump = object;
|
|
14112
|
+
if (!detectType(state, object, false)) {
|
|
14113
|
+
detectType(state, object, true);
|
|
14114
|
+
}
|
|
14115
|
+
var type2 = _toString.call(state.dump);
|
|
14116
|
+
var inblock = block;
|
|
14117
|
+
var tagStr;
|
|
14118
|
+
if (block) {
|
|
14119
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
14120
|
+
}
|
|
14121
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
14122
|
+
if (objectOrArray) {
|
|
14123
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
14124
|
+
duplicate = duplicateIndex !== -1;
|
|
14125
|
+
}
|
|
14126
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
14127
|
+
compact = false;
|
|
14128
|
+
}
|
|
14129
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
14130
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
14131
|
+
} else {
|
|
14132
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
14133
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
14134
|
+
}
|
|
14135
|
+
if (type2 === "[object Object]") {
|
|
14136
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
14137
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
14138
|
+
if (duplicate) {
|
|
14139
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
14140
|
+
}
|
|
14141
|
+
} else {
|
|
14142
|
+
writeFlowMapping(state, level, state.dump);
|
|
14143
|
+
if (duplicate) {
|
|
14144
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
14145
|
+
}
|
|
14146
|
+
}
|
|
14147
|
+
} else if (type2 === "[object Array]") {
|
|
14148
|
+
if (block && state.dump.length !== 0) {
|
|
14149
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
14150
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
14151
|
+
} else {
|
|
14152
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
14153
|
+
}
|
|
14154
|
+
if (duplicate) {
|
|
14155
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
14156
|
+
}
|
|
14157
|
+
} else {
|
|
14158
|
+
writeFlowSequence(state, level, state.dump);
|
|
14159
|
+
if (duplicate) {
|
|
14160
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
14161
|
+
}
|
|
14162
|
+
}
|
|
14163
|
+
} else if (type2 === "[object String]") {
|
|
14164
|
+
if (state.tag !== "?") {
|
|
14165
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
14166
|
+
}
|
|
14167
|
+
} else if (type2 === "[object Undefined]") {
|
|
14168
|
+
return false;
|
|
14169
|
+
} else {
|
|
14170
|
+
if (state.skipInvalid) return false;
|
|
14171
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
14172
|
+
}
|
|
14173
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
14174
|
+
tagStr = encodeURI(
|
|
14175
|
+
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
14176
|
+
).replace(/!/g, "%21");
|
|
14177
|
+
if (state.tag[0] === "!") {
|
|
14178
|
+
tagStr = "!" + tagStr;
|
|
14179
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
14180
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
14181
|
+
} else {
|
|
14182
|
+
tagStr = "!<" + tagStr + ">";
|
|
14183
|
+
}
|
|
14184
|
+
state.dump = tagStr + " " + state.dump;
|
|
14185
|
+
}
|
|
14186
|
+
}
|
|
14187
|
+
return true;
|
|
14188
|
+
}
|
|
14189
|
+
function getDuplicateReferences(object, state) {
|
|
14190
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
14191
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
14192
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
14193
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
14194
|
+
}
|
|
14195
|
+
state.usedDuplicates = new Array(length);
|
|
14196
|
+
}
|
|
14197
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
14198
|
+
var objectKeyList, index, length;
|
|
14199
|
+
if (object !== null && typeof object === "object") {
|
|
14200
|
+
index = objects.indexOf(object);
|
|
14201
|
+
if (index !== -1) {
|
|
14202
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
14203
|
+
duplicatesIndexes.push(index);
|
|
14204
|
+
}
|
|
14205
|
+
} else {
|
|
14206
|
+
objects.push(object);
|
|
14207
|
+
if (Array.isArray(object)) {
|
|
14208
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
14209
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
14210
|
+
}
|
|
14211
|
+
} else {
|
|
14212
|
+
objectKeyList = Object.keys(object);
|
|
14213
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
14214
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
14215
|
+
}
|
|
14216
|
+
}
|
|
14217
|
+
}
|
|
14218
|
+
}
|
|
14219
|
+
}
|
|
14220
|
+
function dump$1(input, options) {
|
|
14221
|
+
options = options || {};
|
|
14222
|
+
var state = new State(options);
|
|
14223
|
+
if (!state.noRefs) getDuplicateReferences(input, state);
|
|
14224
|
+
var value = input;
|
|
14225
|
+
if (state.replacer) {
|
|
14226
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
14227
|
+
}
|
|
14228
|
+
if (writeNode(state, 0, value, true, true)) return state.dump + "\n";
|
|
14229
|
+
return "";
|
|
14230
|
+
}
|
|
14231
|
+
var dump_1 = dump$1;
|
|
14232
|
+
var dumper = {
|
|
14233
|
+
dump: dump_1
|
|
14234
|
+
};
|
|
14235
|
+
function renamed(from, to) {
|
|
14236
|
+
return function() {
|
|
14237
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
14238
|
+
};
|
|
14239
|
+
}
|
|
14240
|
+
var Type = type;
|
|
14241
|
+
var Schema = schema;
|
|
14242
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
14243
|
+
var JSON_SCHEMA = json;
|
|
14244
|
+
var CORE_SCHEMA = core;
|
|
14245
|
+
var DEFAULT_SCHEMA = _default;
|
|
14246
|
+
var load = loader.load;
|
|
14247
|
+
var loadAll = loader.loadAll;
|
|
14248
|
+
var dump = dumper.dump;
|
|
14249
|
+
var YAMLException = exception;
|
|
14250
|
+
var types = {
|
|
14251
|
+
binary,
|
|
14252
|
+
float,
|
|
14253
|
+
map,
|
|
14254
|
+
null: _null,
|
|
14255
|
+
pairs,
|
|
14256
|
+
set,
|
|
14257
|
+
timestamp,
|
|
14258
|
+
bool,
|
|
14259
|
+
int,
|
|
14260
|
+
merge,
|
|
14261
|
+
omap,
|
|
14262
|
+
seq,
|
|
14263
|
+
str
|
|
14264
|
+
};
|
|
14265
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
14266
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
14267
|
+
var safeDump = renamed("safeDump", "dump");
|
|
14268
|
+
var jsYaml = {
|
|
14269
|
+
Type,
|
|
14270
|
+
Schema,
|
|
14271
|
+
FAILSAFE_SCHEMA,
|
|
14272
|
+
JSON_SCHEMA,
|
|
14273
|
+
CORE_SCHEMA,
|
|
14274
|
+
DEFAULT_SCHEMA,
|
|
14275
|
+
load,
|
|
14276
|
+
loadAll,
|
|
14277
|
+
dump,
|
|
14278
|
+
YAMLException,
|
|
14279
|
+
types,
|
|
14280
|
+
safeLoad,
|
|
14281
|
+
safeLoadAll,
|
|
14282
|
+
safeDump
|
|
14283
|
+
};
|
|
14284
|
+
var js_yaml_default = jsYaml;
|
|
14285
|
+
|
|
14286
|
+
// src/openapi-loader.ts
|
|
14287
|
+
import crypto from "crypto";
|
|
14288
|
+
|
|
14289
|
+
// src/abbreviations.ts
|
|
14290
|
+
var REVISED_COMMON_WORDS_TO_REMOVE = [
|
|
14291
|
+
"controller",
|
|
14292
|
+
"api",
|
|
14293
|
+
"operation",
|
|
14294
|
+
"handler",
|
|
14295
|
+
"endpoint",
|
|
14296
|
+
"action",
|
|
14297
|
+
"perform",
|
|
14298
|
+
"execute",
|
|
14299
|
+
"retrieve",
|
|
14300
|
+
"specify",
|
|
14301
|
+
// generic verbs
|
|
14302
|
+
"for",
|
|
14303
|
+
"and",
|
|
14304
|
+
"the",
|
|
14305
|
+
"with",
|
|
14306
|
+
"from",
|
|
14307
|
+
"into",
|
|
14308
|
+
"onto",
|
|
14309
|
+
"out"
|
|
14310
|
+
// prepositions/articles
|
|
14311
|
+
];
|
|
14312
|
+
var WORD_ABBREVIATIONS = {
|
|
14313
|
+
service: "Svc",
|
|
14314
|
+
services: "Svcs",
|
|
14315
|
+
user: "Usr",
|
|
14316
|
+
users: "Usrs",
|
|
14317
|
+
management: "Mgmt",
|
|
14318
|
+
manager: "Mgr",
|
|
14319
|
+
manage: "Mng",
|
|
14320
|
+
authority: "Auth",
|
|
14321
|
+
authorities: "Auths",
|
|
14322
|
+
group: "Grp",
|
|
14323
|
+
groups: "Grps",
|
|
14324
|
+
update: "Upd",
|
|
14325
|
+
updating: "Upd",
|
|
14326
|
+
updated: "Upd",
|
|
14327
|
+
delete: "Del",
|
|
14328
|
+
deleting: "Del",
|
|
14329
|
+
deleted: "Del",
|
|
14330
|
+
create: "Crt",
|
|
14331
|
+
creating: "Crt",
|
|
14332
|
+
created: "Crt",
|
|
14333
|
+
get: "Get",
|
|
14334
|
+
getting: "Get",
|
|
14335
|
+
list: "Lst",
|
|
14336
|
+
listing: "Lst",
|
|
14337
|
+
post: "Pst",
|
|
14338
|
+
put: "Put",
|
|
14339
|
+
patch: "Ptch",
|
|
14340
|
+
request: "Req",
|
|
14341
|
+
response: "Resp",
|
|
14342
|
+
parameter: "Param",
|
|
14343
|
+
parameters: "Params",
|
|
14344
|
+
config: "Cfg",
|
|
14345
|
+
configuration: "Config",
|
|
14346
|
+
configure: "Cfg",
|
|
14347
|
+
resource: "Res",
|
|
14348
|
+
resources: "Resrcs",
|
|
14349
|
+
identity: "Id",
|
|
14350
|
+
identifier: "Id",
|
|
14351
|
+
identification: "Id",
|
|
14352
|
+
identifiers: "Ids",
|
|
14353
|
+
application: "App",
|
|
14354
|
+
account: "Acct",
|
|
14355
|
+
information: "Info",
|
|
14356
|
+
notification: "Notif",
|
|
14357
|
+
description: "Desc",
|
|
14358
|
+
summary: "Summ",
|
|
14359
|
+
version: "Ver",
|
|
14360
|
+
value: "Val",
|
|
14361
|
+
values: "Vals",
|
|
14362
|
+
authentication: "Authn",
|
|
14363
|
+
authorization: "Authz",
|
|
14364
|
+
specification: "Spec",
|
|
14365
|
+
document: "Doc",
|
|
14366
|
+
documents: "Docs",
|
|
14367
|
+
repository: "Repo",
|
|
14368
|
+
repositories: "Repos",
|
|
14369
|
+
experimental: "Exp",
|
|
14370
|
+
deprecated: "Depr",
|
|
14371
|
+
query: "Qry"
|
|
14372
|
+
};
|
|
14373
|
+
|
|
14374
|
+
// src/openapi-loader.ts
|
|
14375
|
+
var OpenAPISpecLoader = class {
|
|
14376
|
+
/**
|
|
14377
|
+
* Load an OpenAPI specification from a file path or URL
|
|
14378
|
+
*/
|
|
14379
|
+
async loadOpenAPISpec(specPathOrUrl) {
|
|
14380
|
+
let specContent;
|
|
14381
|
+
if (specPathOrUrl.startsWith("http://") || specPathOrUrl.startsWith("https://")) {
|
|
14382
|
+
const response = await fetch(specPathOrUrl);
|
|
14383
|
+
if (!response.ok) {
|
|
14384
|
+
throw new Error(`Failed to fetch OpenAPI spec from URL: ${specPathOrUrl}`);
|
|
14385
|
+
}
|
|
14386
|
+
specContent = await response.text();
|
|
14387
|
+
} else {
|
|
14388
|
+
specContent = await readFile(specPathOrUrl, "utf-8");
|
|
14389
|
+
}
|
|
14390
|
+
try {
|
|
14391
|
+
return JSON.parse(specContent);
|
|
14392
|
+
} catch (jsonError) {
|
|
14393
|
+
try {
|
|
14394
|
+
return js_yaml_default.load(specContent);
|
|
14395
|
+
} catch (yamlError) {
|
|
14396
|
+
throw new Error(
|
|
14397
|
+
`Failed to parse OpenAPI spec as JSON or YAML: ${jsonError.message} | ${yamlError.message}`
|
|
14398
|
+
);
|
|
14399
|
+
}
|
|
14400
|
+
}
|
|
14401
|
+
}
|
|
14402
|
+
/**
|
|
14403
|
+
* Parse an OpenAPI specification into a map of tools
|
|
14404
|
+
*/
|
|
14405
|
+
parseOpenAPISpec(spec) {
|
|
14406
|
+
const tools = /* @__PURE__ */ new Map();
|
|
14407
|
+
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
14408
|
+
if (!pathItem) continue;
|
|
14409
|
+
for (const [method, operation] of Object.entries(pathItem)) {
|
|
14410
|
+
if (method === "parameters" || !operation) continue;
|
|
14411
|
+
const op = operation;
|
|
14412
|
+
const cleanPath = path.replace(/^\//, "").replace(/\{([^}]+)\}/g, "$1");
|
|
14413
|
+
const toolId = `${method.toUpperCase()}-${cleanPath}`.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
14414
|
+
let nameSource = op.operationId || op.summary || `${method.toUpperCase()} ${path}`;
|
|
14415
|
+
const name = this.abbreviateOperationId(nameSource);
|
|
14416
|
+
const tool = {
|
|
14417
|
+
name,
|
|
14418
|
+
description: op.description || `Make a ${method.toUpperCase()} request to ${path}`,
|
|
14419
|
+
inputSchema: {
|
|
14420
|
+
type: "object",
|
|
14421
|
+
properties: {}
|
|
14422
|
+
}
|
|
14423
|
+
};
|
|
14424
|
+
if (op.parameters) {
|
|
14425
|
+
const requiredParams = [];
|
|
14426
|
+
for (const param of op.parameters) {
|
|
14427
|
+
if ("name" in param && "in" in param) {
|
|
14428
|
+
const paramSchema = param.schema;
|
|
14429
|
+
if (tool.inputSchema && tool.inputSchema.properties) {
|
|
14430
|
+
tool.inputSchema.properties[param.name] = {
|
|
14431
|
+
type: paramSchema.type || "string",
|
|
14432
|
+
description: param.description || `${param.name} parameter`
|
|
14433
|
+
};
|
|
14434
|
+
}
|
|
14435
|
+
if (param.required === true) {
|
|
14436
|
+
requiredParams.push(param.name);
|
|
14437
|
+
}
|
|
14438
|
+
}
|
|
14439
|
+
}
|
|
14440
|
+
if (requiredParams.length > 0 && tool.inputSchema) {
|
|
14441
|
+
tool.inputSchema.required = requiredParams;
|
|
14442
|
+
}
|
|
14443
|
+
}
|
|
14444
|
+
tools.set(toolId, tool);
|
|
14445
|
+
}
|
|
14446
|
+
}
|
|
14447
|
+
return tools;
|
|
14448
|
+
}
|
|
14449
|
+
// Helper function to generate a simple hash
|
|
14450
|
+
generateShortHash(input, length = 4) {
|
|
14451
|
+
return crypto.createHash("sha256").update(input).digest("hex").substring(0, length);
|
|
14452
|
+
}
|
|
14453
|
+
// Helper to split by underscore, camelCase, and numbers, then filter out empty strings
|
|
14454
|
+
splitCombined(input) {
|
|
14455
|
+
const underscoreParts = input.split("_");
|
|
14456
|
+
let combinedParts = [];
|
|
14457
|
+
underscoreParts.forEach((part) => {
|
|
14458
|
+
const spacedPart = part.replace(/([A-Z]+)/g, " $1").replace(/([A-Z][a-z])/g, " $1").replace(/([a-z])([0-9])/g, "$1 $2").replace(/([0-9])([A-Za-z])/g, "$1 $2");
|
|
14459
|
+
const splitParts = spacedPart.split(" ").filter((p) => p.length > 0);
|
|
14460
|
+
combinedParts = combinedParts.concat(splitParts);
|
|
14461
|
+
});
|
|
14462
|
+
return combinedParts.map((p) => p.trim()).filter((p) => p.length > 0);
|
|
14463
|
+
}
|
|
14464
|
+
_initialSanitizeAndValidate(originalId, maxLength) {
|
|
14465
|
+
if (!originalId || originalId.trim().length === 0)
|
|
14466
|
+
return { currentName: "", originalWasLong: false, errorName: "unnamed-tool" };
|
|
14467
|
+
const originalWasLong = originalId.length > maxLength;
|
|
14468
|
+
let currentName = originalId.replace(/[^a-zA-Z0-9_]/g, "-");
|
|
14469
|
+
currentName = currentName.replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
14470
|
+
if (currentName.length === 0)
|
|
14471
|
+
return {
|
|
14472
|
+
currentName: "",
|
|
14473
|
+
originalWasLong,
|
|
14474
|
+
errorName: "tool-" + this.generateShortHash(originalId, 8)
|
|
14475
|
+
};
|
|
14476
|
+
return { currentName, originalWasLong };
|
|
14477
|
+
}
|
|
14478
|
+
_performSemanticAbbreviation(name) {
|
|
14479
|
+
let parts = this.splitCombined(name);
|
|
14480
|
+
parts = parts.filter((part) => {
|
|
14481
|
+
const cleanPartForCheck = part.toLowerCase().replace(/-+$/, "");
|
|
14482
|
+
return !REVISED_COMMON_WORDS_TO_REMOVE.includes(cleanPartForCheck);
|
|
14483
|
+
});
|
|
14484
|
+
parts = parts.map((part) => {
|
|
14485
|
+
const lowerPart = part.toLowerCase();
|
|
14486
|
+
if (WORD_ABBREVIATIONS[lowerPart]) {
|
|
14487
|
+
const abbr = WORD_ABBREVIATIONS[lowerPart];
|
|
14488
|
+
if (part.length > 0 && part[0] === part[0].toUpperCase() && part.slice(1) === part.slice(1).toLowerCase()) {
|
|
14489
|
+
return abbr[0].toUpperCase() + abbr.substring(1).toLowerCase();
|
|
14490
|
+
} else if (part === part.toUpperCase() && part.length > 1 && abbr.length > 1) {
|
|
14491
|
+
return abbr.toUpperCase();
|
|
14492
|
+
} else if (part.length > 0 && part[0] === part[0].toUpperCase()) {
|
|
14493
|
+
return abbr[0].toUpperCase() + abbr.substring(1).toLowerCase();
|
|
14494
|
+
}
|
|
14495
|
+
return abbr.toLowerCase();
|
|
14496
|
+
}
|
|
14497
|
+
return part;
|
|
14498
|
+
});
|
|
14499
|
+
return parts.join("-");
|
|
14500
|
+
}
|
|
14501
|
+
_applyVowelRemovalIfOverLength(name, maxLength) {
|
|
14502
|
+
let currentName = name;
|
|
14503
|
+
if (currentName.length > maxLength) {
|
|
14504
|
+
const currentParts = currentName.split("-");
|
|
14505
|
+
const newParts = currentParts.map((part) => {
|
|
14506
|
+
const isAbbreviation = Object.values(WORD_ABBREVIATIONS).some(
|
|
14507
|
+
(abbr) => abbr.toLowerCase() === part.toLowerCase()
|
|
14508
|
+
);
|
|
14509
|
+
if (part.length > 5 && !isAbbreviation) {
|
|
14510
|
+
const newPart = part[0] + part.substring(1).replace(/[aeiouAEIOU]/g, "");
|
|
14511
|
+
if (newPart.length < part.length && newPart.length > 1) return newPart;
|
|
14512
|
+
}
|
|
14513
|
+
return part;
|
|
14514
|
+
});
|
|
14515
|
+
currentName = newParts.join("-");
|
|
14516
|
+
}
|
|
14517
|
+
return currentName;
|
|
14518
|
+
}
|
|
14519
|
+
_truncateAndApplyHashIfNeeded(name, originalId, originalWasLong, maxLength) {
|
|
14520
|
+
let currentName = name;
|
|
14521
|
+
currentName = currentName.replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
14522
|
+
const needsHash = originalWasLong || currentName.length > maxLength;
|
|
14523
|
+
if (needsHash) {
|
|
14524
|
+
const hash = this.generateShortHash(originalId, 4);
|
|
14525
|
+
const maxLengthForBase = maxLength - hash.length - 1;
|
|
14526
|
+
if (currentName.length > maxLengthForBase) {
|
|
14527
|
+
currentName = currentName.substring(0, maxLengthForBase);
|
|
14528
|
+
currentName = currentName.replace(/-+$/, "");
|
|
14529
|
+
}
|
|
14530
|
+
currentName = currentName + "-" + hash;
|
|
14531
|
+
}
|
|
14532
|
+
return currentName;
|
|
14533
|
+
}
|
|
14534
|
+
_finalizeNameFormatting(name, originalId, maxLength) {
|
|
14535
|
+
let finalName = name.toLowerCase();
|
|
14536
|
+
finalName = finalName.replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "");
|
|
14537
|
+
if (finalName.length > maxLength) {
|
|
14538
|
+
finalName = finalName.substring(0, maxLength);
|
|
14539
|
+
finalName = finalName.replace(/-+$/, "");
|
|
14540
|
+
}
|
|
14541
|
+
if (finalName.length === 0) {
|
|
14542
|
+
return "tool-" + this.generateShortHash(originalId, 8);
|
|
14543
|
+
}
|
|
14544
|
+
return finalName;
|
|
14545
|
+
}
|
|
14546
|
+
abbreviateOperationId(originalId, maxLength = 64) {
|
|
14547
|
+
const {
|
|
14548
|
+
currentName: sanitizedName,
|
|
14549
|
+
originalWasLong,
|
|
14550
|
+
errorName
|
|
14551
|
+
} = this._initialSanitizeAndValidate(originalId, maxLength);
|
|
14552
|
+
if (errorName) return errorName;
|
|
14553
|
+
let processedName = this._performSemanticAbbreviation(sanitizedName);
|
|
14554
|
+
processedName = this._applyVowelRemovalIfOverLength(processedName, maxLength);
|
|
14555
|
+
processedName = this._truncateAndApplyHashIfNeeded(
|
|
14556
|
+
processedName,
|
|
14557
|
+
originalId,
|
|
14558
|
+
originalWasLong,
|
|
14559
|
+
maxLength
|
|
14560
|
+
);
|
|
14561
|
+
processedName = this._finalizeNameFormatting(processedName, originalId, maxLength);
|
|
14562
|
+
return processedName;
|
|
14563
|
+
}
|
|
14564
|
+
};
|
|
14565
|
+
|
|
14566
|
+
// src/tools-manager.ts
|
|
14567
|
+
var ToolsManager = class {
|
|
14568
|
+
constructor(config) {
|
|
14569
|
+
this.config = config;
|
|
14570
|
+
this.specLoader = new OpenAPISpecLoader();
|
|
14571
|
+
}
|
|
14572
|
+
tools = /* @__PURE__ */ new Map();
|
|
14573
|
+
specLoader;
|
|
14574
|
+
/**
|
|
14575
|
+
* Initialize tools from the OpenAPI specification
|
|
14576
|
+
*/
|
|
14577
|
+
async initialize() {
|
|
14578
|
+
const spec = await this.specLoader.loadOpenAPISpec(this.config.openApiSpec);
|
|
14579
|
+
this.tools = this.specLoader.parseOpenAPISpec(spec);
|
|
14580
|
+
for (const [toolId, tool] of this.tools.entries()) {
|
|
14581
|
+
console.error(`Registered tool: ${toolId} (${tool.name})`);
|
|
14582
|
+
}
|
|
14583
|
+
}
|
|
14584
|
+
/**
|
|
14585
|
+
* Get all available tools
|
|
14586
|
+
*/
|
|
14587
|
+
getAllTools() {
|
|
14588
|
+
return Array.from(this.tools.values());
|
|
14589
|
+
}
|
|
14590
|
+
/**
|
|
14591
|
+
* Find a tool by ID or name
|
|
14592
|
+
*/
|
|
14593
|
+
findTool(idOrName) {
|
|
14594
|
+
if (this.tools.has(idOrName)) {
|
|
14595
|
+
return { toolId: idOrName, tool: this.tools.get(idOrName) };
|
|
14596
|
+
}
|
|
14597
|
+
for (const [toolId, tool] of this.tools.entries()) {
|
|
14598
|
+
if (tool.name === idOrName) {
|
|
14599
|
+
return { toolId, tool };
|
|
14600
|
+
}
|
|
14601
|
+
}
|
|
14602
|
+
return void 0;
|
|
14603
|
+
}
|
|
14604
|
+
/**
|
|
14605
|
+
* Get the path and method from a tool ID
|
|
14606
|
+
*/
|
|
14607
|
+
parseToolId(toolId) {
|
|
14608
|
+
const [method, ...pathParts] = toolId.split("-");
|
|
14609
|
+
const path = "/" + pathParts.join("/").replace(/-/g, "/");
|
|
14610
|
+
return { method, path };
|
|
14611
|
+
}
|
|
14612
|
+
};
|
|
14613
|
+
|
|
11661
14614
|
// node_modules/axios/lib/helpers/bind.js
|
|
11662
14615
|
function bind(fn, thisArg) {
|
|
11663
14616
|
return function wrap2() {
|
|
@@ -11666,18 +14619,18 @@ function bind(fn, thisArg) {
|
|
|
11666
14619
|
}
|
|
11667
14620
|
|
|
11668
14621
|
// node_modules/axios/lib/utils.js
|
|
11669
|
-
var { toString } = Object.prototype;
|
|
14622
|
+
var { toString: toString2 } = Object.prototype;
|
|
11670
14623
|
var { getPrototypeOf } = Object;
|
|
11671
14624
|
var { iterator, toStringTag } = Symbol;
|
|
11672
14625
|
var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
|
|
11673
|
-
const
|
|
11674
|
-
return cache[
|
|
14626
|
+
const str2 = toString2.call(thing);
|
|
14627
|
+
return cache[str2] || (cache[str2] = str2.slice(8, -1).toLowerCase());
|
|
11675
14628
|
})(/* @__PURE__ */ Object.create(null));
|
|
11676
|
-
var kindOfTest = (
|
|
11677
|
-
|
|
11678
|
-
return (thing) => kindOf(thing) ===
|
|
14629
|
+
var kindOfTest = (type2) => {
|
|
14630
|
+
type2 = type2.toLowerCase();
|
|
14631
|
+
return (thing) => kindOf(thing) === type2;
|
|
11679
14632
|
};
|
|
11680
|
-
var typeOfTest = (
|
|
14633
|
+
var typeOfTest = (type2) => (thing) => typeof thing === type2;
|
|
11681
14634
|
var { isArray } = Array;
|
|
11682
14635
|
var isUndefined = typeOfTest("undefined");
|
|
11683
14636
|
function isBuffer(val) {
|
|
@@ -11696,8 +14649,8 @@ function isArrayBufferView(val) {
|
|
|
11696
14649
|
var isString = typeOfTest("string");
|
|
11697
14650
|
var isFunction = typeOfTest("function");
|
|
11698
14651
|
var isNumber = typeOfTest("number");
|
|
11699
|
-
var
|
|
11700
|
-
var
|
|
14652
|
+
var isObject2 = (thing) => thing !== null && typeof thing === "object";
|
|
14653
|
+
var isBoolean2 = (thing) => thing === true || thing === false;
|
|
11701
14654
|
var isPlainObject = (val) => {
|
|
11702
14655
|
if (kindOf(val) !== "object") {
|
|
11703
14656
|
return false;
|
|
@@ -11709,7 +14662,7 @@ var isDate = kindOfTest("Date");
|
|
|
11709
14662
|
var isFile = kindOfTest("File");
|
|
11710
14663
|
var isBlob = kindOfTest("Blob");
|
|
11711
14664
|
var isFileList = kindOfTest("FileList");
|
|
11712
|
-
var isStream = (val) =>
|
|
14665
|
+
var isStream = (val) => isObject2(val) && isFunction(val.pipe);
|
|
11713
14666
|
var isFormData = (thing) => {
|
|
11714
14667
|
let kind;
|
|
11715
14668
|
return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
|
|
@@ -11717,7 +14670,7 @@ var isFormData = (thing) => {
|
|
|
11717
14670
|
};
|
|
11718
14671
|
var isURLSearchParams = kindOfTest("URLSearchParams");
|
|
11719
14672
|
var [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
|
|
11720
|
-
var trim = (
|
|
14673
|
+
var trim = (str2) => str2.trim ? str2.trim() : str2.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
11721
14674
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
11722
14675
|
if (obj === null || typeof obj === "undefined") {
|
|
11723
14676
|
return;
|
|
@@ -11759,15 +14712,15 @@ var _global = (() => {
|
|
|
11759
14712
|
return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
|
|
11760
14713
|
})();
|
|
11761
14714
|
var isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
11762
|
-
function
|
|
14715
|
+
function merge2() {
|
|
11763
14716
|
const { caseless } = isContextDefined(this) && this || {};
|
|
11764
14717
|
const result = {};
|
|
11765
14718
|
const assignValue = (val, key) => {
|
|
11766
14719
|
const targetKey = caseless && findKey(result, key) || key;
|
|
11767
14720
|
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
11768
|
-
result[targetKey] =
|
|
14721
|
+
result[targetKey] = merge2(result[targetKey], val);
|
|
11769
14722
|
} else if (isPlainObject(val)) {
|
|
11770
|
-
result[targetKey] =
|
|
14723
|
+
result[targetKey] = merge2({}, val);
|
|
11771
14724
|
} else if (isArray(val)) {
|
|
11772
14725
|
result[targetKey] = val.slice();
|
|
11773
14726
|
} else {
|
|
@@ -11779,7 +14732,7 @@ function merge() {
|
|
|
11779
14732
|
}
|
|
11780
14733
|
return result;
|
|
11781
14734
|
}
|
|
11782
|
-
var
|
|
14735
|
+
var extend3 = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
11783
14736
|
forEach(b, (val, key) => {
|
|
11784
14737
|
if (thisArg && isFunction(val)) {
|
|
11785
14738
|
a[key] = bind(val, thisArg);
|
|
@@ -11824,16 +14777,16 @@ var toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
|
|
|
11824
14777
|
} while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
11825
14778
|
return destObj;
|
|
11826
14779
|
};
|
|
11827
|
-
var endsWith = (
|
|
11828
|
-
|
|
11829
|
-
if (position === void 0 || position >
|
|
11830
|
-
position =
|
|
14780
|
+
var endsWith = (str2, searchString, position) => {
|
|
14781
|
+
str2 = String(str2);
|
|
14782
|
+
if (position === void 0 || position > str2.length) {
|
|
14783
|
+
position = str2.length;
|
|
11831
14784
|
}
|
|
11832
14785
|
position -= searchString.length;
|
|
11833
|
-
const lastIndex =
|
|
14786
|
+
const lastIndex = str2.indexOf(searchString, position);
|
|
11834
14787
|
return lastIndex !== -1 && lastIndex === position;
|
|
11835
14788
|
};
|
|
11836
|
-
var
|
|
14789
|
+
var toArray2 = (thing) => {
|
|
11837
14790
|
if (!thing) return null;
|
|
11838
14791
|
if (isArray(thing)) return thing;
|
|
11839
14792
|
let i = thing.length;
|
|
@@ -11858,17 +14811,17 @@ var forEachEntry = (obj, fn) => {
|
|
|
11858
14811
|
fn.call(obj, pair[0], pair[1]);
|
|
11859
14812
|
}
|
|
11860
14813
|
};
|
|
11861
|
-
var matchAll = (regExp,
|
|
14814
|
+
var matchAll = (regExp, str2) => {
|
|
11862
14815
|
let matches;
|
|
11863
14816
|
const arr = [];
|
|
11864
|
-
while ((matches = regExp.exec(
|
|
14817
|
+
while ((matches = regExp.exec(str2)) !== null) {
|
|
11865
14818
|
arr.push(matches);
|
|
11866
14819
|
}
|
|
11867
14820
|
return arr;
|
|
11868
14821
|
};
|
|
11869
14822
|
var isHTMLForm = kindOfTest("HTMLFormElement");
|
|
11870
|
-
var toCamelCase = (
|
|
11871
|
-
return
|
|
14823
|
+
var toCamelCase = (str2) => {
|
|
14824
|
+
return str2.toLowerCase().replace(
|
|
11872
14825
|
/[-_\s]([a-z\d])(\w*)/g,
|
|
11873
14826
|
function replacer(m, p1, p2) {
|
|
11874
14827
|
return p1.toUpperCase() + p2;
|
|
@@ -11928,7 +14881,7 @@ function isSpecCompliantForm(thing) {
|
|
|
11928
14881
|
var toJSONObject = (obj) => {
|
|
11929
14882
|
const stack = new Array(10);
|
|
11930
14883
|
const visit = (source, i) => {
|
|
11931
|
-
if (
|
|
14884
|
+
if (isObject2(source)) {
|
|
11932
14885
|
if (stack.indexOf(source) >= 0) {
|
|
11933
14886
|
return;
|
|
11934
14887
|
}
|
|
@@ -11948,7 +14901,7 @@ var toJSONObject = (obj) => {
|
|
|
11948
14901
|
return visit(obj, 0);
|
|
11949
14902
|
};
|
|
11950
14903
|
var isAsyncFn = kindOfTest("AsyncFunction");
|
|
11951
|
-
var isThenable = (thing) => thing && (
|
|
14904
|
+
var isThenable = (thing) => thing && (isObject2(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
11952
14905
|
var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
11953
14906
|
if (setImmediateSupported) {
|
|
11954
14907
|
return setImmediate;
|
|
@@ -11978,8 +14931,8 @@ var utils_default = {
|
|
|
11978
14931
|
isArrayBufferView,
|
|
11979
14932
|
isString,
|
|
11980
14933
|
isNumber,
|
|
11981
|
-
isBoolean,
|
|
11982
|
-
isObject,
|
|
14934
|
+
isBoolean: isBoolean2,
|
|
14935
|
+
isObject: isObject2,
|
|
11983
14936
|
isPlainObject,
|
|
11984
14937
|
isReadableStream,
|
|
11985
14938
|
isRequest,
|
|
@@ -11996,8 +14949,8 @@ var utils_default = {
|
|
|
11996
14949
|
isTypedArray,
|
|
11997
14950
|
isFileList,
|
|
11998
14951
|
forEach,
|
|
11999
|
-
merge,
|
|
12000
|
-
extend,
|
|
14952
|
+
merge: merge2,
|
|
14953
|
+
extend: extend3,
|
|
12001
14954
|
trim,
|
|
12002
14955
|
stripBOM,
|
|
12003
14956
|
inherits,
|
|
@@ -12005,7 +14958,7 @@ var utils_default = {
|
|
|
12005
14958
|
kindOf,
|
|
12006
14959
|
kindOfTest,
|
|
12007
14960
|
endsWith,
|
|
12008
|
-
toArray,
|
|
14961
|
+
toArray: toArray2,
|
|
12009
14962
|
forEachEntry,
|
|
12010
14963
|
matchAll,
|
|
12011
14964
|
isHTMLForm,
|
|
@@ -12222,7 +15175,7 @@ function toFormData(obj, formData, options) {
|
|
|
12222
15175
|
var toFormData_default = toFormData;
|
|
12223
15176
|
|
|
12224
15177
|
// node_modules/axios/lib/helpers/AxiosURLSearchParams.js
|
|
12225
|
-
function encode(
|
|
15178
|
+
function encode(str2) {
|
|
12226
15179
|
const charMap = {
|
|
12227
15180
|
"!": "%21",
|
|
12228
15181
|
"'": "%27",
|
|
@@ -12232,7 +15185,7 @@ function encode(str) {
|
|
|
12232
15185
|
"%20": "+",
|
|
12233
15186
|
"%00": "\0"
|
|
12234
15187
|
};
|
|
12235
|
-
return encodeURIComponent(
|
|
15188
|
+
return encodeURIComponent(str2).replace(/[!'()~]|%20|%00/g, function replacer(match) {
|
|
12236
15189
|
return charMap[match];
|
|
12237
15190
|
});
|
|
12238
15191
|
}
|
|
@@ -12244,7 +15197,7 @@ var prototype2 = AxiosURLSearchParams.prototype;
|
|
|
12244
15197
|
prototype2.append = function append(name, value) {
|
|
12245
15198
|
this._pairs.push([name, value]);
|
|
12246
15199
|
};
|
|
12247
|
-
prototype2.toString = function
|
|
15200
|
+
prototype2.toString = function toString3(encoder) {
|
|
12248
15201
|
const _encode = encoder ? function(value) {
|
|
12249
15202
|
return encoder.call(this, value, encode);
|
|
12250
15203
|
} : encode;
|
|
@@ -12357,7 +15310,7 @@ var transitional_default = {
|
|
|
12357
15310
|
};
|
|
12358
15311
|
|
|
12359
15312
|
// node_modules/axios/lib/platform/node/index.js
|
|
12360
|
-
import
|
|
15313
|
+
import crypto2 from "crypto";
|
|
12361
15314
|
|
|
12362
15315
|
// node_modules/axios/lib/platform/node/classes/URLSearchParams.js
|
|
12363
15316
|
import url from "url";
|
|
@@ -12372,14 +15325,14 @@ var ALPHABET = {
|
|
|
12372
15325
|
ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
|
|
12373
15326
|
};
|
|
12374
15327
|
var generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
|
|
12375
|
-
let
|
|
15328
|
+
let str2 = "";
|
|
12376
15329
|
const { length } = alphabet;
|
|
12377
15330
|
const randomValues = new Uint32Array(size);
|
|
12378
|
-
|
|
15331
|
+
crypto2.randomFillSync(randomValues);
|
|
12379
15332
|
for (let i = 0; i < size; i++) {
|
|
12380
|
-
|
|
15333
|
+
str2 += alphabet[randomValues[i] % length];
|
|
12381
15334
|
}
|
|
12382
|
-
return
|
|
15335
|
+
return str2;
|
|
12383
15336
|
};
|
|
12384
15337
|
var node_default = {
|
|
12385
15338
|
isNode: true,
|
|
@@ -12648,16 +15601,16 @@ function normalizeValue(value) {
|
|
|
12648
15601
|
}
|
|
12649
15602
|
return utils_default.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
12650
15603
|
}
|
|
12651
|
-
function parseTokens(
|
|
15604
|
+
function parseTokens(str2) {
|
|
12652
15605
|
const tokens = /* @__PURE__ */ Object.create(null);
|
|
12653
15606
|
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
12654
15607
|
let match;
|
|
12655
|
-
while (match = tokensRE.exec(
|
|
15608
|
+
while (match = tokensRE.exec(str2)) {
|
|
12656
15609
|
tokens[match[1]] = match[2];
|
|
12657
15610
|
}
|
|
12658
15611
|
return tokens;
|
|
12659
15612
|
}
|
|
12660
|
-
var isValidHeaderName = (
|
|
15613
|
+
var isValidHeaderName = (str2) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str2.trim());
|
|
12661
15614
|
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
12662
15615
|
if (utils_default.isFunction(filter2)) {
|
|
12663
15616
|
return filter2.call(this, value, header);
|
|
@@ -12674,8 +15627,8 @@ function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
|
12674
15627
|
}
|
|
12675
15628
|
}
|
|
12676
15629
|
function formatHeader(header) {
|
|
12677
|
-
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char,
|
|
12678
|
-
return char.toUpperCase() +
|
|
15630
|
+
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str2) => {
|
|
15631
|
+
return char.toUpperCase() + str2;
|
|
12679
15632
|
});
|
|
12680
15633
|
}
|
|
12681
15634
|
function buildAccessors(obj, header) {
|
|
@@ -13269,12 +16222,12 @@ var speedometer_default = speedometer;
|
|
|
13269
16222
|
|
|
13270
16223
|
// node_modules/axios/lib/helpers/throttle.js
|
|
13271
16224
|
function throttle(fn, freq) {
|
|
13272
|
-
let
|
|
16225
|
+
let timestamp2 = 0;
|
|
13273
16226
|
let threshold = 1e3 / freq;
|
|
13274
16227
|
let lastArgs;
|
|
13275
16228
|
let timer;
|
|
13276
16229
|
const invoke = (args, now = Date.now()) => {
|
|
13277
|
-
|
|
16230
|
+
timestamp2 = now;
|
|
13278
16231
|
lastArgs = null;
|
|
13279
16232
|
if (timer) {
|
|
13280
16233
|
clearTimeout(timer);
|
|
@@ -13284,7 +16237,7 @@ function throttle(fn, freq) {
|
|
|
13284
16237
|
};
|
|
13285
16238
|
const throttled = (...args) => {
|
|
13286
16239
|
const now = Date.now();
|
|
13287
|
-
const passed = now -
|
|
16240
|
+
const passed = now - timestamp2;
|
|
13288
16241
|
if (passed >= threshold) {
|
|
13289
16242
|
invoke(args, now);
|
|
13290
16243
|
} else {
|
|
@@ -13953,9 +16906,9 @@ function mergeConfig(config1, config2) {
|
|
|
13953
16906
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
13954
16907
|
};
|
|
13955
16908
|
utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
13956
|
-
const
|
|
13957
|
-
const configValue =
|
|
13958
|
-
utils_default.isUndefined(configValue) &&
|
|
16909
|
+
const merge3 = mergeMap[prop] || mergeDeepProperties;
|
|
16910
|
+
const configValue = merge3(config1[prop], config2[prop], prop);
|
|
16911
|
+
utils_default.isUndefined(configValue) && merge3 !== mergeDirectKeys || (config[prop] = configValue);
|
|
13959
16912
|
});
|
|
13960
16913
|
return config;
|
|
13961
16914
|
}
|
|
@@ -13977,8 +16930,8 @@ var resolveConfig_default = (config) => {
|
|
|
13977
16930
|
if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv) {
|
|
13978
16931
|
headers.setContentType(void 0);
|
|
13979
16932
|
} else if ((contentType = headers.getContentType()) !== false) {
|
|
13980
|
-
const [
|
|
13981
|
-
headers.setContentType([
|
|
16933
|
+
const [type2, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
|
|
16934
|
+
headers.setContentType([type2 || "multipart/form-data", ...tokens].join("; "));
|
|
13982
16935
|
}
|
|
13983
16936
|
}
|
|
13984
16937
|
if (platform_default.hasStandardBrowserEnv) {
|
|
@@ -14236,7 +17189,7 @@ var trackStream = (stream4, chunkSize, onProgress, onFinish) => {
|
|
|
14236
17189
|
// node_modules/axios/lib/adapters/fetch.js
|
|
14237
17190
|
var isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
|
|
14238
17191
|
var isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
|
|
14239
|
-
var encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (
|
|
17192
|
+
var encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str2) => encoder.encode(str2))(new TextEncoder()) : async (str2) => new Uint8Array(await new Response(str2).arrayBuffer()));
|
|
14240
17193
|
var test = (fn, ...args) => {
|
|
14241
17194
|
try {
|
|
14242
17195
|
return !!fn(...args);
|
|
@@ -14262,9 +17215,9 @@ var resolvers = {
|
|
|
14262
17215
|
stream: supportsResponseStream && ((res) => res.body)
|
|
14263
17216
|
};
|
|
14264
17217
|
isFetchSupported && ((res) => {
|
|
14265
|
-
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((
|
|
14266
|
-
!resolvers[
|
|
14267
|
-
throw new AxiosError_default(`Response type '${
|
|
17218
|
+
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type2) => {
|
|
17219
|
+
!resolvers[type2] && (resolvers[type2] = utils_default.isFunction(res[type2]) ? (res2) => res2[type2]() : (_, config) => {
|
|
17220
|
+
throw new AxiosError_default(`Response type '${type2}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config);
|
|
14268
17221
|
});
|
|
14269
17222
|
});
|
|
14270
17223
|
})(new Response());
|
|
@@ -14498,9 +17451,9 @@ function dispatchRequest(config) {
|
|
|
14498
17451
|
|
|
14499
17452
|
// node_modules/axios/lib/helpers/validator.js
|
|
14500
17453
|
var validators = {};
|
|
14501
|
-
["object", "boolean", "number", "function", "string", "symbol"].forEach((
|
|
14502
|
-
validators[
|
|
14503
|
-
return typeof thing ===
|
|
17454
|
+
["object", "boolean", "number", "function", "string", "symbol"].forEach((type2, i) => {
|
|
17455
|
+
validators[type2] = function validator(thing) {
|
|
17456
|
+
return typeof thing === type2 || "a" + (i < 1 ? "n " : " ") + type2;
|
|
14504
17457
|
};
|
|
14505
17458
|
});
|
|
14506
17459
|
var deprecatedWarnings = {};
|
|
@@ -14533,7 +17486,7 @@ validators.spelling = function spelling(correctSpelling) {
|
|
|
14533
17486
|
return true;
|
|
14534
17487
|
};
|
|
14535
17488
|
};
|
|
14536
|
-
function assertOptions(options,
|
|
17489
|
+
function assertOptions(options, schema2, allowUnknown) {
|
|
14537
17490
|
if (typeof options !== "object") {
|
|
14538
17491
|
throw new AxiosError_default("options must be an object", AxiosError_default.ERR_BAD_OPTION_VALUE);
|
|
14539
17492
|
}
|
|
@@ -14541,7 +17494,7 @@ function assertOptions(options, schema, allowUnknown) {
|
|
|
14541
17494
|
let i = keys.length;
|
|
14542
17495
|
while (i-- > 0) {
|
|
14543
17496
|
const opt = keys[i];
|
|
14544
|
-
const validator =
|
|
17497
|
+
const validator = schema2[opt];
|
|
14545
17498
|
if (validator) {
|
|
14546
17499
|
const value = options[opt];
|
|
14547
17500
|
const result = value === void 0 || validator(value, opt, options);
|
|
@@ -14910,173 +17863,62 @@ var HttpStatusCode = {
|
|
|
14910
17863
|
NetworkAuthenticationRequired: 511
|
|
14911
17864
|
};
|
|
14912
17865
|
Object.entries(HttpStatusCode).forEach(([key, value]) => {
|
|
14913
|
-
HttpStatusCode[value] = key;
|
|
14914
|
-
});
|
|
14915
|
-
var HttpStatusCode_default = HttpStatusCode;
|
|
14916
|
-
|
|
14917
|
-
// node_modules/axios/lib/axios.js
|
|
14918
|
-
function createInstance(defaultConfig) {
|
|
14919
|
-
const context = new Axios_default(defaultConfig);
|
|
14920
|
-
const instance = bind(Axios_default.prototype.request, context);
|
|
14921
|
-
utils_default.extend(instance, Axios_default.prototype, context, { allOwnKeys: true });
|
|
14922
|
-
utils_default.extend(instance, context, null, { allOwnKeys: true });
|
|
14923
|
-
instance.create = function create(instanceConfig) {
|
|
14924
|
-
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|
14925
|
-
};
|
|
14926
|
-
return instance;
|
|
14927
|
-
}
|
|
14928
|
-
var axios = createInstance(defaults_default);
|
|
14929
|
-
axios.Axios = Axios_default;
|
|
14930
|
-
axios.CanceledError = CanceledError_default;
|
|
14931
|
-
axios.CancelToken = CancelToken_default;
|
|
14932
|
-
axios.isCancel = isCancel;
|
|
14933
|
-
axios.VERSION = VERSION;
|
|
14934
|
-
axios.toFormData = toFormData_default;
|
|
14935
|
-
axios.AxiosError = AxiosError_default;
|
|
14936
|
-
axios.Cancel = axios.CanceledError;
|
|
14937
|
-
axios.all = function all(promises) {
|
|
14938
|
-
return Promise.all(promises);
|
|
14939
|
-
};
|
|
14940
|
-
axios.spread = spread;
|
|
14941
|
-
axios.isAxiosError = isAxiosError;
|
|
14942
|
-
axios.mergeConfig = mergeConfig;
|
|
14943
|
-
axios.AxiosHeaders = AxiosHeaders_default;
|
|
14944
|
-
axios.formToJSON = (thing) => formDataToJSON_default(utils_default.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
14945
|
-
axios.getAdapter = adapters_default.getAdapter;
|
|
14946
|
-
axios.HttpStatusCode = HttpStatusCode_default;
|
|
14947
|
-
axios.default = axios;
|
|
14948
|
-
var axios_default = axios;
|
|
14949
|
-
|
|
14950
|
-
// node_modules/axios/index.js
|
|
14951
|
-
var {
|
|
14952
|
-
Axios: Axios2,
|
|
14953
|
-
AxiosError: AxiosError2,
|
|
14954
|
-
CanceledError: CanceledError2,
|
|
14955
|
-
isCancel: isCancel2,
|
|
14956
|
-
CancelToken: CancelToken2,
|
|
14957
|
-
VERSION: VERSION2,
|
|
14958
|
-
all: all2,
|
|
14959
|
-
Cancel,
|
|
14960
|
-
isAxiosError: isAxiosError2,
|
|
14961
|
-
spread: spread2,
|
|
14962
|
-
toFormData: toFormData2,
|
|
14963
|
-
AxiosHeaders: AxiosHeaders2,
|
|
14964
|
-
HttpStatusCode: HttpStatusCode2,
|
|
14965
|
-
formToJSON,
|
|
14966
|
-
getAdapter,
|
|
14967
|
-
mergeConfig: mergeConfig2
|
|
14968
|
-
} = axios_default;
|
|
14969
|
-
|
|
14970
|
-
// src/openapi-loader.ts
|
|
14971
|
-
import { readFile } from "fs/promises";
|
|
14972
|
-
var OpenAPISpecLoader = class {
|
|
14973
|
-
/**
|
|
14974
|
-
* Load an OpenAPI specification from a file or URL
|
|
14975
|
-
*/
|
|
14976
|
-
async loadOpenAPISpec(specPath) {
|
|
14977
|
-
if (specPath.startsWith("http")) {
|
|
14978
|
-
const response = await axios_default.get(specPath);
|
|
14979
|
-
return response.data;
|
|
14980
|
-
} else {
|
|
14981
|
-
const content = await readFile(specPath, "utf-8");
|
|
14982
|
-
return JSON.parse(content);
|
|
14983
|
-
}
|
|
14984
|
-
}
|
|
14985
|
-
/**
|
|
14986
|
-
* Parse an OpenAPI specification into a map of tools
|
|
14987
|
-
*/
|
|
14988
|
-
parseOpenAPISpec(spec) {
|
|
14989
|
-
const tools = /* @__PURE__ */ new Map();
|
|
14990
|
-
for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
14991
|
-
if (!pathItem) continue;
|
|
14992
|
-
for (const [method, operation] of Object.entries(pathItem)) {
|
|
14993
|
-
if (method === "parameters" || !operation) continue;
|
|
14994
|
-
const op = operation;
|
|
14995
|
-
const cleanPath = path.replace(/^\//, "").replace(/\{([^}]+)\}/g, "$1");
|
|
14996
|
-
const toolId = `${method.toUpperCase()}-${cleanPath}`.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
14997
|
-
const name = (op.operationId || op.summary || `${method.toUpperCase()} ${path}`).replace(
|
|
14998
|
-
/[^a-zA-Z0-9-]/g,
|
|
14999
|
-
"-"
|
|
15000
|
-
);
|
|
15001
|
-
const tool = {
|
|
15002
|
-
name,
|
|
15003
|
-
description: op.description || `Make a ${method.toUpperCase()} request to ${path}`,
|
|
15004
|
-
inputSchema: {
|
|
15005
|
-
type: "object",
|
|
15006
|
-
properties: {}
|
|
15007
|
-
}
|
|
15008
|
-
};
|
|
15009
|
-
if (op.parameters) {
|
|
15010
|
-
for (const param of op.parameters) {
|
|
15011
|
-
if ("name" in param && "in" in param) {
|
|
15012
|
-
const paramSchema = param.schema;
|
|
15013
|
-
tool.inputSchema.properties[param.name] = {
|
|
15014
|
-
type: paramSchema.type || "string",
|
|
15015
|
-
description: param.description || `${param.name} parameter`
|
|
15016
|
-
};
|
|
15017
|
-
if (param.required === true) {
|
|
15018
|
-
if (!tool.inputSchema.required) {
|
|
15019
|
-
tool.inputSchema.required = [];
|
|
15020
|
-
}
|
|
15021
|
-
tool.inputSchema.required.push(param.name);
|
|
15022
|
-
}
|
|
15023
|
-
}
|
|
15024
|
-
}
|
|
15025
|
-
}
|
|
15026
|
-
tools.set(toolId, tool);
|
|
15027
|
-
}
|
|
15028
|
-
}
|
|
15029
|
-
return tools;
|
|
15030
|
-
}
|
|
15031
|
-
};
|
|
15032
|
-
|
|
15033
|
-
// src/tools-manager.ts
|
|
15034
|
-
var ToolsManager = class {
|
|
15035
|
-
constructor(config) {
|
|
15036
|
-
this.config = config;
|
|
15037
|
-
this.specLoader = new OpenAPISpecLoader();
|
|
15038
|
-
}
|
|
15039
|
-
tools = /* @__PURE__ */ new Map();
|
|
15040
|
-
specLoader;
|
|
15041
|
-
/**
|
|
15042
|
-
* Initialize tools from the OpenAPI specification
|
|
15043
|
-
*/
|
|
15044
|
-
async initialize() {
|
|
15045
|
-
const spec = await this.specLoader.loadOpenAPISpec(this.config.openApiSpec);
|
|
15046
|
-
this.tools = this.specLoader.parseOpenAPISpec(spec);
|
|
15047
|
-
for (const [toolId, tool] of this.tools.entries()) {
|
|
15048
|
-
console.error(`Registered tool: ${toolId} (${tool.name})`);
|
|
15049
|
-
}
|
|
15050
|
-
}
|
|
15051
|
-
/**
|
|
15052
|
-
* Get all available tools
|
|
15053
|
-
*/
|
|
15054
|
-
getAllTools() {
|
|
15055
|
-
return Array.from(this.tools.values());
|
|
15056
|
-
}
|
|
15057
|
-
/**
|
|
15058
|
-
* Find a tool by ID or name
|
|
15059
|
-
*/
|
|
15060
|
-
findTool(idOrName) {
|
|
15061
|
-
if (this.tools.has(idOrName)) {
|
|
15062
|
-
return { toolId: idOrName, tool: this.tools.get(idOrName) };
|
|
15063
|
-
}
|
|
15064
|
-
for (const [toolId, tool] of this.tools.entries()) {
|
|
15065
|
-
if (tool.name === idOrName) {
|
|
15066
|
-
return { toolId, tool };
|
|
15067
|
-
}
|
|
15068
|
-
}
|
|
15069
|
-
return void 0;
|
|
15070
|
-
}
|
|
15071
|
-
/**
|
|
15072
|
-
* Get the path and method from a tool ID
|
|
15073
|
-
*/
|
|
15074
|
-
parseToolId(toolId) {
|
|
15075
|
-
const [method, ...pathParts] = toolId.split("-");
|
|
15076
|
-
const path = "/" + pathParts.join("/").replace(/-/g, "/");
|
|
15077
|
-
return { method, path };
|
|
15078
|
-
}
|
|
17866
|
+
HttpStatusCode[value] = key;
|
|
17867
|
+
});
|
|
17868
|
+
var HttpStatusCode_default = HttpStatusCode;
|
|
17869
|
+
|
|
17870
|
+
// node_modules/axios/lib/axios.js
|
|
17871
|
+
function createInstance(defaultConfig) {
|
|
17872
|
+
const context = new Axios_default(defaultConfig);
|
|
17873
|
+
const instance = bind(Axios_default.prototype.request, context);
|
|
17874
|
+
utils_default.extend(instance, Axios_default.prototype, context, { allOwnKeys: true });
|
|
17875
|
+
utils_default.extend(instance, context, null, { allOwnKeys: true });
|
|
17876
|
+
instance.create = function create(instanceConfig) {
|
|
17877
|
+
return createInstance(mergeConfig(defaultConfig, instanceConfig));
|
|
17878
|
+
};
|
|
17879
|
+
return instance;
|
|
17880
|
+
}
|
|
17881
|
+
var axios = createInstance(defaults_default);
|
|
17882
|
+
axios.Axios = Axios_default;
|
|
17883
|
+
axios.CanceledError = CanceledError_default;
|
|
17884
|
+
axios.CancelToken = CancelToken_default;
|
|
17885
|
+
axios.isCancel = isCancel;
|
|
17886
|
+
axios.VERSION = VERSION;
|
|
17887
|
+
axios.toFormData = toFormData_default;
|
|
17888
|
+
axios.AxiosError = AxiosError_default;
|
|
17889
|
+
axios.Cancel = axios.CanceledError;
|
|
17890
|
+
axios.all = function all(promises) {
|
|
17891
|
+
return Promise.all(promises);
|
|
15079
17892
|
};
|
|
17893
|
+
axios.spread = spread;
|
|
17894
|
+
axios.isAxiosError = isAxiosError;
|
|
17895
|
+
axios.mergeConfig = mergeConfig;
|
|
17896
|
+
axios.AxiosHeaders = AxiosHeaders_default;
|
|
17897
|
+
axios.formToJSON = (thing) => formDataToJSON_default(utils_default.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
17898
|
+
axios.getAdapter = adapters_default.getAdapter;
|
|
17899
|
+
axios.HttpStatusCode = HttpStatusCode_default;
|
|
17900
|
+
axios.default = axios;
|
|
17901
|
+
var axios_default = axios;
|
|
17902
|
+
|
|
17903
|
+
// node_modules/axios/index.js
|
|
17904
|
+
var {
|
|
17905
|
+
Axios: Axios2,
|
|
17906
|
+
AxiosError: AxiosError2,
|
|
17907
|
+
CanceledError: CanceledError2,
|
|
17908
|
+
isCancel: isCancel2,
|
|
17909
|
+
CancelToken: CancelToken2,
|
|
17910
|
+
VERSION: VERSION2,
|
|
17911
|
+
all: all2,
|
|
17912
|
+
Cancel,
|
|
17913
|
+
isAxiosError: isAxiosError2,
|
|
17914
|
+
spread: spread2,
|
|
17915
|
+
toFormData: toFormData2,
|
|
17916
|
+
AxiosHeaders: AxiosHeaders2,
|
|
17917
|
+
HttpStatusCode: HttpStatusCode2,
|
|
17918
|
+
formToJSON,
|
|
17919
|
+
getAdapter,
|
|
17920
|
+
mergeConfig: mergeConfig2
|
|
17921
|
+
} = axios_default;
|
|
15080
17922
|
|
|
15081
17923
|
// src/api-client.ts
|
|
15082
17924
|
var ApiClient = class {
|
|
@@ -15087,7 +17929,6 @@ var ApiClient = class {
|
|
|
15087
17929
|
* @param headers - Optional headers to include with every request
|
|
15088
17930
|
*/
|
|
15089
17931
|
constructor(baseUrl, headers = {}) {
|
|
15090
|
-
this.baseUrl = baseUrl;
|
|
15091
17932
|
this.headers = headers;
|
|
15092
17933
|
this.axiosInstance = axios_default.create({
|
|
15093
17934
|
baseURL: baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`
|
|
@@ -15159,13 +18000,18 @@ var ApiClient = class {
|
|
|
15159
18000
|
|
|
15160
18001
|
// src/server.ts
|
|
15161
18002
|
var OpenAPIServer = class {
|
|
18003
|
+
server;
|
|
18004
|
+
toolsManager;
|
|
18005
|
+
apiClient;
|
|
15162
18006
|
constructor(config) {
|
|
15163
|
-
this.config = config;
|
|
15164
18007
|
this.server = new Server(
|
|
15165
18008
|
{ name: config.name, version: config.version },
|
|
15166
18009
|
{
|
|
15167
18010
|
capabilities: {
|
|
15168
|
-
tools: {
|
|
18011
|
+
tools: {
|
|
18012
|
+
list: true,
|
|
18013
|
+
execute: true
|
|
18014
|
+
}
|
|
15169
18015
|
}
|
|
15170
18016
|
}
|
|
15171
18017
|
);
|
|
@@ -15173,9 +18019,6 @@ var OpenAPIServer = class {
|
|
|
15173
18019
|
this.apiClient = new ApiClient(config.apiBaseUrl, config.headers);
|
|
15174
18020
|
this.initializeHandlers();
|
|
15175
18021
|
}
|
|
15176
|
-
server;
|
|
15177
|
-
toolsManager;
|
|
15178
|
-
apiClient;
|
|
15179
18022
|
/**
|
|
15180
18023
|
* Initialize request handlers
|
|
15181
18024
|
*/
|
|
@@ -15189,7 +18032,7 @@ var OpenAPIServer = class {
|
|
|
15189
18032
|
const { id, name, arguments: params } = request.params;
|
|
15190
18033
|
console.error("Received request:", request.params);
|
|
15191
18034
|
console.error("Using parameters from arguments:", params);
|
|
15192
|
-
const idOrName = id
|
|
18035
|
+
const idOrName = typeof id === "string" ? id : typeof name === "string" ? name : "";
|
|
15193
18036
|
if (!idOrName) {
|
|
15194
18037
|
throw new Error("Tool ID or name is required");
|
|
15195
18038
|
}
|
|
@@ -15282,8 +18125,8 @@ var UI = class {
|
|
|
15282
18125
|
shouldApplyLayoutDSL(...args) {
|
|
15283
18126
|
return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]);
|
|
15284
18127
|
}
|
|
15285
|
-
applyLayoutDSL(
|
|
15286
|
-
const rows =
|
|
18128
|
+
applyLayoutDSL(str2) {
|
|
18129
|
+
const rows = str2.split("\n").map((row) => row.split(" "));
|
|
15287
18130
|
let leftColumnWidth = 0;
|
|
15288
18131
|
rows.forEach((columns) => {
|
|
15289
18132
|
if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
|
|
@@ -15307,8 +18150,8 @@ var UI = class {
|
|
|
15307
18150
|
padding: this.measurePadding(text)
|
|
15308
18151
|
};
|
|
15309
18152
|
}
|
|
15310
|
-
measurePadding(
|
|
15311
|
-
const noAnsi = mixin.stripAnsi(
|
|
18153
|
+
measurePadding(str2) {
|
|
18154
|
+
const noAnsi = mixin.stripAnsi(str2);
|
|
15312
18155
|
return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
|
|
15313
18156
|
}
|
|
15314
18157
|
toString() {
|
|
@@ -15320,7 +18163,7 @@ var UI = class {
|
|
|
15320
18163
|
}
|
|
15321
18164
|
rowToString(row, lines) {
|
|
15322
18165
|
this.rasterize(row).forEach((rrow, r) => {
|
|
15323
|
-
let
|
|
18166
|
+
let str2 = "";
|
|
15324
18167
|
rrow.forEach((col, c) => {
|
|
15325
18168
|
const { width } = row[c];
|
|
15326
18169
|
const wrapWidth = this.negatePadding(row[c]);
|
|
@@ -15337,20 +18180,20 @@ var UI = class {
|
|
|
15337
18180
|
}
|
|
15338
18181
|
const padding = row[c].padding || [0, 0, 0, 0];
|
|
15339
18182
|
if (padding[left]) {
|
|
15340
|
-
|
|
18183
|
+
str2 += " ".repeat(padding[left]);
|
|
15341
18184
|
}
|
|
15342
|
-
|
|
15343
|
-
|
|
15344
|
-
|
|
18185
|
+
str2 += addBorder(row[c], ts, "| ");
|
|
18186
|
+
str2 += ts;
|
|
18187
|
+
str2 += addBorder(row[c], ts, " |");
|
|
15345
18188
|
if (padding[right]) {
|
|
15346
|
-
|
|
18189
|
+
str2 += " ".repeat(padding[right]);
|
|
15347
18190
|
}
|
|
15348
18191
|
if (r === 0 && lines.length > 0) {
|
|
15349
|
-
|
|
18192
|
+
str2 = this.renderInline(str2, lines[lines.length - 1]);
|
|
15350
18193
|
}
|
|
15351
18194
|
});
|
|
15352
18195
|
lines.push({
|
|
15353
|
-
text:
|
|
18196
|
+
text: str2.replace(/ +$/, ""),
|
|
15354
18197
|
span: row.span
|
|
15355
18198
|
});
|
|
15356
18199
|
});
|
|
@@ -15395,7 +18238,7 @@ var UI = class {
|
|
|
15395
18238
|
wrapped.unshift(...new Array(col.padding[top] || 0).fill(""));
|
|
15396
18239
|
wrapped.push(...new Array(col.padding[bottom] || 0).fill(""));
|
|
15397
18240
|
}
|
|
15398
|
-
wrapped.forEach((
|
|
18241
|
+
wrapped.forEach((str2, r) => {
|
|
15399
18242
|
if (!rrows[r]) {
|
|
15400
18243
|
rrows.push([]);
|
|
15401
18244
|
}
|
|
@@ -15405,7 +18248,7 @@ var UI = class {
|
|
|
15405
18248
|
rrow.push("");
|
|
15406
18249
|
}
|
|
15407
18250
|
}
|
|
15408
|
-
rrow.push(
|
|
18251
|
+
rrow.push(str2);
|
|
15409
18252
|
});
|
|
15410
18253
|
});
|
|
15411
18254
|
return rrows;
|
|
@@ -15471,21 +18314,21 @@ function getWindowWidth() {
|
|
|
15471
18314
|
}
|
|
15472
18315
|
return 80;
|
|
15473
18316
|
}
|
|
15474
|
-
function alignRight(
|
|
15475
|
-
|
|
15476
|
-
const strWidth = mixin.stringWidth(
|
|
18317
|
+
function alignRight(str2, width) {
|
|
18318
|
+
str2 = str2.trim();
|
|
18319
|
+
const strWidth = mixin.stringWidth(str2);
|
|
15477
18320
|
if (strWidth < width) {
|
|
15478
|
-
return " ".repeat(width - strWidth) +
|
|
18321
|
+
return " ".repeat(width - strWidth) + str2;
|
|
15479
18322
|
}
|
|
15480
|
-
return
|
|
18323
|
+
return str2;
|
|
15481
18324
|
}
|
|
15482
|
-
function alignCenter(
|
|
15483
|
-
|
|
15484
|
-
const strWidth = mixin.stringWidth(
|
|
18325
|
+
function alignCenter(str2, width) {
|
|
18326
|
+
str2 = str2.trim();
|
|
18327
|
+
const strWidth = mixin.stringWidth(str2);
|
|
15485
18328
|
if (strWidth >= width) {
|
|
15486
|
-
return
|
|
18329
|
+
return str2;
|
|
15487
18330
|
}
|
|
15488
|
-
return " ".repeat(width - strWidth >> 1) +
|
|
18331
|
+
return " ".repeat(width - strWidth >> 1) + str2;
|
|
15489
18332
|
}
|
|
15490
18333
|
var mixin;
|
|
15491
18334
|
function cliui(opts, _mixin) {
|
|
@@ -15498,18 +18341,18 @@ function cliui(opts, _mixin) {
|
|
|
15498
18341
|
|
|
15499
18342
|
// node_modules/cliui/build/lib/string-utils.js
|
|
15500
18343
|
var ansi = new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
|
|
15501
|
-
function stripAnsi(
|
|
15502
|
-
return
|
|
18344
|
+
function stripAnsi(str2) {
|
|
18345
|
+
return str2.replace(ansi, "");
|
|
15503
18346
|
}
|
|
15504
|
-
function wrap(
|
|
15505
|
-
const [start, end] =
|
|
15506
|
-
|
|
18347
|
+
function wrap(str2, width) {
|
|
18348
|
+
const [start, end] = str2.match(ansi) || ["", ""];
|
|
18349
|
+
str2 = stripAnsi(str2);
|
|
15507
18350
|
let wrapped = "";
|
|
15508
|
-
for (let i = 0; i <
|
|
18351
|
+
for (let i = 0; i < str2.length; i++) {
|
|
15509
18352
|
if (i !== 0 && i % width === 0) {
|
|
15510
18353
|
wrapped += "\n";
|
|
15511
18354
|
}
|
|
15512
|
-
wrapped +=
|
|
18355
|
+
wrapped += str2.charAt(i);
|
|
15513
18356
|
}
|
|
15514
18357
|
if (start && end) {
|
|
15515
18358
|
wrapped = `${start}${wrapped}${end}`;
|
|
@@ -15520,8 +18363,8 @@ function wrap(str, width) {
|
|
|
15520
18363
|
// node_modules/cliui/index.mjs
|
|
15521
18364
|
function ui(opts) {
|
|
15522
18365
|
return cliui(opts, {
|
|
15523
|
-
stringWidth: (
|
|
15524
|
-
return [...
|
|
18366
|
+
stringWidth: (str2) => {
|
|
18367
|
+
return [...str2].length;
|
|
15525
18368
|
},
|
|
15526
18369
|
stripAnsi,
|
|
15527
18370
|
wrap
|
|
@@ -15555,19 +18398,19 @@ import { format } from "util";
|
|
|
15555
18398
|
import { normalize, resolve as resolve2 } from "path";
|
|
15556
18399
|
|
|
15557
18400
|
// node_modules/yargs-parser/build/lib/string-utils.js
|
|
15558
|
-
function camelCase(
|
|
15559
|
-
const isCamelCase =
|
|
18401
|
+
function camelCase(str2) {
|
|
18402
|
+
const isCamelCase = str2 !== str2.toLowerCase() && str2 !== str2.toUpperCase();
|
|
15560
18403
|
if (!isCamelCase) {
|
|
15561
|
-
|
|
18404
|
+
str2 = str2.toLowerCase();
|
|
15562
18405
|
}
|
|
15563
|
-
if (
|
|
15564
|
-
return
|
|
18406
|
+
if (str2.indexOf("-") === -1 && str2.indexOf("_") === -1) {
|
|
18407
|
+
return str2;
|
|
15565
18408
|
} else {
|
|
15566
18409
|
let camelcase = "";
|
|
15567
18410
|
let nextChrUpper = false;
|
|
15568
|
-
const leadingHyphens =
|
|
15569
|
-
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i <
|
|
15570
|
-
let chr =
|
|
18411
|
+
const leadingHyphens = str2.match(/^-+/);
|
|
18412
|
+
for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str2.length; i++) {
|
|
18413
|
+
let chr = str2.charAt(i);
|
|
15571
18414
|
if (nextChrUpper) {
|
|
15572
18415
|
nextChrUpper = false;
|
|
15573
18416
|
chr = chr.toUpperCase();
|
|
@@ -15581,13 +18424,13 @@ function camelCase(str) {
|
|
|
15581
18424
|
return camelcase;
|
|
15582
18425
|
}
|
|
15583
18426
|
}
|
|
15584
|
-
function decamelize(
|
|
15585
|
-
const lowercase =
|
|
18427
|
+
function decamelize(str2, joinString) {
|
|
18428
|
+
const lowercase = str2.toLowerCase();
|
|
15586
18429
|
joinString = joinString || "-";
|
|
15587
18430
|
let notCamelcase = "";
|
|
15588
|
-
for (let i = 0; i <
|
|
18431
|
+
for (let i = 0; i < str2.length; i++) {
|
|
15589
18432
|
const chrLower = lowercase.charAt(i);
|
|
15590
|
-
const chrString =
|
|
18433
|
+
const chrString = str2.charAt(i);
|
|
15591
18434
|
if (chrLower !== chrString && i > 0) {
|
|
15592
18435
|
notCamelcase += `${joinString}${lowercase.charAt(i)}`;
|
|
15593
18436
|
} else {
|
|
@@ -16397,26 +19240,26 @@ var YargsParser = class {
|
|
|
16397
19240
|
return defaultForType(guessType2(key));
|
|
16398
19241
|
}
|
|
16399
19242
|
}
|
|
16400
|
-
function defaultForType(
|
|
19243
|
+
function defaultForType(type2) {
|
|
16401
19244
|
const def = {
|
|
16402
19245
|
[DefaultValuesForTypeKey.BOOLEAN]: true,
|
|
16403
19246
|
[DefaultValuesForTypeKey.STRING]: "",
|
|
16404
19247
|
[DefaultValuesForTypeKey.NUMBER]: void 0,
|
|
16405
19248
|
[DefaultValuesForTypeKey.ARRAY]: []
|
|
16406
19249
|
};
|
|
16407
|
-
return def[
|
|
19250
|
+
return def[type2];
|
|
16408
19251
|
}
|
|
16409
19252
|
function guessType2(key) {
|
|
16410
|
-
let
|
|
19253
|
+
let type2 = DefaultValuesForTypeKey.BOOLEAN;
|
|
16411
19254
|
if (checkAllAliases(key, flags.strings))
|
|
16412
|
-
|
|
19255
|
+
type2 = DefaultValuesForTypeKey.STRING;
|
|
16413
19256
|
else if (checkAllAliases(key, flags.numbers))
|
|
16414
|
-
|
|
19257
|
+
type2 = DefaultValuesForTypeKey.NUMBER;
|
|
16415
19258
|
else if (checkAllAliases(key, flags.bools))
|
|
16416
|
-
|
|
19259
|
+
type2 = DefaultValuesForTypeKey.BOOLEAN;
|
|
16417
19260
|
else if (checkAllAliases(key, flags.arrays))
|
|
16418
|
-
|
|
16419
|
-
return
|
|
19261
|
+
type2 = DefaultValuesForTypeKey.ARRAY;
|
|
19262
|
+
return type2;
|
|
16420
19263
|
}
|
|
16421
19264
|
function isUndefined2(num) {
|
|
16422
19265
|
return num === void 0;
|
|
@@ -16604,7 +19447,7 @@ var Y18N = class {
|
|
|
16604
19447
|
if (typeof arguments[0] !== "string") {
|
|
16605
19448
|
return this._taggedLiteral(arguments[0], ...arguments);
|
|
16606
19449
|
}
|
|
16607
|
-
const
|
|
19450
|
+
const str2 = args.shift();
|
|
16608
19451
|
let cb = function() {
|
|
16609
19452
|
};
|
|
16610
19453
|
if (typeof args[args.length - 1] === "function")
|
|
@@ -16613,8 +19456,8 @@ var Y18N = class {
|
|
|
16613
19456
|
};
|
|
16614
19457
|
if (!this.cache[this.locale])
|
|
16615
19458
|
this._readLocaleFile();
|
|
16616
|
-
if (!this.cache[this.locale][
|
|
16617
|
-
this.cache[this.locale][
|
|
19459
|
+
if (!this.cache[this.locale][str2] && this.updateFiles) {
|
|
19460
|
+
this.cache[this.locale][str2] = str2;
|
|
16618
19461
|
this._enqueueWrite({
|
|
16619
19462
|
directory: this.directory,
|
|
16620
19463
|
locale: this.locale,
|
|
@@ -16623,7 +19466,7 @@ var Y18N = class {
|
|
|
16623
19466
|
} else {
|
|
16624
19467
|
cb();
|
|
16625
19468
|
}
|
|
16626
|
-
return shim.format.apply(shim.format, [this.cache[this.locale][
|
|
19469
|
+
return shim.format.apply(shim.format, [this.cache[this.locale][str2] || str2].concat(args));
|
|
16627
19470
|
}
|
|
16628
19471
|
__n() {
|
|
16629
19472
|
const args = Array.prototype.slice.call(arguments);
|
|
@@ -16636,10 +19479,10 @@ var Y18N = class {
|
|
|
16636
19479
|
cb = args.pop();
|
|
16637
19480
|
if (!this.cache[this.locale])
|
|
16638
19481
|
this._readLocaleFile();
|
|
16639
|
-
let
|
|
19482
|
+
let str2 = quantity === 1 ? singular : plural;
|
|
16640
19483
|
if (this.cache[this.locale][singular]) {
|
|
16641
19484
|
const entry = this.cache[this.locale][singular];
|
|
16642
|
-
|
|
19485
|
+
str2 = entry[quantity === 1 ? "one" : "other"];
|
|
16643
19486
|
}
|
|
16644
19487
|
if (!this.cache[this.locale][singular] && this.updateFiles) {
|
|
16645
19488
|
this.cache[this.locale][singular] = {
|
|
@@ -16654,8 +19497,8 @@ var Y18N = class {
|
|
|
16654
19497
|
} else {
|
|
16655
19498
|
cb();
|
|
16656
19499
|
}
|
|
16657
|
-
const values = [
|
|
16658
|
-
if (~
|
|
19500
|
+
const values = [str2];
|
|
19501
|
+
if (~str2.indexOf("%d"))
|
|
16659
19502
|
values.push(quantity);
|
|
16660
19503
|
return shim.format.apply(shim.format, values.concat(args));
|
|
16661
19504
|
}
|
|
@@ -16675,15 +19518,15 @@ var Y18N = class {
|
|
|
16675
19518
|
}
|
|
16676
19519
|
}
|
|
16677
19520
|
_taggedLiteral(parts, ...args) {
|
|
16678
|
-
let
|
|
19521
|
+
let str2 = "";
|
|
16679
19522
|
parts.forEach(function(part, i) {
|
|
16680
19523
|
const arg = args[i + 1];
|
|
16681
|
-
|
|
19524
|
+
str2 += part;
|
|
16682
19525
|
if (typeof arg !== "undefined") {
|
|
16683
|
-
|
|
19526
|
+
str2 += "%s";
|
|
16684
19527
|
}
|
|
16685
19528
|
});
|
|
16686
|
-
return this.__.apply(this, [
|
|
19529
|
+
return this.__.apply(this, [str2].concat([].slice.call(args, 1)));
|
|
16687
19530
|
}
|
|
16688
19531
|
_enqueueWrite(work) {
|
|
16689
19532
|
this.writeQueue.push(work);
|
|
@@ -16792,7 +19635,7 @@ var esm_default = {
|
|
|
16792
19635
|
process: {
|
|
16793
19636
|
argv: () => process.argv,
|
|
16794
19637
|
cwd: process.cwd,
|
|
16795
|
-
emitWarning: (warning,
|
|
19638
|
+
emitWarning: (warning, type2) => process.emitWarning(warning, type2),
|
|
16796
19639
|
execPath: () => process.execPath,
|
|
16797
19640
|
exit: process.exit,
|
|
16798
19641
|
nextTick: process.nextTick,
|
|
@@ -16805,8 +19648,8 @@ var esm_default = {
|
|
|
16805
19648
|
requireDirectory: () => {
|
|
16806
19649
|
throw new YError(REQUIRE_DIRECTORY_ERROR);
|
|
16807
19650
|
},
|
|
16808
|
-
stringWidth: (
|
|
16809
|
-
return [...
|
|
19651
|
+
stringWidth: (str2) => {
|
|
19652
|
+
return [...str2].length;
|
|
16810
19653
|
},
|
|
16811
19654
|
y18n: y18n_default({
|
|
16812
19655
|
directory: resolve4(__dirname, "../../../locales"),
|
|
@@ -16890,7 +19733,7 @@ function argsert(arg1, arg2, arg3) {
|
|
|
16890
19733
|
parsed.demanded.forEach((demanded) => {
|
|
16891
19734
|
const arg = args.shift();
|
|
16892
19735
|
const observedType = guessType(arg);
|
|
16893
|
-
const matchingTypes = demanded.cmd.filter((
|
|
19736
|
+
const matchingTypes = demanded.cmd.filter((type2) => type2 === observedType || type2 === "*");
|
|
16894
19737
|
if (matchingTypes.length === 0)
|
|
16895
19738
|
argumentTypeError(observedType, demanded.cmd, position);
|
|
16896
19739
|
position += 1;
|
|
@@ -16900,7 +19743,7 @@ function argsert(arg1, arg2, arg3) {
|
|
|
16900
19743
|
return;
|
|
16901
19744
|
const arg = args.shift();
|
|
16902
19745
|
const observedType = guessType(arg);
|
|
16903
|
-
const matchingTypes = optional.cmd.filter((
|
|
19746
|
+
const matchingTypes = optional.cmd.filter((type2) => type2 === observedType || type2 === "*");
|
|
16904
19747
|
if (matchingTypes.length === 0)
|
|
16905
19748
|
argumentTypeError(observedType, optional.cmd, position);
|
|
16906
19749
|
position += 1;
|
|
@@ -17446,7 +20289,7 @@ function setBlocking(blocking) {
|
|
|
17446
20289
|
}
|
|
17447
20290
|
|
|
17448
20291
|
// node_modules/yargs/build/lib/usage.js
|
|
17449
|
-
function
|
|
20292
|
+
function isBoolean3(fail) {
|
|
17450
20293
|
return typeof fail === "boolean";
|
|
17451
20294
|
}
|
|
17452
20295
|
function usage(yargs, shim3) {
|
|
@@ -17474,7 +20317,7 @@ function usage(yargs, shim3) {
|
|
|
17474
20317
|
if (fails.length) {
|
|
17475
20318
|
for (let i = fails.length - 1; i >= 0; --i) {
|
|
17476
20319
|
const fail2 = fails[i];
|
|
17477
|
-
if (
|
|
20320
|
+
if (isBoolean3(fail2)) {
|
|
17478
20321
|
if (err)
|
|
17479
20322
|
throw err;
|
|
17480
20323
|
else if (msg)
|
|
@@ -17583,7 +20426,7 @@ function usage(yargs, shim3) {
|
|
|
17583
20426
|
return wrap2;
|
|
17584
20427
|
};
|
|
17585
20428
|
const deferY18nLookupPrefix = "__yargsString__:";
|
|
17586
|
-
self2.deferY18nLookup = (
|
|
20429
|
+
self2.deferY18nLookup = (str2) => deferY18nLookupPrefix + str2;
|
|
17587
20430
|
self2.help = function help() {
|
|
17588
20431
|
if (cachedHelpMessage)
|
|
17589
20432
|
return cachedHelpMessage;
|
|
@@ -17717,25 +20560,25 @@ function usage(yargs, shim3) {
|
|
|
17717
20560
|
normalizedKeys.forEach((key) => {
|
|
17718
20561
|
const kswitch = switches[key];
|
|
17719
20562
|
let desc = descriptions[key] || "";
|
|
17720
|
-
let
|
|
20563
|
+
let type2 = null;
|
|
17721
20564
|
if (desc.includes(deferY18nLookupPrefix))
|
|
17722
20565
|
desc = __(desc.substring(deferY18nLookupPrefix.length));
|
|
17723
20566
|
if (options.boolean.includes(key))
|
|
17724
|
-
|
|
20567
|
+
type2 = `[${__("boolean")}]`;
|
|
17725
20568
|
if (options.count.includes(key))
|
|
17726
|
-
|
|
20569
|
+
type2 = `[${__("count")}]`;
|
|
17727
20570
|
if (options.string.includes(key))
|
|
17728
|
-
|
|
20571
|
+
type2 = `[${__("string")}]`;
|
|
17729
20572
|
if (options.normalize.includes(key))
|
|
17730
|
-
|
|
20573
|
+
type2 = `[${__("string")}]`;
|
|
17731
20574
|
if (options.array.includes(key))
|
|
17732
|
-
|
|
20575
|
+
type2 = `[${__("array")}]`;
|
|
17733
20576
|
if (options.number.includes(key))
|
|
17734
|
-
|
|
20577
|
+
type2 = `[${__("number")}]`;
|
|
17735
20578
|
const deprecatedExtra = (deprecated) => typeof deprecated === "string" ? `[${__("deprecated: %s", deprecated)}]` : `[${__("deprecated")}]`;
|
|
17736
20579
|
const extra = [
|
|
17737
20580
|
key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null,
|
|
17738
|
-
|
|
20581
|
+
type2,
|
|
17739
20582
|
key in demandedOptions ? `[${__("required")}]` : null,
|
|
17740
20583
|
options.choices && options.choices[key] ? `[${__("choices:")} ${self2.stringifiedValues(options.choices[key])}]` : null,
|
|
17741
20584
|
defaultString(options.default[key], options.defaultDescription[key])
|
|
@@ -18574,12 +21417,12 @@ function getPathToDefaultConfig(cwd, pathToExtend) {
|
|
|
18574
21417
|
}
|
|
18575
21418
|
function mergeDeep(config1, config2) {
|
|
18576
21419
|
const target = {};
|
|
18577
|
-
function
|
|
21420
|
+
function isObject3(obj) {
|
|
18578
21421
|
return obj && typeof obj === "object" && !Array.isArray(obj);
|
|
18579
21422
|
}
|
|
18580
21423
|
Object.assign(target, config1);
|
|
18581
21424
|
for (const key of Object.keys(config2)) {
|
|
18582
|
-
if (
|
|
21425
|
+
if (isObject3(config2[key]) && isObject3(target[key])) {
|
|
18583
21426
|
target[key] = mergeDeep(config1[key], config2[key]);
|
|
18584
21427
|
} else {
|
|
18585
21428
|
target[key] = config2[key];
|
|
@@ -19594,9 +22437,9 @@ var YargsInstance = class {
|
|
|
19594
22437
|
});
|
|
19595
22438
|
delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
|
|
19596
22439
|
}
|
|
19597
|
-
[kEmitWarning](warning,
|
|
22440
|
+
[kEmitWarning](warning, type2, deduplicationId) {
|
|
19598
22441
|
if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
|
|
19599
|
-
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning,
|
|
22442
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type2);
|
|
19600
22443
|
__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
|
|
19601
22444
|
}
|
|
19602
22445
|
}
|
|
@@ -19688,24 +22531,24 @@ var YargsInstance = class {
|
|
|
19688
22531
|
__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
|
|
19689
22532
|
return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
|
|
19690
22533
|
}
|
|
19691
|
-
[kPopulateParserHintArray](
|
|
22534
|
+
[kPopulateParserHintArray](type2, keys) {
|
|
19692
22535
|
keys = [].concat(keys);
|
|
19693
22536
|
keys.forEach((key) => {
|
|
19694
22537
|
key = this[kSanitizeKey](key);
|
|
19695
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f")[
|
|
22538
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2].push(key);
|
|
19696
22539
|
});
|
|
19697
22540
|
}
|
|
19698
|
-
[kPopulateParserHintSingleValueDictionary](builder,
|
|
19699
|
-
this[kPopulateParserHintDictionary](builder,
|
|
19700
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f")[
|
|
22541
|
+
[kPopulateParserHintSingleValueDictionary](builder, type2, key, value) {
|
|
22542
|
+
this[kPopulateParserHintDictionary](builder, type2, key, value, (type3, key2, value2) => {
|
|
22543
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] = value2;
|
|
19701
22544
|
});
|
|
19702
22545
|
}
|
|
19703
|
-
[kPopulateParserHintArrayDictionary](builder,
|
|
19704
|
-
this[kPopulateParserHintDictionary](builder,
|
|
19705
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f")[
|
|
22546
|
+
[kPopulateParserHintArrayDictionary](builder, type2, key, value) {
|
|
22547
|
+
this[kPopulateParserHintDictionary](builder, type2, key, value, (type3, key2, value2) => {
|
|
22548
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] || []).concat(value2);
|
|
19706
22549
|
});
|
|
19707
22550
|
}
|
|
19708
|
-
[kPopulateParserHintDictionary](builder,
|
|
22551
|
+
[kPopulateParserHintDictionary](builder, type2, key, value, singleKeyHandler) {
|
|
19709
22552
|
if (Array.isArray(key)) {
|
|
19710
22553
|
key.forEach((k) => {
|
|
19711
22554
|
builder(k, value);
|
|
@@ -19715,7 +22558,7 @@ var YargsInstance = class {
|
|
|
19715
22558
|
builder(k, key[k]);
|
|
19716
22559
|
}
|
|
19717
22560
|
} else {
|
|
19718
|
-
singleKeyHandler(
|
|
22561
|
+
singleKeyHandler(type2, this[kSanitizeKey](key), value);
|
|
19719
22562
|
}
|
|
19720
22563
|
}
|
|
19721
22564
|
[kSanitizeKey](key) {
|
|
@@ -19723,8 +22566,8 @@ var YargsInstance = class {
|
|
|
19723
22566
|
return "___proto___";
|
|
19724
22567
|
return key;
|
|
19725
22568
|
}
|
|
19726
|
-
[kSetKey](key,
|
|
19727
|
-
this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key,
|
|
22569
|
+
[kSetKey](key, set2) {
|
|
22570
|
+
this[kPopulateParserHintSingleValueDictionary](this[kSetKey].bind(this), "key", key, set2);
|
|
19728
22571
|
return this;
|
|
19729
22572
|
}
|
|
19730
22573
|
[kUnfreeze]() {
|
|
@@ -20098,7 +22941,22 @@ function parseHeaders(headerStr) {
|
|
|
20098
22941
|
return headers;
|
|
20099
22942
|
}
|
|
20100
22943
|
function loadConfig() {
|
|
20101
|
-
const argv = yargs_default(hideBin(process.argv)).option("
|
|
22944
|
+
const argv = yargs_default(hideBin(process.argv)).option("transport", {
|
|
22945
|
+
alias: "t",
|
|
22946
|
+
type: "string",
|
|
22947
|
+
choices: ["stdio", "http"],
|
|
22948
|
+
description: "Transport type to use (stdio or http)"
|
|
22949
|
+
}).option("port", {
|
|
22950
|
+
alias: "p",
|
|
22951
|
+
type: "number",
|
|
22952
|
+
description: "HTTP port for HTTP transport"
|
|
22953
|
+
}).option("host", {
|
|
22954
|
+
type: "string",
|
|
22955
|
+
description: "HTTP host for HTTP transport"
|
|
22956
|
+
}).option("path", {
|
|
22957
|
+
type: "string",
|
|
22958
|
+
description: "HTTP endpoint path for HTTP transport"
|
|
22959
|
+
}).option("api-base-url", {
|
|
20102
22960
|
alias: "u",
|
|
20103
22961
|
type: "string",
|
|
20104
22962
|
description: "Base URL for the API"
|
|
@@ -20118,7 +22976,16 @@ function loadConfig() {
|
|
|
20118
22976
|
alias: "v",
|
|
20119
22977
|
type: "string",
|
|
20120
22978
|
description: "Server version"
|
|
20121
|
-
}).help().
|
|
22979
|
+
}).help().parseSync();
|
|
22980
|
+
let transportType;
|
|
22981
|
+
if (argv.transport === "http" || process.env.TRANSPORT_TYPE === "http") {
|
|
22982
|
+
transportType = "http";
|
|
22983
|
+
} else {
|
|
22984
|
+
transportType = "stdio";
|
|
22985
|
+
}
|
|
22986
|
+
const httpPort = argv.port ?? (process.env.HTTP_PORT ? parseInt(process.env.HTTP_PORT, 10) : 3e3);
|
|
22987
|
+
const httpHost = argv.host || process.env.HTTP_HOST || "127.0.0.1";
|
|
22988
|
+
const endpointPath = argv.path || process.env.ENDPOINT_PATH || "/mcp";
|
|
20122
22989
|
const apiBaseUrl = argv["api-base-url"] || process.env.API_BASE_URL;
|
|
20123
22990
|
const openApiSpec = argv["openapi-spec"] || process.env.OPENAPI_SPEC_PATH;
|
|
20124
22991
|
if (!apiBaseUrl) {
|
|
@@ -20133,18 +23000,582 @@ function loadConfig() {
|
|
|
20133
23000
|
version: argv.version || process.env.SERVER_VERSION || "1.0.0",
|
|
20134
23001
|
apiBaseUrl,
|
|
20135
23002
|
openApiSpec,
|
|
20136
|
-
headers
|
|
23003
|
+
headers,
|
|
23004
|
+
transportType,
|
|
23005
|
+
httpPort,
|
|
23006
|
+
httpHost,
|
|
23007
|
+
endpointPath
|
|
20137
23008
|
};
|
|
20138
23009
|
}
|
|
20139
23010
|
|
|
23011
|
+
// src/transport/StreamableHttpServerTransport.ts
|
|
23012
|
+
import {
|
|
23013
|
+
isInitializeRequest,
|
|
23014
|
+
isJSONRPCRequest,
|
|
23015
|
+
isJSONRPCResponse
|
|
23016
|
+
} from "@modelcontextprotocol/sdk/types.js";
|
|
23017
|
+
import * as http2 from "http";
|
|
23018
|
+
import { randomUUID } from "crypto";
|
|
23019
|
+
var StreamableHttpServerTransport = class {
|
|
23020
|
+
// Maps request IDs to session IDs
|
|
23021
|
+
/**
|
|
23022
|
+
* Initialize a new StreamableHttpServerTransport
|
|
23023
|
+
*
|
|
23024
|
+
* @param port HTTP port to listen on
|
|
23025
|
+
* @param host Host to bind to (default: 127.0.0.1)
|
|
23026
|
+
* @param endpointPath Endpoint path (default: /mcp)
|
|
23027
|
+
*/
|
|
23028
|
+
constructor(port, host = "127.0.0.1", endpointPath = "/mcp") {
|
|
23029
|
+
this.port = port;
|
|
23030
|
+
this.host = host;
|
|
23031
|
+
this.endpointPath = endpointPath;
|
|
23032
|
+
this.server = http2.createServer(this.handleRequest.bind(this));
|
|
23033
|
+
}
|
|
23034
|
+
server;
|
|
23035
|
+
sessions = /* @__PURE__ */ new Map();
|
|
23036
|
+
started = false;
|
|
23037
|
+
maxBodySize = 4 * 1024 * 1024;
|
|
23038
|
+
// 4MB max request size
|
|
23039
|
+
requestSessionMap = /* @__PURE__ */ new Map();
|
|
23040
|
+
/**
|
|
23041
|
+
* Callback when message is received
|
|
23042
|
+
*/
|
|
23043
|
+
onmessage;
|
|
23044
|
+
/**
|
|
23045
|
+
* Callback when error occurs
|
|
23046
|
+
*/
|
|
23047
|
+
onerror;
|
|
23048
|
+
/**
|
|
23049
|
+
* Callback when transport closes
|
|
23050
|
+
*/
|
|
23051
|
+
onclose;
|
|
23052
|
+
/**
|
|
23053
|
+
* Start the transport
|
|
23054
|
+
*/
|
|
23055
|
+
async start() {
|
|
23056
|
+
if (this.started) {
|
|
23057
|
+
throw new Error("Transport already started");
|
|
23058
|
+
}
|
|
23059
|
+
return new Promise((resolve5, reject) => {
|
|
23060
|
+
this.server.listen(this.port, this.host, () => {
|
|
23061
|
+
this.started = true;
|
|
23062
|
+
console.error(
|
|
23063
|
+
`Streamable HTTP transport listening on http://${this.host}:${this.port}${this.endpointPath}`
|
|
23064
|
+
);
|
|
23065
|
+
resolve5();
|
|
23066
|
+
});
|
|
23067
|
+
this.server.on("error", (err) => {
|
|
23068
|
+
reject(err);
|
|
23069
|
+
if (this.onerror) {
|
|
23070
|
+
this.onerror(err);
|
|
23071
|
+
}
|
|
23072
|
+
});
|
|
23073
|
+
});
|
|
23074
|
+
}
|
|
23075
|
+
/**
|
|
23076
|
+
* Close the transport
|
|
23077
|
+
*/
|
|
23078
|
+
async close() {
|
|
23079
|
+
for (const session of this.sessions.values()) {
|
|
23080
|
+
for (const response of session.activeResponses) {
|
|
23081
|
+
try {
|
|
23082
|
+
response.end();
|
|
23083
|
+
} catch (err) {
|
|
23084
|
+
}
|
|
23085
|
+
}
|
|
23086
|
+
}
|
|
23087
|
+
this.sessions.clear();
|
|
23088
|
+
return new Promise((resolve5, reject) => {
|
|
23089
|
+
this.server.close((err) => {
|
|
23090
|
+
if (err) {
|
|
23091
|
+
reject(err instanceof Error ? err : new Error(String(err)));
|
|
23092
|
+
} else {
|
|
23093
|
+
this.started = false;
|
|
23094
|
+
if (this.onclose) {
|
|
23095
|
+
this.onclose();
|
|
23096
|
+
}
|
|
23097
|
+
resolve5();
|
|
23098
|
+
}
|
|
23099
|
+
});
|
|
23100
|
+
});
|
|
23101
|
+
}
|
|
23102
|
+
/**
|
|
23103
|
+
* Send message to client(s)
|
|
23104
|
+
*
|
|
23105
|
+
* @param message JSON-RPC message
|
|
23106
|
+
*/
|
|
23107
|
+
async send(message) {
|
|
23108
|
+
console.error(`StreamableHttpServerTransport: Sending message: ${JSON.stringify(message)}`);
|
|
23109
|
+
let targetSessionId;
|
|
23110
|
+
let messageIdForThisResponse = null;
|
|
23111
|
+
if (isJSONRPCResponse(message) && message.id !== null) {
|
|
23112
|
+
messageIdForThisResponse = message.id;
|
|
23113
|
+
targetSessionId = this.requestSessionMap.get(messageIdForThisResponse);
|
|
23114
|
+
console.error(
|
|
23115
|
+
`StreamableHttpServerTransport: Potential target session for response ID ${messageIdForThisResponse}: ${targetSessionId}`
|
|
23116
|
+
);
|
|
23117
|
+
if (targetSessionId && this.initResponseHandlers.has(targetSessionId)) {
|
|
23118
|
+
console.error(
|
|
23119
|
+
`StreamableHttpServerTransport: Session ${targetSessionId} has initResponseHandlers. Invoking them for message ID ${messageIdForThisResponse}.`
|
|
23120
|
+
);
|
|
23121
|
+
const handlers = this.initResponseHandlers.get(targetSessionId);
|
|
23122
|
+
[...handlers].forEach((handler) => handler(message));
|
|
23123
|
+
if (!this.requestSessionMap.has(messageIdForThisResponse)) {
|
|
23124
|
+
console.error(
|
|
23125
|
+
`StreamableHttpServerTransport: Response for ID ${messageIdForThisResponse} was handled by an initResponseHandler (e.g., synchronous POST response for initialize or tools/list).`
|
|
23126
|
+
);
|
|
23127
|
+
return;
|
|
23128
|
+
} else {
|
|
23129
|
+
console.error(
|
|
23130
|
+
`StreamableHttpServerTransport: Response for ID ${messageIdForThisResponse} was NOT exclusively handled by an initResponseHandler or handler did not remove from requestSessionMap. Proceeding to GET stream / broadcast if applicable.`
|
|
23131
|
+
);
|
|
23132
|
+
}
|
|
23133
|
+
}
|
|
23134
|
+
if (this.requestSessionMap.has(messageIdForThisResponse)) {
|
|
23135
|
+
console.error(
|
|
23136
|
+
`StreamableHttpServerTransport: Deleting request ID ${messageIdForThisResponse} from requestSessionMap as it's being processed for GET stream or broadcast.`
|
|
23137
|
+
);
|
|
23138
|
+
this.requestSessionMap.delete(messageIdForThisResponse);
|
|
23139
|
+
}
|
|
23140
|
+
}
|
|
23141
|
+
if (!targetSessionId) {
|
|
23142
|
+
const idForLog = messageIdForThisResponse !== null ? messageIdForThisResponse : isJSONRPCRequest(message) ? message.id : "N/A";
|
|
23143
|
+
console.warn(
|
|
23144
|
+
`StreamableHttpServerTransport: No specific target session for message (ID: ${idForLog}). Broadcasting to all applicable sessions.`
|
|
23145
|
+
);
|
|
23146
|
+
for (const [sid, session2] of this.sessions.entries()) {
|
|
23147
|
+
if (session2.initialized && session2.activeResponses.size > 0) {
|
|
23148
|
+
this.sendMessageToSession(sid, session2, message);
|
|
23149
|
+
}
|
|
23150
|
+
}
|
|
23151
|
+
return;
|
|
23152
|
+
}
|
|
23153
|
+
const session = this.sessions.get(targetSessionId);
|
|
23154
|
+
if (session && session.activeResponses.size > 0) {
|
|
23155
|
+
console.error(
|
|
23156
|
+
`StreamableHttpServerTransport: Sending message (ID: ${messageIdForThisResponse}) to GET stream for session ${targetSessionId} (${session.activeResponses.size} active connections).`
|
|
23157
|
+
);
|
|
23158
|
+
this.sendMessageToSession(targetSessionId, session, message);
|
|
23159
|
+
} else if (targetSessionId) {
|
|
23160
|
+
console.error(
|
|
23161
|
+
`StreamableHttpServerTransport: No active GET connections for session ${targetSessionId} to send message (ID: ${messageIdForThisResponse}). Message might not be delivered if not handled by POST.`
|
|
23162
|
+
);
|
|
23163
|
+
}
|
|
23164
|
+
}
|
|
23165
|
+
/**
|
|
23166
|
+
* Helper method to send a message to a specific session
|
|
23167
|
+
*/
|
|
23168
|
+
sendMessageToSession(sessionId, session, message) {
|
|
23169
|
+
const messageStr = `data: ${JSON.stringify(message)}
|
|
23170
|
+
|
|
23171
|
+
`;
|
|
23172
|
+
for (const response of session.activeResponses) {
|
|
23173
|
+
try {
|
|
23174
|
+
response.write(messageStr);
|
|
23175
|
+
} catch (err) {
|
|
23176
|
+
session.activeResponses.delete(response);
|
|
23177
|
+
if (this.onerror) {
|
|
23178
|
+
this.onerror(new Error(`Failed to write to response: ${err.message}`));
|
|
23179
|
+
}
|
|
23180
|
+
}
|
|
23181
|
+
}
|
|
23182
|
+
}
|
|
23183
|
+
/**
|
|
23184
|
+
* Handle HTTP request
|
|
23185
|
+
*/
|
|
23186
|
+
handleRequest(req, res) {
|
|
23187
|
+
if (req.url !== this.endpointPath) {
|
|
23188
|
+
res.writeHead(404);
|
|
23189
|
+
res.end();
|
|
23190
|
+
return;
|
|
23191
|
+
}
|
|
23192
|
+
this.validateOrigin(req, res);
|
|
23193
|
+
switch (req.method) {
|
|
23194
|
+
case "POST":
|
|
23195
|
+
this.handlePostRequest(req, res);
|
|
23196
|
+
break;
|
|
23197
|
+
case "GET":
|
|
23198
|
+
this.handleGetRequest(req, res);
|
|
23199
|
+
break;
|
|
23200
|
+
case "DELETE":
|
|
23201
|
+
this.handleDeleteRequest(req, res);
|
|
23202
|
+
break;
|
|
23203
|
+
default:
|
|
23204
|
+
res.writeHead(405, { Allow: "POST, GET, DELETE" });
|
|
23205
|
+
res.end(
|
|
23206
|
+
JSON.stringify({
|
|
23207
|
+
jsonrpc: "2.0",
|
|
23208
|
+
error: {
|
|
23209
|
+
code: -32e3,
|
|
23210
|
+
message: "Method not allowed"
|
|
23211
|
+
},
|
|
23212
|
+
id: null
|
|
23213
|
+
})
|
|
23214
|
+
);
|
|
23215
|
+
}
|
|
23216
|
+
}
|
|
23217
|
+
/**
|
|
23218
|
+
* Validate origin header to prevent DNS rebinding attacks
|
|
23219
|
+
*/
|
|
23220
|
+
validateOrigin(req, res) {
|
|
23221
|
+
const origin2 = req.headers.origin;
|
|
23222
|
+
if (!origin2) {
|
|
23223
|
+
return true;
|
|
23224
|
+
}
|
|
23225
|
+
try {
|
|
23226
|
+
const originUrl = new URL(origin2);
|
|
23227
|
+
const isLocalhost = originUrl.hostname === "localhost" || originUrl.hostname === "127.0.0.1";
|
|
23228
|
+
if (!isLocalhost) {
|
|
23229
|
+
res.writeHead(403);
|
|
23230
|
+
res.end(
|
|
23231
|
+
JSON.stringify({
|
|
23232
|
+
jsonrpc: "2.0",
|
|
23233
|
+
error: {
|
|
23234
|
+
code: -32e3,
|
|
23235
|
+
message: "Origin not allowed"
|
|
23236
|
+
},
|
|
23237
|
+
id: null
|
|
23238
|
+
})
|
|
23239
|
+
);
|
|
23240
|
+
return false;
|
|
23241
|
+
}
|
|
23242
|
+
return true;
|
|
23243
|
+
} catch (err) {
|
|
23244
|
+
res.writeHead(400);
|
|
23245
|
+
res.end(
|
|
23246
|
+
JSON.stringify({
|
|
23247
|
+
jsonrpc: "2.0",
|
|
23248
|
+
error: {
|
|
23249
|
+
code: -32e3,
|
|
23250
|
+
message: "Invalid origin"
|
|
23251
|
+
},
|
|
23252
|
+
id: null
|
|
23253
|
+
})
|
|
23254
|
+
);
|
|
23255
|
+
return false;
|
|
23256
|
+
}
|
|
23257
|
+
}
|
|
23258
|
+
/**
|
|
23259
|
+
* Handle POST request
|
|
23260
|
+
*/
|
|
23261
|
+
handlePostRequest(req, res) {
|
|
23262
|
+
const contentType = req.headers["content-type"];
|
|
23263
|
+
if (!contentType || !contentType.includes("application/json")) {
|
|
23264
|
+
res.writeHead(415);
|
|
23265
|
+
res.end(
|
|
23266
|
+
JSON.stringify({
|
|
23267
|
+
jsonrpc: "2.0",
|
|
23268
|
+
error: {
|
|
23269
|
+
code: -32e3,
|
|
23270
|
+
message: "Unsupported Media Type: Content-Type must be application/json"
|
|
23271
|
+
},
|
|
23272
|
+
id: null
|
|
23273
|
+
})
|
|
23274
|
+
);
|
|
23275
|
+
return;
|
|
23276
|
+
}
|
|
23277
|
+
let body = "";
|
|
23278
|
+
let size = 0;
|
|
23279
|
+
req.on("data", (chunk) => {
|
|
23280
|
+
size += chunk.length;
|
|
23281
|
+
if (size > this.maxBodySize) {
|
|
23282
|
+
res.writeHead(413);
|
|
23283
|
+
res.end(
|
|
23284
|
+
JSON.stringify({
|
|
23285
|
+
jsonrpc: "2.0",
|
|
23286
|
+
error: {
|
|
23287
|
+
code: -32e3,
|
|
23288
|
+
message: "Request entity too large"
|
|
23289
|
+
},
|
|
23290
|
+
id: null
|
|
23291
|
+
})
|
|
23292
|
+
);
|
|
23293
|
+
req.destroy();
|
|
23294
|
+
return;
|
|
23295
|
+
}
|
|
23296
|
+
body += chunk.toString();
|
|
23297
|
+
});
|
|
23298
|
+
req.on("end", () => {
|
|
23299
|
+
try {
|
|
23300
|
+
const message = JSON.parse(body);
|
|
23301
|
+
if (isInitializeRequest(message)) {
|
|
23302
|
+
this.handleInitializeRequest(message, req, res);
|
|
23303
|
+
} else if (isJSONRPCRequest(message) && message.method === "tools/list") {
|
|
23304
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
23305
|
+
if (!sessionId || !this.sessions.has(sessionId)) {
|
|
23306
|
+
res.writeHead(400);
|
|
23307
|
+
res.end(
|
|
23308
|
+
JSON.stringify({
|
|
23309
|
+
jsonrpc: "2.0",
|
|
23310
|
+
error: {
|
|
23311
|
+
code: -32e3,
|
|
23312
|
+
message: "Invalid session. A valid Mcp-Session-Id header is required."
|
|
23313
|
+
},
|
|
23314
|
+
id: "id" in message ? message.id : null
|
|
23315
|
+
})
|
|
23316
|
+
);
|
|
23317
|
+
return;
|
|
23318
|
+
}
|
|
23319
|
+
const session = this.sessions.get(sessionId);
|
|
23320
|
+
if (message.id !== void 0 && message.id !== null) {
|
|
23321
|
+
this.requestSessionMap.set(message.id, sessionId);
|
|
23322
|
+
if (!session.pendingRequests) {
|
|
23323
|
+
session.pendingRequests = /* @__PURE__ */ new Set();
|
|
23324
|
+
}
|
|
23325
|
+
session.pendingRequests.add(message.id);
|
|
23326
|
+
}
|
|
23327
|
+
const responseHandler = (responseMessage) => {
|
|
23328
|
+
if (isJSONRPCResponse(responseMessage) && responseMessage.id === message.id) {
|
|
23329
|
+
res.setHeader("Content-Type", "application/json");
|
|
23330
|
+
res.writeHead(200);
|
|
23331
|
+
res.end(JSON.stringify(responseMessage));
|
|
23332
|
+
this.removeInitResponseHandler(sessionId, responseHandler);
|
|
23333
|
+
if (message.id !== void 0 && message.id !== null) {
|
|
23334
|
+
this.requestSessionMap.delete(message.id);
|
|
23335
|
+
session.pendingRequests.delete(message.id);
|
|
23336
|
+
}
|
|
23337
|
+
}
|
|
23338
|
+
};
|
|
23339
|
+
this.addInitResponseHandler(sessionId, responseHandler);
|
|
23340
|
+
if (session.messageHandler) {
|
|
23341
|
+
session.messageHandler(message);
|
|
23342
|
+
} else {
|
|
23343
|
+
this.removeInitResponseHandler(sessionId, responseHandler);
|
|
23344
|
+
res.writeHead(500);
|
|
23345
|
+
res.end(
|
|
23346
|
+
JSON.stringify({
|
|
23347
|
+
jsonrpc: "2.0",
|
|
23348
|
+
error: {
|
|
23349
|
+
code: -32603,
|
|
23350
|
+
message: "Internal error: No message handler available"
|
|
23351
|
+
},
|
|
23352
|
+
id: "id" in message ? message.id : null
|
|
23353
|
+
})
|
|
23354
|
+
);
|
|
23355
|
+
}
|
|
23356
|
+
} else {
|
|
23357
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
23358
|
+
if (!sessionId || !this.sessions.has(sessionId)) {
|
|
23359
|
+
res.writeHead(400);
|
|
23360
|
+
res.end(
|
|
23361
|
+
JSON.stringify({
|
|
23362
|
+
jsonrpc: "2.0",
|
|
23363
|
+
error: {
|
|
23364
|
+
code: -32e3,
|
|
23365
|
+
message: "Invalid session. A valid Mcp-Session-Id header is required."
|
|
23366
|
+
},
|
|
23367
|
+
id: "id" in message ? message.id : null
|
|
23368
|
+
})
|
|
23369
|
+
);
|
|
23370
|
+
return;
|
|
23371
|
+
}
|
|
23372
|
+
const session = this.sessions.get(sessionId);
|
|
23373
|
+
if (isJSONRPCRequest(message)) {
|
|
23374
|
+
if (session.messageHandler) {
|
|
23375
|
+
if (message.id !== void 0 && message.id !== null) {
|
|
23376
|
+
this.requestSessionMap.set(message.id, sessionId);
|
|
23377
|
+
if (!session.pendingRequests) {
|
|
23378
|
+
session.pendingRequests = /* @__PURE__ */ new Set();
|
|
23379
|
+
}
|
|
23380
|
+
session.pendingRequests.add(message.id);
|
|
23381
|
+
}
|
|
23382
|
+
session.messageHandler(message);
|
|
23383
|
+
res.writeHead(202);
|
|
23384
|
+
res.end();
|
|
23385
|
+
}
|
|
23386
|
+
} else {
|
|
23387
|
+
if (session.messageHandler) {
|
|
23388
|
+
session.messageHandler(message);
|
|
23389
|
+
res.writeHead(202);
|
|
23390
|
+
res.end();
|
|
23391
|
+
}
|
|
23392
|
+
}
|
|
23393
|
+
}
|
|
23394
|
+
} catch (err) {
|
|
23395
|
+
res.writeHead(400);
|
|
23396
|
+
res.end(
|
|
23397
|
+
JSON.stringify({
|
|
23398
|
+
jsonrpc: "2.0",
|
|
23399
|
+
error: {
|
|
23400
|
+
code: -32700,
|
|
23401
|
+
message: "Parse error",
|
|
23402
|
+
data: String(err)
|
|
23403
|
+
},
|
|
23404
|
+
id: null
|
|
23405
|
+
})
|
|
23406
|
+
);
|
|
23407
|
+
if (this.onerror) {
|
|
23408
|
+
this.onerror(new Error(`Parse error: ${String(err)}`));
|
|
23409
|
+
}
|
|
23410
|
+
}
|
|
23411
|
+
});
|
|
23412
|
+
req.on("error", (err) => {
|
|
23413
|
+
if (this.onerror) {
|
|
23414
|
+
this.onerror(err instanceof Error ? err : new Error(String(err)));
|
|
23415
|
+
}
|
|
23416
|
+
});
|
|
23417
|
+
}
|
|
23418
|
+
/**
|
|
23419
|
+
* Handle initialization request
|
|
23420
|
+
*/
|
|
23421
|
+
handleInitializeRequest(message, _req, res) {
|
|
23422
|
+
const sessionId = randomUUID();
|
|
23423
|
+
this.sessions.set(sessionId, {
|
|
23424
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
23425
|
+
messageHandler: this.onmessage || (() => {
|
|
23426
|
+
}),
|
|
23427
|
+
activeResponses: /* @__PURE__ */ new Set(),
|
|
23428
|
+
initialized: true,
|
|
23429
|
+
pendingRequests: /* @__PURE__ */ new Set()
|
|
23430
|
+
});
|
|
23431
|
+
if ("id" in message && message.id !== null && message.id !== void 0) {
|
|
23432
|
+
this.requestSessionMap.set(message.id, sessionId);
|
|
23433
|
+
}
|
|
23434
|
+
res.setHeader("Content-Type", "application/json");
|
|
23435
|
+
res.setHeader("Mcp-Session-Id", sessionId);
|
|
23436
|
+
const responseHandler = (responseMessage) => {
|
|
23437
|
+
if (isJSONRPCResponse(responseMessage) && "id" in message && responseMessage.id === message.id) {
|
|
23438
|
+
res.writeHead(200);
|
|
23439
|
+
res.end(JSON.stringify(responseMessage));
|
|
23440
|
+
this.removeInitResponseHandler(sessionId, responseHandler);
|
|
23441
|
+
this.requestSessionMap.delete(message.id);
|
|
23442
|
+
}
|
|
23443
|
+
};
|
|
23444
|
+
this.addInitResponseHandler(sessionId, responseHandler);
|
|
23445
|
+
if (this.onmessage) {
|
|
23446
|
+
this.onmessage(message);
|
|
23447
|
+
} else {
|
|
23448
|
+
this.removeInitResponseHandler(sessionId, responseHandler);
|
|
23449
|
+
res.writeHead(500);
|
|
23450
|
+
res.end(
|
|
23451
|
+
JSON.stringify({
|
|
23452
|
+
jsonrpc: "2.0",
|
|
23453
|
+
error: {
|
|
23454
|
+
code: -32603,
|
|
23455
|
+
message: "Internal error: No message handler available"
|
|
23456
|
+
},
|
|
23457
|
+
id: "id" in message ? message.id : null
|
|
23458
|
+
})
|
|
23459
|
+
);
|
|
23460
|
+
}
|
|
23461
|
+
}
|
|
23462
|
+
/**
|
|
23463
|
+
* Add initialize response handler
|
|
23464
|
+
*/
|
|
23465
|
+
initResponseHandlers = /* @__PURE__ */ new Map();
|
|
23466
|
+
addInitResponseHandler(sessionId, handler) {
|
|
23467
|
+
if (!this.initResponseHandlers.has(sessionId)) {
|
|
23468
|
+
this.initResponseHandlers.set(sessionId, []);
|
|
23469
|
+
}
|
|
23470
|
+
this.initResponseHandlers.get(sessionId).push(handler);
|
|
23471
|
+
}
|
|
23472
|
+
removeInitResponseHandler(sessionId, handler) {
|
|
23473
|
+
if (this.initResponseHandlers.has(sessionId)) {
|
|
23474
|
+
const handlers = this.initResponseHandlers.get(sessionId);
|
|
23475
|
+
const index = handlers.indexOf(handler);
|
|
23476
|
+
if (index !== -1) {
|
|
23477
|
+
handlers.splice(index, 1);
|
|
23478
|
+
}
|
|
23479
|
+
if (handlers.length === 0) {
|
|
23480
|
+
this.initResponseHandlers.delete(sessionId);
|
|
23481
|
+
}
|
|
23482
|
+
}
|
|
23483
|
+
}
|
|
23484
|
+
/**
|
|
23485
|
+
* Handle GET request (streaming connection)
|
|
23486
|
+
*/
|
|
23487
|
+
handleGetRequest(req, res) {
|
|
23488
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
23489
|
+
if (!sessionId || !this.sessions.has(sessionId)) {
|
|
23490
|
+
res.writeHead(400);
|
|
23491
|
+
res.end(
|
|
23492
|
+
JSON.stringify({
|
|
23493
|
+
jsonrpc: "2.0",
|
|
23494
|
+
error: {
|
|
23495
|
+
code: -32e3,
|
|
23496
|
+
message: "Invalid session. A valid Mcp-Session-Id header is required."
|
|
23497
|
+
},
|
|
23498
|
+
id: null
|
|
23499
|
+
})
|
|
23500
|
+
);
|
|
23501
|
+
return;
|
|
23502
|
+
}
|
|
23503
|
+
const session = this.sessions.get(sessionId);
|
|
23504
|
+
res.setHeader("Content-Type", "text/event-stream");
|
|
23505
|
+
res.setHeader("Connection", "keep-alive");
|
|
23506
|
+
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
23507
|
+
res.setHeader("Transfer-Encoding", "chunked");
|
|
23508
|
+
res.setHeader("Mcp-Session-Id", sessionId);
|
|
23509
|
+
res.writeHead(200);
|
|
23510
|
+
session.activeResponses.add(res);
|
|
23511
|
+
req.on("close", () => {
|
|
23512
|
+
session.activeResponses.delete(res);
|
|
23513
|
+
});
|
|
23514
|
+
res.on("error", (err) => {
|
|
23515
|
+
session.activeResponses.delete(res);
|
|
23516
|
+
if (this.onerror) {
|
|
23517
|
+
this.onerror(err);
|
|
23518
|
+
}
|
|
23519
|
+
});
|
|
23520
|
+
}
|
|
23521
|
+
/**
|
|
23522
|
+
* Handle DELETE request (session termination)
|
|
23523
|
+
*/
|
|
23524
|
+
handleDeleteRequest(req, res) {
|
|
23525
|
+
const sessionId = req.headers["mcp-session-id"];
|
|
23526
|
+
if (!sessionId || !this.sessions.has(sessionId)) {
|
|
23527
|
+
res.writeHead(400);
|
|
23528
|
+
res.end(
|
|
23529
|
+
JSON.stringify({
|
|
23530
|
+
jsonrpc: "2.0",
|
|
23531
|
+
error: {
|
|
23532
|
+
code: -32e3,
|
|
23533
|
+
message: "Invalid session. A valid Mcp-Session-Id header is required."
|
|
23534
|
+
},
|
|
23535
|
+
id: null
|
|
23536
|
+
})
|
|
23537
|
+
);
|
|
23538
|
+
return;
|
|
23539
|
+
}
|
|
23540
|
+
const session = this.sessions.get(sessionId);
|
|
23541
|
+
for (const response of session.activeResponses) {
|
|
23542
|
+
try {
|
|
23543
|
+
response.end();
|
|
23544
|
+
} catch (err) {
|
|
23545
|
+
}
|
|
23546
|
+
}
|
|
23547
|
+
if (session.pendingRequests) {
|
|
23548
|
+
for (const requestId of session.pendingRequests) {
|
|
23549
|
+
this.requestSessionMap.delete(requestId);
|
|
23550
|
+
}
|
|
23551
|
+
}
|
|
23552
|
+
this.sessions.delete(sessionId);
|
|
23553
|
+
res.writeHead(204);
|
|
23554
|
+
res.end();
|
|
23555
|
+
}
|
|
23556
|
+
};
|
|
23557
|
+
|
|
20140
23558
|
// src/index.ts
|
|
20141
23559
|
async function main() {
|
|
20142
23560
|
try {
|
|
20143
23561
|
const config = loadConfig();
|
|
20144
23562
|
const server = new OpenAPIServer(config);
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
23563
|
+
let transport;
|
|
23564
|
+
if (config.transportType === "http") {
|
|
23565
|
+
transport = new StreamableHttpServerTransport(
|
|
23566
|
+
config.httpPort,
|
|
23567
|
+
config.httpHost,
|
|
23568
|
+
config.endpointPath
|
|
23569
|
+
);
|
|
23570
|
+
await server.start(transport);
|
|
23571
|
+
console.error(
|
|
23572
|
+
`OpenAPI MCP Server running on http://${config.httpHost}:${config.httpPort}${config.endpointPath}`
|
|
23573
|
+
);
|
|
23574
|
+
} else {
|
|
23575
|
+
transport = new StdioServerTransport();
|
|
23576
|
+
await server.start(transport);
|
|
23577
|
+
console.error("OpenAPI MCP Server running on stdio");
|
|
23578
|
+
}
|
|
20148
23579
|
} catch (error) {
|
|
20149
23580
|
console.error("Failed to start server:", error);
|
|
20150
23581
|
process.exit(1);
|
|
@@ -20155,6 +23586,7 @@ export {
|
|
|
20155
23586
|
ApiClient,
|
|
20156
23587
|
OpenAPIServer,
|
|
20157
23588
|
OpenAPISpecLoader,
|
|
23589
|
+
StreamableHttpServerTransport,
|
|
20158
23590
|
ToolsManager,
|
|
20159
23591
|
loadConfig,
|
|
20160
23592
|
parseHeaders
|
|
@@ -20177,6 +23609,9 @@ mime-types/index.js:
|
|
|
20177
23609
|
* MIT Licensed
|
|
20178
23610
|
*)
|
|
20179
23611
|
|
|
23612
|
+
js-yaml/dist/js-yaml.mjs:
|
|
23613
|
+
(*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
|
|
23614
|
+
|
|
20180
23615
|
yargs-parser/build/lib/string-utils.js:
|
|
20181
23616
|
yargs-parser/build/lib/tokenize-arg-string.js:
|
|
20182
23617
|
yargs-parser/build/lib/yargs-parser-types.js:
|