cdk8s 2.7.61 → 2.7.63
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/.jsii +3 -3
- package/lib/api-object.js +1 -1
- package/lib/app.js +1 -1
- package/lib/chart.js +1 -1
- package/lib/cron.js +1 -1
- package/lib/dependency.js +2 -2
- package/lib/duration.js +1 -1
- package/lib/helm.js +1 -1
- package/lib/include.js +1 -1
- package/lib/json-patch.js +1 -1
- package/lib/lazy.js +1 -1
- package/lib/metadata.js +1 -1
- package/lib/names.js +1 -1
- package/lib/size.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/yaml.js +6 -4
- package/node_modules/yaml/README.md +2 -2
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +4 -3
- package/node_modules/yaml/browser/dist/compose/compose-node.js +18 -5
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +19 -13
- package/node_modules/yaml/browser/dist/compose/composer.js +8 -10
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +30 -13
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +12 -3
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +10 -5
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +17 -6
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +8 -2
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +9 -1
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +1 -1
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +76 -19
- package/node_modules/yaml/browser/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/browser/dist/doc/createNode.js +14 -11
- package/node_modules/yaml/browser/dist/doc/directives.js +11 -3
- package/node_modules/yaml/browser/dist/errors.js +1 -1
- package/node_modules/yaml/browser/dist/index.js +1 -2
- package/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +164 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +30 -16
- package/node_modules/yaml/browser/dist/nodes/Node.js +7 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +11 -3
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +10 -10
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +5 -13
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +3 -2
- package/node_modules/yaml/browser/dist/nodes/toJS.js +3 -1
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +3 -8
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/browser/dist/parse/lexer.js +49 -22
- package/node_modules/yaml/browser/dist/parse/parser.js +142 -68
- package/node_modules/yaml/browser/dist/public-api.js +5 -7
- package/node_modules/yaml/browser/dist/schema/Schema.js +19 -4
- package/node_modules/yaml/browser/dist/schema/common/null.js +3 -1
- package/node_modules/yaml/browser/dist/schema/core/float.js +4 -1
- package/node_modules/yaml/browser/dist/schema/tags.js +17 -13
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +4 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +1 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +1 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +6 -1
- package/node_modules/yaml/browser/dist/stringify/stringify.js +53 -23
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +114 -85
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +18 -12
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +36 -15
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +71 -32
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +56 -53
- package/node_modules/yaml/browser/dist/util.js +3 -0
- package/node_modules/yaml/browser/dist/visit.js +149 -62
- package/node_modules/yaml/dist/compose/compose-collection.js +1 -1
- package/node_modules/yaml/dist/compose/compose-doc.js +4 -3
- package/node_modules/yaml/dist/compose/compose-node.d.ts +4 -2
- package/node_modules/yaml/dist/compose/compose-node.js +18 -5
- package/node_modules/yaml/dist/compose/compose-scalar.js +18 -12
- package/node_modules/yaml/dist/compose/composer.d.ts +3 -3
- package/node_modules/yaml/dist/compose/composer.js +10 -12
- package/node_modules/yaml/dist/compose/resolve-block-map.js +30 -13
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +12 -3
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +10 -5
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +17 -6
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +8 -2
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +2 -1
- package/node_modules/yaml/dist/compose/resolve-props.js +9 -1
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +1 -1
- package/node_modules/yaml/dist/compose/util-flow-indent-check.d.ts +3 -0
- package/node_modules/yaml/dist/compose/util-flow-indent-check.js +17 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +24 -15
- package/node_modules/yaml/dist/doc/Document.js +80 -23
- package/node_modules/yaml/dist/doc/anchors.d.ts +3 -3
- package/node_modules/yaml/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +1 -1
- package/node_modules/yaml/dist/doc/createNode.d.ts +3 -2
- package/node_modules/yaml/dist/doc/createNode.js +13 -10
- package/node_modules/yaml/dist/doc/directives.d.ts +5 -2
- package/node_modules/yaml/dist/doc/directives.js +11 -3
- package/node_modules/yaml/dist/errors.d.ts +2 -2
- package/node_modules/yaml/dist/errors.js +1 -1
- package/node_modules/yaml/dist/index.d.ts +6 -4
- package/node_modules/yaml/dist/index.js +1 -2
- package/node_modules/yaml/dist/log.d.ts +1 -1
- package/node_modules/yaml/dist/nodes/Alias.d.ts +8 -4
- package/node_modules/yaml/dist/nodes/Collection.d.ts +12 -6
- package/node_modules/yaml/dist/nodes/Collection.js +29 -15
- package/node_modules/yaml/dist/nodes/Node.d.ts +22 -11
- package/node_modules/yaml/dist/nodes/Node.js +7 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +8 -3
- package/node_modules/yaml/dist/nodes/Pair.js +10 -2
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +2 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +1 -1
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +12 -4
- package/node_modules/yaml/dist/nodes/YAMLMap.js +10 -10
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +6 -1
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +5 -13
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +2 -1
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +2 -1
- package/node_modules/yaml/dist/nodes/toJS.js +3 -1
- package/node_modules/yaml/dist/options.d.ts +82 -22
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +6 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +3 -8
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +2 -2
- package/node_modules/yaml/dist/parse/cst-visit.js +2 -2
- package/node_modules/yaml/dist/parse/cst.d.ts +3 -3
- package/node_modules/yaml/dist/parse/lexer.d.ts +2 -0
- package/node_modules/yaml/dist/parse/lexer.js +49 -22
- package/node_modules/yaml/dist/parse/parser.js +142 -68
- package/node_modules/yaml/dist/public-api.js +5 -7
- package/node_modules/yaml/dist/schema/Schema.d.ts +9 -7
- package/node_modules/yaml/dist/schema/Schema.js +18 -3
- package/node_modules/yaml/dist/schema/common/null.js +3 -1
- package/node_modules/yaml/dist/schema/core/float.js +4 -1
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +3 -4
- package/node_modules/yaml/dist/schema/tags.js +17 -13
- package/node_modules/yaml/dist/schema/types.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +4 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +7 -3
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +6 -2
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +6 -1
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +1 -1
- package/node_modules/yaml/dist/stringify/stringify.d.ts +7 -4
- package/node_modules/yaml/dist/stringify/stringify.js +53 -23
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +2 -6
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +113 -84
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -2
- package/node_modules/yaml/dist/stringify/stringifyComment.js +19 -12
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +35 -14
- package/node_modules/yaml/dist/stringify/stringifyPair.js +70 -31
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +7 -1
- package/node_modules/yaml/dist/stringify/stringifyString.js +56 -53
- package/node_modules/yaml/dist/test-events.d.ts +1 -1
- package/node_modules/yaml/dist/test-events.js +14 -14
- package/node_modules/yaml/dist/util.d.ts +3 -0
- package/node_modules/yaml/dist/util.js +6 -0
- package/node_modules/yaml/dist/visit.d.ts +51 -12
- package/node_modules/yaml/dist/visit.js +148 -60
- package/node_modules/yaml/package.json +19 -17
- package/node_modules/yaml/util.d.ts +3 -0
- package/package.json +4 -4
- package/node_modules/yaml/browser/dist/options.js +0 -17
- package/node_modules/yaml/dist/options.js +0 -19
|
@@ -8,11 +8,10 @@ export { Pair } from './nodes/Pair.js';
|
|
|
8
8
|
export { Scalar } from './nodes/Scalar.js';
|
|
9
9
|
export { YAMLMap } from './nodes/YAMLMap.js';
|
|
10
10
|
export { YAMLSeq } from './nodes/YAMLSeq.js';
|
|
11
|
-
export { defaultOptions } from './options.js';
|
|
12
11
|
import * as cst from './parse/cst.js';
|
|
13
12
|
export { cst as CST };
|
|
14
13
|
export { Lexer } from './parse/lexer.js';
|
|
15
14
|
export { LineCounter } from './parse/line-counter.js';
|
|
16
15
|
export { Parser } from './parse/parser.js';
|
|
17
16
|
export { parse, parseAllDocuments, parseDocument, stringify } from './public-api.js';
|
|
18
|
-
export { visit } from './visit.js';
|
|
17
|
+
export { visit, visitAsync } from './visit.js';
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*! *****************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
/* global Reflect, Promise */
|
|
17
|
+
var extendStatics = function (d, b) {
|
|
18
|
+
extendStatics = Object.setPrototypeOf || {
|
|
19
|
+
__proto__: []
|
|
20
|
+
} instanceof Array && function (d, b) {
|
|
21
|
+
d.__proto__ = b;
|
|
22
|
+
} || function (d, b) {
|
|
23
|
+
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
return extendStatics(d, b);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function __extends(d, b) {
|
|
30
|
+
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
31
|
+
extendStatics(d, b);
|
|
32
|
+
|
|
33
|
+
function __() {
|
|
34
|
+
this.constructor = d;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
38
|
+
}
|
|
39
|
+
function __generator(thisArg, body) {
|
|
40
|
+
var _ = {
|
|
41
|
+
label: 0,
|
|
42
|
+
sent: function () {
|
|
43
|
+
if (t[0] & 1) throw t[1];
|
|
44
|
+
return t[1];
|
|
45
|
+
},
|
|
46
|
+
trys: [],
|
|
47
|
+
ops: []
|
|
48
|
+
},
|
|
49
|
+
f,
|
|
50
|
+
y,
|
|
51
|
+
t,
|
|
52
|
+
g;
|
|
53
|
+
return g = {
|
|
54
|
+
next: verb(0),
|
|
55
|
+
"throw": verb(1),
|
|
56
|
+
"return": verb(2)
|
|
57
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
58
|
+
return this;
|
|
59
|
+
}), g;
|
|
60
|
+
|
|
61
|
+
function verb(n) {
|
|
62
|
+
return function (v) {
|
|
63
|
+
return step([n, v]);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function step(op) {
|
|
68
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
69
|
+
|
|
70
|
+
while (_) try {
|
|
71
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
72
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
73
|
+
|
|
74
|
+
switch (op[0]) {
|
|
75
|
+
case 0:
|
|
76
|
+
case 1:
|
|
77
|
+
t = op;
|
|
78
|
+
break;
|
|
79
|
+
|
|
80
|
+
case 4:
|
|
81
|
+
_.label++;
|
|
82
|
+
return {
|
|
83
|
+
value: op[1],
|
|
84
|
+
done: false
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
case 5:
|
|
88
|
+
_.label++;
|
|
89
|
+
y = op[1];
|
|
90
|
+
op = [0];
|
|
91
|
+
continue;
|
|
92
|
+
|
|
93
|
+
case 7:
|
|
94
|
+
op = _.ops.pop();
|
|
95
|
+
|
|
96
|
+
_.trys.pop();
|
|
97
|
+
|
|
98
|
+
continue;
|
|
99
|
+
|
|
100
|
+
default:
|
|
101
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
102
|
+
_ = 0;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
107
|
+
_.label = op[1];
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
112
|
+
_.label = t[1];
|
|
113
|
+
t = op;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (t && _.label < t[2]) {
|
|
118
|
+
_.label = t[2];
|
|
119
|
+
|
|
120
|
+
_.ops.push(op);
|
|
121
|
+
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (t[2]) _.ops.pop();
|
|
126
|
+
|
|
127
|
+
_.trys.pop();
|
|
128
|
+
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
op = body.call(thisArg, _);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
op = [6, e];
|
|
135
|
+
y = 0;
|
|
136
|
+
} finally {
|
|
137
|
+
f = t = 0;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (op[0] & 5) throw op[1];
|
|
141
|
+
return {
|
|
142
|
+
value: op[0] ? op[1] : void 0,
|
|
143
|
+
done: true
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function __values(o) {
|
|
148
|
+
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
149
|
+
m = s && o[s],
|
|
150
|
+
i = 0;
|
|
151
|
+
if (m) return m.call(o);
|
|
152
|
+
if (o && typeof o.length === "number") return {
|
|
153
|
+
next: function () {
|
|
154
|
+
if (o && i >= o.length) o = void 0;
|
|
155
|
+
return {
|
|
156
|
+
value: o && o[i++],
|
|
157
|
+
done: !o
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export { __extends, __generator, __values };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createNode } from '../doc/createNode.js';
|
|
2
|
-
import { NodeBase, isCollection, isScalar
|
|
2
|
+
import { NodeBase, isNode, isPair, isCollection, isScalar } from './Node.js';
|
|
3
3
|
|
|
4
4
|
function collectionFromPath(schema, path, value) {
|
|
5
5
|
let v = value;
|
|
@@ -11,25 +11,21 @@ function collectionFromPath(schema, path, value) {
|
|
|
11
11
|
v = a;
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
|
-
|
|
15
|
-
Object.defineProperty(o, typeof k === 'symbol' ? k : String(k), {
|
|
16
|
-
value: v,
|
|
17
|
-
writable: true,
|
|
18
|
-
enumerable: true,
|
|
19
|
-
configurable: true
|
|
20
|
-
});
|
|
21
|
-
v = o;
|
|
14
|
+
v = new Map([[k, v]]);
|
|
22
15
|
}
|
|
23
16
|
}
|
|
24
17
|
return createNode(v, undefined, {
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
aliasDuplicateObjects: false,
|
|
19
|
+
keepUndefined: false,
|
|
20
|
+
onAnchor: () => {
|
|
21
|
+
throw new Error('This should not happen, please report a bug.');
|
|
27
22
|
},
|
|
28
23
|
schema,
|
|
29
24
|
sourceObjects: new Map()
|
|
30
25
|
});
|
|
31
26
|
}
|
|
32
|
-
//
|
|
27
|
+
// Type guard is intentionally a little wrong so as to be more useful,
|
|
28
|
+
// as it does not cover untypable empty non-string iterables (e.g. []).
|
|
33
29
|
const isEmptyPath = (path) => path == null ||
|
|
34
30
|
(typeof path === 'object' && !!path[Symbol.iterator]().next().done);
|
|
35
31
|
class Collection extends NodeBase {
|
|
@@ -42,6 +38,20 @@ class Collection extends NodeBase {
|
|
|
42
38
|
writable: true
|
|
43
39
|
});
|
|
44
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Create a copy of this collection.
|
|
43
|
+
*
|
|
44
|
+
* @param schema - If defined, overwrites the original's schema
|
|
45
|
+
*/
|
|
46
|
+
clone(schema) {
|
|
47
|
+
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
48
|
+
if (schema)
|
|
49
|
+
copy.schema = schema;
|
|
50
|
+
copy.items = copy.items.map(it => isNode(it) || isPair(it) ? it.clone(schema) : it);
|
|
51
|
+
if (this.range)
|
|
52
|
+
copy.range = this.range.slice();
|
|
53
|
+
return copy;
|
|
54
|
+
}
|
|
45
55
|
/**
|
|
46
56
|
* Adds a value to the collection. For `!!map` and `!!omap` the value must
|
|
47
57
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
@@ -65,7 +75,8 @@ class Collection extends NodeBase {
|
|
|
65
75
|
* Removes a value from the collection.
|
|
66
76
|
* @returns `true` if the item was found and removed.
|
|
67
77
|
*/
|
|
68
|
-
deleteIn(
|
|
78
|
+
deleteIn(path) {
|
|
79
|
+
const [key, ...rest] = path;
|
|
69
80
|
if (rest.length === 0)
|
|
70
81
|
return this.delete(key);
|
|
71
82
|
const node = this.get(key, true);
|
|
@@ -79,7 +90,8 @@ class Collection extends NodeBase {
|
|
|
79
90
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
80
91
|
* `true` (collections are always returned intact).
|
|
81
92
|
*/
|
|
82
|
-
getIn(
|
|
93
|
+
getIn(path, keepScalar) {
|
|
94
|
+
const [key, ...rest] = path;
|
|
83
95
|
const node = this.get(key, true);
|
|
84
96
|
if (rest.length === 0)
|
|
85
97
|
return !keepScalar && isScalar(node) ? node.value : node;
|
|
@@ -103,7 +115,8 @@ class Collection extends NodeBase {
|
|
|
103
115
|
/**
|
|
104
116
|
* Checks if the collection includes a value with the key `key`.
|
|
105
117
|
*/
|
|
106
|
-
hasIn(
|
|
118
|
+
hasIn(path) {
|
|
119
|
+
const [key, ...rest] = path;
|
|
107
120
|
if (rest.length === 0)
|
|
108
121
|
return this.has(key);
|
|
109
122
|
const node = this.get(key, true);
|
|
@@ -113,7 +126,8 @@ class Collection extends NodeBase {
|
|
|
113
126
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
114
127
|
* boolean to add/remove the item from the set.
|
|
115
128
|
*/
|
|
116
|
-
setIn(
|
|
129
|
+
setIn(path, value) {
|
|
130
|
+
const [key, ...rest] = path;
|
|
117
131
|
if (rest.length === 0) {
|
|
118
132
|
this.set(key, value);
|
|
119
133
|
}
|
|
@@ -36,6 +36,13 @@ class NodeBase {
|
|
|
36
36
|
constructor(type) {
|
|
37
37
|
Object.defineProperty(this, NODE_TYPE, { value: type });
|
|
38
38
|
}
|
|
39
|
+
/** Create a copy of this node. */
|
|
40
|
+
clone() {
|
|
41
|
+
const copy = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
|
|
42
|
+
if (this.range)
|
|
43
|
+
copy.range = this.range.slice();
|
|
44
|
+
return copy;
|
|
45
|
+
}
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
export { ALIAS, DOC, MAP, NODE_TYPE, NodeBase, PAIR, SCALAR, SEQ, hasAnchor, isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createNode } from '../doc/createNode.js';
|
|
2
2
|
import { stringifyPair } from '../stringify/stringifyPair.js';
|
|
3
3
|
import { addPairToJSMap } from './addPairToJSMap.js';
|
|
4
|
-
import { NODE_TYPE, PAIR } from './Node.js';
|
|
4
|
+
import { NODE_TYPE, PAIR, isNode } from './Node.js';
|
|
5
5
|
|
|
6
6
|
function createPair(key, value, ctx) {
|
|
7
7
|
const k = createNode(key, undefined, ctx);
|
|
@@ -14,12 +14,20 @@ class Pair {
|
|
|
14
14
|
this.key = key;
|
|
15
15
|
this.value = value;
|
|
16
16
|
}
|
|
17
|
+
clone(schema) {
|
|
18
|
+
let { key, value } = this;
|
|
19
|
+
if (isNode(key))
|
|
20
|
+
key = key.clone(schema);
|
|
21
|
+
if (isNode(value))
|
|
22
|
+
value = value.clone(schema);
|
|
23
|
+
return new Pair(key, value);
|
|
24
|
+
}
|
|
17
25
|
toJSON(_, ctx) {
|
|
18
|
-
const pair = ctx
|
|
26
|
+
const pair = ctx?.mapAsMap ? new Map() : {};
|
|
19
27
|
return addPairToJSMap(ctx, pair, this);
|
|
20
28
|
}
|
|
21
29
|
toString(ctx, onComment, onChompKeep) {
|
|
22
|
-
return ctx
|
|
30
|
+
return ctx?.doc
|
|
23
31
|
? stringifyPair(this, ctx, onComment, onChompKeep)
|
|
24
32
|
: JSON.stringify(this);
|
|
25
33
|
}
|
|
@@ -18,13 +18,13 @@ function findPair(items, key) {
|
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
20
20
|
class YAMLMap extends Collection {
|
|
21
|
+
static get tagName() {
|
|
22
|
+
return 'tag:yaml.org,2002:map';
|
|
23
|
+
}
|
|
21
24
|
constructor(schema) {
|
|
22
25
|
super(MAP, schema);
|
|
23
26
|
this.items = [];
|
|
24
27
|
}
|
|
25
|
-
static get tagName() {
|
|
26
|
-
return 'tag:yaml.org,2002:map';
|
|
27
|
-
}
|
|
28
28
|
/**
|
|
29
29
|
* Adds a value to the collection.
|
|
30
30
|
*
|
|
@@ -37,12 +37,12 @@ class YAMLMap extends Collection {
|
|
|
37
37
|
_pair = pair;
|
|
38
38
|
else if (!pair || typeof pair !== 'object' || !('key' in pair)) {
|
|
39
39
|
// In TypeScript, this never happens.
|
|
40
|
-
_pair = new Pair(pair, pair
|
|
40
|
+
_pair = new Pair(pair, pair?.value);
|
|
41
41
|
}
|
|
42
42
|
else
|
|
43
43
|
_pair = new Pair(pair.key, pair.value);
|
|
44
44
|
const prev = findPair(this.items, _pair.key);
|
|
45
|
-
const sortEntries = this.schema
|
|
45
|
+
const sortEntries = this.schema?.sortMapEntries;
|
|
46
46
|
if (prev) {
|
|
47
47
|
if (!overwrite)
|
|
48
48
|
throw new Error(`Key ${_pair.key} already set`);
|
|
@@ -72,8 +72,8 @@ class YAMLMap extends Collection {
|
|
|
72
72
|
}
|
|
73
73
|
get(key, keepScalar) {
|
|
74
74
|
const it = findPair(this.items, key);
|
|
75
|
-
const node = it
|
|
76
|
-
return !keepScalar && isScalar(node) ? node.value : node;
|
|
75
|
+
const node = it?.value;
|
|
76
|
+
return (!keepScalar && isScalar(node) ? node.value : node) ?? undefined;
|
|
77
77
|
}
|
|
78
78
|
has(key) {
|
|
79
79
|
return !!findPair(this.items, key);
|
|
@@ -87,8 +87,8 @@ class YAMLMap extends Collection {
|
|
|
87
87
|
* @returns Instance of Type, Map, or Object
|
|
88
88
|
*/
|
|
89
89
|
toJSON(_, ctx, Type) {
|
|
90
|
-
const map = Type ? new Type() : ctx
|
|
91
|
-
if (ctx
|
|
90
|
+
const map = Type ? new Type() : ctx?.mapAsMap ? new Map() : {};
|
|
91
|
+
if (ctx?.onCreate)
|
|
92
92
|
ctx.onCreate(map);
|
|
93
93
|
for (const item of this.items)
|
|
94
94
|
addPairToJSMap(ctx, map, item);
|
|
@@ -104,7 +104,7 @@ class YAMLMap extends Collection {
|
|
|
104
104
|
if (!ctx.allNullValues && this.hasAllNullValues(false))
|
|
105
105
|
ctx = Object.assign({}, ctx, { allNullValues: true });
|
|
106
106
|
return stringifyCollection(this, ctx, {
|
|
107
|
-
|
|
107
|
+
blockItemPrefix: '',
|
|
108
108
|
flowChars: { start: '{', end: '}' },
|
|
109
109
|
itemIndent: ctx.indent || '',
|
|
110
110
|
onChompKeep,
|
|
@@ -5,13 +5,13 @@ import { isScalarValue } from './Scalar.js';
|
|
|
5
5
|
import { toJS } from './toJS.js';
|
|
6
6
|
|
|
7
7
|
class YAMLSeq extends Collection {
|
|
8
|
+
static get tagName() {
|
|
9
|
+
return 'tag:yaml.org,2002:seq';
|
|
10
|
+
}
|
|
8
11
|
constructor(schema) {
|
|
9
12
|
super(SEQ, schema);
|
|
10
13
|
this.items = [];
|
|
11
14
|
}
|
|
12
|
-
static get tagName() {
|
|
13
|
-
return 'tag:yaml.org,2002:seq';
|
|
14
|
-
}
|
|
15
15
|
add(value) {
|
|
16
16
|
this.items.push(value);
|
|
17
17
|
}
|
|
@@ -30,14 +30,6 @@ class YAMLSeq extends Collection {
|
|
|
30
30
|
const del = this.items.splice(idx, 1);
|
|
31
31
|
return del.length > 0;
|
|
32
32
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
35
|
-
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
36
|
-
* `true` (collections are always returned intact).
|
|
37
|
-
*
|
|
38
|
-
* `key` must contain a representation of an integer for this to succeed.
|
|
39
|
-
* It may be wrapped in a `Scalar`.
|
|
40
|
-
*/
|
|
41
33
|
get(key, keepScalar) {
|
|
42
34
|
const idx = asItemIndex(key);
|
|
43
35
|
if (typeof idx !== 'number')
|
|
@@ -74,7 +66,7 @@ class YAMLSeq extends Collection {
|
|
|
74
66
|
}
|
|
75
67
|
toJSON(_, ctx) {
|
|
76
68
|
const seq = [];
|
|
77
|
-
if (ctx
|
|
69
|
+
if (ctx?.onCreate)
|
|
78
70
|
ctx.onCreate(seq);
|
|
79
71
|
let i = 0;
|
|
80
72
|
for (const item of this.items)
|
|
@@ -85,7 +77,7 @@ class YAMLSeq extends Collection {
|
|
|
85
77
|
if (!ctx)
|
|
86
78
|
return JSON.stringify(this);
|
|
87
79
|
return stringifyCollection(this, ctx, {
|
|
88
|
-
|
|
80
|
+
blockItemPrefix: '- ',
|
|
89
81
|
flowChars: { start: '[', end: ']' },
|
|
90
82
|
itemIndent: (ctx.indent || '') + ' ',
|
|
91
83
|
onChompKeep,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { warn } from '../log.js';
|
|
2
2
|
import { createStringifyContext } from '../stringify/stringify.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isAlias, isSeq, isScalar, isMap, isNode } from './Node.js';
|
|
4
4
|
import { Scalar } from './Scalar.js';
|
|
5
5
|
import { toJS } from './toJS.js';
|
|
6
6
|
|
|
7
7
|
const MERGE_KEY = '<<';
|
|
8
8
|
function addPairToJSMap(ctx, map, { key, value }) {
|
|
9
|
-
if (ctx
|
|
9
|
+
if (ctx?.doc.schema.merge && isMergeKey(key)) {
|
|
10
|
+
value = isAlias(value) ? value.resolve(ctx.doc) : value;
|
|
10
11
|
if (isSeq(value))
|
|
11
12
|
for (const it of value.items)
|
|
12
13
|
mergeToJSMap(ctx, map, it);
|
|
@@ -11,9 +11,11 @@ import { hasAnchor } from './Node.js';
|
|
|
11
11
|
* stringification.
|
|
12
12
|
*/
|
|
13
13
|
function toJS(value, arg, ctx) {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
14
15
|
if (Array.isArray(value))
|
|
15
16
|
return value.map((v, i) => toJS(v, String(i), ctx));
|
|
16
17
|
if (value && typeof value.toJSON === 'function') {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
17
19
|
if (!ctx || !hasAnchor(value))
|
|
18
20
|
return value.toJSON(arg, ctx);
|
|
19
21
|
const data = { aliasCount: 0, count: 1, res: undefined };
|
|
@@ -27,7 +29,7 @@ function toJS(value, arg, ctx) {
|
|
|
27
29
|
ctx.onCreate(res);
|
|
28
30
|
return res;
|
|
29
31
|
}
|
|
30
|
-
if (typeof value === 'bigint' && !
|
|
32
|
+
if (typeof value === 'bigint' && !ctx?.keep)
|
|
31
33
|
return Number(value);
|
|
32
34
|
return value;
|
|
33
35
|
}
|
|
@@ -3,10 +3,6 @@ import { resolveFlowScalar } from '../compose/resolve-flow-scalar.js';
|
|
|
3
3
|
import { YAMLParseError } from '../errors.js';
|
|
4
4
|
import { stringifyString } from '../stringify/stringifyString.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* If `token` is a CST flow or block scalar, determine its string value and a few other attributes.
|
|
8
|
-
* Otherwise, return `null`.
|
|
9
|
-
*/
|
|
10
6
|
function resolveAsScalar(token, strict = true, onError) {
|
|
11
7
|
if (token) {
|
|
12
8
|
const _onError = (pos, code, message) => {
|
|
@@ -42,15 +38,14 @@ function resolveAsScalar(token, strict = true, onError) {
|
|
|
42
38
|
* @param context.type The preferred type of the scalar token. If undefined, the previous type of the `token` will be used, defaulting to `'PLAIN'`.
|
|
43
39
|
*/
|
|
44
40
|
function createScalarToken(value, context) {
|
|
45
|
-
var _a;
|
|
46
41
|
const { implicitKey = false, indent, inFlow = false, offset = -1, type = 'PLAIN' } = context;
|
|
47
42
|
const source = stringifyString({ type, value }, {
|
|
48
43
|
implicitKey,
|
|
49
44
|
indent: indent > 0 ? ' '.repeat(indent) : '',
|
|
50
45
|
inFlow,
|
|
51
|
-
options: { lineWidth: -1 }
|
|
46
|
+
options: { blockQuote: true, lineWidth: -1 }
|
|
52
47
|
});
|
|
53
|
-
const end =
|
|
48
|
+
const end = context.end ?? [
|
|
54
49
|
{ type: 'newline', offset: -1, indent, source: '\n' }
|
|
55
50
|
];
|
|
56
51
|
switch (source[0]) {
|
|
@@ -117,7 +112,7 @@ function setScalarValue(token, value, context = {}) {
|
|
|
117
112
|
implicitKey: implicitKey || indent === null,
|
|
118
113
|
indent: indent !== null && indent > 0 ? ' '.repeat(indent) : '',
|
|
119
114
|
inFlow,
|
|
120
|
-
options: { lineWidth: -1 }
|
|
115
|
+
options: { blockQuote: true, lineWidth: -1 }
|
|
121
116
|
});
|
|
122
117
|
switch (source[0]) {
|
|
123
118
|
case '|':
|
|
@@ -47,7 +47,7 @@ visit.REMOVE = REMOVE;
|
|
|
47
47
|
visit.itemAtPath = (cst, path) => {
|
|
48
48
|
let item = cst;
|
|
49
49
|
for (const [field, index] of path) {
|
|
50
|
-
const tok = item
|
|
50
|
+
const tok = item?.[field];
|
|
51
51
|
if (tok && 'items' in tok) {
|
|
52
52
|
item = tok.items[index];
|
|
53
53
|
}
|
|
@@ -64,7 +64,7 @@ visit.itemAtPath = (cst, path) => {
|
|
|
64
64
|
visit.parentCollection = (cst, path) => {
|
|
65
65
|
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
66
66
|
const field = path[path.length - 1][0];
|
|
67
|
-
const coll = parent
|
|
67
|
+
const coll = parent?.[field];
|
|
68
68
|
if (coll && 'items' in coll)
|
|
69
69
|
return coll;
|
|
70
70
|
throw new Error('Parent collection not found');
|