postgresai 0.14.0-dev.45 → 0.14.0-dev.48

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.
@@ -13064,7 +13064,7 @@ var {
13064
13064
  // package.json
13065
13065
  var package_default = {
13066
13066
  name: "postgresai",
13067
- version: "0.14.0-dev.45",
13067
+ version: "0.14.0-dev.48",
13068
13068
  description: "postgres_ai CLI",
13069
13069
  license: "Apache-2.0",
13070
13070
  private: false,
@@ -13086,7 +13086,7 @@ var package_default = {
13086
13086
  node: ">=18"
13087
13087
  },
13088
13088
  scripts: {
13089
- build: `bun build ./bin/postgres-ai.ts --outdir ./dist/bin --target node && node -e "const fs=require('fs');const f='./dist/bin/postgres-ai.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('#!/usr/bin/env bun','#!/usr/bin/env node'))" && cp -r sql dist/`,
13089
+ build: `bun build ./bin/postgres-ai.ts --outdir ./dist/bin --target node && node -e "const fs=require('fs');const f='./dist/bin/postgres-ai.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('#!/usr/bin/env bun','#!/usr/bin/env node'))"`,
13090
13090
  prepublishOnly: "npm run build",
13091
13091
  start: "bun ./bin/postgres-ai.ts --help",
13092
13092
  "start:node": "node ./dist/bin/postgres-ai.js --help",
@@ -15881,7 +15881,7 @@ var Result = import_lib.default.Result;
15881
15881
  var TypeOverrides = import_lib.default.TypeOverrides;
15882
15882
  var defaults = import_lib.default.defaults;
15883
15883
  // package.json
15884
- var version = "0.14.0-dev.45";
15884
+ var version = "0.14.0-dev.48";
15885
15885
  var package_default2 = {
15886
15886
  name: "postgresai",
15887
15887
  version,
@@ -15906,7 +15906,7 @@ var package_default2 = {
15906
15906
  node: ">=18"
15907
15907
  },
15908
15908
  scripts: {
15909
- build: `bun build ./bin/postgres-ai.ts --outdir ./dist/bin --target node && node -e "const fs=require('fs');const f='./dist/bin/postgres-ai.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('#!/usr/bin/env bun','#!/usr/bin/env node'))" && cp -r sql dist/`,
15909
+ build: `bun build ./bin/postgres-ai.ts --outdir ./dist/bin --target node && node -e "const fs=require('fs');const f='./dist/bin/postgres-ai.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('#!/usr/bin/env bun','#!/usr/bin/env node'))"`,
15910
15910
  prepublishOnly: "npm run build",
15911
15911
  start: "bun ./bin/postgres-ai.ts --help",
15912
15912
  "start:node": "node ./dist/bin/postgres-ai.js --help",
@@ -24212,2704 +24212,422 @@ import * as fs4 from "fs";
24212
24212
  import * as path4 from "path";
24213
24213
 
24214
24214
  // lib/metrics-loader.ts
24215
- import { readFileSync as readFileSync4 } from "fs";
24216
- import { resolve as resolve4, dirname } from "path";
24217
- import { fileURLToPath } from "url";
24218
-
24219
- // node_modules/js-yaml/dist/js-yaml.mjs
24220
- /*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
24221
- function isNothing2(subject) {
24222
- return typeof subject === "undefined" || subject === null;
24223
- }
24224
- function isObject3(subject) {
24225
- return typeof subject === "object" && subject !== null;
24226
- }
24227
- function toArray2(sequence) {
24228
- if (Array.isArray(sequence))
24229
- return sequence;
24230
- else if (isNothing2(sequence))
24231
- return [];
24232
- return [sequence];
24233
- }
24234
- function extend4(target, source) {
24235
- var index, length, key, sourceKeys;
24236
- if (source) {
24237
- sourceKeys = Object.keys(source);
24238
- for (index = 0, length = sourceKeys.length;index < length; index += 1) {
24239
- key = sourceKeys[index];
24240
- target[key] = source[key];
24241
- }
24242
- }
24243
- return target;
24244
- }
24245
- function repeat2(string4, count) {
24246
- var result = "", cycle;
24247
- for (cycle = 0;cycle < count; cycle += 1) {
24248
- result += string4;
24249
- }
24250
- return result;
24251
- }
24252
- function isNegativeZero2(number4) {
24253
- return number4 === 0 && Number.NEGATIVE_INFINITY === 1 / number4;
24254
- }
24255
- var isNothing_12 = isNothing2;
24256
- var isObject_12 = isObject3;
24257
- var toArray_12 = toArray2;
24258
- var repeat_12 = repeat2;
24259
- var isNegativeZero_12 = isNegativeZero2;
24260
- var extend_12 = extend4;
24261
- var common2 = {
24262
- isNothing: isNothing_12,
24263
- isObject: isObject_12,
24264
- toArray: toArray_12,
24265
- repeat: repeat_12,
24266
- isNegativeZero: isNegativeZero_12,
24267
- extend: extend_12
24268
- };
24269
- function formatError3(exception2, compact) {
24270
- var where = "", message = exception2.reason || "(unknown reason)";
24271
- if (!exception2.mark)
24272
- return message;
24273
- if (exception2.mark.name) {
24274
- where += 'in "' + exception2.mark.name + '" ';
24275
- }
24276
- where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
24277
- if (!compact && exception2.mark.snippet) {
24278
- where += `
24279
-
24280
- ` + exception2.mark.snippet;
24281
- }
24282
- return message + " " + where;
24283
- }
24284
- function YAMLException$12(reason, mark) {
24285
- Error.call(this);
24286
- this.name = "YAMLException";
24287
- this.reason = reason;
24288
- this.mark = mark;
24289
- this.message = formatError3(this, false);
24290
- if (Error.captureStackTrace) {
24291
- Error.captureStackTrace(this, this.constructor);
24292
- } else {
24293
- this.stack = new Error().stack || "";
24294
- }
24295
- }
24296
- YAMLException$12.prototype = Object.create(Error.prototype);
24297
- YAMLException$12.prototype.constructor = YAMLException$12;
24298
- YAMLException$12.prototype.toString = function toString2(compact) {
24299
- return this.name + ": " + formatError3(this, compact);
24300
- };
24301
- var exception2 = YAMLException$12;
24302
- function getLine2(buffer, lineStart, lineEnd, position, maxLineLength) {
24303
- var head = "";
24304
- var tail = "";
24305
- var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
24306
- if (position - lineStart > maxHalfLength) {
24307
- head = " ... ";
24308
- lineStart = position - maxHalfLength + head.length;
24309
- }
24310
- if (lineEnd - position > maxHalfLength) {
24311
- tail = " ...";
24312
- lineEnd = position + maxHalfLength - tail.length;
24313
- }
24314
- return {
24315
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "→") + tail,
24316
- pos: position - lineStart + head.length
24317
- };
24318
- }
24319
- function padStart2(string4, max) {
24320
- return common2.repeat(" ", max - string4.length) + string4;
24321
- }
24322
- function makeSnippet2(mark, options) {
24323
- options = Object.create(options || null);
24324
- if (!mark.buffer)
24325
- return null;
24326
- if (!options.maxLength)
24327
- options.maxLength = 79;
24328
- if (typeof options.indent !== "number")
24329
- options.indent = 1;
24330
- if (typeof options.linesBefore !== "number")
24331
- options.linesBefore = 3;
24332
- if (typeof options.linesAfter !== "number")
24333
- options.linesAfter = 2;
24334
- var re = /\r?\n|\r|\0/g;
24335
- var lineStarts = [0];
24336
- var lineEnds = [];
24337
- var match;
24338
- var foundLineNo = -1;
24339
- while (match = re.exec(mark.buffer)) {
24340
- lineEnds.push(match.index);
24341
- lineStarts.push(match.index + match[0].length);
24342
- if (mark.position <= match.index && foundLineNo < 0) {
24343
- foundLineNo = lineStarts.length - 2;
24344
- }
24345
- }
24346
- if (foundLineNo < 0)
24347
- foundLineNo = lineStarts.length - 1;
24348
- var result = "", i2, line;
24349
- var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
24350
- var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
24351
- for (i2 = 1;i2 <= options.linesBefore; i2++) {
24352
- if (foundLineNo - i2 < 0)
24353
- break;
24354
- line = getLine2(mark.buffer, lineStarts[foundLineNo - i2], lineEnds[foundLineNo - i2], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i2]), maxLineLength);
24355
- result = common2.repeat(" ", options.indent) + padStart2((mark.line - i2 + 1).toString(), lineNoLength) + " | " + line.str + `
24356
- ` + result;
24357
- }
24358
- line = getLine2(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
24359
- result += common2.repeat(" ", options.indent) + padStart2((mark.line + 1).toString(), lineNoLength) + " | " + line.str + `
24360
- `;
24361
- result += common2.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^" + `
24362
- `;
24363
- for (i2 = 1;i2 <= options.linesAfter; i2++) {
24364
- if (foundLineNo + i2 >= lineEnds.length)
24365
- break;
24366
- line = getLine2(mark.buffer, lineStarts[foundLineNo + i2], lineEnds[foundLineNo + i2], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i2]), maxLineLength);
24367
- result += common2.repeat(" ", options.indent) + padStart2((mark.line + i2 + 1).toString(), lineNoLength) + " | " + line.str + `
24368
- `;
24369
- }
24370
- return result.replace(/\n$/, "");
24371
- }
24372
- var snippet2 = makeSnippet2;
24373
- var TYPE_CONSTRUCTOR_OPTIONS2 = [
24374
- "kind",
24375
- "multi",
24376
- "resolve",
24377
- "construct",
24378
- "instanceOf",
24379
- "predicate",
24380
- "represent",
24381
- "representName",
24382
- "defaultStyle",
24383
- "styleAliases"
24384
- ];
24385
- var YAML_NODE_KINDS2 = [
24386
- "scalar",
24387
- "sequence",
24388
- "mapping"
24389
- ];
24390
- function compileStyleAliases2(map3) {
24391
- var result = {};
24392
- if (map3 !== null) {
24393
- Object.keys(map3).forEach(function(style) {
24394
- map3[style].forEach(function(alias) {
24395
- result[String(alias)] = style;
24396
- });
24397
- });
24398
- }
24399
- return result;
24400
- }
24401
- function Type$12(tag, options) {
24402
- options = options || {};
24403
- Object.keys(options).forEach(function(name) {
24404
- if (TYPE_CONSTRUCTOR_OPTIONS2.indexOf(name) === -1) {
24405
- throw new exception2('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
24406
- }
24407
- });
24408
- this.options = options;
24409
- this.tag = tag;
24410
- this.kind = options["kind"] || null;
24411
- this.resolve = options["resolve"] || function() {
24412
- return true;
24413
- };
24414
- this.construct = options["construct"] || function(data) {
24415
- return data;
24416
- };
24417
- this.instanceOf = options["instanceOf"] || null;
24418
- this.predicate = options["predicate"] || null;
24419
- this.represent = options["represent"] || null;
24420
- this.representName = options["representName"] || null;
24421
- this.defaultStyle = options["defaultStyle"] || null;
24422
- this.multi = options["multi"] || false;
24423
- this.styleAliases = compileStyleAliases2(options["styleAliases"] || null);
24424
- if (YAML_NODE_KINDS2.indexOf(this.kind) === -1) {
24425
- throw new exception2('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
24426
- }
24427
- }
24428
- var type2 = Type$12;
24429
- function compileList2(schema2, name) {
24430
- var result = [];
24431
- schema2[name].forEach(function(currentType) {
24432
- var newIndex = result.length;
24433
- result.forEach(function(previousType, previousIndex) {
24434
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
24435
- newIndex = previousIndex;
24436
- }
24437
- });
24438
- result[newIndex] = currentType;
24439
- });
24440
- return result;
24441
- }
24442
- function compileMap2() {
24443
- var result = {
24444
- scalar: {},
24445
- sequence: {},
24446
- mapping: {},
24447
- fallback: {},
24448
- multi: {
24449
- scalar: [],
24450
- sequence: [],
24451
- mapping: [],
24452
- fallback: []
24453
- }
24454
- }, index, length;
24455
- function collectType(type3) {
24456
- if (type3.multi) {
24457
- result.multi[type3.kind].push(type3);
24458
- result.multi["fallback"].push(type3);
24459
- } else {
24460
- result[type3.kind][type3.tag] = result["fallback"][type3.tag] = type3;
24461
- }
24462
- }
24463
- for (index = 0, length = arguments.length;index < length; index += 1) {
24464
- arguments[index].forEach(collectType);
24465
- }
24466
- return result;
24467
- }
24468
- function Schema$12(definition) {
24469
- return this.extend(definition);
24470
- }
24471
- Schema$12.prototype.extend = function extend5(definition) {
24472
- var implicit = [];
24473
- var explicit = [];
24474
- if (definition instanceof type2) {
24475
- explicit.push(definition);
24476
- } else if (Array.isArray(definition)) {
24477
- explicit = explicit.concat(definition);
24478
- } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
24479
- if (definition.implicit)
24480
- implicit = implicit.concat(definition.implicit);
24481
- if (definition.explicit)
24482
- explicit = explicit.concat(definition.explicit);
24483
- } else {
24484
- throw new exception2("Schema.extend argument should be a Type, [ Type ], " + "or a schema definition ({ implicit: [...], explicit: [...] })");
24485
- }
24486
- implicit.forEach(function(type$1) {
24487
- if (!(type$1 instanceof type2)) {
24488
- throw new exception2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
24489
- }
24490
- if (type$1.loadKind && type$1.loadKind !== "scalar") {
24491
- throw new exception2("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
24492
- }
24493
- if (type$1.multi) {
24494
- throw new exception2("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
24495
- }
24496
- });
24497
- explicit.forEach(function(type$1) {
24498
- if (!(type$1 instanceof type2)) {
24499
- throw new exception2("Specified list of YAML types (or a single Type object) contains a non-Type object.");
24500
- }
24501
- });
24502
- var result = Object.create(Schema$12.prototype);
24503
- result.implicit = (this.implicit || []).concat(implicit);
24504
- result.explicit = (this.explicit || []).concat(explicit);
24505
- result.compiledImplicit = compileList2(result, "implicit");
24506
- result.compiledExplicit = compileList2(result, "explicit");
24507
- result.compiledTypeMap = compileMap2(result.compiledImplicit, result.compiledExplicit);
24508
- return result;
24509
- };
24510
- var schema2 = Schema$12;
24511
- var str2 = new type2("tag:yaml.org,2002:str", {
24512
- kind: "scalar",
24513
- construct: function(data) {
24514
- return data !== null ? data : "";
24515
- }
24516
- });
24517
- var seq2 = new type2("tag:yaml.org,2002:seq", {
24518
- kind: "sequence",
24519
- construct: function(data) {
24520
- return data !== null ? data : [];
24521
- }
24522
- });
24523
- var map3 = new type2("tag:yaml.org,2002:map", {
24524
- kind: "mapping",
24525
- construct: function(data) {
24526
- return data !== null ? data : {};
24527
- }
24528
- });
24529
- var failsafe2 = new schema2({
24530
- explicit: [
24531
- str2,
24532
- seq2,
24533
- map3
24534
- ]
24535
- });
24536
- function resolveYamlNull2(data) {
24537
- if (data === null)
24538
- return true;
24539
- var max = data.length;
24540
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
24541
- }
24542
- function constructYamlNull2() {
24543
- return null;
24544
- }
24545
- function isNull2(object4) {
24546
- return object4 === null;
24547
- }
24548
- var _null5 = new type2("tag:yaml.org,2002:null", {
24549
- kind: "scalar",
24550
- resolve: resolveYamlNull2,
24551
- construct: constructYamlNull2,
24552
- predicate: isNull2,
24553
- represent: {
24554
- canonical: function() {
24555
- return "~";
24556
- },
24557
- lowercase: function() {
24558
- return "null";
24559
- },
24560
- uppercase: function() {
24561
- return "NULL";
24562
- },
24563
- camelcase: function() {
24564
- return "Null";
24565
- },
24566
- empty: function() {
24567
- return "";
24568
- }
24569
- },
24570
- defaultStyle: "lowercase"
24571
- });
24572
- function resolveYamlBoolean2(data) {
24573
- if (data === null)
24574
- return false;
24575
- var max = data.length;
24576
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
24577
- }
24578
- function constructYamlBoolean2(data) {
24579
- return data === "true" || data === "True" || data === "TRUE";
24580
- }
24581
- function isBoolean2(object4) {
24582
- return Object.prototype.toString.call(object4) === "[object Boolean]";
24583
- }
24584
- var bool2 = new type2("tag:yaml.org,2002:bool", {
24585
- kind: "scalar",
24586
- resolve: resolveYamlBoolean2,
24587
- construct: constructYamlBoolean2,
24588
- predicate: isBoolean2,
24589
- represent: {
24590
- lowercase: function(object4) {
24591
- return object4 ? "true" : "false";
24592
- },
24593
- uppercase: function(object4) {
24594
- return object4 ? "TRUE" : "FALSE";
24595
- },
24596
- camelcase: function(object4) {
24597
- return object4 ? "True" : "False";
24598
- }
24599
- },
24600
- defaultStyle: "lowercase"
24601
- });
24602
- function isHexCode2(c) {
24603
- return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
24604
- }
24605
- function isOctCode2(c) {
24606
- return 48 <= c && c <= 55;
24607
- }
24608
- function isDecCode2(c) {
24609
- return 48 <= c && c <= 57;
24610
- }
24611
- function resolveYamlInteger2(data) {
24612
- if (data === null)
24613
- return false;
24614
- var max = data.length, index = 0, hasDigits = false, ch;
24615
- if (!max)
24616
- return false;
24617
- ch = data[index];
24618
- if (ch === "-" || ch === "+") {
24619
- ch = data[++index];
24620
- }
24621
- if (ch === "0") {
24622
- if (index + 1 === max)
24623
- return true;
24624
- ch = data[++index];
24625
- if (ch === "b") {
24626
- index++;
24627
- for (;index < max; index++) {
24628
- ch = data[index];
24629
- if (ch === "_")
24630
- continue;
24631
- if (ch !== "0" && ch !== "1")
24632
- return false;
24633
- hasDigits = true;
24634
- }
24635
- return hasDigits && ch !== "_";
24636
- }
24637
- if (ch === "x") {
24638
- index++;
24639
- for (;index < max; index++) {
24640
- ch = data[index];
24641
- if (ch === "_")
24642
- continue;
24643
- if (!isHexCode2(data.charCodeAt(index)))
24644
- return false;
24645
- hasDigits = true;
24646
- }
24647
- return hasDigits && ch !== "_";
24648
- }
24649
- if (ch === "o") {
24650
- index++;
24651
- for (;index < max; index++) {
24652
- ch = data[index];
24653
- if (ch === "_")
24654
- continue;
24655
- if (!isOctCode2(data.charCodeAt(index)))
24656
- return false;
24657
- hasDigits = true;
24658
- }
24659
- return hasDigits && ch !== "_";
24660
- }
24661
- }
24662
- if (ch === "_")
24663
- return false;
24664
- for (;index < max; index++) {
24665
- ch = data[index];
24666
- if (ch === "_")
24667
- continue;
24668
- if (!isDecCode2(data.charCodeAt(index))) {
24669
- return false;
24670
- }
24671
- hasDigits = true;
24672
- }
24673
- if (!hasDigits || ch === "_")
24674
- return false;
24675
- return true;
24676
- }
24677
- function constructYamlInteger2(data) {
24678
- var value = data, sign = 1, ch;
24679
- if (value.indexOf("_") !== -1) {
24680
- value = value.replace(/_/g, "");
24681
- }
24682
- ch = value[0];
24683
- if (ch === "-" || ch === "+") {
24684
- if (ch === "-")
24685
- sign = -1;
24686
- value = value.slice(1);
24687
- ch = value[0];
24688
- }
24689
- if (value === "0")
24690
- return 0;
24691
- if (ch === "0") {
24692
- if (value[1] === "b")
24693
- return sign * parseInt(value.slice(2), 2);
24694
- if (value[1] === "x")
24695
- return sign * parseInt(value.slice(2), 16);
24696
- if (value[1] === "o")
24697
- return sign * parseInt(value.slice(2), 8);
24698
- }
24699
- return sign * parseInt(value, 10);
24700
- }
24701
- function isInteger2(object4) {
24702
- return Object.prototype.toString.call(object4) === "[object Number]" && (object4 % 1 === 0 && !common2.isNegativeZero(object4));
24703
- }
24704
- var int3 = new type2("tag:yaml.org,2002:int", {
24705
- kind: "scalar",
24706
- resolve: resolveYamlInteger2,
24707
- construct: constructYamlInteger2,
24708
- predicate: isInteger2,
24709
- represent: {
24710
- binary: function(obj) {
24711
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
24712
- },
24713
- octal: function(obj) {
24714
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
24715
- },
24716
- decimal: function(obj) {
24717
- return obj.toString(10);
24718
- },
24719
- hexadecimal: function(obj) {
24720
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
24721
- }
24722
- },
24723
- defaultStyle: "decimal",
24724
- styleAliases: {
24725
- binary: [2, "bin"],
24726
- octal: [8, "oct"],
24727
- decimal: [10, "dec"],
24728
- hexadecimal: [16, "hex"]
24729
- }
24730
- });
24731
- 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))$");
24732
- function resolveYamlFloat2(data) {
24733
- if (data === null)
24734
- return false;
24735
- if (!YAML_FLOAT_PATTERN2.test(data) || data[data.length - 1] === "_") {
24736
- return false;
24737
- }
24738
- return true;
24739
- }
24740
- function constructYamlFloat2(data) {
24741
- var value, sign;
24742
- value = data.replace(/_/g, "").toLowerCase();
24743
- sign = value[0] === "-" ? -1 : 1;
24744
- if ("+-".indexOf(value[0]) >= 0) {
24745
- value = value.slice(1);
24746
- }
24747
- if (value === ".inf") {
24748
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
24749
- } else if (value === ".nan") {
24750
- return NaN;
24751
- }
24752
- return sign * parseFloat(value, 10);
24753
- }
24754
- var SCIENTIFIC_WITHOUT_DOT2 = /^[-+]?[0-9]+e/;
24755
- function representYamlFloat2(object4, style) {
24756
- var res;
24757
- if (isNaN(object4)) {
24758
- switch (style) {
24759
- case "lowercase":
24760
- return ".nan";
24761
- case "uppercase":
24762
- return ".NAN";
24763
- case "camelcase":
24764
- return ".NaN";
24765
- }
24766
- } else if (Number.POSITIVE_INFINITY === object4) {
24767
- switch (style) {
24768
- case "lowercase":
24769
- return ".inf";
24770
- case "uppercase":
24771
- return ".INF";
24772
- case "camelcase":
24773
- return ".Inf";
24774
- }
24775
- } else if (Number.NEGATIVE_INFINITY === object4) {
24776
- switch (style) {
24777
- case "lowercase":
24778
- return "-.inf";
24779
- case "uppercase":
24780
- return "-.INF";
24781
- case "camelcase":
24782
- return "-.Inf";
24783
- }
24784
- } else if (common2.isNegativeZero(object4)) {
24785
- return "-0.0";
24786
- }
24787
- res = object4.toString(10);
24788
- return SCIENTIFIC_WITHOUT_DOT2.test(res) ? res.replace("e", ".e") : res;
24789
- }
24790
- function isFloat2(object4) {
24791
- return Object.prototype.toString.call(object4) === "[object Number]" && (object4 % 1 !== 0 || common2.isNegativeZero(object4));
24792
- }
24793
- var float2 = new type2("tag:yaml.org,2002:float", {
24794
- kind: "scalar",
24795
- resolve: resolveYamlFloat2,
24796
- construct: constructYamlFloat2,
24797
- predicate: isFloat2,
24798
- represent: representYamlFloat2,
24799
- defaultStyle: "lowercase"
24800
- });
24801
- var json2 = failsafe2.extend({
24802
- implicit: [
24803
- _null5,
24804
- bool2,
24805
- int3,
24806
- float2
24807
- ]
24808
- });
24809
- var core3 = json2;
24810
- var YAML_DATE_REGEXP2 = new RegExp("^([0-9][0-9][0-9][0-9])" + "-([0-9][0-9])" + "-([0-9][0-9])$");
24811
- 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]))?))?$");
24812
- function resolveYamlTimestamp2(data) {
24813
- if (data === null)
24814
- return false;
24815
- if (YAML_DATE_REGEXP2.exec(data) !== null)
24816
- return true;
24817
- if (YAML_TIMESTAMP_REGEXP2.exec(data) !== null)
24818
- return true;
24819
- return false;
24820
- }
24821
- function constructYamlTimestamp2(data) {
24822
- var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date4;
24823
- match = YAML_DATE_REGEXP2.exec(data);
24824
- if (match === null)
24825
- match = YAML_TIMESTAMP_REGEXP2.exec(data);
24826
- if (match === null)
24827
- throw new Error("Date resolve error");
24828
- year = +match[1];
24829
- month = +match[2] - 1;
24830
- day = +match[3];
24831
- if (!match[4]) {
24832
- return new Date(Date.UTC(year, month, day));
24833
- }
24834
- hour = +match[4];
24835
- minute = +match[5];
24836
- second = +match[6];
24837
- if (match[7]) {
24838
- fraction = match[7].slice(0, 3);
24839
- while (fraction.length < 3) {
24840
- fraction += "0";
24841
- }
24842
- fraction = +fraction;
24843
- }
24844
- if (match[9]) {
24845
- tz_hour = +match[10];
24846
- tz_minute = +(match[11] || 0);
24847
- delta = (tz_hour * 60 + tz_minute) * 60000;
24848
- if (match[9] === "-")
24849
- delta = -delta;
24850
- }
24851
- date4 = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
24852
- if (delta)
24853
- date4.setTime(date4.getTime() - delta);
24854
- return date4;
24855
- }
24856
- function representYamlTimestamp2(object4) {
24857
- return object4.toISOString();
24858
- }
24859
- var timestamp2 = new type2("tag:yaml.org,2002:timestamp", {
24860
- kind: "scalar",
24861
- resolve: resolveYamlTimestamp2,
24862
- construct: constructYamlTimestamp2,
24863
- instanceOf: Date,
24864
- represent: representYamlTimestamp2
24865
- });
24866
- function resolveYamlMerge2(data) {
24867
- return data === "<<" || data === null;
24868
- }
24869
- var merge3 = new type2("tag:yaml.org,2002:merge", {
24870
- kind: "scalar",
24871
- resolve: resolveYamlMerge2
24872
- });
24873
- var BASE64_MAP2 = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
24874
- \r`;
24875
- function resolveYamlBinary2(data) {
24876
- if (data === null)
24877
- return false;
24878
- var code, idx, bitlen = 0, max = data.length, map4 = BASE64_MAP2;
24879
- for (idx = 0;idx < max; idx++) {
24880
- code = map4.indexOf(data.charAt(idx));
24881
- if (code > 64)
24882
- continue;
24883
- if (code < 0)
24884
- return false;
24885
- bitlen += 6;
24886
- }
24887
- return bitlen % 8 === 0;
24888
- }
24889
- function constructYamlBinary2(data) {
24890
- var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map4 = BASE64_MAP2, bits = 0, result = [];
24891
- for (idx = 0;idx < max; idx++) {
24892
- if (idx % 4 === 0 && idx) {
24893
- result.push(bits >> 16 & 255);
24894
- result.push(bits >> 8 & 255);
24895
- result.push(bits & 255);
24896
- }
24897
- bits = bits << 6 | map4.indexOf(input.charAt(idx));
24898
- }
24899
- tailbits = max % 4 * 6;
24900
- if (tailbits === 0) {
24901
- result.push(bits >> 16 & 255);
24902
- result.push(bits >> 8 & 255);
24903
- result.push(bits & 255);
24904
- } else if (tailbits === 18) {
24905
- result.push(bits >> 10 & 255);
24906
- result.push(bits >> 2 & 255);
24907
- } else if (tailbits === 12) {
24908
- result.push(bits >> 4 & 255);
24909
- }
24910
- return new Uint8Array(result);
24911
- }
24912
- function representYamlBinary2(object4) {
24913
- var result = "", bits = 0, idx, tail, max = object4.length, map4 = BASE64_MAP2;
24914
- for (idx = 0;idx < max; idx++) {
24915
- if (idx % 3 === 0 && idx) {
24916
- result += map4[bits >> 18 & 63];
24917
- result += map4[bits >> 12 & 63];
24918
- result += map4[bits >> 6 & 63];
24919
- result += map4[bits & 63];
24920
- }
24921
- bits = (bits << 8) + object4[idx];
24922
- }
24923
- tail = max % 3;
24924
- if (tail === 0) {
24925
- result += map4[bits >> 18 & 63];
24926
- result += map4[bits >> 12 & 63];
24927
- result += map4[bits >> 6 & 63];
24928
- result += map4[bits & 63];
24929
- } else if (tail === 2) {
24930
- result += map4[bits >> 10 & 63];
24931
- result += map4[bits >> 4 & 63];
24932
- result += map4[bits << 2 & 63];
24933
- result += map4[64];
24934
- } else if (tail === 1) {
24935
- result += map4[bits >> 2 & 63];
24936
- result += map4[bits << 4 & 63];
24937
- result += map4[64];
24938
- result += map4[64];
24939
- }
24940
- return result;
24941
- }
24942
- function isBinary2(obj) {
24943
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
24944
- }
24945
- var binary2 = new type2("tag:yaml.org,2002:binary", {
24946
- kind: "scalar",
24947
- resolve: resolveYamlBinary2,
24948
- construct: constructYamlBinary2,
24949
- predicate: isBinary2,
24950
- represent: representYamlBinary2
24951
- });
24952
- var _hasOwnProperty$32 = Object.prototype.hasOwnProperty;
24953
- var _toString$22 = Object.prototype.toString;
24954
- function resolveYamlOmap2(data) {
24955
- if (data === null)
24956
- return true;
24957
- var objectKeys = [], index, length, pair, pairKey, pairHasKey, object4 = data;
24958
- for (index = 0, length = object4.length;index < length; index += 1) {
24959
- pair = object4[index];
24960
- pairHasKey = false;
24961
- if (_toString$22.call(pair) !== "[object Object]")
24962
- return false;
24963
- for (pairKey in pair) {
24964
- if (_hasOwnProperty$32.call(pair, pairKey)) {
24965
- if (!pairHasKey)
24966
- pairHasKey = true;
24967
- else
24968
- return false;
24969
- }
24970
- }
24971
- if (!pairHasKey)
24972
- return false;
24973
- if (objectKeys.indexOf(pairKey) === -1)
24974
- objectKeys.push(pairKey);
24975
- else
24976
- return false;
24977
- }
24978
- return true;
24979
- }
24980
- function constructYamlOmap2(data) {
24981
- return data !== null ? data : [];
24982
- }
24983
- var omap2 = new type2("tag:yaml.org,2002:omap", {
24984
- kind: "sequence",
24985
- resolve: resolveYamlOmap2,
24986
- construct: constructYamlOmap2
24987
- });
24988
- var _toString$12 = Object.prototype.toString;
24989
- function resolveYamlPairs2(data) {
24990
- if (data === null)
24991
- return true;
24992
- var index, length, pair, keys, result, object4 = data;
24993
- result = new Array(object4.length);
24994
- for (index = 0, length = object4.length;index < length; index += 1) {
24995
- pair = object4[index];
24996
- if (_toString$12.call(pair) !== "[object Object]")
24997
- return false;
24998
- keys = Object.keys(pair);
24999
- if (keys.length !== 1)
25000
- return false;
25001
- result[index] = [keys[0], pair[keys[0]]];
25002
- }
25003
- return true;
25004
- }
25005
- function constructYamlPairs2(data) {
25006
- if (data === null)
25007
- return [];
25008
- var index, length, pair, keys, result, object4 = data;
25009
- result = new Array(object4.length);
25010
- for (index = 0, length = object4.length;index < length; index += 1) {
25011
- pair = object4[index];
25012
- keys = Object.keys(pair);
25013
- result[index] = [keys[0], pair[keys[0]]];
25014
- }
25015
- return result;
25016
- }
25017
- var pairs2 = new type2("tag:yaml.org,2002:pairs", {
25018
- kind: "sequence",
25019
- resolve: resolveYamlPairs2,
25020
- construct: constructYamlPairs2
25021
- });
25022
- var _hasOwnProperty$22 = Object.prototype.hasOwnProperty;
25023
- function resolveYamlSet2(data) {
25024
- if (data === null)
25025
- return true;
25026
- var key, object4 = data;
25027
- for (key in object4) {
25028
- if (_hasOwnProperty$22.call(object4, key)) {
25029
- if (object4[key] !== null)
25030
- return false;
25031
- }
25032
- }
25033
- return true;
25034
- }
25035
- function constructYamlSet2(data) {
25036
- return data !== null ? data : {};
25037
- }
25038
- var set3 = new type2("tag:yaml.org,2002:set", {
25039
- kind: "mapping",
25040
- resolve: resolveYamlSet2,
25041
- construct: constructYamlSet2
25042
- });
25043
- var _default3 = core3.extend({
25044
- implicit: [
25045
- timestamp2,
25046
- merge3
25047
- ],
25048
- explicit: [
25049
- binary2,
25050
- omap2,
25051
- pairs2,
25052
- set3
25053
- ]
25054
- });
25055
- var _hasOwnProperty$12 = Object.prototype.hasOwnProperty;
25056
- var CONTEXT_FLOW_IN2 = 1;
25057
- var CONTEXT_FLOW_OUT2 = 2;
25058
- var CONTEXT_BLOCK_IN2 = 3;
25059
- var CONTEXT_BLOCK_OUT2 = 4;
25060
- var CHOMPING_CLIP2 = 1;
25061
- var CHOMPING_STRIP2 = 2;
25062
- var CHOMPING_KEEP2 = 3;
25063
- var PATTERN_NON_PRINTABLE2 = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
25064
- var PATTERN_NON_ASCII_LINE_BREAKS2 = /[\x85\u2028\u2029]/;
25065
- var PATTERN_FLOW_INDICATORS2 = /[,\[\]\{\}]/;
25066
- var PATTERN_TAG_HANDLE2 = /^(?:!|!!|![a-z\-]+!)$/i;
25067
- var PATTERN_TAG_URI2 = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
25068
- function _class2(obj) {
25069
- return Object.prototype.toString.call(obj);
25070
- }
25071
- function is_EOL2(c) {
25072
- return c === 10 || c === 13;
25073
- }
25074
- function is_WHITE_SPACE2(c) {
25075
- return c === 9 || c === 32;
25076
- }
25077
- function is_WS_OR_EOL2(c) {
25078
- return c === 9 || c === 32 || c === 10 || c === 13;
25079
- }
25080
- function is_FLOW_INDICATOR2(c) {
25081
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
25082
- }
25083
- function fromHexCode2(c) {
25084
- var lc;
25085
- if (48 <= c && c <= 57) {
25086
- return c - 48;
25087
- }
25088
- lc = c | 32;
25089
- if (97 <= lc && lc <= 102) {
25090
- return lc - 97 + 10;
25091
- }
25092
- return -1;
25093
- }
25094
- function escapedHexLen2(c) {
25095
- if (c === 120) {
25096
- return 2;
25097
- }
25098
- if (c === 117) {
25099
- return 4;
25100
- }
25101
- if (c === 85) {
25102
- return 8;
25103
- }
25104
- return 0;
25105
- }
25106
- function fromDecimalCode2(c) {
25107
- if (48 <= c && c <= 57) {
25108
- return c - 48;
25109
- }
25110
- return -1;
25111
- }
25112
- function simpleEscapeSequence2(c) {
25113
- return c === 48 ? "\x00" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? "\t" : c === 9 ? "\t" : c === 110 ? `
25114
- ` : 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" : "";
25115
- }
25116
- function charFromCodepoint2(c) {
25117
- if (c <= 65535) {
25118
- return String.fromCharCode(c);
25119
- }
25120
- return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
25121
- }
25122
- function setProperty2(object4, key, value) {
25123
- if (key === "__proto__") {
25124
- Object.defineProperty(object4, key, {
25125
- configurable: true,
25126
- enumerable: true,
25127
- writable: true,
25128
- value
25129
- });
25130
- } else {
25131
- object4[key] = value;
25132
- }
25133
- }
25134
- var simpleEscapeCheck2 = new Array(256);
25135
- var simpleEscapeMap2 = new Array(256);
25136
- for (i2 = 0;i2 < 256; i2++) {
25137
- simpleEscapeCheck2[i2] = simpleEscapeSequence2(i2) ? 1 : 0;
25138
- simpleEscapeMap2[i2] = simpleEscapeSequence2(i2);
25139
- }
25140
- var i2;
25141
- function State$12(input, options) {
25142
- this.input = input;
25143
- this.filename = options["filename"] || null;
25144
- this.schema = options["schema"] || _default3;
25145
- this.onWarning = options["onWarning"] || null;
25146
- this.legacy = options["legacy"] || false;
25147
- this.json = options["json"] || false;
25148
- this.listener = options["listener"] || null;
25149
- this.implicitTypes = this.schema.compiledImplicit;
25150
- this.typeMap = this.schema.compiledTypeMap;
25151
- this.length = input.length;
25152
- this.position = 0;
25153
- this.line = 0;
25154
- this.lineStart = 0;
25155
- this.lineIndent = 0;
25156
- this.firstTabInLine = -1;
25157
- this.documents = [];
25158
- }
25159
- function generateError2(state, message) {
25160
- var mark = {
25161
- name: state.filename,
25162
- buffer: state.input.slice(0, -1),
25163
- position: state.position,
25164
- line: state.line,
25165
- column: state.position - state.lineStart
25166
- };
25167
- mark.snippet = snippet2(mark);
25168
- return new exception2(message, mark);
25169
- }
25170
- function throwError2(state, message) {
25171
- throw generateError2(state, message);
25172
- }
25173
- function throwWarning2(state, message) {
25174
- if (state.onWarning) {
25175
- state.onWarning.call(null, generateError2(state, message));
25176
- }
25177
- }
25178
- var directiveHandlers2 = {
25179
- YAML: function handleYamlDirective2(state, name, args) {
25180
- var match, major, minor;
25181
- if (state.version !== null) {
25182
- throwError2(state, "duplication of %YAML directive");
25183
- }
25184
- if (args.length !== 1) {
25185
- throwError2(state, "YAML directive accepts exactly one argument");
25186
- }
25187
- match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
25188
- if (match === null) {
25189
- throwError2(state, "ill-formed argument of the YAML directive");
25190
- }
25191
- major = parseInt(match[1], 10);
25192
- minor = parseInt(match[2], 10);
25193
- if (major !== 1) {
25194
- throwError2(state, "unacceptable YAML version of the document");
25195
- }
25196
- state.version = args[0];
25197
- state.checkLineBreaks = minor < 2;
25198
- if (minor !== 1 && minor !== 2) {
25199
- throwWarning2(state, "unsupported YAML version of the document");
25200
- }
25201
- },
25202
- TAG: function handleTagDirective2(state, name, args) {
25203
- var handle, prefix;
25204
- if (args.length !== 2) {
25205
- throwError2(state, "TAG directive accepts exactly two arguments");
25206
- }
25207
- handle = args[0];
25208
- prefix = args[1];
25209
- if (!PATTERN_TAG_HANDLE2.test(handle)) {
25210
- throwError2(state, "ill-formed tag handle (first argument) of the TAG directive");
25211
- }
25212
- if (_hasOwnProperty$12.call(state.tagMap, handle)) {
25213
- throwError2(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
25214
- }
25215
- if (!PATTERN_TAG_URI2.test(prefix)) {
25216
- throwError2(state, "ill-formed tag prefix (second argument) of the TAG directive");
25217
- }
25218
- try {
25219
- prefix = decodeURIComponent(prefix);
25220
- } catch (err) {
25221
- throwError2(state, "tag prefix is malformed: " + prefix);
25222
- }
25223
- state.tagMap[handle] = prefix;
25224
- }
25225
- };
25226
- function captureSegment2(state, start, end, checkJson) {
25227
- var _position, _length2, _character, _result;
25228
- if (start < end) {
25229
- _result = state.input.slice(start, end);
25230
- if (checkJson) {
25231
- for (_position = 0, _length2 = _result.length;_position < _length2; _position += 1) {
25232
- _character = _result.charCodeAt(_position);
25233
- if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
25234
- throwError2(state, "expected valid JSON character");
25235
- }
25236
- }
25237
- } else if (PATTERN_NON_PRINTABLE2.test(_result)) {
25238
- throwError2(state, "the stream contains non-printable characters");
25239
- }
25240
- state.result += _result;
25241
- }
25242
- }
25243
- function mergeMappings2(state, destination, source, overridableKeys) {
25244
- var sourceKeys, key, index, quantity;
25245
- if (!common2.isObject(source)) {
25246
- throwError2(state, "cannot merge mappings; the provided source object is unacceptable");
25247
- }
25248
- sourceKeys = Object.keys(source);
25249
- for (index = 0, quantity = sourceKeys.length;index < quantity; index += 1) {
25250
- key = sourceKeys[index];
25251
- if (!_hasOwnProperty$12.call(destination, key)) {
25252
- setProperty2(destination, key, source[key]);
25253
- overridableKeys[key] = true;
25254
- }
25255
- }
25256
- }
25257
- function storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
25258
- var index, quantity;
25259
- if (Array.isArray(keyNode)) {
25260
- keyNode = Array.prototype.slice.call(keyNode);
25261
- for (index = 0, quantity = keyNode.length;index < quantity; index += 1) {
25262
- if (Array.isArray(keyNode[index])) {
25263
- throwError2(state, "nested arrays are not supported inside keys");
25264
- }
25265
- if (typeof keyNode === "object" && _class2(keyNode[index]) === "[object Object]") {
25266
- keyNode[index] = "[object Object]";
25267
- }
25268
- }
25269
- }
25270
- if (typeof keyNode === "object" && _class2(keyNode) === "[object Object]") {
25271
- keyNode = "[object Object]";
25272
- }
25273
- keyNode = String(keyNode);
25274
- if (_result === null) {
25275
- _result = {};
25276
- }
25277
- if (keyTag === "tag:yaml.org,2002:merge") {
25278
- if (Array.isArray(valueNode)) {
25279
- for (index = 0, quantity = valueNode.length;index < quantity; index += 1) {
25280
- mergeMappings2(state, _result, valueNode[index], overridableKeys);
25281
- }
25282
- } else {
25283
- mergeMappings2(state, _result, valueNode, overridableKeys);
25284
- }
25285
- } else {
25286
- if (!state.json && !_hasOwnProperty$12.call(overridableKeys, keyNode) && _hasOwnProperty$12.call(_result, keyNode)) {
25287
- state.line = startLine || state.line;
25288
- state.lineStart = startLineStart || state.lineStart;
25289
- state.position = startPos || state.position;
25290
- throwError2(state, "duplicated mapping key");
25291
- }
25292
- setProperty2(_result, keyNode, valueNode);
25293
- delete overridableKeys[keyNode];
25294
- }
25295
- return _result;
25296
- }
25297
- function readLineBreak2(state) {
25298
- var ch;
25299
- ch = state.input.charCodeAt(state.position);
25300
- if (ch === 10) {
25301
- state.position++;
25302
- } else if (ch === 13) {
25303
- state.position++;
25304
- if (state.input.charCodeAt(state.position) === 10) {
25305
- state.position++;
25306
- }
25307
- } else {
25308
- throwError2(state, "a line break is expected");
25309
- }
25310
- state.line += 1;
25311
- state.lineStart = state.position;
25312
- state.firstTabInLine = -1;
25313
- }
25314
- function skipSeparationSpace2(state, allowComments, checkIndent) {
25315
- var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
25316
- while (ch !== 0) {
25317
- while (is_WHITE_SPACE2(ch)) {
25318
- if (ch === 9 && state.firstTabInLine === -1) {
25319
- state.firstTabInLine = state.position;
25320
- }
25321
- ch = state.input.charCodeAt(++state.position);
25322
- }
25323
- if (allowComments && ch === 35) {
25324
- do {
25325
- ch = state.input.charCodeAt(++state.position);
25326
- } while (ch !== 10 && ch !== 13 && ch !== 0);
25327
- }
25328
- if (is_EOL2(ch)) {
25329
- readLineBreak2(state);
25330
- ch = state.input.charCodeAt(state.position);
25331
- lineBreaks++;
25332
- state.lineIndent = 0;
25333
- while (ch === 32) {
25334
- state.lineIndent++;
25335
- ch = state.input.charCodeAt(++state.position);
25336
- }
25337
- } else {
25338
- break;
25339
- }
25340
- }
25341
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
25342
- throwWarning2(state, "deficient indentation");
25343
- }
25344
- return lineBreaks;
25345
- }
25346
- function testDocumentSeparator2(state) {
25347
- var _position = state.position, ch;
25348
- ch = state.input.charCodeAt(_position);
25349
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
25350
- _position += 3;
25351
- ch = state.input.charCodeAt(_position);
25352
- if (ch === 0 || is_WS_OR_EOL2(ch)) {
25353
- return true;
25354
- }
25355
- }
25356
- return false;
25357
- }
25358
- function writeFoldedLines2(state, count) {
25359
- if (count === 1) {
25360
- state.result += " ";
25361
- } else if (count > 1) {
25362
- state.result += common2.repeat(`
25363
- `, count - 1);
25364
- }
25365
- }
25366
- function readPlainScalar2(state, nodeIndent, withinFlowCollection) {
25367
- var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
25368
- ch = state.input.charCodeAt(state.position);
25369
- 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) {
25370
- return false;
25371
- }
25372
- if (ch === 63 || ch === 45) {
25373
- following = state.input.charCodeAt(state.position + 1);
25374
- if (is_WS_OR_EOL2(following) || withinFlowCollection && is_FLOW_INDICATOR2(following)) {
25375
- return false;
25376
- }
25377
- }
25378
- state.kind = "scalar";
25379
- state.result = "";
25380
- captureStart = captureEnd = state.position;
25381
- hasPendingContent = false;
25382
- while (ch !== 0) {
25383
- if (ch === 58) {
25384
- following = state.input.charCodeAt(state.position + 1);
25385
- if (is_WS_OR_EOL2(following) || withinFlowCollection && is_FLOW_INDICATOR2(following)) {
25386
- break;
25387
- }
25388
- } else if (ch === 35) {
25389
- preceding = state.input.charCodeAt(state.position - 1);
25390
- if (is_WS_OR_EOL2(preceding)) {
25391
- break;
25392
- }
25393
- } else if (state.position === state.lineStart && testDocumentSeparator2(state) || withinFlowCollection && is_FLOW_INDICATOR2(ch)) {
25394
- break;
25395
- } else if (is_EOL2(ch)) {
25396
- _line = state.line;
25397
- _lineStart = state.lineStart;
25398
- _lineIndent = state.lineIndent;
25399
- skipSeparationSpace2(state, false, -1);
25400
- if (state.lineIndent >= nodeIndent) {
25401
- hasPendingContent = true;
25402
- ch = state.input.charCodeAt(state.position);
25403
- continue;
25404
- } else {
25405
- state.position = captureEnd;
25406
- state.line = _line;
25407
- state.lineStart = _lineStart;
25408
- state.lineIndent = _lineIndent;
25409
- break;
25410
- }
25411
- }
25412
- if (hasPendingContent) {
25413
- captureSegment2(state, captureStart, captureEnd, false);
25414
- writeFoldedLines2(state, state.line - _line);
25415
- captureStart = captureEnd = state.position;
25416
- hasPendingContent = false;
25417
- }
25418
- if (!is_WHITE_SPACE2(ch)) {
25419
- captureEnd = state.position + 1;
25420
- }
25421
- ch = state.input.charCodeAt(++state.position);
25422
- }
25423
- captureSegment2(state, captureStart, captureEnd, false);
25424
- if (state.result) {
25425
- return true;
25426
- }
25427
- state.kind = _kind;
25428
- state.result = _result;
25429
- return false;
25430
- }
25431
- function readSingleQuotedScalar2(state, nodeIndent) {
25432
- var ch, captureStart, captureEnd;
25433
- ch = state.input.charCodeAt(state.position);
25434
- if (ch !== 39) {
25435
- return false;
25436
- }
25437
- state.kind = "scalar";
25438
- state.result = "";
25439
- state.position++;
25440
- captureStart = captureEnd = state.position;
25441
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
25442
- if (ch === 39) {
25443
- captureSegment2(state, captureStart, state.position, true);
25444
- ch = state.input.charCodeAt(++state.position);
25445
- if (ch === 39) {
25446
- captureStart = state.position;
25447
- state.position++;
25448
- captureEnd = state.position;
25449
- } else {
25450
- return true;
25451
- }
25452
- } else if (is_EOL2(ch)) {
25453
- captureSegment2(state, captureStart, captureEnd, true);
25454
- writeFoldedLines2(state, skipSeparationSpace2(state, false, nodeIndent));
25455
- captureStart = captureEnd = state.position;
25456
- } else if (state.position === state.lineStart && testDocumentSeparator2(state)) {
25457
- throwError2(state, "unexpected end of the document within a single quoted scalar");
25458
- } else {
25459
- state.position++;
25460
- captureEnd = state.position;
25461
- }
25462
- }
25463
- throwError2(state, "unexpected end of the stream within a single quoted scalar");
25464
- }
25465
- function readDoubleQuotedScalar2(state, nodeIndent) {
25466
- var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
25467
- ch = state.input.charCodeAt(state.position);
25468
- if (ch !== 34) {
25469
- return false;
25470
- }
25471
- state.kind = "scalar";
25472
- state.result = "";
25473
- state.position++;
25474
- captureStart = captureEnd = state.position;
25475
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
25476
- if (ch === 34) {
25477
- captureSegment2(state, captureStart, state.position, true);
25478
- state.position++;
25479
- return true;
25480
- } else if (ch === 92) {
25481
- captureSegment2(state, captureStart, state.position, true);
25482
- ch = state.input.charCodeAt(++state.position);
25483
- if (is_EOL2(ch)) {
25484
- skipSeparationSpace2(state, false, nodeIndent);
25485
- } else if (ch < 256 && simpleEscapeCheck2[ch]) {
25486
- state.result += simpleEscapeMap2[ch];
25487
- state.position++;
25488
- } else if ((tmp = escapedHexLen2(ch)) > 0) {
25489
- hexLength = tmp;
25490
- hexResult = 0;
25491
- for (;hexLength > 0; hexLength--) {
25492
- ch = state.input.charCodeAt(++state.position);
25493
- if ((tmp = fromHexCode2(ch)) >= 0) {
25494
- hexResult = (hexResult << 4) + tmp;
25495
- } else {
25496
- throwError2(state, "expected hexadecimal character");
25497
- }
25498
- }
25499
- state.result += charFromCodepoint2(hexResult);
25500
- state.position++;
25501
- } else {
25502
- throwError2(state, "unknown escape sequence");
25503
- }
25504
- captureStart = captureEnd = state.position;
25505
- } else if (is_EOL2(ch)) {
25506
- captureSegment2(state, captureStart, captureEnd, true);
25507
- writeFoldedLines2(state, skipSeparationSpace2(state, false, nodeIndent));
25508
- captureStart = captureEnd = state.position;
25509
- } else if (state.position === state.lineStart && testDocumentSeparator2(state)) {
25510
- throwError2(state, "unexpected end of the document within a double quoted scalar");
25511
- } else {
25512
- state.position++;
25513
- captureEnd = state.position;
25514
- }
25515
- }
25516
- throwError2(state, "unexpected end of the stream within a double quoted scalar");
25517
- }
25518
- function readFlowCollection2(state, nodeIndent) {
25519
- 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;
25520
- ch = state.input.charCodeAt(state.position);
25521
- if (ch === 91) {
25522
- terminator = 93;
25523
- isMapping = false;
25524
- _result = [];
25525
- } else if (ch === 123) {
25526
- terminator = 125;
25527
- isMapping = true;
25528
- _result = {};
25529
- } else {
25530
- return false;
25531
- }
25532
- if (state.anchor !== null) {
25533
- state.anchorMap[state.anchor] = _result;
25534
- }
25535
- ch = state.input.charCodeAt(++state.position);
25536
- while (ch !== 0) {
25537
- skipSeparationSpace2(state, true, nodeIndent);
25538
- ch = state.input.charCodeAt(state.position);
25539
- if (ch === terminator) {
25540
- state.position++;
25541
- state.tag = _tag;
25542
- state.anchor = _anchor;
25543
- state.kind = isMapping ? "mapping" : "sequence";
25544
- state.result = _result;
25545
- return true;
25546
- } else if (!readNext) {
25547
- throwError2(state, "missed comma between flow collection entries");
25548
- } else if (ch === 44) {
25549
- throwError2(state, "expected the node content, but found ','");
25550
- }
25551
- keyTag = keyNode = valueNode = null;
25552
- isPair = isExplicitPair = false;
25553
- if (ch === 63) {
25554
- following = state.input.charCodeAt(state.position + 1);
25555
- if (is_WS_OR_EOL2(following)) {
25556
- isPair = isExplicitPair = true;
25557
- state.position++;
25558
- skipSeparationSpace2(state, true, nodeIndent);
25559
- }
25560
- }
25561
- _line = state.line;
25562
- _lineStart = state.lineStart;
25563
- _pos = state.position;
25564
- composeNode2(state, nodeIndent, CONTEXT_FLOW_IN2, false, true);
25565
- keyTag = state.tag;
25566
- keyNode = state.result;
25567
- skipSeparationSpace2(state, true, nodeIndent);
25568
- ch = state.input.charCodeAt(state.position);
25569
- if ((isExplicitPair || state.line === _line) && ch === 58) {
25570
- isPair = true;
25571
- ch = state.input.charCodeAt(++state.position);
25572
- skipSeparationSpace2(state, true, nodeIndent);
25573
- composeNode2(state, nodeIndent, CONTEXT_FLOW_IN2, false, true);
25574
- valueNode = state.result;
25575
- }
25576
- if (isMapping) {
25577
- storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
25578
- } else if (isPair) {
25579
- _result.push(storeMappingPair2(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
25580
- } else {
25581
- _result.push(keyNode);
25582
- }
25583
- skipSeparationSpace2(state, true, nodeIndent);
25584
- ch = state.input.charCodeAt(state.position);
25585
- if (ch === 44) {
25586
- readNext = true;
25587
- ch = state.input.charCodeAt(++state.position);
25588
- } else {
25589
- readNext = false;
25590
- }
25591
- }
25592
- throwError2(state, "unexpected end of the stream within a flow collection");
25593
- }
25594
- function readBlockScalar2(state, nodeIndent) {
25595
- var captureStart, folding, chomping = CHOMPING_CLIP2, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
25596
- ch = state.input.charCodeAt(state.position);
25597
- if (ch === 124) {
25598
- folding = false;
25599
- } else if (ch === 62) {
25600
- folding = true;
25601
- } else {
25602
- return false;
25603
- }
25604
- state.kind = "scalar";
25605
- state.result = "";
25606
- while (ch !== 0) {
25607
- ch = state.input.charCodeAt(++state.position);
25608
- if (ch === 43 || ch === 45) {
25609
- if (CHOMPING_CLIP2 === chomping) {
25610
- chomping = ch === 43 ? CHOMPING_KEEP2 : CHOMPING_STRIP2;
25611
- } else {
25612
- throwError2(state, "repeat of a chomping mode identifier");
25613
- }
25614
- } else if ((tmp = fromDecimalCode2(ch)) >= 0) {
25615
- if (tmp === 0) {
25616
- throwError2(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
25617
- } else if (!detectedIndent) {
25618
- textIndent = nodeIndent + tmp - 1;
25619
- detectedIndent = true;
25620
- } else {
25621
- throwError2(state, "repeat of an indentation width identifier");
25622
- }
25623
- } else {
25624
- break;
25625
- }
25626
- }
25627
- if (is_WHITE_SPACE2(ch)) {
25628
- do {
25629
- ch = state.input.charCodeAt(++state.position);
25630
- } while (is_WHITE_SPACE2(ch));
25631
- if (ch === 35) {
25632
- do {
25633
- ch = state.input.charCodeAt(++state.position);
25634
- } while (!is_EOL2(ch) && ch !== 0);
25635
- }
25636
- }
25637
- while (ch !== 0) {
25638
- readLineBreak2(state);
25639
- state.lineIndent = 0;
25640
- ch = state.input.charCodeAt(state.position);
25641
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
25642
- state.lineIndent++;
25643
- ch = state.input.charCodeAt(++state.position);
25644
- }
25645
- if (!detectedIndent && state.lineIndent > textIndent) {
25646
- textIndent = state.lineIndent;
25647
- }
25648
- if (is_EOL2(ch)) {
25649
- emptyLines++;
25650
- continue;
25651
- }
25652
- if (state.lineIndent < textIndent) {
25653
- if (chomping === CHOMPING_KEEP2) {
25654
- state.result += common2.repeat(`
25655
- `, didReadContent ? 1 + emptyLines : emptyLines);
25656
- } else if (chomping === CHOMPING_CLIP2) {
25657
- if (didReadContent) {
25658
- state.result += `
25659
- `;
25660
- }
25661
- }
25662
- break;
25663
- }
25664
- if (folding) {
25665
- if (is_WHITE_SPACE2(ch)) {
25666
- atMoreIndented = true;
25667
- state.result += common2.repeat(`
25668
- `, didReadContent ? 1 + emptyLines : emptyLines);
25669
- } else if (atMoreIndented) {
25670
- atMoreIndented = false;
25671
- state.result += common2.repeat(`
25672
- `, emptyLines + 1);
25673
- } else if (emptyLines === 0) {
25674
- if (didReadContent) {
25675
- state.result += " ";
25676
- }
25677
- } else {
25678
- state.result += common2.repeat(`
25679
- `, emptyLines);
25680
- }
25681
- } else {
25682
- state.result += common2.repeat(`
25683
- `, didReadContent ? 1 + emptyLines : emptyLines);
25684
- }
25685
- didReadContent = true;
25686
- detectedIndent = true;
25687
- emptyLines = 0;
25688
- captureStart = state.position;
25689
- while (!is_EOL2(ch) && ch !== 0) {
25690
- ch = state.input.charCodeAt(++state.position);
25691
- }
25692
- captureSegment2(state, captureStart, state.position, false);
25693
- }
25694
- return true;
25695
- }
25696
- function readBlockSequence2(state, nodeIndent) {
25697
- var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
25698
- if (state.firstTabInLine !== -1)
25699
- return false;
25700
- if (state.anchor !== null) {
25701
- state.anchorMap[state.anchor] = _result;
25702
- }
25703
- ch = state.input.charCodeAt(state.position);
25704
- while (ch !== 0) {
25705
- if (state.firstTabInLine !== -1) {
25706
- state.position = state.firstTabInLine;
25707
- throwError2(state, "tab characters must not be used in indentation");
25708
- }
25709
- if (ch !== 45) {
25710
- break;
25711
- }
25712
- following = state.input.charCodeAt(state.position + 1);
25713
- if (!is_WS_OR_EOL2(following)) {
25714
- break;
25715
- }
25716
- detected = true;
25717
- state.position++;
25718
- if (skipSeparationSpace2(state, true, -1)) {
25719
- if (state.lineIndent <= nodeIndent) {
25720
- _result.push(null);
25721
- ch = state.input.charCodeAt(state.position);
25722
- continue;
25723
- }
25724
- }
25725
- _line = state.line;
25726
- composeNode2(state, nodeIndent, CONTEXT_BLOCK_IN2, false, true);
25727
- _result.push(state.result);
25728
- skipSeparationSpace2(state, true, -1);
25729
- ch = state.input.charCodeAt(state.position);
25730
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
25731
- throwError2(state, "bad indentation of a sequence entry");
25732
- } else if (state.lineIndent < nodeIndent) {
25733
- break;
25734
- }
25735
- }
25736
- if (detected) {
25737
- state.tag = _tag;
25738
- state.anchor = _anchor;
25739
- state.kind = "sequence";
25740
- state.result = _result;
25741
- return true;
25742
- }
25743
- return false;
25744
- }
25745
- function readBlockMapping2(state, nodeIndent, flowIndent) {
25746
- 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;
25747
- if (state.firstTabInLine !== -1)
25748
- return false;
25749
- if (state.anchor !== null) {
25750
- state.anchorMap[state.anchor] = _result;
25751
- }
25752
- ch = state.input.charCodeAt(state.position);
25753
- while (ch !== 0) {
25754
- if (!atExplicitKey && state.firstTabInLine !== -1) {
25755
- state.position = state.firstTabInLine;
25756
- throwError2(state, "tab characters must not be used in indentation");
25757
- }
25758
- following = state.input.charCodeAt(state.position + 1);
25759
- _line = state.line;
25760
- if ((ch === 63 || ch === 58) && is_WS_OR_EOL2(following)) {
25761
- if (ch === 63) {
25762
- if (atExplicitKey) {
25763
- storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
25764
- keyTag = keyNode = valueNode = null;
25765
- }
25766
- detected = true;
25767
- atExplicitKey = true;
25768
- allowCompact = true;
25769
- } else if (atExplicitKey) {
25770
- atExplicitKey = false;
25771
- allowCompact = true;
25772
- } else {
25773
- throwError2(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
25774
- }
25775
- state.position += 1;
25776
- ch = following;
25777
- } else {
25778
- _keyLine = state.line;
25779
- _keyLineStart = state.lineStart;
25780
- _keyPos = state.position;
25781
- if (!composeNode2(state, flowIndent, CONTEXT_FLOW_OUT2, false, true)) {
25782
- break;
25783
- }
25784
- if (state.line === _line) {
25785
- ch = state.input.charCodeAt(state.position);
25786
- while (is_WHITE_SPACE2(ch)) {
25787
- ch = state.input.charCodeAt(++state.position);
25788
- }
25789
- if (ch === 58) {
25790
- ch = state.input.charCodeAt(++state.position);
25791
- if (!is_WS_OR_EOL2(ch)) {
25792
- throwError2(state, "a whitespace character is expected after the key-value separator within a block mapping");
25793
- }
25794
- if (atExplicitKey) {
25795
- storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
25796
- keyTag = keyNode = valueNode = null;
25797
- }
25798
- detected = true;
25799
- atExplicitKey = false;
25800
- allowCompact = false;
25801
- keyTag = state.tag;
25802
- keyNode = state.result;
25803
- } else if (detected) {
25804
- throwError2(state, "can not read an implicit mapping pair; a colon is missed");
25805
- } else {
25806
- state.tag = _tag;
25807
- state.anchor = _anchor;
25808
- return true;
25809
- }
25810
- } else if (detected) {
25811
- throwError2(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
25812
- } else {
25813
- state.tag = _tag;
25814
- state.anchor = _anchor;
25815
- return true;
25816
- }
25817
- }
25818
- if (state.line === _line || state.lineIndent > nodeIndent) {
25819
- if (atExplicitKey) {
25820
- _keyLine = state.line;
25821
- _keyLineStart = state.lineStart;
25822
- _keyPos = state.position;
25823
- }
25824
- if (composeNode2(state, nodeIndent, CONTEXT_BLOCK_OUT2, true, allowCompact)) {
25825
- if (atExplicitKey) {
25826
- keyNode = state.result;
25827
- } else {
25828
- valueNode = state.result;
25829
- }
25830
- }
25831
- if (!atExplicitKey) {
25832
- storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
25833
- keyTag = keyNode = valueNode = null;
25834
- }
25835
- skipSeparationSpace2(state, true, -1);
25836
- ch = state.input.charCodeAt(state.position);
25837
- }
25838
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
25839
- throwError2(state, "bad indentation of a mapping entry");
25840
- } else if (state.lineIndent < nodeIndent) {
25841
- break;
25842
- }
25843
- }
25844
- if (atExplicitKey) {
25845
- storeMappingPair2(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
25846
- }
25847
- if (detected) {
25848
- state.tag = _tag;
25849
- state.anchor = _anchor;
25850
- state.kind = "mapping";
25851
- state.result = _result;
25852
- }
25853
- return detected;
25854
- }
25855
- function readTagProperty2(state) {
25856
- var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
25857
- ch = state.input.charCodeAt(state.position);
25858
- if (ch !== 33)
25859
- return false;
25860
- if (state.tag !== null) {
25861
- throwError2(state, "duplication of a tag property");
25862
- }
25863
- ch = state.input.charCodeAt(++state.position);
25864
- if (ch === 60) {
25865
- isVerbatim = true;
25866
- ch = state.input.charCodeAt(++state.position);
25867
- } else if (ch === 33) {
25868
- isNamed = true;
25869
- tagHandle = "!!";
25870
- ch = state.input.charCodeAt(++state.position);
25871
- } else {
25872
- tagHandle = "!";
25873
- }
25874
- _position = state.position;
25875
- if (isVerbatim) {
25876
- do {
25877
- ch = state.input.charCodeAt(++state.position);
25878
- } while (ch !== 0 && ch !== 62);
25879
- if (state.position < state.length) {
25880
- tagName = state.input.slice(_position, state.position);
25881
- ch = state.input.charCodeAt(++state.position);
25882
- } else {
25883
- throwError2(state, "unexpected end of the stream within a verbatim tag");
25884
- }
25885
- } else {
25886
- while (ch !== 0 && !is_WS_OR_EOL2(ch)) {
25887
- if (ch === 33) {
25888
- if (!isNamed) {
25889
- tagHandle = state.input.slice(_position - 1, state.position + 1);
25890
- if (!PATTERN_TAG_HANDLE2.test(tagHandle)) {
25891
- throwError2(state, "named tag handle cannot contain such characters");
25892
- }
25893
- isNamed = true;
25894
- _position = state.position + 1;
25895
- } else {
25896
- throwError2(state, "tag suffix cannot contain exclamation marks");
25897
- }
25898
- }
25899
- ch = state.input.charCodeAt(++state.position);
25900
- }
25901
- tagName = state.input.slice(_position, state.position);
25902
- if (PATTERN_FLOW_INDICATORS2.test(tagName)) {
25903
- throwError2(state, "tag suffix cannot contain flow indicator characters");
25904
- }
25905
- }
25906
- if (tagName && !PATTERN_TAG_URI2.test(tagName)) {
25907
- throwError2(state, "tag name cannot contain such characters: " + tagName);
25908
- }
25909
- try {
25910
- tagName = decodeURIComponent(tagName);
25911
- } catch (err) {
25912
- throwError2(state, "tag name is malformed: " + tagName);
25913
- }
25914
- if (isVerbatim) {
25915
- state.tag = tagName;
25916
- } else if (_hasOwnProperty$12.call(state.tagMap, tagHandle)) {
25917
- state.tag = state.tagMap[tagHandle] + tagName;
25918
- } else if (tagHandle === "!") {
25919
- state.tag = "!" + tagName;
25920
- } else if (tagHandle === "!!") {
25921
- state.tag = "tag:yaml.org,2002:" + tagName;
25922
- } else {
25923
- throwError2(state, 'undeclared tag handle "' + tagHandle + '"');
25924
- }
25925
- return true;
25926
- }
25927
- function readAnchorProperty2(state) {
25928
- var _position, ch;
25929
- ch = state.input.charCodeAt(state.position);
25930
- if (ch !== 38)
25931
- return false;
25932
- if (state.anchor !== null) {
25933
- throwError2(state, "duplication of an anchor property");
25934
- }
25935
- ch = state.input.charCodeAt(++state.position);
25936
- _position = state.position;
25937
- while (ch !== 0 && !is_WS_OR_EOL2(ch) && !is_FLOW_INDICATOR2(ch)) {
25938
- ch = state.input.charCodeAt(++state.position);
25939
- }
25940
- if (state.position === _position) {
25941
- throwError2(state, "name of an anchor node must contain at least one character");
25942
- }
25943
- state.anchor = state.input.slice(_position, state.position);
25944
- return true;
25945
- }
25946
- function readAlias2(state) {
25947
- var _position, alias, ch;
25948
- ch = state.input.charCodeAt(state.position);
25949
- if (ch !== 42)
25950
- return false;
25951
- ch = state.input.charCodeAt(++state.position);
25952
- _position = state.position;
25953
- while (ch !== 0 && !is_WS_OR_EOL2(ch) && !is_FLOW_INDICATOR2(ch)) {
25954
- ch = state.input.charCodeAt(++state.position);
25955
- }
25956
- if (state.position === _position) {
25957
- throwError2(state, "name of an alias node must contain at least one character");
25958
- }
25959
- alias = state.input.slice(_position, state.position);
25960
- if (!_hasOwnProperty$12.call(state.anchorMap, alias)) {
25961
- throwError2(state, 'unidentified alias "' + alias + '"');
25962
- }
25963
- state.result = state.anchorMap[alias];
25964
- skipSeparationSpace2(state, true, -1);
25965
- return true;
25966
- }
25967
- function composeNode2(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
25968
- var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type3, flowIndent, blockIndent;
25969
- if (state.listener !== null) {
25970
- state.listener("open", state);
25971
- }
25972
- state.tag = null;
25973
- state.anchor = null;
25974
- state.kind = null;
25975
- state.result = null;
25976
- allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT2 === nodeContext || CONTEXT_BLOCK_IN2 === nodeContext;
25977
- if (allowToSeek) {
25978
- if (skipSeparationSpace2(state, true, -1)) {
25979
- atNewLine = true;
25980
- if (state.lineIndent > parentIndent) {
25981
- indentStatus = 1;
25982
- } else if (state.lineIndent === parentIndent) {
25983
- indentStatus = 0;
25984
- } else if (state.lineIndent < parentIndent) {
25985
- indentStatus = -1;
25986
- }
25987
- }
25988
- }
25989
- if (indentStatus === 1) {
25990
- while (readTagProperty2(state) || readAnchorProperty2(state)) {
25991
- if (skipSeparationSpace2(state, true, -1)) {
25992
- atNewLine = true;
25993
- allowBlockCollections = allowBlockStyles;
25994
- if (state.lineIndent > parentIndent) {
25995
- indentStatus = 1;
25996
- } else if (state.lineIndent === parentIndent) {
25997
- indentStatus = 0;
25998
- } else if (state.lineIndent < parentIndent) {
25999
- indentStatus = -1;
26000
- }
26001
- } else {
26002
- allowBlockCollections = false;
26003
- }
26004
- }
26005
- }
26006
- if (allowBlockCollections) {
26007
- allowBlockCollections = atNewLine || allowCompact;
26008
- }
26009
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT2 === nodeContext) {
26010
- if (CONTEXT_FLOW_IN2 === nodeContext || CONTEXT_FLOW_OUT2 === nodeContext) {
26011
- flowIndent = parentIndent;
26012
- } else {
26013
- flowIndent = parentIndent + 1;
26014
- }
26015
- blockIndent = state.position - state.lineStart;
26016
- if (indentStatus === 1) {
26017
- if (allowBlockCollections && (readBlockSequence2(state, blockIndent) || readBlockMapping2(state, blockIndent, flowIndent)) || readFlowCollection2(state, flowIndent)) {
26018
- hasContent = true;
26019
- } else {
26020
- if (allowBlockScalars && readBlockScalar2(state, flowIndent) || readSingleQuotedScalar2(state, flowIndent) || readDoubleQuotedScalar2(state, flowIndent)) {
26021
- hasContent = true;
26022
- } else if (readAlias2(state)) {
26023
- hasContent = true;
26024
- if (state.tag !== null || state.anchor !== null) {
26025
- throwError2(state, "alias node should not have any properties");
26026
- }
26027
- } else if (readPlainScalar2(state, flowIndent, CONTEXT_FLOW_IN2 === nodeContext)) {
26028
- hasContent = true;
26029
- if (state.tag === null) {
26030
- state.tag = "?";
26031
- }
26032
- }
26033
- if (state.anchor !== null) {
26034
- state.anchorMap[state.anchor] = state.result;
26035
- }
26036
- }
26037
- } else if (indentStatus === 0) {
26038
- hasContent = allowBlockCollections && readBlockSequence2(state, blockIndent);
26039
- }
26040
- }
26041
- if (state.tag === null) {
26042
- if (state.anchor !== null) {
26043
- state.anchorMap[state.anchor] = state.result;
26044
- }
26045
- } else if (state.tag === "?") {
26046
- if (state.result !== null && state.kind !== "scalar") {
26047
- throwError2(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
26048
- }
26049
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length;typeIndex < typeQuantity; typeIndex += 1) {
26050
- type3 = state.implicitTypes[typeIndex];
26051
- if (type3.resolve(state.result)) {
26052
- state.result = type3.construct(state.result);
26053
- state.tag = type3.tag;
26054
- if (state.anchor !== null) {
26055
- state.anchorMap[state.anchor] = state.result;
26056
- }
26057
- break;
26058
- }
26059
- }
26060
- } else if (state.tag !== "!") {
26061
- if (_hasOwnProperty$12.call(state.typeMap[state.kind || "fallback"], state.tag)) {
26062
- type3 = state.typeMap[state.kind || "fallback"][state.tag];
26063
- } else {
26064
- type3 = null;
26065
- typeList = state.typeMap.multi[state.kind || "fallback"];
26066
- for (typeIndex = 0, typeQuantity = typeList.length;typeIndex < typeQuantity; typeIndex += 1) {
26067
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
26068
- type3 = typeList[typeIndex];
26069
- break;
26070
- }
26071
- }
26072
- }
26073
- if (!type3) {
26074
- throwError2(state, "unknown tag !<" + state.tag + ">");
26075
- }
26076
- if (state.result !== null && type3.kind !== state.kind) {
26077
- throwError2(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type3.kind + '", not "' + state.kind + '"');
26078
- }
26079
- if (!type3.resolve(state.result, state.tag)) {
26080
- throwError2(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
26081
- } else {
26082
- state.result = type3.construct(state.result, state.tag);
26083
- if (state.anchor !== null) {
26084
- state.anchorMap[state.anchor] = state.result;
26085
- }
26086
- }
26087
- }
26088
- if (state.listener !== null) {
26089
- state.listener("close", state);
26090
- }
26091
- return state.tag !== null || state.anchor !== null || hasContent;
26092
- }
26093
- function readDocument2(state) {
26094
- var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
26095
- state.version = null;
26096
- state.checkLineBreaks = state.legacy;
26097
- state.tagMap = Object.create(null);
26098
- state.anchorMap = Object.create(null);
26099
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
26100
- skipSeparationSpace2(state, true, -1);
26101
- ch = state.input.charCodeAt(state.position);
26102
- if (state.lineIndent > 0 || ch !== 37) {
26103
- break;
26104
- }
26105
- hasDirectives = true;
26106
- ch = state.input.charCodeAt(++state.position);
26107
- _position = state.position;
26108
- while (ch !== 0 && !is_WS_OR_EOL2(ch)) {
26109
- ch = state.input.charCodeAt(++state.position);
26110
- }
26111
- directiveName = state.input.slice(_position, state.position);
26112
- directiveArgs = [];
26113
- if (directiveName.length < 1) {
26114
- throwError2(state, "directive name must not be less than one character in length");
26115
- }
26116
- while (ch !== 0) {
26117
- while (is_WHITE_SPACE2(ch)) {
26118
- ch = state.input.charCodeAt(++state.position);
26119
- }
26120
- if (ch === 35) {
26121
- do {
26122
- ch = state.input.charCodeAt(++state.position);
26123
- } while (ch !== 0 && !is_EOL2(ch));
26124
- break;
26125
- }
26126
- if (is_EOL2(ch))
26127
- break;
26128
- _position = state.position;
26129
- while (ch !== 0 && !is_WS_OR_EOL2(ch)) {
26130
- ch = state.input.charCodeAt(++state.position);
26131
- }
26132
- directiveArgs.push(state.input.slice(_position, state.position));
26133
- }
26134
- if (ch !== 0)
26135
- readLineBreak2(state);
26136
- if (_hasOwnProperty$12.call(directiveHandlers2, directiveName)) {
26137
- directiveHandlers2[directiveName](state, directiveName, directiveArgs);
26138
- } else {
26139
- throwWarning2(state, 'unknown document directive "' + directiveName + '"');
26140
- }
26141
- }
26142
- skipSeparationSpace2(state, true, -1);
26143
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
26144
- state.position += 3;
26145
- skipSeparationSpace2(state, true, -1);
26146
- } else if (hasDirectives) {
26147
- throwError2(state, "directives end mark is expected");
26148
- }
26149
- composeNode2(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT2, false, true);
26150
- skipSeparationSpace2(state, true, -1);
26151
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS2.test(state.input.slice(documentStart, state.position))) {
26152
- throwWarning2(state, "non-ASCII line breaks are interpreted as content");
26153
- }
26154
- state.documents.push(state.result);
26155
- if (state.position === state.lineStart && testDocumentSeparator2(state)) {
26156
- if (state.input.charCodeAt(state.position) === 46) {
26157
- state.position += 3;
26158
- skipSeparationSpace2(state, true, -1);
26159
- }
26160
- return;
26161
- }
26162
- if (state.position < state.length - 1) {
26163
- throwError2(state, "end of the stream or a document separator is expected");
26164
- } else {
26165
- return;
26166
- }
26167
- }
26168
- function loadDocuments2(input, options) {
26169
- input = String(input);
26170
- options = options || {};
26171
- if (input.length !== 0) {
26172
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
26173
- input += `
26174
- `;
26175
- }
26176
- if (input.charCodeAt(0) === 65279) {
26177
- input = input.slice(1);
26178
- }
26179
- }
26180
- var state = new State$12(input, options);
26181
- var nullpos = input.indexOf("\x00");
26182
- if (nullpos !== -1) {
26183
- state.position = nullpos;
26184
- throwError2(state, "null byte is not allowed in input");
26185
- }
26186
- state.input += "\x00";
26187
- while (state.input.charCodeAt(state.position) === 32) {
26188
- state.lineIndent += 1;
26189
- state.position += 1;
26190
- }
26191
- while (state.position < state.length - 1) {
26192
- readDocument2(state);
26193
- }
26194
- return state.documents;
26195
- }
26196
- function loadAll$12(input, iterator, options) {
26197
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
26198
- options = iterator;
26199
- iterator = null;
26200
- }
26201
- var documents = loadDocuments2(input, options);
26202
- if (typeof iterator !== "function") {
26203
- return documents;
26204
- }
26205
- for (var index = 0, length = documents.length;index < length; index += 1) {
26206
- iterator(documents[index]);
26207
- }
26208
- }
26209
- function load$12(input, options) {
26210
- var documents = loadDocuments2(input, options);
26211
- if (documents.length === 0) {
26212
- return;
26213
- } else if (documents.length === 1) {
26214
- return documents[0];
26215
- }
26216
- throw new exception2("expected a single document in the stream, but found more");
26217
- }
26218
- var loadAll_12 = loadAll$12;
26219
- var load_12 = load$12;
26220
- var loader2 = {
26221
- loadAll: loadAll_12,
26222
- load: load_12
26223
- };
26224
- var _toString2 = Object.prototype.toString;
26225
- var _hasOwnProperty2 = Object.prototype.hasOwnProperty;
26226
- var CHAR_BOM2 = 65279;
26227
- var CHAR_TAB2 = 9;
26228
- var CHAR_LINE_FEED2 = 10;
26229
- var CHAR_CARRIAGE_RETURN2 = 13;
26230
- var CHAR_SPACE2 = 32;
26231
- var CHAR_EXCLAMATION2 = 33;
26232
- var CHAR_DOUBLE_QUOTE2 = 34;
26233
- var CHAR_SHARP2 = 35;
26234
- var CHAR_PERCENT2 = 37;
26235
- var CHAR_AMPERSAND2 = 38;
26236
- var CHAR_SINGLE_QUOTE2 = 39;
26237
- var CHAR_ASTERISK2 = 42;
26238
- var CHAR_COMMA2 = 44;
26239
- var CHAR_MINUS2 = 45;
26240
- var CHAR_COLON2 = 58;
26241
- var CHAR_EQUALS2 = 61;
26242
- var CHAR_GREATER_THAN2 = 62;
26243
- var CHAR_QUESTION2 = 63;
26244
- var CHAR_COMMERCIAL_AT2 = 64;
26245
- var CHAR_LEFT_SQUARE_BRACKET2 = 91;
26246
- var CHAR_RIGHT_SQUARE_BRACKET2 = 93;
26247
- var CHAR_GRAVE_ACCENT2 = 96;
26248
- var CHAR_LEFT_CURLY_BRACKET2 = 123;
26249
- var CHAR_VERTICAL_LINE2 = 124;
26250
- var CHAR_RIGHT_CURLY_BRACKET2 = 125;
26251
- var ESCAPE_SEQUENCES2 = {};
26252
- ESCAPE_SEQUENCES2[0] = "\\0";
26253
- ESCAPE_SEQUENCES2[7] = "\\a";
26254
- ESCAPE_SEQUENCES2[8] = "\\b";
26255
- ESCAPE_SEQUENCES2[9] = "\\t";
26256
- ESCAPE_SEQUENCES2[10] = "\\n";
26257
- ESCAPE_SEQUENCES2[11] = "\\v";
26258
- ESCAPE_SEQUENCES2[12] = "\\f";
26259
- ESCAPE_SEQUENCES2[13] = "\\r";
26260
- ESCAPE_SEQUENCES2[27] = "\\e";
26261
- ESCAPE_SEQUENCES2[34] = "\\\"";
26262
- ESCAPE_SEQUENCES2[92] = "\\\\";
26263
- ESCAPE_SEQUENCES2[133] = "\\N";
26264
- ESCAPE_SEQUENCES2[160] = "\\_";
26265
- ESCAPE_SEQUENCES2[8232] = "\\L";
26266
- ESCAPE_SEQUENCES2[8233] = "\\P";
26267
- var DEPRECATED_BOOLEANS_SYNTAX2 = [
26268
- "y",
26269
- "Y",
26270
- "yes",
26271
- "Yes",
26272
- "YES",
26273
- "on",
26274
- "On",
26275
- "ON",
26276
- "n",
26277
- "N",
26278
- "no",
26279
- "No",
26280
- "NO",
26281
- "off",
26282
- "Off",
26283
- "OFF"
26284
- ];
26285
- var DEPRECATED_BASE60_SYNTAX2 = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
26286
- function compileStyleMap2(schema3, map4) {
26287
- var result, keys, index, length, tag, style, type3;
26288
- if (map4 === null)
26289
- return {};
26290
- result = {};
26291
- keys = Object.keys(map4);
26292
- for (index = 0, length = keys.length;index < length; index += 1) {
26293
- tag = keys[index];
26294
- style = String(map4[tag]);
26295
- if (tag.slice(0, 2) === "!!") {
26296
- tag = "tag:yaml.org,2002:" + tag.slice(2);
26297
- }
26298
- type3 = schema3.compiledTypeMap["fallback"][tag];
26299
- if (type3 && _hasOwnProperty2.call(type3.styleAliases, style)) {
26300
- style = type3.styleAliases[style];
26301
- }
26302
- result[tag] = style;
26303
- }
26304
- return result;
26305
- }
26306
- function encodeHex2(character) {
26307
- var string4, handle, length;
26308
- string4 = character.toString(16).toUpperCase();
26309
- if (character <= 255) {
26310
- handle = "x";
26311
- length = 2;
26312
- } else if (character <= 65535) {
26313
- handle = "u";
26314
- length = 4;
26315
- } else if (character <= 4294967295) {
26316
- handle = "U";
26317
- length = 8;
26318
- } else {
26319
- throw new exception2("code point within a string may not be greater than 0xFFFFFFFF");
26320
- }
26321
- return "\\" + handle + common2.repeat("0", length - string4.length) + string4;
26322
- }
26323
- var QUOTING_TYPE_SINGLE2 = 1;
26324
- var QUOTING_TYPE_DOUBLE2 = 2;
26325
- function State2(options) {
26326
- this.schema = options["schema"] || _default3;
26327
- this.indent = Math.max(1, options["indent"] || 2);
26328
- this.noArrayIndent = options["noArrayIndent"] || false;
26329
- this.skipInvalid = options["skipInvalid"] || false;
26330
- this.flowLevel = common2.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
26331
- this.styleMap = compileStyleMap2(this.schema, options["styles"] || null);
26332
- this.sortKeys = options["sortKeys"] || false;
26333
- this.lineWidth = options["lineWidth"] || 80;
26334
- this.noRefs = options["noRefs"] || false;
26335
- this.noCompatMode = options["noCompatMode"] || false;
26336
- this.condenseFlow = options["condenseFlow"] || false;
26337
- this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE2 : QUOTING_TYPE_SINGLE2;
26338
- this.forceQuotes = options["forceQuotes"] || false;
26339
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
26340
- this.implicitTypes = this.schema.compiledImplicit;
26341
- this.explicitTypes = this.schema.compiledExplicit;
26342
- this.tag = null;
26343
- this.result = "";
26344
- this.duplicates = [];
26345
- this.usedDuplicates = null;
26346
- }
26347
- function indentString2(string4, spaces) {
26348
- var ind = common2.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string4.length;
26349
- while (position < length) {
26350
- next = string4.indexOf(`
26351
- `, position);
26352
- if (next === -1) {
26353
- line = string4.slice(position);
26354
- position = length;
26355
- } else {
26356
- line = string4.slice(position, next + 1);
26357
- position = next + 1;
26358
- }
26359
- if (line.length && line !== `
26360
- `)
26361
- result += ind;
26362
- result += line;
26363
- }
26364
- return result;
26365
- }
26366
- function generateNextLine2(state, level) {
26367
- return `
26368
- ` + common2.repeat(" ", state.indent * level);
26369
- }
26370
- function testImplicitResolving2(state, str3) {
26371
- var index, length, type3;
26372
- for (index = 0, length = state.implicitTypes.length;index < length; index += 1) {
26373
- type3 = state.implicitTypes[index];
26374
- if (type3.resolve(str3)) {
26375
- return true;
26376
- }
26377
- }
26378
- return false;
26379
- }
26380
- function isWhitespace2(c) {
26381
- return c === CHAR_SPACE2 || c === CHAR_TAB2;
26382
- }
26383
- function isPrintable2(c) {
26384
- return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM2 || 65536 <= c && c <= 1114111;
26385
- }
26386
- function isNsCharOrWhitespace2(c) {
26387
- return isPrintable2(c) && c !== CHAR_BOM2 && c !== CHAR_CARRIAGE_RETURN2 && c !== CHAR_LINE_FEED2;
26388
- }
26389
- function isPlainSafe2(c, prev, inblock) {
26390
- var cIsNsCharOrWhitespace = isNsCharOrWhitespace2(c);
26391
- var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace2(c);
26392
- 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;
26393
- }
26394
- function isPlainSafeFirst2(c) {
26395
- 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;
26396
- }
26397
- function isPlainSafeLast2(c) {
26398
- return !isWhitespace2(c) && c !== CHAR_COLON2;
26399
- }
26400
- function codePointAt2(string4, pos) {
26401
- var first = string4.charCodeAt(pos), second;
26402
- if (first >= 55296 && first <= 56319 && pos + 1 < string4.length) {
26403
- second = string4.charCodeAt(pos + 1);
26404
- if (second >= 56320 && second <= 57343) {
26405
- return (first - 55296) * 1024 + second - 56320 + 65536;
26406
- }
26407
- }
26408
- return first;
26409
- }
26410
- function needIndentIndicator2(string4) {
26411
- var leadingSpaceRe = /^\n* /;
26412
- return leadingSpaceRe.test(string4);
26413
- }
26414
- var STYLE_PLAIN2 = 1;
26415
- var STYLE_SINGLE2 = 2;
26416
- var STYLE_LITERAL2 = 3;
26417
- var STYLE_FOLDED2 = 4;
26418
- var STYLE_DOUBLE2 = 5;
26419
- function chooseScalarStyle2(string4, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
26420
- var i3;
26421
- var char = 0;
26422
- var prevChar = null;
26423
- var hasLineBreak = false;
26424
- var hasFoldableLine = false;
26425
- var shouldTrackWidth = lineWidth !== -1;
26426
- var previousLineBreak = -1;
26427
- var plain = isPlainSafeFirst2(codePointAt2(string4, 0)) && isPlainSafeLast2(codePointAt2(string4, string4.length - 1));
26428
- if (singleLineOnly || forceQuotes) {
26429
- for (i3 = 0;i3 < string4.length; char >= 65536 ? i3 += 2 : i3++) {
26430
- char = codePointAt2(string4, i3);
26431
- if (!isPrintable2(char)) {
26432
- return STYLE_DOUBLE2;
26433
- }
26434
- plain = plain && isPlainSafe2(char, prevChar, inblock);
26435
- prevChar = char;
26436
- }
26437
- } else {
26438
- for (i3 = 0;i3 < string4.length; char >= 65536 ? i3 += 2 : i3++) {
26439
- char = codePointAt2(string4, i3);
26440
- if (char === CHAR_LINE_FEED2) {
26441
- hasLineBreak = true;
26442
- if (shouldTrackWidth) {
26443
- hasFoldableLine = hasFoldableLine || i3 - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ";
26444
- previousLineBreak = i3;
26445
- }
26446
- } else if (!isPrintable2(char)) {
26447
- return STYLE_DOUBLE2;
26448
- }
26449
- plain = plain && isPlainSafe2(char, prevChar, inblock);
26450
- prevChar = char;
26451
- }
26452
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i3 - previousLineBreak - 1 > lineWidth && string4[previousLineBreak + 1] !== " ");
26453
- }
26454
- if (!hasLineBreak && !hasFoldableLine) {
26455
- if (plain && !forceQuotes && !testAmbiguousType(string4)) {
26456
- return STYLE_PLAIN2;
26457
- }
26458
- return quotingType === QUOTING_TYPE_DOUBLE2 ? STYLE_DOUBLE2 : STYLE_SINGLE2;
26459
- }
26460
- if (indentPerLevel > 9 && needIndentIndicator2(string4)) {
26461
- return STYLE_DOUBLE2;
26462
- }
26463
- if (!forceQuotes) {
26464
- return hasFoldableLine ? STYLE_FOLDED2 : STYLE_LITERAL2;
26465
- }
26466
- return quotingType === QUOTING_TYPE_DOUBLE2 ? STYLE_DOUBLE2 : STYLE_SINGLE2;
26467
- }
26468
- function writeScalar2(state, string4, level, iskey, inblock) {
26469
- state.dump = function() {
26470
- if (string4.length === 0) {
26471
- return state.quotingType === QUOTING_TYPE_DOUBLE2 ? '""' : "''";
26472
- }
26473
- if (!state.noCompatMode) {
26474
- if (DEPRECATED_BOOLEANS_SYNTAX2.indexOf(string4) !== -1 || DEPRECATED_BASE60_SYNTAX2.test(string4)) {
26475
- return state.quotingType === QUOTING_TYPE_DOUBLE2 ? '"' + string4 + '"' : "'" + string4 + "'";
26476
- }
26477
- }
26478
- var indent = state.indent * Math.max(1, level);
26479
- var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
26480
- var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
26481
- function testAmbiguity(string5) {
26482
- return testImplicitResolving2(state, string5);
26483
- }
26484
- switch (chooseScalarStyle2(string4, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
26485
- case STYLE_PLAIN2:
26486
- return string4;
26487
- case STYLE_SINGLE2:
26488
- return "'" + string4.replace(/'/g, "''") + "'";
26489
- case STYLE_LITERAL2:
26490
- return "|" + blockHeader2(string4, state.indent) + dropEndingNewline2(indentString2(string4, indent));
26491
- case STYLE_FOLDED2:
26492
- return ">" + blockHeader2(string4, state.indent) + dropEndingNewline2(indentString2(foldString2(string4, lineWidth), indent));
26493
- case STYLE_DOUBLE2:
26494
- return '"' + escapeString2(string4) + '"';
26495
- default:
26496
- throw new exception2("impossible error: invalid scalar style");
26497
- }
26498
- }();
26499
- }
26500
- function blockHeader2(string4, indentPerLevel) {
26501
- var indentIndicator = needIndentIndicator2(string4) ? String(indentPerLevel) : "";
26502
- var clip = string4[string4.length - 1] === `
26503
- `;
26504
- var keep = clip && (string4[string4.length - 2] === `
26505
- ` || string4 === `
26506
- `);
26507
- var chomp = keep ? "+" : clip ? "" : "-";
26508
- return indentIndicator + chomp + `
26509
- `;
26510
- }
26511
- function dropEndingNewline2(string4) {
26512
- return string4[string4.length - 1] === `
26513
- ` ? string4.slice(0, -1) : string4;
26514
- }
26515
- function foldString2(string4, width) {
26516
- var lineRe = /(\n+)([^\n]*)/g;
26517
- var result = function() {
26518
- var nextLF = string4.indexOf(`
26519
- `);
26520
- nextLF = nextLF !== -1 ? nextLF : string4.length;
26521
- lineRe.lastIndex = nextLF;
26522
- return foldLine2(string4.slice(0, nextLF), width);
26523
- }();
26524
- var prevMoreIndented = string4[0] === `
26525
- ` || string4[0] === " ";
26526
- var moreIndented;
26527
- var match;
26528
- while (match = lineRe.exec(string4)) {
26529
- var prefix = match[1], line = match[2];
26530
- moreIndented = line[0] === " ";
26531
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? `
26532
- ` : "") + foldLine2(line, width);
26533
- prevMoreIndented = moreIndented;
26534
- }
26535
- return result;
26536
- }
26537
- function foldLine2(line, width) {
26538
- if (line === "" || line[0] === " ")
26539
- return line;
26540
- var breakRe = / [^ ]/g;
26541
- var match;
26542
- var start = 0, end, curr = 0, next = 0;
26543
- var result = "";
26544
- while (match = breakRe.exec(line)) {
26545
- next = match.index;
26546
- if (next - start > width) {
26547
- end = curr > start ? curr : next;
26548
- result += `
26549
- ` + line.slice(start, end);
26550
- start = end + 1;
26551
- }
26552
- curr = next;
26553
- }
26554
- result += `
26555
- `;
26556
- if (line.length - start > width && curr > start) {
26557
- result += line.slice(start, curr) + `
26558
- ` + line.slice(curr + 1);
26559
- } else {
26560
- result += line.slice(start);
26561
- }
26562
- return result.slice(1);
26563
- }
26564
- function escapeString2(string4) {
26565
- var result = "";
26566
- var char = 0;
26567
- var escapeSeq;
26568
- for (var i3 = 0;i3 < string4.length; char >= 65536 ? i3 += 2 : i3++) {
26569
- char = codePointAt2(string4, i3);
26570
- escapeSeq = ESCAPE_SEQUENCES2[char];
26571
- if (!escapeSeq && isPrintable2(char)) {
26572
- result += string4[i3];
26573
- if (char >= 65536)
26574
- result += string4[i3 + 1];
26575
- } else {
26576
- result += escapeSeq || encodeHex2(char);
26577
- }
26578
- }
26579
- return result;
26580
- }
26581
- function writeFlowSequence2(state, level, object4) {
26582
- var _result = "", _tag = state.tag, index, length, value;
26583
- for (index = 0, length = object4.length;index < length; index += 1) {
26584
- value = object4[index];
26585
- if (state.replacer) {
26586
- value = state.replacer.call(object4, String(index), value);
26587
- }
26588
- if (writeNode2(state, level, value, false, false) || typeof value === "undefined" && writeNode2(state, level, null, false, false)) {
26589
- if (_result !== "")
26590
- _result += "," + (!state.condenseFlow ? " " : "");
26591
- _result += state.dump;
26592
- }
26593
- }
26594
- state.tag = _tag;
26595
- state.dump = "[" + _result + "]";
26596
- }
26597
- function writeBlockSequence2(state, level, object4, compact) {
26598
- var _result = "", _tag = state.tag, index, length, value;
26599
- for (index = 0, length = object4.length;index < length; index += 1) {
26600
- value = object4[index];
26601
- if (state.replacer) {
26602
- value = state.replacer.call(object4, String(index), value);
26603
- }
26604
- if (writeNode2(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode2(state, level + 1, null, true, true, false, true)) {
26605
- if (!compact || _result !== "") {
26606
- _result += generateNextLine2(state, level);
26607
- }
26608
- if (state.dump && CHAR_LINE_FEED2 === state.dump.charCodeAt(0)) {
26609
- _result += "-";
26610
- } else {
26611
- _result += "- ";
26612
- }
26613
- _result += state.dump;
26614
- }
26615
- }
26616
- state.tag = _tag;
26617
- state.dump = _result || "[]";
26618
- }
26619
- function writeFlowMapping2(state, level, object4) {
26620
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object4), index, length, objectKey, objectValue, pairBuffer;
26621
- for (index = 0, length = objectKeyList.length;index < length; index += 1) {
26622
- pairBuffer = "";
26623
- if (_result !== "")
26624
- pairBuffer += ", ";
26625
- if (state.condenseFlow)
26626
- pairBuffer += '"';
26627
- objectKey = objectKeyList[index];
26628
- objectValue = object4[objectKey];
26629
- if (state.replacer) {
26630
- objectValue = state.replacer.call(object4, objectKey, objectValue);
26631
- }
26632
- if (!writeNode2(state, level, objectKey, false, false)) {
26633
- continue;
26634
- }
26635
- if (state.dump.length > 1024)
26636
- pairBuffer += "? ";
26637
- pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
26638
- if (!writeNode2(state, level, objectValue, false, false)) {
26639
- continue;
26640
- }
26641
- pairBuffer += state.dump;
26642
- _result += pairBuffer;
26643
- }
26644
- state.tag = _tag;
26645
- state.dump = "{" + _result + "}";
26646
- }
26647
- function writeBlockMapping2(state, level, object4, compact) {
26648
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object4), index, length, objectKey, objectValue, explicitPair, pairBuffer;
26649
- if (state.sortKeys === true) {
26650
- objectKeyList.sort();
26651
- } else if (typeof state.sortKeys === "function") {
26652
- objectKeyList.sort(state.sortKeys);
26653
- } else if (state.sortKeys) {
26654
- throw new exception2("sortKeys must be a boolean or a function");
26655
- }
26656
- for (index = 0, length = objectKeyList.length;index < length; index += 1) {
26657
- pairBuffer = "";
26658
- if (!compact || _result !== "") {
26659
- pairBuffer += generateNextLine2(state, level);
26660
- }
26661
- objectKey = objectKeyList[index];
26662
- objectValue = object4[objectKey];
26663
- if (state.replacer) {
26664
- objectValue = state.replacer.call(object4, objectKey, objectValue);
26665
- }
26666
- if (!writeNode2(state, level + 1, objectKey, true, true, true)) {
26667
- continue;
26668
- }
26669
- explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
26670
- if (explicitPair) {
26671
- if (state.dump && CHAR_LINE_FEED2 === state.dump.charCodeAt(0)) {
26672
- pairBuffer += "?";
26673
- } else {
26674
- pairBuffer += "? ";
26675
- }
26676
- }
26677
- pairBuffer += state.dump;
26678
- if (explicitPair) {
26679
- pairBuffer += generateNextLine2(state, level);
26680
- }
26681
- if (!writeNode2(state, level + 1, objectValue, true, explicitPair)) {
26682
- continue;
26683
- }
26684
- if (state.dump && CHAR_LINE_FEED2 === state.dump.charCodeAt(0)) {
26685
- pairBuffer += ":";
26686
- } else {
26687
- pairBuffer += ": ";
26688
- }
26689
- pairBuffer += state.dump;
26690
- _result += pairBuffer;
26691
- }
26692
- state.tag = _tag;
26693
- state.dump = _result || "{}";
26694
- }
26695
- function detectType2(state, object4, explicit) {
26696
- var _result, typeList, index, length, type3, style;
26697
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
26698
- for (index = 0, length = typeList.length;index < length; index += 1) {
26699
- type3 = typeList[index];
26700
- if ((type3.instanceOf || type3.predicate) && (!type3.instanceOf || typeof object4 === "object" && object4 instanceof type3.instanceOf) && (!type3.predicate || type3.predicate(object4))) {
26701
- if (explicit) {
26702
- if (type3.multi && type3.representName) {
26703
- state.tag = type3.representName(object4);
26704
- } else {
26705
- state.tag = type3.tag;
26706
- }
26707
- } else {
26708
- state.tag = "?";
26709
- }
26710
- if (type3.represent) {
26711
- style = state.styleMap[type3.tag] || type3.defaultStyle;
26712
- if (_toString2.call(type3.represent) === "[object Function]") {
26713
- _result = type3.represent(object4, style);
26714
- } else if (_hasOwnProperty2.call(type3.represent, style)) {
26715
- _result = type3.represent[style](object4, style);
26716
- } else {
26717
- throw new exception2("!<" + type3.tag + '> tag resolver accepts not "' + style + '" style');
26718
- }
26719
- state.dump = _result;
26720
- }
26721
- return true;
26722
- }
26723
- }
26724
- return false;
26725
- }
26726
- function writeNode2(state, level, object4, block, compact, iskey, isblockseq) {
26727
- state.tag = null;
26728
- state.dump = object4;
26729
- if (!detectType2(state, object4, false)) {
26730
- detectType2(state, object4, true);
26731
- }
26732
- var type3 = _toString2.call(state.dump);
26733
- var inblock = block;
26734
- var tagStr;
26735
- if (block) {
26736
- block = state.flowLevel < 0 || state.flowLevel > level;
26737
- }
26738
- var objectOrArray = type3 === "[object Object]" || type3 === "[object Array]", duplicateIndex, duplicate;
26739
- if (objectOrArray) {
26740
- duplicateIndex = state.duplicates.indexOf(object4);
26741
- duplicate = duplicateIndex !== -1;
26742
- }
26743
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
26744
- compact = false;
26745
- }
26746
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
26747
- state.dump = "*ref_" + duplicateIndex;
26748
- } else {
26749
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
26750
- state.usedDuplicates[duplicateIndex] = true;
26751
- }
26752
- if (type3 === "[object Object]") {
26753
- if (block && Object.keys(state.dump).length !== 0) {
26754
- writeBlockMapping2(state, level, state.dump, compact);
26755
- if (duplicate) {
26756
- state.dump = "&ref_" + duplicateIndex + state.dump;
26757
- }
26758
- } else {
26759
- writeFlowMapping2(state, level, state.dump);
26760
- if (duplicate) {
26761
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
26762
- }
26763
- }
26764
- } else if (type3 === "[object Array]") {
26765
- if (block && state.dump.length !== 0) {
26766
- if (state.noArrayIndent && !isblockseq && level > 0) {
26767
- writeBlockSequence2(state, level - 1, state.dump, compact);
26768
- } else {
26769
- writeBlockSequence2(state, level, state.dump, compact);
26770
- }
26771
- if (duplicate) {
26772
- state.dump = "&ref_" + duplicateIndex + state.dump;
26773
- }
26774
- } else {
26775
- writeFlowSequence2(state, level, state.dump);
26776
- if (duplicate) {
26777
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
26778
- }
26779
- }
26780
- } else if (type3 === "[object String]") {
26781
- if (state.tag !== "?") {
26782
- writeScalar2(state, state.dump, level, iskey, inblock);
26783
- }
26784
- } else if (type3 === "[object Undefined]") {
26785
- return false;
26786
- } else {
26787
- if (state.skipInvalid)
26788
- return false;
26789
- throw new exception2("unacceptable kind of an object to dump " + type3);
26790
- }
26791
- if (state.tag !== null && state.tag !== "?") {
26792
- tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
26793
- if (state.tag[0] === "!") {
26794
- tagStr = "!" + tagStr;
26795
- } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
26796
- tagStr = "!!" + tagStr.slice(18);
26797
- } else {
26798
- tagStr = "!<" + tagStr + ">";
26799
- }
26800
- state.dump = tagStr + " " + state.dump;
26801
- }
26802
- }
26803
- return true;
26804
- }
26805
- function getDuplicateReferences2(object4, state) {
26806
- var objects = [], duplicatesIndexes = [], index, length;
26807
- inspectNode2(object4, objects, duplicatesIndexes);
26808
- for (index = 0, length = duplicatesIndexes.length;index < length; index += 1) {
26809
- state.duplicates.push(objects[duplicatesIndexes[index]]);
26810
- }
26811
- state.usedDuplicates = new Array(length);
26812
- }
26813
- function inspectNode2(object4, objects, duplicatesIndexes) {
26814
- var objectKeyList, index, length;
26815
- if (object4 !== null && typeof object4 === "object") {
26816
- index = objects.indexOf(object4);
26817
- if (index !== -1) {
26818
- if (duplicatesIndexes.indexOf(index) === -1) {
26819
- duplicatesIndexes.push(index);
26820
- }
26821
- } else {
26822
- objects.push(object4);
26823
- if (Array.isArray(object4)) {
26824
- for (index = 0, length = object4.length;index < length; index += 1) {
26825
- inspectNode2(object4[index], objects, duplicatesIndexes);
26826
- }
26827
- } else {
26828
- objectKeyList = Object.keys(object4);
26829
- for (index = 0, length = objectKeyList.length;index < length; index += 1) {
26830
- inspectNode2(object4[objectKeyList[index]], objects, duplicatesIndexes);
26831
- }
26832
- }
26833
- }
26834
- }
26835
- }
26836
- function dump$12(input, options) {
26837
- options = options || {};
26838
- var state = new State2(options);
26839
- if (!state.noRefs)
26840
- getDuplicateReferences2(input, state);
26841
- var value = input;
26842
- if (state.replacer) {
26843
- value = state.replacer.call({ "": value }, "", value);
26844
- }
26845
- if (writeNode2(state, 0, value, true, true))
26846
- return state.dump + `
26847
- `;
26848
- return "";
26849
- }
26850
- var dump_12 = dump$12;
26851
- var dumper2 = {
26852
- dump: dump_12
24215
+ var EMBEDDED_SQL = {
24216
+ express_version: `
24217
+ select
24218
+ name,
24219
+ setting
24220
+ from pg_settings
24221
+ where name in ('server_version', 'server_version_num');
24222
+ `,
24223
+ express_settings: `
24224
+ select
24225
+ name,
24226
+ setting,
24227
+ unit,
24228
+ category,
24229
+ context,
24230
+ vartype,
24231
+ case when (source <> 'default') then 0 else 1 end as is_default,
24232
+ case
24233
+ when unit = '8kB' then pg_size_pretty(setting::bigint * 8192)
24234
+ when unit = 'kB' then pg_size_pretty(setting::bigint * 1024)
24235
+ when unit = 'MB' then pg_size_pretty(setting::bigint * 1024 * 1024)
24236
+ when unit = 'B' then pg_size_pretty(setting::bigint)
24237
+ when unit = 'ms' then setting || ' ms'
24238
+ when unit = 's' then setting || ' s'
24239
+ when unit = 'min' then setting || ' min'
24240
+ else setting
24241
+ end as pretty_value
24242
+ from pg_settings
24243
+ order by name;
24244
+ `,
24245
+ express_altered_settings: `
24246
+ select
24247
+ name,
24248
+ setting,
24249
+ unit,
24250
+ category,
24251
+ case
24252
+ when unit = '8kB' then pg_size_pretty(setting::bigint * 8192)
24253
+ when unit = 'kB' then pg_size_pretty(setting::bigint * 1024)
24254
+ when unit = 'MB' then pg_size_pretty(setting::bigint * 1024 * 1024)
24255
+ when unit = 'B' then pg_size_pretty(setting::bigint)
24256
+ when unit = 'ms' then setting || ' ms'
24257
+ when unit = 's' then setting || ' s'
24258
+ when unit = 'min' then setting || ' min'
24259
+ else setting
24260
+ end as pretty_value
24261
+ from pg_settings
24262
+ where source <> 'default'
24263
+ order by name;
24264
+ `,
24265
+ express_database_sizes: `
24266
+ select
24267
+ datname,
24268
+ pg_database_size(datname) as size_bytes
24269
+ from pg_database
24270
+ where datistemplate = false
24271
+ order by size_bytes desc;
24272
+ `,
24273
+ express_cluster_stats: `
24274
+ select
24275
+ sum(numbackends) as total_connections,
24276
+ sum(xact_commit) as total_commits,
24277
+ sum(xact_rollback) as total_rollbacks,
24278
+ sum(blks_read) as blocks_read,
24279
+ sum(blks_hit) as blocks_hit,
24280
+ sum(tup_returned) as tuples_returned,
24281
+ sum(tup_fetched) as tuples_fetched,
24282
+ sum(tup_inserted) as tuples_inserted,
24283
+ sum(tup_updated) as tuples_updated,
24284
+ sum(tup_deleted) as tuples_deleted,
24285
+ sum(deadlocks) as total_deadlocks,
24286
+ sum(temp_files) as temp_files_created,
24287
+ sum(temp_bytes) as temp_bytes_written
24288
+ from pg_stat_database
24289
+ where datname is not null;
24290
+ `,
24291
+ express_connection_states: `
24292
+ select
24293
+ coalesce(state, 'null') as state,
24294
+ count(*) as count
24295
+ from pg_stat_activity
24296
+ group by state;
24297
+ `,
24298
+ express_uptime: `
24299
+ select
24300
+ pg_postmaster_start_time() as start_time,
24301
+ current_timestamp - pg_postmaster_start_time() as uptime;
24302
+ `,
24303
+ express_stats_reset: `
24304
+ select
24305
+ extract(epoch from stats_reset) as stats_reset_epoch,
24306
+ stats_reset::text as stats_reset_time,
24307
+ extract(day from (now() - stats_reset))::integer as days_since_reset,
24308
+ extract(epoch from pg_postmaster_start_time()) as postmaster_startup_epoch,
24309
+ pg_postmaster_start_time()::text as postmaster_startup_time
24310
+ from pg_stat_database
24311
+ where datname = current_database();
24312
+ `,
24313
+ express_current_database: `
24314
+ select
24315
+ current_database() as datname,
24316
+ pg_database_size(current_database()) as size_bytes;
24317
+ `,
24318
+ pg_invalid_indexes: `
24319
+ with fk_indexes as (
24320
+ select
24321
+ schemaname as tag_schema_name,
24322
+ (indexrelid::regclass)::text as tag_index_name,
24323
+ (relid::regclass)::text as tag_table_name,
24324
+ (confrelid::regclass)::text as tag_fk_table_ref,
24325
+ array_to_string(indclass, ', ') as tag_opclasses
24326
+ from
24327
+ pg_stat_all_indexes
24328
+ join pg_index using (indexrelid)
24329
+ left join pg_constraint
24330
+ on array_to_string(indkey, ',') = array_to_string(conkey, ',')
24331
+ and schemaname = (connamespace::regnamespace)::text
24332
+ and conrelid = relid
24333
+ and contype = 'f'
24334
+ where idx_scan = 0
24335
+ and indisunique is false
24336
+ and conkey is not null
24337
+ ), data as (
24338
+ select
24339
+ pci.relname as tag_index_name,
24340
+ pn.nspname as tag_schema_name,
24341
+ pct.relname as tag_table_name,
24342
+ quote_ident(pn.nspname) as tag_schema_name,
24343
+ quote_ident(pci.relname) as tag_index_name,
24344
+ quote_ident(pct.relname) as tag_table_name,
24345
+ coalesce(nullif(quote_ident(pn.nspname), 'public') || '.', '') || quote_ident(pct.relname) as tag_relation_name,
24346
+ pg_relation_size(pidx.indexrelid) index_size_bytes,
24347
+ ((
24348
+ select count(1)
24349
+ from fk_indexes fi
24350
+ where
24351
+ fi.tag_fk_table_ref = pct.relname
24352
+ and fi.tag_opclasses like (array_to_string(pidx.indclass, ', ') || '%')
24353
+ ) > 0)::int as supports_fk
24354
+ from pg_index pidx
24355
+ join pg_class as pci on pci.oid = pidx.indexrelid
24356
+ join pg_class as pct on pct.oid = pidx.indrelid
24357
+ left join pg_namespace pn on pn.oid = pct.relnamespace
24358
+ where pidx.indisvalid = false
24359
+ ), data_total as (
24360
+ select
24361
+ sum(index_size_bytes) as index_size_bytes_sum
24362
+ from data
24363
+ ), num_data as (
24364
+ select
24365
+ row_number() over () num,
24366
+ data.*
24367
+ from data
24368
+ )
24369
+ select
24370
+ (extract(epoch from now()) * 1e9)::int8 as epoch_ns,
24371
+ current_database() as tag_datname,
24372
+ num_data.*
24373
+ from num_data
24374
+ limit 1000;
24375
+ `,
24376
+ unused_indexes: `
24377
+ with fk_indexes as (
24378
+ select
24379
+ n.nspname as schema_name,
24380
+ ci.relname as index_name,
24381
+ cr.relname as table_name,
24382
+ (confrelid::regclass)::text as fk_table_ref,
24383
+ array_to_string(indclass, ', ') as opclasses
24384
+ from pg_index i
24385
+ join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i'
24386
+ join pg_class cr on cr.oid = i.indrelid and cr.relkind = 'r'
24387
+ join pg_namespace n on n.oid = ci.relnamespace
24388
+ join pg_constraint cn on cn.conrelid = cr.oid
24389
+ left join pg_stat_all_indexes as si on si.indexrelid = i.indexrelid
24390
+ where
24391
+ contype = 'f'
24392
+ and i.indisunique is false
24393
+ and conkey is not null
24394
+ and ci.relpages > 5
24395
+ and si.idx_scan < 10
24396
+ ), table_scans as (
24397
+ select relid,
24398
+ tables.idx_scan + tables.seq_scan as all_scans,
24399
+ ( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
24400
+ pg_relation_size(relid) as table_size
24401
+ from pg_stat_all_tables as tables
24402
+ join pg_class c on c.oid = relid
24403
+ where c.relpages > 5
24404
+ ), indexes as (
24405
+ select
24406
+ i.indrelid,
24407
+ i.indexrelid,
24408
+ n.nspname as schema_name,
24409
+ cr.relname as table_name,
24410
+ ci.relname as index_name,
24411
+ si.idx_scan,
24412
+ pg_relation_size(i.indexrelid) as index_bytes,
24413
+ ci.relpages,
24414
+ (case when a.amname = 'btree' then true else false end) as idx_is_btree,
24415
+ array_to_string(i.indclass, ', ') as opclasses
24416
+ from pg_index i
24417
+ join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i'
24418
+ join pg_class cr on cr.oid = i.indrelid and cr.relkind = 'r'
24419
+ join pg_namespace n on n.oid = ci.relnamespace
24420
+ join pg_am a on ci.relam = a.oid
24421
+ left join pg_stat_all_indexes as si on si.indexrelid = i.indexrelid
24422
+ where
24423
+ i.indisunique = false
24424
+ and i.indisvalid = true
24425
+ and ci.relpages > 5
24426
+ ), index_ratios as (
24427
+ select
24428
+ i.indexrelid as index_id,
24429
+ i.schema_name,
24430
+ i.table_name,
24431
+ i.index_name,
24432
+ idx_scan,
24433
+ all_scans,
24434
+ round(( case when all_scans = 0 then 0.0::numeric
24435
+ else idx_scan::numeric/all_scans * 100 end), 2) as index_scan_pct,
24436
+ writes,
24437
+ round((case when writes = 0 then idx_scan::numeric else idx_scan::numeric/writes end), 2)
24438
+ as scans_per_write,
24439
+ index_bytes as index_size_bytes,
24440
+ table_size as table_size_bytes,
24441
+ i.relpages,
24442
+ idx_is_btree,
24443
+ i.opclasses,
24444
+ (
24445
+ select count(1)
24446
+ from fk_indexes fi
24447
+ where fi.fk_table_ref = i.table_name
24448
+ and fi.schema_name = i.schema_name
24449
+ and fi.opclasses like (i.opclasses || '%')
24450
+ ) > 0 as supports_fk
24451
+ from indexes i
24452
+ join table_scans ts on ts.relid = i.indrelid
24453
+ )
24454
+ select
24455
+ 'Never Used Indexes' as tag_reason,
24456
+ current_database() as tag_datname,
24457
+ index_id,
24458
+ schema_name as tag_schema_name,
24459
+ table_name as tag_table_name,
24460
+ index_name as tag_index_name,
24461
+ pg_get_indexdef(index_id) as index_definition,
24462
+ idx_scan,
24463
+ all_scans,
24464
+ index_scan_pct,
24465
+ writes,
24466
+ scans_per_write,
24467
+ index_size_bytes,
24468
+ table_size_bytes,
24469
+ relpages,
24470
+ idx_is_btree,
24471
+ opclasses as tag_opclasses,
24472
+ supports_fk
24473
+ from index_ratios
24474
+ where
24475
+ idx_scan = 0
24476
+ and idx_is_btree
24477
+ order by index_size_bytes desc
24478
+ limit 1000;
24479
+ `,
24480
+ redundant_indexes: `
24481
+ with fk_indexes as (
24482
+ select
24483
+ n.nspname as schema_name,
24484
+ ci.relname as index_name,
24485
+ cr.relname as table_name,
24486
+ (confrelid::regclass)::text as fk_table_ref,
24487
+ array_to_string(indclass, ', ') as opclasses
24488
+ from pg_index i
24489
+ join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i'
24490
+ join pg_class cr on cr.oid = i.indrelid and cr.relkind = 'r'
24491
+ join pg_namespace n on n.oid = ci.relnamespace
24492
+ join pg_constraint cn on cn.conrelid = cr.oid
24493
+ left join pg_stat_all_indexes as si on si.indexrelid = i.indexrelid
24494
+ where
24495
+ contype = 'f'
24496
+ and i.indisunique is false
24497
+ and conkey is not null
24498
+ and ci.relpages > 5
24499
+ and si.idx_scan < 10
24500
+ ),
24501
+ index_data as (
24502
+ select
24503
+ *,
24504
+ indkey::text as columns,
24505
+ array_to_string(indclass, ', ') as opclasses
24506
+ from pg_index i
24507
+ join pg_class ci on ci.oid = i.indexrelid and ci.relkind = 'i'
24508
+ where indisvalid = true and ci.relpages > 5
24509
+ ), redundant_indexes as (
24510
+ select
24511
+ i2.indexrelid as index_id,
24512
+ tnsp.nspname as schema_name,
24513
+ trel.relname as table_name,
24514
+ pg_relation_size(trel.oid) as table_size_bytes,
24515
+ irel.relname as index_name,
24516
+ am1.amname as access_method,
24517
+ (i1.indexrelid::regclass)::text as reason,
24518
+ i1.indexrelid as reason_index_id,
24519
+ pg_get_indexdef(i1.indexrelid) main_index_def,
24520
+ pg_size_pretty(pg_relation_size(i1.indexrelid)) main_index_size,
24521
+ pg_get_indexdef(i2.indexrelid) index_def,
24522
+ pg_relation_size(i2.indexrelid) index_size_bytes,
24523
+ s.idx_scan as index_usage,
24524
+ quote_ident(tnsp.nspname) as formated_schema_name,
24525
+ coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(irel.relname) as formated_index_name,
24526
+ quote_ident(trel.relname) as formated_table_name,
24527
+ coalesce(nullif(quote_ident(tnsp.nspname), 'public') || '.', '') || quote_ident(trel.relname) as formated_relation_name,
24528
+ i2.opclasses
24529
+ from (
24530
+ select indrelid, indexrelid, opclasses, indclass, indexprs, indpred, indisprimary, indisunique, columns
24531
+ from index_data
24532
+ order by indexrelid
24533
+ ) as i1
24534
+ join index_data as i2 on (
24535
+ i1.indrelid = i2.indrelid
24536
+ and i1.indexrelid <> i2.indexrelid
24537
+ )
24538
+ inner join pg_opclass op1 on i1.indclass[0] = op1.oid
24539
+ inner join pg_opclass op2 on i2.indclass[0] = op2.oid
24540
+ inner join pg_am am1 on op1.opcmethod = am1.oid
24541
+ inner join pg_am am2 on op2.opcmethod = am2.oid
24542
+ join pg_stat_all_indexes as s on s.indexrelid = i2.indexrelid
24543
+ join pg_class as trel on trel.oid = i2.indrelid
24544
+ join pg_namespace as tnsp on trel.relnamespace = tnsp.oid
24545
+ join pg_class as irel on irel.oid = i2.indexrelid
24546
+ where
24547
+ not i2.indisprimary
24548
+ and not i2.indisunique
24549
+ and am1.amname = am2.amname
24550
+ and i1.columns like (i2.columns || '%')
24551
+ and i1.opclasses like (i2.opclasses || '%')
24552
+ and pg_get_expr(i1.indexprs, i1.indrelid) is not distinct from pg_get_expr(i2.indexprs, i2.indrelid)
24553
+ and pg_get_expr(i1.indpred, i1.indrelid) is not distinct from pg_get_expr(i2.indpred, i2.indrelid)
24554
+ ), redundant_indexes_fk as (
24555
+ select
24556
+ ri.*,
24557
+ ((
24558
+ select count(1)
24559
+ from fk_indexes fi
24560
+ where
24561
+ fi.fk_table_ref = ri.table_name
24562
+ and fi.opclasses like (ri.opclasses || '%')
24563
+ ) > 0)::int as supports_fk
24564
+ from redundant_indexes ri
24565
+ ),
24566
+ redundant_indexes_tmp_num as (
24567
+ select row_number() over () num, rig.*
24568
+ from redundant_indexes_fk rig
24569
+ ), redundant_indexes_tmp_links as (
24570
+ select
24571
+ ri1.*,
24572
+ ri2.num as r_num
24573
+ from redundant_indexes_tmp_num ri1
24574
+ left join redundant_indexes_tmp_num ri2 on ri2.reason_index_id = ri1.index_id and ri1.reason_index_id = ri2.index_id
24575
+ ), redundant_indexes_tmp_cut as (
24576
+ select
24577
+ *
24578
+ from redundant_indexes_tmp_links
24579
+ where num < r_num or r_num is null
24580
+ ), redundant_indexes_cut_grouped as (
24581
+ select
24582
+ distinct(num),
24583
+ *
24584
+ from redundant_indexes_tmp_cut
24585
+ order by index_size_bytes desc
24586
+ ), redundant_indexes_grouped as (
24587
+ select
24588
+ index_id,
24589
+ schema_name as tag_schema_name,
24590
+ table_name,
24591
+ table_size_bytes,
24592
+ index_name as tag_index_name,
24593
+ access_method as tag_access_method,
24594
+ string_agg(distinct reason, ', ') as tag_reason,
24595
+ index_size_bytes,
24596
+ index_usage,
24597
+ index_def as index_definition,
24598
+ formated_index_name as tag_index_name,
24599
+ formated_schema_name as tag_schema_name,
24600
+ formated_table_name as tag_table_name,
24601
+ formated_relation_name as tag_relation_name,
24602
+ supports_fk::int as supports_fk
24603
+ from redundant_indexes_cut_grouped
24604
+ group by
24605
+ index_id,
24606
+ table_size_bytes,
24607
+ schema_name,
24608
+ table_name,
24609
+ index_name,
24610
+ access_method,
24611
+ index_def,
24612
+ index_size_bytes,
24613
+ index_usage,
24614
+ formated_index_name,
24615
+ formated_schema_name,
24616
+ formated_table_name,
24617
+ formated_relation_name,
24618
+ supports_fk
24619
+ order by index_size_bytes desc
24620
+ )
24621
+ select * from redundant_indexes_grouped
24622
+ limit 1000;
24623
+ `
26853
24624
  };
26854
- function renamed2(from, to) {
26855
- return function() {
26856
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. " + "Use yaml." + to + " instead, which is now safe by default.");
26857
- };
26858
- }
26859
- var load2 = loader2.load;
26860
- var loadAll2 = loader2.loadAll;
26861
- var dump2 = dumper2.dump;
26862
- var safeLoad2 = renamed2("safeLoad", "load");
26863
- var safeLoadAll2 = renamed2("safeLoadAll", "loadAll");
26864
- var safeDump2 = renamed2("safeDump", "dump");
26865
-
26866
- // lib/metrics-loader.ts
26867
- var __dirname = "/builds/postgres-ai/postgres_ai/cli/lib";
26868
- function getMetricsYmlPath() {
26869
- const currentDir = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
26870
- const possiblePaths = [
26871
- resolve4(currentDir, "../../config/pgwatch-prometheus/metrics.yml"),
26872
- resolve4(currentDir, "../../../config/pgwatch-prometheus/metrics.yml"),
26873
- resolve4(currentDir, "../../../../config/pgwatch-prometheus/metrics.yml")
26874
- ];
26875
- for (const path4 of possiblePaths) {
26876
- try {
26877
- readFileSync4(path4);
26878
- return path4;
26879
- } catch {}
26880
- }
26881
- throw new Error(`Cannot find metrics.yml. Tried: ${possiblePaths.join(", ")}`);
26882
- }
26883
- var cachedMetrics = null;
26884
- function loadMetricsYml() {
26885
- if (cachedMetrics) {
26886
- return cachedMetrics;
26887
- }
26888
- const metricsPath = getMetricsYmlPath();
26889
- const content = readFileSync4(metricsPath, "utf8");
26890
- cachedMetrics = load2(content);
26891
- return cachedMetrics;
26892
- }
26893
- function getMetricSql(metricName, pgMajorVersion = 16) {
26894
- const root = loadMetricsYml();
26895
- const metric = root.metrics[metricName];
26896
- if (!metric) {
26897
- throw new Error(`Metric "${metricName}" not found in metrics.yml`);
26898
- }
26899
- if (!metric.sqls) {
26900
- throw new Error(`Metric "${metricName}" has no SQL queries defined`);
24625
+ function getMetricSql(metricName, _pgMajorVersion = 16) {
24626
+ const sql = EMBEDDED_SQL[metricName];
24627
+ if (!sql) {
24628
+ throw new Error(`Metric "${metricName}" not found. Available metrics: ${Object.keys(EMBEDDED_SQL).join(", ")}`);
26901
24629
  }
26902
- const versions2 = Object.keys(metric.sqls).map(Number).filter((v) => !isNaN(v)).sort((a, b) => b - a);
26903
- for (const version3 of versions2) {
26904
- if (version3 <= pgMajorVersion) {
26905
- return metric.sqls[version3.toString()];
26906
- }
26907
- }
26908
- const lowestVersion = versions2[versions2.length - 1];
26909
- if (lowestVersion !== undefined) {
26910
- return metric.sqls[lowestVersion.toString()];
26911
- }
26912
- throw new Error(`No SQL query found for metric "${metricName}"`);
24630
+ return sql;
26913
24631
  }
26914
24632
  var METRIC_NAMES = {
26915
24633
  H001: "pg_invalid_indexes",
@@ -26957,8 +24675,8 @@ function formatBytes(bytes) {
26957
24675
  if (bytes === 0)
26958
24676
  return "0 B";
26959
24677
  const units = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
26960
- const i3 = Math.floor(Math.log(bytes) / Math.log(1024));
26961
- return `${(bytes / Math.pow(1024, i3)).toFixed(2)} ${units[i3]}`;
24678
+ const i2 = Math.floor(Math.log(bytes) / Math.log(1024));
24679
+ return `${(bytes / Math.pow(1024, i2)).toFixed(2)} ${units[i2]}`;
26962
24680
  }
26963
24681
  async function getPostgresVersion(client) {
26964
24682
  const sql = getMetricSql(METRIC_NAMES.version);
@@ -27375,12 +25093,216 @@ async function generateH004(client, nodeName = "node-01") {
27375
25093
  };
27376
25094
  return report;
27377
25095
  }
25096
+ async function generateD004(client, nodeName) {
25097
+ const report = createBaseReport("D004", "pg_stat_statements and pg_stat_kcache settings", nodeName);
25098
+ const postgresVersion = await getPostgresVersion(client);
25099
+ const allSettings = await getSettings(client);
25100
+ const pgssSettings = {};
25101
+ for (const [name, setting] of Object.entries(allSettings)) {
25102
+ if (name.startsWith("pg_stat_statements") || name.startsWith("pg_stat_kcache")) {
25103
+ pgssSettings[name] = setting;
25104
+ }
25105
+ }
25106
+ let pgssAvailable = false;
25107
+ let pgssMetricsCount = 0;
25108
+ let pgssTotalCalls = 0;
25109
+ const pgssSampleQueries = [];
25110
+ try {
25111
+ const extCheck = await client.query("select 1 from pg_extension where extname = 'pg_stat_statements'");
25112
+ if (extCheck.rows.length > 0) {
25113
+ pgssAvailable = true;
25114
+ const statsResult = await client.query(`
25115
+ select count(*) as cnt, coalesce(sum(calls), 0) as total_calls
25116
+ from pg_stat_statements
25117
+ `);
25118
+ pgssMetricsCount = parseInt(statsResult.rows[0]?.cnt || "0", 10);
25119
+ pgssTotalCalls = parseInt(statsResult.rows[0]?.total_calls || "0", 10);
25120
+ const sampleResult = await client.query(`
25121
+ select
25122
+ queryid::text as queryid,
25123
+ coalesce(usename, 'unknown') as "user",
25124
+ coalesce(datname, 'unknown') as database,
25125
+ calls
25126
+ from pg_stat_statements s
25127
+ left join pg_database d on s.dbid = d.oid
25128
+ left join pg_user u on s.userid = u.usesysid
25129
+ order by calls desc
25130
+ limit 5
25131
+ `);
25132
+ for (const row of sampleResult.rows) {
25133
+ pgssSampleQueries.push({
25134
+ queryid: row.queryid,
25135
+ user: row.user,
25136
+ database: row.database,
25137
+ calls: parseInt(row.calls, 10)
25138
+ });
25139
+ }
25140
+ }
25141
+ } catch {}
25142
+ let kcacheAvailable = false;
25143
+ let kcacheMetricsCount = 0;
25144
+ let kcacheTotalExecTime = 0;
25145
+ let kcacheTotalUserTime = 0;
25146
+ let kcacheTotalSystemTime = 0;
25147
+ const kcacheSampleQueries = [];
25148
+ try {
25149
+ const extCheck = await client.query("select 1 from pg_extension where extname = 'pg_stat_kcache'");
25150
+ if (extCheck.rows.length > 0) {
25151
+ kcacheAvailable = true;
25152
+ const statsResult = await client.query(`
25153
+ select
25154
+ count(*) as cnt,
25155
+ coalesce(sum(exec_user_time + exec_system_time), 0) as total_exec_time,
25156
+ coalesce(sum(exec_user_time), 0) as total_user_time,
25157
+ coalesce(sum(exec_system_time), 0) as total_system_time
25158
+ from pg_stat_kcache
25159
+ `);
25160
+ kcacheMetricsCount = parseInt(statsResult.rows[0]?.cnt || "0", 10);
25161
+ kcacheTotalExecTime = parseFloat(statsResult.rows[0]?.total_exec_time || "0");
25162
+ kcacheTotalUserTime = parseFloat(statsResult.rows[0]?.total_user_time || "0");
25163
+ kcacheTotalSystemTime = parseFloat(statsResult.rows[0]?.total_system_time || "0");
25164
+ const sampleResult = await client.query(`
25165
+ select
25166
+ queryid::text as queryid,
25167
+ coalesce(usename, 'unknown') as "user",
25168
+ (exec_user_time + exec_system_time) as exec_total_time
25169
+ from pg_stat_kcache k
25170
+ left join pg_user u on k.userid = u.usesysid
25171
+ order by (exec_user_time + exec_system_time) desc
25172
+ limit 5
25173
+ `);
25174
+ for (const row of sampleResult.rows) {
25175
+ kcacheSampleQueries.push({
25176
+ queryid: row.queryid,
25177
+ user: row.user,
25178
+ exec_total_time: parseFloat(row.exec_total_time)
25179
+ });
25180
+ }
25181
+ }
25182
+ } catch {}
25183
+ report.results[nodeName] = {
25184
+ data: {
25185
+ settings: pgssSettings,
25186
+ pg_stat_statements_status: {
25187
+ extension_available: pgssAvailable,
25188
+ metrics_count: pgssMetricsCount,
25189
+ total_calls: pgssTotalCalls,
25190
+ sample_queries: pgssSampleQueries
25191
+ },
25192
+ pg_stat_kcache_status: {
25193
+ extension_available: kcacheAvailable,
25194
+ metrics_count: kcacheMetricsCount,
25195
+ total_exec_time: kcacheTotalExecTime,
25196
+ total_user_time: kcacheTotalUserTime,
25197
+ total_system_time: kcacheTotalSystemTime,
25198
+ sample_queries: kcacheSampleQueries
25199
+ }
25200
+ },
25201
+ postgres_version: postgresVersion
25202
+ };
25203
+ return report;
25204
+ }
25205
+ async function generateF001(client, nodeName) {
25206
+ const report = createBaseReport("F001", "Autovacuum: current settings", nodeName);
25207
+ const postgresVersion = await getPostgresVersion(client);
25208
+ const allSettings = await getSettings(client);
25209
+ const autovacuumSettings = {};
25210
+ for (const [name, setting] of Object.entries(allSettings)) {
25211
+ if (name.includes("autovacuum") || name.includes("vacuum")) {
25212
+ autovacuumSettings[name] = setting;
25213
+ }
25214
+ }
25215
+ report.results[nodeName] = {
25216
+ data: autovacuumSettings,
25217
+ postgres_version: postgresVersion
25218
+ };
25219
+ return report;
25220
+ }
25221
+ async function generateG001(client, nodeName) {
25222
+ const report = createBaseReport("G001", "Memory-related settings", nodeName);
25223
+ const postgresVersion = await getPostgresVersion(client);
25224
+ const allSettings = await getSettings(client);
25225
+ const memorySettingNames = [
25226
+ "shared_buffers",
25227
+ "work_mem",
25228
+ "maintenance_work_mem",
25229
+ "effective_cache_size",
25230
+ "wal_buffers",
25231
+ "temp_buffers",
25232
+ "max_connections",
25233
+ "autovacuum_work_mem",
25234
+ "hash_mem_multiplier",
25235
+ "logical_decoding_work_mem",
25236
+ "max_stack_depth",
25237
+ "max_prepared_transactions",
25238
+ "max_locks_per_transaction",
25239
+ "max_pred_locks_per_transaction"
25240
+ ];
25241
+ const memorySettings = {};
25242
+ for (const name of memorySettingNames) {
25243
+ if (allSettings[name]) {
25244
+ memorySettings[name] = allSettings[name];
25245
+ }
25246
+ }
25247
+ let memoryUsage = {};
25248
+ try {
25249
+ const memQuery = await client.query(`
25250
+ select
25251
+ pg_size_bytes(current_setting('shared_buffers')) as shared_buffers_bytes,
25252
+ pg_size_bytes(current_setting('wal_buffers')) as wal_buffers_bytes,
25253
+ pg_size_bytes(current_setting('work_mem')) as work_mem_bytes,
25254
+ pg_size_bytes(current_setting('maintenance_work_mem')) as maintenance_work_mem_bytes,
25255
+ pg_size_bytes(current_setting('effective_cache_size')) as effective_cache_size_bytes,
25256
+ current_setting('max_connections')::int as max_connections
25257
+ `);
25258
+ if (memQuery.rows.length > 0) {
25259
+ const row = memQuery.rows[0];
25260
+ const sharedBuffersBytes = parseInt(row.shared_buffers_bytes, 10);
25261
+ const walBuffersBytes = parseInt(row.wal_buffers_bytes, 10);
25262
+ const workMemBytes = parseInt(row.work_mem_bytes, 10);
25263
+ const maintenanceWorkMemBytes = parseInt(row.maintenance_work_mem_bytes, 10);
25264
+ const effectiveCacheSizeBytes = parseInt(row.effective_cache_size_bytes, 10);
25265
+ const maxConnections = row.max_connections;
25266
+ const sharedMemoryTotal = sharedBuffersBytes + walBuffersBytes;
25267
+ const maxWorkMemUsage = workMemBytes * maxConnections;
25268
+ memoryUsage = {
25269
+ shared_buffers_bytes: sharedBuffersBytes,
25270
+ shared_buffers_pretty: formatBytes(sharedBuffersBytes),
25271
+ wal_buffers_bytes: walBuffersBytes,
25272
+ wal_buffers_pretty: formatBytes(walBuffersBytes),
25273
+ shared_memory_total_bytes: sharedMemoryTotal,
25274
+ shared_memory_total_pretty: formatBytes(sharedMemoryTotal),
25275
+ work_mem_per_connection_bytes: workMemBytes,
25276
+ work_mem_per_connection_pretty: formatBytes(workMemBytes),
25277
+ max_work_mem_usage_bytes: maxWorkMemUsage,
25278
+ max_work_mem_usage_pretty: formatBytes(maxWorkMemUsage),
25279
+ maintenance_work_mem_bytes: maintenanceWorkMemBytes,
25280
+ maintenance_work_mem_pretty: formatBytes(maintenanceWorkMemBytes),
25281
+ effective_cache_size_bytes: effectiveCacheSizeBytes,
25282
+ effective_cache_size_pretty: formatBytes(effectiveCacheSizeBytes)
25283
+ };
25284
+ }
25285
+ } catch {}
25286
+ report.results[nodeName] = {
25287
+ data: {
25288
+ settings: memorySettings,
25289
+ analysis: {
25290
+ estimated_total_memory_usage: memoryUsage
25291
+ }
25292
+ },
25293
+ postgres_version: postgresVersion
25294
+ };
25295
+ return report;
25296
+ }
27378
25297
  var REPORT_GENERATORS = {
27379
25298
  A002: generateA002,
27380
25299
  A003: generateA003,
27381
25300
  A004: generateA004,
27382
25301
  A007: generateA007,
27383
25302
  A013: generateA013,
25303
+ D004: generateD004,
25304
+ F001: generateF001,
25305
+ G001: generateG001,
27384
25306
  H001: generateH001,
27385
25307
  H002: generateH002,
27386
25308
  H004: generateH004
@@ -27391,6 +25313,9 @@ var CHECK_INFO = {
27391
25313
  A004: "Cluster information",
27392
25314
  A007: "Altered settings",
27393
25315
  A013: "Postgres minor version",
25316
+ D004: "pg_stat_statements and pg_stat_kcache settings",
25317
+ F001: "Autovacuum: current settings",
25318
+ G001: "Memory-related settings",
27394
25319
  H001: "Invalid indexes",
27395
25320
  H002: "Unused indexes",
27396
25321
  H004: "Redundant indexes"
@@ -27477,7 +25402,7 @@ async function postRpc(params) {
27477
25402
  "Content-Type": "application/json",
27478
25403
  "Content-Length": Buffer.byteLength(body).toString()
27479
25404
  };
27480
- return new Promise((resolve6, reject) => {
25405
+ return new Promise((resolve5, reject) => {
27481
25406
  const req = https.request(url, {
27482
25407
  method: "POST",
27483
25408
  headers
@@ -27488,7 +25413,7 @@ async function postRpc(params) {
27488
25413
  if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
27489
25414
  try {
27490
25415
  const parsed = JSON.parse(data);
27491
- resolve6(unwrapRpcResponse(parsed));
25416
+ resolve5(unwrapRpcResponse(parsed));
27492
25417
  } catch {
27493
25418
  reject(new Error(`Failed to parse RPC response: ${data}`));
27494
25419
  }
@@ -27570,27 +25495,27 @@ function closeReadline() {
27570
25495
  }
27571
25496
  }
27572
25497
  async function execPromise(command) {
27573
- return new Promise((resolve7, reject) => {
25498
+ return new Promise((resolve6, reject) => {
27574
25499
  childProcess.exec(command, (error2, stdout, stderr) => {
27575
25500
  if (error2) {
27576
25501
  const err = error2;
27577
25502
  err.code = error2.code ?? 1;
27578
25503
  reject(err);
27579
25504
  } else {
27580
- resolve7({ stdout, stderr });
25505
+ resolve6({ stdout, stderr });
27581
25506
  }
27582
25507
  });
27583
25508
  });
27584
25509
  }
27585
25510
  async function execFilePromise(file, args) {
27586
- return new Promise((resolve7, reject) => {
25511
+ return new Promise((resolve6, reject) => {
27587
25512
  childProcess.execFile(file, args, (error2, stdout, stderr) => {
27588
25513
  if (error2) {
27589
25514
  const err = error2;
27590
25515
  err.code = error2.code ?? 1;
27591
25516
  reject(err);
27592
25517
  } else {
27593
- resolve7({ stdout, stderr });
25518
+ resolve6({ stdout, stderr });
27594
25519
  }
27595
25520
  });
27596
25521
  });
@@ -27631,9 +25556,9 @@ function spawn2(cmd, args, options) {
27631
25556
  };
27632
25557
  }
27633
25558
  async function question(prompt) {
27634
- return new Promise((resolve7) => {
25559
+ return new Promise((resolve6) => {
27635
25560
  getReadline().question(prompt, (answer) => {
27636
- resolve7(answer);
25561
+ resolve6(answer);
27637
25562
  });
27638
25563
  });
27639
25564
  }
@@ -27767,14 +25692,14 @@ function getConfig(opts) {
27767
25692
  }
27768
25693
  return { apiKey };
27769
25694
  }
27770
- function printResult(result, json3) {
25695
+ function printResult(result, json2) {
27771
25696
  if (typeof result === "string") {
27772
25697
  process.stdout.write(result);
27773
25698
  if (!/\n$/.test(result))
27774
25699
  console.log();
27775
25700
  return;
27776
25701
  }
27777
- if (json3 || !process.stdout.isTTY) {
25702
+ if (json2 || !process.stdout.isTTY) {
27778
25703
  console.log(JSON.stringify(result, null, 2));
27779
25704
  } else {
27780
25705
  let text = dump(result);
@@ -28346,13 +26271,13 @@ async function runCompose(args) {
28346
26271
  }
28347
26272
  } catch (err) {}
28348
26273
  }
28349
- return new Promise((resolve7) => {
26274
+ return new Promise((resolve6) => {
28350
26275
  const child = spawn2(cmd[0], [...cmd.slice(1), "-f", composeFile, ...args], {
28351
26276
  stdio: "inherit",
28352
26277
  env,
28353
26278
  cwd: projectDir
28354
26279
  });
28355
- child.on("close", (code) => resolve7(code || 0));
26280
+ child.on("close", (code) => resolve6(code || 0));
28356
26281
  });
28357
26282
  }
28358
26283
  program2.command("help", { isDefault: true }).description("show help").action(() => {
@@ -28742,7 +26667,7 @@ mon.command("health").description("health check for monitoring services").option
28742
26667
  if (attempt > 1) {
28743
26668
  console.log(`Retrying (attempt ${attempt}/${maxAttempts})...
28744
26669
  `);
28745
- await new Promise((resolve7) => setTimeout(resolve7, 5000));
26670
+ await new Promise((resolve6) => setTimeout(resolve6, 5000));
28746
26671
  }
28747
26672
  allHealthy = true;
28748
26673
  for (const service of services) {
@@ -29127,7 +27052,7 @@ auth.command("login", { isDefault: true }).description("authenticate via browser
29127
27052
  console.log("Starting local callback server...");
29128
27053
  const requestedPort = opts.port || 0;
29129
27054
  const callbackServer = createCallbackServer(requestedPort, params.state, 120000);
29130
- await new Promise((resolve7) => setTimeout(resolve7, 100));
27055
+ await new Promise((resolve6) => setTimeout(resolve6, 100));
29131
27056
  const actualPort = callbackServer.getPort();
29132
27057
  const redirectUri = `http://localhost:${actualPort}/callback`;
29133
27058
  console.log(`Callback server listening on port ${actualPort}`);
@@ -29411,8 +27336,8 @@ Grafana credentials:`);
29411
27336
  console.log(` Password: ${password}`);
29412
27337
  console.log("");
29413
27338
  });
29414
- function interpretEscapes(str3) {
29415
- return str3.replace(/\\\\/g, "\x00").replace(/\\n/g, `
27339
+ function interpretEscapes(str2) {
27340
+ return str2.replace(/\\\\/g, "\x00").replace(/\\n/g, `
29416
27341
  `).replace(/\\t/g, "\t").replace(/\\r/g, "\r").replace(/\\"/g, '"').replace(/\\'/g, "'").replace(/\x00/g, "\\");
29417
27342
  }
29418
27343
  var issues = program2.command("issues").description("issues management");