@akson/cortex-analytics 0.8.0 → 0.9.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 +56 -814
- package/dist/cli.js +109 -2742
- package/dist/cli.js.map +1 -1
- package/dist/index.js +105 -2738
- package/dist/index.js.map +1 -1
- package/package.json +10 -15
package/dist/index.js
CHANGED
|
@@ -8,13 +8,13 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@akson/cortex-analytics",
|
|
11
|
-
version: "0.
|
|
11
|
+
version: "0.9.0",
|
|
12
12
|
description: "Unified CLI for Cortex analytics operations across all platforms",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "dist/index.js",
|
|
15
15
|
bin: {
|
|
16
16
|
akson: "./dist/cli.js",
|
|
17
|
-
"
|
|
17
|
+
"cortex-analytics": "./dist/cli.js"
|
|
18
18
|
},
|
|
19
19
|
scripts: {
|
|
20
20
|
build: "tsup",
|
|
@@ -25,2718 +25,90 @@ var require_package = __commonJS({
|
|
|
25
25
|
"type-check": "tsc --noEmit"
|
|
26
26
|
},
|
|
27
27
|
dependencies: {
|
|
28
|
-
"@akson/cortex-
|
|
29
|
-
"@akson/cortex-
|
|
30
|
-
"@akson/cortex-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
types: "dist/index.d.ts",
|
|
73
|
-
exports: {
|
|
74
|
-
".": {
|
|
75
|
-
types: "./dist/index.d.ts",
|
|
76
|
-
import: "./dist/index.js"
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
files: [
|
|
80
|
-
"dist",
|
|
81
|
-
"README.md",
|
|
82
|
-
"LICENSE"
|
|
83
|
-
],
|
|
84
|
-
gitHead: "b3a6a0832bb2fd230473076bde1bfc7810e9ac31"
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
// src/analytics-manager.ts
|
|
90
|
-
import crypto from "crypto";
|
|
91
|
-
import fs from "fs/promises";
|
|
92
|
-
import {
|
|
93
|
-
GoogleAdsClient,
|
|
94
|
-
HistoricalAnalyzer,
|
|
95
|
-
SwissMarketAnalyzer,
|
|
96
|
-
loadGoogleAdsConfig
|
|
97
|
-
} from "@akson/cortex-api-google-ads";
|
|
98
|
-
import { GSCClient, loadGSCConfig } from "@akson/cortex-gsc";
|
|
99
|
-
import {
|
|
100
|
-
ConfigParser,
|
|
101
|
-
GTMClient,
|
|
102
|
-
GTMApiTransformer,
|
|
103
|
-
loadGTMConfig,
|
|
104
|
-
Planner,
|
|
105
|
-
StateManager
|
|
106
|
-
} from "@akson/cortex-api-gtm";
|
|
107
|
-
import { loadPostHogConfig, PostHogClient } from "@akson/cortex-posthog";
|
|
108
|
-
import {
|
|
109
|
-
ECOMMERCE_EVENTS,
|
|
110
|
-
LEAD_GENERATION_EVENTS,
|
|
111
|
-
LEAD_SCORES,
|
|
112
|
-
PLATFORM_MAPPINGS
|
|
113
|
-
} from "@akson/cortex-utilities";
|
|
114
|
-
import chalk from "chalk";
|
|
115
|
-
import inquirer from "inquirer";
|
|
116
|
-
|
|
117
|
-
// ../../node_modules/js-yaml/dist/js-yaml.mjs
|
|
118
|
-
function isNothing(subject) {
|
|
119
|
-
return typeof subject === "undefined" || subject === null;
|
|
120
|
-
}
|
|
121
|
-
function isObject(subject) {
|
|
122
|
-
return typeof subject === "object" && subject !== null;
|
|
123
|
-
}
|
|
124
|
-
function toArray(sequence) {
|
|
125
|
-
if (Array.isArray(sequence)) return sequence;
|
|
126
|
-
else if (isNothing(sequence)) return [];
|
|
127
|
-
return [sequence];
|
|
128
|
-
}
|
|
129
|
-
function extend(target, source) {
|
|
130
|
-
var index, length, key, sourceKeys;
|
|
131
|
-
if (source) {
|
|
132
|
-
sourceKeys = Object.keys(source);
|
|
133
|
-
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
134
|
-
key = sourceKeys[index];
|
|
135
|
-
target[key] = source[key];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return target;
|
|
139
|
-
}
|
|
140
|
-
function repeat(string, count) {
|
|
141
|
-
var result = "", cycle;
|
|
142
|
-
for (cycle = 0; cycle < count; cycle += 1) {
|
|
143
|
-
result += string;
|
|
144
|
-
}
|
|
145
|
-
return result;
|
|
146
|
-
}
|
|
147
|
-
function isNegativeZero(number) {
|
|
148
|
-
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
149
|
-
}
|
|
150
|
-
var isNothing_1 = isNothing;
|
|
151
|
-
var isObject_1 = isObject;
|
|
152
|
-
var toArray_1 = toArray;
|
|
153
|
-
var repeat_1 = repeat;
|
|
154
|
-
var isNegativeZero_1 = isNegativeZero;
|
|
155
|
-
var extend_1 = extend;
|
|
156
|
-
var common = {
|
|
157
|
-
isNothing: isNothing_1,
|
|
158
|
-
isObject: isObject_1,
|
|
159
|
-
toArray: toArray_1,
|
|
160
|
-
repeat: repeat_1,
|
|
161
|
-
isNegativeZero: isNegativeZero_1,
|
|
162
|
-
extend: extend_1
|
|
163
|
-
};
|
|
164
|
-
function formatError(exception2, compact) {
|
|
165
|
-
var where = "", message = exception2.reason || "(unknown reason)";
|
|
166
|
-
if (!exception2.mark) return message;
|
|
167
|
-
if (exception2.mark.name) {
|
|
168
|
-
where += 'in "' + exception2.mark.name + '" ';
|
|
169
|
-
}
|
|
170
|
-
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
171
|
-
if (!compact && exception2.mark.snippet) {
|
|
172
|
-
where += "\n\n" + exception2.mark.snippet;
|
|
173
|
-
}
|
|
174
|
-
return message + " " + where;
|
|
175
|
-
}
|
|
176
|
-
function YAMLException$1(reason, mark) {
|
|
177
|
-
Error.call(this);
|
|
178
|
-
this.name = "YAMLException";
|
|
179
|
-
this.reason = reason;
|
|
180
|
-
this.mark = mark;
|
|
181
|
-
this.message = formatError(this, false);
|
|
182
|
-
if (Error.captureStackTrace) {
|
|
183
|
-
Error.captureStackTrace(this, this.constructor);
|
|
184
|
-
} else {
|
|
185
|
-
this.stack = new Error().stack || "";
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
189
|
-
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
190
|
-
YAMLException$1.prototype.toString = function toString(compact) {
|
|
191
|
-
return this.name + ": " + formatError(this, compact);
|
|
192
|
-
};
|
|
193
|
-
var exception = YAMLException$1;
|
|
194
|
-
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
195
|
-
var head = "";
|
|
196
|
-
var tail = "";
|
|
197
|
-
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
198
|
-
if (position - lineStart > maxHalfLength) {
|
|
199
|
-
head = " ... ";
|
|
200
|
-
lineStart = position - maxHalfLength + head.length;
|
|
201
|
-
}
|
|
202
|
-
if (lineEnd - position > maxHalfLength) {
|
|
203
|
-
tail = " ...";
|
|
204
|
-
lineEnd = position + maxHalfLength - tail.length;
|
|
205
|
-
}
|
|
206
|
-
return {
|
|
207
|
-
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
208
|
-
pos: position - lineStart + head.length
|
|
209
|
-
// relative position
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
function padStart(string, max) {
|
|
213
|
-
return common.repeat(" ", max - string.length) + string;
|
|
214
|
-
}
|
|
215
|
-
function makeSnippet(mark, options) {
|
|
216
|
-
options = Object.create(options || null);
|
|
217
|
-
if (!mark.buffer) return null;
|
|
218
|
-
if (!options.maxLength) options.maxLength = 79;
|
|
219
|
-
if (typeof options.indent !== "number") options.indent = 1;
|
|
220
|
-
if (typeof options.linesBefore !== "number") options.linesBefore = 3;
|
|
221
|
-
if (typeof options.linesAfter !== "number") options.linesAfter = 2;
|
|
222
|
-
var re = /\r?\n|\r|\0/g;
|
|
223
|
-
var lineStarts = [0];
|
|
224
|
-
var lineEnds = [];
|
|
225
|
-
var match;
|
|
226
|
-
var foundLineNo = -1;
|
|
227
|
-
while (match = re.exec(mark.buffer)) {
|
|
228
|
-
lineEnds.push(match.index);
|
|
229
|
-
lineStarts.push(match.index + match[0].length);
|
|
230
|
-
if (mark.position <= match.index && foundLineNo < 0) {
|
|
231
|
-
foundLineNo = lineStarts.length - 2;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
if (foundLineNo < 0) foundLineNo = lineStarts.length - 1;
|
|
235
|
-
var result = "", i, line;
|
|
236
|
-
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
237
|
-
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
238
|
-
for (i = 1; i <= options.linesBefore; i++) {
|
|
239
|
-
if (foundLineNo - i < 0) break;
|
|
240
|
-
line = getLine(
|
|
241
|
-
mark.buffer,
|
|
242
|
-
lineStarts[foundLineNo - i],
|
|
243
|
-
lineEnds[foundLineNo - i],
|
|
244
|
-
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
245
|
-
maxLineLength
|
|
246
|
-
);
|
|
247
|
-
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
248
|
-
}
|
|
249
|
-
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
250
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
251
|
-
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
252
|
-
for (i = 1; i <= options.linesAfter; i++) {
|
|
253
|
-
if (foundLineNo + i >= lineEnds.length) break;
|
|
254
|
-
line = getLine(
|
|
255
|
-
mark.buffer,
|
|
256
|
-
lineStarts[foundLineNo + i],
|
|
257
|
-
lineEnds[foundLineNo + i],
|
|
258
|
-
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
259
|
-
maxLineLength
|
|
260
|
-
);
|
|
261
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
262
|
-
}
|
|
263
|
-
return result.replace(/\n$/, "");
|
|
264
|
-
}
|
|
265
|
-
var snippet = makeSnippet;
|
|
266
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
267
|
-
"kind",
|
|
268
|
-
"multi",
|
|
269
|
-
"resolve",
|
|
270
|
-
"construct",
|
|
271
|
-
"instanceOf",
|
|
272
|
-
"predicate",
|
|
273
|
-
"represent",
|
|
274
|
-
"representName",
|
|
275
|
-
"defaultStyle",
|
|
276
|
-
"styleAliases"
|
|
277
|
-
];
|
|
278
|
-
var YAML_NODE_KINDS = [
|
|
279
|
-
"scalar",
|
|
280
|
-
"sequence",
|
|
281
|
-
"mapping"
|
|
282
|
-
];
|
|
283
|
-
function compileStyleAliases(map2) {
|
|
284
|
-
var result = {};
|
|
285
|
-
if (map2 !== null) {
|
|
286
|
-
Object.keys(map2).forEach(function(style) {
|
|
287
|
-
map2[style].forEach(function(alias) {
|
|
288
|
-
result[String(alias)] = style;
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
return result;
|
|
293
|
-
}
|
|
294
|
-
function Type$1(tag, options) {
|
|
295
|
-
options = options || {};
|
|
296
|
-
Object.keys(options).forEach(function(name) {
|
|
297
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
298
|
-
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
this.options = options;
|
|
302
|
-
this.tag = tag;
|
|
303
|
-
this.kind = options["kind"] || null;
|
|
304
|
-
this.resolve = options["resolve"] || function() {
|
|
305
|
-
return true;
|
|
306
|
-
};
|
|
307
|
-
this.construct = options["construct"] || function(data) {
|
|
308
|
-
return data;
|
|
309
|
-
};
|
|
310
|
-
this.instanceOf = options["instanceOf"] || null;
|
|
311
|
-
this.predicate = options["predicate"] || null;
|
|
312
|
-
this.represent = options["represent"] || null;
|
|
313
|
-
this.representName = options["representName"] || null;
|
|
314
|
-
this.defaultStyle = options["defaultStyle"] || null;
|
|
315
|
-
this.multi = options["multi"] || false;
|
|
316
|
-
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
317
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
318
|
-
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
var type = Type$1;
|
|
322
|
-
function compileList(schema2, name) {
|
|
323
|
-
var result = [];
|
|
324
|
-
schema2[name].forEach(function(currentType) {
|
|
325
|
-
var newIndex = result.length;
|
|
326
|
-
result.forEach(function(previousType, previousIndex) {
|
|
327
|
-
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
328
|
-
newIndex = previousIndex;
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
result[newIndex] = currentType;
|
|
332
|
-
});
|
|
333
|
-
return result;
|
|
334
|
-
}
|
|
335
|
-
function compileMap() {
|
|
336
|
-
var result = {
|
|
337
|
-
scalar: {},
|
|
338
|
-
sequence: {},
|
|
339
|
-
mapping: {},
|
|
340
|
-
fallback: {},
|
|
341
|
-
multi: {
|
|
342
|
-
scalar: [],
|
|
343
|
-
sequence: [],
|
|
344
|
-
mapping: [],
|
|
345
|
-
fallback: []
|
|
346
|
-
}
|
|
347
|
-
}, index, length;
|
|
348
|
-
function collectType(type2) {
|
|
349
|
-
if (type2.multi) {
|
|
350
|
-
result.multi[type2.kind].push(type2);
|
|
351
|
-
result.multi["fallback"].push(type2);
|
|
352
|
-
} else {
|
|
353
|
-
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
357
|
-
arguments[index].forEach(collectType);
|
|
358
|
-
}
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
|
-
function Schema$1(definition) {
|
|
362
|
-
return this.extend(definition);
|
|
363
|
-
}
|
|
364
|
-
Schema$1.prototype.extend = function extend2(definition) {
|
|
365
|
-
var implicit = [];
|
|
366
|
-
var explicit = [];
|
|
367
|
-
if (definition instanceof type) {
|
|
368
|
-
explicit.push(definition);
|
|
369
|
-
} else if (Array.isArray(definition)) {
|
|
370
|
-
explicit = explicit.concat(definition);
|
|
371
|
-
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
372
|
-
if (definition.implicit) implicit = implicit.concat(definition.implicit);
|
|
373
|
-
if (definition.explicit) explicit = explicit.concat(definition.explicit);
|
|
374
|
-
} else {
|
|
375
|
-
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
376
|
-
}
|
|
377
|
-
implicit.forEach(function(type$1) {
|
|
378
|
-
if (!(type$1 instanceof type)) {
|
|
379
|
-
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
380
|
-
}
|
|
381
|
-
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
382
|
-
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
383
|
-
}
|
|
384
|
-
if (type$1.multi) {
|
|
385
|
-
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
explicit.forEach(function(type$1) {
|
|
389
|
-
if (!(type$1 instanceof type)) {
|
|
390
|
-
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
var result = Object.create(Schema$1.prototype);
|
|
394
|
-
result.implicit = (this.implicit || []).concat(implicit);
|
|
395
|
-
result.explicit = (this.explicit || []).concat(explicit);
|
|
396
|
-
result.compiledImplicit = compileList(result, "implicit");
|
|
397
|
-
result.compiledExplicit = compileList(result, "explicit");
|
|
398
|
-
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
399
|
-
return result;
|
|
400
|
-
};
|
|
401
|
-
var schema = Schema$1;
|
|
402
|
-
var str = new type("tag:yaml.org,2002:str", {
|
|
403
|
-
kind: "scalar",
|
|
404
|
-
construct: function(data) {
|
|
405
|
-
return data !== null ? data : "";
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
var seq = new type("tag:yaml.org,2002:seq", {
|
|
409
|
-
kind: "sequence",
|
|
410
|
-
construct: function(data) {
|
|
411
|
-
return data !== null ? data : [];
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
var map = new type("tag:yaml.org,2002:map", {
|
|
415
|
-
kind: "mapping",
|
|
416
|
-
construct: function(data) {
|
|
417
|
-
return data !== null ? data : {};
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
var failsafe = new schema({
|
|
421
|
-
explicit: [
|
|
422
|
-
str,
|
|
423
|
-
seq,
|
|
424
|
-
map
|
|
425
|
-
]
|
|
426
|
-
});
|
|
427
|
-
function resolveYamlNull(data) {
|
|
428
|
-
if (data === null) return true;
|
|
429
|
-
var max = data.length;
|
|
430
|
-
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
431
|
-
}
|
|
432
|
-
function constructYamlNull() {
|
|
433
|
-
return null;
|
|
434
|
-
}
|
|
435
|
-
function isNull(object) {
|
|
436
|
-
return object === null;
|
|
437
|
-
}
|
|
438
|
-
var _null = new type("tag:yaml.org,2002:null", {
|
|
439
|
-
kind: "scalar",
|
|
440
|
-
resolve: resolveYamlNull,
|
|
441
|
-
construct: constructYamlNull,
|
|
442
|
-
predicate: isNull,
|
|
443
|
-
represent: {
|
|
444
|
-
canonical: function() {
|
|
445
|
-
return "~";
|
|
446
|
-
},
|
|
447
|
-
lowercase: function() {
|
|
448
|
-
return "null";
|
|
449
|
-
},
|
|
450
|
-
uppercase: function() {
|
|
451
|
-
return "NULL";
|
|
452
|
-
},
|
|
453
|
-
camelcase: function() {
|
|
454
|
-
return "Null";
|
|
455
|
-
},
|
|
456
|
-
empty: function() {
|
|
457
|
-
return "";
|
|
458
|
-
}
|
|
459
|
-
},
|
|
460
|
-
defaultStyle: "lowercase"
|
|
461
|
-
});
|
|
462
|
-
function resolveYamlBoolean(data) {
|
|
463
|
-
if (data === null) return false;
|
|
464
|
-
var max = data.length;
|
|
465
|
-
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
466
|
-
}
|
|
467
|
-
function constructYamlBoolean(data) {
|
|
468
|
-
return data === "true" || data === "True" || data === "TRUE";
|
|
469
|
-
}
|
|
470
|
-
function isBoolean(object) {
|
|
471
|
-
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
472
|
-
}
|
|
473
|
-
var bool = new type("tag:yaml.org,2002:bool", {
|
|
474
|
-
kind: "scalar",
|
|
475
|
-
resolve: resolveYamlBoolean,
|
|
476
|
-
construct: constructYamlBoolean,
|
|
477
|
-
predicate: isBoolean,
|
|
478
|
-
represent: {
|
|
479
|
-
lowercase: function(object) {
|
|
480
|
-
return object ? "true" : "false";
|
|
481
|
-
},
|
|
482
|
-
uppercase: function(object) {
|
|
483
|
-
return object ? "TRUE" : "FALSE";
|
|
484
|
-
},
|
|
485
|
-
camelcase: function(object) {
|
|
486
|
-
return object ? "True" : "False";
|
|
487
|
-
}
|
|
488
|
-
},
|
|
489
|
-
defaultStyle: "lowercase"
|
|
490
|
-
});
|
|
491
|
-
function isHexCode(c) {
|
|
492
|
-
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
493
|
-
}
|
|
494
|
-
function isOctCode(c) {
|
|
495
|
-
return 48 <= c && c <= 55;
|
|
496
|
-
}
|
|
497
|
-
function isDecCode(c) {
|
|
498
|
-
return 48 <= c && c <= 57;
|
|
499
|
-
}
|
|
500
|
-
function resolveYamlInteger(data) {
|
|
501
|
-
if (data === null) return false;
|
|
502
|
-
var max = data.length, index = 0, hasDigits = false, ch;
|
|
503
|
-
if (!max) return false;
|
|
504
|
-
ch = data[index];
|
|
505
|
-
if (ch === "-" || ch === "+") {
|
|
506
|
-
ch = data[++index];
|
|
507
|
-
}
|
|
508
|
-
if (ch === "0") {
|
|
509
|
-
if (index + 1 === max) return true;
|
|
510
|
-
ch = data[++index];
|
|
511
|
-
if (ch === "b") {
|
|
512
|
-
index++;
|
|
513
|
-
for (; index < max; index++) {
|
|
514
|
-
ch = data[index];
|
|
515
|
-
if (ch === "_") continue;
|
|
516
|
-
if (ch !== "0" && ch !== "1") return false;
|
|
517
|
-
hasDigits = true;
|
|
518
|
-
}
|
|
519
|
-
return hasDigits && ch !== "_";
|
|
520
|
-
}
|
|
521
|
-
if (ch === "x") {
|
|
522
|
-
index++;
|
|
523
|
-
for (; index < max; index++) {
|
|
524
|
-
ch = data[index];
|
|
525
|
-
if (ch === "_") continue;
|
|
526
|
-
if (!isHexCode(data.charCodeAt(index))) return false;
|
|
527
|
-
hasDigits = true;
|
|
528
|
-
}
|
|
529
|
-
return hasDigits && ch !== "_";
|
|
530
|
-
}
|
|
531
|
-
if (ch === "o") {
|
|
532
|
-
index++;
|
|
533
|
-
for (; index < max; index++) {
|
|
534
|
-
ch = data[index];
|
|
535
|
-
if (ch === "_") continue;
|
|
536
|
-
if (!isOctCode(data.charCodeAt(index))) return false;
|
|
537
|
-
hasDigits = true;
|
|
538
|
-
}
|
|
539
|
-
return hasDigits && ch !== "_";
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
if (ch === "_") return false;
|
|
543
|
-
for (; index < max; index++) {
|
|
544
|
-
ch = data[index];
|
|
545
|
-
if (ch === "_") continue;
|
|
546
|
-
if (!isDecCode(data.charCodeAt(index))) {
|
|
547
|
-
return false;
|
|
548
|
-
}
|
|
549
|
-
hasDigits = true;
|
|
550
|
-
}
|
|
551
|
-
if (!hasDigits || ch === "_") return false;
|
|
552
|
-
return true;
|
|
553
|
-
}
|
|
554
|
-
function constructYamlInteger(data) {
|
|
555
|
-
var value = data, sign = 1, ch;
|
|
556
|
-
if (value.indexOf("_") !== -1) {
|
|
557
|
-
value = value.replace(/_/g, "");
|
|
558
|
-
}
|
|
559
|
-
ch = value[0];
|
|
560
|
-
if (ch === "-" || ch === "+") {
|
|
561
|
-
if (ch === "-") sign = -1;
|
|
562
|
-
value = value.slice(1);
|
|
563
|
-
ch = value[0];
|
|
564
|
-
}
|
|
565
|
-
if (value === "0") return 0;
|
|
566
|
-
if (ch === "0") {
|
|
567
|
-
if (value[1] === "b") return sign * parseInt(value.slice(2), 2);
|
|
568
|
-
if (value[1] === "x") return sign * parseInt(value.slice(2), 16);
|
|
569
|
-
if (value[1] === "o") return sign * parseInt(value.slice(2), 8);
|
|
570
|
-
}
|
|
571
|
-
return sign * parseInt(value, 10);
|
|
572
|
-
}
|
|
573
|
-
function isInteger(object) {
|
|
574
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
575
|
-
}
|
|
576
|
-
var int = new type("tag:yaml.org,2002:int", {
|
|
577
|
-
kind: "scalar",
|
|
578
|
-
resolve: resolveYamlInteger,
|
|
579
|
-
construct: constructYamlInteger,
|
|
580
|
-
predicate: isInteger,
|
|
581
|
-
represent: {
|
|
582
|
-
binary: function(obj) {
|
|
583
|
-
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
584
|
-
},
|
|
585
|
-
octal: function(obj) {
|
|
586
|
-
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
587
|
-
},
|
|
588
|
-
decimal: function(obj) {
|
|
589
|
-
return obj.toString(10);
|
|
590
|
-
},
|
|
591
|
-
/* eslint-disable max-len */
|
|
592
|
-
hexadecimal: function(obj) {
|
|
593
|
-
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
594
|
-
}
|
|
595
|
-
},
|
|
596
|
-
defaultStyle: "decimal",
|
|
597
|
-
styleAliases: {
|
|
598
|
-
binary: [2, "bin"],
|
|
599
|
-
octal: [8, "oct"],
|
|
600
|
-
decimal: [10, "dec"],
|
|
601
|
-
hexadecimal: [16, "hex"]
|
|
602
|
-
}
|
|
603
|
-
});
|
|
604
|
-
var YAML_FLOAT_PATTERN = new RegExp(
|
|
605
|
-
// 2.5e4, 2.5 and integers
|
|
606
|
-
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
607
|
-
);
|
|
608
|
-
function resolveYamlFloat(data) {
|
|
609
|
-
if (data === null) return false;
|
|
610
|
-
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
611
|
-
// Probably should update regexp & check speed
|
|
612
|
-
data[data.length - 1] === "_") {
|
|
613
|
-
return false;
|
|
614
|
-
}
|
|
615
|
-
return true;
|
|
616
|
-
}
|
|
617
|
-
function constructYamlFloat(data) {
|
|
618
|
-
var value, sign;
|
|
619
|
-
value = data.replace(/_/g, "").toLowerCase();
|
|
620
|
-
sign = value[0] === "-" ? -1 : 1;
|
|
621
|
-
if ("+-".indexOf(value[0]) >= 0) {
|
|
622
|
-
value = value.slice(1);
|
|
623
|
-
}
|
|
624
|
-
if (value === ".inf") {
|
|
625
|
-
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
626
|
-
} else if (value === ".nan") {
|
|
627
|
-
return NaN;
|
|
628
|
-
}
|
|
629
|
-
return sign * parseFloat(value, 10);
|
|
630
|
-
}
|
|
631
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
632
|
-
function representYamlFloat(object, style) {
|
|
633
|
-
var res;
|
|
634
|
-
if (isNaN(object)) {
|
|
635
|
-
switch (style) {
|
|
636
|
-
case "lowercase":
|
|
637
|
-
return ".nan";
|
|
638
|
-
case "uppercase":
|
|
639
|
-
return ".NAN";
|
|
640
|
-
case "camelcase":
|
|
641
|
-
return ".NaN";
|
|
642
|
-
}
|
|
643
|
-
} else if (Number.POSITIVE_INFINITY === object) {
|
|
644
|
-
switch (style) {
|
|
645
|
-
case "lowercase":
|
|
646
|
-
return ".inf";
|
|
647
|
-
case "uppercase":
|
|
648
|
-
return ".INF";
|
|
649
|
-
case "camelcase":
|
|
650
|
-
return ".Inf";
|
|
651
|
-
}
|
|
652
|
-
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
653
|
-
switch (style) {
|
|
654
|
-
case "lowercase":
|
|
655
|
-
return "-.inf";
|
|
656
|
-
case "uppercase":
|
|
657
|
-
return "-.INF";
|
|
658
|
-
case "camelcase":
|
|
659
|
-
return "-.Inf";
|
|
660
|
-
}
|
|
661
|
-
} else if (common.isNegativeZero(object)) {
|
|
662
|
-
return "-0.0";
|
|
663
|
-
}
|
|
664
|
-
res = object.toString(10);
|
|
665
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
666
|
-
}
|
|
667
|
-
function isFloat(object) {
|
|
668
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
669
|
-
}
|
|
670
|
-
var float = new type("tag:yaml.org,2002:float", {
|
|
671
|
-
kind: "scalar",
|
|
672
|
-
resolve: resolveYamlFloat,
|
|
673
|
-
construct: constructYamlFloat,
|
|
674
|
-
predicate: isFloat,
|
|
675
|
-
represent: representYamlFloat,
|
|
676
|
-
defaultStyle: "lowercase"
|
|
677
|
-
});
|
|
678
|
-
var json = failsafe.extend({
|
|
679
|
-
implicit: [
|
|
680
|
-
_null,
|
|
681
|
-
bool,
|
|
682
|
-
int,
|
|
683
|
-
float
|
|
684
|
-
]
|
|
685
|
-
});
|
|
686
|
-
var core = json;
|
|
687
|
-
var YAML_DATE_REGEXP = new RegExp(
|
|
688
|
-
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
689
|
-
);
|
|
690
|
-
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
691
|
-
"^([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]))?))?$"
|
|
692
|
-
);
|
|
693
|
-
function resolveYamlTimestamp(data) {
|
|
694
|
-
if (data === null) return false;
|
|
695
|
-
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
696
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
697
|
-
return false;
|
|
698
|
-
}
|
|
699
|
-
function constructYamlTimestamp(data) {
|
|
700
|
-
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
701
|
-
match = YAML_DATE_REGEXP.exec(data);
|
|
702
|
-
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
703
|
-
if (match === null) throw new Error("Date resolve error");
|
|
704
|
-
year = +match[1];
|
|
705
|
-
month = +match[2] - 1;
|
|
706
|
-
day = +match[3];
|
|
707
|
-
if (!match[4]) {
|
|
708
|
-
return new Date(Date.UTC(year, month, day));
|
|
709
|
-
}
|
|
710
|
-
hour = +match[4];
|
|
711
|
-
minute = +match[5];
|
|
712
|
-
second = +match[6];
|
|
713
|
-
if (match[7]) {
|
|
714
|
-
fraction = match[7].slice(0, 3);
|
|
715
|
-
while (fraction.length < 3) {
|
|
716
|
-
fraction += "0";
|
|
717
|
-
}
|
|
718
|
-
fraction = +fraction;
|
|
719
|
-
}
|
|
720
|
-
if (match[9]) {
|
|
721
|
-
tz_hour = +match[10];
|
|
722
|
-
tz_minute = +(match[11] || 0);
|
|
723
|
-
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
724
|
-
if (match[9] === "-") delta = -delta;
|
|
725
|
-
}
|
|
726
|
-
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
727
|
-
if (delta) date.setTime(date.getTime() - delta);
|
|
728
|
-
return date;
|
|
729
|
-
}
|
|
730
|
-
function representYamlTimestamp(object) {
|
|
731
|
-
return object.toISOString();
|
|
732
|
-
}
|
|
733
|
-
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
734
|
-
kind: "scalar",
|
|
735
|
-
resolve: resolveYamlTimestamp,
|
|
736
|
-
construct: constructYamlTimestamp,
|
|
737
|
-
instanceOf: Date,
|
|
738
|
-
represent: representYamlTimestamp
|
|
739
|
-
});
|
|
740
|
-
function resolveYamlMerge(data) {
|
|
741
|
-
return data === "<<" || data === null;
|
|
742
|
-
}
|
|
743
|
-
var merge = new type("tag:yaml.org,2002:merge", {
|
|
744
|
-
kind: "scalar",
|
|
745
|
-
resolve: resolveYamlMerge
|
|
746
|
-
});
|
|
747
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
748
|
-
function resolveYamlBinary(data) {
|
|
749
|
-
if (data === null) return false;
|
|
750
|
-
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
751
|
-
for (idx = 0; idx < max; idx++) {
|
|
752
|
-
code = map2.indexOf(data.charAt(idx));
|
|
753
|
-
if (code > 64) continue;
|
|
754
|
-
if (code < 0) return false;
|
|
755
|
-
bitlen += 6;
|
|
756
|
-
}
|
|
757
|
-
return bitlen % 8 === 0;
|
|
758
|
-
}
|
|
759
|
-
function constructYamlBinary(data) {
|
|
760
|
-
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
761
|
-
for (idx = 0; idx < max; idx++) {
|
|
762
|
-
if (idx % 4 === 0 && idx) {
|
|
763
|
-
result.push(bits >> 16 & 255);
|
|
764
|
-
result.push(bits >> 8 & 255);
|
|
765
|
-
result.push(bits & 255);
|
|
766
|
-
}
|
|
767
|
-
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
768
|
-
}
|
|
769
|
-
tailbits = max % 4 * 6;
|
|
770
|
-
if (tailbits === 0) {
|
|
771
|
-
result.push(bits >> 16 & 255);
|
|
772
|
-
result.push(bits >> 8 & 255);
|
|
773
|
-
result.push(bits & 255);
|
|
774
|
-
} else if (tailbits === 18) {
|
|
775
|
-
result.push(bits >> 10 & 255);
|
|
776
|
-
result.push(bits >> 2 & 255);
|
|
777
|
-
} else if (tailbits === 12) {
|
|
778
|
-
result.push(bits >> 4 & 255);
|
|
779
|
-
}
|
|
780
|
-
return new Uint8Array(result);
|
|
781
|
-
}
|
|
782
|
-
function representYamlBinary(object) {
|
|
783
|
-
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
784
|
-
for (idx = 0; idx < max; idx++) {
|
|
785
|
-
if (idx % 3 === 0 && idx) {
|
|
786
|
-
result += map2[bits >> 18 & 63];
|
|
787
|
-
result += map2[bits >> 12 & 63];
|
|
788
|
-
result += map2[bits >> 6 & 63];
|
|
789
|
-
result += map2[bits & 63];
|
|
790
|
-
}
|
|
791
|
-
bits = (bits << 8) + object[idx];
|
|
792
|
-
}
|
|
793
|
-
tail = max % 3;
|
|
794
|
-
if (tail === 0) {
|
|
795
|
-
result += map2[bits >> 18 & 63];
|
|
796
|
-
result += map2[bits >> 12 & 63];
|
|
797
|
-
result += map2[bits >> 6 & 63];
|
|
798
|
-
result += map2[bits & 63];
|
|
799
|
-
} else if (tail === 2) {
|
|
800
|
-
result += map2[bits >> 10 & 63];
|
|
801
|
-
result += map2[bits >> 4 & 63];
|
|
802
|
-
result += map2[bits << 2 & 63];
|
|
803
|
-
result += map2[64];
|
|
804
|
-
} else if (tail === 1) {
|
|
805
|
-
result += map2[bits >> 2 & 63];
|
|
806
|
-
result += map2[bits << 4 & 63];
|
|
807
|
-
result += map2[64];
|
|
808
|
-
result += map2[64];
|
|
809
|
-
}
|
|
810
|
-
return result;
|
|
811
|
-
}
|
|
812
|
-
function isBinary(obj) {
|
|
813
|
-
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
814
|
-
}
|
|
815
|
-
var binary = new type("tag:yaml.org,2002:binary", {
|
|
816
|
-
kind: "scalar",
|
|
817
|
-
resolve: resolveYamlBinary,
|
|
818
|
-
construct: constructYamlBinary,
|
|
819
|
-
predicate: isBinary,
|
|
820
|
-
represent: representYamlBinary
|
|
821
|
-
});
|
|
822
|
-
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
823
|
-
var _toString$2 = Object.prototype.toString;
|
|
824
|
-
function resolveYamlOmap(data) {
|
|
825
|
-
if (data === null) return true;
|
|
826
|
-
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
827
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
828
|
-
pair = object[index];
|
|
829
|
-
pairHasKey = false;
|
|
830
|
-
if (_toString$2.call(pair) !== "[object Object]") return false;
|
|
831
|
-
for (pairKey in pair) {
|
|
832
|
-
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
833
|
-
if (!pairHasKey) pairHasKey = true;
|
|
834
|
-
else return false;
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
if (!pairHasKey) return false;
|
|
838
|
-
if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
|
|
839
|
-
else return false;
|
|
840
|
-
}
|
|
841
|
-
return true;
|
|
842
|
-
}
|
|
843
|
-
function constructYamlOmap(data) {
|
|
844
|
-
return data !== null ? data : [];
|
|
845
|
-
}
|
|
846
|
-
var omap = new type("tag:yaml.org,2002:omap", {
|
|
847
|
-
kind: "sequence",
|
|
848
|
-
resolve: resolveYamlOmap,
|
|
849
|
-
construct: constructYamlOmap
|
|
850
|
-
});
|
|
851
|
-
var _toString$1 = Object.prototype.toString;
|
|
852
|
-
function resolveYamlPairs(data) {
|
|
853
|
-
if (data === null) return true;
|
|
854
|
-
var index, length, pair, keys, result, object = data;
|
|
855
|
-
result = new Array(object.length);
|
|
856
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
857
|
-
pair = object[index];
|
|
858
|
-
if (_toString$1.call(pair) !== "[object Object]") return false;
|
|
859
|
-
keys = Object.keys(pair);
|
|
860
|
-
if (keys.length !== 1) return false;
|
|
861
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
862
|
-
}
|
|
863
|
-
return true;
|
|
864
|
-
}
|
|
865
|
-
function constructYamlPairs(data) {
|
|
866
|
-
if (data === null) return [];
|
|
867
|
-
var index, length, pair, keys, result, object = data;
|
|
868
|
-
result = new Array(object.length);
|
|
869
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
870
|
-
pair = object[index];
|
|
871
|
-
keys = Object.keys(pair);
|
|
872
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
873
|
-
}
|
|
874
|
-
return result;
|
|
875
|
-
}
|
|
876
|
-
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
877
|
-
kind: "sequence",
|
|
878
|
-
resolve: resolveYamlPairs,
|
|
879
|
-
construct: constructYamlPairs
|
|
880
|
-
});
|
|
881
|
-
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
882
|
-
function resolveYamlSet(data) {
|
|
883
|
-
if (data === null) return true;
|
|
884
|
-
var key, object = data;
|
|
885
|
-
for (key in object) {
|
|
886
|
-
if (_hasOwnProperty$2.call(object, key)) {
|
|
887
|
-
if (object[key] !== null) return false;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
return true;
|
|
891
|
-
}
|
|
892
|
-
function constructYamlSet(data) {
|
|
893
|
-
return data !== null ? data : {};
|
|
894
|
-
}
|
|
895
|
-
var set = new type("tag:yaml.org,2002:set", {
|
|
896
|
-
kind: "mapping",
|
|
897
|
-
resolve: resolveYamlSet,
|
|
898
|
-
construct: constructYamlSet
|
|
899
|
-
});
|
|
900
|
-
var _default = core.extend({
|
|
901
|
-
implicit: [
|
|
902
|
-
timestamp,
|
|
903
|
-
merge
|
|
904
|
-
],
|
|
905
|
-
explicit: [
|
|
906
|
-
binary,
|
|
907
|
-
omap,
|
|
908
|
-
pairs,
|
|
909
|
-
set
|
|
910
|
-
]
|
|
911
|
-
});
|
|
912
|
-
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
913
|
-
var CONTEXT_FLOW_IN = 1;
|
|
914
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
915
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
916
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
917
|
-
var CHOMPING_CLIP = 1;
|
|
918
|
-
var CHOMPING_STRIP = 2;
|
|
919
|
-
var CHOMPING_KEEP = 3;
|
|
920
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
921
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
922
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
923
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
924
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
925
|
-
function _class(obj) {
|
|
926
|
-
return Object.prototype.toString.call(obj);
|
|
927
|
-
}
|
|
928
|
-
function is_EOL(c) {
|
|
929
|
-
return c === 10 || c === 13;
|
|
930
|
-
}
|
|
931
|
-
function is_WHITE_SPACE(c) {
|
|
932
|
-
return c === 9 || c === 32;
|
|
933
|
-
}
|
|
934
|
-
function is_WS_OR_EOL(c) {
|
|
935
|
-
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
936
|
-
}
|
|
937
|
-
function is_FLOW_INDICATOR(c) {
|
|
938
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
939
|
-
}
|
|
940
|
-
function fromHexCode(c) {
|
|
941
|
-
var lc;
|
|
942
|
-
if (48 <= c && c <= 57) {
|
|
943
|
-
return c - 48;
|
|
944
|
-
}
|
|
945
|
-
lc = c | 32;
|
|
946
|
-
if (97 <= lc && lc <= 102) {
|
|
947
|
-
return lc - 97 + 10;
|
|
948
|
-
}
|
|
949
|
-
return -1;
|
|
950
|
-
}
|
|
951
|
-
function escapedHexLen(c) {
|
|
952
|
-
if (c === 120) {
|
|
953
|
-
return 2;
|
|
954
|
-
}
|
|
955
|
-
if (c === 117) {
|
|
956
|
-
return 4;
|
|
957
|
-
}
|
|
958
|
-
if (c === 85) {
|
|
959
|
-
return 8;
|
|
960
|
-
}
|
|
961
|
-
return 0;
|
|
962
|
-
}
|
|
963
|
-
function fromDecimalCode(c) {
|
|
964
|
-
if (48 <= c && c <= 57) {
|
|
965
|
-
return c - 48;
|
|
966
|
-
}
|
|
967
|
-
return -1;
|
|
968
|
-
}
|
|
969
|
-
function simpleEscapeSequence(c) {
|
|
970
|
-
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
971
|
-
}
|
|
972
|
-
function charFromCodepoint(c) {
|
|
973
|
-
if (c <= 65535) {
|
|
974
|
-
return String.fromCharCode(c);
|
|
975
|
-
}
|
|
976
|
-
return String.fromCharCode(
|
|
977
|
-
(c - 65536 >> 10) + 55296,
|
|
978
|
-
(c - 65536 & 1023) + 56320
|
|
979
|
-
);
|
|
980
|
-
}
|
|
981
|
-
var simpleEscapeCheck = new Array(256);
|
|
982
|
-
var simpleEscapeMap = new Array(256);
|
|
983
|
-
for (i = 0; i < 256; i++) {
|
|
984
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
985
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
986
|
-
}
|
|
987
|
-
var i;
|
|
988
|
-
function State$1(input, options) {
|
|
989
|
-
this.input = input;
|
|
990
|
-
this.filename = options["filename"] || null;
|
|
991
|
-
this.schema = options["schema"] || _default;
|
|
992
|
-
this.onWarning = options["onWarning"] || null;
|
|
993
|
-
this.legacy = options["legacy"] || false;
|
|
994
|
-
this.json = options["json"] || false;
|
|
995
|
-
this.listener = options["listener"] || null;
|
|
996
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
997
|
-
this.typeMap = this.schema.compiledTypeMap;
|
|
998
|
-
this.length = input.length;
|
|
999
|
-
this.position = 0;
|
|
1000
|
-
this.line = 0;
|
|
1001
|
-
this.lineStart = 0;
|
|
1002
|
-
this.lineIndent = 0;
|
|
1003
|
-
this.firstTabInLine = -1;
|
|
1004
|
-
this.documents = [];
|
|
1005
|
-
}
|
|
1006
|
-
function generateError(state, message) {
|
|
1007
|
-
var mark = {
|
|
1008
|
-
name: state.filename,
|
|
1009
|
-
buffer: state.input.slice(0, -1),
|
|
1010
|
-
// omit trailing \0
|
|
1011
|
-
position: state.position,
|
|
1012
|
-
line: state.line,
|
|
1013
|
-
column: state.position - state.lineStart
|
|
1014
|
-
};
|
|
1015
|
-
mark.snippet = snippet(mark);
|
|
1016
|
-
return new exception(message, mark);
|
|
1017
|
-
}
|
|
1018
|
-
function throwError(state, message) {
|
|
1019
|
-
throw generateError(state, message);
|
|
1020
|
-
}
|
|
1021
|
-
function throwWarning(state, message) {
|
|
1022
|
-
if (state.onWarning) {
|
|
1023
|
-
state.onWarning.call(null, generateError(state, message));
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
var directiveHandlers = {
|
|
1027
|
-
YAML: function handleYamlDirective(state, name, args) {
|
|
1028
|
-
var match, major, minor;
|
|
1029
|
-
if (state.version !== null) {
|
|
1030
|
-
throwError(state, "duplication of %YAML directive");
|
|
1031
|
-
}
|
|
1032
|
-
if (args.length !== 1) {
|
|
1033
|
-
throwError(state, "YAML directive accepts exactly one argument");
|
|
1034
|
-
}
|
|
1035
|
-
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1036
|
-
if (match === null) {
|
|
1037
|
-
throwError(state, "ill-formed argument of the YAML directive");
|
|
1038
|
-
}
|
|
1039
|
-
major = parseInt(match[1], 10);
|
|
1040
|
-
minor = parseInt(match[2], 10);
|
|
1041
|
-
if (major !== 1) {
|
|
1042
|
-
throwError(state, "unacceptable YAML version of the document");
|
|
1043
|
-
}
|
|
1044
|
-
state.version = args[0];
|
|
1045
|
-
state.checkLineBreaks = minor < 2;
|
|
1046
|
-
if (minor !== 1 && minor !== 2) {
|
|
1047
|
-
throwWarning(state, "unsupported YAML version of the document");
|
|
1048
|
-
}
|
|
1049
|
-
},
|
|
1050
|
-
TAG: function handleTagDirective(state, name, args) {
|
|
1051
|
-
var handle, prefix;
|
|
1052
|
-
if (args.length !== 2) {
|
|
1053
|
-
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1054
|
-
}
|
|
1055
|
-
handle = args[0];
|
|
1056
|
-
prefix = args[1];
|
|
1057
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1058
|
-
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1059
|
-
}
|
|
1060
|
-
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1061
|
-
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1062
|
-
}
|
|
1063
|
-
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1064
|
-
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1065
|
-
}
|
|
1066
|
-
try {
|
|
1067
|
-
prefix = decodeURIComponent(prefix);
|
|
1068
|
-
} catch (err) {
|
|
1069
|
-
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1070
|
-
}
|
|
1071
|
-
state.tagMap[handle] = prefix;
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
function captureSegment(state, start, end, checkJson) {
|
|
1075
|
-
var _position, _length, _character, _result;
|
|
1076
|
-
if (start < end) {
|
|
1077
|
-
_result = state.input.slice(start, end);
|
|
1078
|
-
if (checkJson) {
|
|
1079
|
-
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1080
|
-
_character = _result.charCodeAt(_position);
|
|
1081
|
-
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1082
|
-
throwError(state, "expected valid JSON character");
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1086
|
-
throwError(state, "the stream contains non-printable characters");
|
|
1087
|
-
}
|
|
1088
|
-
state.result += _result;
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1092
|
-
var sourceKeys, key, index, quantity;
|
|
1093
|
-
if (!common.isObject(source)) {
|
|
1094
|
-
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1095
|
-
}
|
|
1096
|
-
sourceKeys = Object.keys(source);
|
|
1097
|
-
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1098
|
-
key = sourceKeys[index];
|
|
1099
|
-
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1100
|
-
destination[key] = source[key];
|
|
1101
|
-
overridableKeys[key] = true;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1106
|
-
var index, quantity;
|
|
1107
|
-
if (Array.isArray(keyNode)) {
|
|
1108
|
-
keyNode = Array.prototype.slice.call(keyNode);
|
|
1109
|
-
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1110
|
-
if (Array.isArray(keyNode[index])) {
|
|
1111
|
-
throwError(state, "nested arrays are not supported inside keys");
|
|
1112
|
-
}
|
|
1113
|
-
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1114
|
-
keyNode[index] = "[object Object]";
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1119
|
-
keyNode = "[object Object]";
|
|
1120
|
-
}
|
|
1121
|
-
keyNode = String(keyNode);
|
|
1122
|
-
if (_result === null) {
|
|
1123
|
-
_result = {};
|
|
1124
|
-
}
|
|
1125
|
-
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1126
|
-
if (Array.isArray(valueNode)) {
|
|
1127
|
-
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1128
|
-
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1129
|
-
}
|
|
1130
|
-
} else {
|
|
1131
|
-
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1132
|
-
}
|
|
1133
|
-
} else {
|
|
1134
|
-
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1135
|
-
state.line = startLine || state.line;
|
|
1136
|
-
state.lineStart = startLineStart || state.lineStart;
|
|
1137
|
-
state.position = startPos || state.position;
|
|
1138
|
-
throwError(state, "duplicated mapping key");
|
|
1139
|
-
}
|
|
1140
|
-
if (keyNode === "__proto__") {
|
|
1141
|
-
Object.defineProperty(_result, keyNode, {
|
|
1142
|
-
configurable: true,
|
|
1143
|
-
enumerable: true,
|
|
1144
|
-
writable: true,
|
|
1145
|
-
value: valueNode
|
|
1146
|
-
});
|
|
1147
|
-
} else {
|
|
1148
|
-
_result[keyNode] = valueNode;
|
|
1149
|
-
}
|
|
1150
|
-
delete overridableKeys[keyNode];
|
|
1151
|
-
}
|
|
1152
|
-
return _result;
|
|
1153
|
-
}
|
|
1154
|
-
function readLineBreak(state) {
|
|
1155
|
-
var ch;
|
|
1156
|
-
ch = state.input.charCodeAt(state.position);
|
|
1157
|
-
if (ch === 10) {
|
|
1158
|
-
state.position++;
|
|
1159
|
-
} else if (ch === 13) {
|
|
1160
|
-
state.position++;
|
|
1161
|
-
if (state.input.charCodeAt(state.position) === 10) {
|
|
1162
|
-
state.position++;
|
|
1163
|
-
}
|
|
1164
|
-
} else {
|
|
1165
|
-
throwError(state, "a line break is expected");
|
|
1166
|
-
}
|
|
1167
|
-
state.line += 1;
|
|
1168
|
-
state.lineStart = state.position;
|
|
1169
|
-
state.firstTabInLine = -1;
|
|
1170
|
-
}
|
|
1171
|
-
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1172
|
-
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1173
|
-
while (ch !== 0) {
|
|
1174
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1175
|
-
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1176
|
-
state.firstTabInLine = state.position;
|
|
1177
|
-
}
|
|
1178
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1179
|
-
}
|
|
1180
|
-
if (allowComments && ch === 35) {
|
|
1181
|
-
do {
|
|
1182
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1183
|
-
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1184
|
-
}
|
|
1185
|
-
if (is_EOL(ch)) {
|
|
1186
|
-
readLineBreak(state);
|
|
1187
|
-
ch = state.input.charCodeAt(state.position);
|
|
1188
|
-
lineBreaks++;
|
|
1189
|
-
state.lineIndent = 0;
|
|
1190
|
-
while (ch === 32) {
|
|
1191
|
-
state.lineIndent++;
|
|
1192
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1193
|
-
}
|
|
1194
|
-
} else {
|
|
1195
|
-
break;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1199
|
-
throwWarning(state, "deficient indentation");
|
|
1200
|
-
}
|
|
1201
|
-
return lineBreaks;
|
|
1202
|
-
}
|
|
1203
|
-
function testDocumentSeparator(state) {
|
|
1204
|
-
var _position = state.position, ch;
|
|
1205
|
-
ch = state.input.charCodeAt(_position);
|
|
1206
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1207
|
-
_position += 3;
|
|
1208
|
-
ch = state.input.charCodeAt(_position);
|
|
1209
|
-
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1210
|
-
return true;
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
return false;
|
|
1214
|
-
}
|
|
1215
|
-
function writeFoldedLines(state, count) {
|
|
1216
|
-
if (count === 1) {
|
|
1217
|
-
state.result += " ";
|
|
1218
|
-
} else if (count > 1) {
|
|
1219
|
-
state.result += common.repeat("\n", count - 1);
|
|
1220
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1223
|
-
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1224
|
-
ch = state.input.charCodeAt(state.position);
|
|
1225
|
-
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
1226
|
-
return false;
|
|
1227
|
-
}
|
|
1228
|
-
if (ch === 63 || ch === 45) {
|
|
1229
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1230
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1231
|
-
return false;
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
state.kind = "scalar";
|
|
1235
|
-
state.result = "";
|
|
1236
|
-
captureStart = captureEnd = state.position;
|
|
1237
|
-
hasPendingContent = false;
|
|
1238
|
-
while (ch !== 0) {
|
|
1239
|
-
if (ch === 58) {
|
|
1240
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1241
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1242
|
-
break;
|
|
1243
|
-
}
|
|
1244
|
-
} else if (ch === 35) {
|
|
1245
|
-
preceding = state.input.charCodeAt(state.position - 1);
|
|
1246
|
-
if (is_WS_OR_EOL(preceding)) {
|
|
1247
|
-
break;
|
|
1248
|
-
}
|
|
1249
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1250
|
-
break;
|
|
1251
|
-
} else if (is_EOL(ch)) {
|
|
1252
|
-
_line = state.line;
|
|
1253
|
-
_lineStart = state.lineStart;
|
|
1254
|
-
_lineIndent = state.lineIndent;
|
|
1255
|
-
skipSeparationSpace(state, false, -1);
|
|
1256
|
-
if (state.lineIndent >= nodeIndent) {
|
|
1257
|
-
hasPendingContent = true;
|
|
1258
|
-
ch = state.input.charCodeAt(state.position);
|
|
1259
|
-
continue;
|
|
1260
|
-
} else {
|
|
1261
|
-
state.position = captureEnd;
|
|
1262
|
-
state.line = _line;
|
|
1263
|
-
state.lineStart = _lineStart;
|
|
1264
|
-
state.lineIndent = _lineIndent;
|
|
1265
|
-
break;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
if (hasPendingContent) {
|
|
1269
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1270
|
-
writeFoldedLines(state, state.line - _line);
|
|
1271
|
-
captureStart = captureEnd = state.position;
|
|
1272
|
-
hasPendingContent = false;
|
|
1273
|
-
}
|
|
1274
|
-
if (!is_WHITE_SPACE(ch)) {
|
|
1275
|
-
captureEnd = state.position + 1;
|
|
1276
|
-
}
|
|
1277
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1278
|
-
}
|
|
1279
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1280
|
-
if (state.result) {
|
|
1281
|
-
return true;
|
|
1282
|
-
}
|
|
1283
|
-
state.kind = _kind;
|
|
1284
|
-
state.result = _result;
|
|
1285
|
-
return false;
|
|
1286
|
-
}
|
|
1287
|
-
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1288
|
-
var ch, captureStart, captureEnd;
|
|
1289
|
-
ch = state.input.charCodeAt(state.position);
|
|
1290
|
-
if (ch !== 39) {
|
|
1291
|
-
return false;
|
|
1292
|
-
}
|
|
1293
|
-
state.kind = "scalar";
|
|
1294
|
-
state.result = "";
|
|
1295
|
-
state.position++;
|
|
1296
|
-
captureStart = captureEnd = state.position;
|
|
1297
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1298
|
-
if (ch === 39) {
|
|
1299
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1300
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1301
|
-
if (ch === 39) {
|
|
1302
|
-
captureStart = state.position;
|
|
1303
|
-
state.position++;
|
|
1304
|
-
captureEnd = state.position;
|
|
1305
|
-
} else {
|
|
1306
|
-
return true;
|
|
1307
|
-
}
|
|
1308
|
-
} else if (is_EOL(ch)) {
|
|
1309
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1310
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1311
|
-
captureStart = captureEnd = state.position;
|
|
1312
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1313
|
-
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1314
|
-
} else {
|
|
1315
|
-
state.position++;
|
|
1316
|
-
captureEnd = state.position;
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1320
|
-
}
|
|
1321
|
-
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1322
|
-
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1323
|
-
ch = state.input.charCodeAt(state.position);
|
|
1324
|
-
if (ch !== 34) {
|
|
1325
|
-
return false;
|
|
1326
|
-
}
|
|
1327
|
-
state.kind = "scalar";
|
|
1328
|
-
state.result = "";
|
|
1329
|
-
state.position++;
|
|
1330
|
-
captureStart = captureEnd = state.position;
|
|
1331
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1332
|
-
if (ch === 34) {
|
|
1333
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1334
|
-
state.position++;
|
|
1335
|
-
return true;
|
|
1336
|
-
} else if (ch === 92) {
|
|
1337
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1338
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1339
|
-
if (is_EOL(ch)) {
|
|
1340
|
-
skipSeparationSpace(state, false, nodeIndent);
|
|
1341
|
-
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1342
|
-
state.result += simpleEscapeMap[ch];
|
|
1343
|
-
state.position++;
|
|
1344
|
-
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1345
|
-
hexLength = tmp;
|
|
1346
|
-
hexResult = 0;
|
|
1347
|
-
for (; hexLength > 0; hexLength--) {
|
|
1348
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1349
|
-
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1350
|
-
hexResult = (hexResult << 4) + tmp;
|
|
1351
|
-
} else {
|
|
1352
|
-
throwError(state, "expected hexadecimal character");
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
state.result += charFromCodepoint(hexResult);
|
|
1356
|
-
state.position++;
|
|
1357
|
-
} else {
|
|
1358
|
-
throwError(state, "unknown escape sequence");
|
|
1359
|
-
}
|
|
1360
|
-
captureStart = captureEnd = state.position;
|
|
1361
|
-
} else if (is_EOL(ch)) {
|
|
1362
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1363
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1364
|
-
captureStart = captureEnd = state.position;
|
|
1365
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1366
|
-
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1367
|
-
} else {
|
|
1368
|
-
state.position++;
|
|
1369
|
-
captureEnd = state.position;
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1373
|
-
}
|
|
1374
|
-
function readFlowCollection(state, nodeIndent) {
|
|
1375
|
-
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1376
|
-
ch = state.input.charCodeAt(state.position);
|
|
1377
|
-
if (ch === 91) {
|
|
1378
|
-
terminator = 93;
|
|
1379
|
-
isMapping = false;
|
|
1380
|
-
_result = [];
|
|
1381
|
-
} else if (ch === 123) {
|
|
1382
|
-
terminator = 125;
|
|
1383
|
-
isMapping = true;
|
|
1384
|
-
_result = {};
|
|
1385
|
-
} else {
|
|
1386
|
-
return false;
|
|
1387
|
-
}
|
|
1388
|
-
if (state.anchor !== null) {
|
|
1389
|
-
state.anchorMap[state.anchor] = _result;
|
|
1390
|
-
}
|
|
1391
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1392
|
-
while (ch !== 0) {
|
|
1393
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1394
|
-
ch = state.input.charCodeAt(state.position);
|
|
1395
|
-
if (ch === terminator) {
|
|
1396
|
-
state.position++;
|
|
1397
|
-
state.tag = _tag;
|
|
1398
|
-
state.anchor = _anchor;
|
|
1399
|
-
state.kind = isMapping ? "mapping" : "sequence";
|
|
1400
|
-
state.result = _result;
|
|
1401
|
-
return true;
|
|
1402
|
-
} else if (!readNext) {
|
|
1403
|
-
throwError(state, "missed comma between flow collection entries");
|
|
1404
|
-
} else if (ch === 44) {
|
|
1405
|
-
throwError(state, "expected the node content, but found ','");
|
|
1406
|
-
}
|
|
1407
|
-
keyTag = keyNode = valueNode = null;
|
|
1408
|
-
isPair = isExplicitPair = false;
|
|
1409
|
-
if (ch === 63) {
|
|
1410
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1411
|
-
if (is_WS_OR_EOL(following)) {
|
|
1412
|
-
isPair = isExplicitPair = true;
|
|
1413
|
-
state.position++;
|
|
1414
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
_line = state.line;
|
|
1418
|
-
_lineStart = state.lineStart;
|
|
1419
|
-
_pos = state.position;
|
|
1420
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1421
|
-
keyTag = state.tag;
|
|
1422
|
-
keyNode = state.result;
|
|
1423
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1424
|
-
ch = state.input.charCodeAt(state.position);
|
|
1425
|
-
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1426
|
-
isPair = true;
|
|
1427
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1428
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1429
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1430
|
-
valueNode = state.result;
|
|
1431
|
-
}
|
|
1432
|
-
if (isMapping) {
|
|
1433
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1434
|
-
} else if (isPair) {
|
|
1435
|
-
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1436
|
-
} else {
|
|
1437
|
-
_result.push(keyNode);
|
|
1438
|
-
}
|
|
1439
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1440
|
-
ch = state.input.charCodeAt(state.position);
|
|
1441
|
-
if (ch === 44) {
|
|
1442
|
-
readNext = true;
|
|
1443
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1444
|
-
} else {
|
|
1445
|
-
readNext = false;
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1449
|
-
}
|
|
1450
|
-
function readBlockScalar(state, nodeIndent) {
|
|
1451
|
-
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1452
|
-
ch = state.input.charCodeAt(state.position);
|
|
1453
|
-
if (ch === 124) {
|
|
1454
|
-
folding = false;
|
|
1455
|
-
} else if (ch === 62) {
|
|
1456
|
-
folding = true;
|
|
1457
|
-
} else {
|
|
1458
|
-
return false;
|
|
1459
|
-
}
|
|
1460
|
-
state.kind = "scalar";
|
|
1461
|
-
state.result = "";
|
|
1462
|
-
while (ch !== 0) {
|
|
1463
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1464
|
-
if (ch === 43 || ch === 45) {
|
|
1465
|
-
if (CHOMPING_CLIP === chomping) {
|
|
1466
|
-
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1467
|
-
} else {
|
|
1468
|
-
throwError(state, "repeat of a chomping mode identifier");
|
|
1469
|
-
}
|
|
1470
|
-
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1471
|
-
if (tmp === 0) {
|
|
1472
|
-
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1473
|
-
} else if (!detectedIndent) {
|
|
1474
|
-
textIndent = nodeIndent + tmp - 1;
|
|
1475
|
-
detectedIndent = true;
|
|
1476
|
-
} else {
|
|
1477
|
-
throwError(state, "repeat of an indentation width identifier");
|
|
1478
|
-
}
|
|
1479
|
-
} else {
|
|
1480
|
-
break;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1484
|
-
do {
|
|
1485
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1486
|
-
} while (is_WHITE_SPACE(ch));
|
|
1487
|
-
if (ch === 35) {
|
|
1488
|
-
do {
|
|
1489
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1490
|
-
} while (!is_EOL(ch) && ch !== 0);
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
while (ch !== 0) {
|
|
1494
|
-
readLineBreak(state);
|
|
1495
|
-
state.lineIndent = 0;
|
|
1496
|
-
ch = state.input.charCodeAt(state.position);
|
|
1497
|
-
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1498
|
-
state.lineIndent++;
|
|
1499
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1500
|
-
}
|
|
1501
|
-
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1502
|
-
textIndent = state.lineIndent;
|
|
1503
|
-
}
|
|
1504
|
-
if (is_EOL(ch)) {
|
|
1505
|
-
emptyLines++;
|
|
1506
|
-
continue;
|
|
1507
|
-
}
|
|
1508
|
-
if (state.lineIndent < textIndent) {
|
|
1509
|
-
if (chomping === CHOMPING_KEEP) {
|
|
1510
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1511
|
-
} else if (chomping === CHOMPING_CLIP) {
|
|
1512
|
-
if (didReadContent) {
|
|
1513
|
-
state.result += "\n";
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
break;
|
|
1517
|
-
}
|
|
1518
|
-
if (folding) {
|
|
1519
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1520
|
-
atMoreIndented = true;
|
|
1521
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1522
|
-
} else if (atMoreIndented) {
|
|
1523
|
-
atMoreIndented = false;
|
|
1524
|
-
state.result += common.repeat("\n", emptyLines + 1);
|
|
1525
|
-
} else if (emptyLines === 0) {
|
|
1526
|
-
if (didReadContent) {
|
|
1527
|
-
state.result += " ";
|
|
1528
|
-
}
|
|
1529
|
-
} else {
|
|
1530
|
-
state.result += common.repeat("\n", emptyLines);
|
|
1531
|
-
}
|
|
1532
|
-
} else {
|
|
1533
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1534
|
-
}
|
|
1535
|
-
didReadContent = true;
|
|
1536
|
-
detectedIndent = true;
|
|
1537
|
-
emptyLines = 0;
|
|
1538
|
-
captureStart = state.position;
|
|
1539
|
-
while (!is_EOL(ch) && ch !== 0) {
|
|
1540
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1541
|
-
}
|
|
1542
|
-
captureSegment(state, captureStart, state.position, false);
|
|
1543
|
-
}
|
|
1544
|
-
return true;
|
|
1545
|
-
}
|
|
1546
|
-
function readBlockSequence(state, nodeIndent) {
|
|
1547
|
-
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1548
|
-
if (state.firstTabInLine !== -1) return false;
|
|
1549
|
-
if (state.anchor !== null) {
|
|
1550
|
-
state.anchorMap[state.anchor] = _result;
|
|
1551
|
-
}
|
|
1552
|
-
ch = state.input.charCodeAt(state.position);
|
|
1553
|
-
while (ch !== 0) {
|
|
1554
|
-
if (state.firstTabInLine !== -1) {
|
|
1555
|
-
state.position = state.firstTabInLine;
|
|
1556
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1557
|
-
}
|
|
1558
|
-
if (ch !== 45) {
|
|
1559
|
-
break;
|
|
1560
|
-
}
|
|
1561
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1562
|
-
if (!is_WS_OR_EOL(following)) {
|
|
1563
|
-
break;
|
|
1564
|
-
}
|
|
1565
|
-
detected = true;
|
|
1566
|
-
state.position++;
|
|
1567
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1568
|
-
if (state.lineIndent <= nodeIndent) {
|
|
1569
|
-
_result.push(null);
|
|
1570
|
-
ch = state.input.charCodeAt(state.position);
|
|
1571
|
-
continue;
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
_line = state.line;
|
|
1575
|
-
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1576
|
-
_result.push(state.result);
|
|
1577
|
-
skipSeparationSpace(state, true, -1);
|
|
1578
|
-
ch = state.input.charCodeAt(state.position);
|
|
1579
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1580
|
-
throwError(state, "bad indentation of a sequence entry");
|
|
1581
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1582
|
-
break;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
if (detected) {
|
|
1586
|
-
state.tag = _tag;
|
|
1587
|
-
state.anchor = _anchor;
|
|
1588
|
-
state.kind = "sequence";
|
|
1589
|
-
state.result = _result;
|
|
1590
|
-
return true;
|
|
1591
|
-
}
|
|
1592
|
-
return false;
|
|
1593
|
-
}
|
|
1594
|
-
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1595
|
-
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1596
|
-
if (state.firstTabInLine !== -1) return false;
|
|
1597
|
-
if (state.anchor !== null) {
|
|
1598
|
-
state.anchorMap[state.anchor] = _result;
|
|
1599
|
-
}
|
|
1600
|
-
ch = state.input.charCodeAt(state.position);
|
|
1601
|
-
while (ch !== 0) {
|
|
1602
|
-
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1603
|
-
state.position = state.firstTabInLine;
|
|
1604
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1605
|
-
}
|
|
1606
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1607
|
-
_line = state.line;
|
|
1608
|
-
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1609
|
-
if (ch === 63) {
|
|
1610
|
-
if (atExplicitKey) {
|
|
1611
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1612
|
-
keyTag = keyNode = valueNode = null;
|
|
1613
|
-
}
|
|
1614
|
-
detected = true;
|
|
1615
|
-
atExplicitKey = true;
|
|
1616
|
-
allowCompact = true;
|
|
1617
|
-
} else if (atExplicitKey) {
|
|
1618
|
-
atExplicitKey = false;
|
|
1619
|
-
allowCompact = true;
|
|
1620
|
-
} else {
|
|
1621
|
-
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1622
|
-
}
|
|
1623
|
-
state.position += 1;
|
|
1624
|
-
ch = following;
|
|
1625
|
-
} else {
|
|
1626
|
-
_keyLine = state.line;
|
|
1627
|
-
_keyLineStart = state.lineStart;
|
|
1628
|
-
_keyPos = state.position;
|
|
1629
|
-
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1630
|
-
break;
|
|
1631
|
-
}
|
|
1632
|
-
if (state.line === _line) {
|
|
1633
|
-
ch = state.input.charCodeAt(state.position);
|
|
1634
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1635
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1636
|
-
}
|
|
1637
|
-
if (ch === 58) {
|
|
1638
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1639
|
-
if (!is_WS_OR_EOL(ch)) {
|
|
1640
|
-
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1641
|
-
}
|
|
1642
|
-
if (atExplicitKey) {
|
|
1643
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1644
|
-
keyTag = keyNode = valueNode = null;
|
|
1645
|
-
}
|
|
1646
|
-
detected = true;
|
|
1647
|
-
atExplicitKey = false;
|
|
1648
|
-
allowCompact = false;
|
|
1649
|
-
keyTag = state.tag;
|
|
1650
|
-
keyNode = state.result;
|
|
1651
|
-
} else if (detected) {
|
|
1652
|
-
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1653
|
-
} else {
|
|
1654
|
-
state.tag = _tag;
|
|
1655
|
-
state.anchor = _anchor;
|
|
1656
|
-
return true;
|
|
1657
|
-
}
|
|
1658
|
-
} else if (detected) {
|
|
1659
|
-
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1660
|
-
} else {
|
|
1661
|
-
state.tag = _tag;
|
|
1662
|
-
state.anchor = _anchor;
|
|
1663
|
-
return true;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1667
|
-
if (atExplicitKey) {
|
|
1668
|
-
_keyLine = state.line;
|
|
1669
|
-
_keyLineStart = state.lineStart;
|
|
1670
|
-
_keyPos = state.position;
|
|
1671
|
-
}
|
|
1672
|
-
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1673
|
-
if (atExplicitKey) {
|
|
1674
|
-
keyNode = state.result;
|
|
1675
|
-
} else {
|
|
1676
|
-
valueNode = state.result;
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
if (!atExplicitKey) {
|
|
1680
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1681
|
-
keyTag = keyNode = valueNode = null;
|
|
1682
|
-
}
|
|
1683
|
-
skipSeparationSpace(state, true, -1);
|
|
1684
|
-
ch = state.input.charCodeAt(state.position);
|
|
1685
|
-
}
|
|
1686
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1687
|
-
throwError(state, "bad indentation of a mapping entry");
|
|
1688
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1689
|
-
break;
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
if (atExplicitKey) {
|
|
1693
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1694
|
-
}
|
|
1695
|
-
if (detected) {
|
|
1696
|
-
state.tag = _tag;
|
|
1697
|
-
state.anchor = _anchor;
|
|
1698
|
-
state.kind = "mapping";
|
|
1699
|
-
state.result = _result;
|
|
1700
|
-
}
|
|
1701
|
-
return detected;
|
|
1702
|
-
}
|
|
1703
|
-
function readTagProperty(state) {
|
|
1704
|
-
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1705
|
-
ch = state.input.charCodeAt(state.position);
|
|
1706
|
-
if (ch !== 33) return false;
|
|
1707
|
-
if (state.tag !== null) {
|
|
1708
|
-
throwError(state, "duplication of a tag property");
|
|
1709
|
-
}
|
|
1710
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1711
|
-
if (ch === 60) {
|
|
1712
|
-
isVerbatim = true;
|
|
1713
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1714
|
-
} else if (ch === 33) {
|
|
1715
|
-
isNamed = true;
|
|
1716
|
-
tagHandle = "!!";
|
|
1717
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1718
|
-
} else {
|
|
1719
|
-
tagHandle = "!";
|
|
1720
|
-
}
|
|
1721
|
-
_position = state.position;
|
|
1722
|
-
if (isVerbatim) {
|
|
1723
|
-
do {
|
|
1724
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1725
|
-
} while (ch !== 0 && ch !== 62);
|
|
1726
|
-
if (state.position < state.length) {
|
|
1727
|
-
tagName = state.input.slice(_position, state.position);
|
|
1728
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1729
|
-
} else {
|
|
1730
|
-
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
1731
|
-
}
|
|
1732
|
-
} else {
|
|
1733
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1734
|
-
if (ch === 33) {
|
|
1735
|
-
if (!isNamed) {
|
|
1736
|
-
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
1737
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
1738
|
-
throwError(state, "named tag handle cannot contain such characters");
|
|
1739
|
-
}
|
|
1740
|
-
isNamed = true;
|
|
1741
|
-
_position = state.position + 1;
|
|
1742
|
-
} else {
|
|
1743
|
-
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
1744
|
-
}
|
|
1745
|
-
}
|
|
1746
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1747
|
-
}
|
|
1748
|
-
tagName = state.input.slice(_position, state.position);
|
|
1749
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
1750
|
-
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
1751
|
-
}
|
|
1752
|
-
}
|
|
1753
|
-
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
1754
|
-
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
1755
|
-
}
|
|
1756
|
-
try {
|
|
1757
|
-
tagName = decodeURIComponent(tagName);
|
|
1758
|
-
} catch (err) {
|
|
1759
|
-
throwError(state, "tag name is malformed: " + tagName);
|
|
1760
|
-
}
|
|
1761
|
-
if (isVerbatim) {
|
|
1762
|
-
state.tag = tagName;
|
|
1763
|
-
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
1764
|
-
state.tag = state.tagMap[tagHandle] + tagName;
|
|
1765
|
-
} else if (tagHandle === "!") {
|
|
1766
|
-
state.tag = "!" + tagName;
|
|
1767
|
-
} else if (tagHandle === "!!") {
|
|
1768
|
-
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
1769
|
-
} else {
|
|
1770
|
-
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
1771
|
-
}
|
|
1772
|
-
return true;
|
|
1773
|
-
}
|
|
1774
|
-
function readAnchorProperty(state) {
|
|
1775
|
-
var _position, ch;
|
|
1776
|
-
ch = state.input.charCodeAt(state.position);
|
|
1777
|
-
if (ch !== 38) return false;
|
|
1778
|
-
if (state.anchor !== null) {
|
|
1779
|
-
throwError(state, "duplication of an anchor property");
|
|
1780
|
-
}
|
|
1781
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1782
|
-
_position = state.position;
|
|
1783
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1784
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1785
|
-
}
|
|
1786
|
-
if (state.position === _position) {
|
|
1787
|
-
throwError(state, "name of an anchor node must contain at least one character");
|
|
1788
|
-
}
|
|
1789
|
-
state.anchor = state.input.slice(_position, state.position);
|
|
1790
|
-
return true;
|
|
1791
|
-
}
|
|
1792
|
-
function readAlias(state) {
|
|
1793
|
-
var _position, alias, ch;
|
|
1794
|
-
ch = state.input.charCodeAt(state.position);
|
|
1795
|
-
if (ch !== 42) return false;
|
|
1796
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1797
|
-
_position = state.position;
|
|
1798
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
1799
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1800
|
-
}
|
|
1801
|
-
if (state.position === _position) {
|
|
1802
|
-
throwError(state, "name of an alias node must contain at least one character");
|
|
1803
|
-
}
|
|
1804
|
-
alias = state.input.slice(_position, state.position);
|
|
1805
|
-
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
1806
|
-
throwError(state, 'unidentified alias "' + alias + '"');
|
|
1807
|
-
}
|
|
1808
|
-
state.result = state.anchorMap[alias];
|
|
1809
|
-
skipSeparationSpace(state, true, -1);
|
|
1810
|
-
return true;
|
|
1811
|
-
}
|
|
1812
|
-
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
1813
|
-
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
1814
|
-
if (state.listener !== null) {
|
|
1815
|
-
state.listener("open", state);
|
|
1816
|
-
}
|
|
1817
|
-
state.tag = null;
|
|
1818
|
-
state.anchor = null;
|
|
1819
|
-
state.kind = null;
|
|
1820
|
-
state.result = null;
|
|
1821
|
-
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
1822
|
-
if (allowToSeek) {
|
|
1823
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1824
|
-
atNewLine = true;
|
|
1825
|
-
if (state.lineIndent > parentIndent) {
|
|
1826
|
-
indentStatus = 1;
|
|
1827
|
-
} else if (state.lineIndent === parentIndent) {
|
|
1828
|
-
indentStatus = 0;
|
|
1829
|
-
} else if (state.lineIndent < parentIndent) {
|
|
1830
|
-
indentStatus = -1;
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
}
|
|
1834
|
-
if (indentStatus === 1) {
|
|
1835
|
-
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
1836
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1837
|
-
atNewLine = true;
|
|
1838
|
-
allowBlockCollections = allowBlockStyles;
|
|
1839
|
-
if (state.lineIndent > parentIndent) {
|
|
1840
|
-
indentStatus = 1;
|
|
1841
|
-
} else if (state.lineIndent === parentIndent) {
|
|
1842
|
-
indentStatus = 0;
|
|
1843
|
-
} else if (state.lineIndent < parentIndent) {
|
|
1844
|
-
indentStatus = -1;
|
|
1845
|
-
}
|
|
1846
|
-
} else {
|
|
1847
|
-
allowBlockCollections = false;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
if (allowBlockCollections) {
|
|
1852
|
-
allowBlockCollections = atNewLine || allowCompact;
|
|
1853
|
-
}
|
|
1854
|
-
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
1855
|
-
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
1856
|
-
flowIndent = parentIndent;
|
|
1857
|
-
} else {
|
|
1858
|
-
flowIndent = parentIndent + 1;
|
|
1859
|
-
}
|
|
1860
|
-
blockIndent = state.position - state.lineStart;
|
|
1861
|
-
if (indentStatus === 1) {
|
|
1862
|
-
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
1863
|
-
hasContent = true;
|
|
1864
|
-
} else {
|
|
1865
|
-
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
1866
|
-
hasContent = true;
|
|
1867
|
-
} else if (readAlias(state)) {
|
|
1868
|
-
hasContent = true;
|
|
1869
|
-
if (state.tag !== null || state.anchor !== null) {
|
|
1870
|
-
throwError(state, "alias node should not have any properties");
|
|
1871
|
-
}
|
|
1872
|
-
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
1873
|
-
hasContent = true;
|
|
1874
|
-
if (state.tag === null) {
|
|
1875
|
-
state.tag = "?";
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
if (state.anchor !== null) {
|
|
1879
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1880
|
-
}
|
|
1881
|
-
}
|
|
1882
|
-
} else if (indentStatus === 0) {
|
|
1883
|
-
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
if (state.tag === null) {
|
|
1887
|
-
if (state.anchor !== null) {
|
|
1888
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1889
|
-
}
|
|
1890
|
-
} else if (state.tag === "?") {
|
|
1891
|
-
if (state.result !== null && state.kind !== "scalar") {
|
|
1892
|
-
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
1893
|
-
}
|
|
1894
|
-
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1895
|
-
type2 = state.implicitTypes[typeIndex];
|
|
1896
|
-
if (type2.resolve(state.result)) {
|
|
1897
|
-
state.result = type2.construct(state.result);
|
|
1898
|
-
state.tag = type2.tag;
|
|
1899
|
-
if (state.anchor !== null) {
|
|
1900
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1901
|
-
}
|
|
1902
|
-
break;
|
|
1903
|
-
}
|
|
1904
|
-
}
|
|
1905
|
-
} else if (state.tag !== "!") {
|
|
1906
|
-
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
1907
|
-
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
1908
|
-
} else {
|
|
1909
|
-
type2 = null;
|
|
1910
|
-
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
1911
|
-
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
1912
|
-
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
1913
|
-
type2 = typeList[typeIndex];
|
|
1914
|
-
break;
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
}
|
|
1918
|
-
if (!type2) {
|
|
1919
|
-
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
1920
|
-
}
|
|
1921
|
-
if (state.result !== null && type2.kind !== state.kind) {
|
|
1922
|
-
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
1923
|
-
}
|
|
1924
|
-
if (!type2.resolve(state.result, state.tag)) {
|
|
1925
|
-
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
1926
|
-
} else {
|
|
1927
|
-
state.result = type2.construct(state.result, state.tag);
|
|
1928
|
-
if (state.anchor !== null) {
|
|
1929
|
-
state.anchorMap[state.anchor] = state.result;
|
|
1930
|
-
}
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
if (state.listener !== null) {
|
|
1934
|
-
state.listener("close", state);
|
|
1935
|
-
}
|
|
1936
|
-
return state.tag !== null || state.anchor !== null || hasContent;
|
|
1937
|
-
}
|
|
1938
|
-
function readDocument(state) {
|
|
1939
|
-
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
1940
|
-
state.version = null;
|
|
1941
|
-
state.checkLineBreaks = state.legacy;
|
|
1942
|
-
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
1943
|
-
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
1944
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1945
|
-
skipSeparationSpace(state, true, -1);
|
|
1946
|
-
ch = state.input.charCodeAt(state.position);
|
|
1947
|
-
if (state.lineIndent > 0 || ch !== 37) {
|
|
1948
|
-
break;
|
|
1949
|
-
}
|
|
1950
|
-
hasDirectives = true;
|
|
1951
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1952
|
-
_position = state.position;
|
|
1953
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1954
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1955
|
-
}
|
|
1956
|
-
directiveName = state.input.slice(_position, state.position);
|
|
1957
|
-
directiveArgs = [];
|
|
1958
|
-
if (directiveName.length < 1) {
|
|
1959
|
-
throwError(state, "directive name must not be less than one character in length");
|
|
1960
|
-
}
|
|
1961
|
-
while (ch !== 0) {
|
|
1962
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1963
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1964
|
-
}
|
|
1965
|
-
if (ch === 35) {
|
|
1966
|
-
do {
|
|
1967
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1968
|
-
} while (ch !== 0 && !is_EOL(ch));
|
|
1969
|
-
break;
|
|
1970
|
-
}
|
|
1971
|
-
if (is_EOL(ch)) break;
|
|
1972
|
-
_position = state.position;
|
|
1973
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
1974
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1975
|
-
}
|
|
1976
|
-
directiveArgs.push(state.input.slice(_position, state.position));
|
|
1977
|
-
}
|
|
1978
|
-
if (ch !== 0) readLineBreak(state);
|
|
1979
|
-
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
1980
|
-
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
1981
|
-
} else {
|
|
1982
|
-
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
skipSeparationSpace(state, true, -1);
|
|
1986
|
-
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
1987
|
-
state.position += 3;
|
|
1988
|
-
skipSeparationSpace(state, true, -1);
|
|
1989
|
-
} else if (hasDirectives) {
|
|
1990
|
-
throwError(state, "directives end mark is expected");
|
|
1991
|
-
}
|
|
1992
|
-
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
1993
|
-
skipSeparationSpace(state, true, -1);
|
|
1994
|
-
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
1995
|
-
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
1996
|
-
}
|
|
1997
|
-
state.documents.push(state.result);
|
|
1998
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1999
|
-
if (state.input.charCodeAt(state.position) === 46) {
|
|
2000
|
-
state.position += 3;
|
|
2001
|
-
skipSeparationSpace(state, true, -1);
|
|
2002
|
-
}
|
|
2003
|
-
return;
|
|
2004
|
-
}
|
|
2005
|
-
if (state.position < state.length - 1) {
|
|
2006
|
-
throwError(state, "end of the stream or a document separator is expected");
|
|
2007
|
-
} else {
|
|
2008
|
-
return;
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
function loadDocuments(input, options) {
|
|
2012
|
-
input = String(input);
|
|
2013
|
-
options = options || {};
|
|
2014
|
-
if (input.length !== 0) {
|
|
2015
|
-
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2016
|
-
input += "\n";
|
|
2017
|
-
}
|
|
2018
|
-
if (input.charCodeAt(0) === 65279) {
|
|
2019
|
-
input = input.slice(1);
|
|
2020
|
-
}
|
|
2021
|
-
}
|
|
2022
|
-
var state = new State$1(input, options);
|
|
2023
|
-
var nullpos = input.indexOf("\0");
|
|
2024
|
-
if (nullpos !== -1) {
|
|
2025
|
-
state.position = nullpos;
|
|
2026
|
-
throwError(state, "null byte is not allowed in input");
|
|
2027
|
-
}
|
|
2028
|
-
state.input += "\0";
|
|
2029
|
-
while (state.input.charCodeAt(state.position) === 32) {
|
|
2030
|
-
state.lineIndent += 1;
|
|
2031
|
-
state.position += 1;
|
|
2032
|
-
}
|
|
2033
|
-
while (state.position < state.length - 1) {
|
|
2034
|
-
readDocument(state);
|
|
2035
|
-
}
|
|
2036
|
-
return state.documents;
|
|
2037
|
-
}
|
|
2038
|
-
function loadAll$1(input, iterator, options) {
|
|
2039
|
-
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2040
|
-
options = iterator;
|
|
2041
|
-
iterator = null;
|
|
2042
|
-
}
|
|
2043
|
-
var documents = loadDocuments(input, options);
|
|
2044
|
-
if (typeof iterator !== "function") {
|
|
2045
|
-
return documents;
|
|
2046
|
-
}
|
|
2047
|
-
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
2048
|
-
iterator(documents[index]);
|
|
2049
|
-
}
|
|
2050
|
-
}
|
|
2051
|
-
function load$1(input, options) {
|
|
2052
|
-
var documents = loadDocuments(input, options);
|
|
2053
|
-
if (documents.length === 0) {
|
|
2054
|
-
return void 0;
|
|
2055
|
-
} else if (documents.length === 1) {
|
|
2056
|
-
return documents[0];
|
|
2057
|
-
}
|
|
2058
|
-
throw new exception("expected a single document in the stream, but found more");
|
|
2059
|
-
}
|
|
2060
|
-
var loadAll_1 = loadAll$1;
|
|
2061
|
-
var load_1 = load$1;
|
|
2062
|
-
var loader = {
|
|
2063
|
-
loadAll: loadAll_1,
|
|
2064
|
-
load: load_1
|
|
2065
|
-
};
|
|
2066
|
-
var _toString = Object.prototype.toString;
|
|
2067
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2068
|
-
var CHAR_BOM = 65279;
|
|
2069
|
-
var CHAR_TAB = 9;
|
|
2070
|
-
var CHAR_LINE_FEED = 10;
|
|
2071
|
-
var CHAR_CARRIAGE_RETURN = 13;
|
|
2072
|
-
var CHAR_SPACE = 32;
|
|
2073
|
-
var CHAR_EXCLAMATION = 33;
|
|
2074
|
-
var CHAR_DOUBLE_QUOTE = 34;
|
|
2075
|
-
var CHAR_SHARP = 35;
|
|
2076
|
-
var CHAR_PERCENT = 37;
|
|
2077
|
-
var CHAR_AMPERSAND = 38;
|
|
2078
|
-
var CHAR_SINGLE_QUOTE = 39;
|
|
2079
|
-
var CHAR_ASTERISK = 42;
|
|
2080
|
-
var CHAR_COMMA = 44;
|
|
2081
|
-
var CHAR_MINUS = 45;
|
|
2082
|
-
var CHAR_COLON = 58;
|
|
2083
|
-
var CHAR_EQUALS = 61;
|
|
2084
|
-
var CHAR_GREATER_THAN = 62;
|
|
2085
|
-
var CHAR_QUESTION = 63;
|
|
2086
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
2087
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2088
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2089
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
2090
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2091
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
2092
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2093
|
-
var ESCAPE_SEQUENCES = {};
|
|
2094
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2095
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2096
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2097
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2098
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2099
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2100
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2101
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2102
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2103
|
-
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2104
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2105
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2106
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2107
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2108
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2109
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2110
|
-
"y",
|
|
2111
|
-
"Y",
|
|
2112
|
-
"yes",
|
|
2113
|
-
"Yes",
|
|
2114
|
-
"YES",
|
|
2115
|
-
"on",
|
|
2116
|
-
"On",
|
|
2117
|
-
"ON",
|
|
2118
|
-
"n",
|
|
2119
|
-
"N",
|
|
2120
|
-
"no",
|
|
2121
|
-
"No",
|
|
2122
|
-
"NO",
|
|
2123
|
-
"off",
|
|
2124
|
-
"Off",
|
|
2125
|
-
"OFF"
|
|
2126
|
-
];
|
|
2127
|
-
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2128
|
-
function compileStyleMap(schema2, map2) {
|
|
2129
|
-
var result, keys, index, length, tag, style, type2;
|
|
2130
|
-
if (map2 === null) return {};
|
|
2131
|
-
result = {};
|
|
2132
|
-
keys = Object.keys(map2);
|
|
2133
|
-
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2134
|
-
tag = keys[index];
|
|
2135
|
-
style = String(map2[tag]);
|
|
2136
|
-
if (tag.slice(0, 2) === "!!") {
|
|
2137
|
-
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2138
|
-
}
|
|
2139
|
-
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2140
|
-
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2141
|
-
style = type2.styleAliases[style];
|
|
2142
|
-
}
|
|
2143
|
-
result[tag] = style;
|
|
2144
|
-
}
|
|
2145
|
-
return result;
|
|
2146
|
-
}
|
|
2147
|
-
function encodeHex(character) {
|
|
2148
|
-
var string, handle, length;
|
|
2149
|
-
string = character.toString(16).toUpperCase();
|
|
2150
|
-
if (character <= 255) {
|
|
2151
|
-
handle = "x";
|
|
2152
|
-
length = 2;
|
|
2153
|
-
} else if (character <= 65535) {
|
|
2154
|
-
handle = "u";
|
|
2155
|
-
length = 4;
|
|
2156
|
-
} else if (character <= 4294967295) {
|
|
2157
|
-
handle = "U";
|
|
2158
|
-
length = 8;
|
|
2159
|
-
} else {
|
|
2160
|
-
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2161
|
-
}
|
|
2162
|
-
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2163
|
-
}
|
|
2164
|
-
var QUOTING_TYPE_SINGLE = 1;
|
|
2165
|
-
var QUOTING_TYPE_DOUBLE = 2;
|
|
2166
|
-
function State(options) {
|
|
2167
|
-
this.schema = options["schema"] || _default;
|
|
2168
|
-
this.indent = Math.max(1, options["indent"] || 2);
|
|
2169
|
-
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2170
|
-
this.skipInvalid = options["skipInvalid"] || false;
|
|
2171
|
-
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2172
|
-
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2173
|
-
this.sortKeys = options["sortKeys"] || false;
|
|
2174
|
-
this.lineWidth = options["lineWidth"] || 80;
|
|
2175
|
-
this.noRefs = options["noRefs"] || false;
|
|
2176
|
-
this.noCompatMode = options["noCompatMode"] || false;
|
|
2177
|
-
this.condenseFlow = options["condenseFlow"] || false;
|
|
2178
|
-
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2179
|
-
this.forceQuotes = options["forceQuotes"] || false;
|
|
2180
|
-
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2181
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
2182
|
-
this.explicitTypes = this.schema.compiledExplicit;
|
|
2183
|
-
this.tag = null;
|
|
2184
|
-
this.result = "";
|
|
2185
|
-
this.duplicates = [];
|
|
2186
|
-
this.usedDuplicates = null;
|
|
2187
|
-
}
|
|
2188
|
-
function indentString(string, spaces) {
|
|
2189
|
-
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2190
|
-
while (position < length) {
|
|
2191
|
-
next = string.indexOf("\n", position);
|
|
2192
|
-
if (next === -1) {
|
|
2193
|
-
line = string.slice(position);
|
|
2194
|
-
position = length;
|
|
2195
|
-
} else {
|
|
2196
|
-
line = string.slice(position, next + 1);
|
|
2197
|
-
position = next + 1;
|
|
2198
|
-
}
|
|
2199
|
-
if (line.length && line !== "\n") result += ind;
|
|
2200
|
-
result += line;
|
|
2201
|
-
}
|
|
2202
|
-
return result;
|
|
2203
|
-
}
|
|
2204
|
-
function generateNextLine(state, level) {
|
|
2205
|
-
return "\n" + common.repeat(" ", state.indent * level);
|
|
2206
|
-
}
|
|
2207
|
-
function testImplicitResolving(state, str2) {
|
|
2208
|
-
var index, length, type2;
|
|
2209
|
-
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2210
|
-
type2 = state.implicitTypes[index];
|
|
2211
|
-
if (type2.resolve(str2)) {
|
|
2212
|
-
return true;
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
return false;
|
|
2216
|
-
}
|
|
2217
|
-
function isWhitespace(c) {
|
|
2218
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2219
|
-
}
|
|
2220
|
-
function isPrintable(c) {
|
|
2221
|
-
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2222
|
-
}
|
|
2223
|
-
function isNsCharOrWhitespace(c) {
|
|
2224
|
-
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2225
|
-
}
|
|
2226
|
-
function isPlainSafe(c, prev, inblock) {
|
|
2227
|
-
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2228
|
-
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2229
|
-
return (
|
|
2230
|
-
// ns-plain-safe
|
|
2231
|
-
(inblock ? (
|
|
2232
|
-
// c = flow-in
|
|
2233
|
-
cIsNsCharOrWhitespace
|
|
2234
|
-
) : 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
|
|
2235
|
-
);
|
|
2236
|
-
}
|
|
2237
|
-
function isPlainSafeFirst(c) {
|
|
2238
|
-
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;
|
|
2239
|
-
}
|
|
2240
|
-
function isPlainSafeLast(c) {
|
|
2241
|
-
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2242
|
-
}
|
|
2243
|
-
function codePointAt(string, pos) {
|
|
2244
|
-
var first = string.charCodeAt(pos), second;
|
|
2245
|
-
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2246
|
-
second = string.charCodeAt(pos + 1);
|
|
2247
|
-
if (second >= 56320 && second <= 57343) {
|
|
2248
|
-
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
return first;
|
|
2252
|
-
}
|
|
2253
|
-
function needIndentIndicator(string) {
|
|
2254
|
-
var leadingSpaceRe = /^\n* /;
|
|
2255
|
-
return leadingSpaceRe.test(string);
|
|
2256
|
-
}
|
|
2257
|
-
var STYLE_PLAIN = 1;
|
|
2258
|
-
var STYLE_SINGLE = 2;
|
|
2259
|
-
var STYLE_LITERAL = 3;
|
|
2260
|
-
var STYLE_FOLDED = 4;
|
|
2261
|
-
var STYLE_DOUBLE = 5;
|
|
2262
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2263
|
-
var i;
|
|
2264
|
-
var char = 0;
|
|
2265
|
-
var prevChar = null;
|
|
2266
|
-
var hasLineBreak = false;
|
|
2267
|
-
var hasFoldableLine = false;
|
|
2268
|
-
var shouldTrackWidth = lineWidth !== -1;
|
|
2269
|
-
var previousLineBreak = -1;
|
|
2270
|
-
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2271
|
-
if (singleLineOnly || forceQuotes) {
|
|
2272
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2273
|
-
char = codePointAt(string, i);
|
|
2274
|
-
if (!isPrintable(char)) {
|
|
2275
|
-
return STYLE_DOUBLE;
|
|
2276
|
-
}
|
|
2277
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2278
|
-
prevChar = char;
|
|
2279
|
-
}
|
|
2280
|
-
} else {
|
|
2281
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2282
|
-
char = codePointAt(string, i);
|
|
2283
|
-
if (char === CHAR_LINE_FEED) {
|
|
2284
|
-
hasLineBreak = true;
|
|
2285
|
-
if (shouldTrackWidth) {
|
|
2286
|
-
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2287
|
-
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2288
|
-
previousLineBreak = i;
|
|
2289
|
-
}
|
|
2290
|
-
} else if (!isPrintable(char)) {
|
|
2291
|
-
return STYLE_DOUBLE;
|
|
2292
|
-
}
|
|
2293
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2294
|
-
prevChar = char;
|
|
2295
|
-
}
|
|
2296
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2297
|
-
}
|
|
2298
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2299
|
-
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2300
|
-
return STYLE_PLAIN;
|
|
2301
|
-
}
|
|
2302
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2303
|
-
}
|
|
2304
|
-
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2305
|
-
return STYLE_DOUBLE;
|
|
2306
|
-
}
|
|
2307
|
-
if (!forceQuotes) {
|
|
2308
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2309
|
-
}
|
|
2310
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2311
|
-
}
|
|
2312
|
-
function writeScalar(state, string, level, iskey, inblock) {
|
|
2313
|
-
state.dump = (function() {
|
|
2314
|
-
if (string.length === 0) {
|
|
2315
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2316
|
-
}
|
|
2317
|
-
if (!state.noCompatMode) {
|
|
2318
|
-
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2319
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2320
|
-
}
|
|
2321
|
-
}
|
|
2322
|
-
var indent = state.indent * Math.max(1, level);
|
|
2323
|
-
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2324
|
-
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2325
|
-
function testAmbiguity(string2) {
|
|
2326
|
-
return testImplicitResolving(state, string2);
|
|
2327
|
-
}
|
|
2328
|
-
switch (chooseScalarStyle(
|
|
2329
|
-
string,
|
|
2330
|
-
singleLineOnly,
|
|
2331
|
-
state.indent,
|
|
2332
|
-
lineWidth,
|
|
2333
|
-
testAmbiguity,
|
|
2334
|
-
state.quotingType,
|
|
2335
|
-
state.forceQuotes && !iskey,
|
|
2336
|
-
inblock
|
|
2337
|
-
)) {
|
|
2338
|
-
case STYLE_PLAIN:
|
|
2339
|
-
return string;
|
|
2340
|
-
case STYLE_SINGLE:
|
|
2341
|
-
return "'" + string.replace(/'/g, "''") + "'";
|
|
2342
|
-
case STYLE_LITERAL:
|
|
2343
|
-
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2344
|
-
case STYLE_FOLDED:
|
|
2345
|
-
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2346
|
-
case STYLE_DOUBLE:
|
|
2347
|
-
return '"' + escapeString(string) + '"';
|
|
2348
|
-
default:
|
|
2349
|
-
throw new exception("impossible error: invalid scalar style");
|
|
2350
|
-
}
|
|
2351
|
-
})();
|
|
2352
|
-
}
|
|
2353
|
-
function blockHeader(string, indentPerLevel) {
|
|
2354
|
-
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2355
|
-
var clip = string[string.length - 1] === "\n";
|
|
2356
|
-
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
2357
|
-
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2358
|
-
return indentIndicator + chomp + "\n";
|
|
2359
|
-
}
|
|
2360
|
-
function dropEndingNewline(string) {
|
|
2361
|
-
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2362
|
-
}
|
|
2363
|
-
function foldString(string, width) {
|
|
2364
|
-
var lineRe = /(\n+)([^\n]*)/g;
|
|
2365
|
-
var result = (function() {
|
|
2366
|
-
var nextLF = string.indexOf("\n");
|
|
2367
|
-
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2368
|
-
lineRe.lastIndex = nextLF;
|
|
2369
|
-
return foldLine(string.slice(0, nextLF), width);
|
|
2370
|
-
})();
|
|
2371
|
-
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2372
|
-
var moreIndented;
|
|
2373
|
-
var match;
|
|
2374
|
-
while (match = lineRe.exec(string)) {
|
|
2375
|
-
var prefix = match[1], line = match[2];
|
|
2376
|
-
moreIndented = line[0] === " ";
|
|
2377
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2378
|
-
prevMoreIndented = moreIndented;
|
|
2379
|
-
}
|
|
2380
|
-
return result;
|
|
2381
|
-
}
|
|
2382
|
-
function foldLine(line, width) {
|
|
2383
|
-
if (line === "" || line[0] === " ") return line;
|
|
2384
|
-
var breakRe = / [^ ]/g;
|
|
2385
|
-
var match;
|
|
2386
|
-
var start = 0, end, curr = 0, next = 0;
|
|
2387
|
-
var result = "";
|
|
2388
|
-
while (match = breakRe.exec(line)) {
|
|
2389
|
-
next = match.index;
|
|
2390
|
-
if (next - start > width) {
|
|
2391
|
-
end = curr > start ? curr : next;
|
|
2392
|
-
result += "\n" + line.slice(start, end);
|
|
2393
|
-
start = end + 1;
|
|
2394
|
-
}
|
|
2395
|
-
curr = next;
|
|
2396
|
-
}
|
|
2397
|
-
result += "\n";
|
|
2398
|
-
if (line.length - start > width && curr > start) {
|
|
2399
|
-
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2400
|
-
} else {
|
|
2401
|
-
result += line.slice(start);
|
|
2402
|
-
}
|
|
2403
|
-
return result.slice(1);
|
|
2404
|
-
}
|
|
2405
|
-
function escapeString(string) {
|
|
2406
|
-
var result = "";
|
|
2407
|
-
var char = 0;
|
|
2408
|
-
var escapeSeq;
|
|
2409
|
-
for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2410
|
-
char = codePointAt(string, i);
|
|
2411
|
-
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2412
|
-
if (!escapeSeq && isPrintable(char)) {
|
|
2413
|
-
result += string[i];
|
|
2414
|
-
if (char >= 65536) result += string[i + 1];
|
|
2415
|
-
} else {
|
|
2416
|
-
result += escapeSeq || encodeHex(char);
|
|
2417
|
-
}
|
|
2418
|
-
}
|
|
2419
|
-
return result;
|
|
2420
|
-
}
|
|
2421
|
-
function writeFlowSequence(state, level, object) {
|
|
2422
|
-
var _result = "", _tag = state.tag, index, length, value;
|
|
2423
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2424
|
-
value = object[index];
|
|
2425
|
-
if (state.replacer) {
|
|
2426
|
-
value = state.replacer.call(object, String(index), value);
|
|
2427
|
-
}
|
|
2428
|
-
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2429
|
-
if (_result !== "") _result += "," + (!state.condenseFlow ? " " : "");
|
|
2430
|
-
_result += state.dump;
|
|
2431
|
-
}
|
|
2432
|
-
}
|
|
2433
|
-
state.tag = _tag;
|
|
2434
|
-
state.dump = "[" + _result + "]";
|
|
2435
|
-
}
|
|
2436
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
2437
|
-
var _result = "", _tag = state.tag, index, length, value;
|
|
2438
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2439
|
-
value = object[index];
|
|
2440
|
-
if (state.replacer) {
|
|
2441
|
-
value = state.replacer.call(object, String(index), value);
|
|
2442
|
-
}
|
|
2443
|
-
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2444
|
-
if (!compact || _result !== "") {
|
|
2445
|
-
_result += generateNextLine(state, level);
|
|
2446
|
-
}
|
|
2447
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2448
|
-
_result += "-";
|
|
2449
|
-
} else {
|
|
2450
|
-
_result += "- ";
|
|
2451
|
-
}
|
|
2452
|
-
_result += state.dump;
|
|
2453
|
-
}
|
|
2454
|
-
}
|
|
2455
|
-
state.tag = _tag;
|
|
2456
|
-
state.dump = _result || "[]";
|
|
2457
|
-
}
|
|
2458
|
-
function writeFlowMapping(state, level, object) {
|
|
2459
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2460
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2461
|
-
pairBuffer = "";
|
|
2462
|
-
if (_result !== "") pairBuffer += ", ";
|
|
2463
|
-
if (state.condenseFlow) pairBuffer += '"';
|
|
2464
|
-
objectKey = objectKeyList[index];
|
|
2465
|
-
objectValue = object[objectKey];
|
|
2466
|
-
if (state.replacer) {
|
|
2467
|
-
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2468
|
-
}
|
|
2469
|
-
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2470
|
-
continue;
|
|
2471
|
-
}
|
|
2472
|
-
if (state.dump.length > 1024) pairBuffer += "? ";
|
|
2473
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2474
|
-
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2475
|
-
continue;
|
|
2476
|
-
}
|
|
2477
|
-
pairBuffer += state.dump;
|
|
2478
|
-
_result += pairBuffer;
|
|
2479
|
-
}
|
|
2480
|
-
state.tag = _tag;
|
|
2481
|
-
state.dump = "{" + _result + "}";
|
|
2482
|
-
}
|
|
2483
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
2484
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2485
|
-
if (state.sortKeys === true) {
|
|
2486
|
-
objectKeyList.sort();
|
|
2487
|
-
} else if (typeof state.sortKeys === "function") {
|
|
2488
|
-
objectKeyList.sort(state.sortKeys);
|
|
2489
|
-
} else if (state.sortKeys) {
|
|
2490
|
-
throw new exception("sortKeys must be a boolean or a function");
|
|
2491
|
-
}
|
|
2492
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2493
|
-
pairBuffer = "";
|
|
2494
|
-
if (!compact || _result !== "") {
|
|
2495
|
-
pairBuffer += generateNextLine(state, level);
|
|
2496
|
-
}
|
|
2497
|
-
objectKey = objectKeyList[index];
|
|
2498
|
-
objectValue = object[objectKey];
|
|
2499
|
-
if (state.replacer) {
|
|
2500
|
-
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2501
|
-
}
|
|
2502
|
-
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2503
|
-
continue;
|
|
2504
|
-
}
|
|
2505
|
-
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2506
|
-
if (explicitPair) {
|
|
2507
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2508
|
-
pairBuffer += "?";
|
|
2509
|
-
} else {
|
|
2510
|
-
pairBuffer += "? ";
|
|
2511
|
-
}
|
|
2512
|
-
}
|
|
2513
|
-
pairBuffer += state.dump;
|
|
2514
|
-
if (explicitPair) {
|
|
2515
|
-
pairBuffer += generateNextLine(state, level);
|
|
2516
|
-
}
|
|
2517
|
-
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2518
|
-
continue;
|
|
2519
|
-
}
|
|
2520
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2521
|
-
pairBuffer += ":";
|
|
2522
|
-
} else {
|
|
2523
|
-
pairBuffer += ": ";
|
|
2524
|
-
}
|
|
2525
|
-
pairBuffer += state.dump;
|
|
2526
|
-
_result += pairBuffer;
|
|
2527
|
-
}
|
|
2528
|
-
state.tag = _tag;
|
|
2529
|
-
state.dump = _result || "{}";
|
|
2530
|
-
}
|
|
2531
|
-
function detectType(state, object, explicit) {
|
|
2532
|
-
var _result, typeList, index, length, type2, style;
|
|
2533
|
-
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2534
|
-
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2535
|
-
type2 = typeList[index];
|
|
2536
|
-
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
2537
|
-
if (explicit) {
|
|
2538
|
-
if (type2.multi && type2.representName) {
|
|
2539
|
-
state.tag = type2.representName(object);
|
|
2540
|
-
} else {
|
|
2541
|
-
state.tag = type2.tag;
|
|
2542
|
-
}
|
|
2543
|
-
} else {
|
|
2544
|
-
state.tag = "?";
|
|
2545
|
-
}
|
|
2546
|
-
if (type2.represent) {
|
|
2547
|
-
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2548
|
-
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2549
|
-
_result = type2.represent(object, style);
|
|
2550
|
-
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2551
|
-
_result = type2.represent[style](object, style);
|
|
2552
|
-
} else {
|
|
2553
|
-
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2554
|
-
}
|
|
2555
|
-
state.dump = _result;
|
|
2556
|
-
}
|
|
2557
|
-
return true;
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
return false;
|
|
2561
|
-
}
|
|
2562
|
-
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2563
|
-
state.tag = null;
|
|
2564
|
-
state.dump = object;
|
|
2565
|
-
if (!detectType(state, object, false)) {
|
|
2566
|
-
detectType(state, object, true);
|
|
2567
|
-
}
|
|
2568
|
-
var type2 = _toString.call(state.dump);
|
|
2569
|
-
var inblock = block;
|
|
2570
|
-
var tagStr;
|
|
2571
|
-
if (block) {
|
|
2572
|
-
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2573
|
-
}
|
|
2574
|
-
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2575
|
-
if (objectOrArray) {
|
|
2576
|
-
duplicateIndex = state.duplicates.indexOf(object);
|
|
2577
|
-
duplicate = duplicateIndex !== -1;
|
|
2578
|
-
}
|
|
2579
|
-
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2580
|
-
compact = false;
|
|
2581
|
-
}
|
|
2582
|
-
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2583
|
-
state.dump = "*ref_" + duplicateIndex;
|
|
2584
|
-
} else {
|
|
2585
|
-
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2586
|
-
state.usedDuplicates[duplicateIndex] = true;
|
|
2587
|
-
}
|
|
2588
|
-
if (type2 === "[object Object]") {
|
|
2589
|
-
if (block && Object.keys(state.dump).length !== 0) {
|
|
2590
|
-
writeBlockMapping(state, level, state.dump, compact);
|
|
2591
|
-
if (duplicate) {
|
|
2592
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2593
|
-
}
|
|
2594
|
-
} else {
|
|
2595
|
-
writeFlowMapping(state, level, state.dump);
|
|
2596
|
-
if (duplicate) {
|
|
2597
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2598
|
-
}
|
|
2599
|
-
}
|
|
2600
|
-
} else if (type2 === "[object Array]") {
|
|
2601
|
-
if (block && state.dump.length !== 0) {
|
|
2602
|
-
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2603
|
-
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2604
|
-
} else {
|
|
2605
|
-
writeBlockSequence(state, level, state.dump, compact);
|
|
2606
|
-
}
|
|
2607
|
-
if (duplicate) {
|
|
2608
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2609
|
-
}
|
|
2610
|
-
} else {
|
|
2611
|
-
writeFlowSequence(state, level, state.dump);
|
|
2612
|
-
if (duplicate) {
|
|
2613
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2614
|
-
}
|
|
2615
|
-
}
|
|
2616
|
-
} else if (type2 === "[object String]") {
|
|
2617
|
-
if (state.tag !== "?") {
|
|
2618
|
-
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2619
|
-
}
|
|
2620
|
-
} else if (type2 === "[object Undefined]") {
|
|
2621
|
-
return false;
|
|
2622
|
-
} else {
|
|
2623
|
-
if (state.skipInvalid) return false;
|
|
2624
|
-
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2625
|
-
}
|
|
2626
|
-
if (state.tag !== null && state.tag !== "?") {
|
|
2627
|
-
tagStr = encodeURI(
|
|
2628
|
-
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
2629
|
-
).replace(/!/g, "%21");
|
|
2630
|
-
if (state.tag[0] === "!") {
|
|
2631
|
-
tagStr = "!" + tagStr;
|
|
2632
|
-
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2633
|
-
tagStr = "!!" + tagStr.slice(18);
|
|
2634
|
-
} else {
|
|
2635
|
-
tagStr = "!<" + tagStr + ">";
|
|
2636
|
-
}
|
|
2637
|
-
state.dump = tagStr + " " + state.dump;
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
return true;
|
|
2641
|
-
}
|
|
2642
|
-
function getDuplicateReferences(object, state) {
|
|
2643
|
-
var objects = [], duplicatesIndexes = [], index, length;
|
|
2644
|
-
inspectNode(object, objects, duplicatesIndexes);
|
|
2645
|
-
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2646
|
-
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2647
|
-
}
|
|
2648
|
-
state.usedDuplicates = new Array(length);
|
|
2649
|
-
}
|
|
2650
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2651
|
-
var objectKeyList, index, length;
|
|
2652
|
-
if (object !== null && typeof object === "object") {
|
|
2653
|
-
index = objects.indexOf(object);
|
|
2654
|
-
if (index !== -1) {
|
|
2655
|
-
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2656
|
-
duplicatesIndexes.push(index);
|
|
2657
|
-
}
|
|
2658
|
-
} else {
|
|
2659
|
-
objects.push(object);
|
|
2660
|
-
if (Array.isArray(object)) {
|
|
2661
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2662
|
-
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2663
|
-
}
|
|
2664
|
-
} else {
|
|
2665
|
-
objectKeyList = Object.keys(object);
|
|
2666
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2667
|
-
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
28
|
+
"@akson/cortex-gsc": "workspace:*",
|
|
29
|
+
"@akson/cortex-gtm": "workspace:*",
|
|
30
|
+
"@akson/cortex-posthog": "workspace:*",
|
|
31
|
+
chalk: "^5.5.0",
|
|
32
|
+
commander: "^14.0.0",
|
|
33
|
+
inquirer: "^13.1.0",
|
|
34
|
+
"js-yaml": "^4.1.0",
|
|
35
|
+
ora: "^8.1.1",
|
|
36
|
+
table: "^6.9.0"
|
|
37
|
+
},
|
|
38
|
+
devDependencies: {
|
|
39
|
+
"@types/inquirer": "^9.0.7",
|
|
40
|
+
"@types/js-yaml": "^4.0.9",
|
|
41
|
+
"@types/node": "^22",
|
|
42
|
+
eslint: "^8",
|
|
43
|
+
tsup: "^8.5.0",
|
|
44
|
+
typescript: "^5.9.2",
|
|
45
|
+
vitest: "^3.2.4"
|
|
46
|
+
},
|
|
47
|
+
engines: {
|
|
48
|
+
node: ">=18.0.0"
|
|
49
|
+
},
|
|
50
|
+
keywords: [
|
|
51
|
+
"cli",
|
|
52
|
+
"analytics",
|
|
53
|
+
"gtm",
|
|
54
|
+
"google-ads",
|
|
55
|
+
"posthog",
|
|
56
|
+
"gsc",
|
|
57
|
+
"cortex"
|
|
58
|
+
],
|
|
59
|
+
author: "Akson <contact@akson.ch>",
|
|
60
|
+
license: "MIT",
|
|
61
|
+
homepage: "https://github.com/antoineschaller/cortex-packages/tree/main/packages/@akson/cortex-analytics",
|
|
62
|
+
repository: {
|
|
63
|
+
type: "git",
|
|
64
|
+
url: "https://github.com/antoineschaller/cortex-packages.git",
|
|
65
|
+
directory: "packages/@akson/cortex-analytics"
|
|
66
|
+
},
|
|
67
|
+
types: "dist/index.d.ts",
|
|
68
|
+
exports: {
|
|
69
|
+
".": {
|
|
70
|
+
types: "./dist/index.d.ts",
|
|
71
|
+
import: "./dist/index.js"
|
|
2668
72
|
}
|
|
2669
|
-
}
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
var value = input;
|
|
2678
|
-
if (state.replacer) {
|
|
2679
|
-
value = state.replacer.call({ "": value }, "", value);
|
|
73
|
+
},
|
|
74
|
+
files: [
|
|
75
|
+
"dist",
|
|
76
|
+
"README.md",
|
|
77
|
+
"LICENSE"
|
|
78
|
+
],
|
|
79
|
+
gitHead: "b3a6a0832bb2fd230473076bde1bfc7810e9ac31"
|
|
80
|
+
};
|
|
2680
81
|
}
|
|
2681
|
-
|
|
2682
|
-
return "";
|
|
2683
|
-
}
|
|
2684
|
-
var dump_1 = dump$1;
|
|
2685
|
-
var dumper = {
|
|
2686
|
-
dump: dump_1
|
|
2687
|
-
};
|
|
2688
|
-
function renamed(from, to) {
|
|
2689
|
-
return function() {
|
|
2690
|
-
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
2691
|
-
};
|
|
2692
|
-
}
|
|
2693
|
-
var Type = type;
|
|
2694
|
-
var Schema = schema;
|
|
2695
|
-
var FAILSAFE_SCHEMA = failsafe;
|
|
2696
|
-
var JSON_SCHEMA = json;
|
|
2697
|
-
var CORE_SCHEMA = core;
|
|
2698
|
-
var DEFAULT_SCHEMA = _default;
|
|
2699
|
-
var load = loader.load;
|
|
2700
|
-
var loadAll = loader.loadAll;
|
|
2701
|
-
var dump = dumper.dump;
|
|
2702
|
-
var YAMLException = exception;
|
|
2703
|
-
var types = {
|
|
2704
|
-
binary,
|
|
2705
|
-
float,
|
|
2706
|
-
map,
|
|
2707
|
-
null: _null,
|
|
2708
|
-
pairs,
|
|
2709
|
-
set,
|
|
2710
|
-
timestamp,
|
|
2711
|
-
bool,
|
|
2712
|
-
int,
|
|
2713
|
-
merge,
|
|
2714
|
-
omap,
|
|
2715
|
-
seq,
|
|
2716
|
-
str
|
|
2717
|
-
};
|
|
2718
|
-
var safeLoad = renamed("safeLoad", "load");
|
|
2719
|
-
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
2720
|
-
var safeDump = renamed("safeDump", "dump");
|
|
2721
|
-
var jsYaml = {
|
|
2722
|
-
Type,
|
|
2723
|
-
Schema,
|
|
2724
|
-
FAILSAFE_SCHEMA,
|
|
2725
|
-
JSON_SCHEMA,
|
|
2726
|
-
CORE_SCHEMA,
|
|
2727
|
-
DEFAULT_SCHEMA,
|
|
2728
|
-
load,
|
|
2729
|
-
loadAll,
|
|
2730
|
-
dump,
|
|
2731
|
-
YAMLException,
|
|
2732
|
-
types,
|
|
2733
|
-
safeLoad,
|
|
2734
|
-
safeLoadAll,
|
|
2735
|
-
safeDump
|
|
2736
|
-
};
|
|
2737
|
-
var js_yaml_default = jsYaml;
|
|
82
|
+
});
|
|
2738
83
|
|
|
2739
84
|
// src/analytics-manager.ts
|
|
85
|
+
import crypto from "crypto";
|
|
86
|
+
import fs from "fs/promises";
|
|
87
|
+
import {
|
|
88
|
+
GoogleAdsClient,
|
|
89
|
+
HistoricalAnalyzer,
|
|
90
|
+
SwissMarketAnalyzer,
|
|
91
|
+
loadGoogleAdsConfig
|
|
92
|
+
} from "@akson/cortex-google-ads";
|
|
93
|
+
import { GSCClient, loadGSCConfig } from "@akson/cortex-gsc";
|
|
94
|
+
import {
|
|
95
|
+
ConfigParser,
|
|
96
|
+
GTMClient,
|
|
97
|
+
GTMApiTransformer,
|
|
98
|
+
loadGTMConfig,
|
|
99
|
+
Planner,
|
|
100
|
+
StateManager
|
|
101
|
+
} from "@akson/cortex-gtm";
|
|
102
|
+
import { loadPostHogConfig, PostHogClient } from "@akson/cortex-posthog";
|
|
103
|
+
import {
|
|
104
|
+
ECOMMERCE_EVENTS,
|
|
105
|
+
LEAD_GENERATION_EVENTS,
|
|
106
|
+
LEAD_SCORES,
|
|
107
|
+
PLATFORM_MAPPINGS
|
|
108
|
+
} from "@akson/cortex-utilities";
|
|
109
|
+
import chalk from "chalk";
|
|
110
|
+
import inquirer from "inquirer";
|
|
111
|
+
import yaml from "js-yaml";
|
|
2740
112
|
import ora from "ora";
|
|
2741
113
|
import { table } from "table";
|
|
2742
114
|
var AnalyticsManager = class {
|
|
@@ -3159,7 +531,7 @@ var AnalyticsManager = class {
|
|
|
3159
531
|
"gtm.config.yaml not found. Please create the configuration file first."
|
|
3160
532
|
);
|
|
3161
533
|
}
|
|
3162
|
-
const config =
|
|
534
|
+
const config = yaml.load(yamlContent);
|
|
3163
535
|
spinner.text = "Querying current GTM state...";
|
|
3164
536
|
const variablesResult = await this.clients.gtm.listVariables();
|
|
3165
537
|
if (variablesResult.success && variablesResult.data) {
|
|
@@ -3180,7 +552,7 @@ var AnalyticsManager = class {
|
|
|
3180
552
|
}
|
|
3181
553
|
}
|
|
3182
554
|
spinner.text = "Writing updated configuration...";
|
|
3183
|
-
const updatedYaml =
|
|
555
|
+
const updatedYaml = yaml.dump(config, {
|
|
3184
556
|
indent: 2,
|
|
3185
557
|
lineWidth: -1,
|
|
3186
558
|
quotingType: '"',
|
|
@@ -5196,8 +2568,8 @@ ${validation.errors.join("\n")}`
|
|
|
5196
2568
|
/**
|
|
5197
2569
|
* Normalize parameter map structures for GTM API (convert lowercase types to uppercase)
|
|
5198
2570
|
*/
|
|
5199
|
-
normalizeParameterMap(
|
|
5200
|
-
return
|
|
2571
|
+
normalizeParameterMap(map) {
|
|
2572
|
+
return map.map((item) => ({
|
|
5201
2573
|
...item,
|
|
5202
2574
|
type: item.type?.toUpperCase() || "TEMPLATE",
|
|
5203
2575
|
...item.map && { map: this.normalizeParameterMap(item.map) },
|
|
@@ -5458,7 +2830,7 @@ ${validation.errors.join("\n")}`
|
|
|
5458
2830
|
* Map tag type codes to full GTM API type names
|
|
5459
2831
|
* CRITICAL: Auto-corrects googtag to gaawe for GA4 event tags
|
|
5460
2832
|
*/
|
|
5461
|
-
mapTagType(
|
|
2833
|
+
mapTagType(type, yamlConfig) {
|
|
5462
2834
|
const typeMap = {
|
|
5463
2835
|
googtag: "googtag",
|
|
5464
2836
|
// Google Tag (basic config only - NOT for events)
|
|
@@ -5483,13 +2855,13 @@ ${validation.errors.join("\n")}`
|
|
|
5483
2855
|
fls: "fls"
|
|
5484
2856
|
// Floodlight Sales
|
|
5485
2857
|
};
|
|
5486
|
-
if (
|
|
2858
|
+
if (type === "googtag" && yamlConfig && this.isGA4EventTag(yamlConfig)) {
|
|
5487
2859
|
console.log(
|
|
5488
2860
|
`[AUTO-CORRECT] Converting tag "${yamlConfig.name}" from type "googtag" to "gaawe" (GA4 Event Tag)`
|
|
5489
2861
|
);
|
|
5490
2862
|
return "gaawe";
|
|
5491
2863
|
}
|
|
5492
|
-
return typeMap[
|
|
2864
|
+
return typeMap[type] || type;
|
|
5493
2865
|
}
|
|
5494
2866
|
/**
|
|
5495
2867
|
* Get parameter type for tag parameters
|
|
@@ -5599,7 +2971,7 @@ ${validation.errors.join("\n")}`
|
|
|
5599
2971
|
/**
|
|
5600
2972
|
* Map trigger type codes to full GTM API type names
|
|
5601
2973
|
*/
|
|
5602
|
-
mapTriggerType(
|
|
2974
|
+
mapTriggerType(type) {
|
|
5603
2975
|
const typeMap = {
|
|
5604
2976
|
pageview: "pageview",
|
|
5605
2977
|
domReady: "domReady",
|
|
@@ -5613,7 +2985,7 @@ ${validation.errors.join("\n")}`
|
|
|
5613
2985
|
scrollDepth: "scrollDepth",
|
|
5614
2986
|
youtubeVideo: "youtubeVideo"
|
|
5615
2987
|
};
|
|
5616
|
-
return typeMap[
|
|
2988
|
+
return typeMap[type] || type;
|
|
5617
2989
|
}
|
|
5618
2990
|
/**
|
|
5619
2991
|
* Filter trigger fields for update operations
|
|
@@ -5807,7 +3179,7 @@ ${validation.errors.join("\n")}`
|
|
|
5807
3179
|
/**
|
|
5808
3180
|
* Map short variable type codes to full GTM API type names (LEGACY - for display purposes)
|
|
5809
3181
|
*/
|
|
5810
|
-
mapVariableType(
|
|
3182
|
+
mapVariableType(type) {
|
|
5811
3183
|
const typeMap = {
|
|
5812
3184
|
c: "Constant",
|
|
5813
3185
|
constant: "Constant",
|
|
@@ -5824,12 +3196,12 @@ ${validation.errors.join("\n")}`
|
|
|
5824
3196
|
r: "Referrer",
|
|
5825
3197
|
gas: "Google Analytics Settings"
|
|
5826
3198
|
};
|
|
5827
|
-
return typeMap[
|
|
3199
|
+
return typeMap[type] || type;
|
|
5828
3200
|
}
|
|
5829
3201
|
/**
|
|
5830
3202
|
* Map variable type codes to GTM API format (keep short codes, normalize long names to short codes)
|
|
5831
3203
|
*/
|
|
5832
|
-
mapVariableTypeForGTMApi(
|
|
3204
|
+
mapVariableTypeForGTMApi(type) {
|
|
5833
3205
|
const typeMap = {
|
|
5834
3206
|
// Short codes remain as-is (these are what GTM API wants)
|
|
5835
3207
|
c: "c",
|
|
@@ -5861,7 +3233,7 @@ ${validation.errors.join("\n")}`
|
|
|
5861
3233
|
autoEvent: "aev",
|
|
5862
3234
|
autoEventVariable: "aev"
|
|
5863
3235
|
};
|
|
5864
|
-
return typeMap[
|
|
3236
|
+
return typeMap[type] || type;
|
|
5865
3237
|
}
|
|
5866
3238
|
/**
|
|
5867
3239
|
* GTM API rate limiter: 0.25 QPS (1 request every 4 seconds)
|
|
@@ -6109,7 +3481,7 @@ Total resources: ${state.resources.length}`));
|
|
|
6109
3481
|
} else if (options.format === "yaml") {
|
|
6110
3482
|
const configParser = new ConfigParser();
|
|
6111
3483
|
const config = configParser.stateToConfig(state);
|
|
6112
|
-
console.log(
|
|
3484
|
+
console.log(yaml.dump(config));
|
|
6113
3485
|
} else {
|
|
6114
3486
|
console.log(JSON.stringify(state, null, 2));
|
|
6115
3487
|
}
|
|
@@ -6136,10 +3508,10 @@ Total resources: ${state.resources.length}`));
|
|
|
6136
3508
|
)
|
|
6137
3509
|
);
|
|
6138
3510
|
if (config.resources) {
|
|
6139
|
-
for (const [
|
|
3511
|
+
for (const [type, resources] of Object.entries(config.resources)) {
|
|
6140
3512
|
if (Array.isArray(resources)) {
|
|
6141
3513
|
console.log(
|
|
6142
|
-
chalk.blue(` - ${
|
|
3514
|
+
chalk.blue(` - ${type}: ${resources.length} resources`)
|
|
6143
3515
|
);
|
|
6144
3516
|
}
|
|
6145
3517
|
}
|
|
@@ -6181,8 +3553,8 @@ Total resources: ${state.resources.length}`));
|
|
|
6181
3553
|
async gtmTerraformStateShow(options) {
|
|
6182
3554
|
try {
|
|
6183
3555
|
const stateManager = new StateManager();
|
|
6184
|
-
const [
|
|
6185
|
-
const resource = await stateManager.getResource(
|
|
3556
|
+
const [type, name] = options.address.split(".");
|
|
3557
|
+
const resource = await stateManager.getResource(type, name);
|
|
6186
3558
|
if (!resource) {
|
|
6187
3559
|
console.log(
|
|
6188
3560
|
chalk.yellow(`Resource ${options.address} not found in state`)
|
|
@@ -6204,8 +3576,8 @@ Total resources: ${state.resources.length}`));
|
|
|
6204
3576
|
const spinner = ora(`Removing ${options.address} from state...`).start();
|
|
6205
3577
|
try {
|
|
6206
3578
|
const stateManager = new StateManager();
|
|
6207
|
-
const [
|
|
6208
|
-
const result = await stateManager.removeResource(
|
|
3579
|
+
const [type, name] = options.address.split(".");
|
|
3580
|
+
const result = await stateManager.removeResource(type, name);
|
|
6209
3581
|
if (result.success) {
|
|
6210
3582
|
spinner.succeed(`Removed ${options.address} from state`);
|
|
6211
3583
|
} else {
|
|
@@ -8165,7 +5537,7 @@ function getCommands() {
|
|
|
8165
5537
|
examples: ["akson gtm apply", "akson gtm apply --yes --verbose"]
|
|
8166
5538
|
}
|
|
8167
5539
|
],
|
|
8168
|
-
dependencies: ["@akson/cortex-
|
|
5540
|
+
dependencies: ["@akson/cortex-gtm", "Google Service Account Key"]
|
|
8169
5541
|
},
|
|
8170
5542
|
{
|
|
8171
5543
|
module: "Swiss Market Analytics",
|
|
@@ -8360,9 +5732,9 @@ program.command("version-info").description("Show version and dependency informa
|
|
|
8360
5732
|
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
8361
5733
|
|
|
8362
5734
|
\u{1F4E6} PACKAGE DEPENDENCIES:
|
|
8363
|
-
\u2022 @akson/cortex-
|
|
5735
|
+
\u2022 @akson/cortex-gtm: GTM operations and configuration
|
|
8364
5736
|
\u2022 @akson/cortex-gsc: Google Search Console integration
|
|
8365
|
-
\u2022 @akson/cortex-
|
|
5737
|
+
\u2022 @akson/cortex-google-ads: Google Ads reporting and analysis
|
|
8366
5738
|
\u2022 @akson/cortex-posthog: PostHog analytics and experiments
|
|
8367
5739
|
\u2022 @akson/cortex-utilities: Shared utilities and types
|
|
8368
5740
|
|
|
@@ -8763,9 +6135,4 @@ export {
|
|
|
8763
6135
|
showSwissMarketHelp,
|
|
8764
6136
|
showTroubleshooting
|
|
8765
6137
|
};
|
|
8766
|
-
/*! Bundled license information:
|
|
8767
|
-
|
|
8768
|
-
js-yaml/dist/js-yaml.mjs:
|
|
8769
|
-
(*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
|
|
8770
|
-
*/
|
|
8771
6138
|
//# sourceMappingURL=index.js.map
|