postgresai 0.15.0-rc.2 → 0.15.0-rc.3
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/bin/postgres-ai.ts +88 -124
- package/dist/bin/postgres-ai.js +3260 -540
- package/lib/instances.ts +245 -0
- package/package.json +1 -1
- package/test/monitoring.test.ts +277 -0
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -1020,7 +1020,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1020
1020
|
this._exitCallback = (err) => {
|
|
1021
1021
|
if (err.code !== "commander.executeSubCommandAsync") {
|
|
1022
1022
|
throw err;
|
|
1023
|
-
}
|
|
1023
|
+
}
|
|
1024
1024
|
};
|
|
1025
1025
|
}
|
|
1026
1026
|
return this;
|
|
@@ -13423,7 +13423,7 @@ var {
|
|
|
13423
13423
|
// package.json
|
|
13424
13424
|
var package_default = {
|
|
13425
13425
|
name: "postgresai",
|
|
13426
|
-
version: "0.15.0-rc.
|
|
13426
|
+
version: "0.15.0-rc.3",
|
|
13427
13427
|
description: "postgres_ai CLI",
|
|
13428
13428
|
license: "Apache-2.0",
|
|
13429
13429
|
private: false,
|
|
@@ -16234,7 +16234,7 @@ var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
|
16234
16234
|
var safeDump = renamed("safeDump", "dump");
|
|
16235
16235
|
|
|
16236
16236
|
// bin/postgres-ai.ts
|
|
16237
|
-
import * as
|
|
16237
|
+
import * as fs8 from "fs";
|
|
16238
16238
|
import * as path7 from "path";
|
|
16239
16239
|
import * as os3 from "os";
|
|
16240
16240
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
@@ -16254,7 +16254,7 @@ var Result = import_lib.default.Result;
|
|
|
16254
16254
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
16255
16255
|
var defaults = import_lib.default.defaults;
|
|
16256
16256
|
// package.json
|
|
16257
|
-
var version = "0.15.0-rc.
|
|
16257
|
+
var version = "0.15.0-rc.3";
|
|
16258
16258
|
var package_default2 = {
|
|
16259
16259
|
name: "postgresai",
|
|
16260
16260
|
version,
|
|
@@ -20968,7 +20968,7 @@ function finalize(ctx, schema2) {
|
|
|
20968
20968
|
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
20969
20969
|
} else if (ctx.target === "draft-04") {
|
|
20970
20970
|
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
20971
|
-
} else if (ctx.target === "openapi-3.0") {}
|
|
20971
|
+
} else if (ctx.target === "openapi-3.0") {}
|
|
20972
20972
|
if (ctx.external?.uri) {
|
|
20973
20973
|
const id = ctx.external.registry.get(schema2)?.id;
|
|
20974
20974
|
if (!id)
|
|
@@ -21187,7 +21187,7 @@ var literalProcessor = (schema2, ctx, json2, _params) => {
|
|
|
21187
21187
|
if (val === undefined) {
|
|
21188
21188
|
if (ctx.unrepresentable === "throw") {
|
|
21189
21189
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
21190
|
-
}
|
|
21190
|
+
}
|
|
21191
21191
|
} else if (typeof val === "bigint") {
|
|
21192
21192
|
if (ctx.unrepresentable === "throw") {
|
|
21193
21193
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
@@ -30541,395 +30541,3176 @@ function summarizeG003(nodeData) {
|
|
|
30541
30541
|
};
|
|
30542
30542
|
}
|
|
30543
30543
|
|
|
30544
|
-
//
|
|
30545
|
-
|
|
30546
|
-
|
|
30547
|
-
|
|
30548
|
-
|
|
30549
|
-
|
|
30550
|
-
|
|
30551
|
-
Download: https://nodejs.org/`);
|
|
30552
|
-
process.exit(1);
|
|
30544
|
+
// lib/instances.ts
|
|
30545
|
+
import * as fs7 from "fs";
|
|
30546
|
+
|
|
30547
|
+
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
30548
|
+
/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
|
|
30549
|
+
function isNothing2(subject) {
|
|
30550
|
+
return typeof subject === "undefined" || subject === null;
|
|
30553
30551
|
}
|
|
30554
|
-
|
|
30555
|
-
|
|
30556
|
-
if (!rl) {
|
|
30557
|
-
rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
30558
|
-
}
|
|
30559
|
-
return rl;
|
|
30552
|
+
function isObject3(subject) {
|
|
30553
|
+
return typeof subject === "object" && subject !== null;
|
|
30560
30554
|
}
|
|
30561
|
-
function
|
|
30562
|
-
if (
|
|
30563
|
-
|
|
30564
|
-
|
|
30565
|
-
|
|
30555
|
+
function toArray2(sequence) {
|
|
30556
|
+
if (Array.isArray(sequence))
|
|
30557
|
+
return sequence;
|
|
30558
|
+
else if (isNothing2(sequence))
|
|
30559
|
+
return [];
|
|
30560
|
+
return [sequence];
|
|
30566
30561
|
}
|
|
30567
|
-
function
|
|
30568
|
-
|
|
30569
|
-
|
|
30570
|
-
|
|
30571
|
-
|
|
30562
|
+
function extend4(target, source) {
|
|
30563
|
+
var index, length, key, sourceKeys;
|
|
30564
|
+
if (source) {
|
|
30565
|
+
sourceKeys = Object.keys(source);
|
|
30566
|
+
for (index = 0, length = sourceKeys.length;index < length; index += 1) {
|
|
30567
|
+
key = sourceKeys[index];
|
|
30568
|
+
target[key] = source[key];
|
|
30569
|
+
}
|
|
30572
30570
|
}
|
|
30573
|
-
return
|
|
30574
|
-
}
|
|
30575
|
-
async function execFilePromise(file, args) {
|
|
30576
|
-
return new Promise((resolve8, reject) => {
|
|
30577
|
-
childProcess.execFile(file, args, (error2, stdout, stderr) => {
|
|
30578
|
-
if (error2) {
|
|
30579
|
-
const err = error2;
|
|
30580
|
-
err.code = typeof error2.code === "number" ? error2.code : 1;
|
|
30581
|
-
reject(err);
|
|
30582
|
-
} else {
|
|
30583
|
-
resolve8({ stdout, stderr });
|
|
30584
|
-
}
|
|
30585
|
-
});
|
|
30586
|
-
});
|
|
30587
|
-
}
|
|
30588
|
-
function spawnSync2(cmd, args, options) {
|
|
30589
|
-
const result = childProcess.spawnSync(cmd, args, {
|
|
30590
|
-
stdio: options?.stdio === "inherit" ? "inherit" : "pipe",
|
|
30591
|
-
env: options?.env,
|
|
30592
|
-
cwd: options?.cwd,
|
|
30593
|
-
encoding: "utf8"
|
|
30594
|
-
});
|
|
30595
|
-
return {
|
|
30596
|
-
status: result.status,
|
|
30597
|
-
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
30598
|
-
stderr: typeof result.stderr === "string" ? result.stderr : ""
|
|
30599
|
-
};
|
|
30600
|
-
}
|
|
30601
|
-
function spawn2(cmd, args, options) {
|
|
30602
|
-
const proc = childProcess.spawn(cmd, args, {
|
|
30603
|
-
stdio: options?.stdio ?? "pipe",
|
|
30604
|
-
env: options?.env,
|
|
30605
|
-
cwd: options?.cwd,
|
|
30606
|
-
detached: options?.detached
|
|
30607
|
-
});
|
|
30608
|
-
return {
|
|
30609
|
-
on(event, cb) {
|
|
30610
|
-
if (event === "close" || event === "exit") {
|
|
30611
|
-
proc.on(event, (code, signal) => cb(code, signal ?? undefined));
|
|
30612
|
-
} else if (event === "error") {
|
|
30613
|
-
proc.on("error", (err) => cb(null, String(err)));
|
|
30614
|
-
}
|
|
30615
|
-
return this;
|
|
30616
|
-
},
|
|
30617
|
-
unref() {
|
|
30618
|
-
proc.unref();
|
|
30619
|
-
},
|
|
30620
|
-
pid: proc.pid
|
|
30621
|
-
};
|
|
30622
|
-
}
|
|
30623
|
-
async function question(prompt) {
|
|
30624
|
-
return new Promise((resolve8) => {
|
|
30625
|
-
getReadline().question(prompt, (answer) => {
|
|
30626
|
-
resolve8(answer);
|
|
30627
|
-
});
|
|
30628
|
-
});
|
|
30571
|
+
return target;
|
|
30629
30572
|
}
|
|
30630
|
-
function
|
|
30631
|
-
|
|
30632
|
-
|
|
30633
|
-
|
|
30634
|
-
if (s === "~")
|
|
30635
|
-
return os3.homedir();
|
|
30636
|
-
if (s.startsWith("~/") || s.startsWith("~\\")) {
|
|
30637
|
-
return path7.join(os3.homedir(), s.slice(2));
|
|
30573
|
+
function repeat2(string4, count) {
|
|
30574
|
+
var result = "", cycle;
|
|
30575
|
+
for (cycle = 0;cycle < count; cycle += 1) {
|
|
30576
|
+
result += string4;
|
|
30638
30577
|
}
|
|
30639
|
-
return
|
|
30578
|
+
return result;
|
|
30640
30579
|
}
|
|
30641
|
-
function
|
|
30642
|
-
|
|
30643
|
-
|
|
30644
|
-
|
|
30645
|
-
|
|
30646
|
-
|
|
30580
|
+
function isNegativeZero2(number4) {
|
|
30581
|
+
return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
|
|
30582
|
+
}
|
|
30583
|
+
var isNothing_12 = isNothing2;
|
|
30584
|
+
var isObject_12 = isObject3;
|
|
30585
|
+
var toArray_12 = toArray2;
|
|
30586
|
+
var repeat_12 = repeat2;
|
|
30587
|
+
var isNegativeZero_12 = isNegativeZero2;
|
|
30588
|
+
var extend_12 = extend4;
|
|
30589
|
+
var common2 = {
|
|
30590
|
+
isNothing: isNothing_12,
|
|
30591
|
+
isObject: isObject_12,
|
|
30592
|
+
toArray: toArray_12,
|
|
30593
|
+
repeat: repeat_12,
|
|
30594
|
+
isNegativeZero: isNegativeZero_12,
|
|
30595
|
+
extend: extend_12
|
|
30596
|
+
};
|
|
30597
|
+
function formatError3(exception2, compact) {
|
|
30598
|
+
var where = "", message = exception2.reason || "(unknown reason)";
|
|
30599
|
+
if (!exception2.mark)
|
|
30600
|
+
return message;
|
|
30601
|
+
if (exception2.mark.name) {
|
|
30602
|
+
where += 'in "' + exception2.mark.name + '" ';
|
|
30647
30603
|
}
|
|
30648
|
-
|
|
30649
|
-
|
|
30650
|
-
|
|
30651
|
-
|
|
30652
|
-
|
|
30653
|
-
|
|
30654
|
-
|
|
30655
|
-
return;
|
|
30656
|
-
const elapsedSec = ((Date.now() - startTs) / 1000).toFixed(1);
|
|
30657
|
-
const frame = frames[frameIdx % frames.length] ?? frames[0] ?? "\u283F";
|
|
30658
|
-
frameIdx += 1;
|
|
30659
|
-
process.stdout.write(`\r\x1B[2K${frame} ${text} (${elapsedSec}s)`);
|
|
30660
|
-
};
|
|
30661
|
-
const timer = setInterval(render, 120);
|
|
30662
|
-
render();
|
|
30663
|
-
return {
|
|
30664
|
-
update: (t) => {
|
|
30665
|
-
text = t;
|
|
30666
|
-
render();
|
|
30667
|
-
},
|
|
30668
|
-
stop: (finalText) => {
|
|
30669
|
-
if (stopped)
|
|
30670
|
-
return;
|
|
30671
|
-
stopped = true;
|
|
30672
|
-
clearInterval(timer);
|
|
30673
|
-
process.stdout.write("\r\x1B[2K");
|
|
30674
|
-
if (finalText && finalText.trim()) {
|
|
30675
|
-
process.stdout.write(finalText);
|
|
30676
|
-
}
|
|
30677
|
-
process.stdout.write(`
|
|
30678
|
-
`);
|
|
30679
|
-
}
|
|
30680
|
-
};
|
|
30604
|
+
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
30605
|
+
if (!compact && exception2.mark.snippet) {
|
|
30606
|
+
where += `
|
|
30607
|
+
|
|
30608
|
+
` + exception2.mark.snippet;
|
|
30609
|
+
}
|
|
30610
|
+
return message + " " + where;
|
|
30681
30611
|
}
|
|
30682
|
-
function
|
|
30683
|
-
|
|
30684
|
-
|
|
30685
|
-
|
|
30686
|
-
|
|
30687
|
-
|
|
30688
|
-
|
|
30689
|
-
|
|
30690
|
-
|
|
30691
|
-
|
|
30692
|
-
const code = typeof errAny?.code === "string" ? errAny.code : "";
|
|
30693
|
-
const msg = errAny instanceof Error ? errAny.message : String(errAny);
|
|
30694
|
-
if (code === "EACCES" || code === "EPERM" || code === "ENOENT") {
|
|
30695
|
-
console.error(`Error: Failed to create output directory: ${outputPath}`);
|
|
30696
|
-
console.error(`Reason: ${msg}`);
|
|
30697
|
-
console.error("Tip: choose a writable path, e.g. --output ./reports or --output ~/reports");
|
|
30698
|
-
return null;
|
|
30699
|
-
}
|
|
30700
|
-
throw e;
|
|
30701
|
-
}
|
|
30612
|
+
function YAMLException$12(reason, mark) {
|
|
30613
|
+
Error.call(this);
|
|
30614
|
+
this.name = "YAMLException";
|
|
30615
|
+
this.reason = reason;
|
|
30616
|
+
this.mark = mark;
|
|
30617
|
+
this.message = formatError3(this, false);
|
|
30618
|
+
if (Error.captureStackTrace) {
|
|
30619
|
+
Error.captureStackTrace(this, this.constructor);
|
|
30620
|
+
} else {
|
|
30621
|
+
this.stack = new Error().stack || "";
|
|
30702
30622
|
}
|
|
30703
|
-
return outputPath;
|
|
30704
30623
|
}
|
|
30705
|
-
|
|
30706
|
-
|
|
30707
|
-
|
|
30708
|
-
|
|
30709
|
-
|
|
30710
|
-
|
|
30711
|
-
|
|
30712
|
-
|
|
30713
|
-
|
|
30714
|
-
|
|
30715
|
-
|
|
30624
|
+
YAMLException$12.prototype = Object.create(Error.prototype);
|
|
30625
|
+
YAMLException$12.prototype.constructor = YAMLException$12;
|
|
30626
|
+
YAMLException$12.prototype.toString = function toString2(compact) {
|
|
30627
|
+
return this.name + ": " + formatError3(this, compact);
|
|
30628
|
+
};
|
|
30629
|
+
var exception2 = YAMLException$12;
|
|
30630
|
+
function getLine2(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
30631
|
+
var head = "";
|
|
30632
|
+
var tail = "";
|
|
30633
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
30634
|
+
if (position - lineStart > maxHalfLength) {
|
|
30635
|
+
head = " ... ";
|
|
30636
|
+
lineStart = position - maxHalfLength + head.length;
|
|
30716
30637
|
}
|
|
30717
|
-
|
|
30718
|
-
|
|
30719
|
-
|
|
30720
|
-
let projectWasGenerated = false;
|
|
30721
|
-
if (!project) {
|
|
30722
|
-
project = `project_${crypto2.randomBytes(6).toString("hex")}`;
|
|
30723
|
-
projectWasGenerated = true;
|
|
30724
|
-
try {
|
|
30725
|
-
writeConfig({ defaultProject: project });
|
|
30726
|
-
} catch (e) {
|
|
30727
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
30728
|
-
console.error(`Warning: Failed to save generated default project: ${message}`);
|
|
30729
|
-
}
|
|
30638
|
+
if (lineEnd - position > maxHalfLength) {
|
|
30639
|
+
tail = " ...";
|
|
30640
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
30730
30641
|
}
|
|
30731
30642
|
return {
|
|
30732
|
-
|
|
30733
|
-
|
|
30643
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
|
|
30644
|
+
pos: position - lineStart + head.length
|
|
30734
30645
|
};
|
|
30735
30646
|
}
|
|
30736
|
-
|
|
30737
|
-
|
|
30738
|
-
const created = await withRetry(() => createCheckupReport({
|
|
30739
|
-
apiKey: uploadCfg.apiKey,
|
|
30740
|
-
apiBaseUrl: uploadCfg.apiBaseUrl,
|
|
30741
|
-
project: uploadCfg.project
|
|
30742
|
-
}), { maxAttempts: 3 }, (attempt, err, delayMs) => {
|
|
30743
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
30744
|
-
logUpload(`[Retry ${attempt}/3] createCheckupReport failed: ${errMsg}, retrying in ${delayMs}ms...`);
|
|
30745
|
-
});
|
|
30746
|
-
const reportId = created.reportId;
|
|
30747
|
-
const uploaded = [];
|
|
30748
|
-
for (const [checkId, report] of Object.entries(reports)) {
|
|
30749
|
-
spinner.update(`Uploading ${checkId}.json`);
|
|
30750
|
-
const jsonText = JSON.stringify(report, null, 2);
|
|
30751
|
-
const r = await withRetry(() => uploadCheckupReportJson({
|
|
30752
|
-
apiKey: uploadCfg.apiKey,
|
|
30753
|
-
apiBaseUrl: uploadCfg.apiBaseUrl,
|
|
30754
|
-
reportId,
|
|
30755
|
-
filename: `${checkId}.json`,
|
|
30756
|
-
checkId,
|
|
30757
|
-
jsonText
|
|
30758
|
-
}), { maxAttempts: 3 }, (attempt, err, delayMs) => {
|
|
30759
|
-
const errMsg = err instanceof Error ? err.message : String(err);
|
|
30760
|
-
logUpload(`[Retry ${attempt}/3] Upload ${checkId}.json failed: ${errMsg}, retrying in ${delayMs}ms...`);
|
|
30761
|
-
});
|
|
30762
|
-
uploaded.push({ checkId, filename: `${checkId}.json`, chunkId: r.reportChunkId });
|
|
30763
|
-
}
|
|
30764
|
-
return { project: uploadCfg.project, reportId, uploaded };
|
|
30765
|
-
}
|
|
30766
|
-
function writeReportFiles(reports, outputPath) {
|
|
30767
|
-
for (const [checkId, report] of Object.entries(reports)) {
|
|
30768
|
-
const filePath = path7.join(outputPath, `${checkId}.json`);
|
|
30769
|
-
fs7.writeFileSync(filePath, JSON.stringify(report, null, 2), "utf8");
|
|
30770
|
-
const title = report.checkTitle || checkId;
|
|
30771
|
-
console.log(`\u2713 ${checkId} ${title}: ${filePath}`);
|
|
30772
|
-
}
|
|
30647
|
+
function padStart2(string4, max) {
|
|
30648
|
+
return common2.repeat(" ", max - string4.length) + string4;
|
|
30773
30649
|
}
|
|
30774
|
-
function
|
|
30775
|
-
|
|
30776
|
-
|
|
30777
|
-
|
|
30778
|
-
|
|
30779
|
-
|
|
30780
|
-
if (
|
|
30781
|
-
|
|
30782
|
-
|
|
30783
|
-
|
|
30784
|
-
|
|
30785
|
-
|
|
30786
|
-
|
|
30787
|
-
|
|
30788
|
-
|
|
30789
|
-
|
|
30790
|
-
|
|
30791
|
-
|
|
30792
|
-
|
|
30793
|
-
|
|
30794
|
-
|
|
30795
|
-
|
|
30796
|
-
if (isSignificant) {
|
|
30797
|
-
summaries.push({ checkId: item.checkId, title, status, message });
|
|
30798
|
-
} else {
|
|
30799
|
-
skippedCount++;
|
|
30800
|
-
}
|
|
30650
|
+
function makeSnippet2(mark, options) {
|
|
30651
|
+
options = Object.create(options || null);
|
|
30652
|
+
if (!mark.buffer)
|
|
30653
|
+
return null;
|
|
30654
|
+
if (!options.maxLength)
|
|
30655
|
+
options.maxLength = 79;
|
|
30656
|
+
if (typeof options.indent !== "number")
|
|
30657
|
+
options.indent = 1;
|
|
30658
|
+
if (typeof options.linesBefore !== "number")
|
|
30659
|
+
options.linesBefore = 3;
|
|
30660
|
+
if (typeof options.linesAfter !== "number")
|
|
30661
|
+
options.linesAfter = 2;
|
|
30662
|
+
var re = /\r?\n|\r|\0/g;
|
|
30663
|
+
var lineStarts = [0];
|
|
30664
|
+
var lineEnds = [];
|
|
30665
|
+
var match;
|
|
30666
|
+
var foundLineNo = -1;
|
|
30667
|
+
while (match = re.exec(mark.buffer)) {
|
|
30668
|
+
lineEnds.push(match.index);
|
|
30669
|
+
lineStarts.push(match.index + match[0].length);
|
|
30670
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
30671
|
+
foundLineNo = lineStarts.length - 2;
|
|
30801
30672
|
}
|
|
30802
30673
|
}
|
|
30803
|
-
|
|
30804
|
-
|
|
30674
|
+
if (foundLineNo < 0)
|
|
30675
|
+
foundLineNo = lineStarts.length - 1;
|
|
30676
|
+
var result = "", i2, line;
|
|
30677
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
30678
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
30679
|
+
for (i2 = 1;i2 <= options.linesBefore; i2++) {
|
|
30680
|
+
if (foundLineNo - i2 < 0)
|
|
30681
|
+
break;
|
|
30682
|
+
line = getLine2(mark.buffer, lineStarts[foundLineNo - i2], lineEnds[foundLineNo - i2], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i2]), maxLineLength);
|
|
30683
|
+
result = common2.repeat(" ", options.indent) + padStart2((mark.line - i2 + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
30684
|
+
` + result;
|
|
30805
30685
|
}
|
|
30806
|
-
|
|
30807
|
-
|
|
30686
|
+
line = getLine2(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
30687
|
+
result += common2.repeat(" ", options.indent) + padStart2((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
30688
|
+
`;
|
|
30689
|
+
result += common2.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + `
|
|
30690
|
+
`;
|
|
30691
|
+
for (i2 = 1;i2 <= options.linesAfter; i2++) {
|
|
30692
|
+
if (foundLineNo + i2 >= lineEnds.length)
|
|
30693
|
+
break;
|
|
30694
|
+
line = getLine2(mark.buffer, lineStarts[foundLineNo + i2], lineEnds[foundLineNo + i2], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i2]), maxLineLength);
|
|
30695
|
+
result += common2.repeat(" ", options.indent) + padStart2((mark.line + i2 + 1).toString(), lineNoLength) + " | " + line.str + `
|
|
30696
|
+
`;
|
|
30808
30697
|
}
|
|
30698
|
+
return result.replace(/\n$/, "");
|
|
30809
30699
|
}
|
|
30810
|
-
|
|
30811
|
-
|
|
30812
|
-
|
|
30813
|
-
|
|
30814
|
-
|
|
30700
|
+
var snippet2 = makeSnippet2;
|
|
30701
|
+
var TYPE_CONSTRUCTOR_OPTIONS2 = [
|
|
30702
|
+
"kind",
|
|
30703
|
+
"multi",
|
|
30704
|
+
"resolve",
|
|
30705
|
+
"construct",
|
|
30706
|
+
"instanceOf",
|
|
30707
|
+
"predicate",
|
|
30708
|
+
"represent",
|
|
30709
|
+
"representName",
|
|
30710
|
+
"defaultStyle",
|
|
30711
|
+
"styleAliases"
|
|
30712
|
+
];
|
|
30713
|
+
var YAML_NODE_KINDS2 = [
|
|
30714
|
+
"scalar",
|
|
30715
|
+
"sequence",
|
|
30716
|
+
"mapping"
|
|
30717
|
+
];
|
|
30718
|
+
function compileStyleAliases2(map3) {
|
|
30719
|
+
var result = {};
|
|
30720
|
+
if (map3 !== null) {
|
|
30721
|
+
Object.keys(map3).forEach(function(style) {
|
|
30722
|
+
map3[style].forEach(function(alias) {
|
|
30723
|
+
result[String(alias)] = style;
|
|
30724
|
+
});
|
|
30725
|
+
});
|
|
30726
|
+
}
|
|
30727
|
+
return result;
|
|
30815
30728
|
}
|
|
30816
|
-
|
|
30817
|
-
|
|
30818
|
-
|
|
30819
|
-
|
|
30820
|
-
|
|
30821
|
-
if (!response.ok) {
|
|
30822
|
-
throw new Error(`HTTP ${response.status} for ${url}`);
|
|
30729
|
+
function Type$12(tag, options) {
|
|
30730
|
+
options = options || {};
|
|
30731
|
+
Object.keys(options).forEach(function(name) {
|
|
30732
|
+
if (TYPE_CONSTRUCTOR_OPTIONS2.indexOf(name) === -1) {
|
|
30733
|
+
throw new exception2('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
30823
30734
|
}
|
|
30824
|
-
|
|
30825
|
-
|
|
30826
|
-
|
|
30735
|
+
});
|
|
30736
|
+
this.options = options;
|
|
30737
|
+
this.tag = tag;
|
|
30738
|
+
this.kind = options["kind"] || null;
|
|
30739
|
+
this.resolve = options["resolve"] || function() {
|
|
30740
|
+
return true;
|
|
30741
|
+
};
|
|
30742
|
+
this.construct = options["construct"] || function(data) {
|
|
30743
|
+
return data;
|
|
30744
|
+
};
|
|
30745
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
30746
|
+
this.predicate = options["predicate"] || null;
|
|
30747
|
+
this.represent = options["represent"] || null;
|
|
30748
|
+
this.representName = options["representName"] || null;
|
|
30749
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
30750
|
+
this.multi = options["multi"] || false;
|
|
30751
|
+
this.styleAliases = compileStyleAliases2(options["styleAliases"] || null);
|
|
30752
|
+
if (YAML_NODE_KINDS2.indexOf(this.kind) === -1) {
|
|
30753
|
+
throw new exception2('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
30827
30754
|
}
|
|
30828
30755
|
}
|
|
30829
|
-
|
|
30830
|
-
|
|
30831
|
-
|
|
30832
|
-
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
30837
|
-
const refs = [
|
|
30838
|
-
process.env.PGAI_PROJECT_REF,
|
|
30839
|
-
package_default.version,
|
|
30840
|
-
`v${package_default.version}`,
|
|
30841
|
-
"main"
|
|
30842
|
-
].filter((v) => Boolean(v && v.trim()));
|
|
30843
|
-
let lastErr;
|
|
30844
|
-
for (const ref of refs) {
|
|
30845
|
-
const url = `https://gitlab.com/postgres-ai/postgres_ai/-/raw/${encodeURIComponent(ref)}/docker-compose.yml`;
|
|
30846
|
-
try {
|
|
30847
|
-
const text = await downloadText(url);
|
|
30848
|
-
fs7.writeFileSync(composeFile, text, { encoding: "utf8", mode: 384 });
|
|
30849
|
-
break;
|
|
30850
|
-
} catch (err) {
|
|
30851
|
-
lastErr = err;
|
|
30756
|
+
var type2 = Type$12;
|
|
30757
|
+
function compileList2(schema2, name) {
|
|
30758
|
+
var result = [];
|
|
30759
|
+
schema2[name].forEach(function(currentType) {
|
|
30760
|
+
var newIndex = result.length;
|
|
30761
|
+
result.forEach(function(previousType, previousIndex) {
|
|
30762
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
30763
|
+
newIndex = previousIndex;
|
|
30852
30764
|
}
|
|
30765
|
+
});
|
|
30766
|
+
result[newIndex] = currentType;
|
|
30767
|
+
});
|
|
30768
|
+
return result;
|
|
30769
|
+
}
|
|
30770
|
+
function compileMap2() {
|
|
30771
|
+
var result = {
|
|
30772
|
+
scalar: {},
|
|
30773
|
+
sequence: {},
|
|
30774
|
+
mapping: {},
|
|
30775
|
+
fallback: {},
|
|
30776
|
+
multi: {
|
|
30777
|
+
scalar: [],
|
|
30778
|
+
sequence: [],
|
|
30779
|
+
mapping: [],
|
|
30780
|
+
fallback: []
|
|
30853
30781
|
}
|
|
30854
|
-
|
|
30855
|
-
|
|
30856
|
-
|
|
30782
|
+
}, index, length;
|
|
30783
|
+
function collectType(type3) {
|
|
30784
|
+
if (type3.multi) {
|
|
30785
|
+
result.multi[type3.kind].push(type3);
|
|
30786
|
+
result.multi["fallback"].push(type3);
|
|
30787
|
+
} else {
|
|
30788
|
+
result[type3.kind][type3.tag] = result["fallback"][type3.tag] = type3;
|
|
30857
30789
|
}
|
|
30858
30790
|
}
|
|
30859
|
-
|
|
30860
|
-
|
|
30861
|
-
}
|
|
30862
|
-
if (!fs7.existsSync(instancesFile)) {
|
|
30863
|
-
const header = `# PostgreSQL instances to monitor
|
|
30864
|
-
` + `# Add your instances using: pgai mon targets add <connection-string> <name>
|
|
30865
|
-
|
|
30866
|
-
`;
|
|
30867
|
-
fs7.writeFileSync(instancesFile, header, { encoding: "utf8", mode: 384 });
|
|
30868
|
-
}
|
|
30869
|
-
const pgwatchConfig = path7.resolve(projectDir, ".pgwatch-config");
|
|
30870
|
-
if (!fs7.existsSync(pgwatchConfig)) {
|
|
30871
|
-
fs7.writeFileSync(pgwatchConfig, "", { encoding: "utf8", mode: 384 });
|
|
30872
|
-
}
|
|
30873
|
-
const envFile = path7.resolve(projectDir, ".env");
|
|
30874
|
-
if (!fs7.existsSync(envFile)) {
|
|
30875
|
-
const envText = `PGAI_TAG=${package_default.version}
|
|
30876
|
-
# PGAI_REGISTRY=registry.gitlab.com/postgres-ai/postgres_ai
|
|
30877
|
-
`;
|
|
30878
|
-
fs7.writeFileSync(envFile, envText, { encoding: "utf8", mode: 384 });
|
|
30791
|
+
for (index = 0, length = arguments.length;index < length; index += 1) {
|
|
30792
|
+
arguments[index].forEach(collectType);
|
|
30879
30793
|
}
|
|
30880
|
-
return
|
|
30794
|
+
return result;
|
|
30881
30795
|
}
|
|
30882
|
-
function
|
|
30883
|
-
|
|
30884
|
-
if (!apiKey) {
|
|
30885
|
-
const fileConfig = readConfig();
|
|
30886
|
-
if (!apiKey)
|
|
30887
|
-
apiKey = fileConfig.apiKey || "";
|
|
30888
|
-
}
|
|
30889
|
-
return { apiKey };
|
|
30796
|
+
function Schema$12(definition) {
|
|
30797
|
+
return this.extend(definition);
|
|
30890
30798
|
}
|
|
30891
|
-
function
|
|
30892
|
-
|
|
30893
|
-
|
|
30894
|
-
|
|
30895
|
-
|
|
30896
|
-
|
|
30897
|
-
|
|
30898
|
-
if (
|
|
30899
|
-
|
|
30799
|
+
Schema$12.prototype.extend = function extend5(definition) {
|
|
30800
|
+
var implicit = [];
|
|
30801
|
+
var explicit = [];
|
|
30802
|
+
if (definition instanceof type2) {
|
|
30803
|
+
explicit.push(definition);
|
|
30804
|
+
} else if (Array.isArray(definition)) {
|
|
30805
|
+
explicit = explicit.concat(definition);
|
|
30806
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
30807
|
+
if (definition.implicit)
|
|
30808
|
+
implicit = implicit.concat(definition.implicit);
|
|
30809
|
+
if (definition.explicit)
|
|
30810
|
+
explicit = explicit.concat(definition.explicit);
|
|
30900
30811
|
} else {
|
|
30901
|
-
|
|
30902
|
-
|
|
30903
|
-
|
|
30904
|
-
|
|
30905
|
-
-
|
|
30812
|
+
throw new exception2("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
30813
|
+
}
|
|
30814
|
+
implicit.forEach(function(type$1) {
|
|
30815
|
+
if (!(type$1 instanceof type2)) {
|
|
30816
|
+
throw new exception2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
30906
30817
|
}
|
|
30907
|
-
|
|
30818
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
30819
|
+
throw new exception2("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
30820
|
+
}
|
|
30821
|
+
if (type$1.multi) {
|
|
30822
|
+
throw new exception2("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
30823
|
+
}
|
|
30824
|
+
});
|
|
30825
|
+
explicit.forEach(function(type$1) {
|
|
30826
|
+
if (!(type$1 instanceof type2)) {
|
|
30827
|
+
throw new exception2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
30828
|
+
}
|
|
30829
|
+
});
|
|
30830
|
+
var result = Object.create(Schema$12.prototype);
|
|
30831
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
30832
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
30833
|
+
result.compiledImplicit = compileList2(result, "implicit");
|
|
30834
|
+
result.compiledExplicit = compileList2(result, "explicit");
|
|
30835
|
+
result.compiledTypeMap = compileMap2(result.compiledImplicit, result.compiledExplicit);
|
|
30836
|
+
return result;
|
|
30837
|
+
};
|
|
30838
|
+
var schema2 = Schema$12;
|
|
30839
|
+
var str2 = new type2("tag:yaml.org,2002:str", {
|
|
30840
|
+
kind: "scalar",
|
|
30841
|
+
construct: function(data) {
|
|
30842
|
+
return data !== null ? data : "";
|
|
30908
30843
|
}
|
|
30909
|
-
}
|
|
30910
|
-
var
|
|
30911
|
-
|
|
30912
|
-
|
|
30913
|
-
|
|
30914
|
-
if (!value) {
|
|
30915
|
-
console.error("Error: project is required");
|
|
30916
|
-
process.exitCode = 1;
|
|
30917
|
-
return;
|
|
30844
|
+
});
|
|
30845
|
+
var seq2 = new type2("tag:yaml.org,2002:seq", {
|
|
30846
|
+
kind: "sequence",
|
|
30847
|
+
construct: function(data) {
|
|
30848
|
+
return data !== null ? data : [];
|
|
30918
30849
|
}
|
|
30919
|
-
writeConfig({ defaultProject: value });
|
|
30920
|
-
console.log(`Default project saved: ${value}`);
|
|
30921
30850
|
});
|
|
30922
|
-
|
|
30923
|
-
|
|
30924
|
-
|
|
30925
|
-
|
|
30926
|
-
process.exitCode = 1;
|
|
30927
|
-
return;
|
|
30851
|
+
var map3 = new type2("tag:yaml.org,2002:map", {
|
|
30852
|
+
kind: "mapping",
|
|
30853
|
+
construct: function(data) {
|
|
30854
|
+
return data !== null ? data : {};
|
|
30928
30855
|
}
|
|
30929
|
-
|
|
30930
|
-
|
|
30931
|
-
|
|
30932
|
-
|
|
30856
|
+
});
|
|
30857
|
+
var failsafe2 = new schema2({
|
|
30858
|
+
explicit: [
|
|
30859
|
+
str2,
|
|
30860
|
+
seq2,
|
|
30861
|
+
map3
|
|
30862
|
+
]
|
|
30863
|
+
});
|
|
30864
|
+
function resolveYamlNull2(data) {
|
|
30865
|
+
if (data === null)
|
|
30866
|
+
return true;
|
|
30867
|
+
var max = data.length;
|
|
30868
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
30869
|
+
}
|
|
30870
|
+
function constructYamlNull2() {
|
|
30871
|
+
return null;
|
|
30872
|
+
}
|
|
30873
|
+
function isNull2(object4) {
|
|
30874
|
+
return object4 === null;
|
|
30875
|
+
}
|
|
30876
|
+
var _null5 = new type2("tag:yaml.org,2002:null", {
|
|
30877
|
+
kind: "scalar",
|
|
30878
|
+
resolve: resolveYamlNull2,
|
|
30879
|
+
construct: constructYamlNull2,
|
|
30880
|
+
predicate: isNull2,
|
|
30881
|
+
represent: {
|
|
30882
|
+
canonical: function() {
|
|
30883
|
+
return "~";
|
|
30884
|
+
},
|
|
30885
|
+
lowercase: function() {
|
|
30886
|
+
return "null";
|
|
30887
|
+
},
|
|
30888
|
+
uppercase: function() {
|
|
30889
|
+
return "NULL";
|
|
30890
|
+
},
|
|
30891
|
+
camelcase: function() {
|
|
30892
|
+
return "Null";
|
|
30893
|
+
},
|
|
30894
|
+
empty: function() {
|
|
30895
|
+
return "";
|
|
30896
|
+
}
|
|
30897
|
+
},
|
|
30898
|
+
defaultStyle: "lowercase"
|
|
30899
|
+
});
|
|
30900
|
+
function resolveYamlBoolean2(data) {
|
|
30901
|
+
if (data === null)
|
|
30902
|
+
return false;
|
|
30903
|
+
var max = data.length;
|
|
30904
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
30905
|
+
}
|
|
30906
|
+
function constructYamlBoolean2(data) {
|
|
30907
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
30908
|
+
}
|
|
30909
|
+
function isBoolean2(object4) {
|
|
30910
|
+
return Object.prototype.toString.call(object4) === "[object Boolean]";
|
|
30911
|
+
}
|
|
30912
|
+
var bool2 = new type2("tag:yaml.org,2002:bool", {
|
|
30913
|
+
kind: "scalar",
|
|
30914
|
+
resolve: resolveYamlBoolean2,
|
|
30915
|
+
construct: constructYamlBoolean2,
|
|
30916
|
+
predicate: isBoolean2,
|
|
30917
|
+
represent: {
|
|
30918
|
+
lowercase: function(object4) {
|
|
30919
|
+
return object4 ? "true" : "false";
|
|
30920
|
+
},
|
|
30921
|
+
uppercase: function(object4) {
|
|
30922
|
+
return object4 ? "TRUE" : "FALSE";
|
|
30923
|
+
},
|
|
30924
|
+
camelcase: function(object4) {
|
|
30925
|
+
return object4 ? "True" : "False";
|
|
30926
|
+
}
|
|
30927
|
+
},
|
|
30928
|
+
defaultStyle: "lowercase"
|
|
30929
|
+
});
|
|
30930
|
+
function isHexCode2(c) {
|
|
30931
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
30932
|
+
}
|
|
30933
|
+
function isOctCode2(c) {
|
|
30934
|
+
return 48 <= c && c <= 55;
|
|
30935
|
+
}
|
|
30936
|
+
function isDecCode2(c) {
|
|
30937
|
+
return 48 <= c && c <= 57;
|
|
30938
|
+
}
|
|
30939
|
+
function resolveYamlInteger2(data) {
|
|
30940
|
+
if (data === null)
|
|
30941
|
+
return false;
|
|
30942
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
30943
|
+
if (!max)
|
|
30944
|
+
return false;
|
|
30945
|
+
ch = data[index];
|
|
30946
|
+
if (ch === "-" || ch === "+") {
|
|
30947
|
+
ch = data[++index];
|
|
30948
|
+
}
|
|
30949
|
+
if (ch === "0") {
|
|
30950
|
+
if (index + 1 === max)
|
|
30951
|
+
return true;
|
|
30952
|
+
ch = data[++index];
|
|
30953
|
+
if (ch === "b") {
|
|
30954
|
+
index++;
|
|
30955
|
+
for (;index < max; index++) {
|
|
30956
|
+
ch = data[index];
|
|
30957
|
+
if (ch === "_")
|
|
30958
|
+
continue;
|
|
30959
|
+
if (ch !== "0" && ch !== "1")
|
|
30960
|
+
return false;
|
|
30961
|
+
hasDigits = true;
|
|
30962
|
+
}
|
|
30963
|
+
return hasDigits && ch !== "_";
|
|
30964
|
+
}
|
|
30965
|
+
if (ch === "x") {
|
|
30966
|
+
index++;
|
|
30967
|
+
for (;index < max; index++) {
|
|
30968
|
+
ch = data[index];
|
|
30969
|
+
if (ch === "_")
|
|
30970
|
+
continue;
|
|
30971
|
+
if (!isHexCode2(data.charCodeAt(index)))
|
|
30972
|
+
return false;
|
|
30973
|
+
hasDigits = true;
|
|
30974
|
+
}
|
|
30975
|
+
return hasDigits && ch !== "_";
|
|
30976
|
+
}
|
|
30977
|
+
if (ch === "o") {
|
|
30978
|
+
index++;
|
|
30979
|
+
for (;index < max; index++) {
|
|
30980
|
+
ch = data[index];
|
|
30981
|
+
if (ch === "_")
|
|
30982
|
+
continue;
|
|
30983
|
+
if (!isOctCode2(data.charCodeAt(index)))
|
|
30984
|
+
return false;
|
|
30985
|
+
hasDigits = true;
|
|
30986
|
+
}
|
|
30987
|
+
return hasDigits && ch !== "_";
|
|
30988
|
+
}
|
|
30989
|
+
}
|
|
30990
|
+
if (ch === "_")
|
|
30991
|
+
return false;
|
|
30992
|
+
for (;index < max; index++) {
|
|
30993
|
+
ch = data[index];
|
|
30994
|
+
if (ch === "_")
|
|
30995
|
+
continue;
|
|
30996
|
+
if (!isDecCode2(data.charCodeAt(index))) {
|
|
30997
|
+
return false;
|
|
30998
|
+
}
|
|
30999
|
+
hasDigits = true;
|
|
31000
|
+
}
|
|
31001
|
+
if (!hasDigits || ch === "_")
|
|
31002
|
+
return false;
|
|
31003
|
+
return true;
|
|
31004
|
+
}
|
|
31005
|
+
function constructYamlInteger2(data) {
|
|
31006
|
+
var value = data, sign = 1, ch;
|
|
31007
|
+
if (value.indexOf("_") !== -1) {
|
|
31008
|
+
value = value.replace(/_/g, "");
|
|
31009
|
+
}
|
|
31010
|
+
ch = value[0];
|
|
31011
|
+
if (ch === "-" || ch === "+") {
|
|
31012
|
+
if (ch === "-")
|
|
31013
|
+
sign = -1;
|
|
31014
|
+
value = value.slice(1);
|
|
31015
|
+
ch = value[0];
|
|
31016
|
+
}
|
|
31017
|
+
if (value === "0")
|
|
31018
|
+
return 0;
|
|
31019
|
+
if (ch === "0") {
|
|
31020
|
+
if (value[1] === "b")
|
|
31021
|
+
return sign * parseInt(value.slice(2), 2);
|
|
31022
|
+
if (value[1] === "x")
|
|
31023
|
+
return sign * parseInt(value.slice(2), 16);
|
|
31024
|
+
if (value[1] === "o")
|
|
31025
|
+
return sign * parseInt(value.slice(2), 8);
|
|
31026
|
+
}
|
|
31027
|
+
return sign * parseInt(value, 10);
|
|
31028
|
+
}
|
|
31029
|
+
function isInteger2(object4) {
|
|
31030
|
+
return Object.prototype.toString.call(object4) === "[object Number]" && (object4 % 1 === 0 && !common2.isNegativeZero(object4));
|
|
31031
|
+
}
|
|
31032
|
+
var int3 = new type2("tag:yaml.org,2002:int", {
|
|
31033
|
+
kind: "scalar",
|
|
31034
|
+
resolve: resolveYamlInteger2,
|
|
31035
|
+
construct: constructYamlInteger2,
|
|
31036
|
+
predicate: isInteger2,
|
|
31037
|
+
represent: {
|
|
31038
|
+
binary: function(obj) {
|
|
31039
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
31040
|
+
},
|
|
31041
|
+
octal: function(obj) {
|
|
31042
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
31043
|
+
},
|
|
31044
|
+
decimal: function(obj) {
|
|
31045
|
+
return obj.toString(10);
|
|
31046
|
+
},
|
|
31047
|
+
hexadecimal: function(obj) {
|
|
31048
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
31049
|
+
}
|
|
31050
|
+
},
|
|
31051
|
+
defaultStyle: "decimal",
|
|
31052
|
+
styleAliases: {
|
|
31053
|
+
binary: [2, "bin"],
|
|
31054
|
+
octal: [8, "oct"],
|
|
31055
|
+
decimal: [10, "dec"],
|
|
31056
|
+
hexadecimal: [16, "hex"]
|
|
31057
|
+
}
|
|
31058
|
+
});
|
|
31059
|
+
var YAML_FLOAT_PATTERN2 = new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?" + "|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?" + "|[-+]?\\.(?:inf|Inf|INF)" + "|\\.(?:nan|NaN|NAN))$");
|
|
31060
|
+
function resolveYamlFloat2(data) {
|
|
31061
|
+
if (data === null)
|
|
31062
|
+
return false;
|
|
31063
|
+
if (!YAML_FLOAT_PATTERN2.test(data) || data[data.length - 1] === "_") {
|
|
31064
|
+
return false;
|
|
31065
|
+
}
|
|
31066
|
+
return true;
|
|
31067
|
+
}
|
|
31068
|
+
function constructYamlFloat2(data) {
|
|
31069
|
+
var value, sign;
|
|
31070
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
31071
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
31072
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
31073
|
+
value = value.slice(1);
|
|
31074
|
+
}
|
|
31075
|
+
if (value === ".inf") {
|
|
31076
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
31077
|
+
} else if (value === ".nan") {
|
|
31078
|
+
return NaN;
|
|
31079
|
+
}
|
|
31080
|
+
return sign * parseFloat(value, 10);
|
|
31081
|
+
}
|
|
31082
|
+
var SCIENTIFIC_WITHOUT_DOT2 = /^[-+]?[0-9]+e/;
|
|
31083
|
+
function representYamlFloat2(object4, style) {
|
|
31084
|
+
var res;
|
|
31085
|
+
if (isNaN(object4)) {
|
|
31086
|
+
switch (style) {
|
|
31087
|
+
case "lowercase":
|
|
31088
|
+
return ".nan";
|
|
31089
|
+
case "uppercase":
|
|
31090
|
+
return ".NAN";
|
|
31091
|
+
case "camelcase":
|
|
31092
|
+
return ".NaN";
|
|
31093
|
+
}
|
|
31094
|
+
} else if (Number.POSITIVE_INFINITY === object4) {
|
|
31095
|
+
switch (style) {
|
|
31096
|
+
case "lowercase":
|
|
31097
|
+
return ".inf";
|
|
31098
|
+
case "uppercase":
|
|
31099
|
+
return ".INF";
|
|
31100
|
+
case "camelcase":
|
|
31101
|
+
return ".Inf";
|
|
31102
|
+
}
|
|
31103
|
+
} else if (Number.NEGATIVE_INFINITY === object4) {
|
|
31104
|
+
switch (style) {
|
|
31105
|
+
case "lowercase":
|
|
31106
|
+
return "-.inf";
|
|
31107
|
+
case "uppercase":
|
|
31108
|
+
return "-.INF";
|
|
31109
|
+
case "camelcase":
|
|
31110
|
+
return "-.Inf";
|
|
31111
|
+
}
|
|
31112
|
+
} else if (common2.isNegativeZero(object4)) {
|
|
31113
|
+
return "-0.0";
|
|
31114
|
+
}
|
|
31115
|
+
res = object4.toString(10);
|
|
31116
|
+
return SCIENTIFIC_WITHOUT_DOT2.test(res) ? res.replace("e", ".e") : res;
|
|
31117
|
+
}
|
|
31118
|
+
function isFloat2(object4) {
|
|
31119
|
+
return Object.prototype.toString.call(object4) === "[object Number]" && (object4 % 1 !== 0 || common2.isNegativeZero(object4));
|
|
31120
|
+
}
|
|
31121
|
+
var float2 = new type2("tag:yaml.org,2002:float", {
|
|
31122
|
+
kind: "scalar",
|
|
31123
|
+
resolve: resolveYamlFloat2,
|
|
31124
|
+
construct: constructYamlFloat2,
|
|
31125
|
+
predicate: isFloat2,
|
|
31126
|
+
represent: representYamlFloat2,
|
|
31127
|
+
defaultStyle: "lowercase"
|
|
31128
|
+
});
|
|
31129
|
+
var json2 = failsafe2.extend({
|
|
31130
|
+
implicit: [
|
|
31131
|
+
_null5,
|
|
31132
|
+
bool2,
|
|
31133
|
+
int3,
|
|
31134
|
+
float2
|
|
31135
|
+
]
|
|
31136
|
+
});
|
|
31137
|
+
var core3 = json2;
|
|
31138
|
+
var YAML_DATE_REGEXP2 = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
|
|
31139
|
+
var YAML_TIMESTAMP_REGEXP2 = new RegExp("^([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]))?))?$");
|
|
31140
|
+
function resolveYamlTimestamp2(data) {
|
|
31141
|
+
if (data === null)
|
|
31142
|
+
return false;
|
|
31143
|
+
if (YAML_DATE_REGEXP2.exec(data) !== null)
|
|
31144
|
+
return true;
|
|
31145
|
+
if (YAML_TIMESTAMP_REGEXP2.exec(data) !== null)
|
|
31146
|
+
return true;
|
|
31147
|
+
return false;
|
|
31148
|
+
}
|
|
31149
|
+
function constructYamlTimestamp2(data) {
|
|
31150
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date4;
|
|
31151
|
+
match = YAML_DATE_REGEXP2.exec(data);
|
|
31152
|
+
if (match === null)
|
|
31153
|
+
match = YAML_TIMESTAMP_REGEXP2.exec(data);
|
|
31154
|
+
if (match === null)
|
|
31155
|
+
throw new Error("Date resolve error");
|
|
31156
|
+
year = +match[1];
|
|
31157
|
+
month = +match[2] - 1;
|
|
31158
|
+
day = +match[3];
|
|
31159
|
+
if (!match[4]) {
|
|
31160
|
+
return new Date(Date.UTC(year, month, day));
|
|
31161
|
+
}
|
|
31162
|
+
hour = +match[4];
|
|
31163
|
+
minute = +match[5];
|
|
31164
|
+
second = +match[6];
|
|
31165
|
+
if (match[7]) {
|
|
31166
|
+
fraction = match[7].slice(0, 3);
|
|
31167
|
+
while (fraction.length < 3) {
|
|
31168
|
+
fraction += "0";
|
|
31169
|
+
}
|
|
31170
|
+
fraction = +fraction;
|
|
31171
|
+
}
|
|
31172
|
+
if (match[9]) {
|
|
31173
|
+
tz_hour = +match[10];
|
|
31174
|
+
tz_minute = +(match[11] || 0);
|
|
31175
|
+
delta = (tz_hour * 60 + tz_minute) * 60000;
|
|
31176
|
+
if (match[9] === "-")
|
|
31177
|
+
delta = -delta;
|
|
31178
|
+
}
|
|
31179
|
+
date4 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
31180
|
+
if (delta)
|
|
31181
|
+
date4.setTime(date4.getTime() - delta);
|
|
31182
|
+
return date4;
|
|
31183
|
+
}
|
|
31184
|
+
function representYamlTimestamp2(object4) {
|
|
31185
|
+
return object4.toISOString();
|
|
31186
|
+
}
|
|
31187
|
+
var timestamp2 = new type2("tag:yaml.org,2002:timestamp", {
|
|
31188
|
+
kind: "scalar",
|
|
31189
|
+
resolve: resolveYamlTimestamp2,
|
|
31190
|
+
construct: constructYamlTimestamp2,
|
|
31191
|
+
instanceOf: Date,
|
|
31192
|
+
represent: representYamlTimestamp2
|
|
31193
|
+
});
|
|
31194
|
+
function resolveYamlMerge2(data) {
|
|
31195
|
+
return data === "<<" || data === null;
|
|
31196
|
+
}
|
|
31197
|
+
var merge3 = new type2("tag:yaml.org,2002:merge", {
|
|
31198
|
+
kind: "scalar",
|
|
31199
|
+
resolve: resolveYamlMerge2
|
|
31200
|
+
});
|
|
31201
|
+
var BASE64_MAP2 = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
31202
|
+
\r`;
|
|
31203
|
+
function resolveYamlBinary2(data) {
|
|
31204
|
+
if (data === null)
|
|
31205
|
+
return false;
|
|
31206
|
+
var code, idx, bitlen = 0, max = data.length, map4 = BASE64_MAP2;
|
|
31207
|
+
for (idx = 0;idx < max; idx++) {
|
|
31208
|
+
code = map4.indexOf(data.charAt(idx));
|
|
31209
|
+
if (code > 64)
|
|
31210
|
+
continue;
|
|
31211
|
+
if (code < 0)
|
|
31212
|
+
return false;
|
|
31213
|
+
bitlen += 6;
|
|
31214
|
+
}
|
|
31215
|
+
return bitlen % 8 === 0;
|
|
31216
|
+
}
|
|
31217
|
+
function constructYamlBinary2(data) {
|
|
31218
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map4 = BASE64_MAP2, bits = 0, result = [];
|
|
31219
|
+
for (idx = 0;idx < max; idx++) {
|
|
31220
|
+
if (idx % 4 === 0 && idx) {
|
|
31221
|
+
result.push(bits >> 16 & 255);
|
|
31222
|
+
result.push(bits >> 8 & 255);
|
|
31223
|
+
result.push(bits & 255);
|
|
31224
|
+
}
|
|
31225
|
+
bits = bits << 6 | map4.indexOf(input.charAt(idx));
|
|
31226
|
+
}
|
|
31227
|
+
tailbits = max % 4 * 6;
|
|
31228
|
+
if (tailbits === 0) {
|
|
31229
|
+
result.push(bits >> 16 & 255);
|
|
31230
|
+
result.push(bits >> 8 & 255);
|
|
31231
|
+
result.push(bits & 255);
|
|
31232
|
+
} else if (tailbits === 18) {
|
|
31233
|
+
result.push(bits >> 10 & 255);
|
|
31234
|
+
result.push(bits >> 2 & 255);
|
|
31235
|
+
} else if (tailbits === 12) {
|
|
31236
|
+
result.push(bits >> 4 & 255);
|
|
31237
|
+
}
|
|
31238
|
+
return new Uint8Array(result);
|
|
31239
|
+
}
|
|
31240
|
+
function representYamlBinary2(object4) {
|
|
31241
|
+
var result = "", bits = 0, idx, tail, max = object4.length, map4 = BASE64_MAP2;
|
|
31242
|
+
for (idx = 0;idx < max; idx++) {
|
|
31243
|
+
if (idx % 3 === 0 && idx) {
|
|
31244
|
+
result += map4[bits >> 18 & 63];
|
|
31245
|
+
result += map4[bits >> 12 & 63];
|
|
31246
|
+
result += map4[bits >> 6 & 63];
|
|
31247
|
+
result += map4[bits & 63];
|
|
31248
|
+
}
|
|
31249
|
+
bits = (bits << 8) + object4[idx];
|
|
31250
|
+
}
|
|
31251
|
+
tail = max % 3;
|
|
31252
|
+
if (tail === 0) {
|
|
31253
|
+
result += map4[bits >> 18 & 63];
|
|
31254
|
+
result += map4[bits >> 12 & 63];
|
|
31255
|
+
result += map4[bits >> 6 & 63];
|
|
31256
|
+
result += map4[bits & 63];
|
|
31257
|
+
} else if (tail === 2) {
|
|
31258
|
+
result += map4[bits >> 10 & 63];
|
|
31259
|
+
result += map4[bits >> 4 & 63];
|
|
31260
|
+
result += map4[bits << 2 & 63];
|
|
31261
|
+
result += map4[64];
|
|
31262
|
+
} else if (tail === 1) {
|
|
31263
|
+
result += map4[bits >> 2 & 63];
|
|
31264
|
+
result += map4[bits << 4 & 63];
|
|
31265
|
+
result += map4[64];
|
|
31266
|
+
result += map4[64];
|
|
31267
|
+
}
|
|
31268
|
+
return result;
|
|
31269
|
+
}
|
|
31270
|
+
function isBinary2(obj) {
|
|
31271
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
31272
|
+
}
|
|
31273
|
+
var binary2 = new type2("tag:yaml.org,2002:binary", {
|
|
31274
|
+
kind: "scalar",
|
|
31275
|
+
resolve: resolveYamlBinary2,
|
|
31276
|
+
construct: constructYamlBinary2,
|
|
31277
|
+
predicate: isBinary2,
|
|
31278
|
+
represent: representYamlBinary2
|
|
31279
|
+
});
|
|
31280
|
+
var _hasOwnProperty$32 = Object.prototype.hasOwnProperty;
|
|
31281
|
+
var _toString$22 = Object.prototype.toString;
|
|
31282
|
+
function resolveYamlOmap2(data) {
|
|
31283
|
+
if (data === null)
|
|
31284
|
+
return true;
|
|
31285
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object4 = data;
|
|
31286
|
+
for (index = 0, length = object4.length;index < length; index += 1) {
|
|
31287
|
+
pair = object4[index];
|
|
31288
|
+
pairHasKey = false;
|
|
31289
|
+
if (_toString$22.call(pair) !== "[object Object]")
|
|
31290
|
+
return false;
|
|
31291
|
+
for (pairKey in pair) {
|
|
31292
|
+
if (_hasOwnProperty$32.call(pair, pairKey)) {
|
|
31293
|
+
if (!pairHasKey)
|
|
31294
|
+
pairHasKey = true;
|
|
31295
|
+
else
|
|
31296
|
+
return false;
|
|
31297
|
+
}
|
|
31298
|
+
}
|
|
31299
|
+
if (!pairHasKey)
|
|
31300
|
+
return false;
|
|
31301
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
31302
|
+
objectKeys.push(pairKey);
|
|
31303
|
+
else
|
|
31304
|
+
return false;
|
|
31305
|
+
}
|
|
31306
|
+
return true;
|
|
31307
|
+
}
|
|
31308
|
+
function constructYamlOmap2(data) {
|
|
31309
|
+
return data !== null ? data : [];
|
|
31310
|
+
}
|
|
31311
|
+
var omap2 = new type2("tag:yaml.org,2002:omap", {
|
|
31312
|
+
kind: "sequence",
|
|
31313
|
+
resolve: resolveYamlOmap2,
|
|
31314
|
+
construct: constructYamlOmap2
|
|
31315
|
+
});
|
|
31316
|
+
var _toString$12 = Object.prototype.toString;
|
|
31317
|
+
function resolveYamlPairs2(data) {
|
|
31318
|
+
if (data === null)
|
|
31319
|
+
return true;
|
|
31320
|
+
var index, length, pair, keys, result, object4 = data;
|
|
31321
|
+
result = new Array(object4.length);
|
|
31322
|
+
for (index = 0, length = object4.length;index < length; index += 1) {
|
|
31323
|
+
pair = object4[index];
|
|
31324
|
+
if (_toString$12.call(pair) !== "[object Object]")
|
|
31325
|
+
return false;
|
|
31326
|
+
keys = Object.keys(pair);
|
|
31327
|
+
if (keys.length !== 1)
|
|
31328
|
+
return false;
|
|
31329
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
31330
|
+
}
|
|
31331
|
+
return true;
|
|
31332
|
+
}
|
|
31333
|
+
function constructYamlPairs2(data) {
|
|
31334
|
+
if (data === null)
|
|
31335
|
+
return [];
|
|
31336
|
+
var index, length, pair, keys, result, object4 = data;
|
|
31337
|
+
result = new Array(object4.length);
|
|
31338
|
+
for (index = 0, length = object4.length;index < length; index += 1) {
|
|
31339
|
+
pair = object4[index];
|
|
31340
|
+
keys = Object.keys(pair);
|
|
31341
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
31342
|
+
}
|
|
31343
|
+
return result;
|
|
31344
|
+
}
|
|
31345
|
+
var pairs2 = new type2("tag:yaml.org,2002:pairs", {
|
|
31346
|
+
kind: "sequence",
|
|
31347
|
+
resolve: resolveYamlPairs2,
|
|
31348
|
+
construct: constructYamlPairs2
|
|
31349
|
+
});
|
|
31350
|
+
var _hasOwnProperty$22 = Object.prototype.hasOwnProperty;
|
|
31351
|
+
function resolveYamlSet2(data) {
|
|
31352
|
+
if (data === null)
|
|
31353
|
+
return true;
|
|
31354
|
+
var key, object4 = data;
|
|
31355
|
+
for (key in object4) {
|
|
31356
|
+
if (_hasOwnProperty$22.call(object4, key)) {
|
|
31357
|
+
if (object4[key] !== null)
|
|
31358
|
+
return false;
|
|
31359
|
+
}
|
|
31360
|
+
}
|
|
31361
|
+
return true;
|
|
31362
|
+
}
|
|
31363
|
+
function constructYamlSet2(data) {
|
|
31364
|
+
return data !== null ? data : {};
|
|
31365
|
+
}
|
|
31366
|
+
var set3 = new type2("tag:yaml.org,2002:set", {
|
|
31367
|
+
kind: "mapping",
|
|
31368
|
+
resolve: resolveYamlSet2,
|
|
31369
|
+
construct: constructYamlSet2
|
|
31370
|
+
});
|
|
31371
|
+
var _default3 = core3.extend({
|
|
31372
|
+
implicit: [
|
|
31373
|
+
timestamp2,
|
|
31374
|
+
merge3
|
|
31375
|
+
],
|
|
31376
|
+
explicit: [
|
|
31377
|
+
binary2,
|
|
31378
|
+
omap2,
|
|
31379
|
+
pairs2,
|
|
31380
|
+
set3
|
|
31381
|
+
]
|
|
31382
|
+
});
|
|
31383
|
+
var _hasOwnProperty$12 = Object.prototype.hasOwnProperty;
|
|
31384
|
+
var CONTEXT_FLOW_IN2 = 1;
|
|
31385
|
+
var CONTEXT_FLOW_OUT2 = 2;
|
|
31386
|
+
var CONTEXT_BLOCK_IN2 = 3;
|
|
31387
|
+
var CONTEXT_BLOCK_OUT2 = 4;
|
|
31388
|
+
var CHOMPING_CLIP2 = 1;
|
|
31389
|
+
var CHOMPING_STRIP2 = 2;
|
|
31390
|
+
var CHOMPING_KEEP2 = 3;
|
|
31391
|
+
var PATTERN_NON_PRINTABLE2 = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
31392
|
+
var PATTERN_NON_ASCII_LINE_BREAKS2 = /[\x85\u2028\u2029]/;
|
|
31393
|
+
var PATTERN_FLOW_INDICATORS2 = /[,\[\]\{\}]/;
|
|
31394
|
+
var PATTERN_TAG_HANDLE2 = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
31395
|
+
var PATTERN_TAG_URI2 = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
31396
|
+
function _class2(obj) {
|
|
31397
|
+
return Object.prototype.toString.call(obj);
|
|
31398
|
+
}
|
|
31399
|
+
function is_EOL2(c) {
|
|
31400
|
+
return c === 10 || c === 13;
|
|
31401
|
+
}
|
|
31402
|
+
function is_WHITE_SPACE2(c) {
|
|
31403
|
+
return c === 9 || c === 32;
|
|
31404
|
+
}
|
|
31405
|
+
function is_WS_OR_EOL2(c) {
|
|
31406
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
31407
|
+
}
|
|
31408
|
+
function is_FLOW_INDICATOR2(c) {
|
|
31409
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
31410
|
+
}
|
|
31411
|
+
function fromHexCode2(c) {
|
|
31412
|
+
var lc;
|
|
31413
|
+
if (48 <= c && c <= 57) {
|
|
31414
|
+
return c - 48;
|
|
31415
|
+
}
|
|
31416
|
+
lc = c | 32;
|
|
31417
|
+
if (97 <= lc && lc <= 102) {
|
|
31418
|
+
return lc - 97 + 10;
|
|
31419
|
+
}
|
|
31420
|
+
return -1;
|
|
31421
|
+
}
|
|
31422
|
+
function escapedHexLen2(c) {
|
|
31423
|
+
if (c === 120) {
|
|
31424
|
+
return 2;
|
|
31425
|
+
}
|
|
31426
|
+
if (c === 117) {
|
|
31427
|
+
return 4;
|
|
31428
|
+
}
|
|
31429
|
+
if (c === 85) {
|
|
31430
|
+
return 8;
|
|
31431
|
+
}
|
|
31432
|
+
return 0;
|
|
31433
|
+
}
|
|
31434
|
+
function fromDecimalCode2(c) {
|
|
31435
|
+
if (48 <= c && c <= 57) {
|
|
31436
|
+
return c - 48;
|
|
31437
|
+
}
|
|
31438
|
+
return -1;
|
|
31439
|
+
}
|
|
31440
|
+
function simpleEscapeSequence2(c) {
|
|
31441
|
+
return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
|
|
31442
|
+
` : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "
" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
31443
|
+
}
|
|
31444
|
+
function charFromCodepoint2(c) {
|
|
31445
|
+
if (c <= 65535) {
|
|
31446
|
+
return String.fromCharCode(c);
|
|
31447
|
+
}
|
|
31448
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
31449
|
+
}
|
|
31450
|
+
function setProperty2(object4, key, value) {
|
|
31451
|
+
if (key === "__proto__") {
|
|
31452
|
+
Object.defineProperty(object4, key, {
|
|
31453
|
+
configurable: true,
|
|
31454
|
+
enumerable: true,
|
|
31455
|
+
writable: true,
|
|
31456
|
+
value
|
|
31457
|
+
});
|
|
31458
|
+
} else {
|
|
31459
|
+
object4[key] = value;
|
|
31460
|
+
}
|
|
31461
|
+
}
|
|
31462
|
+
var simpleEscapeCheck2 = new Array(256);
|
|
31463
|
+
var simpleEscapeMap2 = new Array(256);
|
|
31464
|
+
for (i2 = 0;i2 < 256; i2++) {
|
|
31465
|
+
simpleEscapeCheck2[i2] = simpleEscapeSequence2(i2) ? 1 : 0;
|
|
31466
|
+
simpleEscapeMap2[i2] = simpleEscapeSequence2(i2);
|
|
31467
|
+
}
|
|
31468
|
+
var i2;
|
|
31469
|
+
function State$12(input, options) {
|
|
31470
|
+
this.input = input;
|
|
31471
|
+
this.filename = options["filename"] || null;
|
|
31472
|
+
this.schema = options["schema"] || _default3;
|
|
31473
|
+
this.onWarning = options["onWarning"] || null;
|
|
31474
|
+
this.legacy = options["legacy"] || false;
|
|
31475
|
+
this.json = options["json"] || false;
|
|
31476
|
+
this.listener = options["listener"] || null;
|
|
31477
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
31478
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
31479
|
+
this.length = input.length;
|
|
31480
|
+
this.position = 0;
|
|
31481
|
+
this.line = 0;
|
|
31482
|
+
this.lineStart = 0;
|
|
31483
|
+
this.lineIndent = 0;
|
|
31484
|
+
this.firstTabInLine = -1;
|
|
31485
|
+
this.documents = [];
|
|
31486
|
+
}
|
|
31487
|
+
function generateError2(state, message) {
|
|
31488
|
+
var mark = {
|
|
31489
|
+
name: state.filename,
|
|
31490
|
+
buffer: state.input.slice(0, -1),
|
|
31491
|
+
position: state.position,
|
|
31492
|
+
line: state.line,
|
|
31493
|
+
column: state.position - state.lineStart
|
|
31494
|
+
};
|
|
31495
|
+
mark.snippet = snippet2(mark);
|
|
31496
|
+
return new exception2(message, mark);
|
|
31497
|
+
}
|
|
31498
|
+
function throwError2(state, message) {
|
|
31499
|
+
throw generateError2(state, message);
|
|
31500
|
+
}
|
|
31501
|
+
function throwWarning2(state, message) {
|
|
31502
|
+
if (state.onWarning) {
|
|
31503
|
+
state.onWarning.call(null, generateError2(state, message));
|
|
31504
|
+
}
|
|
31505
|
+
}
|
|
31506
|
+
var directiveHandlers2 = {
|
|
31507
|
+
YAML: function handleYamlDirective2(state, name, args) {
|
|
31508
|
+
var match, major, minor;
|
|
31509
|
+
if (state.version !== null) {
|
|
31510
|
+
throwError2(state, "duplication of %YAML directive");
|
|
31511
|
+
}
|
|
31512
|
+
if (args.length !== 1) {
|
|
31513
|
+
throwError2(state, "YAML directive accepts exactly one argument");
|
|
31514
|
+
}
|
|
31515
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
31516
|
+
if (match === null) {
|
|
31517
|
+
throwError2(state, "ill-formed argument of the YAML directive");
|
|
31518
|
+
}
|
|
31519
|
+
major = parseInt(match[1], 10);
|
|
31520
|
+
minor = parseInt(match[2], 10);
|
|
31521
|
+
if (major !== 1) {
|
|
31522
|
+
throwError2(state, "unacceptable YAML version of the document");
|
|
31523
|
+
}
|
|
31524
|
+
state.version = args[0];
|
|
31525
|
+
state.checkLineBreaks = minor < 2;
|
|
31526
|
+
if (minor !== 1 && minor !== 2) {
|
|
31527
|
+
throwWarning2(state, "unsupported YAML version of the document");
|
|
31528
|
+
}
|
|
31529
|
+
},
|
|
31530
|
+
TAG: function handleTagDirective2(state, name, args) {
|
|
31531
|
+
var handle, prefix;
|
|
31532
|
+
if (args.length !== 2) {
|
|
31533
|
+
throwError2(state, "TAG directive accepts exactly two arguments");
|
|
31534
|
+
}
|
|
31535
|
+
handle = args[0];
|
|
31536
|
+
prefix = args[1];
|
|
31537
|
+
if (!PATTERN_TAG_HANDLE2.test(handle)) {
|
|
31538
|
+
throwError2(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
31539
|
+
}
|
|
31540
|
+
if (_hasOwnProperty$12.call(state.tagMap, handle)) {
|
|
31541
|
+
throwError2(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
31542
|
+
}
|
|
31543
|
+
if (!PATTERN_TAG_URI2.test(prefix)) {
|
|
31544
|
+
throwError2(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
31545
|
+
}
|
|
31546
|
+
try {
|
|
31547
|
+
prefix = decodeURIComponent(prefix);
|
|
31548
|
+
} catch (err) {
|
|
31549
|
+
throwError2(state, "tag prefix is malformed: " + prefix);
|
|
31550
|
+
}
|
|
31551
|
+
state.tagMap[handle] = prefix;
|
|
31552
|
+
}
|
|
31553
|
+
};
|
|
31554
|
+
function captureSegment2(state, start, end, checkJson) {
|
|
31555
|
+
var _position, _length2, _character, _result;
|
|
31556
|
+
if (start < end) {
|
|
31557
|
+
_result = state.input.slice(start, end);
|
|
31558
|
+
if (checkJson) {
|
|
31559
|
+
for (_position = 0, _length2 = _result.length;_position < _length2; _position += 1) {
|
|
31560
|
+
_character = _result.charCodeAt(_position);
|
|
31561
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
31562
|
+
throwError2(state, "expected valid JSON character");
|
|
31563
|
+
}
|
|
31564
|
+
}
|
|
31565
|
+
} else if (PATTERN_NON_PRINTABLE2.test(_result)) {
|
|
31566
|
+
throwError2(state, "the stream contains non-printable characters");
|
|
31567
|
+
}
|
|
31568
|
+
state.result += _result;
|
|
31569
|
+
}
|
|
31570
|
+
}
|
|
31571
|
+
function mergeMappings2(state, destination, source, overridableKeys) {
|
|
31572
|
+
var sourceKeys, key, index, quantity;
|
|
31573
|
+
if (!common2.isObject(source)) {
|
|
31574
|
+
throwError2(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
31575
|
+
}
|
|
31576
|
+
sourceKeys = Object.keys(source);
|
|
31577
|
+
for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
|
|
31578
|
+
key = sourceKeys[index];
|
|
31579
|
+
if (!_hasOwnProperty$12.call(destination, key)) {
|
|
31580
|
+
setProperty2(destination, key, source[key]);
|
|
31581
|
+
overridableKeys[key] = true;
|
|
31582
|
+
}
|
|
31583
|
+
}
|
|
31584
|
+
}
|
|
31585
|
+
function storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
31586
|
+
var index, quantity;
|
|
31587
|
+
if (Array.isArray(keyNode)) {
|
|
31588
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
31589
|
+
for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
|
|
31590
|
+
if (Array.isArray(keyNode[index])) {
|
|
31591
|
+
throwError2(state, "nested arrays are not supported inside keys");
|
|
31592
|
+
}
|
|
31593
|
+
if (typeof keyNode === "object" && _class2(keyNode[index]) === "[object Object]") {
|
|
31594
|
+
keyNode[index] = "[object Object]";
|
|
31595
|
+
}
|
|
31596
|
+
}
|
|
31597
|
+
}
|
|
31598
|
+
if (typeof keyNode === "object" && _class2(keyNode) === "[object Object]") {
|
|
31599
|
+
keyNode = "[object Object]";
|
|
31600
|
+
}
|
|
31601
|
+
keyNode = String(keyNode);
|
|
31602
|
+
if (_result === null) {
|
|
31603
|
+
_result = {};
|
|
31604
|
+
}
|
|
31605
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
31606
|
+
if (Array.isArray(valueNode)) {
|
|
31607
|
+
for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
|
|
31608
|
+
mergeMappings2(state, _result, valueNode[index], overridableKeys);
|
|
31609
|
+
}
|
|
31610
|
+
} else {
|
|
31611
|
+
mergeMappings2(state, _result, valueNode, overridableKeys);
|
|
31612
|
+
}
|
|
31613
|
+
} else {
|
|
31614
|
+
if (!state.json && !_hasOwnProperty$12.call(overridableKeys, keyNode) && _hasOwnProperty$12.call(_result, keyNode)) {
|
|
31615
|
+
state.line = startLine || state.line;
|
|
31616
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
31617
|
+
state.position = startPos || state.position;
|
|
31618
|
+
throwError2(state, "duplicated mapping key");
|
|
31619
|
+
}
|
|
31620
|
+
setProperty2(_result, keyNode, valueNode);
|
|
31621
|
+
delete overridableKeys[keyNode];
|
|
31622
|
+
}
|
|
31623
|
+
return _result;
|
|
31624
|
+
}
|
|
31625
|
+
function readLineBreak2(state) {
|
|
31626
|
+
var ch;
|
|
31627
|
+
ch = state.input.charCodeAt(state.position);
|
|
31628
|
+
if (ch === 10) {
|
|
31629
|
+
state.position++;
|
|
31630
|
+
} else if (ch === 13) {
|
|
31631
|
+
state.position++;
|
|
31632
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
31633
|
+
state.position++;
|
|
31634
|
+
}
|
|
31635
|
+
} else {
|
|
31636
|
+
throwError2(state, "a line break is expected");
|
|
31637
|
+
}
|
|
31638
|
+
state.line += 1;
|
|
31639
|
+
state.lineStart = state.position;
|
|
31640
|
+
state.firstTabInLine = -1;
|
|
31641
|
+
}
|
|
31642
|
+
function skipSeparationSpace2(state, allowComments, checkIndent) {
|
|
31643
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
31644
|
+
while (ch !== 0) {
|
|
31645
|
+
while (is_WHITE_SPACE2(ch)) {
|
|
31646
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
31647
|
+
state.firstTabInLine = state.position;
|
|
31648
|
+
}
|
|
31649
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31650
|
+
}
|
|
31651
|
+
if (allowComments && ch === 35) {
|
|
31652
|
+
do {
|
|
31653
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31654
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
31655
|
+
}
|
|
31656
|
+
if (is_EOL2(ch)) {
|
|
31657
|
+
readLineBreak2(state);
|
|
31658
|
+
ch = state.input.charCodeAt(state.position);
|
|
31659
|
+
lineBreaks++;
|
|
31660
|
+
state.lineIndent = 0;
|
|
31661
|
+
while (ch === 32) {
|
|
31662
|
+
state.lineIndent++;
|
|
31663
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31664
|
+
}
|
|
31665
|
+
} else {
|
|
31666
|
+
break;
|
|
31667
|
+
}
|
|
31668
|
+
}
|
|
31669
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
31670
|
+
throwWarning2(state, "deficient indentation");
|
|
31671
|
+
}
|
|
31672
|
+
return lineBreaks;
|
|
31673
|
+
}
|
|
31674
|
+
function testDocumentSeparator2(state) {
|
|
31675
|
+
var _position = state.position, ch;
|
|
31676
|
+
ch = state.input.charCodeAt(_position);
|
|
31677
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
31678
|
+
_position += 3;
|
|
31679
|
+
ch = state.input.charCodeAt(_position);
|
|
31680
|
+
if (ch === 0 || is_WS_OR_EOL2(ch)) {
|
|
31681
|
+
return true;
|
|
31682
|
+
}
|
|
31683
|
+
}
|
|
31684
|
+
return false;
|
|
31685
|
+
}
|
|
31686
|
+
function writeFoldedLines2(state, count) {
|
|
31687
|
+
if (count === 1) {
|
|
31688
|
+
state.result += " ";
|
|
31689
|
+
} else if (count > 1) {
|
|
31690
|
+
state.result += common2.repeat(`
|
|
31691
|
+
`, count - 1);
|
|
31692
|
+
}
|
|
31693
|
+
}
|
|
31694
|
+
function readPlainScalar2(state, nodeIndent, withinFlowCollection) {
|
|
31695
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
31696
|
+
ch = state.input.charCodeAt(state.position);
|
|
31697
|
+
if (is_WS_OR_EOL2(ch) || is_FLOW_INDICATOR2(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
31698
|
+
return false;
|
|
31699
|
+
}
|
|
31700
|
+
if (ch === 63 || ch === 45) {
|
|
31701
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
31702
|
+
if (is_WS_OR_EOL2(following) || withinFlowCollection && is_FLOW_INDICATOR2(following)) {
|
|
31703
|
+
return false;
|
|
31704
|
+
}
|
|
31705
|
+
}
|
|
31706
|
+
state.kind = "scalar";
|
|
31707
|
+
state.result = "";
|
|
31708
|
+
captureStart = captureEnd = state.position;
|
|
31709
|
+
hasPendingContent = false;
|
|
31710
|
+
while (ch !== 0) {
|
|
31711
|
+
if (ch === 58) {
|
|
31712
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
31713
|
+
if (is_WS_OR_EOL2(following) || withinFlowCollection && is_FLOW_INDICATOR2(following)) {
|
|
31714
|
+
break;
|
|
31715
|
+
}
|
|
31716
|
+
} else if (ch === 35) {
|
|
31717
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
31718
|
+
if (is_WS_OR_EOL2(preceding)) {
|
|
31719
|
+
break;
|
|
31720
|
+
}
|
|
31721
|
+
} else if (state.position === state.lineStart && testDocumentSeparator2(state) || withinFlowCollection && is_FLOW_INDICATOR2(ch)) {
|
|
31722
|
+
break;
|
|
31723
|
+
} else if (is_EOL2(ch)) {
|
|
31724
|
+
_line = state.line;
|
|
31725
|
+
_lineStart = state.lineStart;
|
|
31726
|
+
_lineIndent = state.lineIndent;
|
|
31727
|
+
skipSeparationSpace2(state, false, -1);
|
|
31728
|
+
if (state.lineIndent >= nodeIndent) {
|
|
31729
|
+
hasPendingContent = true;
|
|
31730
|
+
ch = state.input.charCodeAt(state.position);
|
|
31731
|
+
continue;
|
|
31732
|
+
} else {
|
|
31733
|
+
state.position = captureEnd;
|
|
31734
|
+
state.line = _line;
|
|
31735
|
+
state.lineStart = _lineStart;
|
|
31736
|
+
state.lineIndent = _lineIndent;
|
|
31737
|
+
break;
|
|
31738
|
+
}
|
|
31739
|
+
}
|
|
31740
|
+
if (hasPendingContent) {
|
|
31741
|
+
captureSegment2(state, captureStart, captureEnd, false);
|
|
31742
|
+
writeFoldedLines2(state, state.line - _line);
|
|
31743
|
+
captureStart = captureEnd = state.position;
|
|
31744
|
+
hasPendingContent = false;
|
|
31745
|
+
}
|
|
31746
|
+
if (!is_WHITE_SPACE2(ch)) {
|
|
31747
|
+
captureEnd = state.position + 1;
|
|
31748
|
+
}
|
|
31749
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31750
|
+
}
|
|
31751
|
+
captureSegment2(state, captureStart, captureEnd, false);
|
|
31752
|
+
if (state.result) {
|
|
31753
|
+
return true;
|
|
31754
|
+
}
|
|
31755
|
+
state.kind = _kind;
|
|
31756
|
+
state.result = _result;
|
|
31757
|
+
return false;
|
|
31758
|
+
}
|
|
31759
|
+
function readSingleQuotedScalar2(state, nodeIndent) {
|
|
31760
|
+
var ch, captureStart, captureEnd;
|
|
31761
|
+
ch = state.input.charCodeAt(state.position);
|
|
31762
|
+
if (ch !== 39) {
|
|
31763
|
+
return false;
|
|
31764
|
+
}
|
|
31765
|
+
state.kind = "scalar";
|
|
31766
|
+
state.result = "";
|
|
31767
|
+
state.position++;
|
|
31768
|
+
captureStart = captureEnd = state.position;
|
|
31769
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
31770
|
+
if (ch === 39) {
|
|
31771
|
+
captureSegment2(state, captureStart, state.position, true);
|
|
31772
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31773
|
+
if (ch === 39) {
|
|
31774
|
+
captureStart = state.position;
|
|
31775
|
+
state.position++;
|
|
31776
|
+
captureEnd = state.position;
|
|
31777
|
+
} else {
|
|
31778
|
+
return true;
|
|
31779
|
+
}
|
|
31780
|
+
} else if (is_EOL2(ch)) {
|
|
31781
|
+
captureSegment2(state, captureStart, captureEnd, true);
|
|
31782
|
+
writeFoldedLines2(state, skipSeparationSpace2(state, false, nodeIndent));
|
|
31783
|
+
captureStart = captureEnd = state.position;
|
|
31784
|
+
} else if (state.position === state.lineStart && testDocumentSeparator2(state)) {
|
|
31785
|
+
throwError2(state, "unexpected end of the document within a single quoted scalar");
|
|
31786
|
+
} else {
|
|
31787
|
+
state.position++;
|
|
31788
|
+
captureEnd = state.position;
|
|
31789
|
+
}
|
|
31790
|
+
}
|
|
31791
|
+
throwError2(state, "unexpected end of the stream within a single quoted scalar");
|
|
31792
|
+
}
|
|
31793
|
+
function readDoubleQuotedScalar2(state, nodeIndent) {
|
|
31794
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
31795
|
+
ch = state.input.charCodeAt(state.position);
|
|
31796
|
+
if (ch !== 34) {
|
|
31797
|
+
return false;
|
|
31798
|
+
}
|
|
31799
|
+
state.kind = "scalar";
|
|
31800
|
+
state.result = "";
|
|
31801
|
+
state.position++;
|
|
31802
|
+
captureStart = captureEnd = state.position;
|
|
31803
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
31804
|
+
if (ch === 34) {
|
|
31805
|
+
captureSegment2(state, captureStart, state.position, true);
|
|
31806
|
+
state.position++;
|
|
31807
|
+
return true;
|
|
31808
|
+
} else if (ch === 92) {
|
|
31809
|
+
captureSegment2(state, captureStart, state.position, true);
|
|
31810
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31811
|
+
if (is_EOL2(ch)) {
|
|
31812
|
+
skipSeparationSpace2(state, false, nodeIndent);
|
|
31813
|
+
} else if (ch < 256 && simpleEscapeCheck2[ch]) {
|
|
31814
|
+
state.result += simpleEscapeMap2[ch];
|
|
31815
|
+
state.position++;
|
|
31816
|
+
} else if ((tmp = escapedHexLen2(ch)) > 0) {
|
|
31817
|
+
hexLength = tmp;
|
|
31818
|
+
hexResult = 0;
|
|
31819
|
+
for (;hexLength > 0; hexLength--) {
|
|
31820
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31821
|
+
if ((tmp = fromHexCode2(ch)) >= 0) {
|
|
31822
|
+
hexResult = (hexResult << 4) + tmp;
|
|
31823
|
+
} else {
|
|
31824
|
+
throwError2(state, "expected hexadecimal character");
|
|
31825
|
+
}
|
|
31826
|
+
}
|
|
31827
|
+
state.result += charFromCodepoint2(hexResult);
|
|
31828
|
+
state.position++;
|
|
31829
|
+
} else {
|
|
31830
|
+
throwError2(state, "unknown escape sequence");
|
|
31831
|
+
}
|
|
31832
|
+
captureStart = captureEnd = state.position;
|
|
31833
|
+
} else if (is_EOL2(ch)) {
|
|
31834
|
+
captureSegment2(state, captureStart, captureEnd, true);
|
|
31835
|
+
writeFoldedLines2(state, skipSeparationSpace2(state, false, nodeIndent));
|
|
31836
|
+
captureStart = captureEnd = state.position;
|
|
31837
|
+
} else if (state.position === state.lineStart && testDocumentSeparator2(state)) {
|
|
31838
|
+
throwError2(state, "unexpected end of the document within a double quoted scalar");
|
|
31839
|
+
} else {
|
|
31840
|
+
state.position++;
|
|
31841
|
+
captureEnd = state.position;
|
|
31842
|
+
}
|
|
31843
|
+
}
|
|
31844
|
+
throwError2(state, "unexpected end of the stream within a double quoted scalar");
|
|
31845
|
+
}
|
|
31846
|
+
function readFlowCollection2(state, nodeIndent) {
|
|
31847
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
31848
|
+
ch = state.input.charCodeAt(state.position);
|
|
31849
|
+
if (ch === 91) {
|
|
31850
|
+
terminator = 93;
|
|
31851
|
+
isMapping = false;
|
|
31852
|
+
_result = [];
|
|
31853
|
+
} else if (ch === 123) {
|
|
31854
|
+
terminator = 125;
|
|
31855
|
+
isMapping = true;
|
|
31856
|
+
_result = {};
|
|
31857
|
+
} else {
|
|
31858
|
+
return false;
|
|
31859
|
+
}
|
|
31860
|
+
if (state.anchor !== null) {
|
|
31861
|
+
state.anchorMap[state.anchor] = _result;
|
|
31862
|
+
}
|
|
31863
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31864
|
+
while (ch !== 0) {
|
|
31865
|
+
skipSeparationSpace2(state, true, nodeIndent);
|
|
31866
|
+
ch = state.input.charCodeAt(state.position);
|
|
31867
|
+
if (ch === terminator) {
|
|
31868
|
+
state.position++;
|
|
31869
|
+
state.tag = _tag;
|
|
31870
|
+
state.anchor = _anchor;
|
|
31871
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
31872
|
+
state.result = _result;
|
|
31873
|
+
return true;
|
|
31874
|
+
} else if (!readNext) {
|
|
31875
|
+
throwError2(state, "missed comma between flow collection entries");
|
|
31876
|
+
} else if (ch === 44) {
|
|
31877
|
+
throwError2(state, "expected the node content, but found ','");
|
|
31878
|
+
}
|
|
31879
|
+
keyTag = keyNode = valueNode = null;
|
|
31880
|
+
isPair = isExplicitPair = false;
|
|
31881
|
+
if (ch === 63) {
|
|
31882
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
31883
|
+
if (is_WS_OR_EOL2(following)) {
|
|
31884
|
+
isPair = isExplicitPair = true;
|
|
31885
|
+
state.position++;
|
|
31886
|
+
skipSeparationSpace2(state, true, nodeIndent);
|
|
31887
|
+
}
|
|
31888
|
+
}
|
|
31889
|
+
_line = state.line;
|
|
31890
|
+
_lineStart = state.lineStart;
|
|
31891
|
+
_pos = state.position;
|
|
31892
|
+
composeNode2(state, nodeIndent, CONTEXT_FLOW_IN2, false, true);
|
|
31893
|
+
keyTag = state.tag;
|
|
31894
|
+
keyNode = state.result;
|
|
31895
|
+
skipSeparationSpace2(state, true, nodeIndent);
|
|
31896
|
+
ch = state.input.charCodeAt(state.position);
|
|
31897
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
31898
|
+
isPair = true;
|
|
31899
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31900
|
+
skipSeparationSpace2(state, true, nodeIndent);
|
|
31901
|
+
composeNode2(state, nodeIndent, CONTEXT_FLOW_IN2, false, true);
|
|
31902
|
+
valueNode = state.result;
|
|
31903
|
+
}
|
|
31904
|
+
if (isMapping) {
|
|
31905
|
+
storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
31906
|
+
} else if (isPair) {
|
|
31907
|
+
_result.push(storeMappingPair2(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
31908
|
+
} else {
|
|
31909
|
+
_result.push(keyNode);
|
|
31910
|
+
}
|
|
31911
|
+
skipSeparationSpace2(state, true, nodeIndent);
|
|
31912
|
+
ch = state.input.charCodeAt(state.position);
|
|
31913
|
+
if (ch === 44) {
|
|
31914
|
+
readNext = true;
|
|
31915
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31916
|
+
} else {
|
|
31917
|
+
readNext = false;
|
|
31918
|
+
}
|
|
31919
|
+
}
|
|
31920
|
+
throwError2(state, "unexpected end of the stream within a flow collection");
|
|
31921
|
+
}
|
|
31922
|
+
function readBlockScalar2(state, nodeIndent) {
|
|
31923
|
+
var captureStart, folding, chomping = CHOMPING_CLIP2, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
31924
|
+
ch = state.input.charCodeAt(state.position);
|
|
31925
|
+
if (ch === 124) {
|
|
31926
|
+
folding = false;
|
|
31927
|
+
} else if (ch === 62) {
|
|
31928
|
+
folding = true;
|
|
31929
|
+
} else {
|
|
31930
|
+
return false;
|
|
31931
|
+
}
|
|
31932
|
+
state.kind = "scalar";
|
|
31933
|
+
state.result = "";
|
|
31934
|
+
while (ch !== 0) {
|
|
31935
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31936
|
+
if (ch === 43 || ch === 45) {
|
|
31937
|
+
if (CHOMPING_CLIP2 === chomping) {
|
|
31938
|
+
chomping = ch === 43 ? CHOMPING_KEEP2 : CHOMPING_STRIP2;
|
|
31939
|
+
} else {
|
|
31940
|
+
throwError2(state, "repeat of a chomping mode identifier");
|
|
31941
|
+
}
|
|
31942
|
+
} else if ((tmp = fromDecimalCode2(ch)) >= 0) {
|
|
31943
|
+
if (tmp === 0) {
|
|
31944
|
+
throwError2(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
31945
|
+
} else if (!detectedIndent) {
|
|
31946
|
+
textIndent = nodeIndent + tmp - 1;
|
|
31947
|
+
detectedIndent = true;
|
|
31948
|
+
} else {
|
|
31949
|
+
throwError2(state, "repeat of an indentation width identifier");
|
|
31950
|
+
}
|
|
31951
|
+
} else {
|
|
31952
|
+
break;
|
|
31953
|
+
}
|
|
31954
|
+
}
|
|
31955
|
+
if (is_WHITE_SPACE2(ch)) {
|
|
31956
|
+
do {
|
|
31957
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31958
|
+
} while (is_WHITE_SPACE2(ch));
|
|
31959
|
+
if (ch === 35) {
|
|
31960
|
+
do {
|
|
31961
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31962
|
+
} while (!is_EOL2(ch) && ch !== 0);
|
|
31963
|
+
}
|
|
31964
|
+
}
|
|
31965
|
+
while (ch !== 0) {
|
|
31966
|
+
readLineBreak2(state);
|
|
31967
|
+
state.lineIndent = 0;
|
|
31968
|
+
ch = state.input.charCodeAt(state.position);
|
|
31969
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
31970
|
+
state.lineIndent++;
|
|
31971
|
+
ch = state.input.charCodeAt(++state.position);
|
|
31972
|
+
}
|
|
31973
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
31974
|
+
textIndent = state.lineIndent;
|
|
31975
|
+
}
|
|
31976
|
+
if (is_EOL2(ch)) {
|
|
31977
|
+
emptyLines++;
|
|
31978
|
+
continue;
|
|
31979
|
+
}
|
|
31980
|
+
if (state.lineIndent < textIndent) {
|
|
31981
|
+
if (chomping === CHOMPING_KEEP2) {
|
|
31982
|
+
state.result += common2.repeat(`
|
|
31983
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
31984
|
+
} else if (chomping === CHOMPING_CLIP2) {
|
|
31985
|
+
if (didReadContent) {
|
|
31986
|
+
state.result += `
|
|
31987
|
+
`;
|
|
31988
|
+
}
|
|
31989
|
+
}
|
|
31990
|
+
break;
|
|
31991
|
+
}
|
|
31992
|
+
if (folding) {
|
|
31993
|
+
if (is_WHITE_SPACE2(ch)) {
|
|
31994
|
+
atMoreIndented = true;
|
|
31995
|
+
state.result += common2.repeat(`
|
|
31996
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
31997
|
+
} else if (atMoreIndented) {
|
|
31998
|
+
atMoreIndented = false;
|
|
31999
|
+
state.result += common2.repeat(`
|
|
32000
|
+
`, emptyLines + 1);
|
|
32001
|
+
} else if (emptyLines === 0) {
|
|
32002
|
+
if (didReadContent) {
|
|
32003
|
+
state.result += " ";
|
|
32004
|
+
}
|
|
32005
|
+
} else {
|
|
32006
|
+
state.result += common2.repeat(`
|
|
32007
|
+
`, emptyLines);
|
|
32008
|
+
}
|
|
32009
|
+
} else {
|
|
32010
|
+
state.result += common2.repeat(`
|
|
32011
|
+
`, didReadContent ? 1 + emptyLines : emptyLines);
|
|
32012
|
+
}
|
|
32013
|
+
didReadContent = true;
|
|
32014
|
+
detectedIndent = true;
|
|
32015
|
+
emptyLines = 0;
|
|
32016
|
+
captureStart = state.position;
|
|
32017
|
+
while (!is_EOL2(ch) && ch !== 0) {
|
|
32018
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32019
|
+
}
|
|
32020
|
+
captureSegment2(state, captureStart, state.position, false);
|
|
32021
|
+
}
|
|
32022
|
+
return true;
|
|
32023
|
+
}
|
|
32024
|
+
function readBlockSequence2(state, nodeIndent) {
|
|
32025
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
32026
|
+
if (state.firstTabInLine !== -1)
|
|
32027
|
+
return false;
|
|
32028
|
+
if (state.anchor !== null) {
|
|
32029
|
+
state.anchorMap[state.anchor] = _result;
|
|
32030
|
+
}
|
|
32031
|
+
ch = state.input.charCodeAt(state.position);
|
|
32032
|
+
while (ch !== 0) {
|
|
32033
|
+
if (state.firstTabInLine !== -1) {
|
|
32034
|
+
state.position = state.firstTabInLine;
|
|
32035
|
+
throwError2(state, "tab characters must not be used in indentation");
|
|
32036
|
+
}
|
|
32037
|
+
if (ch !== 45) {
|
|
32038
|
+
break;
|
|
32039
|
+
}
|
|
32040
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
32041
|
+
if (!is_WS_OR_EOL2(following)) {
|
|
32042
|
+
break;
|
|
32043
|
+
}
|
|
32044
|
+
detected = true;
|
|
32045
|
+
state.position++;
|
|
32046
|
+
if (skipSeparationSpace2(state, true, -1)) {
|
|
32047
|
+
if (state.lineIndent <= nodeIndent) {
|
|
32048
|
+
_result.push(null);
|
|
32049
|
+
ch = state.input.charCodeAt(state.position);
|
|
32050
|
+
continue;
|
|
32051
|
+
}
|
|
32052
|
+
}
|
|
32053
|
+
_line = state.line;
|
|
32054
|
+
composeNode2(state, nodeIndent, CONTEXT_BLOCK_IN2, false, true);
|
|
32055
|
+
_result.push(state.result);
|
|
32056
|
+
skipSeparationSpace2(state, true, -1);
|
|
32057
|
+
ch = state.input.charCodeAt(state.position);
|
|
32058
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
32059
|
+
throwError2(state, "bad indentation of a sequence entry");
|
|
32060
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
32061
|
+
break;
|
|
32062
|
+
}
|
|
32063
|
+
}
|
|
32064
|
+
if (detected) {
|
|
32065
|
+
state.tag = _tag;
|
|
32066
|
+
state.anchor = _anchor;
|
|
32067
|
+
state.kind = "sequence";
|
|
32068
|
+
state.result = _result;
|
|
32069
|
+
return true;
|
|
32070
|
+
}
|
|
32071
|
+
return false;
|
|
32072
|
+
}
|
|
32073
|
+
function readBlockMapping2(state, nodeIndent, flowIndent) {
|
|
32074
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
32075
|
+
if (state.firstTabInLine !== -1)
|
|
32076
|
+
return false;
|
|
32077
|
+
if (state.anchor !== null) {
|
|
32078
|
+
state.anchorMap[state.anchor] = _result;
|
|
32079
|
+
}
|
|
32080
|
+
ch = state.input.charCodeAt(state.position);
|
|
32081
|
+
while (ch !== 0) {
|
|
32082
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
32083
|
+
state.position = state.firstTabInLine;
|
|
32084
|
+
throwError2(state, "tab characters must not be used in indentation");
|
|
32085
|
+
}
|
|
32086
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
32087
|
+
_line = state.line;
|
|
32088
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL2(following)) {
|
|
32089
|
+
if (ch === 63) {
|
|
32090
|
+
if (atExplicitKey) {
|
|
32091
|
+
storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
32092
|
+
keyTag = keyNode = valueNode = null;
|
|
32093
|
+
}
|
|
32094
|
+
detected = true;
|
|
32095
|
+
atExplicitKey = true;
|
|
32096
|
+
allowCompact = true;
|
|
32097
|
+
} else if (atExplicitKey) {
|
|
32098
|
+
atExplicitKey = false;
|
|
32099
|
+
allowCompact = true;
|
|
32100
|
+
} else {
|
|
32101
|
+
throwError2(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
32102
|
+
}
|
|
32103
|
+
state.position += 1;
|
|
32104
|
+
ch = following;
|
|
32105
|
+
} else {
|
|
32106
|
+
_keyLine = state.line;
|
|
32107
|
+
_keyLineStart = state.lineStart;
|
|
32108
|
+
_keyPos = state.position;
|
|
32109
|
+
if (!composeNode2(state, flowIndent, CONTEXT_FLOW_OUT2, false, true)) {
|
|
32110
|
+
break;
|
|
32111
|
+
}
|
|
32112
|
+
if (state.line === _line) {
|
|
32113
|
+
ch = state.input.charCodeAt(state.position);
|
|
32114
|
+
while (is_WHITE_SPACE2(ch)) {
|
|
32115
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32116
|
+
}
|
|
32117
|
+
if (ch === 58) {
|
|
32118
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32119
|
+
if (!is_WS_OR_EOL2(ch)) {
|
|
32120
|
+
throwError2(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
32121
|
+
}
|
|
32122
|
+
if (atExplicitKey) {
|
|
32123
|
+
storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
32124
|
+
keyTag = keyNode = valueNode = null;
|
|
32125
|
+
}
|
|
32126
|
+
detected = true;
|
|
32127
|
+
atExplicitKey = false;
|
|
32128
|
+
allowCompact = false;
|
|
32129
|
+
keyTag = state.tag;
|
|
32130
|
+
keyNode = state.result;
|
|
32131
|
+
} else if (detected) {
|
|
32132
|
+
throwError2(state, "can not read an implicit mapping pair; a colon is missed");
|
|
32133
|
+
} else {
|
|
32134
|
+
state.tag = _tag;
|
|
32135
|
+
state.anchor = _anchor;
|
|
32136
|
+
return true;
|
|
32137
|
+
}
|
|
32138
|
+
} else if (detected) {
|
|
32139
|
+
throwError2(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
32140
|
+
} else {
|
|
32141
|
+
state.tag = _tag;
|
|
32142
|
+
state.anchor = _anchor;
|
|
32143
|
+
return true;
|
|
32144
|
+
}
|
|
32145
|
+
}
|
|
32146
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
32147
|
+
if (atExplicitKey) {
|
|
32148
|
+
_keyLine = state.line;
|
|
32149
|
+
_keyLineStart = state.lineStart;
|
|
32150
|
+
_keyPos = state.position;
|
|
32151
|
+
}
|
|
32152
|
+
if (composeNode2(state, nodeIndent, CONTEXT_BLOCK_OUT2, true, allowCompact)) {
|
|
32153
|
+
if (atExplicitKey) {
|
|
32154
|
+
keyNode = state.result;
|
|
32155
|
+
} else {
|
|
32156
|
+
valueNode = state.result;
|
|
32157
|
+
}
|
|
32158
|
+
}
|
|
32159
|
+
if (!atExplicitKey) {
|
|
32160
|
+
storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
32161
|
+
keyTag = keyNode = valueNode = null;
|
|
32162
|
+
}
|
|
32163
|
+
skipSeparationSpace2(state, true, -1);
|
|
32164
|
+
ch = state.input.charCodeAt(state.position);
|
|
32165
|
+
}
|
|
32166
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
32167
|
+
throwError2(state, "bad indentation of a mapping entry");
|
|
32168
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
32169
|
+
break;
|
|
32170
|
+
}
|
|
32171
|
+
}
|
|
32172
|
+
if (atExplicitKey) {
|
|
32173
|
+
storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
32174
|
+
}
|
|
32175
|
+
if (detected) {
|
|
32176
|
+
state.tag = _tag;
|
|
32177
|
+
state.anchor = _anchor;
|
|
32178
|
+
state.kind = "mapping";
|
|
32179
|
+
state.result = _result;
|
|
32180
|
+
}
|
|
32181
|
+
return detected;
|
|
32182
|
+
}
|
|
32183
|
+
function readTagProperty2(state) {
|
|
32184
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
32185
|
+
ch = state.input.charCodeAt(state.position);
|
|
32186
|
+
if (ch !== 33)
|
|
32187
|
+
return false;
|
|
32188
|
+
if (state.tag !== null) {
|
|
32189
|
+
throwError2(state, "duplication of a tag property");
|
|
32190
|
+
}
|
|
32191
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32192
|
+
if (ch === 60) {
|
|
32193
|
+
isVerbatim = true;
|
|
32194
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32195
|
+
} else if (ch === 33) {
|
|
32196
|
+
isNamed = true;
|
|
32197
|
+
tagHandle = "!!";
|
|
32198
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32199
|
+
} else {
|
|
32200
|
+
tagHandle = "!";
|
|
32201
|
+
}
|
|
32202
|
+
_position = state.position;
|
|
32203
|
+
if (isVerbatim) {
|
|
32204
|
+
do {
|
|
32205
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32206
|
+
} while (ch !== 0 && ch !== 62);
|
|
32207
|
+
if (state.position < state.length) {
|
|
32208
|
+
tagName = state.input.slice(_position, state.position);
|
|
32209
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32210
|
+
} else {
|
|
32211
|
+
throwError2(state, "unexpected end of the stream within a verbatim tag");
|
|
32212
|
+
}
|
|
32213
|
+
} else {
|
|
32214
|
+
while (ch !== 0 && !is_WS_OR_EOL2(ch)) {
|
|
32215
|
+
if (ch === 33) {
|
|
32216
|
+
if (!isNamed) {
|
|
32217
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
32218
|
+
if (!PATTERN_TAG_HANDLE2.test(tagHandle)) {
|
|
32219
|
+
throwError2(state, "named tag handle cannot contain such characters");
|
|
32220
|
+
}
|
|
32221
|
+
isNamed = true;
|
|
32222
|
+
_position = state.position + 1;
|
|
32223
|
+
} else {
|
|
32224
|
+
throwError2(state, "tag suffix cannot contain exclamation marks");
|
|
32225
|
+
}
|
|
32226
|
+
}
|
|
32227
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32228
|
+
}
|
|
32229
|
+
tagName = state.input.slice(_position, state.position);
|
|
32230
|
+
if (PATTERN_FLOW_INDICATORS2.test(tagName)) {
|
|
32231
|
+
throwError2(state, "tag suffix cannot contain flow indicator characters");
|
|
32232
|
+
}
|
|
32233
|
+
}
|
|
32234
|
+
if (tagName && !PATTERN_TAG_URI2.test(tagName)) {
|
|
32235
|
+
throwError2(state, "tag name cannot contain such characters: " + tagName);
|
|
32236
|
+
}
|
|
32237
|
+
try {
|
|
32238
|
+
tagName = decodeURIComponent(tagName);
|
|
32239
|
+
} catch (err) {
|
|
32240
|
+
throwError2(state, "tag name is malformed: " + tagName);
|
|
32241
|
+
}
|
|
32242
|
+
if (isVerbatim) {
|
|
32243
|
+
state.tag = tagName;
|
|
32244
|
+
} else if (_hasOwnProperty$12.call(state.tagMap, tagHandle)) {
|
|
32245
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
32246
|
+
} else if (tagHandle === "!") {
|
|
32247
|
+
state.tag = "!" + tagName;
|
|
32248
|
+
} else if (tagHandle === "!!") {
|
|
32249
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
32250
|
+
} else {
|
|
32251
|
+
throwError2(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
32252
|
+
}
|
|
32253
|
+
return true;
|
|
32254
|
+
}
|
|
32255
|
+
function readAnchorProperty2(state) {
|
|
32256
|
+
var _position, ch;
|
|
32257
|
+
ch = state.input.charCodeAt(state.position);
|
|
32258
|
+
if (ch !== 38)
|
|
32259
|
+
return false;
|
|
32260
|
+
if (state.anchor !== null) {
|
|
32261
|
+
throwError2(state, "duplication of an anchor property");
|
|
32262
|
+
}
|
|
32263
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32264
|
+
_position = state.position;
|
|
32265
|
+
while (ch !== 0 && !is_WS_OR_EOL2(ch) && !is_FLOW_INDICATOR2(ch)) {
|
|
32266
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32267
|
+
}
|
|
32268
|
+
if (state.position === _position) {
|
|
32269
|
+
throwError2(state, "name of an anchor node must contain at least one character");
|
|
32270
|
+
}
|
|
32271
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
32272
|
+
return true;
|
|
32273
|
+
}
|
|
32274
|
+
function readAlias2(state) {
|
|
32275
|
+
var _position, alias, ch;
|
|
32276
|
+
ch = state.input.charCodeAt(state.position);
|
|
32277
|
+
if (ch !== 42)
|
|
32278
|
+
return false;
|
|
32279
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32280
|
+
_position = state.position;
|
|
32281
|
+
while (ch !== 0 && !is_WS_OR_EOL2(ch) && !is_FLOW_INDICATOR2(ch)) {
|
|
32282
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32283
|
+
}
|
|
32284
|
+
if (state.position === _position) {
|
|
32285
|
+
throwError2(state, "name of an alias node must contain at least one character");
|
|
32286
|
+
}
|
|
32287
|
+
alias = state.input.slice(_position, state.position);
|
|
32288
|
+
if (!_hasOwnProperty$12.call(state.anchorMap, alias)) {
|
|
32289
|
+
throwError2(state, 'unidentified alias "' + alias + '"');
|
|
32290
|
+
}
|
|
32291
|
+
state.result = state.anchorMap[alias];
|
|
32292
|
+
skipSeparationSpace2(state, true, -1);
|
|
32293
|
+
return true;
|
|
32294
|
+
}
|
|
32295
|
+
function composeNode2(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
32296
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type3, flowIndent, blockIndent;
|
|
32297
|
+
if (state.listener !== null) {
|
|
32298
|
+
state.listener("open", state);
|
|
32299
|
+
}
|
|
32300
|
+
state.tag = null;
|
|
32301
|
+
state.anchor = null;
|
|
32302
|
+
state.kind = null;
|
|
32303
|
+
state.result = null;
|
|
32304
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT2 === nodeContext || CONTEXT_BLOCK_IN2 === nodeContext;
|
|
32305
|
+
if (allowToSeek) {
|
|
32306
|
+
if (skipSeparationSpace2(state, true, -1)) {
|
|
32307
|
+
atNewLine = true;
|
|
32308
|
+
if (state.lineIndent > parentIndent) {
|
|
32309
|
+
indentStatus = 1;
|
|
32310
|
+
} else if (state.lineIndent === parentIndent) {
|
|
32311
|
+
indentStatus = 0;
|
|
32312
|
+
} else if (state.lineIndent < parentIndent) {
|
|
32313
|
+
indentStatus = -1;
|
|
32314
|
+
}
|
|
32315
|
+
}
|
|
32316
|
+
}
|
|
32317
|
+
if (indentStatus === 1) {
|
|
32318
|
+
while (readTagProperty2(state) || readAnchorProperty2(state)) {
|
|
32319
|
+
if (skipSeparationSpace2(state, true, -1)) {
|
|
32320
|
+
atNewLine = true;
|
|
32321
|
+
allowBlockCollections = allowBlockStyles;
|
|
32322
|
+
if (state.lineIndent > parentIndent) {
|
|
32323
|
+
indentStatus = 1;
|
|
32324
|
+
} else if (state.lineIndent === parentIndent) {
|
|
32325
|
+
indentStatus = 0;
|
|
32326
|
+
} else if (state.lineIndent < parentIndent) {
|
|
32327
|
+
indentStatus = -1;
|
|
32328
|
+
}
|
|
32329
|
+
} else {
|
|
32330
|
+
allowBlockCollections = false;
|
|
32331
|
+
}
|
|
32332
|
+
}
|
|
32333
|
+
}
|
|
32334
|
+
if (allowBlockCollections) {
|
|
32335
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
32336
|
+
}
|
|
32337
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT2 === nodeContext) {
|
|
32338
|
+
if (CONTEXT_FLOW_IN2 === nodeContext || CONTEXT_FLOW_OUT2 === nodeContext) {
|
|
32339
|
+
flowIndent = parentIndent;
|
|
32340
|
+
} else {
|
|
32341
|
+
flowIndent = parentIndent + 1;
|
|
32342
|
+
}
|
|
32343
|
+
blockIndent = state.position - state.lineStart;
|
|
32344
|
+
if (indentStatus === 1) {
|
|
32345
|
+
if (allowBlockCollections && (readBlockSequence2(state, blockIndent) || readBlockMapping2(state, blockIndent, flowIndent)) || readFlowCollection2(state, flowIndent)) {
|
|
32346
|
+
hasContent = true;
|
|
32347
|
+
} else {
|
|
32348
|
+
if (allowBlockScalars && readBlockScalar2(state, flowIndent) || readSingleQuotedScalar2(state, flowIndent) || readDoubleQuotedScalar2(state, flowIndent)) {
|
|
32349
|
+
hasContent = true;
|
|
32350
|
+
} else if (readAlias2(state)) {
|
|
32351
|
+
hasContent = true;
|
|
32352
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
32353
|
+
throwError2(state, "alias node should not have any properties");
|
|
32354
|
+
}
|
|
32355
|
+
} else if (readPlainScalar2(state, flowIndent, CONTEXT_FLOW_IN2 === nodeContext)) {
|
|
32356
|
+
hasContent = true;
|
|
32357
|
+
if (state.tag === null) {
|
|
32358
|
+
state.tag = "?";
|
|
32359
|
+
}
|
|
32360
|
+
}
|
|
32361
|
+
if (state.anchor !== null) {
|
|
32362
|
+
state.anchorMap[state.anchor] = state.result;
|
|
32363
|
+
}
|
|
32364
|
+
}
|
|
32365
|
+
} else if (indentStatus === 0) {
|
|
32366
|
+
hasContent = allowBlockCollections && readBlockSequence2(state, blockIndent);
|
|
32367
|
+
}
|
|
32368
|
+
}
|
|
32369
|
+
if (state.tag === null) {
|
|
32370
|
+
if (state.anchor !== null) {
|
|
32371
|
+
state.anchorMap[state.anchor] = state.result;
|
|
32372
|
+
}
|
|
32373
|
+
} else if (state.tag === "?") {
|
|
32374
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
32375
|
+
throwError2(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
32376
|
+
}
|
|
32377
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
32378
|
+
type3 = state.implicitTypes[typeIndex];
|
|
32379
|
+
if (type3.resolve(state.result)) {
|
|
32380
|
+
state.result = type3.construct(state.result);
|
|
32381
|
+
state.tag = type3.tag;
|
|
32382
|
+
if (state.anchor !== null) {
|
|
32383
|
+
state.anchorMap[state.anchor] = state.result;
|
|
32384
|
+
}
|
|
32385
|
+
break;
|
|
32386
|
+
}
|
|
32387
|
+
}
|
|
32388
|
+
} else if (state.tag !== "!") {
|
|
32389
|
+
if (_hasOwnProperty$12.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
32390
|
+
type3 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
32391
|
+
} else {
|
|
32392
|
+
type3 = null;
|
|
32393
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
32394
|
+
for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
|
|
32395
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
32396
|
+
type3 = typeList[typeIndex];
|
|
32397
|
+
break;
|
|
32398
|
+
}
|
|
32399
|
+
}
|
|
32400
|
+
}
|
|
32401
|
+
if (!type3) {
|
|
32402
|
+
throwError2(state, "unknown tag !<" + state.tag + ">");
|
|
32403
|
+
}
|
|
32404
|
+
if (state.result !== null && type3.kind !== state.kind) {
|
|
32405
|
+
throwError2(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type3.kind + '", not "' + state.kind + '"');
|
|
32406
|
+
}
|
|
32407
|
+
if (!type3.resolve(state.result, state.tag)) {
|
|
32408
|
+
throwError2(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
32409
|
+
} else {
|
|
32410
|
+
state.result = type3.construct(state.result, state.tag);
|
|
32411
|
+
if (state.anchor !== null) {
|
|
32412
|
+
state.anchorMap[state.anchor] = state.result;
|
|
32413
|
+
}
|
|
32414
|
+
}
|
|
32415
|
+
}
|
|
32416
|
+
if (state.listener !== null) {
|
|
32417
|
+
state.listener("close", state);
|
|
32418
|
+
}
|
|
32419
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
32420
|
+
}
|
|
32421
|
+
function readDocument2(state) {
|
|
32422
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
32423
|
+
state.version = null;
|
|
32424
|
+
state.checkLineBreaks = state.legacy;
|
|
32425
|
+
state.tagMap = Object.create(null);
|
|
32426
|
+
state.anchorMap = Object.create(null);
|
|
32427
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
32428
|
+
skipSeparationSpace2(state, true, -1);
|
|
32429
|
+
ch = state.input.charCodeAt(state.position);
|
|
32430
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
32431
|
+
break;
|
|
32432
|
+
}
|
|
32433
|
+
hasDirectives = true;
|
|
32434
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32435
|
+
_position = state.position;
|
|
32436
|
+
while (ch !== 0 && !is_WS_OR_EOL2(ch)) {
|
|
32437
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32438
|
+
}
|
|
32439
|
+
directiveName = state.input.slice(_position, state.position);
|
|
32440
|
+
directiveArgs = [];
|
|
32441
|
+
if (directiveName.length < 1) {
|
|
32442
|
+
throwError2(state, "directive name must not be less than one character in length");
|
|
32443
|
+
}
|
|
32444
|
+
while (ch !== 0) {
|
|
32445
|
+
while (is_WHITE_SPACE2(ch)) {
|
|
32446
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32447
|
+
}
|
|
32448
|
+
if (ch === 35) {
|
|
32449
|
+
do {
|
|
32450
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32451
|
+
} while (ch !== 0 && !is_EOL2(ch));
|
|
32452
|
+
break;
|
|
32453
|
+
}
|
|
32454
|
+
if (is_EOL2(ch))
|
|
32455
|
+
break;
|
|
32456
|
+
_position = state.position;
|
|
32457
|
+
while (ch !== 0 && !is_WS_OR_EOL2(ch)) {
|
|
32458
|
+
ch = state.input.charCodeAt(++state.position);
|
|
32459
|
+
}
|
|
32460
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
32461
|
+
}
|
|
32462
|
+
if (ch !== 0)
|
|
32463
|
+
readLineBreak2(state);
|
|
32464
|
+
if (_hasOwnProperty$12.call(directiveHandlers2, directiveName)) {
|
|
32465
|
+
directiveHandlers2[directiveName](state, directiveName, directiveArgs);
|
|
32466
|
+
} else {
|
|
32467
|
+
throwWarning2(state, 'unknown document directive "' + directiveName + '"');
|
|
32468
|
+
}
|
|
32469
|
+
}
|
|
32470
|
+
skipSeparationSpace2(state, true, -1);
|
|
32471
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
32472
|
+
state.position += 3;
|
|
32473
|
+
skipSeparationSpace2(state, true, -1);
|
|
32474
|
+
} else if (hasDirectives) {
|
|
32475
|
+
throwError2(state, "directives end mark is expected");
|
|
32476
|
+
}
|
|
32477
|
+
composeNode2(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT2, false, true);
|
|
32478
|
+
skipSeparationSpace2(state, true, -1);
|
|
32479
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS2.test(state.input.slice(documentStart, state.position))) {
|
|
32480
|
+
throwWarning2(state, "non-ASCII line breaks are interpreted as content");
|
|
32481
|
+
}
|
|
32482
|
+
state.documents.push(state.result);
|
|
32483
|
+
if (state.position === state.lineStart && testDocumentSeparator2(state)) {
|
|
32484
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
32485
|
+
state.position += 3;
|
|
32486
|
+
skipSeparationSpace2(state, true, -1);
|
|
32487
|
+
}
|
|
32488
|
+
return;
|
|
32489
|
+
}
|
|
32490
|
+
if (state.position < state.length - 1) {
|
|
32491
|
+
throwError2(state, "end of the stream or a document separator is expected");
|
|
32492
|
+
} else {
|
|
32493
|
+
return;
|
|
32494
|
+
}
|
|
32495
|
+
}
|
|
32496
|
+
function loadDocuments2(input, options) {
|
|
32497
|
+
input = String(input);
|
|
32498
|
+
options = options || {};
|
|
32499
|
+
if (input.length !== 0) {
|
|
32500
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
32501
|
+
input += `
|
|
32502
|
+
`;
|
|
32503
|
+
}
|
|
32504
|
+
if (input.charCodeAt(0) === 65279) {
|
|
32505
|
+
input = input.slice(1);
|
|
32506
|
+
}
|
|
32507
|
+
}
|
|
32508
|
+
var state = new State$12(input, options);
|
|
32509
|
+
var nullpos = input.indexOf("\x00");
|
|
32510
|
+
if (nullpos !== -1) {
|
|
32511
|
+
state.position = nullpos;
|
|
32512
|
+
throwError2(state, "null byte is not allowed in input");
|
|
32513
|
+
}
|
|
32514
|
+
state.input += "\x00";
|
|
32515
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
32516
|
+
state.lineIndent += 1;
|
|
32517
|
+
state.position += 1;
|
|
32518
|
+
}
|
|
32519
|
+
while (state.position < state.length - 1) {
|
|
32520
|
+
readDocument2(state);
|
|
32521
|
+
}
|
|
32522
|
+
return state.documents;
|
|
32523
|
+
}
|
|
32524
|
+
function loadAll$12(input, iterator, options) {
|
|
32525
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
32526
|
+
options = iterator;
|
|
32527
|
+
iterator = null;
|
|
32528
|
+
}
|
|
32529
|
+
var documents = loadDocuments2(input, options);
|
|
32530
|
+
if (typeof iterator !== "function") {
|
|
32531
|
+
return documents;
|
|
32532
|
+
}
|
|
32533
|
+
for (var index = 0, length = documents.length;index < length; index += 1) {
|
|
32534
|
+
iterator(documents[index]);
|
|
32535
|
+
}
|
|
32536
|
+
}
|
|
32537
|
+
function load$12(input, options) {
|
|
32538
|
+
var documents = loadDocuments2(input, options);
|
|
32539
|
+
if (documents.length === 0) {
|
|
32540
|
+
return;
|
|
32541
|
+
} else if (documents.length === 1) {
|
|
32542
|
+
return documents[0];
|
|
32543
|
+
}
|
|
32544
|
+
throw new exception2("expected a single document in the stream, but found more");
|
|
32545
|
+
}
|
|
32546
|
+
var loadAll_12 = loadAll$12;
|
|
32547
|
+
var load_12 = load$12;
|
|
32548
|
+
var loader2 = {
|
|
32549
|
+
loadAll: loadAll_12,
|
|
32550
|
+
load: load_12
|
|
32551
|
+
};
|
|
32552
|
+
var _toString2 = Object.prototype.toString;
|
|
32553
|
+
var _hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
32554
|
+
var CHAR_BOM2 = 65279;
|
|
32555
|
+
var CHAR_TAB2 = 9;
|
|
32556
|
+
var CHAR_LINE_FEED2 = 10;
|
|
32557
|
+
var CHAR_CARRIAGE_RETURN2 = 13;
|
|
32558
|
+
var CHAR_SPACE2 = 32;
|
|
32559
|
+
var CHAR_EXCLAMATION2 = 33;
|
|
32560
|
+
var CHAR_DOUBLE_QUOTE2 = 34;
|
|
32561
|
+
var CHAR_SHARP2 = 35;
|
|
32562
|
+
var CHAR_PERCENT2 = 37;
|
|
32563
|
+
var CHAR_AMPERSAND2 = 38;
|
|
32564
|
+
var CHAR_SINGLE_QUOTE2 = 39;
|
|
32565
|
+
var CHAR_ASTERISK2 = 42;
|
|
32566
|
+
var CHAR_COMMA2 = 44;
|
|
32567
|
+
var CHAR_MINUS2 = 45;
|
|
32568
|
+
var CHAR_COLON2 = 58;
|
|
32569
|
+
var CHAR_EQUALS2 = 61;
|
|
32570
|
+
var CHAR_GREATER_THAN2 = 62;
|
|
32571
|
+
var CHAR_QUESTION2 = 63;
|
|
32572
|
+
var CHAR_COMMERCIAL_AT2 = 64;
|
|
32573
|
+
var CHAR_LEFT_SQUARE_BRACKET2 = 91;
|
|
32574
|
+
var CHAR_RIGHT_SQUARE_BRACKET2 = 93;
|
|
32575
|
+
var CHAR_GRAVE_ACCENT2 = 96;
|
|
32576
|
+
var CHAR_LEFT_CURLY_BRACKET2 = 123;
|
|
32577
|
+
var CHAR_VERTICAL_LINE2 = 124;
|
|
32578
|
+
var CHAR_RIGHT_CURLY_BRACKET2 = 125;
|
|
32579
|
+
var ESCAPE_SEQUENCES2 = {};
|
|
32580
|
+
ESCAPE_SEQUENCES2[0] = "\\0";
|
|
32581
|
+
ESCAPE_SEQUENCES2[7] = "\\a";
|
|
32582
|
+
ESCAPE_SEQUENCES2[8] = "\\b";
|
|
32583
|
+
ESCAPE_SEQUENCES2[9] = "\\t";
|
|
32584
|
+
ESCAPE_SEQUENCES2[10] = "\\n";
|
|
32585
|
+
ESCAPE_SEQUENCES2[11] = "\\v";
|
|
32586
|
+
ESCAPE_SEQUENCES2[12] = "\\f";
|
|
32587
|
+
ESCAPE_SEQUENCES2[13] = "\\r";
|
|
32588
|
+
ESCAPE_SEQUENCES2[27] = "\\e";
|
|
32589
|
+
ESCAPE_SEQUENCES2[34] = "\\\"";
|
|
32590
|
+
ESCAPE_SEQUENCES2[92] = "\\\\";
|
|
32591
|
+
ESCAPE_SEQUENCES2[133] = "\\N";
|
|
32592
|
+
ESCAPE_SEQUENCES2[160] = "\\_";
|
|
32593
|
+
ESCAPE_SEQUENCES2[8232] = "\\L";
|
|
32594
|
+
ESCAPE_SEQUENCES2[8233] = "\\P";
|
|
32595
|
+
var DEPRECATED_BOOLEANS_SYNTAX2 = [
|
|
32596
|
+
"y",
|
|
32597
|
+
"Y",
|
|
32598
|
+
"yes",
|
|
32599
|
+
"Yes",
|
|
32600
|
+
"YES",
|
|
32601
|
+
"on",
|
|
32602
|
+
"On",
|
|
32603
|
+
"ON",
|
|
32604
|
+
"n",
|
|
32605
|
+
"N",
|
|
32606
|
+
"no",
|
|
32607
|
+
"No",
|
|
32608
|
+
"NO",
|
|
32609
|
+
"off",
|
|
32610
|
+
"Off",
|
|
32611
|
+
"OFF"
|
|
32612
|
+
];
|
|
32613
|
+
var DEPRECATED_BASE60_SYNTAX2 = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
32614
|
+
function compileStyleMap2(schema3, map4) {
|
|
32615
|
+
var result, keys, index, length, tag, style, type3;
|
|
32616
|
+
if (map4 === null)
|
|
32617
|
+
return {};
|
|
32618
|
+
result = {};
|
|
32619
|
+
keys = Object.keys(map4);
|
|
32620
|
+
for (index = 0, length = keys.length;index < length; index += 1) {
|
|
32621
|
+
tag = keys[index];
|
|
32622
|
+
style = String(map4[tag]);
|
|
32623
|
+
if (tag.slice(0, 2) === "!!") {
|
|
32624
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
32625
|
+
}
|
|
32626
|
+
type3 = schema3.compiledTypeMap["fallback"][tag];
|
|
32627
|
+
if (type3 && _hasOwnProperty2.call(type3.styleAliases, style)) {
|
|
32628
|
+
style = type3.styleAliases[style];
|
|
32629
|
+
}
|
|
32630
|
+
result[tag] = style;
|
|
32631
|
+
}
|
|
32632
|
+
return result;
|
|
32633
|
+
}
|
|
32634
|
+
function encodeHex2(character) {
|
|
32635
|
+
var string4, handle, length;
|
|
32636
|
+
string4 = character.toString(16).toUpperCase();
|
|
32637
|
+
if (character <= 255) {
|
|
32638
|
+
handle = "x";
|
|
32639
|
+
length = 2;
|
|
32640
|
+
} else if (character <= 65535) {
|
|
32641
|
+
handle = "u";
|
|
32642
|
+
length = 4;
|
|
32643
|
+
} else if (character <= 4294967295) {
|
|
32644
|
+
handle = "U";
|
|
32645
|
+
length = 8;
|
|
32646
|
+
} else {
|
|
32647
|
+
throw new exception2("code point within a string may not be greater than 0xFFFFFFFF");
|
|
32648
|
+
}
|
|
32649
|
+
return "\\" + handle + common2.repeat("0", length - string4.length) + string4;
|
|
32650
|
+
}
|
|
32651
|
+
var QUOTING_TYPE_SINGLE2 = 1;
|
|
32652
|
+
var QUOTING_TYPE_DOUBLE2 = 2;
|
|
32653
|
+
function State2(options) {
|
|
32654
|
+
this.schema = options["schema"] || _default3;
|
|
32655
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
32656
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
32657
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
32658
|
+
this.flowLevel = common2.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
32659
|
+
this.styleMap = compileStyleMap2(this.schema, options["styles"] || null);
|
|
32660
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
32661
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
32662
|
+
this.noRefs = options["noRefs"] || false;
|
|
32663
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
32664
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
32665
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE2 : QUOTING_TYPE_SINGLE2;
|
|
32666
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
32667
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
32668
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
32669
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
32670
|
+
this.tag = null;
|
|
32671
|
+
this.result = "";
|
|
32672
|
+
this.duplicates = [];
|
|
32673
|
+
this.usedDuplicates = null;
|
|
32674
|
+
}
|
|
32675
|
+
function indentString2(string4, spaces) {
|
|
32676
|
+
var ind = common2.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string4.length;
|
|
32677
|
+
while (position < length) {
|
|
32678
|
+
next = string4.indexOf(`
|
|
32679
|
+
`, position);
|
|
32680
|
+
if (next === -1) {
|
|
32681
|
+
line = string4.slice(position);
|
|
32682
|
+
position = length;
|
|
32683
|
+
} else {
|
|
32684
|
+
line = string4.slice(position, next + 1);
|
|
32685
|
+
position = next + 1;
|
|
32686
|
+
}
|
|
32687
|
+
if (line.length && line !== `
|
|
32688
|
+
`)
|
|
32689
|
+
result += ind;
|
|
32690
|
+
result += line;
|
|
32691
|
+
}
|
|
32692
|
+
return result;
|
|
32693
|
+
}
|
|
32694
|
+
function generateNextLine2(state, level) {
|
|
32695
|
+
return `
|
|
32696
|
+
` + common2.repeat(" ", state.indent * level);
|
|
32697
|
+
}
|
|
32698
|
+
function testImplicitResolving2(state, str3) {
|
|
32699
|
+
var index, length, type3;
|
|
32700
|
+
for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
|
|
32701
|
+
type3 = state.implicitTypes[index];
|
|
32702
|
+
if (type3.resolve(str3)) {
|
|
32703
|
+
return true;
|
|
32704
|
+
}
|
|
32705
|
+
}
|
|
32706
|
+
return false;
|
|
32707
|
+
}
|
|
32708
|
+
function isWhitespace2(c) {
|
|
32709
|
+
return c === CHAR_SPACE2 || c === CHAR_TAB2;
|
|
32710
|
+
}
|
|
32711
|
+
function isPrintable2(c) {
|
|
32712
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM2 || 65536 <= c && c <= 1114111;
|
|
32713
|
+
}
|
|
32714
|
+
function isNsCharOrWhitespace2(c) {
|
|
32715
|
+
return isPrintable2(c) && c !== CHAR_BOM2 && c !== CHAR_CARRIAGE_RETURN2 && c !== CHAR_LINE_FEED2;
|
|
32716
|
+
}
|
|
32717
|
+
function isPlainSafe2(c, prev, inblock) {
|
|
32718
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace2(c);
|
|
32719
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace2(c);
|
|
32720
|
+
return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA2 && c !== CHAR_LEFT_SQUARE_BRACKET2 && c !== CHAR_RIGHT_SQUARE_BRACKET2 && c !== CHAR_LEFT_CURLY_BRACKET2 && c !== CHAR_RIGHT_CURLY_BRACKET2) && c !== CHAR_SHARP2 && !(prev === CHAR_COLON2 && !cIsNsChar) || isNsCharOrWhitespace2(prev) && !isWhitespace2(prev) && c === CHAR_SHARP2 || prev === CHAR_COLON2 && cIsNsChar;
|
|
32721
|
+
}
|
|
32722
|
+
function isPlainSafeFirst2(c) {
|
|
32723
|
+
return isPrintable2(c) && c !== CHAR_BOM2 && !isWhitespace2(c) && c !== CHAR_MINUS2 && c !== CHAR_QUESTION2 && c !== CHAR_COLON2 && c !== CHAR_COMMA2 && c !== CHAR_LEFT_SQUARE_BRACKET2 && c !== CHAR_RIGHT_SQUARE_BRACKET2 && c !== CHAR_LEFT_CURLY_BRACKET2 && c !== CHAR_RIGHT_CURLY_BRACKET2 && c !== CHAR_SHARP2 && c !== CHAR_AMPERSAND2 && c !== CHAR_ASTERISK2 && c !== CHAR_EXCLAMATION2 && c !== CHAR_VERTICAL_LINE2 && c !== CHAR_EQUALS2 && c !== CHAR_GREATER_THAN2 && c !== CHAR_SINGLE_QUOTE2 && c !== CHAR_DOUBLE_QUOTE2 && c !== CHAR_PERCENT2 && c !== CHAR_COMMERCIAL_AT2 && c !== CHAR_GRAVE_ACCENT2;
|
|
32724
|
+
}
|
|
32725
|
+
function isPlainSafeLast2(c) {
|
|
32726
|
+
return !isWhitespace2(c) && c !== CHAR_COLON2;
|
|
32727
|
+
}
|
|
32728
|
+
function codePointAt2(string4, pos) {
|
|
32729
|
+
var first = string4.charCodeAt(pos), second;
|
|
32730
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string4.length) {
|
|
32731
|
+
second = string4.charCodeAt(pos + 1);
|
|
32732
|
+
if (second >= 56320 && second <= 57343) {
|
|
32733
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
32734
|
+
}
|
|
32735
|
+
}
|
|
32736
|
+
return first;
|
|
32737
|
+
}
|
|
32738
|
+
function needIndentIndicator2(string4) {
|
|
32739
|
+
var leadingSpaceRe = /^\n* /;
|
|
32740
|
+
return leadingSpaceRe.test(string4);
|
|
32741
|
+
}
|
|
32742
|
+
var STYLE_PLAIN2 = 1;
|
|
32743
|
+
var STYLE_SINGLE2 = 2;
|
|
32744
|
+
var STYLE_LITERAL2 = 3;
|
|
32745
|
+
var STYLE_FOLDED2 = 4;
|
|
32746
|
+
var STYLE_DOUBLE2 = 5;
|
|
32747
|
+
function chooseScalarStyle2(string4, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
32748
|
+
var i3;
|
|
32749
|
+
var char = 0;
|
|
32750
|
+
var prevChar = null;
|
|
32751
|
+
var hasLineBreak = false;
|
|
32752
|
+
var hasFoldableLine = false;
|
|
32753
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
32754
|
+
var previousLineBreak = -1;
|
|
32755
|
+
var plain = isPlainSafeFirst2(codePointAt2(string4, 0)) && isPlainSafeLast2(codePointAt2(string4, string4.length - 1));
|
|
32756
|
+
if (singleLineOnly || forceQuotes) {
|
|
32757
|
+
for (i3 = 0;i3 < string4.length; char >= 65536 ? i3 += 2 : i3++) {
|
|
32758
|
+
char = codePointAt2(string4, i3);
|
|
32759
|
+
if (!isPrintable2(char)) {
|
|
32760
|
+
return STYLE_DOUBLE2;
|
|
32761
|
+
}
|
|
32762
|
+
plain = plain && isPlainSafe2(char, prevChar, inblock);
|
|
32763
|
+
prevChar = char;
|
|
32764
|
+
}
|
|
32765
|
+
} else {
|
|
32766
|
+
for (i3 = 0;i3 < string4.length; char >= 65536 ? i3 += 2 : i3++) {
|
|
32767
|
+
char = codePointAt2(string4, i3);
|
|
32768
|
+
if (char === CHAR_LINE_FEED2) {
|
|
32769
|
+
hasLineBreak = true;
|
|
32770
|
+
if (shouldTrackWidth) {
|
|
32771
|
+
hasFoldableLine = hasFoldableLine || i3 - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ";
|
|
32772
|
+
previousLineBreak = i3;
|
|
32773
|
+
}
|
|
32774
|
+
} else if (!isPrintable2(char)) {
|
|
32775
|
+
return STYLE_DOUBLE2;
|
|
32776
|
+
}
|
|
32777
|
+
plain = plain && isPlainSafe2(char, prevChar, inblock);
|
|
32778
|
+
prevChar = char;
|
|
32779
|
+
}
|
|
32780
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i3 - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ");
|
|
32781
|
+
}
|
|
32782
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
32783
|
+
if (plain && !forceQuotes && !testAmbiguousType(string4)) {
|
|
32784
|
+
return STYLE_PLAIN2;
|
|
32785
|
+
}
|
|
32786
|
+
return quotingType === QUOTING_TYPE_DOUBLE2 ? STYLE_DOUBLE2 : STYLE_SINGLE2;
|
|
32787
|
+
}
|
|
32788
|
+
if (indentPerLevel > 9 && needIndentIndicator2(string4)) {
|
|
32789
|
+
return STYLE_DOUBLE2;
|
|
32790
|
+
}
|
|
32791
|
+
if (!forceQuotes) {
|
|
32792
|
+
return hasFoldableLine ? STYLE_FOLDED2 : STYLE_LITERAL2;
|
|
32793
|
+
}
|
|
32794
|
+
return quotingType === QUOTING_TYPE_DOUBLE2 ? STYLE_DOUBLE2 : STYLE_SINGLE2;
|
|
32795
|
+
}
|
|
32796
|
+
function writeScalar2(state, string4, level, iskey, inblock) {
|
|
32797
|
+
state.dump = function() {
|
|
32798
|
+
if (string4.length === 0) {
|
|
32799
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE2 ? '""' : "''";
|
|
32800
|
+
}
|
|
32801
|
+
if (!state.noCompatMode) {
|
|
32802
|
+
if (DEPRECATED_BOOLEANS_SYNTAX2.indexOf(string4) !== -1 || DEPRECATED_BASE60_SYNTAX2.test(string4)) {
|
|
32803
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE2 ? '"' + string4 + '"' : "'" + string4 + "'";
|
|
32804
|
+
}
|
|
32805
|
+
}
|
|
32806
|
+
var indent = state.indent * Math.max(1, level);
|
|
32807
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
32808
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
32809
|
+
function testAmbiguity(string5) {
|
|
32810
|
+
return testImplicitResolving2(state, string5);
|
|
32811
|
+
}
|
|
32812
|
+
switch (chooseScalarStyle2(string4, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
32813
|
+
case STYLE_PLAIN2:
|
|
32814
|
+
return string4;
|
|
32815
|
+
case STYLE_SINGLE2:
|
|
32816
|
+
return "'" + string4.replace(/'/g, "''") + "'";
|
|
32817
|
+
case STYLE_LITERAL2:
|
|
32818
|
+
return "|" + blockHeader2(string4, state.indent) + dropEndingNewline2(indentString2(string4, indent));
|
|
32819
|
+
case STYLE_FOLDED2:
|
|
32820
|
+
return ">" + blockHeader2(string4, state.indent) + dropEndingNewline2(indentString2(foldString2(string4, lineWidth), indent));
|
|
32821
|
+
case STYLE_DOUBLE2:
|
|
32822
|
+
return '"' + escapeString2(string4) + '"';
|
|
32823
|
+
default:
|
|
32824
|
+
throw new exception2("impossible error: invalid scalar style");
|
|
32825
|
+
}
|
|
32826
|
+
}();
|
|
32827
|
+
}
|
|
32828
|
+
function blockHeader2(string4, indentPerLevel) {
|
|
32829
|
+
var indentIndicator = needIndentIndicator2(string4) ? String(indentPerLevel) : "";
|
|
32830
|
+
var clip = string4[string4.length - 1] === `
|
|
32831
|
+
`;
|
|
32832
|
+
var keep = clip && (string4[string4.length - 2] === `
|
|
32833
|
+
` || string4 === `
|
|
32834
|
+
`);
|
|
32835
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
32836
|
+
return indentIndicator + chomp + `
|
|
32837
|
+
`;
|
|
32838
|
+
}
|
|
32839
|
+
function dropEndingNewline2(string4) {
|
|
32840
|
+
return string4[string4.length - 1] === `
|
|
32841
|
+
` ? string4.slice(0, -1) : string4;
|
|
32842
|
+
}
|
|
32843
|
+
function foldString2(string4, width) {
|
|
32844
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
32845
|
+
var result = function() {
|
|
32846
|
+
var nextLF = string4.indexOf(`
|
|
32847
|
+
`);
|
|
32848
|
+
nextLF = nextLF !== -1 ? nextLF : string4.length;
|
|
32849
|
+
lineRe.lastIndex = nextLF;
|
|
32850
|
+
return foldLine2(string4.slice(0, nextLF), width);
|
|
32851
|
+
}();
|
|
32852
|
+
var prevMoreIndented = string4[0] === `
|
|
32853
|
+
` || string4[0] === " ";
|
|
32854
|
+
var moreIndented;
|
|
32855
|
+
var match;
|
|
32856
|
+
while (match = lineRe.exec(string4)) {
|
|
32857
|
+
var prefix = match[1], line = match[2];
|
|
32858
|
+
moreIndented = line[0] === " ";
|
|
32859
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
|
|
32860
|
+
` : "") + foldLine2(line, width);
|
|
32861
|
+
prevMoreIndented = moreIndented;
|
|
32862
|
+
}
|
|
32863
|
+
return result;
|
|
32864
|
+
}
|
|
32865
|
+
function foldLine2(line, width) {
|
|
32866
|
+
if (line === "" || line[0] === " ")
|
|
32867
|
+
return line;
|
|
32868
|
+
var breakRe = / [^ ]/g;
|
|
32869
|
+
var match;
|
|
32870
|
+
var start = 0, end, curr = 0, next = 0;
|
|
32871
|
+
var result = "";
|
|
32872
|
+
while (match = breakRe.exec(line)) {
|
|
32873
|
+
next = match.index;
|
|
32874
|
+
if (next - start > width) {
|
|
32875
|
+
end = curr > start ? curr : next;
|
|
32876
|
+
result += `
|
|
32877
|
+
` + line.slice(start, end);
|
|
32878
|
+
start = end + 1;
|
|
32879
|
+
}
|
|
32880
|
+
curr = next;
|
|
32881
|
+
}
|
|
32882
|
+
result += `
|
|
32883
|
+
`;
|
|
32884
|
+
if (line.length - start > width && curr > start) {
|
|
32885
|
+
result += line.slice(start, curr) + `
|
|
32886
|
+
` + line.slice(curr + 1);
|
|
32887
|
+
} else {
|
|
32888
|
+
result += line.slice(start);
|
|
32889
|
+
}
|
|
32890
|
+
return result.slice(1);
|
|
32891
|
+
}
|
|
32892
|
+
function escapeString2(string4) {
|
|
32893
|
+
var result = "";
|
|
32894
|
+
var char = 0;
|
|
32895
|
+
var escapeSeq;
|
|
32896
|
+
for (var i3 = 0;i3 < string4.length; char >= 65536 ? i3 += 2 : i3++) {
|
|
32897
|
+
char = codePointAt2(string4, i3);
|
|
32898
|
+
escapeSeq = ESCAPE_SEQUENCES2[char];
|
|
32899
|
+
if (!escapeSeq && isPrintable2(char)) {
|
|
32900
|
+
result += string4[i3];
|
|
32901
|
+
if (char >= 65536)
|
|
32902
|
+
result += string4[i3 + 1];
|
|
32903
|
+
} else {
|
|
32904
|
+
result += escapeSeq || encodeHex2(char);
|
|
32905
|
+
}
|
|
32906
|
+
}
|
|
32907
|
+
return result;
|
|
32908
|
+
}
|
|
32909
|
+
function writeFlowSequence2(state, level, object4) {
|
|
32910
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
32911
|
+
for (index = 0, length = object4.length;index < length; index += 1) {
|
|
32912
|
+
value = object4[index];
|
|
32913
|
+
if (state.replacer) {
|
|
32914
|
+
value = state.replacer.call(object4, String(index), value);
|
|
32915
|
+
}
|
|
32916
|
+
if (writeNode2(state, level, value, false, false) || typeof value === "undefined" && writeNode2(state, level, null, false, false)) {
|
|
32917
|
+
if (_result !== "")
|
|
32918
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
32919
|
+
_result += state.dump;
|
|
32920
|
+
}
|
|
32921
|
+
}
|
|
32922
|
+
state.tag = _tag;
|
|
32923
|
+
state.dump = "[" + _result + "]";
|
|
32924
|
+
}
|
|
32925
|
+
function writeBlockSequence2(state, level, object4, compact) {
|
|
32926
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
32927
|
+
for (index = 0, length = object4.length;index < length; index += 1) {
|
|
32928
|
+
value = object4[index];
|
|
32929
|
+
if (state.replacer) {
|
|
32930
|
+
value = state.replacer.call(object4, String(index), value);
|
|
32931
|
+
}
|
|
32932
|
+
if (writeNode2(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode2(state, level + 1, null, true, true, false, true)) {
|
|
32933
|
+
if (!compact || _result !== "") {
|
|
32934
|
+
_result += generateNextLine2(state, level);
|
|
32935
|
+
}
|
|
32936
|
+
if (state.dump && CHAR_LINE_FEED2 === state.dump.charCodeAt(0)) {
|
|
32937
|
+
_result += "-";
|
|
32938
|
+
} else {
|
|
32939
|
+
_result += "- ";
|
|
32940
|
+
}
|
|
32941
|
+
_result += state.dump;
|
|
32942
|
+
}
|
|
32943
|
+
}
|
|
32944
|
+
state.tag = _tag;
|
|
32945
|
+
state.dump = _result || "[]";
|
|
32946
|
+
}
|
|
32947
|
+
function writeFlowMapping2(state, level, object4) {
|
|
32948
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object4), index, length, objectKey, objectValue, pairBuffer;
|
|
32949
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
32950
|
+
pairBuffer = "";
|
|
32951
|
+
if (_result !== "")
|
|
32952
|
+
pairBuffer += ", ";
|
|
32953
|
+
if (state.condenseFlow)
|
|
32954
|
+
pairBuffer += '"';
|
|
32955
|
+
objectKey = objectKeyList[index];
|
|
32956
|
+
objectValue = object4[objectKey];
|
|
32957
|
+
if (state.replacer) {
|
|
32958
|
+
objectValue = state.replacer.call(object4, objectKey, objectValue);
|
|
32959
|
+
}
|
|
32960
|
+
if (!writeNode2(state, level, objectKey, false, false)) {
|
|
32961
|
+
continue;
|
|
32962
|
+
}
|
|
32963
|
+
if (state.dump.length > 1024)
|
|
32964
|
+
pairBuffer += "? ";
|
|
32965
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
32966
|
+
if (!writeNode2(state, level, objectValue, false, false)) {
|
|
32967
|
+
continue;
|
|
32968
|
+
}
|
|
32969
|
+
pairBuffer += state.dump;
|
|
32970
|
+
_result += pairBuffer;
|
|
32971
|
+
}
|
|
32972
|
+
state.tag = _tag;
|
|
32973
|
+
state.dump = "{" + _result + "}";
|
|
32974
|
+
}
|
|
32975
|
+
function writeBlockMapping2(state, level, object4, compact) {
|
|
32976
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object4), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
32977
|
+
if (state.sortKeys === true) {
|
|
32978
|
+
objectKeyList.sort();
|
|
32979
|
+
} else if (typeof state.sortKeys === "function") {
|
|
32980
|
+
objectKeyList.sort(state.sortKeys);
|
|
32981
|
+
} else if (state.sortKeys) {
|
|
32982
|
+
throw new exception2("sortKeys must be a boolean or a function");
|
|
32983
|
+
}
|
|
32984
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
32985
|
+
pairBuffer = "";
|
|
32986
|
+
if (!compact || _result !== "") {
|
|
32987
|
+
pairBuffer += generateNextLine2(state, level);
|
|
32988
|
+
}
|
|
32989
|
+
objectKey = objectKeyList[index];
|
|
32990
|
+
objectValue = object4[objectKey];
|
|
32991
|
+
if (state.replacer) {
|
|
32992
|
+
objectValue = state.replacer.call(object4, objectKey, objectValue);
|
|
32993
|
+
}
|
|
32994
|
+
if (!writeNode2(state, level + 1, objectKey, true, true, true)) {
|
|
32995
|
+
continue;
|
|
32996
|
+
}
|
|
32997
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
32998
|
+
if (explicitPair) {
|
|
32999
|
+
if (state.dump && CHAR_LINE_FEED2 === state.dump.charCodeAt(0)) {
|
|
33000
|
+
pairBuffer += "?";
|
|
33001
|
+
} else {
|
|
33002
|
+
pairBuffer += "? ";
|
|
33003
|
+
}
|
|
33004
|
+
}
|
|
33005
|
+
pairBuffer += state.dump;
|
|
33006
|
+
if (explicitPair) {
|
|
33007
|
+
pairBuffer += generateNextLine2(state, level);
|
|
33008
|
+
}
|
|
33009
|
+
if (!writeNode2(state, level + 1, objectValue, true, explicitPair)) {
|
|
33010
|
+
continue;
|
|
33011
|
+
}
|
|
33012
|
+
if (state.dump && CHAR_LINE_FEED2 === state.dump.charCodeAt(0)) {
|
|
33013
|
+
pairBuffer += ":";
|
|
33014
|
+
} else {
|
|
33015
|
+
pairBuffer += ": ";
|
|
33016
|
+
}
|
|
33017
|
+
pairBuffer += state.dump;
|
|
33018
|
+
_result += pairBuffer;
|
|
33019
|
+
}
|
|
33020
|
+
state.tag = _tag;
|
|
33021
|
+
state.dump = _result || "{}";
|
|
33022
|
+
}
|
|
33023
|
+
function detectType2(state, object4, explicit) {
|
|
33024
|
+
var _result, typeList, index, length, type3, style;
|
|
33025
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
33026
|
+
for (index = 0, length = typeList.length;index < length; index += 1) {
|
|
33027
|
+
type3 = typeList[index];
|
|
33028
|
+
if ((type3.instanceOf || type3.predicate) && (!type3.instanceOf || typeof object4 === "object" && object4 instanceof type3.instanceOf) && (!type3.predicate || type3.predicate(object4))) {
|
|
33029
|
+
if (explicit) {
|
|
33030
|
+
if (type3.multi && type3.representName) {
|
|
33031
|
+
state.tag = type3.representName(object4);
|
|
33032
|
+
} else {
|
|
33033
|
+
state.tag = type3.tag;
|
|
33034
|
+
}
|
|
33035
|
+
} else {
|
|
33036
|
+
state.tag = "?";
|
|
33037
|
+
}
|
|
33038
|
+
if (type3.represent) {
|
|
33039
|
+
style = state.styleMap[type3.tag] || type3.defaultStyle;
|
|
33040
|
+
if (_toString2.call(type3.represent) === "[object Function]") {
|
|
33041
|
+
_result = type3.represent(object4, style);
|
|
33042
|
+
} else if (_hasOwnProperty2.call(type3.represent, style)) {
|
|
33043
|
+
_result = type3.represent[style](object4, style);
|
|
33044
|
+
} else {
|
|
33045
|
+
throw new exception2("!<" + type3.tag + '> tag resolver accepts not "' + style + '" style');
|
|
33046
|
+
}
|
|
33047
|
+
state.dump = _result;
|
|
33048
|
+
}
|
|
33049
|
+
return true;
|
|
33050
|
+
}
|
|
33051
|
+
}
|
|
33052
|
+
return false;
|
|
33053
|
+
}
|
|
33054
|
+
function writeNode2(state, level, object4, block, compact, iskey, isblockseq) {
|
|
33055
|
+
state.tag = null;
|
|
33056
|
+
state.dump = object4;
|
|
33057
|
+
if (!detectType2(state, object4, false)) {
|
|
33058
|
+
detectType2(state, object4, true);
|
|
33059
|
+
}
|
|
33060
|
+
var type3 = _toString2.call(state.dump);
|
|
33061
|
+
var inblock = block;
|
|
33062
|
+
var tagStr;
|
|
33063
|
+
if (block) {
|
|
33064
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
33065
|
+
}
|
|
33066
|
+
var objectOrArray = type3 === "[object Object]" || type3 === "[object Array]", duplicateIndex, duplicate;
|
|
33067
|
+
if (objectOrArray) {
|
|
33068
|
+
duplicateIndex = state.duplicates.indexOf(object4);
|
|
33069
|
+
duplicate = duplicateIndex !== -1;
|
|
33070
|
+
}
|
|
33071
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
33072
|
+
compact = false;
|
|
33073
|
+
}
|
|
33074
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
33075
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
33076
|
+
} else {
|
|
33077
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
33078
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
33079
|
+
}
|
|
33080
|
+
if (type3 === "[object Object]") {
|
|
33081
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
33082
|
+
writeBlockMapping2(state, level, state.dump, compact);
|
|
33083
|
+
if (duplicate) {
|
|
33084
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
33085
|
+
}
|
|
33086
|
+
} else {
|
|
33087
|
+
writeFlowMapping2(state, level, state.dump);
|
|
33088
|
+
if (duplicate) {
|
|
33089
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
33090
|
+
}
|
|
33091
|
+
}
|
|
33092
|
+
} else if (type3 === "[object Array]") {
|
|
33093
|
+
if (block && state.dump.length !== 0) {
|
|
33094
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
33095
|
+
writeBlockSequence2(state, level - 1, state.dump, compact);
|
|
33096
|
+
} else {
|
|
33097
|
+
writeBlockSequence2(state, level, state.dump, compact);
|
|
33098
|
+
}
|
|
33099
|
+
if (duplicate) {
|
|
33100
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
33101
|
+
}
|
|
33102
|
+
} else {
|
|
33103
|
+
writeFlowSequence2(state, level, state.dump);
|
|
33104
|
+
if (duplicate) {
|
|
33105
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
33106
|
+
}
|
|
33107
|
+
}
|
|
33108
|
+
} else if (type3 === "[object String]") {
|
|
33109
|
+
if (state.tag !== "?") {
|
|
33110
|
+
writeScalar2(state, state.dump, level, iskey, inblock);
|
|
33111
|
+
}
|
|
33112
|
+
} else if (type3 === "[object Undefined]") {
|
|
33113
|
+
return false;
|
|
33114
|
+
} else {
|
|
33115
|
+
if (state.skipInvalid)
|
|
33116
|
+
return false;
|
|
33117
|
+
throw new exception2("unacceptable kind of an object to dump " + type3);
|
|
33118
|
+
}
|
|
33119
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
33120
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
33121
|
+
if (state.tag[0] === "!") {
|
|
33122
|
+
tagStr = "!" + tagStr;
|
|
33123
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
33124
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
33125
|
+
} else {
|
|
33126
|
+
tagStr = "!<" + tagStr + ">";
|
|
33127
|
+
}
|
|
33128
|
+
state.dump = tagStr + " " + state.dump;
|
|
33129
|
+
}
|
|
33130
|
+
}
|
|
33131
|
+
return true;
|
|
33132
|
+
}
|
|
33133
|
+
function getDuplicateReferences2(object4, state) {
|
|
33134
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
33135
|
+
inspectNode2(object4, objects, duplicatesIndexes);
|
|
33136
|
+
for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
|
|
33137
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
33138
|
+
}
|
|
33139
|
+
state.usedDuplicates = new Array(length);
|
|
33140
|
+
}
|
|
33141
|
+
function inspectNode2(object4, objects, duplicatesIndexes) {
|
|
33142
|
+
var objectKeyList, index, length;
|
|
33143
|
+
if (object4 !== null && typeof object4 === "object") {
|
|
33144
|
+
index = objects.indexOf(object4);
|
|
33145
|
+
if (index !== -1) {
|
|
33146
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
33147
|
+
duplicatesIndexes.push(index);
|
|
33148
|
+
}
|
|
33149
|
+
} else {
|
|
33150
|
+
objects.push(object4);
|
|
33151
|
+
if (Array.isArray(object4)) {
|
|
33152
|
+
for (index = 0, length = object4.length;index < length; index += 1) {
|
|
33153
|
+
inspectNode2(object4[index], objects, duplicatesIndexes);
|
|
33154
|
+
}
|
|
33155
|
+
} else {
|
|
33156
|
+
objectKeyList = Object.keys(object4);
|
|
33157
|
+
for (index = 0, length = objectKeyList.length;index < length; index += 1) {
|
|
33158
|
+
inspectNode2(object4[objectKeyList[index]], objects, duplicatesIndexes);
|
|
33159
|
+
}
|
|
33160
|
+
}
|
|
33161
|
+
}
|
|
33162
|
+
}
|
|
33163
|
+
}
|
|
33164
|
+
function dump$12(input, options) {
|
|
33165
|
+
options = options || {};
|
|
33166
|
+
var state = new State2(options);
|
|
33167
|
+
if (!state.noRefs)
|
|
33168
|
+
getDuplicateReferences2(input, state);
|
|
33169
|
+
var value = input;
|
|
33170
|
+
if (state.replacer) {
|
|
33171
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
33172
|
+
}
|
|
33173
|
+
if (writeNode2(state, 0, value, true, true))
|
|
33174
|
+
return state.dump + `
|
|
33175
|
+
`;
|
|
33176
|
+
return "";
|
|
33177
|
+
}
|
|
33178
|
+
var dump_12 = dump$12;
|
|
33179
|
+
var dumper2 = {
|
|
33180
|
+
dump: dump_12
|
|
33181
|
+
};
|
|
33182
|
+
function renamed2(from, to) {
|
|
33183
|
+
return function() {
|
|
33184
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
|
|
33185
|
+
};
|
|
33186
|
+
}
|
|
33187
|
+
var load2 = loader2.load;
|
|
33188
|
+
var loadAll2 = loader2.loadAll;
|
|
33189
|
+
var dump2 = dumper2.dump;
|
|
33190
|
+
var safeLoad2 = renamed2("safeLoad", "load");
|
|
33191
|
+
var safeLoadAll2 = renamed2("safeLoadAll", "loadAll");
|
|
33192
|
+
var safeDump2 = renamed2("safeDump", "dump");
|
|
33193
|
+
|
|
33194
|
+
// node_modules/pg-connection-string/esm/index.mjs
|
|
33195
|
+
var import___ = __toESM(require_pg_connection_string(), 1);
|
|
33196
|
+
var esm_default = import___.default.parse;
|
|
33197
|
+
var parse5 = import___.default.parse;
|
|
33198
|
+
var toClientConfig = import___.default.toClientConfig;
|
|
33199
|
+
var parseIntoClientConfig = import___.default.parseIntoClientConfig;
|
|
33200
|
+
|
|
33201
|
+
// lib/instances.ts
|
|
33202
|
+
class InstancesParseError extends Error {
|
|
33203
|
+
constructor(file, cause) {
|
|
33204
|
+
const causeMsg = cause instanceof Error ? cause.message : String(cause);
|
|
33205
|
+
super(`Failed to parse ${file}: ${causeMsg}`);
|
|
33206
|
+
this.name = "InstancesParseError";
|
|
33207
|
+
}
|
|
33208
|
+
}
|
|
33209
|
+
function loadInstances(file) {
|
|
33210
|
+
if (!fs7.existsSync(file))
|
|
33211
|
+
return [];
|
|
33212
|
+
if (fs7.lstatSync(file).isDirectory())
|
|
33213
|
+
return [];
|
|
33214
|
+
const text = fs7.readFileSync(file, "utf8");
|
|
33215
|
+
if (text.trim() === "")
|
|
33216
|
+
return [];
|
|
33217
|
+
let parsed;
|
|
33218
|
+
try {
|
|
33219
|
+
parsed = load2(text);
|
|
33220
|
+
} catch (err) {
|
|
33221
|
+
throw new InstancesParseError(file, err);
|
|
33222
|
+
}
|
|
33223
|
+
if (parsed === null || parsed === undefined)
|
|
33224
|
+
return [];
|
|
33225
|
+
if (!Array.isArray(parsed)) {
|
|
33226
|
+
throw new InstancesParseError(file, "expected a YAML list at the document root");
|
|
33227
|
+
}
|
|
33228
|
+
return parsed;
|
|
33229
|
+
}
|
|
33230
|
+
function buildInstance(name, connStr) {
|
|
33231
|
+
return {
|
|
33232
|
+
name,
|
|
33233
|
+
conn_str: connStr,
|
|
33234
|
+
preset_metrics: "full",
|
|
33235
|
+
custom_metrics: null,
|
|
33236
|
+
is_enabled: true,
|
|
33237
|
+
group: "default",
|
|
33238
|
+
custom_tags: {
|
|
33239
|
+
env: "production",
|
|
33240
|
+
cluster: "default",
|
|
33241
|
+
node_name: name,
|
|
33242
|
+
sink_type: "~sink_type~"
|
|
33243
|
+
}
|
|
33244
|
+
};
|
|
33245
|
+
}
|
|
33246
|
+
function addInstanceToFile(file, instance) {
|
|
33247
|
+
if (fs7.existsSync(file) && fs7.lstatSync(file).isDirectory()) {
|
|
33248
|
+
fs7.rmSync(file, { recursive: true, force: true });
|
|
33249
|
+
}
|
|
33250
|
+
const existing = loadInstances(file);
|
|
33251
|
+
if (existing.some((i3) => i3.name === instance.name)) {
|
|
33252
|
+
throw new Error(`Monitoring target '${instance.name}' already exists`);
|
|
33253
|
+
}
|
|
33254
|
+
existing.push(instance);
|
|
33255
|
+
fs7.writeFileSync(file, dump2(existing), "utf8");
|
|
33256
|
+
}
|
|
33257
|
+
function removeInstanceFromFile(file, name) {
|
|
33258
|
+
const instances = loadInstances(file);
|
|
33259
|
+
const filtered = instances.filter((i3) => i3.name !== name);
|
|
33260
|
+
if (filtered.length === instances.length)
|
|
33261
|
+
return false;
|
|
33262
|
+
fs7.writeFileSync(file, dump2(filtered), "utf8");
|
|
33263
|
+
return true;
|
|
33264
|
+
}
|
|
33265
|
+
function extractSslmode(connStr) {
|
|
33266
|
+
try {
|
|
33267
|
+
return (new URL(connStr).searchParams.get("sslmode") || "").toLowerCase();
|
|
33268
|
+
} catch {
|
|
33269
|
+
return "";
|
|
33270
|
+
}
|
|
33271
|
+
}
|
|
33272
|
+
function sslOptionFromSslmode(sslmode) {
|
|
33273
|
+
switch (sslmode) {
|
|
33274
|
+
case "disable":
|
|
33275
|
+
return false;
|
|
33276
|
+
case "verify-ca":
|
|
33277
|
+
return { rejectUnauthorized: true, checkServerIdentity: () => {
|
|
33278
|
+
return;
|
|
33279
|
+
} };
|
|
33280
|
+
case "verify-full":
|
|
33281
|
+
return { rejectUnauthorized: true };
|
|
33282
|
+
case "allow":
|
|
33283
|
+
case "prefer":
|
|
33284
|
+
case "require":
|
|
33285
|
+
case "no-verify":
|
|
33286
|
+
case "":
|
|
33287
|
+
default:
|
|
33288
|
+
return { rejectUnauthorized: false };
|
|
33289
|
+
}
|
|
33290
|
+
}
|
|
33291
|
+
var LAX_SSLMODES = new Set(["", "allow", "prefer", "require"]);
|
|
33292
|
+
function isLaxSslmode(sslmode) {
|
|
33293
|
+
return LAX_SSLMODES.has(sslmode);
|
|
33294
|
+
}
|
|
33295
|
+
function warnIfLaxSslmode(connStr) {
|
|
33296
|
+
const sslmode = extractSslmode(connStr);
|
|
33297
|
+
if (!isLaxSslmode(sslmode))
|
|
33298
|
+
return;
|
|
33299
|
+
const shown = sslmode || "(unset)";
|
|
33300
|
+
console.error(`⚠ sslmode=${shown}: TLS chain is NOT verified (matches libpq/psql semantics). ` + `Use sslmode=verify-full for full chain+hostname verification.`);
|
|
33301
|
+
}
|
|
33302
|
+
function buildClientConfig(connStr, extra = {}) {
|
|
33303
|
+
const sslmode = extractSslmode(connStr);
|
|
33304
|
+
const parsed = parse5(withoutSslmode(connStr));
|
|
33305
|
+
return {
|
|
33306
|
+
host: parsed.host || undefined,
|
|
33307
|
+
port: parsed.port ? Number(parsed.port) : undefined,
|
|
33308
|
+
user: parsed.user,
|
|
33309
|
+
password: parsed.password,
|
|
33310
|
+
database: parsed.database || undefined,
|
|
33311
|
+
ssl: sslOptionFromSslmode(sslmode),
|
|
33312
|
+
...extra
|
|
33313
|
+
};
|
|
33314
|
+
}
|
|
33315
|
+
function withoutSslmode(connStr) {
|
|
33316
|
+
try {
|
|
33317
|
+
const u = new URL(connStr);
|
|
33318
|
+
u.searchParams.delete("sslmode");
|
|
33319
|
+
return u.toString();
|
|
33320
|
+
} catch {
|
|
33321
|
+
return connStr;
|
|
33322
|
+
}
|
|
33323
|
+
}
|
|
33324
|
+
|
|
33325
|
+
// bin/postgres-ai.ts
|
|
33326
|
+
var nodeVersion = parseInt(process.versions.node.split(".")[0], 10);
|
|
33327
|
+
if (nodeVersion < 18) {
|
|
33328
|
+
console.error(`\x1B[31mError: postgresai requires Node 18 or higher.\x1B[0m`);
|
|
33329
|
+
console.error(`You are running Node.js ${process.versions.node}.`);
|
|
33330
|
+
console.error(`Please upgrade to Node.js 20 LTS or Node.js 22 for security updates.`);
|
|
33331
|
+
console.error(`
|
|
33332
|
+
Download: https://nodejs.org/`);
|
|
33333
|
+
process.exit(1);
|
|
33334
|
+
}
|
|
33335
|
+
var rl = null;
|
|
33336
|
+
function getReadline() {
|
|
33337
|
+
if (!rl) {
|
|
33338
|
+
rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
33339
|
+
}
|
|
33340
|
+
return rl;
|
|
33341
|
+
}
|
|
33342
|
+
function closeReadline() {
|
|
33343
|
+
if (rl) {
|
|
33344
|
+
rl.close();
|
|
33345
|
+
rl = null;
|
|
33346
|
+
}
|
|
33347
|
+
}
|
|
33348
|
+
function stripMatchingQuotes(value) {
|
|
33349
|
+
const trimmed = value.trim();
|
|
33350
|
+
const quote = trimmed[0];
|
|
33351
|
+
if (trimmed.length >= 2 && (quote === '"' || quote === "'") && trimmed.endsWith(quote)) {
|
|
33352
|
+
return trimmed.slice(1, -1);
|
|
33353
|
+
}
|
|
33354
|
+
return trimmed;
|
|
33355
|
+
}
|
|
33356
|
+
async function execFilePromise(file, args) {
|
|
33357
|
+
return new Promise((resolve8, reject) => {
|
|
33358
|
+
childProcess.execFile(file, args, (error2, stdout, stderr) => {
|
|
33359
|
+
if (error2) {
|
|
33360
|
+
const err = error2;
|
|
33361
|
+
err.code = typeof error2.code === "number" ? error2.code : 1;
|
|
33362
|
+
reject(err);
|
|
33363
|
+
} else {
|
|
33364
|
+
resolve8({ stdout, stderr });
|
|
33365
|
+
}
|
|
33366
|
+
});
|
|
33367
|
+
});
|
|
33368
|
+
}
|
|
33369
|
+
function spawnSync2(cmd, args, options) {
|
|
33370
|
+
const result = childProcess.spawnSync(cmd, args, {
|
|
33371
|
+
stdio: options?.stdio === "inherit" ? "inherit" : "pipe",
|
|
33372
|
+
env: options?.env,
|
|
33373
|
+
cwd: options?.cwd,
|
|
33374
|
+
encoding: "utf8"
|
|
33375
|
+
});
|
|
33376
|
+
return {
|
|
33377
|
+
status: result.status,
|
|
33378
|
+
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
33379
|
+
stderr: typeof result.stderr === "string" ? result.stderr : ""
|
|
33380
|
+
};
|
|
33381
|
+
}
|
|
33382
|
+
function spawn2(cmd, args, options) {
|
|
33383
|
+
const proc = childProcess.spawn(cmd, args, {
|
|
33384
|
+
stdio: options?.stdio ?? "pipe",
|
|
33385
|
+
env: options?.env,
|
|
33386
|
+
cwd: options?.cwd,
|
|
33387
|
+
detached: options?.detached
|
|
33388
|
+
});
|
|
33389
|
+
return {
|
|
33390
|
+
on(event, cb) {
|
|
33391
|
+
if (event === "close" || event === "exit") {
|
|
33392
|
+
proc.on(event, (code, signal) => cb(code, signal ?? undefined));
|
|
33393
|
+
} else if (event === "error") {
|
|
33394
|
+
proc.on("error", (err) => cb(null, String(err)));
|
|
33395
|
+
}
|
|
33396
|
+
return this;
|
|
33397
|
+
},
|
|
33398
|
+
unref() {
|
|
33399
|
+
proc.unref();
|
|
33400
|
+
},
|
|
33401
|
+
pid: proc.pid
|
|
33402
|
+
};
|
|
33403
|
+
}
|
|
33404
|
+
async function question(prompt) {
|
|
33405
|
+
return new Promise((resolve8) => {
|
|
33406
|
+
getReadline().question(prompt, (answer) => {
|
|
33407
|
+
resolve8(answer);
|
|
33408
|
+
});
|
|
33409
|
+
});
|
|
33410
|
+
}
|
|
33411
|
+
function expandHomePath(p) {
|
|
33412
|
+
const s = (p || "").trim();
|
|
33413
|
+
if (!s)
|
|
33414
|
+
return s;
|
|
33415
|
+
if (s === "~")
|
|
33416
|
+
return os3.homedir();
|
|
33417
|
+
if (s.startsWith("~/") || s.startsWith("~\\")) {
|
|
33418
|
+
return path7.join(os3.homedir(), s.slice(2));
|
|
33419
|
+
}
|
|
33420
|
+
return s;
|
|
33421
|
+
}
|
|
33422
|
+
function createTtySpinner(enabled, initialText) {
|
|
33423
|
+
if (!enabled) {
|
|
33424
|
+
return {
|
|
33425
|
+
update: () => {},
|
|
33426
|
+
stop: () => {}
|
|
33427
|
+
};
|
|
33428
|
+
}
|
|
33429
|
+
const frames = ["|", "/", "-", "\\"];
|
|
33430
|
+
const startTs = Date.now();
|
|
33431
|
+
let text = initialText;
|
|
33432
|
+
let frameIdx = 0;
|
|
33433
|
+
let stopped = false;
|
|
33434
|
+
const render = () => {
|
|
33435
|
+
if (stopped)
|
|
33436
|
+
return;
|
|
33437
|
+
const elapsedSec = ((Date.now() - startTs) / 1000).toFixed(1);
|
|
33438
|
+
const frame = frames[frameIdx % frames.length] ?? frames[0] ?? "\u283F";
|
|
33439
|
+
frameIdx += 1;
|
|
33440
|
+
process.stdout.write(`\r\x1B[2K${frame} ${text} (${elapsedSec}s)`);
|
|
33441
|
+
};
|
|
33442
|
+
const timer = setInterval(render, 120);
|
|
33443
|
+
render();
|
|
33444
|
+
return {
|
|
33445
|
+
update: (t) => {
|
|
33446
|
+
text = t;
|
|
33447
|
+
render();
|
|
33448
|
+
},
|
|
33449
|
+
stop: (finalText) => {
|
|
33450
|
+
if (stopped)
|
|
33451
|
+
return;
|
|
33452
|
+
stopped = true;
|
|
33453
|
+
clearInterval(timer);
|
|
33454
|
+
process.stdout.write("\r\x1B[2K");
|
|
33455
|
+
if (finalText && finalText.trim()) {
|
|
33456
|
+
process.stdout.write(finalText);
|
|
33457
|
+
}
|
|
33458
|
+
process.stdout.write(`
|
|
33459
|
+
`);
|
|
33460
|
+
}
|
|
33461
|
+
};
|
|
33462
|
+
}
|
|
33463
|
+
function prepareOutputDirectory(outputOpt) {
|
|
33464
|
+
if (!outputOpt)
|
|
33465
|
+
return;
|
|
33466
|
+
const outputDir = expandHomePath(outputOpt);
|
|
33467
|
+
const outputPath = path7.isAbsolute(outputDir) ? outputDir : path7.resolve(process.cwd(), outputDir);
|
|
33468
|
+
if (!fs8.existsSync(outputPath)) {
|
|
33469
|
+
try {
|
|
33470
|
+
fs8.mkdirSync(outputPath, { recursive: true });
|
|
33471
|
+
} catch (e) {
|
|
33472
|
+
const errAny = e;
|
|
33473
|
+
const code = typeof errAny?.code === "string" ? errAny.code : "";
|
|
33474
|
+
const msg = errAny instanceof Error ? errAny.message : String(errAny);
|
|
33475
|
+
if (code === "EACCES" || code === "EPERM" || code === "ENOENT") {
|
|
33476
|
+
console.error(`Error: Failed to create output directory: ${outputPath}`);
|
|
33477
|
+
console.error(`Reason: ${msg}`);
|
|
33478
|
+
console.error("Tip: choose a writable path, e.g. --output ./reports or --output ~/reports");
|
|
33479
|
+
return null;
|
|
33480
|
+
}
|
|
33481
|
+
throw e;
|
|
33482
|
+
}
|
|
33483
|
+
}
|
|
33484
|
+
return outputPath;
|
|
33485
|
+
}
|
|
33486
|
+
function prepareUploadConfig(opts, rootOpts, shouldUpload, uploadExplicitlyRequested) {
|
|
33487
|
+
if (!shouldUpload)
|
|
33488
|
+
return;
|
|
33489
|
+
const { apiKey } = getConfig(rootOpts);
|
|
33490
|
+
if (!apiKey) {
|
|
33491
|
+
if (uploadExplicitlyRequested) {
|
|
33492
|
+
console.error("Error: API key is required for upload");
|
|
33493
|
+
console.error("Tip: run 'postgresai auth' or pass --api-key / set PGAI_API_KEY");
|
|
33494
|
+
return null;
|
|
33495
|
+
}
|
|
33496
|
+
return;
|
|
33497
|
+
}
|
|
33498
|
+
const cfg = readConfig();
|
|
33499
|
+
const { apiBaseUrl } = resolveBaseUrls2(rootOpts, cfg);
|
|
33500
|
+
let project = (opts.project || cfg.defaultProject || "").trim();
|
|
33501
|
+
let projectWasGenerated = false;
|
|
33502
|
+
if (!project) {
|
|
33503
|
+
project = `project_${crypto2.randomBytes(6).toString("hex")}`;
|
|
33504
|
+
projectWasGenerated = true;
|
|
33505
|
+
try {
|
|
33506
|
+
writeConfig({ defaultProject: project });
|
|
33507
|
+
} catch (e) {
|
|
33508
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
33509
|
+
console.error(`Warning: Failed to save generated default project: ${message}`);
|
|
33510
|
+
}
|
|
33511
|
+
}
|
|
33512
|
+
return {
|
|
33513
|
+
config: { apiKey, apiBaseUrl, project },
|
|
33514
|
+
projectWasGenerated
|
|
33515
|
+
};
|
|
33516
|
+
}
|
|
33517
|
+
async function uploadCheckupReports(uploadCfg, reports, spinner, logUpload) {
|
|
33518
|
+
spinner.update("Creating remote checkup report");
|
|
33519
|
+
const created = await withRetry(() => createCheckupReport({
|
|
33520
|
+
apiKey: uploadCfg.apiKey,
|
|
33521
|
+
apiBaseUrl: uploadCfg.apiBaseUrl,
|
|
33522
|
+
project: uploadCfg.project
|
|
33523
|
+
}), { maxAttempts: 3 }, (attempt, err, delayMs) => {
|
|
33524
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
33525
|
+
logUpload(`[Retry ${attempt}/3] createCheckupReport failed: ${errMsg}, retrying in ${delayMs}ms...`);
|
|
33526
|
+
});
|
|
33527
|
+
const reportId = created.reportId;
|
|
33528
|
+
const uploaded = [];
|
|
33529
|
+
for (const [checkId, report] of Object.entries(reports)) {
|
|
33530
|
+
spinner.update(`Uploading ${checkId}.json`);
|
|
33531
|
+
const jsonText = JSON.stringify(report, null, 2);
|
|
33532
|
+
const r = await withRetry(() => uploadCheckupReportJson({
|
|
33533
|
+
apiKey: uploadCfg.apiKey,
|
|
33534
|
+
apiBaseUrl: uploadCfg.apiBaseUrl,
|
|
33535
|
+
reportId,
|
|
33536
|
+
filename: `${checkId}.json`,
|
|
33537
|
+
checkId,
|
|
33538
|
+
jsonText
|
|
33539
|
+
}), { maxAttempts: 3 }, (attempt, err, delayMs) => {
|
|
33540
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
33541
|
+
logUpload(`[Retry ${attempt}/3] Upload ${checkId}.json failed: ${errMsg}, retrying in ${delayMs}ms...`);
|
|
33542
|
+
});
|
|
33543
|
+
uploaded.push({ checkId, filename: `${checkId}.json`, chunkId: r.reportChunkId });
|
|
33544
|
+
}
|
|
33545
|
+
return { project: uploadCfg.project, reportId, uploaded };
|
|
33546
|
+
}
|
|
33547
|
+
function writeReportFiles(reports, outputPath) {
|
|
33548
|
+
for (const [checkId, report] of Object.entries(reports)) {
|
|
33549
|
+
const filePath = path7.join(outputPath, `${checkId}.json`);
|
|
33550
|
+
fs8.writeFileSync(filePath, JSON.stringify(report, null, 2), "utf8");
|
|
33551
|
+
const title = report.checkTitle || checkId;
|
|
33552
|
+
console.log(`\u2713 ${checkId} ${title}: ${filePath}`);
|
|
33553
|
+
}
|
|
33554
|
+
}
|
|
33555
|
+
function printUploadSummary(summary, projectWasGenerated, useStderr, reports) {
|
|
33556
|
+
const out = useStderr ? console.error : console.log;
|
|
33557
|
+
out(`
|
|
33558
|
+
Checkup report uploaded`);
|
|
33559
|
+
out(`======================
|
|
33560
|
+
`);
|
|
33561
|
+
if (projectWasGenerated) {
|
|
33562
|
+
out(`Project: ${summary.project} (generated and saved as default)`);
|
|
33563
|
+
} else {
|
|
33564
|
+
out(`Project: ${summary.project}`);
|
|
33565
|
+
}
|
|
33566
|
+
out(`Report ID: ${summary.reportId}`);
|
|
33567
|
+
out("View in Console: console.postgres.ai \u2192 Checkup \u2192 checkup reports");
|
|
33568
|
+
out("");
|
|
33569
|
+
const summaries = [];
|
|
33570
|
+
let skippedCount = 0;
|
|
33571
|
+
for (const item of summary.uploaded) {
|
|
33572
|
+
const report = reports[item.checkId];
|
|
33573
|
+
if (report) {
|
|
33574
|
+
const { status, message } = generateCheckSummary(item.checkId, report);
|
|
33575
|
+
const title = report.checkTitle || item.checkId;
|
|
33576
|
+
const isSignificant = status !== "info" || /\d/.test(message) || message.includes("PostgreSQL") || message.includes("Version");
|
|
33577
|
+
if (isSignificant) {
|
|
33578
|
+
summaries.push({ checkId: item.checkId, title, status, message });
|
|
33579
|
+
} else {
|
|
33580
|
+
skippedCount++;
|
|
33581
|
+
}
|
|
33582
|
+
}
|
|
33583
|
+
}
|
|
33584
|
+
for (const { checkId, title, message } of summaries) {
|
|
33585
|
+
out(` ${checkId} (${title}): ${message}`);
|
|
33586
|
+
}
|
|
33587
|
+
if (skippedCount > 0) {
|
|
33588
|
+
out(` ${skippedCount} other check${skippedCount > 1 ? "s" : ""} completed`);
|
|
33589
|
+
}
|
|
33590
|
+
}
|
|
33591
|
+
function getDefaultMonitoringProjectDir() {
|
|
33592
|
+
const override = process.env.PGAI_PROJECT_DIR;
|
|
33593
|
+
if (override && override.trim())
|
|
33594
|
+
return override.trim();
|
|
33595
|
+
return path7.join(getConfigDir(), "monitoring");
|
|
33596
|
+
}
|
|
33597
|
+
async function downloadText(url) {
|
|
33598
|
+
const controller = new AbortController;
|
|
33599
|
+
const timeout = setTimeout(() => controller.abort(), 15000);
|
|
33600
|
+
try {
|
|
33601
|
+
const response = await fetch(url, { signal: controller.signal });
|
|
33602
|
+
if (!response.ok) {
|
|
33603
|
+
throw new Error(`HTTP ${response.status} for ${url}`);
|
|
33604
|
+
}
|
|
33605
|
+
return await response.text();
|
|
33606
|
+
} finally {
|
|
33607
|
+
clearTimeout(timeout);
|
|
33608
|
+
}
|
|
33609
|
+
}
|
|
33610
|
+
async function ensureDefaultMonitoringProject() {
|
|
33611
|
+
const projectDir = getDefaultMonitoringProjectDir();
|
|
33612
|
+
const composeFile = path7.resolve(projectDir, "docker-compose.yml");
|
|
33613
|
+
const instancesFile = path7.resolve(projectDir, "instances.yml");
|
|
33614
|
+
if (!fs8.existsSync(projectDir)) {
|
|
33615
|
+
fs8.mkdirSync(projectDir, { recursive: true, mode: 448 });
|
|
33616
|
+
}
|
|
33617
|
+
if (!fs8.existsSync(composeFile)) {
|
|
33618
|
+
const refs = [
|
|
33619
|
+
process.env.PGAI_PROJECT_REF,
|
|
33620
|
+
package_default.version,
|
|
33621
|
+
`v${package_default.version}`,
|
|
33622
|
+
"main"
|
|
33623
|
+
].filter((v) => Boolean(v && v.trim()));
|
|
33624
|
+
let lastErr;
|
|
33625
|
+
for (const ref of refs) {
|
|
33626
|
+
const url = `https://gitlab.com/postgres-ai/postgres_ai/-/raw/${encodeURIComponent(ref)}/docker-compose.yml`;
|
|
33627
|
+
try {
|
|
33628
|
+
const text = await downloadText(url);
|
|
33629
|
+
fs8.writeFileSync(composeFile, text, { encoding: "utf8", mode: 384 });
|
|
33630
|
+
break;
|
|
33631
|
+
} catch (err) {
|
|
33632
|
+
lastErr = err;
|
|
33633
|
+
}
|
|
33634
|
+
}
|
|
33635
|
+
if (!fs8.existsSync(composeFile)) {
|
|
33636
|
+
const msg = lastErr instanceof Error ? lastErr.message : String(lastErr);
|
|
33637
|
+
throw new Error(`Failed to bootstrap docker-compose.yml: ${msg}`);
|
|
33638
|
+
}
|
|
33639
|
+
}
|
|
33640
|
+
if (fs8.existsSync(instancesFile) && fs8.lstatSync(instancesFile).isDirectory()) {
|
|
33641
|
+
fs8.rmSync(instancesFile, { recursive: true, force: true });
|
|
33642
|
+
}
|
|
33643
|
+
if (!fs8.existsSync(instancesFile)) {
|
|
33644
|
+
const header = `# PostgreSQL instances to monitor
|
|
33645
|
+
` + `# Add your instances using: pgai mon targets add <connection-string> <name>
|
|
33646
|
+
|
|
33647
|
+
`;
|
|
33648
|
+
fs8.writeFileSync(instancesFile, header, { encoding: "utf8", mode: 384 });
|
|
33649
|
+
}
|
|
33650
|
+
const pgwatchConfig = path7.resolve(projectDir, ".pgwatch-config");
|
|
33651
|
+
if (!fs8.existsSync(pgwatchConfig)) {
|
|
33652
|
+
fs8.writeFileSync(pgwatchConfig, "", { encoding: "utf8", mode: 384 });
|
|
33653
|
+
}
|
|
33654
|
+
const envFile = path7.resolve(projectDir, ".env");
|
|
33655
|
+
if (!fs8.existsSync(envFile)) {
|
|
33656
|
+
const envText = `PGAI_TAG=${package_default.version}
|
|
33657
|
+
# PGAI_REGISTRY=registry.gitlab.com/postgres-ai/postgres_ai
|
|
33658
|
+
`;
|
|
33659
|
+
fs8.writeFileSync(envFile, envText, { encoding: "utf8", mode: 384 });
|
|
33660
|
+
}
|
|
33661
|
+
return { fs: fs8, path: path7, projectDir, composeFile, instancesFile };
|
|
33662
|
+
}
|
|
33663
|
+
function getConfig(opts) {
|
|
33664
|
+
let apiKey = opts.apiKey || process.env.PGAI_API_KEY || "";
|
|
33665
|
+
if (!apiKey) {
|
|
33666
|
+
const fileConfig = readConfig();
|
|
33667
|
+
if (!apiKey)
|
|
33668
|
+
apiKey = fileConfig.apiKey || "";
|
|
33669
|
+
}
|
|
33670
|
+
return { apiKey };
|
|
33671
|
+
}
|
|
33672
|
+
function printResult(result, json3) {
|
|
33673
|
+
if (typeof result === "string") {
|
|
33674
|
+
process.stdout.write(result);
|
|
33675
|
+
if (!/\n$/.test(result))
|
|
33676
|
+
console.log();
|
|
33677
|
+
return;
|
|
33678
|
+
}
|
|
33679
|
+
if (json3 || !process.stdout.isTTY) {
|
|
33680
|
+
console.log(JSON.stringify(result, null, 2));
|
|
33681
|
+
} else {
|
|
33682
|
+
let text = dump(result);
|
|
33683
|
+
if (Array.isArray(result)) {
|
|
33684
|
+
text = text.replace(/\n- /g, `
|
|
33685
|
+
|
|
33686
|
+
- `);
|
|
33687
|
+
}
|
|
33688
|
+
console.log(text);
|
|
33689
|
+
}
|
|
33690
|
+
}
|
|
33691
|
+
var program2 = new Command;
|
|
33692
|
+
program2.name("postgres-ai").description("PostgresAI CLI").version(package_default.version).option("--api-key <key>", "API key (overrides PGAI_API_KEY)").option("--api-base-url <url>", "API base URL for backend RPC (overrides PGAI_API_BASE_URL)").option("--ui-base-url <url>", "UI base URL for browser routes (overrides PGAI_UI_BASE_URL)").option("--storage-base-url <url>", "Storage base URL for file uploads (overrides PGAI_STORAGE_BASE_URL)");
|
|
33693
|
+
program2.command("set-default-project <project>").description("store default project for checkup uploads").action(async (project) => {
|
|
33694
|
+
const value = (project || "").trim();
|
|
33695
|
+
if (!value) {
|
|
33696
|
+
console.error("Error: project is required");
|
|
33697
|
+
process.exitCode = 1;
|
|
33698
|
+
return;
|
|
33699
|
+
}
|
|
33700
|
+
writeConfig({ defaultProject: value });
|
|
33701
|
+
console.log(`Default project saved: ${value}`);
|
|
33702
|
+
});
|
|
33703
|
+
program2.command("set-storage-url <url>").description("store storage base URL for file uploads").action(async (url) => {
|
|
33704
|
+
const value = (url || "").trim();
|
|
33705
|
+
if (!value) {
|
|
33706
|
+
console.error("Error: url is required");
|
|
33707
|
+
process.exitCode = 1;
|
|
33708
|
+
return;
|
|
33709
|
+
}
|
|
33710
|
+
try {
|
|
33711
|
+
const { normalizeBaseUrl: normalizeBaseUrl3 } = await Promise.resolve().then(() => (init_util(), exports_util2));
|
|
33712
|
+
const normalized = normalizeBaseUrl3(value);
|
|
33713
|
+
writeConfig({ storageBaseUrl: normalized });
|
|
30933
33714
|
console.log(`Storage URL saved: ${normalized}`);
|
|
30934
33715
|
} catch {
|
|
30935
33716
|
console.error(`Error: invalid URL: ${value}`);
|
|
@@ -32093,9 +34874,9 @@ function resolvePaths() {
|
|
|
32093
34874
|
let currentDir = startDir;
|
|
32094
34875
|
while (true) {
|
|
32095
34876
|
const composeFile = path7.resolve(currentDir, "docker-compose.yml");
|
|
32096
|
-
if (
|
|
34877
|
+
if (fs8.existsSync(composeFile)) {
|
|
32097
34878
|
const instancesFile = path7.resolve(currentDir, "instances.yml");
|
|
32098
|
-
return { fs:
|
|
34879
|
+
return { fs: fs8, path: path7, projectDir: currentDir, composeFile, instancesFile };
|
|
32099
34880
|
}
|
|
32100
34881
|
const parentDir = path7.dirname(currentDir);
|
|
32101
34882
|
if (parentDir === currentDir)
|
|
@@ -32179,10 +34960,10 @@ Debug: Registering monitoring instance...`);
|
|
|
32179
34960
|
}
|
|
32180
34961
|
function updatePgwatchConfig(configPath, updates) {
|
|
32181
34962
|
let lines = [];
|
|
32182
|
-
if (
|
|
32183
|
-
const stats =
|
|
34963
|
+
if (fs8.existsSync(configPath)) {
|
|
34964
|
+
const stats = fs8.statSync(configPath);
|
|
32184
34965
|
if (!stats.isDirectory()) {
|
|
32185
|
-
const content =
|
|
34966
|
+
const content = fs8.readFileSync(configPath, "utf8");
|
|
32186
34967
|
lines = content.split(/\r?\n/).filter((l) => l.trim() !== "");
|
|
32187
34968
|
}
|
|
32188
34969
|
}
|
|
@@ -32194,7 +34975,7 @@ function updatePgwatchConfig(configPath, updates) {
|
|
|
32194
34975
|
lines.push(`${key}=${value}`);
|
|
32195
34976
|
}
|
|
32196
34977
|
}
|
|
32197
|
-
|
|
34978
|
+
fs8.writeFileSync(configPath, lines.join(`
|
|
32198
34979
|
`) + `
|
|
32199
34980
|
`, { encoding: "utf8", mode: 384 });
|
|
32200
34981
|
}
|
|
@@ -32225,11 +35006,11 @@ async function runCompose(args, grafanaPassword) {
|
|
|
32225
35006
|
env.GF_SECURITY_ADMIN_PASSWORD = grafanaPassword;
|
|
32226
35007
|
} else {
|
|
32227
35008
|
const cfgPath = path7.resolve(projectDir, ".pgwatch-config");
|
|
32228
|
-
if (
|
|
35009
|
+
if (fs8.existsSync(cfgPath)) {
|
|
32229
35010
|
try {
|
|
32230
|
-
const stats =
|
|
35011
|
+
const stats = fs8.statSync(cfgPath);
|
|
32231
35012
|
if (!stats.isDirectory()) {
|
|
32232
|
-
const content =
|
|
35013
|
+
const content = fs8.readFileSync(cfgPath, "utf8");
|
|
32233
35014
|
const match = content.match(/^grafana_password=([^\r\n]+)/m);
|
|
32234
35015
|
if (match) {
|
|
32235
35016
|
env.GF_SECURITY_ADMIN_PASSWORD = match[1].trim();
|
|
@@ -32243,9 +35024,9 @@ async function runCompose(args, grafanaPassword) {
|
|
|
32243
35024
|
}
|
|
32244
35025
|
}
|
|
32245
35026
|
const envFilePath = path7.resolve(projectDir, ".env");
|
|
32246
|
-
if (
|
|
35027
|
+
if (fs8.existsSync(envFilePath)) {
|
|
32247
35028
|
try {
|
|
32248
|
-
const envContent =
|
|
35029
|
+
const envContent = fs8.readFileSync(envFilePath, "utf8");
|
|
32249
35030
|
if (!env.VM_AUTH_USERNAME) {
|
|
32250
35031
|
const m = envContent.match(/^VM_AUTH_USERNAME=([^\r\n]+)/m);
|
|
32251
35032
|
if (m)
|
|
@@ -32279,7 +35060,16 @@ program2.command("help", { isDefault: true }).description("show help").action(()
|
|
|
32279
35060
|
program2.outputHelp();
|
|
32280
35061
|
});
|
|
32281
35062
|
var mon = program2.command("mon").description("monitoring services management");
|
|
32282
|
-
mon.command("local-install").description("install local monitoring stack (generate config, start services)").
|
|
35063
|
+
mon.command("local-install").description("install local monitoring stack (generate config, start services)").addHelpText("after", [
|
|
35064
|
+
"",
|
|
35065
|
+
"Networking:",
|
|
35066
|
+
" Compose enables IPv6 on the project's default network so containers can",
|
|
35067
|
+
" reach IPv6-only databases (e.g. Supabase free-tier db.<ref>.supabase.co).",
|
|
35068
|
+
" Override on hosts whose Docker daemon cannot create an IPv6 network:",
|
|
35069
|
+
" PGAI_ENABLE_IPV6=false (accepted: true|false|yes|no, lowercase)",
|
|
35070
|
+
""
|
|
35071
|
+
].join(`
|
|
35072
|
+
`)).option("--demo", "demo mode with sample database", false).option("--api-key <key>", "Postgres AI API key for automated report uploads").option("--db-url <url>", "PostgreSQL connection URL to monitor").option("--tag <tag>", "Docker image tag to use (e.g., 0.14.0, 0.14.0-dev.33)").option("--project <name>", "Docker Compose project name (default: postgres_ai)").option("-y, --yes", "accept all defaults and skip interactive prompts", false).action(async (opts) => {
|
|
32283
35073
|
const globalOpts = program2.opts();
|
|
32284
35074
|
let apiKey = opts.apiKey || globalOpts.apiKey;
|
|
32285
35075
|
console.log(`
|
|
@@ -32304,8 +35094,8 @@ mon.command("local-install").description("install local monitoring stack (genera
|
|
|
32304
35094
|
let existingReplicatorPassword = null;
|
|
32305
35095
|
let existingVmAuthUsername = null;
|
|
32306
35096
|
let existingVmAuthPassword = null;
|
|
32307
|
-
if (
|
|
32308
|
-
const existingEnv =
|
|
35097
|
+
if (fs8.existsSync(envFile)) {
|
|
35098
|
+
const existingEnv = fs8.readFileSync(envFile, "utf8");
|
|
32309
35099
|
const registryMatch = existingEnv.match(/^PGAI_REGISTRY=(.+)$/m);
|
|
32310
35100
|
if (registryMatch)
|
|
32311
35101
|
existingRegistry = registryMatch[1].trim();
|
|
@@ -32333,7 +35123,7 @@ mon.command("local-install").description("install local monitoring stack (genera
|
|
|
32333
35123
|
envLines.push(`REPLICATOR_PASSWORD=${existingReplicatorPassword || crypto2.randomBytes(32).toString("hex")}`);
|
|
32334
35124
|
envLines.push(`VM_AUTH_USERNAME=${existingVmAuthUsername || "vmauth"}`);
|
|
32335
35125
|
envLines.push(`VM_AUTH_PASSWORD=${existingVmAuthPassword || crypto2.randomBytes(18).toString("base64")}`);
|
|
32336
|
-
|
|
35126
|
+
fs8.writeFileSync(envFile, envLines.join(`
|
|
32337
35127
|
`) + `
|
|
32338
35128
|
`, { encoding: "utf8", mode: 384 });
|
|
32339
35129
|
if (opts.tag) {
|
|
@@ -32420,7 +35210,7 @@ Use demo mode without API key: postgres-ai mon local-install --demo`);
|
|
|
32420
35210
|
# Add your instances using: postgres-ai mon targets add
|
|
32421
35211
|
|
|
32422
35212
|
`;
|
|
32423
|
-
|
|
35213
|
+
fs8.writeFileSync(instancesPath2, emptyInstancesContent, "utf8");
|
|
32424
35214
|
console.log(`Instances file: ${instancesPath2}`);
|
|
32425
35215
|
console.log(`Project directory: ${projectDir2}
|
|
32426
35216
|
`);
|
|
@@ -32440,26 +35230,15 @@ Use demo mode without API key: postgres-ai mon local-install --demo`);
|
|
|
32440
35230
|
const host = m[3];
|
|
32441
35231
|
const db = m[5];
|
|
32442
35232
|
const instanceName = `${host}-${db}`.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
32443
|
-
|
|
32444
|
-
conn_str: ${connStr}
|
|
32445
|
-
preset_metrics: full
|
|
32446
|
-
custom_metrics:
|
|
32447
|
-
is_enabled: true
|
|
32448
|
-
group: default
|
|
32449
|
-
custom_tags:
|
|
32450
|
-
env: production
|
|
32451
|
-
cluster: default
|
|
32452
|
-
node_name: ${instanceName}
|
|
32453
|
-
sink_type: ~sink_type~
|
|
32454
|
-
`;
|
|
32455
|
-
fs7.appendFileSync(instancesPath2, body, "utf8");
|
|
35233
|
+
addInstanceToFile(instancesPath2, buildInstance(instanceName, connStr));
|
|
32456
35234
|
console.log(`\u2713 Monitoring target '${instanceName}' added
|
|
32457
35235
|
`);
|
|
32458
35236
|
console.log("Testing connection to the added instance...");
|
|
32459
35237
|
{
|
|
32460
35238
|
let testClient = null;
|
|
32461
35239
|
try {
|
|
32462
|
-
|
|
35240
|
+
warnIfLaxSslmode(connStr);
|
|
35241
|
+
testClient = new Client(buildClientConfig(connStr, { connectionTimeoutMillis: 1e4 }));
|
|
32463
35242
|
await testClient.connect();
|
|
32464
35243
|
const result = await testClient.query("select version();");
|
|
32465
35244
|
console.log("\u2713 Connection successful");
|
|
@@ -32500,26 +35279,15 @@ You can provide either:`);
|
|
|
32500
35279
|
const host = m[3];
|
|
32501
35280
|
const db = m[5];
|
|
32502
35281
|
const instanceName = `${host}-${db}`.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
32503
|
-
|
|
32504
|
-
conn_str: ${connStr}
|
|
32505
|
-
preset_metrics: full
|
|
32506
|
-
custom_metrics:
|
|
32507
|
-
is_enabled: true
|
|
32508
|
-
group: default
|
|
32509
|
-
custom_tags:
|
|
32510
|
-
env: production
|
|
32511
|
-
cluster: default
|
|
32512
|
-
node_name: ${instanceName}
|
|
32513
|
-
sink_type: ~sink_type~
|
|
32514
|
-
`;
|
|
32515
|
-
fs7.appendFileSync(instancesPath2, body, "utf8");
|
|
35282
|
+
addInstanceToFile(instancesPath2, buildInstance(instanceName, connStr));
|
|
32516
35283
|
console.log(`\u2713 Monitoring target '${instanceName}' added
|
|
32517
35284
|
`);
|
|
32518
35285
|
console.log("Testing connection to the added instance...");
|
|
32519
35286
|
{
|
|
32520
35287
|
let testClient = null;
|
|
32521
35288
|
try {
|
|
32522
|
-
|
|
35289
|
+
warnIfLaxSslmode(connStr);
|
|
35290
|
+
testClient = new Client(buildClientConfig(connStr, { connectionTimeoutMillis: 1e4 }));
|
|
32523
35291
|
await testClient.connect();
|
|
32524
35292
|
const result = await testClient.query("select version();");
|
|
32525
35293
|
console.log("\u2713 Connection successful");
|
|
@@ -32551,12 +35319,12 @@ You can provide either:`);
|
|
|
32551
35319
|
path7.resolve(currentDir, "..", "..", "instances.demo.yml"),
|
|
32552
35320
|
path7.resolve(currentDir, "..", "..", "..", "instances.demo.yml")
|
|
32553
35321
|
];
|
|
32554
|
-
const demoSrc = demoCandidates.find((p) =>
|
|
35322
|
+
const demoSrc = demoCandidates.find((p) => fs8.existsSync(p));
|
|
32555
35323
|
if (demoSrc) {
|
|
32556
|
-
if (
|
|
32557
|
-
|
|
35324
|
+
if (fs8.existsSync(instancesPath) && fs8.lstatSync(instancesPath).isDirectory()) {
|
|
35325
|
+
fs8.rmSync(instancesPath, { recursive: true, force: true });
|
|
32558
35326
|
}
|
|
32559
|
-
|
|
35327
|
+
fs8.copyFileSync(demoSrc, instancesPath);
|
|
32560
35328
|
console.log(`\u2713 Demo monitoring target configured
|
|
32561
35329
|
`);
|
|
32562
35330
|
} else {
|
|
@@ -32580,10 +35348,10 @@ Searched: ${demoCandidates.join(", ")}
|
|
|
32580
35348
|
let vmAuthUsername = "";
|
|
32581
35349
|
let vmAuthPassword = "";
|
|
32582
35350
|
try {
|
|
32583
|
-
if (
|
|
32584
|
-
const stats =
|
|
35351
|
+
if (fs8.existsSync(cfgPath)) {
|
|
35352
|
+
const stats = fs8.statSync(cfgPath);
|
|
32585
35353
|
if (!stats.isDirectory()) {
|
|
32586
|
-
const content =
|
|
35354
|
+
const content = fs8.readFileSync(cfgPath, "utf8");
|
|
32587
35355
|
const match = content.match(/^grafana_password=([^\r\n]+)/m);
|
|
32588
35356
|
if (match) {
|
|
32589
35357
|
grafanaPassword = match[1].trim();
|
|
@@ -32595,15 +35363,15 @@ Searched: ${demoCandidates.join(", ")}
|
|
|
32595
35363
|
const { stdout: password } = await execFilePromise("openssl", ["rand", "-base64", "12"]);
|
|
32596
35364
|
grafanaPassword = password.trim().replace(/\n/g, "");
|
|
32597
35365
|
let configContent = "";
|
|
32598
|
-
if (
|
|
32599
|
-
const stats =
|
|
35366
|
+
if (fs8.existsSync(cfgPath)) {
|
|
35367
|
+
const stats = fs8.statSync(cfgPath);
|
|
32600
35368
|
if (!stats.isDirectory()) {
|
|
32601
|
-
configContent =
|
|
35369
|
+
configContent = fs8.readFileSync(cfgPath, "utf8");
|
|
32602
35370
|
}
|
|
32603
35371
|
}
|
|
32604
35372
|
const lines = configContent.split(/\r?\n/).filter((l) => !/^grafana_password=/.test(l));
|
|
32605
35373
|
lines.push(`grafana_password=${grafanaPassword}`);
|
|
32606
|
-
|
|
35374
|
+
fs8.writeFileSync(cfgPath, lines.filter(Boolean).join(`
|
|
32607
35375
|
`) + `
|
|
32608
35376
|
`, "utf8");
|
|
32609
35377
|
}
|
|
@@ -32617,8 +35385,8 @@ Searched: ${demoCandidates.join(", ")}
|
|
|
32617
35385
|
}
|
|
32618
35386
|
try {
|
|
32619
35387
|
const envFile2 = path7.resolve(projectDir, ".env");
|
|
32620
|
-
if (
|
|
32621
|
-
const envContent =
|
|
35388
|
+
if (fs8.existsSync(envFile2)) {
|
|
35389
|
+
const envContent = fs8.readFileSync(envFile2, "utf8");
|
|
32622
35390
|
const userMatch = envContent.match(/^VM_AUTH_USERNAME=([^\r\n]+)/m);
|
|
32623
35391
|
const passMatch = envContent.match(/^VM_AUTH_PASSWORD=([^\r\n]+)/m);
|
|
32624
35392
|
if (userMatch)
|
|
@@ -32634,13 +35402,13 @@ Searched: ${demoCandidates.join(", ")}
|
|
|
32634
35402
|
vmAuthPassword = vmPass.trim().replace(/\n/g, "");
|
|
32635
35403
|
}
|
|
32636
35404
|
let envContent = "";
|
|
32637
|
-
if (
|
|
32638
|
-
envContent =
|
|
35405
|
+
if (fs8.existsSync(envFile2)) {
|
|
35406
|
+
envContent = fs8.readFileSync(envFile2, "utf8");
|
|
32639
35407
|
}
|
|
32640
|
-
const envLines2 = envContent.split(/\r?\n/).filter((l) => !/^VM_AUTH_USERNAME=/.test(l) && !/^VM_AUTH_PASSWORD=/.test(l)).filter((l,
|
|
35408
|
+
const envLines2 = envContent.split(/\r?\n/).filter((l) => !/^VM_AUTH_USERNAME=/.test(l) && !/^VM_AUTH_PASSWORD=/.test(l)).filter((l, i3, arr) => !(i3 === arr.length - 1 && l === ""));
|
|
32641
35409
|
envLines2.push(`VM_AUTH_USERNAME=${vmAuthUsername}`);
|
|
32642
35410
|
envLines2.push(`VM_AUTH_PASSWORD=${vmAuthPassword}`);
|
|
32643
|
-
|
|
35411
|
+
fs8.writeFileSync(envFile2, envLines2.join(`
|
|
32644
35412
|
`) + `
|
|
32645
35413
|
`, { encoding: "utf8", mode: 384 });
|
|
32646
35414
|
}
|
|
@@ -32849,11 +35617,11 @@ mon.command("config").description("show monitoring services configuration").acti
|
|
|
32849
35617
|
console.log(`Project Directory: ${projectDir}`);
|
|
32850
35618
|
console.log(`Docker Compose File: ${composeFile}`);
|
|
32851
35619
|
console.log(`Instances File: ${instancesFile}`);
|
|
32852
|
-
if (
|
|
35620
|
+
if (fs8.existsSync(instancesFile) && !fs8.lstatSync(instancesFile).isDirectory()) {
|
|
32853
35621
|
console.log(`
|
|
32854
35622
|
Instances configuration:
|
|
32855
35623
|
`);
|
|
32856
|
-
const text =
|
|
35624
|
+
const text = fs8.readFileSync(instancesFile, "utf8");
|
|
32857
35625
|
process.stdout.write(text);
|
|
32858
35626
|
if (!/\n$/.test(text))
|
|
32859
35627
|
console.log();
|
|
@@ -32869,7 +35637,7 @@ mon.command("update").description("update monitoring stack").action(async () =>
|
|
|
32869
35637
|
`);
|
|
32870
35638
|
try {
|
|
32871
35639
|
const gitDir = path7.resolve(process.cwd(), ".git");
|
|
32872
|
-
if (!
|
|
35640
|
+
if (!fs8.existsSync(gitDir)) {
|
|
32873
35641
|
console.error("Not a git repository. Cannot update.");
|
|
32874
35642
|
process.exitCode = 1;
|
|
32875
35643
|
return;
|
|
@@ -33024,42 +35792,33 @@ mon.command("check").description("monitoring services system readiness check").a
|
|
|
33024
35792
|
var targets = mon.command("targets").description("manage databases to monitor");
|
|
33025
35793
|
targets.command("list").description("list monitoring target databases").action(async () => {
|
|
33026
35794
|
const { instancesFile: instancesPath, projectDir } = await resolveOrInitPaths();
|
|
33027
|
-
if (!
|
|
35795
|
+
if (!fs8.existsSync(instancesPath) || fs8.lstatSync(instancesPath).isDirectory()) {
|
|
33028
35796
|
console.error(`instances.yml not found in ${projectDir}`);
|
|
33029
35797
|
process.exitCode = 1;
|
|
33030
35798
|
return;
|
|
33031
35799
|
}
|
|
35800
|
+
let instances;
|
|
33032
35801
|
try {
|
|
33033
|
-
|
|
33034
|
-
const instances = load(content);
|
|
33035
|
-
if (!instances || !Array.isArray(instances) || instances.length === 0) {
|
|
33036
|
-
console.log("No monitoring targets configured");
|
|
33037
|
-
console.log("");
|
|
33038
|
-
console.log("To add a monitoring target:");
|
|
33039
|
-
console.log(" postgres-ai mon targets add <connection-string> <name>");
|
|
33040
|
-
console.log("");
|
|
33041
|
-
console.log("Example:");
|
|
33042
|
-
console.log(" postgres-ai mon targets add 'postgresql://user:pass@host:5432/db' my-db");
|
|
33043
|
-
return;
|
|
33044
|
-
}
|
|
33045
|
-
const filtered = instances.filter((inst) => inst.name && inst.is_enabled !== false);
|
|
33046
|
-
if (filtered.length === 0) {
|
|
33047
|
-
console.log("No monitoring targets configured");
|
|
33048
|
-
console.log("");
|
|
33049
|
-
console.log("To add a monitoring target:");
|
|
33050
|
-
console.log(" postgres-ai mon targets add <connection-string> <name>");
|
|
33051
|
-
console.log("");
|
|
33052
|
-
console.log("Example:");
|
|
33053
|
-
console.log(" postgres-ai mon targets add 'postgresql://user:pass@host:5432/db' my-db");
|
|
33054
|
-
return;
|
|
33055
|
-
}
|
|
33056
|
-
for (const inst of filtered) {
|
|
33057
|
-
console.log(`Target: ${inst.name}`);
|
|
33058
|
-
}
|
|
35802
|
+
instances = loadInstances(instancesPath);
|
|
33059
35803
|
} catch (err) {
|
|
33060
35804
|
const message = err instanceof Error ? err.message : String(err);
|
|
33061
35805
|
console.error(`Error parsing instances.yml: ${message}`);
|
|
33062
35806
|
process.exitCode = 1;
|
|
35807
|
+
return;
|
|
35808
|
+
}
|
|
35809
|
+
const filtered = instances.filter((inst) => inst.name && inst.is_enabled !== false);
|
|
35810
|
+
if (filtered.length === 0) {
|
|
35811
|
+
console.log("No monitoring targets configured");
|
|
35812
|
+
console.log("");
|
|
35813
|
+
console.log("To add a monitoring target:");
|
|
35814
|
+
console.log(" postgres-ai mon targets add <connection-string> <name>");
|
|
35815
|
+
console.log("");
|
|
35816
|
+
console.log("Example:");
|
|
35817
|
+
console.log(" postgres-ai mon targets add 'postgresql://user:pass@host:5432/db' my-db");
|
|
35818
|
+
return;
|
|
35819
|
+
}
|
|
35820
|
+
for (const inst of filtered) {
|
|
35821
|
+
console.log(`Target: ${inst.name}`);
|
|
33063
35822
|
}
|
|
33064
35823
|
});
|
|
33065
35824
|
targets.command("add [connStr] [name]").description("add monitoring target database").action(async (connStr, name) => {
|
|
@@ -33079,70 +35838,28 @@ targets.command("add [connStr] [name]").description("add monitoring target datab
|
|
|
33079
35838
|
const db = m[5];
|
|
33080
35839
|
const instanceName = name && name.trim() ? name.trim() : `${host}-${db}`.replace(/[^a-zA-Z0-9-]/g, "-");
|
|
33081
35840
|
try {
|
|
33082
|
-
|
|
33083
|
-
|
|
33084
|
-
const instances = load(content2) || [];
|
|
33085
|
-
if (Array.isArray(instances)) {
|
|
33086
|
-
const exists = instances.some((inst) => inst.name === instanceName);
|
|
33087
|
-
if (exists) {
|
|
33088
|
-
console.error(`Monitoring target '${instanceName}' already exists`);
|
|
33089
|
-
process.exitCode = 1;
|
|
33090
|
-
return;
|
|
33091
|
-
}
|
|
33092
|
-
}
|
|
33093
|
-
}
|
|
35841
|
+
addInstanceToFile(file, buildInstance(instanceName, connStr));
|
|
35842
|
+
console.log(`Monitoring target '${instanceName}' added`);
|
|
33094
35843
|
} catch (err) {
|
|
33095
|
-
const
|
|
33096
|
-
|
|
33097
|
-
|
|
33098
|
-
if (new RegExp(`^- name: ${escapedName}$`, "m").test(content2)) {
|
|
33099
|
-
console.error(`Monitoring target '${instanceName}' already exists`);
|
|
33100
|
-
process.exitCode = 1;
|
|
33101
|
-
return;
|
|
33102
|
-
}
|
|
33103
|
-
}
|
|
33104
|
-
if (fs7.existsSync(file) && fs7.lstatSync(file).isDirectory()) {
|
|
33105
|
-
fs7.rmSync(file, { recursive: true, force: true });
|
|
35844
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
35845
|
+
console.error(message);
|
|
35846
|
+
process.exitCode = 1;
|
|
33106
35847
|
}
|
|
33107
|
-
const body = `- name: ${instanceName}
|
|
33108
|
-
conn_str: ${connStr}
|
|
33109
|
-
preset_metrics: full
|
|
33110
|
-
custom_metrics:
|
|
33111
|
-
is_enabled: true
|
|
33112
|
-
group: default
|
|
33113
|
-
custom_tags:
|
|
33114
|
-
env: production
|
|
33115
|
-
cluster: default
|
|
33116
|
-
node_name: ${instanceName}
|
|
33117
|
-
sink_type: ~sink_type~
|
|
33118
|
-
`;
|
|
33119
|
-
const content = fs7.existsSync(file) ? fs7.readFileSync(file, "utf8") : "";
|
|
33120
|
-
fs7.appendFileSync(file, (content && !/\n$/.test(content) ? `
|
|
33121
|
-
` : "") + body, "utf8");
|
|
33122
|
-
console.log(`Monitoring target '${instanceName}' added`);
|
|
33123
35848
|
});
|
|
33124
35849
|
targets.command("remove <name>").description("remove monitoring target database").action(async (name) => {
|
|
33125
35850
|
const { instancesFile: file } = await resolveOrInitPaths();
|
|
33126
|
-
if (!
|
|
35851
|
+
if (!fs8.existsSync(file) || fs8.lstatSync(file).isDirectory()) {
|
|
33127
35852
|
console.error("instances.yml not found");
|
|
33128
35853
|
process.exitCode = 1;
|
|
33129
35854
|
return;
|
|
33130
35855
|
}
|
|
33131
35856
|
try {
|
|
33132
|
-
const
|
|
33133
|
-
|
|
33134
|
-
if (!instances || !Array.isArray(instances)) {
|
|
33135
|
-
console.error("Invalid instances.yml format");
|
|
33136
|
-
process.exitCode = 1;
|
|
33137
|
-
return;
|
|
33138
|
-
}
|
|
33139
|
-
const filtered = instances.filter((inst) => inst.name !== name);
|
|
33140
|
-
if (filtered.length === instances.length) {
|
|
35857
|
+
const removed = removeInstanceFromFile(file, name);
|
|
35858
|
+
if (!removed) {
|
|
33141
35859
|
console.error(`Monitoring target '${name}' not found`);
|
|
33142
35860
|
process.exitCode = 1;
|
|
33143
35861
|
return;
|
|
33144
35862
|
}
|
|
33145
|
-
fs7.writeFileSync(file, dump(filtered), "utf8");
|
|
33146
35863
|
console.log(`Monitoring target '${name}' removed`);
|
|
33147
35864
|
} catch (err) {
|
|
33148
35865
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -33152,32 +35869,35 @@ targets.command("remove <name>").description("remove monitoring target database"
|
|
|
33152
35869
|
});
|
|
33153
35870
|
targets.command("test <name>").description("test monitoring target database connectivity").action(async (name) => {
|
|
33154
35871
|
const { instancesFile: instancesPath } = await resolveOrInitPaths();
|
|
33155
|
-
if (!
|
|
35872
|
+
if (!fs8.existsSync(instancesPath) || fs8.lstatSync(instancesPath).isDirectory()) {
|
|
33156
35873
|
console.error("instances.yml not found");
|
|
33157
35874
|
process.exitCode = 1;
|
|
33158
35875
|
return;
|
|
33159
35876
|
}
|
|
35877
|
+
let instances;
|
|
35878
|
+
try {
|
|
35879
|
+
instances = loadInstances(instancesPath);
|
|
35880
|
+
} catch (err) {
|
|
35881
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
35882
|
+
console.error(`Error parsing instances.yml: ${message}`);
|
|
35883
|
+
process.exitCode = 1;
|
|
35884
|
+
return;
|
|
35885
|
+
}
|
|
35886
|
+
const instance = instances.find((inst) => inst.name === name);
|
|
35887
|
+
if (!instance) {
|
|
35888
|
+
console.error(`Monitoring target '${name}' not found`);
|
|
35889
|
+
process.exitCode = 1;
|
|
35890
|
+
return;
|
|
35891
|
+
}
|
|
35892
|
+
if (!instance.conn_str) {
|
|
35893
|
+
console.error(`Connection string not found for monitoring target '${name}'`);
|
|
35894
|
+
process.exitCode = 1;
|
|
35895
|
+
return;
|
|
35896
|
+
}
|
|
35897
|
+
console.log(`Testing connection to monitoring target '${name}'...`);
|
|
35898
|
+
warnIfLaxSslmode(instance.conn_str);
|
|
35899
|
+
const client = new Client(buildClientConfig(instance.conn_str, { connectionTimeoutMillis: 1e4 }));
|
|
33160
35900
|
try {
|
|
33161
|
-
const content = fs7.readFileSync(instancesPath, "utf8");
|
|
33162
|
-
const instances = load(content);
|
|
33163
|
-
if (!instances || !Array.isArray(instances)) {
|
|
33164
|
-
console.error("Invalid instances.yml format");
|
|
33165
|
-
process.exitCode = 1;
|
|
33166
|
-
return;
|
|
33167
|
-
}
|
|
33168
|
-
const instance = instances.find((inst) => inst.name === name);
|
|
33169
|
-
if (!instance) {
|
|
33170
|
-
console.error(`Monitoring target '${name}' not found`);
|
|
33171
|
-
process.exitCode = 1;
|
|
33172
|
-
return;
|
|
33173
|
-
}
|
|
33174
|
-
if (!instance.conn_str) {
|
|
33175
|
-
console.error(`Connection string not found for monitoring target '${name}'`);
|
|
33176
|
-
process.exitCode = 1;
|
|
33177
|
-
return;
|
|
33178
|
-
}
|
|
33179
|
-
console.log(`Testing connection to monitoring target '${name}'...`);
|
|
33180
|
-
const client = new Client({ connectionString: instance.conn_str, connectionTimeoutMillis: 1e4 });
|
|
33181
35901
|
try {
|
|
33182
35902
|
await client.connect();
|
|
33183
35903
|
const result = await client.query("select version();");
|
|
@@ -33411,7 +36131,7 @@ To authenticate, run: pgai auth`);
|
|
|
33411
36131
|
});
|
|
33412
36132
|
auth.command("remove-key").description("remove API key").action(async () => {
|
|
33413
36133
|
const newConfigPath = getConfigPath();
|
|
33414
|
-
const hasNewConfig =
|
|
36134
|
+
const hasNewConfig = fs8.existsSync(newConfigPath);
|
|
33415
36135
|
let legacyPath;
|
|
33416
36136
|
try {
|
|
33417
36137
|
const { projectDir } = await resolveOrInitPaths();
|
|
@@ -33419,7 +36139,7 @@ auth.command("remove-key").description("remove API key").action(async () => {
|
|
|
33419
36139
|
} catch {
|
|
33420
36140
|
legacyPath = path7.resolve(process.cwd(), ".pgwatch-config");
|
|
33421
36141
|
}
|
|
33422
|
-
const hasLegacyConfig =
|
|
36142
|
+
const hasLegacyConfig = fs8.existsSync(legacyPath) && fs8.statSync(legacyPath).isFile();
|
|
33423
36143
|
if (!hasNewConfig && !hasLegacyConfig) {
|
|
33424
36144
|
console.log("No API key configured");
|
|
33425
36145
|
return;
|
|
@@ -33429,11 +36149,11 @@ auth.command("remove-key").description("remove API key").action(async () => {
|
|
|
33429
36149
|
}
|
|
33430
36150
|
if (hasLegacyConfig) {
|
|
33431
36151
|
try {
|
|
33432
|
-
const content =
|
|
36152
|
+
const content = fs8.readFileSync(legacyPath, "utf8");
|
|
33433
36153
|
const filtered = content.split(/\r?\n/).filter((l) => !/^api_key=/.test(l)).join(`
|
|
33434
36154
|
`).replace(/\n+$/g, `
|
|
33435
36155
|
`);
|
|
33436
|
-
|
|
36156
|
+
fs8.writeFileSync(legacyPath, filtered, "utf8");
|
|
33437
36157
|
} catch (err) {
|
|
33438
36158
|
console.warn(`Warning: Could not update legacy config: ${err instanceof Error ? err.message : String(err)}`);
|
|
33439
36159
|
}
|
|
@@ -33454,17 +36174,17 @@ mon.command("generate-grafana-password").description("generate Grafana password
|
|
|
33454
36174
|
return;
|
|
33455
36175
|
}
|
|
33456
36176
|
let configContent = "";
|
|
33457
|
-
if (
|
|
33458
|
-
const stats =
|
|
36177
|
+
if (fs8.existsSync(cfgPath)) {
|
|
36178
|
+
const stats = fs8.statSync(cfgPath);
|
|
33459
36179
|
if (stats.isDirectory()) {
|
|
33460
36180
|
console.error(".pgwatch-config is a directory, expected a file. Skipping read.");
|
|
33461
36181
|
} else {
|
|
33462
|
-
configContent =
|
|
36182
|
+
configContent = fs8.readFileSync(cfgPath, "utf8");
|
|
33463
36183
|
}
|
|
33464
36184
|
}
|
|
33465
36185
|
const lines = configContent.split(/\r?\n/).filter((l) => !/^grafana_password=/.test(l));
|
|
33466
36186
|
lines.push(`grafana_password=${newPassword}`);
|
|
33467
|
-
|
|
36187
|
+
fs8.writeFileSync(cfgPath, lines.filter(Boolean).join(`
|
|
33468
36188
|
`) + `
|
|
33469
36189
|
`, "utf8");
|
|
33470
36190
|
console.log("\u2713 New Grafana password generated and saved");
|
|
@@ -33487,18 +36207,18 @@ Note: This command requires 'openssl' to be installed`);
|
|
|
33487
36207
|
mon.command("show-grafana-credentials").description("show Grafana credentials for monitoring services").action(async () => {
|
|
33488
36208
|
const { projectDir } = await resolveOrInitPaths();
|
|
33489
36209
|
const cfgPath = path7.resolve(projectDir, ".pgwatch-config");
|
|
33490
|
-
if (!
|
|
36210
|
+
if (!fs8.existsSync(cfgPath)) {
|
|
33491
36211
|
console.error("Configuration file not found. Run 'postgres-ai mon local-install' first.");
|
|
33492
36212
|
process.exitCode = 1;
|
|
33493
36213
|
return;
|
|
33494
36214
|
}
|
|
33495
|
-
const stats =
|
|
36215
|
+
const stats = fs8.statSync(cfgPath);
|
|
33496
36216
|
if (stats.isDirectory()) {
|
|
33497
36217
|
console.error(".pgwatch-config is a directory, expected a file. Cannot read credentials.");
|
|
33498
36218
|
process.exitCode = 1;
|
|
33499
36219
|
return;
|
|
33500
36220
|
}
|
|
33501
|
-
const content =
|
|
36221
|
+
const content = fs8.readFileSync(cfgPath, "utf8");
|
|
33502
36222
|
const lines = content.split(/\r?\n/);
|
|
33503
36223
|
let password = "";
|
|
33504
36224
|
for (const line of lines) {
|
|
@@ -33519,8 +36239,8 @@ Grafana credentials:`);
|
|
|
33519
36239
|
console.log(" Username: monitor");
|
|
33520
36240
|
console.log(` Password: ${password}`);
|
|
33521
36241
|
const envFile = path7.resolve(projectDir, ".env");
|
|
33522
|
-
if (
|
|
33523
|
-
const envContent =
|
|
36242
|
+
if (fs8.existsSync(envFile)) {
|
|
36243
|
+
const envContent = fs8.readFileSync(envFile, "utf8");
|
|
33524
36244
|
const vmUser = envContent.match(/^VM_AUTH_USERNAME=([^\r\n]+)/m);
|
|
33525
36245
|
const vmPass = envContent.match(/^VM_AUTH_PASSWORD=([^\r\n]+)/m);
|
|
33526
36246
|
if (vmUser && vmPass) {
|
|
@@ -33532,8 +36252,8 @@ VictoriaMetrics credentials:`);
|
|
|
33532
36252
|
}
|
|
33533
36253
|
console.log("");
|
|
33534
36254
|
});
|
|
33535
|
-
function interpretEscapes2(
|
|
33536
|
-
return
|
|
36255
|
+
function interpretEscapes2(str3) {
|
|
36256
|
+
return str3.replace(/\\\\/g, "\x00").replace(/\\n/g, `
|
|
33537
36257
|
`).replace(/\\t/g, "\t").replace(/\\r/g, "\r").replace(/\\"/g, '"').replace(/\\'/g, "'").replace(/\x00/g, "\\");
|
|
33538
36258
|
}
|
|
33539
36259
|
var issues = program2.command("issues").description("issues management");
|
|
@@ -34247,12 +36967,12 @@ reports.command("data [reportId]").description("get checkup report file data (in
|
|
|
34247
36967
|
spinner.stop();
|
|
34248
36968
|
if (opts.output) {
|
|
34249
36969
|
const dir = path7.resolve(opts.output);
|
|
34250
|
-
|
|
36970
|
+
fs8.mkdirSync(dir, { recursive: true });
|
|
34251
36971
|
for (const f of result) {
|
|
34252
36972
|
const safeName = path7.basename(f.filename);
|
|
34253
36973
|
const filePath = path7.join(dir, safeName);
|
|
34254
36974
|
const content = f.type === "json" ? JSON.stringify(tryParseJson(f.data), null, 2) : f.data;
|
|
34255
|
-
|
|
36975
|
+
fs8.writeFileSync(filePath, content, "utf-8");
|
|
34256
36976
|
console.log(filePath);
|
|
34257
36977
|
}
|
|
34258
36978
|
} else if (opts.json) {
|
|
@@ -34386,13 +37106,13 @@ mcp.command("install [client]").description("install MCP server configuration fo
|
|
|
34386
37106
|
process.exitCode = 1;
|
|
34387
37107
|
return;
|
|
34388
37108
|
}
|
|
34389
|
-
if (!
|
|
34390
|
-
|
|
37109
|
+
if (!fs8.existsSync(configDir)) {
|
|
37110
|
+
fs8.mkdirSync(configDir, { recursive: true });
|
|
34391
37111
|
}
|
|
34392
37112
|
let config2 = { mcpServers: {} };
|
|
34393
|
-
if (
|
|
37113
|
+
if (fs8.existsSync(configPath)) {
|
|
34394
37114
|
try {
|
|
34395
|
-
const content =
|
|
37115
|
+
const content = fs8.readFileSync(configPath, "utf8");
|
|
34396
37116
|
config2 = JSON.parse(content);
|
|
34397
37117
|
if (!config2.mcpServers) {
|
|
34398
37118
|
config2.mcpServers = {};
|
|
@@ -34405,7 +37125,7 @@ mcp.command("install [client]").description("install MCP server configuration fo
|
|
|
34405
37125
|
command: pgaiPath,
|
|
34406
37126
|
args: ["mcp", "start"]
|
|
34407
37127
|
};
|
|
34408
|
-
|
|
37128
|
+
fs8.writeFileSync(configPath, JSON.stringify(config2, null, 2), "utf8");
|
|
34409
37129
|
console.log(`\u2713 PostgresAI MCP server configured for ${client}`);
|
|
34410
37130
|
console.log(` Config file: ${configPath}`);
|
|
34411
37131
|
console.log("");
|