cdk8s 2.7.102 → 2.7.104
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 +41 -41
- package/lib/_child_process.d.ts +0 -1
- package/lib/api-object.d.ts +2 -0
- package/lib/api-object.js +31 -31
- package/lib/app.js +14 -14
- package/lib/chart.js +9 -9
- package/lib/cron.js +10 -10
- package/lib/dependency.js +2 -2
- package/lib/duration.js +9 -9
- package/lib/helm.js +1 -1
- package/lib/include.js +1 -1
- package/lib/index.js +7 -3
- package/lib/json-patch.js +6 -6
- package/lib/lazy.js +5 -5
- package/lib/metadata.d.ts +2 -0
- package/lib/metadata.js +4 -4
- package/lib/names.js +6 -6
- package/lib/size.js +10 -10
- package/lib/testing.js +6 -6
- package/lib/yaml.js +9 -9
- package/node_modules/yaml/README.md +4 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +46 -29
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +1 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +1 -1
- package/node_modules/yaml/browser/dist/compose/composer.js +1 -1
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +3 -2
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +3 -2
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +4 -5
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +1 -1
- package/node_modules/yaml/browser/dist/doc/Document.js +12 -10
- package/node_modules/yaml/browser/dist/doc/anchors.js +1 -1
- package/node_modules/yaml/browser/dist/doc/createNode.js +6 -2
- package/node_modules/yaml/browser/dist/doc/directives.js +1 -1
- package/node_modules/yaml/browser/dist/index.js +1 -1
- package/node_modules/yaml/browser/dist/node_modules/tslib/tslib.es6.js +6 -149
- package/node_modules/yaml/browser/dist/nodes/Alias.js +9 -2
- package/node_modules/yaml/browser/dist/nodes/Collection.js +2 -1
- package/node_modules/yaml/browser/dist/nodes/Node.js +25 -35
- package/node_modules/yaml/browser/dist/nodes/Pair.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +2 -1
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +30 -2
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +17 -1
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +1 -1
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +1 -1
- package/node_modules/yaml/browser/dist/schema/Schema.js +1 -1
- package/node_modules/yaml/browser/dist/schema/common/map.js +3 -28
- package/node_modules/yaml/browser/dist/schema/common/seq.js +3 -19
- package/node_modules/yaml/browser/dist/schema/tags.js +1 -1
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +9 -8
- 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 +14 -13
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringify.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +1 -1
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +10 -1
- package/node_modules/yaml/browser/dist/util.js +2 -0
- package/node_modules/yaml/browser/dist/visit.js +1 -1
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +1 -1
- package/node_modules/yaml/dist/compose/compose-collection.js +47 -30
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +2 -1
- package/node_modules/yaml/dist/compose/compose-doc.js +1 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +7 -7
- package/node_modules/yaml/dist/compose/composer.d.ts +5 -5
- package/node_modules/yaml/dist/compose/composer.js +3 -3
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +2 -1
- package/node_modules/yaml/dist/compose/resolve-block-map.js +3 -2
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +2 -1
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +3 -2
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +2 -1
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +5 -6
- package/node_modules/yaml/dist/compose/util-map-includes.d.ts +3 -3
- package/node_modules/yaml/dist/compose/util-map-includes.js +3 -3
- package/node_modules/yaml/dist/doc/Document.d.ts +11 -9
- package/node_modules/yaml/dist/doc/Document.js +22 -20
- package/node_modules/yaml/dist/doc/anchors.d.ts +4 -4
- package/node_modules/yaml/dist/doc/anchors.js +2 -2
- package/node_modules/yaml/dist/doc/createNode.d.ts +1 -1
- package/node_modules/yaml/dist/doc/createNode.js +13 -9
- package/node_modules/yaml/dist/doc/directives.js +3 -3
- package/node_modules/yaml/dist/errors.d.ts +1 -1
- package/node_modules/yaml/dist/index.d.ts +2 -1
- package/node_modules/yaml/dist/index.js +9 -9
- package/node_modules/yaml/dist/nodes/Alias.d.ts +1 -1
- package/node_modules/yaml/dist/nodes/Alias.js +12 -5
- package/node_modules/yaml/dist/nodes/Collection.d.ts +3 -2
- package/node_modules/yaml/dist/nodes/Collection.js +10 -9
- package/node_modules/yaml/dist/nodes/Node.d.ts +5 -18
- package/node_modules/yaml/dist/nodes/Node.js +25 -51
- package/node_modules/yaml/dist/nodes/Pair.d.ts +2 -2
- package/node_modules/yaml/dist/nodes/Pair.js +4 -4
- package/node_modules/yaml/dist/nodes/Scalar.js +2 -1
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +7 -1
- package/node_modules/yaml/dist/nodes/YAMLMap.js +37 -9
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +3 -1
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +21 -5
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +7 -7
- package/node_modules/yaml/dist/nodes/identity.d.ts +23 -0
- package/node_modules/yaml/dist/nodes/identity.js +53 -0
- package/node_modules/yaml/dist/nodes/toJS.d.ts +2 -5
- package/node_modules/yaml/dist/nodes/toJS.js +2 -2
- package/node_modules/yaml/dist/public-api.d.ts +3 -3
- package/node_modules/yaml/dist/schema/Schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/Schema.js +4 -4
- package/node_modules/yaml/dist/schema/common/map.js +4 -29
- package/node_modules/yaml/dist/schema/common/seq.js +4 -20
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/json/schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/tags.d.ts +1 -1
- package/node_modules/yaml/dist/schema/types.d.ts +11 -3
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +4 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +11 -10
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +5 -5
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +3 -1
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +17 -16
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +1 -1
- package/node_modules/yaml/dist/stringify/stringify.js +8 -8
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +8 -8
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -3
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +2 -2
- package/node_modules/yaml/dist/stringify/stringifyPair.js +9 -9
- package/node_modules/yaml/dist/stringify/stringifyString.js +10 -1
- package/node_modules/yaml/dist/test-events.js +8 -8
- package/node_modules/yaml/dist/util.d.ts +4 -1
- package/node_modules/yaml/dist/util.js +4 -0
- package/node_modules/yaml/dist/visit.js +18 -18
- package/node_modules/yaml/package.json +6 -5
- package/package.json +10 -12
- package/node_modules/yaml/util.d.ts +0 -3
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Alias } from '../nodes/Alias.js';
|
|
2
2
|
import { isEmptyPath, collectionFromPath } from '../nodes/Collection.js';
|
|
3
|
-
import { NODE_TYPE, DOC, isNode, isCollection, isScalar } from '../nodes/
|
|
3
|
+
import { NODE_TYPE, DOC, isNode, isCollection, isScalar } from '../nodes/identity.js';
|
|
4
4
|
import { Pair } from '../nodes/Pair.js';
|
|
5
5
|
import { toJS } from '../nodes/toJS.js';
|
|
6
6
|
import { Schema } from '../schema/Schema.js';
|
|
7
|
-
import { stringify } from '../stringify/stringify.js';
|
|
8
7
|
import { stringifyDocument } from '../stringify/stringifyDocument.js';
|
|
9
8
|
import { anchorNames, findNewAnchor, createNodeAnchors } from './anchors.js';
|
|
10
9
|
import { applyReviver } from './applyReviver.js';
|
|
@@ -49,11 +48,9 @@ class Document {
|
|
|
49
48
|
else
|
|
50
49
|
this.directives = new Directives({ version });
|
|
51
50
|
this.setSchema(version, options);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
this.contents = this.createNode(value, _replacer, options);
|
|
56
|
-
}
|
|
51
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
52
|
+
this.contents =
|
|
53
|
+
value === undefined ? null : this.createNode(value, _replacer, options);
|
|
57
54
|
}
|
|
58
55
|
/**
|
|
59
56
|
* Create a deep copy of this Document and its contents.
|
|
@@ -72,6 +69,7 @@ class Document {
|
|
|
72
69
|
if (this.directives)
|
|
73
70
|
copy.directives = this.directives.clone();
|
|
74
71
|
copy.schema = this.schema.clone();
|
|
72
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
75
73
|
copy.contents = isNode(this.contents)
|
|
76
74
|
? this.contents.clone(copy.schema)
|
|
77
75
|
: this.contents;
|
|
@@ -167,6 +165,7 @@ class Document {
|
|
|
167
165
|
if (isEmptyPath(path)) {
|
|
168
166
|
if (this.contents == null)
|
|
169
167
|
return false;
|
|
168
|
+
// @ts-expect-error Presumed impossible if Strict extends false
|
|
170
169
|
this.contents = null;
|
|
171
170
|
return true;
|
|
172
171
|
}
|
|
@@ -218,6 +217,7 @@ class Document {
|
|
|
218
217
|
*/
|
|
219
218
|
set(key, value) {
|
|
220
219
|
if (this.contents == null) {
|
|
220
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
221
221
|
this.contents = collectionFromPath(this.schema, [key], value);
|
|
222
222
|
}
|
|
223
223
|
else if (assertCollection(this.contents)) {
|
|
@@ -229,9 +229,12 @@ class Document {
|
|
|
229
229
|
* boolean to add/remove the item from the set.
|
|
230
230
|
*/
|
|
231
231
|
setIn(path, value) {
|
|
232
|
-
if (isEmptyPath(path))
|
|
232
|
+
if (isEmptyPath(path)) {
|
|
233
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
233
234
|
this.contents = value;
|
|
235
|
+
}
|
|
234
236
|
else if (this.contents == null) {
|
|
237
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
235
238
|
this.contents = collectionFromPath(this.schema, Array.from(path), value);
|
|
236
239
|
}
|
|
237
240
|
else if (assertCollection(this.contents)) {
|
|
@@ -291,8 +294,7 @@ class Document {
|
|
|
291
294
|
keep: !json,
|
|
292
295
|
mapAsMap: mapAsMap === true,
|
|
293
296
|
mapKeyWarned: false,
|
|
294
|
-
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
295
|
-
stringify
|
|
297
|
+
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
296
298
|
};
|
|
297
299
|
const res = toJS(this.contents, jsonArg ?? '', ctx);
|
|
298
300
|
if (typeof onAnchor === 'function')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Alias } from '../nodes/Alias.js';
|
|
2
|
-
import { isNode, isPair, MAP, SEQ, isDocument } from '../nodes/
|
|
2
|
+
import { isNode, isPair, MAP, SEQ, isDocument } from '../nodes/identity.js';
|
|
3
3
|
import { Scalar } from '../nodes/Scalar.js';
|
|
4
4
|
|
|
5
5
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
@@ -74,9 +74,13 @@ function createNode(value, tagName, ctx) {
|
|
|
74
74
|
}
|
|
75
75
|
const node = tagObj?.createNode
|
|
76
76
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
77
|
-
:
|
|
77
|
+
: typeof tagObj?.nodeClass?.from === 'function'
|
|
78
|
+
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
79
|
+
: new Scalar(value);
|
|
78
80
|
if (tagName)
|
|
79
81
|
node.tag = tagName;
|
|
82
|
+
else if (!tagObj.default)
|
|
83
|
+
node.tag = tagObj.tag;
|
|
80
84
|
if (ref)
|
|
81
85
|
ref.node = node;
|
|
82
86
|
return node;
|
|
@@ -3,7 +3,7 @@ export { Document } from './doc/Document.js';
|
|
|
3
3
|
export { Schema } from './schema/Schema.js';
|
|
4
4
|
export { YAMLError, YAMLParseError, YAMLWarning } from './errors.js';
|
|
5
5
|
export { Alias } from './nodes/Alias.js';
|
|
6
|
-
export { isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq } from './nodes/
|
|
6
|
+
export { isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq } from './nodes/identity.js';
|
|
7
7
|
export { Pair } from './nodes/Pair.js';
|
|
8
8
|
export { Scalar } from './nodes/Scalar.js';
|
|
9
9
|
export { YAMLMap } from './nodes/YAMLMap.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/******************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -12,153 +12,10 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
14
|
***************************************************************************** */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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.");
|
|
15
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
16
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
17
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
18
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
162
19
|
}
|
|
163
20
|
|
|
164
|
-
export {
|
|
21
|
+
export { __classPrivateFieldGet };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { anchorIsValid } from '../doc/anchors.js';
|
|
2
2
|
import { visit } from '../visit.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ALIAS, isAlias, isCollection, isPair } from './identity.js';
|
|
4
|
+
import { NodeBase } from './Node.js';
|
|
5
|
+
import { toJS } from './toJS.js';
|
|
4
6
|
|
|
5
7
|
class Alias extends NodeBase {
|
|
6
8
|
constructor(source) {
|
|
@@ -37,7 +39,12 @@ class Alias extends NodeBase {
|
|
|
37
39
|
const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
|
|
38
40
|
throw new ReferenceError(msg);
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
let data = anchors.get(source);
|
|
43
|
+
if (!data) {
|
|
44
|
+
// Resolve anchors for Node.prototype.toJS()
|
|
45
|
+
toJS(source, null, ctx);
|
|
46
|
+
data = anchors.get(source);
|
|
47
|
+
}
|
|
41
48
|
/* istanbul ignore if */
|
|
42
49
|
if (!data || data.res === undefined) {
|
|
43
50
|
const msg = 'This should not happen: Alias anchor was not resolved?';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createNode } from '../doc/createNode.js';
|
|
2
|
-
import {
|
|
2
|
+
import { isNode, isPair, isCollection, isScalar } from './identity.js';
|
|
3
|
+
import { NodeBase } from './Node.js';
|
|
3
4
|
|
|
4
5
|
function collectionFromPath(schema, path, value) {
|
|
5
6
|
let v = value;
|
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const SCALAR = Symbol.for('yaml.scalar');
|
|
6
|
-
const SEQ = Symbol.for('yaml.seq');
|
|
7
|
-
const NODE_TYPE = Symbol.for('yaml.node.type');
|
|
8
|
-
const isAlias = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === ALIAS;
|
|
9
|
-
const isDocument = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === DOC;
|
|
10
|
-
const isMap = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === MAP;
|
|
11
|
-
const isPair = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === PAIR;
|
|
12
|
-
const isScalar = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SCALAR;
|
|
13
|
-
const isSeq = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SEQ;
|
|
14
|
-
function isCollection(node) {
|
|
15
|
-
if (node && typeof node === 'object')
|
|
16
|
-
switch (node[NODE_TYPE]) {
|
|
17
|
-
case MAP:
|
|
18
|
-
case SEQ:
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
function isNode(node) {
|
|
24
|
-
if (node && typeof node === 'object')
|
|
25
|
-
switch (node[NODE_TYPE]) {
|
|
26
|
-
case ALIAS:
|
|
27
|
-
case MAP:
|
|
28
|
-
case SCALAR:
|
|
29
|
-
case SEQ:
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
1
|
+
import { applyReviver } from '../doc/applyReviver.js';
|
|
2
|
+
import { NODE_TYPE, isDocument } from './identity.js';
|
|
3
|
+
import { toJS } from './toJS.js';
|
|
4
|
+
|
|
35
5
|
class NodeBase {
|
|
36
6
|
constructor(type) {
|
|
37
7
|
Object.defineProperty(this, NODE_TYPE, { value: type });
|
|
@@ -43,6 +13,26 @@ class NodeBase {
|
|
|
43
13
|
copy.range = this.range.slice();
|
|
44
14
|
return copy;
|
|
45
15
|
}
|
|
16
|
+
/** A plain JavaScript representation of this node. */
|
|
17
|
+
toJS(doc, { mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
18
|
+
if (!isDocument(doc))
|
|
19
|
+
throw new TypeError('A document argument is required');
|
|
20
|
+
const ctx = {
|
|
21
|
+
anchors: new Map(),
|
|
22
|
+
doc,
|
|
23
|
+
keep: true,
|
|
24
|
+
mapAsMap: mapAsMap === true,
|
|
25
|
+
mapKeyWarned: false,
|
|
26
|
+
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
27
|
+
};
|
|
28
|
+
const res = toJS(this, '', ctx);
|
|
29
|
+
if (typeof onAnchor === 'function')
|
|
30
|
+
for (const { count, res } of ctx.anchors.values())
|
|
31
|
+
onAnchor(res, count);
|
|
32
|
+
return typeof reviver === 'function'
|
|
33
|
+
? applyReviver(reviver, { '': res }, '', res)
|
|
34
|
+
: res;
|
|
35
|
+
}
|
|
46
36
|
}
|
|
47
37
|
|
|
48
|
-
export {
|
|
38
|
+
export { NodeBase };
|
|
@@ -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, isNode } from './
|
|
4
|
+
import { NODE_TYPE, PAIR, isNode } from './identity.js';
|
|
5
5
|
|
|
6
6
|
function createPair(key, value, ctx) {
|
|
7
7
|
const k = createNode(key, undefined, ctx);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SCALAR } from './identity.js';
|
|
2
|
+
import { NodeBase } from './Node.js';
|
|
2
3
|
import { toJS } from './toJS.js';
|
|
3
4
|
|
|
4
5
|
const isScalarValue = (value) => !value || (typeof value !== 'function' && typeof value !== 'object');
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { stringifyCollection } from '../stringify/stringifyCollection.js';
|
|
2
2
|
import { addPairToJSMap } from './addPairToJSMap.js';
|
|
3
3
|
import { Collection } from './Collection.js';
|
|
4
|
-
import { isPair, isScalar, MAP } from './
|
|
5
|
-
import { Pair } from './Pair.js';
|
|
4
|
+
import { isPair, isScalar, MAP } from './identity.js';
|
|
5
|
+
import { Pair, createPair } from './Pair.js';
|
|
6
6
|
import { isScalarValue } from './Scalar.js';
|
|
7
7
|
|
|
8
8
|
function findPair(items, key) {
|
|
@@ -25,6 +25,34 @@ class YAMLMap extends Collection {
|
|
|
25
25
|
super(MAP, schema);
|
|
26
26
|
this.items = [];
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* A generic collection parsing method that can be extended
|
|
30
|
+
* to other node classes that inherit from YAMLMap
|
|
31
|
+
*/
|
|
32
|
+
static from(schema, obj, ctx) {
|
|
33
|
+
const { keepUndefined, replacer } = ctx;
|
|
34
|
+
const map = new this(schema);
|
|
35
|
+
const add = (key, value) => {
|
|
36
|
+
if (typeof replacer === 'function')
|
|
37
|
+
value = replacer.call(obj, key, value);
|
|
38
|
+
else if (Array.isArray(replacer) && !replacer.includes(key))
|
|
39
|
+
return;
|
|
40
|
+
if (value !== undefined || keepUndefined)
|
|
41
|
+
map.items.push(createPair(key, value, ctx));
|
|
42
|
+
};
|
|
43
|
+
if (obj instanceof Map) {
|
|
44
|
+
for (const [key, value] of obj)
|
|
45
|
+
add(key, value);
|
|
46
|
+
}
|
|
47
|
+
else if (obj && typeof obj === 'object') {
|
|
48
|
+
for (const key of Object.keys(obj))
|
|
49
|
+
add(key, obj[key]);
|
|
50
|
+
}
|
|
51
|
+
if (typeof schema.sortMapEntries === 'function') {
|
|
52
|
+
map.items.sort(schema.sortMapEntries);
|
|
53
|
+
}
|
|
54
|
+
return map;
|
|
55
|
+
}
|
|
28
56
|
/**
|
|
29
57
|
* Adds a value to the collection.
|
|
30
58
|
*
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { createNode } from '../doc/createNode.js';
|
|
1
2
|
import { stringifyCollection } from '../stringify/stringifyCollection.js';
|
|
2
3
|
import { Collection } from './Collection.js';
|
|
3
|
-
import { SEQ, isScalar } from './
|
|
4
|
+
import { SEQ, isScalar } from './identity.js';
|
|
4
5
|
import { isScalarValue } from './Scalar.js';
|
|
5
6
|
import { toJS } from './toJS.js';
|
|
6
7
|
|
|
@@ -84,6 +85,21 @@ class YAMLSeq extends Collection {
|
|
|
84
85
|
onComment
|
|
85
86
|
});
|
|
86
87
|
}
|
|
88
|
+
static from(schema, obj, ctx) {
|
|
89
|
+
const { replacer } = ctx;
|
|
90
|
+
const seq = new this(schema);
|
|
91
|
+
if (obj && Symbol.iterator in Object(obj)) {
|
|
92
|
+
let i = 0;
|
|
93
|
+
for (let it of obj) {
|
|
94
|
+
if (typeof replacer === 'function') {
|
|
95
|
+
const key = obj instanceof Set ? it : String(i++);
|
|
96
|
+
it = replacer.call(obj, key, it);
|
|
97
|
+
}
|
|
98
|
+
seq.items.push(createNode(it, undefined, ctx));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return seq;
|
|
102
|
+
}
|
|
87
103
|
}
|
|
88
104
|
function asItemIndex(key) {
|
|
89
105
|
let idx = isScalar(key) ? key.value : key;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { warn } from '../log.js';
|
|
2
2
|
import { createStringifyContext } from '../stringify/stringify.js';
|
|
3
|
-
import { isAlias, isSeq, isScalar, isMap, isNode } from './
|
|
3
|
+
import { isAlias, isSeq, isScalar, isMap, isNode } from './identity.js';
|
|
4
4
|
import { Scalar } from './Scalar.js';
|
|
5
5
|
import { toJS } from './toJS.js';
|
|
6
6
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const ALIAS = Symbol.for('yaml.alias');
|
|
2
|
+
const DOC = Symbol.for('yaml.document');
|
|
3
|
+
const MAP = Symbol.for('yaml.map');
|
|
4
|
+
const PAIR = Symbol.for('yaml.pair');
|
|
5
|
+
const SCALAR = Symbol.for('yaml.scalar');
|
|
6
|
+
const SEQ = Symbol.for('yaml.seq');
|
|
7
|
+
const NODE_TYPE = Symbol.for('yaml.node.type');
|
|
8
|
+
const isAlias = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === ALIAS;
|
|
9
|
+
const isDocument = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === DOC;
|
|
10
|
+
const isMap = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === MAP;
|
|
11
|
+
const isPair = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === PAIR;
|
|
12
|
+
const isScalar = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SCALAR;
|
|
13
|
+
const isSeq = (node) => !!node && typeof node === 'object' && node[NODE_TYPE] === SEQ;
|
|
14
|
+
function isCollection(node) {
|
|
15
|
+
if (node && typeof node === 'object')
|
|
16
|
+
switch (node[NODE_TYPE]) {
|
|
17
|
+
case MAP:
|
|
18
|
+
case SEQ:
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
function isNode(node) {
|
|
24
|
+
if (node && typeof node === 'object')
|
|
25
|
+
switch (node[NODE_TYPE]) {
|
|
26
|
+
case ALIAS:
|
|
27
|
+
case MAP:
|
|
28
|
+
case SCALAR:
|
|
29
|
+
case SEQ:
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
|
|
35
|
+
|
|
36
|
+
export { ALIAS, DOC, MAP, NODE_TYPE, PAIR, SCALAR, SEQ, hasAnchor, isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq };
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
import { isMap } from '../../nodes/
|
|
2
|
-
import { createPair } from '../../nodes/Pair.js';
|
|
1
|
+
import { isMap } from '../../nodes/identity.js';
|
|
3
2
|
import { YAMLMap } from '../../nodes/YAMLMap.js';
|
|
4
3
|
|
|
5
|
-
function createMap(schema, obj, ctx) {
|
|
6
|
-
const { keepUndefined, replacer } = ctx;
|
|
7
|
-
const map = new YAMLMap(schema);
|
|
8
|
-
const add = (key, value) => {
|
|
9
|
-
if (typeof replacer === 'function')
|
|
10
|
-
value = replacer.call(obj, key, value);
|
|
11
|
-
else if (Array.isArray(replacer) && !replacer.includes(key))
|
|
12
|
-
return;
|
|
13
|
-
if (value !== undefined || keepUndefined)
|
|
14
|
-
map.items.push(createPair(key, value, ctx));
|
|
15
|
-
};
|
|
16
|
-
if (obj instanceof Map) {
|
|
17
|
-
for (const [key, value] of obj)
|
|
18
|
-
add(key, value);
|
|
19
|
-
}
|
|
20
|
-
else if (obj && typeof obj === 'object') {
|
|
21
|
-
for (const key of Object.keys(obj))
|
|
22
|
-
add(key, obj[key]);
|
|
23
|
-
}
|
|
24
|
-
if (typeof schema.sortMapEntries === 'function') {
|
|
25
|
-
map.items.sort(schema.sortMapEntries);
|
|
26
|
-
}
|
|
27
|
-
return map;
|
|
28
|
-
}
|
|
29
4
|
const map = {
|
|
30
5
|
collection: 'map',
|
|
31
|
-
createNode: createMap,
|
|
32
6
|
default: true,
|
|
33
7
|
nodeClass: YAMLMap,
|
|
34
8
|
tag: 'tag:yaml.org,2002:map',
|
|
@@ -36,7 +10,8 @@ const map = {
|
|
|
36
10
|
if (!isMap(map))
|
|
37
11
|
onError('Expected a mapping for this tag');
|
|
38
12
|
return map;
|
|
39
|
-
}
|
|
13
|
+
},
|
|
14
|
+
createNode: (schema, obj, ctx) => YAMLMap.from(schema, obj, ctx)
|
|
40
15
|
};
|
|
41
16
|
|
|
42
17
|
export { map };
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isSeq } from '../../nodes/Node.js';
|
|
1
|
+
import { isSeq } from '../../nodes/identity.js';
|
|
3
2
|
import { YAMLSeq } from '../../nodes/YAMLSeq.js';
|
|
4
3
|
|
|
5
|
-
function createSeq(schema, obj, ctx) {
|
|
6
|
-
const { replacer } = ctx;
|
|
7
|
-
const seq = new YAMLSeq(schema);
|
|
8
|
-
if (obj && Symbol.iterator in Object(obj)) {
|
|
9
|
-
let i = 0;
|
|
10
|
-
for (let it of obj) {
|
|
11
|
-
if (typeof replacer === 'function') {
|
|
12
|
-
const key = obj instanceof Set ? it : String(i++);
|
|
13
|
-
it = replacer.call(obj, key, it);
|
|
14
|
-
}
|
|
15
|
-
seq.items.push(createNode(it, undefined, ctx));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return seq;
|
|
19
|
-
}
|
|
20
4
|
const seq = {
|
|
21
5
|
collection: 'seq',
|
|
22
|
-
createNode: createSeq,
|
|
23
6
|
default: true,
|
|
24
7
|
nodeClass: YAMLSeq,
|
|
25
8
|
tag: 'tag:yaml.org,2002:seq',
|
|
@@ -27,7 +10,8 @@ const seq = {
|
|
|
27
10
|
if (!isSeq(seq))
|
|
28
11
|
onError('Expected a sequence for this tag');
|
|
29
12
|
return seq;
|
|
30
|
-
}
|
|
13
|
+
},
|
|
14
|
+
createNode: (schema, obj, ctx) => YAMLSeq.from(schema, obj, ctx)
|
|
31
15
|
};
|
|
32
16
|
|
|
33
17
|
export { seq };
|
|
@@ -12,7 +12,7 @@ import { omap } from './yaml-1.1/omap.js';
|
|
|
12
12
|
import { pairs } from './yaml-1.1/pairs.js';
|
|
13
13
|
import { schema as schema$2 } from './yaml-1.1/schema.js';
|
|
14
14
|
import { set } from './yaml-1.1/set.js';
|
|
15
|
-
import { floatTime, intTime
|
|
15
|
+
import { timestamp, floatTime, intTime } from './yaml-1.1/timestamp.js';
|
|
16
16
|
|
|
17
17
|
const schemas = new Map([
|
|
18
18
|
['core', schema],
|