langwatch 1.20.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agent/index.js +19 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/index.mjs +19 -2
- package/dist/agent/index.mjs.map +1 -1
- package/dist/{chunk-ET5KYCG2.mjs → chunk-2GKEMCKT.mjs} +1 -1
- package/dist/chunk-2GKEMCKT.mjs.map +1 -0
- package/dist/{chunk-BDQ2RG7R.mjs → chunk-AYPQNLCC.mjs} +2 -2
- package/dist/{chunk-EQ5CFQGJ.js → chunk-DLZCOUXC.js} +12 -12
- package/dist/{chunk-EQ5CFQGJ.js.map → chunk-DLZCOUXC.js.map} +1 -1
- package/dist/{chunk-5ZNEXSAB.js → chunk-F7BVJW3S.js} +1 -1
- package/dist/chunk-F7BVJW3S.js.map +1 -0
- package/dist/{chunk-FKYYEGJ7.mjs → chunk-M3DSPR5S.mjs} +6 -2
- package/dist/chunk-M3DSPR5S.mjs.map +1 -0
- package/dist/{chunk-HCK7TCSK.js → chunk-MAO3SIBB.js} +7 -3
- package/dist/chunk-MAO3SIBB.js.map +1 -0
- package/dist/cli/bundle.js +523 -505
- package/dist/{implementation-B4Z2ksnA.d.mts → implementation-BXVPzwOt.d.mts} +1 -1
- package/dist/{implementation-BFUgzz5C.d.ts → implementation-DJ-JveZl.d.ts} +1 -1
- package/dist/index.d.mts +84 -10
- package/dist/index.d.ts +84 -10
- package/dist/index.js +979 -632
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +907 -560
- package/dist/index.mjs.map +1 -1
- package/dist/observability-sdk/index.d.mts +3 -3
- package/dist/observability-sdk/index.d.ts +3 -3
- package/dist/observability-sdk/index.js +4 -4
- package/dist/observability-sdk/index.js.map +1 -1
- package/dist/observability-sdk/index.mjs +8 -8
- package/dist/observability-sdk/instrumentation/langchain/index.d.mts +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.d.ts +1 -1
- package/dist/observability-sdk/instrumentation/langchain/index.js +4 -4
- package/dist/observability-sdk/instrumentation/langchain/index.mjs +1 -1
- package/dist/observability-sdk/setup/node/index.js +3 -3
- package/dist/observability-sdk/setup/node/index.mjs +2 -2
- package/dist/{types-B696jWYQ.d.mts → types--ExXvd26.d.mts} +911 -338
- package/dist/{types-Bo6OvFct.d.ts → types-CpT3iEIj.d.ts} +911 -338
- package/package.json +3 -4
- package/dist/chunk-5ZNEXSAB.js.map +0 -1
- package/dist/chunk-ET5KYCG2.mjs.map +0 -1
- package/dist/chunk-FKYYEGJ7.mjs.map +0 -1
- package/dist/chunk-HCK7TCSK.js.map +0 -1
- /package/dist/{chunk-BDQ2RG7R.mjs.map → chunk-AYPQNLCC.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -4,12 +4,11 @@ var _chunkWDUUAIG3js = require('./chunk-WDUUAIG3.js');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
var _chunkDLZCOUXCjs = require('./chunk-DLZCOUXC.js');
|
|
7
8
|
|
|
8
|
-
var _chunk5ZNEXSABjs = require('./chunk-5ZNEXSAB.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _chunkEQ5CFQGJjs = require('./chunk-EQ5CFQGJ.js');
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
|
|
@@ -17,10 +16,13 @@ var _chunkEQ5CFQGJjs = require('./chunk-EQ5CFQGJ.js');
|
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
|
|
19
|
+
var _chunkMAO3SIBBjs = require('./chunk-MAO3SIBB.js');
|
|
20
|
+
require('./chunk-BL3GHEKF.js');
|
|
21
|
+
|
|
20
22
|
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
require('./chunk-
|
|
24
|
+
|
|
25
|
+
var _chunkF7BVJW3Sjs = require('./chunk-F7BVJW3S.js');
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
|
|
@@ -674,11 +676,10 @@ var chalk = createChalk();
|
|
|
674
676
|
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
675
677
|
var source_default = chalk;
|
|
676
678
|
|
|
677
|
-
// ../../node_modules/.pnpm/js-yaml@5.
|
|
679
|
+
// ../../node_modules/.pnpm/js-yaml@5.4.3/node_modules/js-yaml/dist/js-yaml.mjs
|
|
678
680
|
var NOT_RESOLVED = /* @__PURE__ */ Symbol("NOT_RESOLVED");
|
|
679
|
-
var MERGE_KEY = /* @__PURE__ */ Symbol("MERGE_KEY");
|
|
680
681
|
function defineScalarTag(tagName, options) {
|
|
681
|
-
var _a, _b, _c, _d, _e
|
|
682
|
+
var _a, _b, _c, _d, _e;
|
|
682
683
|
return {
|
|
683
684
|
tagName,
|
|
684
685
|
nodeKind: "scalar",
|
|
@@ -686,13 +687,13 @@ function defineScalarTag(tagName, options) {
|
|
|
686
687
|
matchByTagPrefix: (_b = options.matchByTagPrefix) != null ? _b : false,
|
|
687
688
|
implicitFirstChars: (_c = options.implicitFirstChars) != null ? _c : null,
|
|
688
689
|
resolve: options.resolve,
|
|
689
|
-
identify:
|
|
690
|
-
represent: (
|
|
691
|
-
representTagName: (
|
|
690
|
+
identify: options.identify,
|
|
691
|
+
represent: (_d = options.represent) != null ? _d : ((data) => String(data)),
|
|
692
|
+
representTagName: (_e = options.representTagName) != null ? _e : (() => tagName)
|
|
692
693
|
};
|
|
693
694
|
}
|
|
694
695
|
function defineSequenceTag(tagName, options) {
|
|
695
|
-
var _a, _b, _c, _d
|
|
696
|
+
var _a, _b, _c, _d;
|
|
696
697
|
const carrierIsResult = options.finalize === void 0;
|
|
697
698
|
return {
|
|
698
699
|
tagName,
|
|
@@ -703,13 +704,13 @@ function defineSequenceTag(tagName, options) {
|
|
|
703
704
|
addItem: options.addItem,
|
|
704
705
|
finalize: (_b = options.finalize) != null ? _b : ((carrier) => carrier),
|
|
705
706
|
carrierIsResult,
|
|
706
|
-
identify:
|
|
707
|
-
represent: (
|
|
708
|
-
representTagName: (
|
|
707
|
+
identify: options.identify,
|
|
708
|
+
represent: (_c = options.represent) != null ? _c : ((data) => data),
|
|
709
|
+
representTagName: (_d = options.representTagName) != null ? _d : (() => tagName)
|
|
709
710
|
};
|
|
710
711
|
}
|
|
711
712
|
function defineMappingTag(tagName, options) {
|
|
712
|
-
var _a, _b, _c, _d
|
|
713
|
+
var _a, _b, _c, _d;
|
|
713
714
|
const carrierIsResult = options.finalize === void 0;
|
|
714
715
|
return {
|
|
715
716
|
tagName,
|
|
@@ -723,9 +724,9 @@ function defineMappingTag(tagName, options) {
|
|
|
723
724
|
get: options.get,
|
|
724
725
|
finalize: (_b = options.finalize) != null ? _b : ((carrier) => carrier),
|
|
725
726
|
carrierIsResult,
|
|
726
|
-
identify:
|
|
727
|
-
represent: (
|
|
728
|
-
representTagName: (
|
|
727
|
+
identify: options.identify,
|
|
728
|
+
represent: (_c = options.represent) != null ? _c : ((data) => data),
|
|
729
|
+
representTagName: (_d = options.representTagName) != null ? _d : (() => tagName)
|
|
729
730
|
};
|
|
730
731
|
}
|
|
731
732
|
var strTag = defineScalarTag("tag:yaml.org,2002:str", {
|
|
@@ -1074,9 +1075,10 @@ var mergeTag = defineScalarTag("tag:yaml.org,2002:merge", {
|
|
|
1074
1075
|
implicit: true,
|
|
1075
1076
|
implicitFirstChars: ["<"],
|
|
1076
1077
|
resolve: (source, isExplicit) => {
|
|
1077
|
-
if (source === "<<" || isExplicit && source === "") return
|
|
1078
|
+
if (source === "<<" || isExplicit && source === "") return "<<";
|
|
1078
1079
|
return NOT_RESOLVED;
|
|
1079
|
-
}
|
|
1080
|
+
},
|
|
1081
|
+
identify: () => false
|
|
1080
1082
|
});
|
|
1081
1083
|
var BASE64_PATTERN = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
1082
1084
|
function resolveYamlBinary(source) {
|
|
@@ -1099,6 +1101,11 @@ var binaryTag = defineScalarTag("tag:yaml.org,2002:binary", {
|
|
|
1099
1101
|
});
|
|
1100
1102
|
var YAML_DATE_REGEXP = /* @__PURE__ */ new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
1101
1103
|
var YAML_TIMESTAMP_REGEXP = /* @__PURE__ */ 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]))?))?$");
|
|
1104
|
+
function makeUtcDate(year, month, day, hour = 0, minute = 0, second = 0, fraction = 0) {
|
|
1105
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
1106
|
+
date.setUTCFullYear(year, month, day);
|
|
1107
|
+
return date;
|
|
1108
|
+
}
|
|
1102
1109
|
function resolveYamlTimestamp(source) {
|
|
1103
1110
|
let match = YAML_DATE_REGEXP.exec(source);
|
|
1104
1111
|
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(source);
|
|
@@ -1107,7 +1114,7 @@ function resolveYamlTimestamp(source) {
|
|
|
1107
1114
|
const month = +match[2] - 1;
|
|
1108
1115
|
const day = +match[3];
|
|
1109
1116
|
if (!match[4]) {
|
|
1110
|
-
const date2 =
|
|
1117
|
+
const date2 = makeUtcDate(year, month, day);
|
|
1111
1118
|
if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month || date2.getUTCDate() !== day) return NOT_RESOLVED;
|
|
1112
1119
|
return date2;
|
|
1113
1120
|
}
|
|
@@ -1121,7 +1128,7 @@ function resolveYamlTimestamp(source) {
|
|
|
1121
1128
|
while (value.length < 3) value += "0";
|
|
1122
1129
|
fraction = +value;
|
|
1123
1130
|
}
|
|
1124
|
-
const date =
|
|
1131
|
+
const date = makeUtcDate(year, month, day, hour, minute, second, fraction);
|
|
1125
1132
|
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month || date.getUTCDate() !== day) return NOT_RESOLVED;
|
|
1126
1133
|
if (match[9]) {
|
|
1127
1134
|
const offsetHour = +match[10];
|
|
@@ -1176,7 +1183,8 @@ var omapTag = defineSequenceTag("tag:yaml.org,2002:omap", {
|
|
|
1176
1183
|
carrier.list.push(item);
|
|
1177
1184
|
return "";
|
|
1178
1185
|
},
|
|
1179
|
-
finalize: (carrier) => carrier.list
|
|
1186
|
+
finalize: (carrier) => carrier.list,
|
|
1187
|
+
identify: () => false
|
|
1180
1188
|
});
|
|
1181
1189
|
var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
1182
1190
|
create: () => [],
|
|
@@ -1192,7 +1200,8 @@ var pairsTag = defineSequenceTag("tag:yaml.org,2002:pairs", {
|
|
|
1192
1200
|
if (keys.length !== 1) return "cannot resolve a pairs item";
|
|
1193
1201
|
container.push([keys[0], object[keys[0]]]);
|
|
1194
1202
|
return "";
|
|
1195
|
-
}
|
|
1203
|
+
},
|
|
1204
|
+
identify: () => false
|
|
1196
1205
|
});
|
|
1197
1206
|
var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
1198
1207
|
create: () => ({}),
|
|
@@ -1219,7 +1228,11 @@ var mapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
|
1219
1228
|
return Object.prototype.hasOwnProperty.call(container, String(key));
|
|
1220
1229
|
},
|
|
1221
1230
|
keys: (container) => Object.keys(container),
|
|
1222
|
-
get: (container, key) =>
|
|
1231
|
+
get: (container, key) => {
|
|
1232
|
+
const normalizedKey = String(key);
|
|
1233
|
+
if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
|
|
1234
|
+
return container[normalizedKey];
|
|
1235
|
+
}
|
|
1223
1236
|
});
|
|
1224
1237
|
var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
1225
1238
|
create: () => /* @__PURE__ */ new Set(),
|
|
@@ -1240,9 +1253,9 @@ var setTag = defineMappingTag("tag:yaml.org,2002:set", {
|
|
|
1240
1253
|
});
|
|
1241
1254
|
function createTagDefinitionMap() {
|
|
1242
1255
|
return {
|
|
1243
|
-
scalar:
|
|
1244
|
-
sequence:
|
|
1245
|
-
mapping:
|
|
1256
|
+
scalar: /* @__PURE__ */ Object.create(null),
|
|
1257
|
+
sequence: /* @__PURE__ */ Object.create(null),
|
|
1258
|
+
mapping: /* @__PURE__ */ Object.create(null)
|
|
1246
1259
|
};
|
|
1247
1260
|
}
|
|
1248
1261
|
function createTagDefinitionListMap() {
|
|
@@ -1270,11 +1283,35 @@ function compileTags(tags) {
|
|
|
1270
1283
|
var Schema = class Schema2 {
|
|
1271
1284
|
constructor(tags) {
|
|
1272
1285
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "tags");
|
|
1286
|
+
/** @internal */
|
|
1273
1287
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "implicitScalarTags");
|
|
1288
|
+
/**
|
|
1289
|
+
* Dispatch implicit scalar resolvers by `source.charAt(0)`. Each bucket holds
|
|
1290
|
+
* the resolvers that may match that key, in schema order; a key absent from
|
|
1291
|
+
* the map uses
|
|
1292
|
+
* {@link Schema.implicitScalarAnyFirstChar}
|
|
1293
|
+
* (resolvers that declared no first-char constraint, so they apply to any
|
|
1294
|
+
* first character).
|
|
1295
|
+
*/
|
|
1274
1296
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "implicitScalarByFirstChar");
|
|
1275
1297
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "implicitScalarAnyFirstChar");
|
|
1298
|
+
/**
|
|
1299
|
+
* The default scalar tag (`!!str`), resolved once so the composer's fallback
|
|
1300
|
+
* for unresolved plain scalars avoids a keyed lookup per scalar.
|
|
1301
|
+
*
|
|
1302
|
+
* @internal
|
|
1303
|
+
*/
|
|
1276
1304
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "defaultScalarTag");
|
|
1305
|
+
/**
|
|
1306
|
+
* The default container tags (`!!seq` / `!!map`), used by the dumper: when a
|
|
1307
|
+
* value is identified by its default tag, the tag is implicit and not
|
|
1308
|
+
* printed. Undefined if the schema does not define them (then such values
|
|
1309
|
+
* can't be dumped).
|
|
1310
|
+
*
|
|
1311
|
+
* @internal
|
|
1312
|
+
*/
|
|
1277
1313
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "defaultSequenceTag");
|
|
1314
|
+
/** @internal */
|
|
1278
1315
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "defaultMappingTag");
|
|
1279
1316
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "exact");
|
|
1280
1317
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "prefix");
|
|
@@ -1319,6 +1356,53 @@ var Schema = class Schema2 {
|
|
|
1319
1356
|
this.exact = exact;
|
|
1320
1357
|
this.prefix = prefix;
|
|
1321
1358
|
}
|
|
1359
|
+
/** @internal */
|
|
1360
|
+
lookupScalarTag(tagName) {
|
|
1361
|
+
const exactTag = this.exact.scalar[tagName];
|
|
1362
|
+
if (exactTag) return exactTag;
|
|
1363
|
+
for (const tag of this.prefix.scalar) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1364
|
+
}
|
|
1365
|
+
/** @internal */
|
|
1366
|
+
lookupSequenceTag(tagName) {
|
|
1367
|
+
const exactTag = this.exact.sequence[tagName];
|
|
1368
|
+
if (exactTag) return exactTag;
|
|
1369
|
+
for (const tag of this.prefix.sequence) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1370
|
+
}
|
|
1371
|
+
/** @internal */
|
|
1372
|
+
lookupMappingTag(tagName) {
|
|
1373
|
+
const exactTag = this.exact.mapping[tagName];
|
|
1374
|
+
if (exactTag) return exactTag;
|
|
1375
|
+
for (const tag of this.prefix.mapping) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1376
|
+
}
|
|
1377
|
+
/** @internal */
|
|
1378
|
+
resolveImplicitScalarTag(source) {
|
|
1379
|
+
var _a;
|
|
1380
|
+
const candidates = (_a = this.implicitScalarByFirstChar.get(source.charAt(0))) != null ? _a : this.implicitScalarAnyFirstChar;
|
|
1381
|
+
for (const tag2 of candidates) {
|
|
1382
|
+
const value = tag2.resolve(source, false, tag2.tagName);
|
|
1383
|
+
if (value !== NOT_RESOLVED) return {
|
|
1384
|
+
value,
|
|
1385
|
+
tag: tag2
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
const tag = this.defaultScalarTag;
|
|
1389
|
+
return {
|
|
1390
|
+
value: tag.resolve(source, false, tag.tagName),
|
|
1391
|
+
tag
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Creates a new schema with the specified tags added. If a tag already
|
|
1396
|
+
* exists, it is replaced by the specified tag.
|
|
1397
|
+
*
|
|
1398
|
+
* @example
|
|
1399
|
+
*
|
|
1400
|
+
* ```javascript
|
|
1401
|
+
* import { CORE_SCHEMA, mergeTag, realMapTag } from 'js-yaml'
|
|
1402
|
+
*
|
|
1403
|
+
* const schema = CORE_SCHEMA.withTags(mergeTag, realMapTag)
|
|
1404
|
+
* ```
|
|
1405
|
+
*/
|
|
1322
1406
|
withTags(...tags) {
|
|
1323
1407
|
let flatTags = [];
|
|
1324
1408
|
for (const tag of tags) flatTags = flatTags.concat(tag);
|
|
@@ -1357,6 +1441,17 @@ var YAML11_SCHEMA = new Schema([
|
|
|
1357
1441
|
pairsTag,
|
|
1358
1442
|
setTag
|
|
1359
1443
|
]);
|
|
1444
|
+
var DUMP_SCHEMA = YAML11_SCHEMA.withTags(_chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, intYaml11Tag), {
|
|
1445
|
+
resolve: (source, isExplicit, tagName) => {
|
|
1446
|
+
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
1447
|
+
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
1448
|
+
}
|
|
1449
|
+
}), _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, floatYaml11Tag), {
|
|
1450
|
+
resolve: (source, isExplicit, tagName) => {
|
|
1451
|
+
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
1452
|
+
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
1453
|
+
}
|
|
1454
|
+
}));
|
|
1360
1455
|
var realMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
1361
1456
|
create: () => /* @__PURE__ */ new Map(),
|
|
1362
1457
|
addPair: (container, key, value) => {
|
|
@@ -1412,7 +1507,11 @@ var legacyMapTag = defineMappingTag("tag:yaml.org,2002:map", {
|
|
|
1412
1507
|
return normalizedKey !== null && Object.prototype.hasOwnProperty.call(container, normalizedKey);
|
|
1413
1508
|
},
|
|
1414
1509
|
keys: (container) => Object.keys(container),
|
|
1415
|
-
get: (container, key) =>
|
|
1510
|
+
get: (container, key) => {
|
|
1511
|
+
const normalizedKey = String(key);
|
|
1512
|
+
if (!Object.prototype.hasOwnProperty.call(container, normalizedKey)) return null;
|
|
1513
|
+
return container[normalizedKey];
|
|
1514
|
+
}
|
|
1416
1515
|
});
|
|
1417
1516
|
var DEFAULT_SNIPPET_OPTIONS = {
|
|
1418
1517
|
maxLength: 79,
|
|
@@ -1486,7 +1585,11 @@ function formatError(exception, compact) {
|
|
|
1486
1585
|
${exception.mark.snippet}`;
|
|
1487
1586
|
return `${exception.reason} ${where}`;
|
|
1488
1587
|
}
|
|
1489
|
-
var YAMLException = class extends Error {
|
|
1588
|
+
var YAMLException = class YAMLException2 extends Error {
|
|
1589
|
+
/**
|
|
1590
|
+
* Optional `mark` contains source snippet data. Usually, use
|
|
1591
|
+
* {@link YAMLException.throwAt} instead of passing it directly.
|
|
1592
|
+
*/
|
|
1490
1593
|
constructor(reason, mark) {
|
|
1491
1594
|
super();
|
|
1492
1595
|
_chunkN76BG37Wjs.__publicField.call(void 0, this, "reason");
|
|
@@ -1497,34 +1600,65 @@ var YAMLException = class extends Error {
|
|
|
1497
1600
|
this.message = formatError(this, false);
|
|
1498
1601
|
if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
|
|
1499
1602
|
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Returns the formatted error, omitting the source snippet in compact mode.
|
|
1605
|
+
*/
|
|
1500
1606
|
toString(compact) {
|
|
1501
1607
|
return `${this.name}: ${formatError(this, compact)}`;
|
|
1502
1608
|
}
|
|
1609
|
+
/**
|
|
1610
|
+
* Builds a YAMLException with a source snippet and throws it. `source` is
|
|
1611
|
+
* the raw input text; `position` is an offset into it.
|
|
1612
|
+
*/
|
|
1613
|
+
static throwAt(source, position, message, filename = "") {
|
|
1614
|
+
let line = 0;
|
|
1615
|
+
let lineStart = 0;
|
|
1616
|
+
for (let index = 0; index < position; index++) {
|
|
1617
|
+
const ch = source.charCodeAt(index);
|
|
1618
|
+
if (ch === 10) {
|
|
1619
|
+
line++;
|
|
1620
|
+
lineStart = index + 1;
|
|
1621
|
+
} else if (ch === 13) {
|
|
1622
|
+
line++;
|
|
1623
|
+
if (source.charCodeAt(index + 1) === 10) index++;
|
|
1624
|
+
lineStart = index + 1;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
const mark = {
|
|
1628
|
+
name: filename,
|
|
1629
|
+
buffer: source,
|
|
1630
|
+
position,
|
|
1631
|
+
line,
|
|
1632
|
+
column: position - lineStart
|
|
1633
|
+
};
|
|
1634
|
+
mark.snippet = makeSnippet(mark);
|
|
1635
|
+
throw new YAMLException2(message, mark);
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
var EVENT_ID = {
|
|
1639
|
+
DOCUMENT: 1,
|
|
1640
|
+
SEQUENCE: 2,
|
|
1641
|
+
MAPPING: 3,
|
|
1642
|
+
SCALAR: 4,
|
|
1643
|
+
ALIAS: 5,
|
|
1644
|
+
POP: 6
|
|
1645
|
+
};
|
|
1646
|
+
var SCALAR_STYLE = {
|
|
1647
|
+
PLAIN: 1,
|
|
1648
|
+
SINGLE_QUOTED: 2,
|
|
1649
|
+
DOUBLE_QUOTED: 3,
|
|
1650
|
+
LITERAL_BLOCK: 4,
|
|
1651
|
+
FOLDED_BLOCK: 5
|
|
1652
|
+
};
|
|
1653
|
+
var COLLECTION_STYLE = {
|
|
1654
|
+
BLOCK: 1,
|
|
1655
|
+
FLOW: 2
|
|
1656
|
+
};
|
|
1657
|
+
var CHOMPING_MODE = {
|
|
1658
|
+
CLIP: 1,
|
|
1659
|
+
STRIP: 2,
|
|
1660
|
+
KEEP: 3
|
|
1503
1661
|
};
|
|
1504
|
-
function throwErrorAt(source, position, message, filename = "") {
|
|
1505
|
-
let line = 0;
|
|
1506
|
-
let lineStart = 0;
|
|
1507
|
-
for (let index = 0; index < position; index++) {
|
|
1508
|
-
const ch = source.charCodeAt(index);
|
|
1509
|
-
if (ch === 10) {
|
|
1510
|
-
line++;
|
|
1511
|
-
lineStart = index + 1;
|
|
1512
|
-
} else if (ch === 13) {
|
|
1513
|
-
line++;
|
|
1514
|
-
if (source.charCodeAt(index + 1) === 10) index++;
|
|
1515
|
-
lineStart = index + 1;
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
const mark = {
|
|
1519
|
-
name: filename,
|
|
1520
|
-
buffer: source,
|
|
1521
|
-
position,
|
|
1522
|
-
line,
|
|
1523
|
-
column: position - lineStart
|
|
1524
|
-
};
|
|
1525
|
-
mark.snippet = makeSnippet(mark);
|
|
1526
|
-
throw new YAMLException(message, mark);
|
|
1527
|
-
}
|
|
1528
1662
|
var NO_RANGE$3 = -1;
|
|
1529
1663
|
function simpleEscapeSequence(c) {
|
|
1530
1664
|
switch (c) {
|
|
@@ -1722,8 +1856,8 @@ function getBlockValue(input, start, end, indent, chomping, folded) {
|
|
|
1722
1856
|
didReadContent = true;
|
|
1723
1857
|
emptyLines = 0;
|
|
1724
1858
|
}
|
|
1725
|
-
if (chomping ===
|
|
1726
|
-
else if (chomping !==
|
|
1859
|
+
if (chomping === CHOMPING_MODE.KEEP) result += "\n".repeat(didReadContent ? 1 + emptyLines : emptyLines);
|
|
1860
|
+
else if (chomping !== CHOMPING_MODE.STRIP) {
|
|
1727
1861
|
if (didReadContent) result += "\n";
|
|
1728
1862
|
}
|
|
1729
1863
|
return result;
|
|
@@ -1733,22 +1867,22 @@ function getScalarValue(input, scalar) {
|
|
|
1733
1867
|
const { valueStart, valueEnd } = scalar;
|
|
1734
1868
|
if (scalar.fast) return input.slice(valueStart, valueEnd);
|
|
1735
1869
|
switch (scalar.style) {
|
|
1736
|
-
case
|
|
1870
|
+
case SCALAR_STYLE.SINGLE_QUOTED:
|
|
1737
1871
|
return getSingleQuotedValue(input, valueStart, valueEnd);
|
|
1738
|
-
case
|
|
1872
|
+
case SCALAR_STYLE.DOUBLE_QUOTED:
|
|
1739
1873
|
return getDoubleQuotedValue(input, valueStart, valueEnd);
|
|
1740
|
-
case
|
|
1874
|
+
case SCALAR_STYLE.LITERAL_BLOCK:
|
|
1741
1875
|
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, false);
|
|
1742
|
-
case
|
|
1876
|
+
case SCALAR_STYLE.FOLDED_BLOCK:
|
|
1743
1877
|
return getBlockValue(input, valueStart, valueEnd, scalar.indent, scalar.chomping, true);
|
|
1744
1878
|
default:
|
|
1745
1879
|
return getPlainValue(input, valueStart, valueEnd);
|
|
1746
1880
|
}
|
|
1747
1881
|
}
|
|
1748
|
-
var DEFAULT_TAG_HANDLERS = {
|
|
1882
|
+
var DEFAULT_TAG_HANDLERS = Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
1749
1883
|
"!": "!",
|
|
1750
1884
|
"!!": "tag:yaml.org,2002:"
|
|
1751
|
-
};
|
|
1885
|
+
});
|
|
1752
1886
|
function tagPercentEncode(source) {
|
|
1753
1887
|
return encodeURI(source).replace(/!/g, "%21");
|
|
1754
1888
|
}
|
|
@@ -1770,6 +1904,7 @@ function tagNameShort(fullTag) {
|
|
|
1770
1904
|
return `!<${tagPercentEncode(tag)}>`;
|
|
1771
1905
|
}
|
|
1772
1906
|
var NO_RANGE$2 = -1;
|
|
1907
|
+
var MERGE_TAG_NAME = "tag:yaml.org,2002:merge";
|
|
1773
1908
|
var DEFAULT_CONSTRUCTOR_OPTIONS = {
|
|
1774
1909
|
filename: "",
|
|
1775
1910
|
schema: CORE_SCHEMA,
|
|
@@ -1785,28 +1920,18 @@ function eventPosition$1(event) {
|
|
|
1785
1920
|
return 0;
|
|
1786
1921
|
}
|
|
1787
1922
|
function throwError$1(state, message) {
|
|
1788
|
-
|
|
1923
|
+
YAMLException.throwAt(state.source, state.position, message, state.filename);
|
|
1789
1924
|
}
|
|
1790
1925
|
function finalizeCollection(state, position, tag, carrier) {
|
|
1791
1926
|
try {
|
|
1792
1927
|
return tag.finalize(carrier);
|
|
1793
1928
|
} catch (error) {
|
|
1794
1929
|
if (error instanceof YAMLException) throw error;
|
|
1795
|
-
|
|
1930
|
+
YAMLException.throwAt(state.source, position, error instanceof Error ? error.message : String(error), state.filename);
|
|
1796
1931
|
}
|
|
1797
1932
|
}
|
|
1798
|
-
function lookupTag(exact, prefix, tagName) {
|
|
1799
|
-
const exactTag = exact[tagName];
|
|
1800
|
-
if (exactTag) return exactTag;
|
|
1801
|
-
for (const tag of prefix) if (tagName.startsWith(tag.tagName)) return tag;
|
|
1802
|
-
}
|
|
1803
|
-
function findExplicitTag(state, exact, prefix, tagName, nodeKind) {
|
|
1804
|
-
const tag = lookupTag(exact, prefix, tagName);
|
|
1805
|
-
if (tag) return tag;
|
|
1806
|
-
throwError$1(state, `unknown ${nodeKind} tag !<${tagName}>`);
|
|
1807
|
-
}
|
|
1808
1933
|
function constructScalar(state, event) {
|
|
1809
|
-
var _a
|
|
1934
|
+
var _a;
|
|
1810
1935
|
const source = getScalarValue(state.source, event);
|
|
1811
1936
|
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1812
1937
|
const strTag2 = state.schema.defaultScalarTag;
|
|
@@ -1816,7 +1941,7 @@ function constructScalar(state, event) {
|
|
|
1816
1941
|
tag: strTag2
|
|
1817
1942
|
};
|
|
1818
1943
|
const tagName = tagNameFull(rawTag, state.tagHandlers);
|
|
1819
|
-
const scalarTag =
|
|
1944
|
+
const scalarTag = state.schema.lookupScalarTag(tagName);
|
|
1820
1945
|
if (scalarTag) {
|
|
1821
1946
|
const result = scalarTag.resolve(source, true, tagName);
|
|
1822
1947
|
if (result === NOT_RESOLVED) throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
@@ -1825,7 +1950,7 @@ function constructScalar(state, event) {
|
|
|
1825
1950
|
tag: scalarTag
|
|
1826
1951
|
};
|
|
1827
1952
|
}
|
|
1828
|
-
const collectionTagDef = (_a =
|
|
1953
|
+
const collectionTagDef = (_a = state.schema.lookupMappingTag(tagName)) != null ? _a : state.schema.lookupSequenceTag(tagName);
|
|
1829
1954
|
if (collectionTagDef) {
|
|
1830
1955
|
if (source !== "") throwError$1(state, `cannot resolve a node with !<${tagName}> explicit tag`);
|
|
1831
1956
|
const carrier = collectionTagDef.create(tagName);
|
|
@@ -1836,52 +1961,51 @@ function constructScalar(state, event) {
|
|
|
1836
1961
|
}
|
|
1837
1962
|
throwError$1(state, `unknown scalar tag !<${tagName}>`);
|
|
1838
1963
|
}
|
|
1839
|
-
if (event.style ===
|
|
1840
|
-
const candidates = (_b = state.schema.implicitScalarByFirstChar.get(source.charAt(0))) != null ? _b : state.schema.implicitScalarAnyFirstChar;
|
|
1841
|
-
for (const tag of candidates) {
|
|
1842
|
-
const result = tag.resolve(source, false, tag.tagName);
|
|
1843
|
-
if (result !== NOT_RESOLVED) return {
|
|
1844
|
-
value: result,
|
|
1845
|
-
tag
|
|
1846
|
-
};
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1964
|
+
if (event.style === SCALAR_STYLE.PLAIN) return state.schema.resolveImplicitScalarTag(source);
|
|
1849
1965
|
return {
|
|
1850
1966
|
value: strTag2.resolve(source, false, strTag2.tagName),
|
|
1851
1967
|
tag: strTag2
|
|
1852
1968
|
};
|
|
1853
1969
|
}
|
|
1854
|
-
function
|
|
1970
|
+
function collectionTagName(state, event, defaultTagName) {
|
|
1855
1971
|
const rawTag = event.tagStart === NO_RANGE$2 ? "" : state.source.slice(event.tagStart, event.tagEnd);
|
|
1856
|
-
|
|
1857
|
-
return {
|
|
1858
|
-
tagName,
|
|
1859
|
-
tag: findExplicitTag(state, exact, prefix, tagName, nodeKind)
|
|
1860
|
-
};
|
|
1972
|
+
return rawTag === "" || rawTag === "!" ? defaultTagName : tagNameFull(rawTag, state.tagHandlers);
|
|
1861
1973
|
}
|
|
1862
1974
|
function isMappingTag(tag) {
|
|
1863
1975
|
return tag.nodeKind === "mapping";
|
|
1864
1976
|
}
|
|
1977
|
+
function chargeMergeWork(state) {
|
|
1978
|
+
state.totalMergeKeys++;
|
|
1979
|
+
if (state.maxTotalMergeKeys !== -1 && state.totalMergeKeys > state.maxTotalMergeKeys) throwError$1(state, `merge keys exceeded maxTotalMergeKeys (${state.maxTotalMergeKeys})`);
|
|
1980
|
+
}
|
|
1865
1981
|
function mergeKeys(state, frame, source, sourceTag) {
|
|
1866
1982
|
var _a;
|
|
1983
|
+
chargeMergeWork(state);
|
|
1867
1984
|
for (const sourceKey of sourceTag.keys(source)) {
|
|
1868
|
-
|
|
1985
|
+
chargeMergeWork(state);
|
|
1869
1986
|
if (frame.tag.has(frame.value, sourceKey)) continue;
|
|
1870
1987
|
const err = frame.tag.addPair(frame.value, sourceKey, sourceTag.get(source, sourceKey));
|
|
1871
1988
|
if (err) throwError$1(state, err);
|
|
1872
|
-
(
|
|
1989
|
+
(_a = frame.overridable) != null ? _a : frame.overridable = /* @__PURE__ */ new Set();
|
|
1990
|
+
frame.overridable.add(sourceKey);
|
|
1873
1991
|
}
|
|
1874
1992
|
}
|
|
1875
1993
|
function mergeSource(state, frame, source, sourceTag) {
|
|
1876
1994
|
state.position = frame.keyPosition;
|
|
1877
1995
|
if (isMappingTag(sourceTag)) mergeKeys(state, frame, source, sourceTag);
|
|
1878
|
-
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source))
|
|
1879
|
-
|
|
1996
|
+
else if (sourceTag.nodeKind === "sequence" && Array.isArray(source)) {
|
|
1997
|
+
if (source.length > 100) throwError$1(state, "abnormal merge sequence size");
|
|
1998
|
+
for (const element of source) {
|
|
1999
|
+
const elementTag = state.nodeTags.get(element);
|
|
2000
|
+
if (!elementTag) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
2001
|
+
mergeKeys(state, frame, element, elementTag);
|
|
2002
|
+
}
|
|
2003
|
+
} else throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1880
2004
|
}
|
|
1881
2005
|
function addMappingValue(state, frame, key, value, tag) {
|
|
1882
2006
|
var _a, _b;
|
|
1883
2007
|
state.position = frame.keyPosition;
|
|
1884
|
-
if (
|
|
2008
|
+
if (frame.keyIsMerge) {
|
|
1885
2009
|
mergeSource(state, frame, value, tag);
|
|
1886
2010
|
return;
|
|
1887
2011
|
}
|
|
@@ -1896,9 +2020,7 @@ function addValue(state, value, tag) {
|
|
|
1896
2020
|
frame.value = value;
|
|
1897
2021
|
frame.hasValue = true;
|
|
1898
2022
|
} else if (frame.kind === "sequence") {
|
|
1899
|
-
if (
|
|
1900
|
-
if (!isMappingTag(tag)) throwError$1(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1901
|
-
}
|
|
2023
|
+
if (isMappingTag(tag)) state.nodeTags.set(value, tag);
|
|
1902
2024
|
const err = frame.tag.addItem(frame.value, value, frame.index++);
|
|
1903
2025
|
if (err) throwError$1(state, err);
|
|
1904
2026
|
} else if (frame.hasKey) {
|
|
@@ -1910,6 +2032,7 @@ function addValue(state, value, tag) {
|
|
|
1910
2032
|
frame.key = value;
|
|
1911
2033
|
frame.keyPosition = state.position;
|
|
1912
2034
|
frame.hasKey = true;
|
|
2035
|
+
frame.keyIsMerge = tag.tagName === MERGE_TAG_NAME;
|
|
1913
2036
|
}
|
|
1914
2037
|
}
|
|
1915
2038
|
function storeAnchor(state, event, value, tag, isValueFinal) {
|
|
@@ -1932,6 +2055,7 @@ function constructFromEvents(events, options) {
|
|
|
1932
2055
|
position: 0,
|
|
1933
2056
|
frames: [],
|
|
1934
2057
|
anchors: /* @__PURE__ */ new Map(),
|
|
2058
|
+
nodeTags: /* @__PURE__ */ new Map(),
|
|
1935
2059
|
tagHandlers: /* @__PURE__ */ Object.create(null),
|
|
1936
2060
|
totalMergeKeys: 0,
|
|
1937
2061
|
aliasCount: 0
|
|
@@ -1940,8 +2064,9 @@ function constructFromEvents(events, options) {
|
|
|
1940
2064
|
const event = state.events[state.eventIndex++];
|
|
1941
2065
|
state.position = eventPosition$1(event);
|
|
1942
2066
|
switch (event.type) {
|
|
1943
|
-
case
|
|
2067
|
+
case EVENT_ID.DOCUMENT:
|
|
1944
2068
|
state.anchors = /* @__PURE__ */ new Map();
|
|
2069
|
+
state.nodeTags = /* @__PURE__ */ new Map();
|
|
1945
2070
|
state.aliasCount = 0;
|
|
1946
2071
|
state.tagHandlers = /* @__PURE__ */ Object.create(null);
|
|
1947
2072
|
for (const directive of event.directives) if (directive.kind === "tag") state.tagHandlers[directive.handle] = directive.prefix;
|
|
@@ -1952,47 +2077,49 @@ function constructFromEvents(events, options) {
|
|
|
1952
2077
|
hasValue: false
|
|
1953
2078
|
});
|
|
1954
2079
|
break;
|
|
1955
|
-
case
|
|
2080
|
+
case EVENT_ID.SCALAR: {
|
|
1956
2081
|
const { value, tag } = constructScalar(state, event);
|
|
1957
2082
|
storeAnchor(state, event, value, tag, true);
|
|
1958
2083
|
addValue(state, value, tag);
|
|
1959
2084
|
break;
|
|
1960
2085
|
}
|
|
1961
|
-
case
|
|
1962
|
-
const
|
|
1963
|
-
const
|
|
1964
|
-
|
|
1965
|
-
const
|
|
1966
|
-
const
|
|
2086
|
+
case EVENT_ID.SEQUENCE: {
|
|
2087
|
+
const tagName = collectionTagName(state, event, "tag:yaml.org,2002:seq");
|
|
2088
|
+
const tag = state.schema.lookupSequenceTag(tagName);
|
|
2089
|
+
if (!tag) throwError$1(state, `unknown sequence tag !<${tagName}>`);
|
|
2090
|
+
const value = tag.create(tagName);
|
|
2091
|
+
const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
|
|
1967
2092
|
state.frames.push({
|
|
1968
2093
|
kind: "sequence",
|
|
1969
2094
|
position: state.position,
|
|
1970
2095
|
value,
|
|
1971
|
-
tag
|
|
2096
|
+
tag,
|
|
1972
2097
|
anchor,
|
|
1973
|
-
index: 0
|
|
1974
|
-
merge
|
|
2098
|
+
index: 0
|
|
1975
2099
|
});
|
|
1976
2100
|
break;
|
|
1977
2101
|
}
|
|
1978
|
-
case
|
|
1979
|
-
const
|
|
1980
|
-
const
|
|
1981
|
-
|
|
2102
|
+
case EVENT_ID.MAPPING: {
|
|
2103
|
+
const tagName = collectionTagName(state, event, "tag:yaml.org,2002:map");
|
|
2104
|
+
const tag = state.schema.lookupMappingTag(tagName);
|
|
2105
|
+
if (!tag) throwError$1(state, `unknown mapping tag !<${tagName}>`);
|
|
2106
|
+
const value = tag.create(tagName);
|
|
2107
|
+
const anchor = storeAnchor(state, event, value, tag, tag.carrierIsResult);
|
|
1982
2108
|
state.frames.push({
|
|
1983
2109
|
kind: "mapping",
|
|
1984
2110
|
position: state.position,
|
|
1985
2111
|
value,
|
|
1986
|
-
tag
|
|
2112
|
+
tag,
|
|
1987
2113
|
anchor,
|
|
1988
2114
|
key: void 0,
|
|
1989
2115
|
keyPosition: state.position,
|
|
1990
2116
|
hasKey: false,
|
|
2117
|
+
keyIsMerge: false,
|
|
1991
2118
|
overridable: null
|
|
1992
2119
|
});
|
|
1993
2120
|
break;
|
|
1994
2121
|
}
|
|
1995
|
-
case
|
|
2122
|
+
case EVENT_ID.ALIAS: {
|
|
1996
2123
|
if (state.maxAliases !== -1 && ++state.aliasCount > state.maxAliases) throwError$1(state, `aliases exceeded maxAliases (${state.maxAliases})`);
|
|
1997
2124
|
const name = state.source.slice(event.anchorStart, event.anchorEnd);
|
|
1998
2125
|
const anchor = state.anchors.get(name);
|
|
@@ -2001,8 +2128,12 @@ function constructFromEvents(events, options) {
|
|
|
2001
2128
|
addValue(state, anchor.value, anchor.tag);
|
|
2002
2129
|
break;
|
|
2003
2130
|
}
|
|
2004
|
-
case
|
|
2131
|
+
case EVENT_ID.POP: {
|
|
2005
2132
|
const frame = state.frames.pop();
|
|
2133
|
+
if (frame.kind === "mapping" && frame.hasKey) {
|
|
2134
|
+
state.position = frame.keyPosition;
|
|
2135
|
+
throwError$1(state, "incomplete mapping pair in event stream");
|
|
2136
|
+
}
|
|
2006
2137
|
if (frame.kind === "document") state.documents.push(frame.value);
|
|
2007
2138
|
else {
|
|
2008
2139
|
const value = frame.tag.carrierIsResult ? frame.value : finalizeCollection(state, frame.position, frame.tag, frame.value);
|
|
@@ -2038,7 +2169,7 @@ var DEFAULT_PARSER_OPTIONS = {
|
|
|
2038
2169
|
};
|
|
2039
2170
|
function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
2040
2171
|
state.events.push({
|
|
2041
|
-
type:
|
|
2172
|
+
type: EVENT_ID.DOCUMENT,
|
|
2042
2173
|
explicitStart,
|
|
2043
2174
|
explicitEnd,
|
|
2044
2175
|
directives: state.directives
|
|
@@ -2046,7 +2177,7 @@ function addDocumentEvent(state, explicitStart, explicitEnd) {
|
|
|
2046
2177
|
}
|
|
2047
2178
|
function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
2048
2179
|
state.events.push({
|
|
2049
|
-
type:
|
|
2180
|
+
type: EVENT_ID.SEQUENCE,
|
|
2050
2181
|
start,
|
|
2051
2182
|
anchorStart,
|
|
2052
2183
|
anchorEnd,
|
|
@@ -2057,7 +2188,7 @@ function addSequenceEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd
|
|
|
2057
2188
|
}
|
|
2058
2189
|
function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd, style) {
|
|
2059
2190
|
state.events.push({
|
|
2060
|
-
type:
|
|
2191
|
+
type: EVENT_ID.MAPPING,
|
|
2061
2192
|
start,
|
|
2062
2193
|
anchorStart,
|
|
2063
2194
|
anchorEnd,
|
|
@@ -2068,18 +2199,18 @@ function addMappingEvent(state, start, anchorStart, anchorEnd, tagStart, tagEnd,
|
|
|
2068
2199
|
}
|
|
2069
2200
|
function insertFlowPairMappingEvent(state, snapshot) {
|
|
2070
2201
|
state.events.splice(snapshot.eventsLength, 0, {
|
|
2071
|
-
type:
|
|
2202
|
+
type: EVENT_ID.MAPPING,
|
|
2072
2203
|
start: snapshot.position,
|
|
2073
2204
|
anchorStart: NO_RANGE$1,
|
|
2074
2205
|
anchorEnd: NO_RANGE$1,
|
|
2075
2206
|
tagStart: NO_RANGE$1,
|
|
2076
2207
|
tagEnd: NO_RANGE$1,
|
|
2077
|
-
style:
|
|
2208
|
+
style: COLLECTION_STYLE.FLOW
|
|
2078
2209
|
});
|
|
2079
2210
|
}
|
|
2080
|
-
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping =
|
|
2211
|
+
function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tagStart, tagEnd, style, chomping = CHOMPING_MODE.CLIP, indent = -1, fast = false) {
|
|
2081
2212
|
state.events.push({
|
|
2082
|
-
type:
|
|
2213
|
+
type: EVENT_ID.SCALAR,
|
|
2083
2214
|
valueStart,
|
|
2084
2215
|
valueEnd,
|
|
2085
2216
|
anchorStart,
|
|
@@ -2094,16 +2225,16 @@ function addScalarEvent(state, valueStart, valueEnd, anchorStart, anchorEnd, tag
|
|
|
2094
2225
|
}
|
|
2095
2226
|
function addAliasEvent(state, anchorStart, anchorEnd) {
|
|
2096
2227
|
state.events.push({
|
|
2097
|
-
type:
|
|
2228
|
+
type: EVENT_ID.ALIAS,
|
|
2098
2229
|
anchorStart,
|
|
2099
2230
|
anchorEnd
|
|
2100
2231
|
});
|
|
2101
2232
|
}
|
|
2102
2233
|
function addPopEvent(state) {
|
|
2103
|
-
state.events.push({ type:
|
|
2234
|
+
state.events.push({ type: EVENT_ID.POP });
|
|
2104
2235
|
}
|
|
2105
2236
|
function addEmptyScalarEvent(state) {
|
|
2106
|
-
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1,
|
|
2237
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, NO_RANGE$1, SCALAR_STYLE.PLAIN);
|
|
2107
2238
|
}
|
|
2108
2239
|
function emptyProperties() {
|
|
2109
2240
|
return {
|
|
@@ -2132,7 +2263,7 @@ function restoreState(state, snapshot) {
|
|
|
2132
2263
|
state.events.length = snapshot.eventsLength;
|
|
2133
2264
|
}
|
|
2134
2265
|
function throwError(state, message) {
|
|
2135
|
-
|
|
2266
|
+
YAMLException.throwAt(state.input.slice(0, state.length), state.position, message, state.filename);
|
|
2136
2267
|
}
|
|
2137
2268
|
function isEol(c) {
|
|
2138
2269
|
return c === 10 || c === 13;
|
|
@@ -2211,6 +2342,24 @@ function testDocumentSeparator(state, position = state.position) {
|
|
|
2211
2342
|
}
|
|
2212
2343
|
return false;
|
|
2213
2344
|
}
|
|
2345
|
+
function skipByteOrderMark(state) {
|
|
2346
|
+
if (state.position === state.lineStart && state.input.charCodeAt(state.position) === 65279) {
|
|
2347
|
+
state.position++;
|
|
2348
|
+
state.lineStart = state.position;
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
function testDocumentBoundary(state) {
|
|
2352
|
+
if (state.position !== state.lineStart) return false;
|
|
2353
|
+
if (testDocumentSeparator(state)) return true;
|
|
2354
|
+
if (state.input.charCodeAt(state.position) !== 65279) return false;
|
|
2355
|
+
const snapshot = snapshotState(state);
|
|
2356
|
+
skipByteOrderMark(state);
|
|
2357
|
+
skipSeparationSpace(state, true);
|
|
2358
|
+
const ch = state.input.charCodeAt(state.position);
|
|
2359
|
+
const result = state.position === state.lineStart && (ch === 37 || ch === 45 && testDocumentSeparator(state));
|
|
2360
|
+
restoreState(state, snapshot);
|
|
2361
|
+
return result;
|
|
2362
|
+
}
|
|
2214
2363
|
function skipUntilLineEnd(state) {
|
|
2215
2364
|
let ch = state.input.charCodeAt(state.position);
|
|
2216
2365
|
while (ch !== 0 && !isEol(ch)) ch = state.input.charCodeAt(++state.position);
|
|
@@ -2300,7 +2449,7 @@ function readSingleQuotedScalar(state, nodeIndent, props) {
|
|
|
2300
2449
|
}
|
|
2301
2450
|
const end = state.position;
|
|
2302
2451
|
state.position++;
|
|
2303
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2452
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.SINGLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
|
|
2304
2453
|
return true;
|
|
2305
2454
|
}
|
|
2306
2455
|
if (isEol(ch)) {
|
|
@@ -2322,7 +2471,7 @@ function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
|
2322
2471
|
if (ch === 34) {
|
|
2323
2472
|
const end = state.position;
|
|
2324
2473
|
state.position++;
|
|
2325
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2474
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.DOUBLE_QUOTED, CHOMPING_MODE.CLIP, -1, simple);
|
|
2326
2475
|
return true;
|
|
2327
2476
|
}
|
|
2328
2477
|
if (ch === 92) {
|
|
@@ -2350,18 +2499,18 @@ function readDoubleQuotedScalar(state, nodeIndent, props) {
|
|
|
2350
2499
|
}
|
|
2351
2500
|
function readBlockScalar(state, parentIndent, props) {
|
|
2352
2501
|
const ch = state.input.charCodeAt(state.position);
|
|
2353
|
-
let chomping =
|
|
2502
|
+
let chomping = CHOMPING_MODE.CLIP;
|
|
2354
2503
|
let indent = -1;
|
|
2355
2504
|
let detectedIndent = false;
|
|
2356
2505
|
if (ch !== 124 && ch !== 62) return false;
|
|
2357
|
-
const style = ch === 124 ?
|
|
2506
|
+
const style = ch === 124 ? SCALAR_STYLE.LITERAL_BLOCK : SCALAR_STYLE.FOLDED_BLOCK;
|
|
2358
2507
|
state.position++;
|
|
2359
2508
|
while (state.input.charCodeAt(state.position) !== 0) {
|
|
2360
2509
|
const current = state.input.charCodeAt(state.position);
|
|
2361
2510
|
const digit = fromDecimalCode(current);
|
|
2362
2511
|
if (current === 43 || current === 45) {
|
|
2363
|
-
if (chomping !==
|
|
2364
|
-
chomping = current === 43 ?
|
|
2512
|
+
if (chomping !== CHOMPING_MODE.CLIP) throwError(state, "repeat of a chomping mode identifier");
|
|
2513
|
+
chomping = current === 43 ? CHOMPING_MODE.KEEP : CHOMPING_MODE.STRIP;
|
|
2365
2514
|
state.position++;
|
|
2366
2515
|
} else if (digit >= 0) {
|
|
2367
2516
|
if (digit === 0) throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
@@ -2394,14 +2543,14 @@ function readBlockScalar(state, parentIndent, props) {
|
|
|
2394
2543
|
} else if (column > 0) valueEnd = linePosition + column;
|
|
2395
2544
|
break;
|
|
2396
2545
|
}
|
|
2397
|
-
if (
|
|
2546
|
+
if (testDocumentBoundary(state)) break;
|
|
2398
2547
|
if (!detectedIndent && contentIndent === -1 && isEol(first)) maxLeadingIndent = Math.max(maxLeadingIndent, column);
|
|
2399
2548
|
if (!detectedIndent && contentIndent === -1 && !isEol(first)) {
|
|
2400
2549
|
if (first === 9 && column < parentIndent) {
|
|
2401
2550
|
state.position = linePosition + column;
|
|
2402
2551
|
throwError(state, "tab characters must not be used in indentation");
|
|
2403
2552
|
}
|
|
2404
|
-
if (column < maxLeadingIndent) {
|
|
2553
|
+
if (column >= parentIndent && column < maxLeadingIndent) {
|
|
2405
2554
|
state.position = linePosition + column;
|
|
2406
2555
|
throwError(state, "bad indentation of a mapping entry");
|
|
2407
2556
|
}
|
|
@@ -2447,7 +2596,7 @@ function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
|
2447
2596
|
const inFlow = nodeContext === CONTEXT_FLOW_IN;
|
|
2448
2597
|
let multiline = false;
|
|
2449
2598
|
while (ch !== 0) {
|
|
2450
|
-
if (
|
|
2599
|
+
if (testDocumentBoundary(state)) break;
|
|
2451
2600
|
if (ch === 58) {
|
|
2452
2601
|
const following = state.input.charCodeAt(state.position + 1);
|
|
2453
2602
|
if (isWsOrEolOrEnd(following) || inFlow && isFlowIndicator(following)) break;
|
|
@@ -2476,7 +2625,7 @@ function readPlainScalar(state, nodeIndent, nodeContext, props) {
|
|
|
2476
2625
|
}
|
|
2477
2626
|
if (end === start) return false;
|
|
2478
2627
|
checkPrintable(state, start, end);
|
|
2479
|
-
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2628
|
+
addScalarEvent(state, start, end, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN, CHOMPING_MODE.CLIP, -1, !multiline);
|
|
2480
2629
|
return true;
|
|
2481
2630
|
}
|
|
2482
2631
|
function skipFlowSeparationSpace(state, nodeIndent) {
|
|
@@ -2491,8 +2640,8 @@ function readFlowCollection(state, nodeIndent, props) {
|
|
|
2491
2640
|
let readNext = true;
|
|
2492
2641
|
if (ch !== 91 && ch !== 123) return false;
|
|
2493
2642
|
const terminator = isMapping ? 125 : 93;
|
|
2494
|
-
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2495
|
-
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2643
|
+
if (isMapping) addMappingEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
|
|
2644
|
+
else addSequenceEvent(state, start, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.FLOW);
|
|
2496
2645
|
state.position++;
|
|
2497
2646
|
while (state.input.charCodeAt(state.position) !== 0) {
|
|
2498
2647
|
skipFlowSeparationSpace(state, nodeIndent);
|
|
@@ -2546,7 +2695,7 @@ function readFlowCollection(state, nodeIndent, props) {
|
|
|
2546
2695
|
}
|
|
2547
2696
|
function readBlockSequence(state, nodeIndent, props) {
|
|
2548
2697
|
if (state.firstTabInLine !== -1 || state.input.charCodeAt(state.position) !== 45 || !isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) return false;
|
|
2549
|
-
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2698
|
+
addSequenceEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2550
2699
|
while (state.input.charCodeAt(state.position) === 45 && isWsOrEolOrEnd(state.input.charCodeAt(state.position + 1))) {
|
|
2551
2700
|
if (state.firstTabInLine !== -1) {
|
|
2552
2701
|
state.position = state.firstTabInLine;
|
|
@@ -2582,7 +2731,7 @@ function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
|
2582
2731
|
const entryLine = state.line;
|
|
2583
2732
|
if ((ch === 63 || ch === 58) && isWsOrEolOrEnd(following)) {
|
|
2584
2733
|
if (!mappingOpened) {
|
|
2585
|
-
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2734
|
+
addMappingEvent(state, state.position, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, COLLECTION_STYLE.BLOCK);
|
|
2586
2735
|
mappingOpened = true;
|
|
2587
2736
|
}
|
|
2588
2737
|
if (ch === 63) {
|
|
@@ -2611,13 +2760,16 @@ function readBlockMapping(state, nodeIndent, flowIndent, props) {
|
|
|
2611
2760
|
ch = state.input.charCodeAt(++state.position);
|
|
2612
2761
|
if (!isWsOrEolOrEnd(ch)) throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
2613
2762
|
if (!mappingOpened) {
|
|
2614
|
-
|
|
2615
|
-
|
|
2763
|
+
state.events.splice(beforeKey.eventsLength, 0, {
|
|
2764
|
+
type: EVENT_ID.MAPPING,
|
|
2765
|
+
start: beforeKey.position,
|
|
2766
|
+
anchorStart: props.anchorStart,
|
|
2767
|
+
anchorEnd: props.anchorEnd,
|
|
2768
|
+
tagStart: props.tagStart,
|
|
2769
|
+
tagEnd: props.tagEnd,
|
|
2770
|
+
style: COLLECTION_STYLE.BLOCK
|
|
2771
|
+
});
|
|
2616
2772
|
mappingOpened = true;
|
|
2617
|
-
parseNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true);
|
|
2618
|
-
ch = state.input.charCodeAt(state.position);
|
|
2619
|
-
while (isWhiteSpace(ch)) ch = state.input.charCodeAt(++state.position);
|
|
2620
|
-
state.position++;
|
|
2621
2773
|
}
|
|
2622
2774
|
detected = true;
|
|
2623
2775
|
atExplicitKey = false;
|
|
@@ -2674,10 +2826,6 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2674
2826
|
else if (state.lineIndent === parentIndent) indentStatus = 0;
|
|
2675
2827
|
else indentStatus = -1;
|
|
2676
2828
|
}
|
|
2677
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2678
|
-
state.depth--;
|
|
2679
|
-
return false;
|
|
2680
|
-
}
|
|
2681
2829
|
if (indentStatus === 1) while (true) {
|
|
2682
2830
|
const ch = state.input.charCodeAt(state.position);
|
|
2683
2831
|
const propertyState = snapshotState(state);
|
|
@@ -2685,7 +2833,7 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2685
2833
|
if (atNewLine && allowBlockStyles && (props.tagStart !== NO_RANGE$1 || props.anchorStart !== NO_RANGE$1) && (ch === 33 || ch === 38)) {
|
|
2686
2834
|
const fallbackState = snapshotState(state);
|
|
2687
2835
|
const flowIndent = parentIndent + 1;
|
|
2688
|
-
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && ((_a = state.events[fallbackState.eventsLength]) == null ? void 0 : _a.type) ===
|
|
2836
|
+
if (readBlockMapping(state, state.position - state.lineStart, flowIndent, props) && ((_a = state.events[fallbackState.eventsLength]) == null ? void 0 : _a.type) === EVENT_ID.MAPPING) {
|
|
2689
2837
|
state.depth--;
|
|
2690
2838
|
return true;
|
|
2691
2839
|
}
|
|
@@ -2713,7 +2861,7 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2713
2861
|
const fallbackState = snapshotState(state);
|
|
2714
2862
|
const propertyIndent = propertyStart.position - propertyStart.lineStart;
|
|
2715
2863
|
restoreState(state, propertyStart);
|
|
2716
|
-
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && ((_b = state.events[fallbackState.eventsLength]) == null ? void 0 : _b.type) ===
|
|
2864
|
+
if (readBlockMapping(state, propertyIndent, flowIndent, emptyProperties()) && ((_b = state.events[fallbackState.eventsLength]) == null ? void 0 : _b.type) === EVENT_ID.MAPPING) hasContent = true;
|
|
2717
2865
|
else restoreState(state, fallbackState);
|
|
2718
2866
|
}
|
|
2719
2867
|
if (!hasContent && (allowBlockScalars && readBlockScalar(state, flowIndent, props) || readSingleQuotedScalar(state, flowIndent, props) || readDoubleQuotedScalar(state, flowIndent, props) || readAlias(state, props) || readPlainScalar(state, flowIndent, nodeContext, props))) hasContent = true;
|
|
@@ -2722,7 +2870,7 @@ function parseNode(state, parentIndent, nodeContext, allowToSeek, allowCompact,
|
|
|
2722
2870
|
}
|
|
2723
2871
|
allowBlockScalars = allowBlockScalars && !hasContent;
|
|
2724
2872
|
if (!hasContent && (props.anchorStart !== NO_RANGE$1 || props.tagStart !== NO_RANGE$1 || allowBlockScalars)) {
|
|
2725
|
-
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd,
|
|
2873
|
+
addScalarEvent(state, NO_RANGE$1, NO_RANGE$1, props.anchorStart, props.anchorEnd, props.tagStart, props.tagEnd, SCALAR_STYLE.PLAIN);
|
|
2726
2874
|
hasContent = true;
|
|
2727
2875
|
}
|
|
2728
2876
|
state.depth--;
|
|
@@ -2807,9 +2955,9 @@ function readDocument(state) {
|
|
|
2807
2955
|
}
|
|
2808
2956
|
}
|
|
2809
2957
|
const documentEvent = state.events[documentEventIndex];
|
|
2810
|
-
if ((documentEvent == null ? void 0 : documentEvent.type) ===
|
|
2958
|
+
if ((documentEvent == null ? void 0 : documentEvent.type) === EVENT_ID.DOCUMENT) documentEvent.explicitEnd = explicitEnd;
|
|
2811
2959
|
addPopEvent(state);
|
|
2812
|
-
if (!explicitEnd && state.position < state.length && !(state
|
|
2960
|
+
if (!explicitEnd && state.position < state.length && !testDocumentBoundary(state)) throwError(state, "end of the stream or a document separator is expected");
|
|
2813
2961
|
}
|
|
2814
2962
|
function parseEvents(input, options) {
|
|
2815
2963
|
const length = input.length;
|
|
@@ -2827,9 +2975,9 @@ function parseEvents(input, options) {
|
|
|
2827
2975
|
events: []
|
|
2828
2976
|
});
|
|
2829
2977
|
const nullpos = input.indexOf("\0");
|
|
2830
|
-
if (nullpos !== -1)
|
|
2831
|
-
if (state.input.charCodeAt(state.position) === 65279) state.position++;
|
|
2978
|
+
if (nullpos !== -1) YAMLException.throwAt(input, nullpos, "null byte is not allowed in input", state.filename);
|
|
2832
2979
|
while (state.position < state.length) {
|
|
2980
|
+
skipByteOrderMark(state);
|
|
2833
2981
|
skipSeparationSpace(state, true);
|
|
2834
2982
|
if (state.position >= state.length) break;
|
|
2835
2983
|
const documentStart = state.position;
|
|
@@ -2855,16 +3003,6 @@ function load(input, options) {
|
|
|
2855
3003
|
if (documents.length === 1) return documents[0];
|
|
2856
3004
|
throw new YAMLException("expected a single document in the stream, but found more");
|
|
2857
3005
|
}
|
|
2858
|
-
var Style = class {
|
|
2859
|
-
constructor() {
|
|
2860
|
-
_chunkN76BG37Wjs.__publicField.call(void 0, this, "tagged", false);
|
|
2861
|
-
_chunkN76BG37Wjs.__publicField.call(void 0, this, "flow", false);
|
|
2862
|
-
_chunkN76BG37Wjs.__publicField.call(void 0, this, "singleQuoted", false);
|
|
2863
|
-
_chunkN76BG37Wjs.__publicField.call(void 0, this, "doubleQuoted", false);
|
|
2864
|
-
_chunkN76BG37Wjs.__publicField.call(void 0, this, "literal", false);
|
|
2865
|
-
_chunkN76BG37Wjs.__publicField.call(void 0, this, "folded", false);
|
|
2866
|
-
}
|
|
2867
|
-
};
|
|
2868
3006
|
var INVALID = /* @__PURE__ */ Symbol("INVALID");
|
|
2869
3007
|
function buildRepresentTypes(schema) {
|
|
2870
3008
|
const defaultTags = new Set([
|
|
@@ -2893,9 +3031,9 @@ function buildRepresentTypes(schema) {
|
|
|
2893
3031
|
function matchTag(state, object) {
|
|
2894
3032
|
for (let index = 0, length = state.representTypes.length; index < length; index += 1) {
|
|
2895
3033
|
const { tag, implicitTag } = state.representTypes[index];
|
|
2896
|
-
if (tag.identify
|
|
3034
|
+
if (tag.identify(object)) {
|
|
2897
3035
|
let tagName;
|
|
2898
|
-
if (tag.matchByTagPrefix
|
|
3036
|
+
if (tag.matchByTagPrefix) tagName = tag.representTagName(object);
|
|
2899
3037
|
else tagName = tag.tagName;
|
|
2900
3038
|
return {
|
|
2901
3039
|
tag,
|
|
@@ -2913,8 +3051,6 @@ function build(state, object) {
|
|
|
2913
3051
|
if (existing.anchor === void 0) existing.anchor = `ref_${state.refCounter++}`;
|
|
2914
3052
|
return {
|
|
2915
3053
|
kind: "alias",
|
|
2916
|
-
tag: "",
|
|
2917
|
-
style: new Style(),
|
|
2918
3054
|
anchor: existing.anchor
|
|
2919
3055
|
};
|
|
2920
3056
|
}
|
|
@@ -2927,24 +3063,20 @@ function build(state, object) {
|
|
|
2927
3063
|
}
|
|
2928
3064
|
const { tag, tagName, implicitTag } = matched;
|
|
2929
3065
|
const nodeTagName = implicitTag ? tagName : tagNameShort(tagName);
|
|
2930
|
-
if (tag.nodeKind === "scalar") {
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
value: tag.represent(object)
|
|
2938
|
-
};
|
|
2939
|
-
}
|
|
3066
|
+
if (tag.nodeKind === "scalar") return {
|
|
3067
|
+
kind: "scalar",
|
|
3068
|
+
tag: nodeTagName,
|
|
3069
|
+
tagged: !implicitTag,
|
|
3070
|
+
style: SCALAR_STYLE.PLAIN,
|
|
3071
|
+
value: tag.represent(object)
|
|
3072
|
+
};
|
|
2940
3073
|
if (tag.nodeKind === "sequence") {
|
|
2941
3074
|
const container = tag.represent(object);
|
|
2942
|
-
const style2 = new Style();
|
|
2943
|
-
style2.tagged = !implicitTag;
|
|
2944
3075
|
const node2 = {
|
|
2945
3076
|
kind: "sequence",
|
|
2946
3077
|
tag: nodeTagName,
|
|
2947
|
-
|
|
3078
|
+
tagged: !implicitTag,
|
|
3079
|
+
style: COLLECTION_STYLE.BLOCK,
|
|
2948
3080
|
items: []
|
|
2949
3081
|
};
|
|
2950
3082
|
if (!state.noRefs) state.refs.set(object, node2);
|
|
@@ -2957,12 +3089,11 @@ function build(state, object) {
|
|
|
2957
3089
|
return node2;
|
|
2958
3090
|
}
|
|
2959
3091
|
const map = tag.represent(object);
|
|
2960
|
-
const style = new Style();
|
|
2961
|
-
style.tagged = !implicitTag;
|
|
2962
3092
|
const node = {
|
|
2963
3093
|
kind: "mapping",
|
|
2964
3094
|
tag: nodeTagName,
|
|
2965
|
-
|
|
3095
|
+
tagged: !implicitTag,
|
|
3096
|
+
style: COLLECTION_STYLE.BLOCK,
|
|
2966
3097
|
items: []
|
|
2967
3098
|
};
|
|
2968
3099
|
if (!state.noRefs) state.refs.set(object, node);
|
|
@@ -3031,79 +3162,204 @@ function visit(documents, visitor) {
|
|
|
3031
3162
|
isKey: false
|
|
3032
3163
|
})) return;
|
|
3033
3164
|
}
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
var
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3165
|
+
function hasBit(mask, bit) {
|
|
3166
|
+
return (mask & 1 << bit) !== 0;
|
|
3167
|
+
}
|
|
3168
|
+
var DEFAULT_SCALAR_STYLE_RULES = {
|
|
3169
|
+
applyQuoteFlowKeysOption,
|
|
3170
|
+
doubleQuoteForInvisibles,
|
|
3171
|
+
doubleQuoteWhitespaceOnly,
|
|
3172
|
+
applyForceQuotesOption,
|
|
3173
|
+
tryLongOrMultilineAsBlock,
|
|
3174
|
+
quoteInvalidPlain,
|
|
3175
|
+
fallbackToDoubleQuoted
|
|
3176
|
+
};
|
|
3177
|
+
function _preferredQuotedStyle(layout) {
|
|
3178
|
+
if (layout.presenterOptions.quoteStyle === "single" && hasBit(layout.allowedStylesMask, SCALAR_STYLE.SINGLE_QUOTED)) return SCALAR_STYLE.SINGLE_QUOTED;
|
|
3179
|
+
return SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3180
|
+
}
|
|
3181
|
+
function applyQuoteFlowKeysOption(layout) {
|
|
3182
|
+
if (!layout.presenterOptions.quoteFlowKeys) return;
|
|
3183
|
+
if (!layout.isKey || !layout.flowOnly || layout.style !== SCALAR_STYLE.PLAIN) return;
|
|
3184
|
+
layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3185
|
+
}
|
|
3186
|
+
function doubleQuoteForInvisibles(layout) {
|
|
3187
|
+
if (layout.style === SCALAR_STYLE.PLAIN && /[\t\x7F-\xA0\u2028\u2029\uFEFF\uFFFE\uFFFF]/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3188
|
+
}
|
|
3189
|
+
function doubleQuoteWhitespaceOnly(layout) {
|
|
3190
|
+
if (layout.style === SCALAR_STYLE.PLAIN && /^\s+$/.test(layout.node.value)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3191
|
+
}
|
|
3192
|
+
function applyForceQuotesOption(layout) {
|
|
3193
|
+
if (!layout.presenterOptions.forceQuotes) return;
|
|
3194
|
+
if (layout.isKey || layout.style !== SCALAR_STYLE.PLAIN) return;
|
|
3195
|
+
if (layout.node.tag !== layout.presenterOptions.schema.defaultScalarTag.tagName) return;
|
|
3196
|
+
layout.style = layout.node.value.includes("\n") ? SCALAR_STYLE.DOUBLE_QUOTED : _preferredQuotedStyle(layout);
|
|
3197
|
+
}
|
|
3198
|
+
function tryLongOrMultilineAsBlock(layout) {
|
|
3199
|
+
if (layout.style !== SCALAR_STYLE.PLAIN || layout.isKey) return;
|
|
3200
|
+
const value = layout.node.value;
|
|
3201
|
+
const multiline = value.indexOf("\n") !== -1;
|
|
3202
|
+
if (!hasBit(layout.allowedStylesMask, SCALAR_STYLE.LITERAL_BLOCK)) {
|
|
3203
|
+
if (multiline) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3204
|
+
return;
|
|
3205
|
+
}
|
|
3206
|
+
const w = layout.presenterOptions.lineWidth;
|
|
3207
|
+
if (w === -1) {
|
|
3208
|
+
if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
3209
|
+
return;
|
|
3210
|
+
}
|
|
3211
|
+
const availableWidth = Math.max(Math.min(w, 40), w - layout.shiftOfContent);
|
|
3212
|
+
let position = 0;
|
|
3213
|
+
let shouldFold = false;
|
|
3214
|
+
while (position <= value.length) {
|
|
3215
|
+
let lineEnd = value.length;
|
|
3216
|
+
const nextLineBreak = value.indexOf("\n", position);
|
|
3217
|
+
if (nextLineBreak !== -1) lineEnd = nextLineBreak;
|
|
3218
|
+
const line = value.slice(position, lineEnd);
|
|
3219
|
+
if (line.length > availableWidth && line[0] !== " " && / [^ \t]/.test(line)) shouldFold = true;
|
|
3220
|
+
if (nextLineBreak === -1) break;
|
|
3221
|
+
position = nextLineBreak + 1;
|
|
3222
|
+
}
|
|
3223
|
+
if (shouldFold) layout.style = SCALAR_STYLE.FOLDED_BLOCK;
|
|
3224
|
+
else if (multiline) layout.style = SCALAR_STYLE.LITERAL_BLOCK;
|
|
3225
|
+
}
|
|
3226
|
+
function quoteInvalidPlain(layout) {
|
|
3227
|
+
if (layout.style === SCALAR_STYLE.PLAIN && !hasBit(layout.allowedStylesMask, SCALAR_STYLE.PLAIN)) layout.style = _preferredQuotedStyle(layout);
|
|
3228
|
+
}
|
|
3229
|
+
function fallbackToDoubleQuoted(layout) {
|
|
3230
|
+
if (!hasBit(layout.allowedStylesMask, layout.style)) layout.style = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3231
|
+
}
|
|
3232
|
+
function setBit(mask, bit) {
|
|
3233
|
+
return mask | 1 << bit;
|
|
3234
|
+
}
|
|
3235
|
+
var SRC_C_PRINTABLE = "[\\x09\\x0A\\x0D\\x20-\\x7E\\x85\\xA0-\\uD7FF\\uE000-\\uFFFD\\u{10000}-\\u{10FFFF}]";
|
|
3236
|
+
var SRC_B_CHAR = "[\\n\\r]";
|
|
3237
|
+
var SRC_C_BYTE_ORDER_MARK = "\\uFEFF";
|
|
3238
|
+
var SRC_S_WHITE = "[ \\t]";
|
|
3239
|
+
var SRC_NB_CHAR = `(?:(?!(?:${SRC_B_CHAR}|${SRC_C_BYTE_ORDER_MARK}))${SRC_C_PRINTABLE})`;
|
|
3240
|
+
var SRC_NS_CHAR = `(?:(?!${SRC_S_WHITE})${SRC_NB_CHAR})`;
|
|
3241
|
+
var SRC_NB_JSON = "[\\x09\\x20-\\uD7FF\\uE000-\\uFFFF\\u{10000}-\\u{10FFFF}]";
|
|
3242
|
+
var SRC_C_INDICATOR = "[-?:,\\[\\]{}#&*!|>'\"%@`]";
|
|
3243
|
+
var SRC_C_FLOW_INDICATOR = "[,\\[\\]{}]";
|
|
3244
|
+
var SRC_NS_PLAIN_SAFE_FLOW_OUT = SRC_NS_CHAR;
|
|
3245
|
+
var SRC_NS_PLAIN_SAFE_FLOW_IN = `(?:(?!${SRC_C_FLOW_INDICATOR})${SRC_NS_CHAR})`;
|
|
3246
|
+
var SRC_NS_PLAIN_FIRST_FLOW_OUT = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))`;
|
|
3247
|
+
var SRC_NS_PLAIN_FIRST_FLOW_IN = `(?:(?:(?!${SRC_C_INDICATOR})${SRC_NS_CHAR})|[?:-](?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))`;
|
|
3248
|
+
var SRC_NS_PLAIN_CHAR_FLOW_OUT = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_OUT})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_OUT}))#*`;
|
|
3249
|
+
var SRC_NS_PLAIN_CHAR_FLOW_IN = `(?:(?:(?![:#])${SRC_NS_PLAIN_SAFE_FLOW_IN})|:(?=${SRC_NS_PLAIN_SAFE_FLOW_IN}))#*`;
|
|
3250
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_OUT})*`;
|
|
3251
|
+
var SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN = `(?:${SRC_S_WHITE}*${SRC_NS_PLAIN_CHAR_FLOW_IN})*`;
|
|
3252
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_OUT = `${SRC_NS_PLAIN_FIRST_FLOW_OUT}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
3253
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_IN = `${SRC_NS_PLAIN_FIRST_FLOW_IN}#*${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
3254
|
+
var SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_OUT;
|
|
3255
|
+
var SRC_NS_PLAIN_ONE_LINE_FLOW_KEY = SRC_NS_PLAIN_ONE_LINE_FLOW_IN;
|
|
3256
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_OUT}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_OUT}`;
|
|
3257
|
+
var SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN = `\\n+${SRC_NS_PLAIN_CHAR_FLOW_IN}${SRC_NB_NS_PLAIN_IN_LINE_FLOW_IN}`;
|
|
3258
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT = `${SRC_NS_PLAIN_ONE_LINE_FLOW_OUT}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_OUT})*`;
|
|
3259
|
+
var SRC_NS_PLAIN_MULTI_LINE_FLOW_IN = `${SRC_NS_PLAIN_ONE_LINE_FLOW_IN}(?:${SRC_S_NS_PLAIN_NEXT_LINE_FLOW_IN})*`;
|
|
3260
|
+
var NS_PLAIN_FLOW_OUT = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_OUT})$`, "u");
|
|
3261
|
+
var NS_PLAIN_FLOW_IN = new RegExp(`^(?:${SRC_NS_PLAIN_MULTI_LINE_FLOW_IN})$`, "u");
|
|
3262
|
+
var NS_PLAIN_BLOCK_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_BLOCK_KEY})$`, "u");
|
|
3263
|
+
var NS_PLAIN_FLOW_KEY = new RegExp(`^(?:${SRC_NS_PLAIN_ONE_LINE_FLOW_KEY})$`, "u");
|
|
3264
|
+
var NB_SINGLE_ONE_LINE = new RegExp(`^(?:${SRC_NB_JSON})*$`, "u");
|
|
3265
|
+
var NB_SINGLE_MULTI_LINE = new RegExp(`^(?:${SRC_NB_JSON}|\\n)*$`, "u");
|
|
3266
|
+
var BLOCK_SCALAR_CONTENT = new RegExp(`^(?:${SRC_NB_CHAR}|\\n)*$`, "u");
|
|
3267
|
+
var C_FORBIDDEN_FIRST_LINE = /^(?:---|\.\.\.)(?=$|[ \t\n\r])/;
|
|
3268
|
+
var C_FORBIDDEN_CONTENT = /^(?:---|\.\.\.)(?=$|[ \t\n\r])/m;
|
|
3269
|
+
function canUsePlain(layout) {
|
|
3270
|
+
const str = layout.node.value;
|
|
3271
|
+
if (str !== "") {
|
|
3272
|
+
if (!(layout.isKey ? layout.flowOnly ? NS_PLAIN_FLOW_KEY : NS_PLAIN_BLOCK_KEY : layout.flowOnly ? NS_PLAIN_FLOW_IN : NS_PLAIN_FLOW_OUT).test(str)) return false;
|
|
3273
|
+
if (layout.shiftOfFirstLine === 0 && C_FORBIDDEN_FIRST_LINE.test(str)) return false;
|
|
3274
|
+
if (layout.shiftOfContent === 0) {
|
|
3275
|
+
const firstLineBreak = str.indexOf("\n");
|
|
3276
|
+
if (firstLineBreak !== -1) {
|
|
3277
|
+
const content = str.slice(firstLineBreak + 1);
|
|
3278
|
+
if (C_FORBIDDEN_CONTENT.test(content)) return false;
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
const resolvedTag = layout.presenterOptions.schema.resolveImplicitScalarTag(str).tag.tagName;
|
|
3283
|
+
if (!layout.node.tagged && resolvedTag !== layout.node.tag) return false;
|
|
3284
|
+
if (!layout.node.tagged && str === "=" && resolvedTag === layout.presenterOptions.schema.defaultScalarTag.tagName) return false;
|
|
3285
|
+
return true;
|
|
3091
3286
|
}
|
|
3092
|
-
function
|
|
3093
|
-
const
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3287
|
+
function canUseSingleQuoted(layout) {
|
|
3288
|
+
const str = layout.node.value;
|
|
3289
|
+
if (!(layout.isKey ? NB_SINGLE_ONE_LINE : NB_SINGLE_MULTI_LINE).test(str)) return false;
|
|
3290
|
+
if (/[ \t]\n|\n[ \t]/.test(str)) return false;
|
|
3291
|
+
if (!layout.isKey && layout.shiftOfContent === 0) {
|
|
3292
|
+
const firstLineBreak = str.indexOf("\n");
|
|
3293
|
+
if (firstLineBreak !== -1 && C_FORBIDDEN_CONTENT.test(str.slice(firstLineBreak + 1))) return false;
|
|
3294
|
+
}
|
|
3295
|
+
return true;
|
|
3098
3296
|
}
|
|
3099
|
-
function
|
|
3100
|
-
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3103
|
-
|
|
3297
|
+
function canUseBlock(layout) {
|
|
3298
|
+
if (layout.flowOnly || !BLOCK_SCALAR_CONTENT.test(layout.node.value)) return false;
|
|
3299
|
+
const contentIndent = layout.shiftOfContent - layout.shiftOfParent;
|
|
3300
|
+
if (contentIndent < 1) return false;
|
|
3301
|
+
if (contentIndent > 9 && /^\n* /.test(layout.node.value)) return false;
|
|
3302
|
+
if (layout.shiftOfContent === 0 && C_FORBIDDEN_CONTENT.test(layout.node.value)) return false;
|
|
3303
|
+
return true;
|
|
3304
|
+
}
|
|
3305
|
+
function detectAllowedStyles(layout) {
|
|
3306
|
+
let mask = setBit(0, SCALAR_STYLE.DOUBLE_QUOTED);
|
|
3307
|
+
if (canUsePlain(layout)) mask = setBit(mask, SCALAR_STYLE.PLAIN);
|
|
3308
|
+
if (canUseSingleQuoted(layout)) mask = setBit(mask, SCALAR_STYLE.SINGLE_QUOTED);
|
|
3309
|
+
if (canUseBlock(layout)) mask = setBit(setBit(mask, SCALAR_STYLE.LITERAL_BLOCK), SCALAR_STYLE.FOLDED_BLOCK);
|
|
3310
|
+
layout.allowedStylesMask = mask;
|
|
3311
|
+
}
|
|
3312
|
+
function renderScalar(layout) {
|
|
3313
|
+
switch (layout.style) {
|
|
3314
|
+
case SCALAR_STYLE.PLAIN:
|
|
3315
|
+
return renderPlain(layout);
|
|
3316
|
+
case SCALAR_STYLE.SINGLE_QUOTED:
|
|
3317
|
+
return renderSingleQuoted(layout);
|
|
3318
|
+
case SCALAR_STYLE.LITERAL_BLOCK:
|
|
3319
|
+
return renderLiteralBlock(layout);
|
|
3320
|
+
case SCALAR_STYLE.FOLDED_BLOCK:
|
|
3321
|
+
return renderFoldedBlock(layout);
|
|
3322
|
+
case SCALAR_STYLE.DOUBLE_QUOTED:
|
|
3323
|
+
return renderDoubleQuoted(layout);
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
function renderPlain(layout) {
|
|
3327
|
+
return encodeFlowBreaks(layout.node.value, layout.shiftOfContent);
|
|
3328
|
+
}
|
|
3329
|
+
function renderSingleQuoted(layout) {
|
|
3330
|
+
return `'${encodeFlowBreaks(layout.node.value, layout.shiftOfContent).replace(/'/g, "''")}'`;
|
|
3331
|
+
}
|
|
3332
|
+
function renderLiteralBlock(layout) {
|
|
3333
|
+
const value = layout.node.value;
|
|
3334
|
+
return "|" + blockHeader(value, layout.shiftOfParent, layout.shiftOfContent) + dropEndingNewline(indentString(value, layout.shiftOfContent));
|
|
3335
|
+
}
|
|
3336
|
+
function renderFoldedBlock(layout) {
|
|
3337
|
+
const value = layout.node.value;
|
|
3338
|
+
const w = layout.presenterOptions.lineWidth;
|
|
3339
|
+
let availableWidth = Infinity;
|
|
3340
|
+
if (w !== -1) availableWidth = Math.max(Math.min(w, 40), w - layout.shiftOfContent);
|
|
3341
|
+
return ">" + blockHeader(value, layout.shiftOfParent, layout.shiftOfContent) + dropEndingNewline(indentString(foldBlockScalar(value, availableWidth), layout.shiftOfContent));
|
|
3342
|
+
}
|
|
3343
|
+
function renderDoubleQuoted(layout) {
|
|
3344
|
+
return `"${escapeString(layout.node.value)}"`;
|
|
3345
|
+
}
|
|
3346
|
+
function encodeFlowBreaks(string, shiftOfContent) {
|
|
3347
|
+
let nextLF = string.indexOf("\n");
|
|
3348
|
+
if (nextLF === -1) return string;
|
|
3349
|
+
const pad = " ".repeat(shiftOfContent);
|
|
3350
|
+
let result = string.slice(0, nextLF);
|
|
3351
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
|
3352
|
+
lineRe.lastIndex = nextLF;
|
|
3353
|
+
let match;
|
|
3354
|
+
while (match = lineRe.exec(string)) {
|
|
3355
|
+
const breaks = match[1].length;
|
|
3356
|
+
const line = match[2];
|
|
3357
|
+
result += "\n".repeat(breaks + 1) + pad + line;
|
|
3358
|
+
}
|
|
3359
|
+
return result;
|
|
3104
3360
|
}
|
|
3105
3361
|
function indentString(string, spaces) {
|
|
3106
|
-
const
|
|
3362
|
+
const indent = " ".repeat(spaces);
|
|
3107
3363
|
let position = 0;
|
|
3108
3364
|
let result = "";
|
|
3109
3365
|
const length = string.length;
|
|
@@ -3117,198 +3373,29 @@ function indentString(string, spaces) {
|
|
|
3117
3373
|
line = string.slice(position, next + 1);
|
|
3118
3374
|
position = next + 1;
|
|
3119
3375
|
}
|
|
3120
|
-
if (line.length && line !== "\n") result +=
|
|
3376
|
+
if (line.length && line !== "\n") result += indent;
|
|
3121
3377
|
result += line;
|
|
3122
3378
|
}
|
|
3123
3379
|
return result;
|
|
3124
3380
|
}
|
|
3125
|
-
function generateNextLine(state, level) {
|
|
3126
|
-
return `
|
|
3127
|
-
${" ".repeat(state.indent * level)}`;
|
|
3128
|
-
}
|
|
3129
|
-
function scalarLayout(state, level) {
|
|
3130
|
-
const indent = state.indent * Math.max(1, level);
|
|
3131
|
-
return {
|
|
3132
|
-
indent,
|
|
3133
|
-
blockIndent: level === 0 ? state.indent + 1 : state.indent,
|
|
3134
|
-
lineWidth: state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent)
|
|
3135
|
-
};
|
|
3136
|
-
}
|
|
3137
|
-
function resolveImplicitTag(state, str) {
|
|
3138
|
-
for (let index = 0, length = state.implicitResolvers.length; index < length; index += 1) {
|
|
3139
|
-
const tagDefinition = state.implicitResolvers[index];
|
|
3140
|
-
if (tagDefinition.resolve(str, false, tagDefinition.tagName) !== NOT_RESOLVED) return tagDefinition.tagName;
|
|
3141
|
-
}
|
|
3142
|
-
return state.defaultScalarTagName;
|
|
3143
|
-
}
|
|
3144
|
-
function isWhitespace(c) {
|
|
3145
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
3146
|
-
}
|
|
3147
|
-
function startsWithDocumentSeparator(string) {
|
|
3148
|
-
const marker = string.charCodeAt(0);
|
|
3149
|
-
if (marker !== CHAR_MINUS && marker !== 46 || string.charCodeAt(1) !== marker || string.charCodeAt(2) !== marker) return false;
|
|
3150
|
-
if (string.length === 3) return true;
|
|
3151
|
-
const following = string.charCodeAt(3);
|
|
3152
|
-
return isWhitespace(following) || following === CHAR_CARRIAGE_RETURN || following === CHAR_LINE_FEED;
|
|
3153
|
-
}
|
|
3154
|
-
function isPrintable(c) {
|
|
3155
|
-
return c >= 32 && c <= 126 || c >= 161 && c <= 55295 && c !== 8232 && c !== 8233 || c >= 57344 && c <= 65533 && c !== CHAR_BOM || c >= 65536 && c <= 1114111;
|
|
3156
|
-
}
|
|
3157
|
-
function isNsCharOrWhitespace(c) {
|
|
3158
|
-
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
3159
|
-
}
|
|
3160
|
-
function isPlainSafe(c, prev, inblock) {
|
|
3161
|
-
const cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
3162
|
-
const cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
3163
|
-
return (inblock ? cIsNsCharOrWhitespace : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar && (inblock || c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET);
|
|
3164
|
-
}
|
|
3165
|
-
function isPlainSafeFirst(c) {
|
|
3166
|
-
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
3167
|
-
}
|
|
3168
|
-
function isPlainSafeAtStart(string, inblock) {
|
|
3169
|
-
const first = codePointAt(string, 0);
|
|
3170
|
-
if (isPlainSafeFirst(first)) return true;
|
|
3171
|
-
if (string.length > 1 && (first === CHAR_MINUS || first === CHAR_QUESTION || first === CHAR_COLON)) {
|
|
3172
|
-
const second = codePointAt(string, 1);
|
|
3173
|
-
return !isWhitespace(second) && isPlainSafe(second, first, inblock);
|
|
3174
|
-
}
|
|
3175
|
-
return false;
|
|
3176
|
-
}
|
|
3177
|
-
function isPlainSafeLast(c) {
|
|
3178
|
-
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
3179
|
-
}
|
|
3180
|
-
function codePointAt(string, pos) {
|
|
3181
|
-
const first = string.charCodeAt(pos);
|
|
3182
|
-
let second;
|
|
3183
|
-
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
3184
|
-
second = string.charCodeAt(pos + 1);
|
|
3185
|
-
if (second >= 56320 && second <= 57343) return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
3186
|
-
}
|
|
3187
|
-
return first;
|
|
3188
|
-
}
|
|
3189
3381
|
function needIndentIndicator(string) {
|
|
3190
3382
|
return /^\n* /.test(string);
|
|
3191
3383
|
}
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
var STYLE_LITERAL = 3;
|
|
3195
|
-
var STYLE_FOLDED = 4;
|
|
3196
|
-
var STYLE_DOUBLE = 5;
|
|
3197
|
-
function chooseScalarStyle(state, string, layout, singleLineOnly, forceQuote, inblock) {
|
|
3198
|
-
const { blockIndent, lineWidth } = layout;
|
|
3199
|
-
let i;
|
|
3200
|
-
let char = 0;
|
|
3201
|
-
let prevChar = -1;
|
|
3202
|
-
let hasLineBreak = false;
|
|
3203
|
-
let hasFoldableLine = false;
|
|
3204
|
-
const shouldTrackWidth = lineWidth !== -1;
|
|
3205
|
-
let previousLineBreak = -1;
|
|
3206
|
-
let plain = !startsWithDocumentSeparator(string) && isPlainSafeAtStart(string, inblock) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
3207
|
-
if (singleLineOnly || forceQuote) for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
3208
|
-
char = codePointAt(string, i);
|
|
3209
|
-
if (!isPrintable(char)) return STYLE_DOUBLE;
|
|
3210
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
3211
|
-
prevChar = char;
|
|
3212
|
-
}
|
|
3213
|
-
else {
|
|
3214
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
3215
|
-
char = codePointAt(string, i);
|
|
3216
|
-
if (char === CHAR_LINE_FEED) {
|
|
3217
|
-
hasLineBreak = true;
|
|
3218
|
-
if (shouldTrackWidth) {
|
|
3219
|
-
hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
3220
|
-
previousLineBreak = i;
|
|
3221
|
-
}
|
|
3222
|
-
} else if (!isPrintable(char)) return STYLE_DOUBLE;
|
|
3223
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
3224
|
-
prevChar = char;
|
|
3225
|
-
}
|
|
3226
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
3227
|
-
}
|
|
3228
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
3229
|
-
if (plain && !forceQuote) return STYLE_PLAIN;
|
|
3230
|
-
return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
3231
|
-
}
|
|
3232
|
-
if (blockIndent > 9 && needIndentIndicator(string)) return STYLE_DOUBLE;
|
|
3233
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
3234
|
-
}
|
|
3235
|
-
function renderScalarStyle(string, style, layout) {
|
|
3236
|
-
const { indent, blockIndent, lineWidth } = layout;
|
|
3237
|
-
switch (style) {
|
|
3238
|
-
case STYLE_PLAIN:
|
|
3239
|
-
return encodeFlowBreaks(string, indent);
|
|
3240
|
-
case STYLE_SINGLE:
|
|
3241
|
-
return `'${encodeFlowBreaks(string, indent).replace(/'/g, "''")}'`;
|
|
3242
|
-
case STYLE_LITERAL:
|
|
3243
|
-
return "|" + blockHeader(string, blockIndent) + dropEndingNewline(indentString(string, indent));
|
|
3244
|
-
case STYLE_FOLDED:
|
|
3245
|
-
return ">" + blockHeader(string, blockIndent) + dropEndingNewline(indentString(foldBlockScalar(string, lineWidth), indent));
|
|
3246
|
-
case STYLE_DOUBLE:
|
|
3247
|
-
return `"${escapeString(string)}"`;
|
|
3248
|
-
}
|
|
3249
|
-
}
|
|
3250
|
-
function resolveScalarStyle(state, node, layout, iskey, inblock) {
|
|
3251
|
-
const singleLineOnly = iskey || !inblock;
|
|
3252
|
-
if (node.style.singleQuoted) return STYLE_SINGLE;
|
|
3253
|
-
if (node.style.doubleQuoted) return STYLE_DOUBLE;
|
|
3254
|
-
if (!singleLineOnly) {
|
|
3255
|
-
if (node.style.literal) return STYLE_LITERAL;
|
|
3256
|
-
if (node.style.folded) return STYLE_FOLDED;
|
|
3257
|
-
}
|
|
3258
|
-
const string = node.value;
|
|
3259
|
-
if (string.length === 0) {
|
|
3260
|
-
if (node.style.tagged || resolveImplicitTag(state, string) === node.tag) return STYLE_PLAIN;
|
|
3261
|
-
return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
3262
|
-
}
|
|
3263
|
-
const style = chooseScalarStyle(state, string, layout, singleLineOnly, state.forceQuotes && !iskey, inblock);
|
|
3264
|
-
if (style === STYLE_PLAIN && !node.style.tagged && resolveImplicitTag(state, string) !== node.tag) return state.quoteStyle === "double" ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
3265
|
-
return style;
|
|
3266
|
-
}
|
|
3267
|
-
function blockHeader(string, indentPerLevel) {
|
|
3268
|
-
const indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
3384
|
+
function blockHeader(string, shiftOfParent, shiftOfContent) {
|
|
3385
|
+
const indentIndicator = needIndentIndicator(string) ? String(shiftOfContent - shiftOfParent) : "";
|
|
3269
3386
|
const clip = string[string.length - 1] === "\n";
|
|
3270
3387
|
return `${indentIndicator}${clip && (string[string.length - 2] === "\n" || string === "\n") ? "+" : clip ? "" : "-"}
|
|
3271
3388
|
`;
|
|
3272
3389
|
}
|
|
3273
|
-
function encodeFlowBreaks(string, indent) {
|
|
3274
|
-
let nextLF = string.indexOf("\n");
|
|
3275
|
-
if (nextLF === -1) return string;
|
|
3276
|
-
const pad = " ".repeat(indent);
|
|
3277
|
-
let result = string.slice(0, nextLF);
|
|
3278
|
-
const lineRe = /(\n+)([^\n]*)/g;
|
|
3279
|
-
lineRe.lastIndex = nextLF;
|
|
3280
|
-
let match;
|
|
3281
|
-
while (match = lineRe.exec(string)) {
|
|
3282
|
-
const breaks = match[1].length;
|
|
3283
|
-
const line = match[2];
|
|
3284
|
-
result += "\n".repeat(breaks + 1) + pad + line;
|
|
3285
|
-
}
|
|
3286
|
-
return result;
|
|
3287
|
-
}
|
|
3288
3390
|
function dropEndingNewline(string) {
|
|
3289
3391
|
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
3290
3392
|
}
|
|
3291
|
-
function
|
|
3292
|
-
|
|
3293
|
-
let nextLF = string.indexOf("\n");
|
|
3294
|
-
if (nextLF === -1) nextLF = string.length;
|
|
3295
|
-
lineRe.lastIndex = nextLF;
|
|
3296
|
-
let result = foldLine(string.slice(0, nextLF), width);
|
|
3297
|
-
let prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
3298
|
-
let moreIndented;
|
|
3299
|
-
let match;
|
|
3300
|
-
while (match = lineRe.exec(string)) {
|
|
3301
|
-
const prefix = match[1];
|
|
3302
|
-
const line = match[2];
|
|
3303
|
-
moreIndented = line[0] === " ";
|
|
3304
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
3305
|
-
prevMoreIndented = moreIndented;
|
|
3306
|
-
}
|
|
3307
|
-
return result;
|
|
3393
|
+
function isMoreIndented(char) {
|
|
3394
|
+
return char === " " || char === " ";
|
|
3308
3395
|
}
|
|
3309
3396
|
function foldLine(line, width) {
|
|
3310
|
-
if (line === "" || line[0]
|
|
3311
|
-
const breakRe = / [^ ]/g;
|
|
3397
|
+
if (line === "" || isMoreIndented(line[0])) return line;
|
|
3398
|
+
const breakRe = / [^ \t]/g;
|
|
3312
3399
|
let match;
|
|
3313
3400
|
let start = 0;
|
|
3314
3401
|
let end;
|
|
@@ -3331,43 +3418,129 @@ ${line.slice(curr + 1)}`;
|
|
|
3331
3418
|
else result += line.slice(start);
|
|
3332
3419
|
return result.slice(1);
|
|
3333
3420
|
}
|
|
3334
|
-
function
|
|
3335
|
-
|
|
3336
|
-
let
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
result += encodeNonPrintable(char);
|
|
3421
|
+
function foldBlockScalar(string, width) {
|
|
3422
|
+
const lineRe = /(\n+)([^\n]*)/g;
|
|
3423
|
+
let nextLF = string.indexOf("\n");
|
|
3424
|
+
if (nextLF === -1) nextLF = string.length;
|
|
3425
|
+
lineRe.lastIndex = nextLF;
|
|
3426
|
+
let result = foldLine(string.slice(0, nextLF), width);
|
|
3427
|
+
let prevMoreIndented = string[0] === "\n" || isMoreIndented(string[0]);
|
|
3428
|
+
let moreIndented;
|
|
3429
|
+
let match;
|
|
3430
|
+
while (match = lineRe.exec(string)) {
|
|
3431
|
+
const prefix = match[1];
|
|
3432
|
+
const line = match[2];
|
|
3433
|
+
moreIndented = line !== "" && isMoreIndented(line[0]);
|
|
3434
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
3435
|
+
prevMoreIndented = moreIndented;
|
|
3350
3436
|
}
|
|
3351
3437
|
return result;
|
|
3352
3438
|
}
|
|
3439
|
+
var CHARACTERS_TO_ESCAPE = /["\\\x00-\x1F\x7F-\xA0\u2028\u2029\uD800-\uDFFF\uFEFF\uFFFE\uFFFF]/gu;
|
|
3440
|
+
function escapeCharacter(character) {
|
|
3441
|
+
switch (character) {
|
|
3442
|
+
case "\0":
|
|
3443
|
+
return "\\0";
|
|
3444
|
+
case "\x07":
|
|
3445
|
+
return "\\a";
|
|
3446
|
+
case "\b":
|
|
3447
|
+
return "\\b";
|
|
3448
|
+
case " ":
|
|
3449
|
+
return "\\t";
|
|
3450
|
+
case "\n":
|
|
3451
|
+
return "\\n";
|
|
3452
|
+
case "\v":
|
|
3453
|
+
return "\\v";
|
|
3454
|
+
case "\f":
|
|
3455
|
+
return "\\f";
|
|
3456
|
+
case "\r":
|
|
3457
|
+
return "\\r";
|
|
3458
|
+
case "\x1B":
|
|
3459
|
+
return "\\e";
|
|
3460
|
+
case '"':
|
|
3461
|
+
return '\\"';
|
|
3462
|
+
case "\\":
|
|
3463
|
+
return "\\\\";
|
|
3464
|
+
case "\x85":
|
|
3465
|
+
return "\\N";
|
|
3466
|
+
case "\xA0":
|
|
3467
|
+
return "\\_";
|
|
3468
|
+
case "\u2028":
|
|
3469
|
+
return "\\L";
|
|
3470
|
+
case "\u2029":
|
|
3471
|
+
return "\\P";
|
|
3472
|
+
}
|
|
3473
|
+
const code = character.charCodeAt(0);
|
|
3474
|
+
const hex = code.toString(16).toUpperCase();
|
|
3475
|
+
if (code <= 255) return `\\x${"0".repeat(2 - hex.length)}${hex}`;
|
|
3476
|
+
return `\\u${"0".repeat(4 - hex.length)}${hex}`;
|
|
3477
|
+
}
|
|
3478
|
+
function escapeString(string) {
|
|
3479
|
+
return string.replace(CHARACTERS_TO_ESCAPE, escapeCharacter);
|
|
3480
|
+
}
|
|
3481
|
+
var CHAR_LINE_FEED = 10;
|
|
3482
|
+
var DEFAULT_PRESENTER_OPTIONS = {
|
|
3483
|
+
indent: 2,
|
|
3484
|
+
seqNoIndent: false,
|
|
3485
|
+
seqInlineFirst: true,
|
|
3486
|
+
lineWidth: 80,
|
|
3487
|
+
flowBracketPadding: false,
|
|
3488
|
+
flowSkipCommaSpace: false,
|
|
3489
|
+
flowSkipColonSpace: false,
|
|
3490
|
+
quoteFlowKeys: false,
|
|
3491
|
+
quoteStyle: "single",
|
|
3492
|
+
forceQuotes: false,
|
|
3493
|
+
scalarStyleRules: Object.keys(DEFAULT_SCALAR_STYLE_RULES).map((name) => Reflect.get(DEFAULT_SCALAR_STYLE_RULES, name)),
|
|
3494
|
+
tagBeforeAnchor: false
|
|
3495
|
+
};
|
|
3496
|
+
function nodeTagShort(node) {
|
|
3497
|
+
return node.tagged ? node.tag : tagNameShort(node.tag);
|
|
3498
|
+
}
|
|
3499
|
+
function createPresenterState(options) {
|
|
3500
|
+
const opts = _chunkN76BG37Wjs.__spreadValues.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, DEFAULT_PRESENTER_OPTIONS), options);
|
|
3501
|
+
if (opts.flowSkipColonSpace) opts.quoteFlowKeys = true;
|
|
3502
|
+
return _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, opts), {
|
|
3503
|
+
defaultScalarTagName: opts.schema.defaultScalarTag.tagName,
|
|
3504
|
+
openEnded: false
|
|
3505
|
+
});
|
|
3506
|
+
}
|
|
3507
|
+
function generateNextLine(state, level) {
|
|
3508
|
+
return `
|
|
3509
|
+
${" ".repeat(state.indent * level)}`;
|
|
3510
|
+
}
|
|
3511
|
+
function scalarLayout(state, node, parent, level, isKey, flowOnly) {
|
|
3512
|
+
return {
|
|
3513
|
+
node,
|
|
3514
|
+
parent,
|
|
3515
|
+
level,
|
|
3516
|
+
isKey,
|
|
3517
|
+
flowOnly,
|
|
3518
|
+
shiftOfParent: level === 0 ? -1 : state.indent * (level - 1),
|
|
3519
|
+
shiftOfContent: state.indent * Math.max(1, level),
|
|
3520
|
+
shiftOfFirstLine: level === 0 ? 0 : state.indent * level,
|
|
3521
|
+
presenterOptions: state,
|
|
3522
|
+
allowedStylesMask: 0,
|
|
3523
|
+
style: node.style
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3353
3526
|
function writeFlowSequence(state, level, node) {
|
|
3354
3527
|
let result = "";
|
|
3355
3528
|
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
3356
|
-
const item = writeNode(state, level, node.items[index], {});
|
|
3357
|
-
if (
|
|
3529
|
+
const item = writeNode(state, level, node.items[index], node, {}).text;
|
|
3530
|
+
if (index > 0) result += `,${!state.flowSkipCommaSpace ? " " : ""}`;
|
|
3358
3531
|
result += item;
|
|
3359
3532
|
}
|
|
3360
|
-
const pad = state.flowBracketPadding &&
|
|
3533
|
+
const pad = state.flowBracketPadding && node.items.length > 0 ? " " : "";
|
|
3361
3534
|
return `[${pad}${result}${pad}]`;
|
|
3362
3535
|
}
|
|
3363
3536
|
function writeBlockSequence(state, level, node, compact) {
|
|
3364
3537
|
let result = "";
|
|
3365
3538
|
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
3366
|
-
const item = writeNode(state, level + 1, node.items[index], {
|
|
3539
|
+
const item = writeNode(state, level + 1, node.items[index], node, {
|
|
3367
3540
|
block: true,
|
|
3368
3541
|
compact: state.seqInlineFirst,
|
|
3369
3542
|
isblockseq: true
|
|
3370
|
-
});
|
|
3543
|
+
}).text;
|
|
3371
3544
|
if (!compact || result !== "") result += generateNextLine(state, level);
|
|
3372
3545
|
if (item === "" || CHAR_LINE_FEED === item.charCodeAt(0)) result += "-";
|
|
3373
3546
|
else result += "- ";
|
|
@@ -3377,70 +3550,51 @@ function writeBlockSequence(state, level, node, compact) {
|
|
|
3377
3550
|
}
|
|
3378
3551
|
function writeFlowMapping(state, level, node) {
|
|
3379
3552
|
let result = "";
|
|
3380
|
-
const
|
|
3381
|
-
for (const { key, value } of items) {
|
|
3553
|
+
for (const { key, value } of node.items) {
|
|
3382
3554
|
let pairBuffer = "";
|
|
3383
3555
|
if (result !== "") pairBuffer += `,${!state.flowSkipCommaSpace ? " " : ""}`;
|
|
3384
|
-
const
|
|
3385
|
-
const
|
|
3386
|
-
|
|
3387
|
-
else if (state.quoteFlowKeys) pairBuffer += '"';
|
|
3388
|
-
const valueText = writeNode(state, level, value, {});
|
|
3556
|
+
const keyRender = writeNode(state, level, key, node, { iskey: true });
|
|
3557
|
+
const keyText = keyRender.text;
|
|
3558
|
+
const valueText = writeNode(state, level, value, node, {}).text;
|
|
3389
3559
|
const sep = state.flowSkipColonSpace || valueText === "" ? "" : " ";
|
|
3390
|
-
|
|
3560
|
+
const keyIsBareProps = key.kind === "scalar" && keyRender.noBody && (key.tagged || key.anchor !== void 0);
|
|
3561
|
+
const keyColonSep = key.kind === "alias" || keyIsBareProps ? " " : "";
|
|
3562
|
+
pairBuffer += `${keyText}${keyColonSep}:${sep}${valueText}`;
|
|
3391
3563
|
result += pairBuffer;
|
|
3392
3564
|
}
|
|
3393
3565
|
const pad = state.flowBracketPadding && result !== "" ? " " : "";
|
|
3394
3566
|
return `{${pad}${result}${pad}}`;
|
|
3395
3567
|
}
|
|
3396
|
-
function sortKeyValue(key) {
|
|
3397
|
-
return key.kind === "scalar" ? key.value : key;
|
|
3398
|
-
}
|
|
3399
|
-
function sortMappingItems(state, items) {
|
|
3400
|
-
if (!state.sortKeys) return items;
|
|
3401
|
-
const copy = items.slice();
|
|
3402
|
-
if (state.sortKeys === true) copy.sort((a, b) => {
|
|
3403
|
-
const x = sortKeyValue(a.key);
|
|
3404
|
-
const y = sortKeyValue(b.key);
|
|
3405
|
-
if (x < y) return -1;
|
|
3406
|
-
if (x > y) return 1;
|
|
3407
|
-
return 0;
|
|
3408
|
-
});
|
|
3409
|
-
else {
|
|
3410
|
-
const fn = state.sortKeys;
|
|
3411
|
-
copy.sort((a, b) => fn(sortKeyValue(a.key), sortKeyValue(b.key)));
|
|
3412
|
-
}
|
|
3413
|
-
return copy;
|
|
3414
|
-
}
|
|
3415
3568
|
function writeBlockMapping(state, level, node, compact) {
|
|
3416
3569
|
let result = "";
|
|
3417
|
-
|
|
3418
|
-
for (let index = 0, length = items.length; index < length; index += 1) {
|
|
3570
|
+
for (let index = 0, length = node.items.length; index < length; index += 1) {
|
|
3419
3571
|
let pairBuffer = "";
|
|
3420
3572
|
if (!compact || result !== "") pairBuffer += generateNextLine(state, level);
|
|
3421
|
-
const { key, value } = items[index];
|
|
3422
|
-
const keyIsBlock = (key.kind === "mapping" || key.kind === "sequence") &&
|
|
3423
|
-
const
|
|
3573
|
+
const { key, value } = node.items[index];
|
|
3574
|
+
const keyIsBlock = (key.kind === "mapping" || key.kind === "sequence") && key.style === COLLECTION_STYLE.BLOCK && key.items.length !== 0 || key.kind === "scalar" && (key.style === SCALAR_STYLE.LITERAL_BLOCK || key.style === SCALAR_STYLE.FOLDED_BLOCK);
|
|
3575
|
+
const keyRender = keyIsBlock ? writeNode(state, level + 1, key, node, {
|
|
3424
3576
|
block: true,
|
|
3425
3577
|
compact: true,
|
|
3426
3578
|
isblockseq: !cannotBeCompact(state, key, level + 1)
|
|
3427
|
-
}) : writeNode(state, level + 1, key, {
|
|
3579
|
+
}) : writeNode(state, level + 1, key, node, {
|
|
3428
3580
|
block: true,
|
|
3429
3581
|
compact: true,
|
|
3430
3582
|
iskey: true
|
|
3431
3583
|
});
|
|
3584
|
+
const keyText = keyRender.text;
|
|
3432
3585
|
const keyHasLineBreak = key.kind === "scalar" && key.value.indexOf("\n") !== -1;
|
|
3433
|
-
const
|
|
3586
|
+
const keyIsTooLong = keyText.length > 1024 && /^[\s\S]{1025}/u.test(keyText);
|
|
3587
|
+
const explicitPair = keyIsBlock || keyHasLineBreak || keyIsTooLong;
|
|
3434
3588
|
if (explicitPair) if (keyText && CHAR_LINE_FEED === keyText.charCodeAt(0)) pairBuffer += "?";
|
|
3435
3589
|
else pairBuffer += "? ";
|
|
3436
3590
|
pairBuffer += keyText;
|
|
3437
3591
|
if (explicitPair) pairBuffer += generateNextLine(state, level);
|
|
3438
|
-
const valueText = writeNode(state, level + 1, value, {
|
|
3592
|
+
const valueText = writeNode(state, level + 1, value, node, {
|
|
3439
3593
|
block: true,
|
|
3440
3594
|
compact: explicitPair,
|
|
3441
3595
|
isblockseq: explicitPair && !cannotBeCompact(state, value, level + 1)
|
|
3442
|
-
});
|
|
3443
|
-
const keyIsBareProps = key.kind === "scalar" &&
|
|
3596
|
+
}).text;
|
|
3597
|
+
const keyIsBareProps = key.kind === "scalar" && keyRender.noBody && (key.tagged || key.anchor !== void 0);
|
|
3444
3598
|
const keyColonSep = !explicitPair && (key.kind === "alias" || keyIsBareProps) ? " " : "";
|
|
3445
3599
|
if (valueText === "" || CHAR_LINE_FEED === valueText.charCodeAt(0)) pairBuffer += `${keyColonSep}:`;
|
|
3446
3600
|
else pairBuffer += `${keyColonSep}: `;
|
|
@@ -3450,30 +3604,42 @@ function writeBlockMapping(state, level, node, compact) {
|
|
|
3450
3604
|
return result;
|
|
3451
3605
|
}
|
|
3452
3606
|
function cannotBeCompact(state, node, level) {
|
|
3453
|
-
|
|
3607
|
+
if (node.kind === "alias") return true;
|
|
3608
|
+
return node.tagged || node.anchor !== void 0 || state.indent < 2 && level > 0;
|
|
3454
3609
|
}
|
|
3455
|
-
function writeNode(state, level, node, ctx) {
|
|
3610
|
+
function writeNode(state, level, node, parent, ctx) {
|
|
3456
3611
|
var _a;
|
|
3457
|
-
if (node.kind === "alias")
|
|
3612
|
+
if (node.kind === "alias") {
|
|
3613
|
+
state.openEnded = false;
|
|
3614
|
+
return {
|
|
3615
|
+
text: `*${node.anchor}`,
|
|
3616
|
+
noBody: false
|
|
3617
|
+
};
|
|
3618
|
+
}
|
|
3458
3619
|
const { block = false, iskey = false, isblockseq = false } = ctx;
|
|
3459
3620
|
let compact = (_a = ctx.compact) != null ? _a : false;
|
|
3460
3621
|
const hasAnchor = node.anchor !== void 0;
|
|
3461
3622
|
if (cannotBeCompact(state, node, level)) compact = false;
|
|
3462
3623
|
let body;
|
|
3463
|
-
let shouldPrintTag = node.
|
|
3464
|
-
const useBlockCollection = block && (node.kind === "mapping" || node.kind === "sequence") &&
|
|
3624
|
+
let shouldPrintTag = node.tagged;
|
|
3625
|
+
const useBlockCollection = block && (node.kind === "mapping" || node.kind === "sequence") && node.style === COLLECTION_STYLE.BLOCK && node.items.length !== 0;
|
|
3465
3626
|
if (node.kind === "mapping") if (useBlockCollection) body = writeBlockMapping(state, level, node, compact);
|
|
3466
3627
|
else body = writeFlowMapping(state, level, node);
|
|
3467
3628
|
else if (node.kind === "sequence") if (useBlockCollection) if (state.seqNoIndent && !isblockseq && level > 0) body = writeBlockSequence(state, level - 1, node, compact);
|
|
3468
3629
|
else body = writeBlockSequence(state, level, node, compact);
|
|
3469
3630
|
else body = writeFlowSequence(state, level, node);
|
|
3470
3631
|
else {
|
|
3471
|
-
const layout = scalarLayout(state, level);
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3632
|
+
const layout = scalarLayout(state, node, parent, level, iskey, !block);
|
|
3633
|
+
detectAllowedStyles(layout);
|
|
3634
|
+
for (const rule of state.scalarStyleRules) rule(layout);
|
|
3635
|
+
body = renderScalar(layout);
|
|
3636
|
+
state.openEnded = (layout.style === SCALAR_STYLE.LITERAL_BLOCK || layout.style === SCALAR_STYLE.FOLDED_BLOCK) && (node.value === "\n" || node.value.endsWith("\n\n"));
|
|
3637
|
+
shouldPrintTag = node.tagged || body === "" && layout.flowOnly && (parent == null ? void 0 : parent.kind) === "sequence" && !hasAnchor || layout.style !== SCALAR_STYLE.PLAIN && node.tag !== state.defaultScalarTagName;
|
|
3638
|
+
}
|
|
3639
|
+
if ((node.kind === "mapping" || node.kind === "sequence") && !useBlockCollection) state.openEnded = false;
|
|
3476
3640
|
if (useBlockCollection && compact && level > 0 && state.indent > 2) body = `${" ".repeat(state.indent - 2)}${body}`;
|
|
3641
|
+
const noBody = body === "";
|
|
3642
|
+
let text = body;
|
|
3477
3643
|
if (shouldPrintTag || hasAnchor) {
|
|
3478
3644
|
const props = [];
|
|
3479
3645
|
const tag = shouldPrintTag ? nodeTagShort(node) : null;
|
|
@@ -3486,19 +3652,15 @@ function writeNode(state, level, node, ctx) {
|
|
|
3486
3652
|
if (tag !== null) props.push(tag);
|
|
3487
3653
|
}
|
|
3488
3654
|
const sep = body === "" || body.charCodeAt(0) === CHAR_LINE_FEED ? "" : " ";
|
|
3489
|
-
|
|
3655
|
+
text = `${props.join(" ")}${sep}${body}`;
|
|
3490
3656
|
}
|
|
3491
|
-
return
|
|
3657
|
+
return {
|
|
3658
|
+
text,
|
|
3659
|
+
noBody
|
|
3660
|
+
};
|
|
3492
3661
|
}
|
|
3493
3662
|
function rootStartsOwnLine(node) {
|
|
3494
|
-
return (node.kind === "sequence" || node.kind === "mapping") &&
|
|
3495
|
-
}
|
|
3496
|
-
function isOpenEnded(node) {
|
|
3497
|
-
let leaf = node;
|
|
3498
|
-
while ((leaf.kind === "sequence" || leaf.kind === "mapping") && !leaf.style.flow && leaf.items.length !== 0) leaf = leaf.kind === "sequence" ? leaf.items[leaf.items.length - 1] : leaf.items[leaf.items.length - 1].value;
|
|
3499
|
-
if (leaf.kind !== "scalar" || !(leaf.style.literal || leaf.style.folded)) return false;
|
|
3500
|
-
const { value } = leaf;
|
|
3501
|
-
return value.endsWith("\n\n") || value === "\n";
|
|
3663
|
+
return (node.kind === "sequence" || node.kind === "mapping") && node.style === COLLECTION_STYLE.BLOCK && node.items.length !== 0 && !node.tagged && node.anchor === void 0;
|
|
3502
3664
|
}
|
|
3503
3665
|
function writeDocumentDirectives(doc) {
|
|
3504
3666
|
let result = "";
|
|
@@ -3520,6 +3682,7 @@ function present(documents, options) {
|
|
|
3520
3682
|
let previousEnded = false;
|
|
3521
3683
|
for (let index = 0; index < documents.length; index += 1) {
|
|
3522
3684
|
const doc = documents[index];
|
|
3685
|
+
state.openEnded = false;
|
|
3523
3686
|
const directives = writeDocumentDirectives(doc);
|
|
3524
3687
|
const hasDirectives = directives !== "";
|
|
3525
3688
|
const marker = doc.explicitStart || hasDirectives || index > 0 && !previousEnded;
|
|
@@ -3527,41 +3690,38 @@ function present(documents, options) {
|
|
|
3527
3690
|
if (doc.contents === null) {
|
|
3528
3691
|
if (marker) result += "---\n";
|
|
3529
3692
|
} else if (marker) {
|
|
3530
|
-
const body = writeNode(state, 0, doc.contents, {
|
|
3693
|
+
const body = writeNode(state, 0, doc.contents, null, {
|
|
3531
3694
|
block: true,
|
|
3532
3695
|
compact: true
|
|
3533
|
-
});
|
|
3696
|
+
}).text;
|
|
3534
3697
|
const sep = body === "" ? "" : hasDirectives || rootStartsOwnLine(doc.contents) ? "\n" : " ";
|
|
3535
3698
|
result += `---${sep}${body}
|
|
3536
3699
|
`;
|
|
3537
|
-
} else result += writeNode(state, 0, doc.contents, {
|
|
3700
|
+
} else result += writeNode(state, 0, doc.contents, null, {
|
|
3538
3701
|
block: true,
|
|
3539
3702
|
compact: true
|
|
3540
|
-
}) + "\n";
|
|
3541
|
-
previousEnded = doc.explicitEnd ||
|
|
3703
|
+
}).text + "\n";
|
|
3704
|
+
previousEnded = doc.explicitEnd || state.openEnded;
|
|
3542
3705
|
if (previousEnded) result += "...\n";
|
|
3543
3706
|
}
|
|
3544
3707
|
return result;
|
|
3545
3708
|
}
|
|
3546
|
-
var DEFAULT_DUMP_SCHEMA = YAML11_SCHEMA.withTags(_chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, intYaml11Tag), {
|
|
3547
|
-
resolve: (source, isExplicit, tagName) => {
|
|
3548
|
-
const result = intYaml11Tag.resolve(source, isExplicit, tagName);
|
|
3549
|
-
return result === NOT_RESOLVED ? intCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
3550
|
-
}
|
|
3551
|
-
}), _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, floatYaml11Tag), {
|
|
3552
|
-
resolve: (source, isExplicit, tagName) => {
|
|
3553
|
-
const result = floatYaml11Tag.resolve(source, isExplicit, tagName);
|
|
3554
|
-
return result === NOT_RESOLVED ? floatCoreTag.resolve(source, isExplicit, tagName) : result;
|
|
3555
|
-
}
|
|
3556
|
-
}));
|
|
3557
3709
|
var DEFAULT_DUMP_OPTIONS = _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, DEFAULT_PRESENTER_OPTIONS), {
|
|
3558
|
-
schema:
|
|
3710
|
+
schema: DUMP_SCHEMA,
|
|
3559
3711
|
skipInvalid: false,
|
|
3560
3712
|
noRefs: false,
|
|
3561
3713
|
flowLevel: -1,
|
|
3714
|
+
sortKeys: false,
|
|
3562
3715
|
transform: () => {
|
|
3563
3716
|
}
|
|
3564
3717
|
});
|
|
3718
|
+
function defaultCompareFn(a, b) {
|
|
3719
|
+
const x = String(a);
|
|
3720
|
+
const y = String(b);
|
|
3721
|
+
if (x < y) return -1;
|
|
3722
|
+
if (x > y) return 1;
|
|
3723
|
+
return 0;
|
|
3724
|
+
}
|
|
3565
3725
|
function dump(input, options = {}) {
|
|
3566
3726
|
const opts = _chunkN76BG37Wjs.__spreadValues.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, DEFAULT_DUMP_OPTIONS), options);
|
|
3567
3727
|
const documents = jsToAst(input, opts.schema, {
|
|
@@ -3570,14 +3730,37 @@ function dump(input, options = {}) {
|
|
|
3570
3730
|
});
|
|
3571
3731
|
if (opts.flowLevel >= 0) visit(documents, (node, ctx) => {
|
|
3572
3732
|
if (ctx.depth < opts.flowLevel) return;
|
|
3573
|
-
node.
|
|
3733
|
+
if (node.kind === "sequence" || node.kind === "mapping") node.style = COLLECTION_STYLE.FLOW;
|
|
3574
3734
|
return VISIT_SKIP;
|
|
3575
3735
|
});
|
|
3736
|
+
if (opts.sortKeys) {
|
|
3737
|
+
const compareFn = opts.sortKeys === true ? defaultCompareFn : opts.sortKeys;
|
|
3738
|
+
visit(documents, (node) => {
|
|
3739
|
+
if (node.kind !== "mapping") return;
|
|
3740
|
+
node.items.sort((a, b) => compareFn(a.key.kind === "scalar" ? a.key.value : "", b.key.kind === "scalar" ? b.key.value : ""));
|
|
3741
|
+
});
|
|
3742
|
+
}
|
|
3576
3743
|
opts.transform(documents);
|
|
3577
3744
|
return present(documents, _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, pick(opts, Object.keys(DEFAULT_PRESENTER_OPTIONS))), {
|
|
3578
3745
|
schema: opts.schema
|
|
3579
3746
|
}));
|
|
3580
3747
|
}
|
|
3748
|
+
var EVENT_DOCUMENT = EVENT_ID.DOCUMENT;
|
|
3749
|
+
var EVENT_SEQUENCE = EVENT_ID.SEQUENCE;
|
|
3750
|
+
var EVENT_MAPPING = EVENT_ID.MAPPING;
|
|
3751
|
+
var EVENT_SCALAR = EVENT_ID.SCALAR;
|
|
3752
|
+
var EVENT_ALIAS = EVENT_ID.ALIAS;
|
|
3753
|
+
var EVENT_POP = EVENT_ID.POP;
|
|
3754
|
+
var SCALAR_STYLE_PLAIN = SCALAR_STYLE.PLAIN;
|
|
3755
|
+
var SCALAR_STYLE_SINGLE_QUOTED = SCALAR_STYLE.SINGLE_QUOTED;
|
|
3756
|
+
var SCALAR_STYLE_DOUBLE_QUOTED = SCALAR_STYLE.DOUBLE_QUOTED;
|
|
3757
|
+
var SCALAR_STYLE_LITERAL_BLOCK = SCALAR_STYLE.LITERAL_BLOCK;
|
|
3758
|
+
var SCALAR_STYLE_FOLDED_BLOCK = SCALAR_STYLE.FOLDED_BLOCK;
|
|
3759
|
+
var COLLECTION_STYLE_BLOCK = COLLECTION_STYLE.BLOCK;
|
|
3760
|
+
var COLLECTION_STYLE_FLOW = COLLECTION_STYLE.FLOW;
|
|
3761
|
+
var CHOMPING_CLIP = CHOMPING_MODE.CLIP;
|
|
3762
|
+
var CHOMPING_STRIP = CHOMPING_MODE.STRIP;
|
|
3763
|
+
var CHOMPING_KEEP = CHOMPING_MODE.KEEP;
|
|
3581
3764
|
|
|
3582
3765
|
// src/cli/utils/responseFormat.ts
|
|
3583
3766
|
var DEFAULT_TEXT_OUTPUT = {
|
|
@@ -3987,23 +4170,23 @@ function formatTopLevelMessage(body, fromMessage, fromError) {
|
|
|
3987
4170
|
}
|
|
3988
4171
|
|
|
3989
4172
|
// src/cli/types-prompt.ts
|
|
3990
|
-
var jsonValueSchema =
|
|
3991
|
-
var localPromptConfigSchema =
|
|
3992
|
-
model:
|
|
3993
|
-
modelParameters:
|
|
3994
|
-
temperature:
|
|
3995
|
-
max_tokens:
|
|
4173
|
+
var jsonValueSchema = _chunkF7BVJW3Sjs.external_exports.json();
|
|
4174
|
+
var localPromptConfigSchema = _chunkF7BVJW3Sjs.external_exports.object({
|
|
4175
|
+
model: _chunkF7BVJW3Sjs.external_exports.string().min(1, "Model is required"),
|
|
4176
|
+
modelParameters: _chunkF7BVJW3Sjs.external_exports.object({
|
|
4177
|
+
temperature: _chunkF7BVJW3Sjs.external_exports.number().optional(),
|
|
4178
|
+
max_tokens: _chunkF7BVJW3Sjs.external_exports.number().optional()
|
|
3996
4179
|
}).loose().optional(),
|
|
3997
|
-
messages:
|
|
3998
|
-
|
|
3999
|
-
role:
|
|
4000
|
-
content:
|
|
4180
|
+
messages: _chunkF7BVJW3Sjs.external_exports.array(
|
|
4181
|
+
_chunkF7BVJW3Sjs.external_exports.object({
|
|
4182
|
+
role: _chunkF7BVJW3Sjs.external_exports.enum(["system", "user", "assistant"]),
|
|
4183
|
+
content: _chunkF7BVJW3Sjs.external_exports.string().min(1, "Message content cannot be empty")
|
|
4001
4184
|
}).loose()
|
|
4002
4185
|
).min(1, "At least one message is required"),
|
|
4003
4186
|
// Parameters persist as JSON: parse them AS json so the value's type
|
|
4004
4187
|
// matches the API contract (the spec's recursive JsonValue) instead of
|
|
4005
4188
|
// laundering unknowns into a typed pipeline.
|
|
4006
|
-
parameters:
|
|
4189
|
+
parameters: _chunkF7BVJW3Sjs.external_exports.record(_chunkF7BVJW3Sjs.external_exports.string(), jsonValueSchema).optional().default({})
|
|
4007
4190
|
}).loose();
|
|
4008
4191
|
|
|
4009
4192
|
// src/cli/utils/fileManager.ts
|
|
@@ -4480,34 +4663,34 @@ var PromptScope = {
|
|
|
4480
4663
|
};
|
|
4481
4664
|
|
|
4482
4665
|
// src/client-sdk/services/prompts/schema/prompt.schema.ts
|
|
4483
|
-
var messageSchema =
|
|
4484
|
-
role:
|
|
4485
|
-
content:
|
|
4666
|
+
var messageSchema = _chunkF7BVJW3Sjs.external_exports.object({
|
|
4667
|
+
role: _chunkF7BVJW3Sjs.external_exports.enum(["user", "assistant", "system"]),
|
|
4668
|
+
content: _chunkF7BVJW3Sjs.external_exports.string()
|
|
4486
4669
|
});
|
|
4487
|
-
var responseFormatSchema =
|
|
4488
|
-
type:
|
|
4489
|
-
json_schema:
|
|
4490
|
-
name:
|
|
4491
|
-
schema:
|
|
4670
|
+
var responseFormatSchema = _chunkF7BVJW3Sjs.external_exports.object({
|
|
4671
|
+
type: _chunkF7BVJW3Sjs.external_exports.literal("json_schema"),
|
|
4672
|
+
json_schema: _chunkF7BVJW3Sjs.external_exports.object({
|
|
4673
|
+
name: _chunkF7BVJW3Sjs.external_exports.string(),
|
|
4674
|
+
schema: _chunkF7BVJW3Sjs.external_exports.record(_chunkF7BVJW3Sjs.external_exports.string(), _chunkF7BVJW3Sjs.external_exports.unknown())
|
|
4492
4675
|
}).nullable()
|
|
4493
4676
|
}).optional();
|
|
4494
|
-
var corePromptDataSchema =
|
|
4495
|
-
model:
|
|
4496
|
-
messages:
|
|
4497
|
-
prompt:
|
|
4498
|
-
temperature:
|
|
4499
|
-
maxTokens:
|
|
4677
|
+
var corePromptDataSchema = _chunkF7BVJW3Sjs.external_exports.object({
|
|
4678
|
+
model: _chunkF7BVJW3Sjs.external_exports.string().min(1, "Model cannot be empty"),
|
|
4679
|
+
messages: _chunkF7BVJW3Sjs.external_exports.array(messageSchema).min(1, "At least one message is required"),
|
|
4680
|
+
prompt: _chunkF7BVJW3Sjs.external_exports.string().optional(),
|
|
4681
|
+
temperature: _chunkF7BVJW3Sjs.external_exports.number().min(0).max(2).optional(),
|
|
4682
|
+
maxTokens: _chunkF7BVJW3Sjs.external_exports.number().positive().optional(),
|
|
4500
4683
|
responseFormat: responseFormatSchema
|
|
4501
4684
|
});
|
|
4502
|
-
var promptMetadataSchema =
|
|
4503
|
-
id:
|
|
4504
|
-
handle:
|
|
4505
|
-
version:
|
|
4506
|
-
versionId:
|
|
4507
|
-
scope:
|
|
4685
|
+
var promptMetadataSchema = _chunkF7BVJW3Sjs.external_exports.object({
|
|
4686
|
+
id: _chunkF7BVJW3Sjs.external_exports.string().optional(),
|
|
4687
|
+
handle: _chunkF7BVJW3Sjs.external_exports.string().nullable().optional(),
|
|
4688
|
+
version: _chunkF7BVJW3Sjs.external_exports.number().min(0).optional(),
|
|
4689
|
+
versionId: _chunkF7BVJW3Sjs.external_exports.string().optional(),
|
|
4690
|
+
scope: _chunkF7BVJW3Sjs.external_exports.enum(PromptScope).optional()
|
|
4508
4691
|
});
|
|
4509
|
-
var promptDataSchema =
|
|
4510
|
-
parameters:
|
|
4692
|
+
var promptDataSchema = _chunkF7BVJW3Sjs.external_exports.object(_chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, corePromptDataSchema.shape), promptMetadataSchema.shape), {
|
|
4693
|
+
parameters: _chunkF7BVJW3Sjs.external_exports.record(_chunkF7BVJW3Sjs.external_exports.string(), _chunkF7BVJW3Sjs.external_exports.unknown()).optional()
|
|
4511
4694
|
}));
|
|
4512
4695
|
|
|
4513
4696
|
// src/client-sdk/services/prompts/tracing/prompt-tracing.decorator.ts
|
|
@@ -4638,9 +4821,9 @@ var PromptServiceTracingDecorator = class {
|
|
|
4638
4821
|
};
|
|
4639
4822
|
|
|
4640
4823
|
// src/client-sdk/services/prompts/tracing/tracer.ts
|
|
4641
|
-
var tracer =
|
|
4642
|
-
`${
|
|
4643
|
-
|
|
4824
|
+
var tracer = _chunkF7BVJW3Sjs.getLangWatchTracer.call(void 0,
|
|
4825
|
+
`${_chunkMAO3SIBBjs.LANGWATCH_SDK_NAME_CLIENT}.prompts`,
|
|
4826
|
+
_chunkMAO3SIBBjs.LANGWATCH_SDK_VERSION
|
|
4644
4827
|
);
|
|
4645
4828
|
|
|
4646
4829
|
// src/client-sdk/services/prompts/prompt.ts
|
|
@@ -4753,6 +4936,21 @@ var LangWatchRedirectError = class extends Error {
|
|
|
4753
4936
|
this.status = status;
|
|
4754
4937
|
}
|
|
4755
4938
|
};
|
|
4939
|
+
var isPlainHeaders = (headers) => !(headers instanceof Headers) && !Array.isArray(headers);
|
|
4940
|
+
var withApiVersion = ({
|
|
4941
|
+
input,
|
|
4942
|
+
init
|
|
4943
|
+
}) => {
|
|
4944
|
+
var _a;
|
|
4945
|
+
const sent = (_a = init == null ? void 0 : init.headers) != null ? _a : typeof Request !== "undefined" && input instanceof Request ? input.headers : void 0;
|
|
4946
|
+
if (new Headers(sent).has(_chunkMAO3SIBBjs.API_VERSION_HEADER)) return _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, init);
|
|
4947
|
+
if (sent === void 0 || isPlainHeaders(sent)) {
|
|
4948
|
+
return _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, init), { headers: _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, sent), { [_chunkMAO3SIBBjs.API_VERSION_HEADER]: _chunkMAO3SIBBjs.LANGWATCH_API_VERSION }) });
|
|
4949
|
+
}
|
|
4950
|
+
const headers = new Headers(sent);
|
|
4951
|
+
headers.set(_chunkMAO3SIBBjs.API_VERSION_HEADER, _chunkMAO3SIBBjs.LANGWATCH_API_VERSION);
|
|
4952
|
+
return _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, init), { headers });
|
|
4953
|
+
};
|
|
4756
4954
|
var warnedOrigins = /* @__PURE__ */ new Set();
|
|
4757
4955
|
var isRedirect = (response) => response.type === "opaqueredirect" || REDIRECT_STATUSES.has(response.status);
|
|
4758
4956
|
var isStream = (body) => typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
|
|
@@ -4927,8 +5125,9 @@ var createLangWatchFetch = ({
|
|
|
4927
5125
|
} = {}) => {
|
|
4928
5126
|
const send = fetchImpl != null ? fetchImpl : ((input, init) => globalThis.fetch(input, init));
|
|
4929
5127
|
const log = logger2 != null ? logger2 : new (0, _chunk5VYEG3RSjs.ConsoleLogger)({ level: "warn", prefix: "LangWatch" });
|
|
4930
|
-
return async (input,
|
|
5128
|
+
return async (input, given) => {
|
|
4931
5129
|
var _a, _b;
|
|
5130
|
+
const init = withApiVersion({ input, init: given });
|
|
4932
5131
|
const url = requestUrl(input);
|
|
4933
5132
|
const effective = effectiveRequest({ input, init });
|
|
4934
5133
|
const method = ((_b = (_a = effective == null ? void 0 : effective.method) != null ? _a : init == null ? void 0 : init.method) != null ? _b : "GET").toUpperCase();
|
|
@@ -5241,16 +5440,16 @@ function buildSdkIdentityHeaders({
|
|
|
5241
5440
|
surface = scopedSurface()
|
|
5242
5441
|
} = {}) {
|
|
5243
5442
|
return _chunkN76BG37Wjs.__spreadValues.call(void 0, {
|
|
5244
|
-
"user-agent": `langwatch-sdk-node/${
|
|
5245
|
-
"x-langwatch-sdk-name":
|
|
5246
|
-
"x-langwatch-sdk-language":
|
|
5247
|
-
"x-langwatch-sdk-version":
|
|
5248
|
-
"x-langwatch-sdk-platform":
|
|
5443
|
+
"user-agent": `langwatch-sdk-node/${_chunkMAO3SIBBjs.LANGWATCH_SDK_VERSION}`,
|
|
5444
|
+
"x-langwatch-sdk-name": _chunkMAO3SIBBjs.LANGWATCH_SDK_NAME_OBSERVABILITY,
|
|
5445
|
+
"x-langwatch-sdk-language": _chunkMAO3SIBBjs.LANGWATCH_SDK_LANGUAGE,
|
|
5446
|
+
"x-langwatch-sdk-version": _chunkMAO3SIBBjs.LANGWATCH_SDK_VERSION,
|
|
5447
|
+
"x-langwatch-sdk-platform": _chunkMAO3SIBBjs.LANGWATCH_SDK_RUNTIME.call(void 0, )
|
|
5249
5448
|
}, surface === "cli" ? { [CLI_SURFACE_HEADER]: CLI_SURFACE_VALUE } : {});
|
|
5250
5449
|
}
|
|
5251
5450
|
function buildRequestHeaders(credentials) {
|
|
5252
5451
|
var _a;
|
|
5253
|
-
return _chunkN76BG37Wjs.__spreadValues.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {},
|
|
5452
|
+
return _chunkN76BG37Wjs.__spreadValues.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, _chunkMAO3SIBBjs.buildAuthHeaders.call(void 0, _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, credentials), {
|
|
5254
5453
|
projectId: (_a = credentials.projectId) != null ? _a : scopedProjectId()
|
|
5255
5454
|
}))), buildSdkIdentityHeaders());
|
|
5256
5455
|
}
|
|
@@ -5281,7 +5480,7 @@ var handledErrorMiddleware = {
|
|
|
5281
5480
|
};
|
|
5282
5481
|
var createLangWatchApiClient = (apiKey = ((_b) => (_b = ((_a) => (_a = scopedApiKey()) != null ? _a : process.env.LANGWATCH_API_KEY)()) != null ? _b : "")(), endpoint, projectId = ((_c) => (_c = scopedProjectId()) != null ? _c : process.env.LANGWATCH_PROJECT_ID)()) => {
|
|
5283
5482
|
const client = _openapifetch2.default.call(void 0, {
|
|
5284
|
-
baseUrl:
|
|
5483
|
+
baseUrl: _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, endpoint),
|
|
5285
5484
|
fetch: langwatchFetch,
|
|
5286
5485
|
headers: _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, buildRequestHeaders({ apiKey, projectId })), {
|
|
5287
5486
|
"content-type": "application/json"
|
|
@@ -5292,17 +5491,17 @@ var createLangWatchApiClient = (apiKey = ((_b) => (_b = ((_a) => (_a = scopedApi
|
|
|
5292
5491
|
};
|
|
5293
5492
|
|
|
5294
5493
|
// src/client-sdk/services/prompts/prompts-api.service.ts
|
|
5295
|
-
var syncActionSchema =
|
|
5296
|
-
var syncResultSchema =
|
|
5494
|
+
var syncActionSchema = _chunkF7BVJW3Sjs.external_exports.enum(["created", "updated", "conflict", "up_to_date"]);
|
|
5495
|
+
var syncResultSchema = _chunkF7BVJW3Sjs.external_exports.object({
|
|
5297
5496
|
action: syncActionSchema,
|
|
5298
5497
|
// `prompt` and `conflictInfo` are passed through untyped — they come from
|
|
5299
5498
|
// the OpenAPI-derived shape which is already validated on the server side.
|
|
5300
|
-
prompt:
|
|
5301
|
-
conflictInfo:
|
|
5302
|
-
localVersion:
|
|
5303
|
-
remoteVersion:
|
|
5304
|
-
differences:
|
|
5305
|
-
remoteConfigData:
|
|
5499
|
+
prompt: _chunkF7BVJW3Sjs.external_exports.unknown().optional(),
|
|
5500
|
+
conflictInfo: _chunkF7BVJW3Sjs.external_exports.object({
|
|
5501
|
+
localVersion: _chunkF7BVJW3Sjs.external_exports.number(),
|
|
5502
|
+
remoteVersion: _chunkF7BVJW3Sjs.external_exports.number(),
|
|
5503
|
+
differences: _chunkF7BVJW3Sjs.external_exports.array(_chunkF7BVJW3Sjs.external_exports.string()),
|
|
5504
|
+
remoteConfigData: _chunkF7BVJW3Sjs.external_exports.unknown()
|
|
5306
5505
|
}).passthrough().optional()
|
|
5307
5506
|
});
|
|
5308
5507
|
var PromptsApiService = class {
|
|
@@ -5883,9 +6082,9 @@ var PageSizer = class {
|
|
|
5883
6082
|
};
|
|
5884
6083
|
|
|
5885
6084
|
// src/client-sdk/services/datasets/tracing/tracer.ts
|
|
5886
|
-
var tracer2 =
|
|
5887
|
-
`${
|
|
5888
|
-
|
|
6085
|
+
var tracer2 = _chunkF7BVJW3Sjs.getLangWatchTracer.call(void 0,
|
|
6086
|
+
`${_chunkMAO3SIBBjs.LANGWATCH_SDK_NAME_CLIENT}.datasets`,
|
|
6087
|
+
_chunkMAO3SIBBjs.LANGWATCH_SDK_VERSION
|
|
5889
6088
|
);
|
|
5890
6089
|
|
|
5891
6090
|
// src/client-sdk/services/datasets/dataset.service.ts
|
|
@@ -5904,7 +6103,7 @@ var API_COLUMN_TYPES = {
|
|
|
5904
6103
|
image: "image",
|
|
5905
6104
|
file: "file"
|
|
5906
6105
|
};
|
|
5907
|
-
var apiColumnTypeSchema =
|
|
6106
|
+
var apiColumnTypeSchema = _chunkF7BVJW3Sjs.external_exports.enum(API_COLUMN_TYPES);
|
|
5908
6107
|
function toApiColumnTypes(columnTypes) {
|
|
5909
6108
|
return columnTypes.map(({ name, type }) => {
|
|
5910
6109
|
const parsed = apiColumnTypeSchema.safeParse(type);
|
|
@@ -5918,7 +6117,7 @@ function toApiColumnTypes(columnTypes) {
|
|
|
5918
6117
|
}
|
|
5919
6118
|
var DatasetService = class {
|
|
5920
6119
|
constructor(config) {
|
|
5921
|
-
this.config = _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, config), { endpoint:
|
|
6120
|
+
this.config = _chunkN76BG37Wjs.__spreadProps.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, config), { endpoint: _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config.endpoint) });
|
|
5922
6121
|
return createTracingProxy(this, tracer2);
|
|
5923
6122
|
}
|
|
5924
6123
|
/** Handles API errors by mapping status codes to appropriate error types. */
|
|
@@ -7126,7 +7325,7 @@ var Experiment = class _Experiment {
|
|
|
7126
7325
|
this.experimentSlug = name;
|
|
7127
7326
|
this.runId = (_a = options.runId) != null ? _a : generateHumanReadableId();
|
|
7128
7327
|
this.apiClient = options.apiClient;
|
|
7129
|
-
this.endpoint =
|
|
7328
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, options.endpoint);
|
|
7130
7329
|
this.apiKey = options.apiKey;
|
|
7131
7330
|
this.logger = options.logger;
|
|
7132
7331
|
this.concurrency = (_b = options.concurrency) != null ? _b : DEFAULT_CONCURRENCY;
|
|
@@ -7136,7 +7335,7 @@ var Experiment = class _Experiment {
|
|
|
7136
7335
|
* Initialize an evaluation session
|
|
7137
7336
|
*/
|
|
7138
7337
|
static async init(name, options) {
|
|
7139
|
-
|
|
7338
|
+
_chunkDLZCOUXCjs.ensureSetup.call(void 0, );
|
|
7140
7339
|
const experiment = new _Experiment(name, options);
|
|
7141
7340
|
await experiment.initialize();
|
|
7142
7341
|
return experiment;
|
|
@@ -7271,7 +7470,7 @@ var Experiment = class _Experiment {
|
|
|
7271
7470
|
}
|
|
7272
7471
|
},
|
|
7273
7472
|
async (otelSpan) => {
|
|
7274
|
-
const span =
|
|
7473
|
+
const span = _chunkF7BVJW3Sjs.createLangWatchSpan.call(void 0, otelSpan);
|
|
7275
7474
|
const spanContext = otelSpan.spanContext();
|
|
7276
7475
|
const traceId = spanContext.traceId;
|
|
7277
7476
|
iterationContext.traceId = traceId;
|
|
@@ -7649,7 +7848,7 @@ var Experiment = class _Experiment {
|
|
|
7649
7848
|
},
|
|
7650
7849
|
_api.ROOT_CONTEXT,
|
|
7651
7850
|
async (otelSpan) => {
|
|
7652
|
-
const span =
|
|
7851
|
+
const span = _chunkF7BVJW3Sjs.createLangWatchSpan.call(void 0, otelSpan);
|
|
7653
7852
|
const spanContext = otelSpan.spanContext();
|
|
7654
7853
|
const rawTraceId = spanContext.traceId;
|
|
7655
7854
|
spanId = spanContext.spanId;
|
|
@@ -8823,7 +9022,7 @@ var EvaluationsFacade = class {
|
|
|
8823
9022
|
},
|
|
8824
9023
|
_api.context.active()
|
|
8825
9024
|
);
|
|
8826
|
-
const langwatchSpan =
|
|
9025
|
+
const langwatchSpan = _chunkF7BVJW3Sjs.createLangWatchSpan.call(void 0, otelSpan);
|
|
8827
9026
|
langwatchSpan.setType(spanType);
|
|
8828
9027
|
langwatchSpan.setInput(_chunkN76BG37Wjs.__spreadValues.call(void 0, {
|
|
8829
9028
|
data
|
|
@@ -9629,7 +9828,7 @@ var WorkflowsApiError = class extends Error {
|
|
|
9629
9828
|
var WorkflowsApiService = class {
|
|
9630
9829
|
constructor(config) {
|
|
9631
9830
|
var _a;
|
|
9632
|
-
this.endpoint =
|
|
9831
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
9633
9832
|
this.apiClient = (_a = config == null ? void 0 : config.langwatchApiClient) != null ? _a : createLangWatchApiClient(void 0, this.endpoint);
|
|
9634
9833
|
this.experimentsApiService = new ExperimentsApiService({
|
|
9635
9834
|
langwatchApiClient: this.apiClient
|
|
@@ -9973,34 +10172,172 @@ var AnnotationsApiService = class {
|
|
|
9973
10172
|
|
|
9974
10173
|
// src/client-sdk/services/dashboards/dashboards-api.service.ts
|
|
9975
10174
|
var DashboardsApiError = class extends Error {
|
|
9976
|
-
constructor(message, operation, originalError) {
|
|
10175
|
+
constructor(message, operation, originalError, status) {
|
|
9977
10176
|
super(message);
|
|
9978
10177
|
this.operation = operation;
|
|
9979
10178
|
this.originalError = originalError;
|
|
10179
|
+
this.status = status;
|
|
9980
10180
|
this.name = "DashboardsApiError";
|
|
9981
10181
|
}
|
|
9982
10182
|
};
|
|
9983
10183
|
var DashboardsApiService = class {
|
|
10184
|
+
constructor(config) {
|
|
10185
|
+
var _a;
|
|
10186
|
+
this.apiClient = (_a = config == null ? void 0 : config.langwatchApiClient) != null ? _a : createLangWatchApiClient();
|
|
10187
|
+
}
|
|
10188
|
+
handleApiError({
|
|
10189
|
+
operation,
|
|
10190
|
+
error,
|
|
10191
|
+
response
|
|
10192
|
+
}) {
|
|
10193
|
+
var _a;
|
|
10194
|
+
const status = (_a = response == null ? void 0 : response.status) != null ? _a : extractStatusFromResponse(error);
|
|
10195
|
+
const message = formatApiErrorForOperation({ operation, error, options: { status } });
|
|
10196
|
+
throwIfHandledError({ operation, error, response, message });
|
|
10197
|
+
throw new DashboardsApiError(message, operation, error, status);
|
|
10198
|
+
}
|
|
10199
|
+
async list() {
|
|
10200
|
+
const { data, error, response } = await this.apiClient.GET("/api/v1/dashboards");
|
|
10201
|
+
if (error) this.handleApiError({ operation: "list dashboards", error, response });
|
|
10202
|
+
return data;
|
|
10203
|
+
}
|
|
10204
|
+
async get(dashboardId) {
|
|
10205
|
+
const operation = `get dashboard "${dashboardId}"`;
|
|
10206
|
+
const { data, error, response } = await this.apiClient.GET("/api/v1/dashboards/{dashboardId}", {
|
|
10207
|
+
params: { path: { dashboardId } }
|
|
10208
|
+
});
|
|
10209
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10210
|
+
return data;
|
|
10211
|
+
}
|
|
10212
|
+
async create({ name }) {
|
|
10213
|
+
const { data, error, response } = await this.apiClient.POST("/api/v1/dashboards", {
|
|
10214
|
+
body: { name }
|
|
10215
|
+
});
|
|
10216
|
+
if (error) this.handleApiError({ operation: "create dashboard", error, response });
|
|
10217
|
+
return data;
|
|
10218
|
+
}
|
|
10219
|
+
/** `description: null` clears it; a field left out keeps its value. */
|
|
10220
|
+
async update({
|
|
10221
|
+
dashboardId,
|
|
10222
|
+
name,
|
|
10223
|
+
description
|
|
10224
|
+
}) {
|
|
10225
|
+
const operation = `update dashboard "${dashboardId}"`;
|
|
10226
|
+
const { data, error, response } = await this.apiClient.PATCH(
|
|
10227
|
+
"/api/v1/dashboards/{dashboardId}",
|
|
10228
|
+
{
|
|
10229
|
+
params: { path: { dashboardId } },
|
|
10230
|
+
body: _chunkN76BG37Wjs.__spreadValues.call(void 0, _chunkN76BG37Wjs.__spreadValues.call(void 0, {}, name === void 0 ? {} : { name }), description === void 0 ? {} : { description })
|
|
10231
|
+
}
|
|
10232
|
+
);
|
|
10233
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10234
|
+
return data;
|
|
10235
|
+
}
|
|
10236
|
+
/** Deletes the dashboard with the widgets on it; answers its id and name. */
|
|
10237
|
+
async delete(dashboardId) {
|
|
10238
|
+
const operation = `delete dashboard "${dashboardId}"`;
|
|
10239
|
+
const { data, error, response } = await this.apiClient.DELETE(
|
|
10240
|
+
"/api/v1/dashboards/{dashboardId}",
|
|
10241
|
+
{
|
|
10242
|
+
params: { path: { dashboardId } }
|
|
10243
|
+
}
|
|
10244
|
+
);
|
|
10245
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10246
|
+
return data;
|
|
10247
|
+
}
|
|
10248
|
+
async listWidgets(dashboardId) {
|
|
10249
|
+
const operation = `list widgets on dashboard "${dashboardId}"`;
|
|
10250
|
+
const { data, error, response } = await this.apiClient.GET(
|
|
10251
|
+
"/api/v1/dashboards/{dashboardId}/widgets",
|
|
10252
|
+
{
|
|
10253
|
+
params: { path: { dashboardId } }
|
|
10254
|
+
}
|
|
10255
|
+
);
|
|
10256
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10257
|
+
return data;
|
|
10258
|
+
}
|
|
10259
|
+
/** Creates a widget placed on this dashboard. */
|
|
10260
|
+
async createWidget({
|
|
10261
|
+
dashboardId,
|
|
10262
|
+
widget
|
|
10263
|
+
}) {
|
|
10264
|
+
const operation = `create widget on dashboard "${dashboardId}"`;
|
|
10265
|
+
const { data, error, response } = await this.apiClient.POST(
|
|
10266
|
+
"/api/v1/dashboards/{dashboardId}/widgets",
|
|
10267
|
+
{ params: { path: { dashboardId } }, body: widget }
|
|
10268
|
+
);
|
|
10269
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10270
|
+
return data;
|
|
10271
|
+
}
|
|
10272
|
+
async getWidget({
|
|
10273
|
+
dashboardId,
|
|
10274
|
+
widgetId
|
|
10275
|
+
}) {
|
|
10276
|
+
const operation = `get widget "${widgetId}" on dashboard "${dashboardId}"`;
|
|
10277
|
+
const { data, error, response } = await this.apiClient.GET(
|
|
10278
|
+
"/api/v1/dashboards/{dashboardId}/widgets/{widgetId}",
|
|
10279
|
+
{ params: { path: { dashboardId, widgetId } } }
|
|
10280
|
+
);
|
|
10281
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10282
|
+
return data;
|
|
10283
|
+
}
|
|
10284
|
+
async updateWidget({
|
|
10285
|
+
dashboardId,
|
|
10286
|
+
widgetId,
|
|
10287
|
+
changes
|
|
10288
|
+
}) {
|
|
10289
|
+
const operation = `update widget "${widgetId}" on dashboard "${dashboardId}"`;
|
|
10290
|
+
const { data, error, response } = await this.apiClient.PATCH(
|
|
10291
|
+
"/api/v1/dashboards/{dashboardId}/widgets/{widgetId}",
|
|
10292
|
+
{ params: { path: { dashboardId, widgetId } }, body: changes }
|
|
10293
|
+
);
|
|
10294
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10295
|
+
return data;
|
|
10296
|
+
}
|
|
10297
|
+
/** The route answers `204` with no body. */
|
|
10298
|
+
async deleteWidget({
|
|
10299
|
+
dashboardId,
|
|
10300
|
+
widgetId
|
|
10301
|
+
}) {
|
|
10302
|
+
const operation = `delete widget "${widgetId}" on dashboard "${dashboardId}"`;
|
|
10303
|
+
const { error, response } = await this.apiClient.DELETE(
|
|
10304
|
+
"/api/v1/dashboards/{dashboardId}/widgets/{widgetId}",
|
|
10305
|
+
{ params: { path: { dashboardId, widgetId } } }
|
|
10306
|
+
);
|
|
10307
|
+
if (error) this.handleApiError({ operation, error, response });
|
|
10308
|
+
}
|
|
10309
|
+
};
|
|
10310
|
+
|
|
10311
|
+
// src/client-sdk/services/analytics-reports/analytics-reports-api.service.ts
|
|
10312
|
+
var AnalyticsReportsApiError = class extends Error {
|
|
10313
|
+
constructor(message, operation, originalError, status) {
|
|
10314
|
+
super(message);
|
|
10315
|
+
this.operation = operation;
|
|
10316
|
+
this.originalError = originalError;
|
|
10317
|
+
this.status = status;
|
|
10318
|
+
this.name = "AnalyticsReportsApiError";
|
|
10319
|
+
}
|
|
10320
|
+
};
|
|
10321
|
+
var AnalyticsReportsApiService = class {
|
|
9984
10322
|
constructor(config) {
|
|
9985
10323
|
var _a;
|
|
9986
10324
|
this.apiClient = (_a = config == null ? void 0 : config.langwatchApiClient) != null ? _a : createLangWatchApiClient();
|
|
9987
10325
|
}
|
|
9988
10326
|
handleApiError(operation, error, response) {
|
|
9989
10327
|
var _a;
|
|
10328
|
+
const status = (_a = response == null ? void 0 : response.status) != null ? _a : extractStatusFromResponse(error);
|
|
9990
10329
|
const message = formatApiErrorForOperation({
|
|
9991
10330
|
operation,
|
|
9992
10331
|
error,
|
|
9993
|
-
options: {
|
|
9994
|
-
status: (_a = response == null ? void 0 : response.status) != null ? _a : extractStatusFromResponse(error)
|
|
9995
|
-
}
|
|
10332
|
+
options: { status }
|
|
9996
10333
|
});
|
|
9997
|
-
throwIfHandledError({ operation, error, message });
|
|
9998
|
-
throw new
|
|
10334
|
+
throwIfHandledError({ operation, error, response, message });
|
|
10335
|
+
throw new AnalyticsReportsApiError(message, operation, error, status);
|
|
9999
10336
|
}
|
|
10000
10337
|
async list() {
|
|
10001
|
-
const { data, error, response } = await this.apiClient.GET("/api/v1/
|
|
10338
|
+
const { data, error, response } = await this.apiClient.GET("/api/v1/analytics/reports");
|
|
10002
10339
|
return unwrapApiResult({
|
|
10003
|
-
operation: "list
|
|
10340
|
+
operation: "list analytics reports",
|
|
10004
10341
|
data,
|
|
10005
10342
|
error,
|
|
10006
10343
|
response,
|
|
@@ -10008,11 +10345,14 @@ var DashboardsApiService = class {
|
|
|
10008
10345
|
});
|
|
10009
10346
|
}
|
|
10010
10347
|
async get(id) {
|
|
10011
|
-
const { data, error, response } = await this.apiClient.GET(
|
|
10012
|
-
|
|
10013
|
-
|
|
10348
|
+
const { data, error, response } = await this.apiClient.GET(
|
|
10349
|
+
"/api/v1/analytics/reports/{reportId}",
|
|
10350
|
+
{
|
|
10351
|
+
params: { path: { reportId: id } }
|
|
10352
|
+
}
|
|
10353
|
+
);
|
|
10014
10354
|
return unwrapApiResult({
|
|
10015
|
-
operation: `get
|
|
10355
|
+
operation: `get analytics report "${id}"`,
|
|
10016
10356
|
data,
|
|
10017
10357
|
error,
|
|
10018
10358
|
response,
|
|
@@ -10020,11 +10360,11 @@ var DashboardsApiService = class {
|
|
|
10020
10360
|
});
|
|
10021
10361
|
}
|
|
10022
10362
|
async create(params) {
|
|
10023
|
-
const { data, error, response } = await this.apiClient.POST("/api/v1/
|
|
10363
|
+
const { data, error, response } = await this.apiClient.POST("/api/v1/analytics/reports", {
|
|
10024
10364
|
body: params
|
|
10025
10365
|
});
|
|
10026
10366
|
return unwrapApiResult({
|
|
10027
|
-
operation: "create
|
|
10367
|
+
operation: "create analytics report",
|
|
10028
10368
|
data,
|
|
10029
10369
|
error,
|
|
10030
10370
|
response,
|
|
@@ -10032,12 +10372,15 @@ var DashboardsApiService = class {
|
|
|
10032
10372
|
});
|
|
10033
10373
|
}
|
|
10034
10374
|
async rename(id, params) {
|
|
10035
|
-
const { data, error, response } = await this.apiClient.PATCH(
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10375
|
+
const { data, error, response } = await this.apiClient.PATCH(
|
|
10376
|
+
"/api/v1/analytics/reports/{reportId}",
|
|
10377
|
+
{
|
|
10378
|
+
params: { path: { reportId: id } },
|
|
10379
|
+
body: params
|
|
10380
|
+
}
|
|
10381
|
+
);
|
|
10039
10382
|
return unwrapApiResult({
|
|
10040
|
-
operation: `rename
|
|
10383
|
+
operation: `rename analytics report "${id}"`,
|
|
10041
10384
|
data,
|
|
10042
10385
|
error,
|
|
10043
10386
|
response,
|
|
@@ -10045,11 +10388,14 @@ var DashboardsApiService = class {
|
|
|
10045
10388
|
});
|
|
10046
10389
|
}
|
|
10047
10390
|
async delete(id) {
|
|
10048
|
-
const { data, error, response } = await this.apiClient.DELETE(
|
|
10049
|
-
|
|
10050
|
-
|
|
10391
|
+
const { data, error, response } = await this.apiClient.DELETE(
|
|
10392
|
+
"/api/v1/analytics/reports/{reportId}",
|
|
10393
|
+
{
|
|
10394
|
+
params: { path: { reportId: id } }
|
|
10395
|
+
}
|
|
10396
|
+
);
|
|
10051
10397
|
return unwrapApiResult({
|
|
10052
|
-
operation: `delete
|
|
10398
|
+
operation: `delete analytics report "${id}"`,
|
|
10053
10399
|
data,
|
|
10054
10400
|
error,
|
|
10055
10401
|
response,
|
|
@@ -10554,7 +10900,7 @@ var MonitorsApiService = class {
|
|
|
10554
10900
|
constructor(config) {
|
|
10555
10901
|
var _a, _b, _c;
|
|
10556
10902
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
10557
|
-
this.endpoint =
|
|
10903
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
10558
10904
|
}
|
|
10559
10905
|
async request(path2, options) {
|
|
10560
10906
|
var _a, _b;
|
|
@@ -10633,7 +10979,7 @@ var SecretsApiService = class {
|
|
|
10633
10979
|
constructor(config) {
|
|
10634
10980
|
var _a, _b, _c;
|
|
10635
10981
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
10636
|
-
this.endpoint =
|
|
10982
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
10637
10983
|
this.configuredProjectId = config == null ? void 0 : config.projectId;
|
|
10638
10984
|
}
|
|
10639
10985
|
projectId() {
|
|
@@ -10790,7 +11136,7 @@ var VirtualKeysApiError = class extends Error {
|
|
|
10790
11136
|
var VirtualKeysApiService = class {
|
|
10791
11137
|
constructor(config) {
|
|
10792
11138
|
var _a, _b, _c, _d, _e, _f;
|
|
10793
|
-
this.endpoint =
|
|
11139
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
10794
11140
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
10795
11141
|
const resolved = scopedProjectId();
|
|
10796
11142
|
this.projectId = (_e = (_d = config == null ? void 0 : config.projectId) != null ? _d : requestedProject() === void 0 ? void 0 : resolved) != null ? _e : process.env.LANGWATCH_PROJECT_ID;
|
|
@@ -11001,7 +11347,7 @@ var GatewayBudgetsApiError = class extends Error {
|
|
|
11001
11347
|
var GatewayBudgetsApiService = class {
|
|
11002
11348
|
constructor(config) {
|
|
11003
11349
|
var _a, _b, _c, _d;
|
|
11004
|
-
this.endpoint =
|
|
11350
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
11005
11351
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
11006
11352
|
this.projectId = (_d = config == null ? void 0 : config.projectId) != null ? _d : process.env.LANGWATCH_PROJECT_ID;
|
|
11007
11353
|
}
|
|
@@ -11242,7 +11588,7 @@ var SpendEventsApiError = class extends Error {
|
|
|
11242
11588
|
var SpendEventsApiService = class {
|
|
11243
11589
|
constructor(config) {
|
|
11244
11590
|
var _a, _b, _c;
|
|
11245
|
-
this.endpoint =
|
|
11591
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
11246
11592
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
11247
11593
|
}
|
|
11248
11594
|
async request(operation, path2, init) {
|
|
@@ -11434,7 +11780,7 @@ var WebhooksApiError = class extends Error {
|
|
|
11434
11780
|
var WebhooksApiService = class {
|
|
11435
11781
|
constructor(config) {
|
|
11436
11782
|
var _a, _b, _c;
|
|
11437
|
-
this.endpoint =
|
|
11783
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
11438
11784
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
11439
11785
|
}
|
|
11440
11786
|
async request(operation, path2, init) {
|
|
@@ -11756,7 +12102,7 @@ var TeamsApiService = class {
|
|
|
11756
12102
|
constructor(config) {
|
|
11757
12103
|
_chunkN76BG37Wjs.__privateAdd.call(void 0, this, _request);
|
|
11758
12104
|
_chunkN76BG37Wjs.__privateSet.call(void 0, this, _request, createManagementRequest({
|
|
11759
|
-
endpoint:
|
|
12105
|
+
endpoint: _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint),
|
|
11760
12106
|
token: resolveManagementToken({ apiKey: config == null ? void 0 : config.apiKey }),
|
|
11761
12107
|
errorFactory: ({ message, operation, body }) => new TeamsApiError(message, operation, body)
|
|
11762
12108
|
}));
|
|
@@ -11840,7 +12186,7 @@ var ProjectsApiError = class extends Error {
|
|
|
11840
12186
|
var ProjectsApiService = class {
|
|
11841
12187
|
constructor(config) {
|
|
11842
12188
|
var _a, _b, _c;
|
|
11843
|
-
this.endpoint =
|
|
12189
|
+
this.endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, config == null ? void 0 : config.endpoint);
|
|
11844
12190
|
this.apiKey = (_c = (_b = (_a = config == null ? void 0 : config.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
11845
12191
|
}
|
|
11846
12192
|
/**
|
|
@@ -11931,9 +12277,9 @@ var ProjectsApiService = class {
|
|
|
11931
12277
|
};
|
|
11932
12278
|
|
|
11933
12279
|
// src/client-sdk/services/traces/tracing/tracer.ts
|
|
11934
|
-
var tracer3 =
|
|
11935
|
-
`${
|
|
11936
|
-
|
|
12280
|
+
var tracer3 = _chunkF7BVJW3Sjs.getLangWatchTracer.call(void 0,
|
|
12281
|
+
`${_chunkMAO3SIBBjs.LANGWATCH_SDK_NAME_CLIENT}.traces`,
|
|
12282
|
+
_chunkMAO3SIBBjs.LANGWATCH_SDK_VERSION
|
|
11937
12283
|
);
|
|
11938
12284
|
|
|
11939
12285
|
// src/client-sdk/services/traces/facade.ts
|
|
@@ -11960,7 +12306,7 @@ var LangWatch = class {
|
|
|
11960
12306
|
_chunkN76BG37Wjs.__privateAdd.call(void 0, this, _projects);
|
|
11961
12307
|
var _a, _b, _c;
|
|
11962
12308
|
const apiKey = (_c = (_b = (_a = options.apiKey) != null ? _a : scopedApiKey()) != null ? _b : process.env.LANGWATCH_API_KEY) != null ? _c : "";
|
|
11963
|
-
const endpoint =
|
|
12309
|
+
const endpoint = _chunkDLZCOUXCjs.resolveEndpoint.call(void 0, options.endpoint);
|
|
11964
12310
|
this.config = _chunkN76BG37Wjs.__privateMethod.call(void 0, this, _LangWatch_instances, createInternalConfig_fn).call(this, {
|
|
11965
12311
|
apiKey,
|
|
11966
12312
|
endpoint,
|
|
@@ -11998,6 +12344,7 @@ var LangWatch = class {
|
|
|
11998
12344
|
this.agents = new AgentsApiService(this.config);
|
|
11999
12345
|
this.annotations = new AnnotationsApiService(this.config);
|
|
12000
12346
|
this.dashboards = new DashboardsApiService(this.config);
|
|
12347
|
+
this.analyticsReports = new AnalyticsReportsApiService(this.config);
|
|
12001
12348
|
this.modelProviders = new ModelProvidersApiService(this.config);
|
|
12002
12349
|
this.analytics = new AnalyticsApiService(this.config);
|
|
12003
12350
|
this.query = new QueryApiService(this.config);
|
|
@@ -12214,10 +12561,10 @@ var logger = {
|
|
|
12214
12561
|
|
|
12215
12562
|
|
|
12216
12563
|
|
|
12217
|
-
exports.ComparisonError = ComparisonError; exports.DatasetApiError = DatasetApiError; exports.DatasetError = DatasetError; exports.DatasetNotFoundError = DatasetNotFoundError; exports.DatasetPlanLimitError = DatasetPlanLimitError; exports.DatasetValidationError = DatasetValidationError; exports.DatasetsFacade = DatasetsFacade; exports.EvaluationError = EvaluationError; exports.EvaluationsApiError = EvaluationsApiError; exports.EvaluationsFacade = EvaluationsFacade; exports.EvaluatorCallError = EvaluatorCallError; exports.EvaluatorError = EvaluatorError; exports.EvaluatorNotFoundError = EvaluatorNotFoundError; exports.EvaluatorsApiError = EvaluatorsApiError; exports.EvaluatorsApiService = EvaluatorsApiService; exports.Experiment = Experiment; exports.ExperimentApiError = ExperimentApiError; exports.ExperimentError = ExperimentError; exports.ExperimentInitError = ExperimentInitError; exports.ExperimentsFacade = ExperimentsFacade; exports.FetchPolicy = FetchPolicy; exports.FilterableBatchSpanProcessor = _chunkWDUUAIG3js.FilterableBatchSpanProcessor; exports.GatewayBudgetsApiError = GatewayBudgetsApiError; exports.GatewayBudgetsApiService = GatewayBudgetsApiService; exports.IDEMPOTENCY_KEY_HEADER = IDEMPOTENCY_KEY_HEADER; exports.IDEMPOTENT_REPLAY_HEADER = IDEMPOTENT_REPLAY_HEADER; exports.LangWatch = LangWatch; exports.LangWatchApiError = LangWatchApiError; exports.LangWatchExporter =
|
|
12564
|
+
exports.ComparisonError = ComparisonError; exports.DatasetApiError = DatasetApiError; exports.DatasetError = DatasetError; exports.DatasetNotFoundError = DatasetNotFoundError; exports.DatasetPlanLimitError = DatasetPlanLimitError; exports.DatasetValidationError = DatasetValidationError; exports.DatasetsFacade = DatasetsFacade; exports.EvaluationError = EvaluationError; exports.EvaluationsApiError = EvaluationsApiError; exports.EvaluationsFacade = EvaluationsFacade; exports.EvaluatorCallError = EvaluatorCallError; exports.EvaluatorError = EvaluatorError; exports.EvaluatorNotFoundError = EvaluatorNotFoundError; exports.EvaluatorsApiError = EvaluatorsApiError; exports.EvaluatorsApiService = EvaluatorsApiService; exports.Experiment = Experiment; exports.ExperimentApiError = ExperimentApiError; exports.ExperimentError = ExperimentError; exports.ExperimentInitError = ExperimentInitError; exports.ExperimentsFacade = ExperimentsFacade; exports.FetchPolicy = FetchPolicy; exports.FilterableBatchSpanProcessor = _chunkWDUUAIG3js.FilterableBatchSpanProcessor; exports.GatewayBudgetsApiError = GatewayBudgetsApiError; exports.GatewayBudgetsApiService = GatewayBudgetsApiService; exports.IDEMPOTENCY_KEY_HEADER = IDEMPOTENCY_KEY_HEADER; exports.IDEMPOTENT_REPLAY_HEADER = IDEMPOTENT_REPLAY_HEADER; exports.LangWatch = LangWatch; exports.LangWatchApiError = LangWatchApiError; exports.LangWatchExporter = _chunkMAO3SIBBjs.LangWatchTraceExporter; exports.LangWatchHandledError = LangWatchHandledError; exports.LangWatchRedirectError = LangWatchRedirectError; exports.ProjectsApiError = ProjectsApiError; exports.ProjectsApiService = ProjectsApiService; exports.SpendEventsApiError = SpendEventsApiError; exports.SpendEventsApiService = SpendEventsApiService; exports.TargetMetadataConflictError = TargetMetadataConflictError; exports.TeamsApiError = TeamsApiError; exports.TeamsApiService = TeamsApiService; exports.VirtualKeysApiError = VirtualKeysApiError; exports.VirtualKeysApiService = VirtualKeysApiService; exports.WEBHOOK_DELIVERY_ID_HEADER = WEBHOOK_DELIVERY_ID_HEADER; exports.WEBHOOK_EVENT_ID_HEADER = WEBHOOK_EVENT_ID_HEADER; exports.WEBHOOK_SIGNATURE_DEFAULT_TOLERANCE_SECONDS = WEBHOOK_SIGNATURE_DEFAULT_TOLERANCE_SECONDS; exports.WEBHOOK_SIGNATURE_HEADER = WEBHOOK_SIGNATURE_HEADER; exports.WebhookSignatureVerificationError = WebhookSignatureVerificationError; exports.WebhooksApiError = WebhooksApiError; exports.WebhooksApiService = WebhooksApiService; exports.attributes = _chunkN76BG37Wjs.attributes_exports; exports.createLangWatchFetch = createLangWatchFetch; exports.getLangWatchLogger = _chunkMAO3SIBBjs.getLangWatchLogger; exports.getLangWatchTracer = _chunkF7BVJW3Sjs.getLangWatchTracer; exports.isLangWatchHandledError = isLangWatchHandledError; exports.langwatchFetch = langwatchFetch; exports.logger = logger; exports.verifyWebhookSignature = verifyWebhookSignature;
|
|
12218
12565
|
/*! Bundled license information:
|
|
12219
12566
|
|
|
12220
12567
|
js-yaml/dist/js-yaml.mjs:
|
|
12221
|
-
(*! js-yaml 5.
|
|
12568
|
+
(*! js-yaml 5.4.3 https://github.com/nodeca/js-yaml @license MIT *)
|
|
12222
12569
|
*/
|
|
12223
12570
|
//# sourceMappingURL=index.js.map
|