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
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { YAMLError, YAMLWarning } from '../errors.js';
|
|
2
2
|
import { Alias } from '../nodes/Alias.js';
|
|
3
|
-
import { Node, NODE_TYPE, ParsedNode, Range } from '../nodes/Node.js';
|
|
3
|
+
import { Node, NodeType, NODE_TYPE, ParsedNode, Range } from '../nodes/Node.js';
|
|
4
4
|
import { Pair } from '../nodes/Pair.js';
|
|
5
5
|
import type { Scalar } from '../nodes/Scalar.js';
|
|
6
6
|
import type { YAMLMap } from '../nodes/YAMLMap.js';
|
|
7
7
|
import type { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
8
|
-
import { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from '../options.js';
|
|
8
|
+
import type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from '../options.js';
|
|
9
9
|
import { Schema } from '../schema/Schema.js';
|
|
10
10
|
import { Directives } from './directives.js';
|
|
11
|
-
export
|
|
11
|
+
export type Replacer = any[] | ((key: any, value: any) => unknown);
|
|
12
12
|
export declare namespace Document {
|
|
13
13
|
interface Parsed<T extends ParsedNode = ParsedNode> extends Document<T> {
|
|
14
|
+
directives: Directives;
|
|
14
15
|
range: Range;
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
export declare class Document<T =
|
|
18
|
+
export declare class Document<T extends Node = Node> {
|
|
18
19
|
readonly [NODE_TYPE]: symbol;
|
|
19
20
|
/** A comment before this Document */
|
|
20
21
|
commentBefore: string | null;
|
|
@@ -22,10 +23,10 @@ export declare class Document<T = unknown> {
|
|
|
22
23
|
comment: string | null;
|
|
23
24
|
/** The document contents. */
|
|
24
25
|
contents: T | null;
|
|
25
|
-
directives
|
|
26
|
+
directives?: Directives;
|
|
26
27
|
/** Errors encountered during parsing. */
|
|
27
28
|
errors: YAMLError[];
|
|
28
|
-
options: Required<Omit<ParseOptions & DocumentOptions, '
|
|
29
|
+
options: Required<Omit<ParseOptions & DocumentOptions, '_directives' | 'lineCounter' | 'version'>>;
|
|
29
30
|
/**
|
|
30
31
|
* The `[start, value-end, node-end]` character offsets for the part of the
|
|
31
32
|
* source parsed into this document (undefined if not parsed). The `value-end`
|
|
@@ -43,6 +44,12 @@ export declare class Document<T = unknown> {
|
|
|
43
44
|
*/
|
|
44
45
|
constructor(value?: any, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions);
|
|
45
46
|
constructor(value: any, replacer: null | Replacer, options?: DocumentOptions & SchemaOptions & ParseOptions & CreateNodeOptions);
|
|
47
|
+
/**
|
|
48
|
+
* Create a deep copy of this Document and its contents.
|
|
49
|
+
*
|
|
50
|
+
* Custom Node values that inherit from `Object` still refer to their original instances.
|
|
51
|
+
*/
|
|
52
|
+
clone(): Document<T>;
|
|
46
53
|
/** Adds a value to the document. */
|
|
47
54
|
add(value: any): void;
|
|
48
55
|
/** Adds a value to the document. */
|
|
@@ -61,8 +68,8 @@ export declare class Document<T = unknown> {
|
|
|
61
68
|
* Convert any value into a `Node` using the current schema, recursively
|
|
62
69
|
* turning objects into collections.
|
|
63
70
|
*/
|
|
64
|
-
createNode(value:
|
|
65
|
-
createNode(value:
|
|
71
|
+
createNode<T = unknown>(value: T, options?: CreateNodeOptions): NodeType<T>;
|
|
72
|
+
createNode<T = unknown>(value: T, replacer: Replacer | CreateNodeOptions | null, options?: CreateNodeOptions): NodeType<T>;
|
|
66
73
|
/**
|
|
67
74
|
* Convert a key and a value into a `Pair` using the current schema,
|
|
68
75
|
* recursively wrapping all values as `Scalar` or `Collection` nodes.
|
|
@@ -72,12 +79,12 @@ export declare class Document<T = unknown> {
|
|
|
72
79
|
* Removes a value from the document.
|
|
73
80
|
* @returns `true` if the item was found and removed.
|
|
74
81
|
*/
|
|
75
|
-
delete(key:
|
|
82
|
+
delete(key: unknown): boolean;
|
|
76
83
|
/**
|
|
77
84
|
* Removes a value from the document.
|
|
78
85
|
* @returns `true` if the item was found and removed.
|
|
79
86
|
*/
|
|
80
|
-
deleteIn(path: Iterable<unknown>): boolean;
|
|
87
|
+
deleteIn(path: Iterable<unknown> | null): boolean;
|
|
81
88
|
/**
|
|
82
89
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
83
90
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
@@ -89,7 +96,7 @@ export declare class Document<T = unknown> {
|
|
|
89
96
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
90
97
|
* `true` (collections are always returned intact).
|
|
91
98
|
*/
|
|
92
|
-
getIn(path: Iterable<unknown
|
|
99
|
+
getIn(path: Iterable<unknown> | null, keepScalar?: boolean): unknown;
|
|
93
100
|
/**
|
|
94
101
|
* Checks if the document includes a value with the key `key`.
|
|
95
102
|
*/
|
|
@@ -97,7 +104,7 @@ export declare class Document<T = unknown> {
|
|
|
97
104
|
/**
|
|
98
105
|
* Checks if the document includes a value at `path`.
|
|
99
106
|
*/
|
|
100
|
-
hasIn(path: Iterable<unknown>): boolean;
|
|
107
|
+
hasIn(path: Iterable<unknown> | null): boolean;
|
|
101
108
|
/**
|
|
102
109
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
103
110
|
* boolean to add/remove the item from the set.
|
|
@@ -107,13 +114,15 @@ export declare class Document<T = unknown> {
|
|
|
107
114
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
108
115
|
* boolean to add/remove the item from the set.
|
|
109
116
|
*/
|
|
110
|
-
setIn(path: Iterable<unknown
|
|
117
|
+
setIn(path: Iterable<unknown> | null, value: unknown): void;
|
|
111
118
|
/**
|
|
112
119
|
* Change the YAML version and schema used by the document.
|
|
120
|
+
* A `null` version disables support for directives, explicit tags, anchors, and aliases.
|
|
121
|
+
* It also requires the `schema` option to be given as a `Schema` instance value.
|
|
113
122
|
*
|
|
114
|
-
* Overrides all previously set schema options
|
|
123
|
+
* Overrides all previously set schema options.
|
|
115
124
|
*/
|
|
116
|
-
setSchema(version: '1.1' | '1.2', options?: SchemaOptions): void;
|
|
125
|
+
setSchema(version: '1.1' | '1.2' | 'next' | null, options?: SchemaOptions): void;
|
|
117
126
|
/** A plain JavaScript representation of the document `contents`. */
|
|
118
127
|
toJS(opt?: ToJSOptions & {
|
|
119
128
|
[ignored: string]: unknown;
|
|
@@ -5,7 +5,6 @@ var Collection = require('../nodes/Collection.js');
|
|
|
5
5
|
var Node = require('../nodes/Node.js');
|
|
6
6
|
var Pair = require('../nodes/Pair.js');
|
|
7
7
|
var toJS = require('../nodes/toJS.js');
|
|
8
|
-
var options = require('../options.js');
|
|
9
8
|
var Schema = require('../schema/Schema.js');
|
|
10
9
|
var stringify = require('../stringify/stringify.js');
|
|
11
10
|
var stringifyDocument = require('../stringify/stringifyDocument.js');
|
|
@@ -15,7 +14,7 @@ var createNode = require('./createNode.js');
|
|
|
15
14
|
var directives = require('./directives.js');
|
|
16
15
|
|
|
17
16
|
class Document {
|
|
18
|
-
constructor(value, replacer, options
|
|
17
|
+
constructor(value, replacer, options) {
|
|
19
18
|
/** A comment before this Document */
|
|
20
19
|
this.commentBefore = null;
|
|
21
20
|
/** A comment immediately after this Document */
|
|
@@ -29,27 +28,59 @@ class Document {
|
|
|
29
28
|
if (typeof replacer === 'function' || Array.isArray(replacer)) {
|
|
30
29
|
_replacer = replacer;
|
|
31
30
|
}
|
|
32
|
-
else if (options
|
|
33
|
-
options
|
|
31
|
+
else if (options === undefined && replacer) {
|
|
32
|
+
options = replacer;
|
|
34
33
|
replacer = undefined;
|
|
35
34
|
}
|
|
36
|
-
const opt = Object.assign({
|
|
35
|
+
const opt = Object.assign({
|
|
36
|
+
intAsBigInt: false,
|
|
37
|
+
keepSourceTokens: false,
|
|
38
|
+
logLevel: 'warn',
|
|
39
|
+
prettyErrors: true,
|
|
40
|
+
strict: true,
|
|
41
|
+
uniqueKeys: true,
|
|
42
|
+
version: '1.2'
|
|
43
|
+
}, options);
|
|
37
44
|
this.options = opt;
|
|
38
45
|
let { version } = opt;
|
|
39
|
-
if (options
|
|
40
|
-
this.directives = options
|
|
46
|
+
if (options?._directives) {
|
|
47
|
+
this.directives = options._directives.atDocument();
|
|
41
48
|
if (this.directives.yaml.explicit)
|
|
42
49
|
version = this.directives.yaml.version;
|
|
43
50
|
}
|
|
44
51
|
else
|
|
45
52
|
this.directives = new directives.Directives({ version });
|
|
46
|
-
this.setSchema(version, options
|
|
53
|
+
this.setSchema(version, options);
|
|
47
54
|
if (value === undefined)
|
|
48
55
|
this.contents = null;
|
|
49
56
|
else {
|
|
50
|
-
this.contents = this.createNode(value, _replacer, options
|
|
57
|
+
this.contents = this.createNode(value, _replacer, options);
|
|
51
58
|
}
|
|
52
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Create a deep copy of this Document and its contents.
|
|
62
|
+
*
|
|
63
|
+
* Custom Node values that inherit from `Object` still refer to their original instances.
|
|
64
|
+
*/
|
|
65
|
+
clone() {
|
|
66
|
+
const copy = Object.create(Document.prototype, {
|
|
67
|
+
[Node.NODE_TYPE]: { value: Node.DOC }
|
|
68
|
+
});
|
|
69
|
+
copy.commentBefore = this.commentBefore;
|
|
70
|
+
copy.comment = this.comment;
|
|
71
|
+
copy.errors = this.errors.slice();
|
|
72
|
+
copy.warnings = this.warnings.slice();
|
|
73
|
+
copy.options = Object.assign({}, this.options);
|
|
74
|
+
if (this.directives)
|
|
75
|
+
copy.directives = this.directives.clone();
|
|
76
|
+
copy.schema = this.schema.clone();
|
|
77
|
+
copy.contents = Node.isNode(this.contents)
|
|
78
|
+
? this.contents.clone(copy.schema)
|
|
79
|
+
: this.contents;
|
|
80
|
+
if (this.range)
|
|
81
|
+
copy.range = this.range.slice();
|
|
82
|
+
return copy;
|
|
83
|
+
}
|
|
53
84
|
/** Adds a value to the document. */
|
|
54
85
|
add(value) {
|
|
55
86
|
if (assertCollection(this.contents))
|
|
@@ -73,6 +104,7 @@ class Document {
|
|
|
73
104
|
if (!node.anchor) {
|
|
74
105
|
const prev = anchors.anchorNames(this);
|
|
75
106
|
node.anchor =
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
76
108
|
!name || prev.has(name) ? anchors.findNewAnchor(name || 'a', prev) : name;
|
|
77
109
|
}
|
|
78
110
|
return new Alias.Alias(node.anchor);
|
|
@@ -94,10 +126,13 @@ class Document {
|
|
|
94
126
|
options = replacer;
|
|
95
127
|
replacer = undefined;
|
|
96
128
|
}
|
|
97
|
-
const { anchorPrefix, flow, keepUndefined, onTagObj, tag } = options
|
|
98
|
-
const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors(this,
|
|
129
|
+
const { aliasDuplicateObjects, anchorPrefix, flow, keepUndefined, onTagObj, tag } = options ?? {};
|
|
130
|
+
const { onAnchor, setAnchors, sourceObjects } = anchors.createNodeAnchors(this,
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
|
132
|
+
anchorPrefix || 'a');
|
|
99
133
|
const ctx = {
|
|
100
|
-
|
|
134
|
+
aliasDuplicateObjects: aliasDuplicateObjects ?? true,
|
|
135
|
+
keepUndefined: keepUndefined ?? false,
|
|
101
136
|
onAnchor,
|
|
102
137
|
onTagObj,
|
|
103
138
|
replacer: _replacer,
|
|
@@ -207,26 +242,48 @@ class Document {
|
|
|
207
242
|
}
|
|
208
243
|
/**
|
|
209
244
|
* Change the YAML version and schema used by the document.
|
|
245
|
+
* A `null` version disables support for directives, explicit tags, anchors, and aliases.
|
|
246
|
+
* It also requires the `schema` option to be given as a `Schema` instance value.
|
|
210
247
|
*
|
|
211
|
-
* Overrides all previously set schema options
|
|
248
|
+
* Overrides all previously set schema options.
|
|
212
249
|
*/
|
|
213
|
-
setSchema(version, options) {
|
|
214
|
-
|
|
215
|
-
|
|
250
|
+
setSchema(version, options = {}) {
|
|
251
|
+
if (typeof version === 'number')
|
|
252
|
+
version = String(version);
|
|
253
|
+
let opt;
|
|
254
|
+
switch (version) {
|
|
216
255
|
case '1.1':
|
|
217
|
-
this.directives
|
|
218
|
-
|
|
256
|
+
if (this.directives)
|
|
257
|
+
this.directives.yaml.version = '1.1';
|
|
258
|
+
else
|
|
259
|
+
this.directives = new directives.Directives({ version: '1.1' });
|
|
260
|
+
opt = { merge: true, resolveKnownTags: false, schema: 'yaml-1.1' };
|
|
219
261
|
break;
|
|
220
262
|
case '1.2':
|
|
221
|
-
|
|
222
|
-
|
|
263
|
+
case 'next':
|
|
264
|
+
if (this.directives)
|
|
265
|
+
this.directives.yaml.version = version;
|
|
266
|
+
else
|
|
267
|
+
this.directives = new directives.Directives({ version });
|
|
268
|
+
opt = { merge: false, resolveKnownTags: true, schema: 'core' };
|
|
269
|
+
break;
|
|
270
|
+
case null:
|
|
271
|
+
if (this.directives)
|
|
272
|
+
delete this.directives;
|
|
273
|
+
opt = null;
|
|
223
274
|
break;
|
|
224
275
|
default: {
|
|
225
276
|
const sv = JSON.stringify(version);
|
|
226
|
-
throw new Error(`Expected '1.1'
|
|
277
|
+
throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${sv}`);
|
|
227
278
|
}
|
|
228
279
|
}
|
|
229
|
-
|
|
280
|
+
// Not using `instanceof Schema` to allow for duck typing
|
|
281
|
+
if (options.schema instanceof Object)
|
|
282
|
+
this.schema = options.schema;
|
|
283
|
+
else if (opt)
|
|
284
|
+
this.schema = new Schema.Schema(Object.assign(opt, options));
|
|
285
|
+
else
|
|
286
|
+
throw new Error(`With a null YAML version, the { schema: Schema } option is required`);
|
|
230
287
|
}
|
|
231
288
|
// json & jsonArg are only used from toJSON()
|
|
232
289
|
toJS({ json, jsonArg, mapAsMap, maxAliasCount, onAnchor, reviver } = {}) {
|
|
@@ -239,7 +296,7 @@ class Document {
|
|
|
239
296
|
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100,
|
|
240
297
|
stringify: stringify.stringify
|
|
241
298
|
};
|
|
242
|
-
const res = toJS.toJS(this.contents, jsonArg
|
|
299
|
+
const res = toJS.toJS(this.contents, jsonArg ?? '', ctx);
|
|
243
300
|
if (typeof onAnchor === 'function')
|
|
244
301
|
for (const { count, res } of ctx.anchors.values())
|
|
245
302
|
onAnchor(res, count);
|
|
@@ -10,15 +10,15 @@ export declare function anchorNames(root: Document | Node): Set<string>;
|
|
|
10
10
|
/** Find a new anchor name with the given `prefix` and a one-indexed suffix. */
|
|
11
11
|
export declare function findNewAnchor(prefix: string, exclude: Set<string>): string;
|
|
12
12
|
export declare function createNodeAnchors(doc: Document, prefix: string): {
|
|
13
|
-
onAnchor(source: unknown)
|
|
13
|
+
onAnchor: (source: unknown) => string;
|
|
14
14
|
/**
|
|
15
15
|
* With circular references, the source node is only resolved after all
|
|
16
16
|
* of its child nodes are. This is why anchors are set only after all of
|
|
17
17
|
* the nodes have been created.
|
|
18
18
|
*/
|
|
19
|
-
setAnchors()
|
|
19
|
+
setAnchors: () => void;
|
|
20
20
|
sourceObjects: Map<unknown, {
|
|
21
21
|
anchor: string | null;
|
|
22
|
-
node: Node | null;
|
|
22
|
+
node: Node<unknown> | null;
|
|
23
23
|
}>;
|
|
24
24
|
};
|
|
@@ -39,7 +39,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
39
39
|
const sourceObjects = new Map();
|
|
40
40
|
let prevAnchors = null;
|
|
41
41
|
return {
|
|
42
|
-
onAnchor(source) {
|
|
42
|
+
onAnchor: (source) => {
|
|
43
43
|
aliasObjects.push(source);
|
|
44
44
|
if (!prevAnchors)
|
|
45
45
|
prevAnchors = anchorNames(doc);
|
|
@@ -52,7 +52,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
52
52
|
* of its child nodes are. This is why anchors are set only after all of
|
|
53
53
|
* the nodes have been created.
|
|
54
54
|
*/
|
|
55
|
-
setAnchors() {
|
|
55
|
+
setAnchors: () => {
|
|
56
56
|
for (const source of aliasObjects) {
|
|
57
57
|
const ref = sourceObjects.get(source);
|
|
58
58
|
if (typeof ref === 'object' &&
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type Reviver = (key: unknown, value: unknown) => unknown;
|
|
2
2
|
/**
|
|
3
3
|
* Applies the JSON.parse reviver algorithm as defined in the ECMA-262 spec,
|
|
4
4
|
* in section 24.5.1.1 "Runtime Semantics: InternalizeJSONProperty" of the
|
|
@@ -3,8 +3,9 @@ import type { Schema } from '../schema/Schema.js';
|
|
|
3
3
|
import type { CollectionTag, ScalarTag } from '../schema/types.js';
|
|
4
4
|
import type { Replacer } from './Document.js';
|
|
5
5
|
export interface CreateNodeContext {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
aliasDuplicateObjects: boolean;
|
|
7
|
+
keepUndefined: boolean;
|
|
8
|
+
onAnchor: (source: unknown) => string;
|
|
8
9
|
onTagObj?: (tagObj: ScalarTag | CollectionTag) => void;
|
|
9
10
|
sourceObjects: Map<unknown, {
|
|
10
11
|
anchor: string | null;
|
|
@@ -8,35 +8,36 @@ const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
|
8
8
|
function findTagObject(value, tagName, tags) {
|
|
9
9
|
if (tagName) {
|
|
10
10
|
const match = tags.filter(t => t.tag === tagName);
|
|
11
|
-
const tagObj = match.find(t => !t.format)
|
|
11
|
+
const tagObj = match.find(t => !t.format) ?? match[0];
|
|
12
12
|
if (!tagObj)
|
|
13
13
|
throw new Error(`Tag ${tagName} not found`);
|
|
14
14
|
return tagObj;
|
|
15
15
|
}
|
|
16
|
-
return tags.find(t => t.identify
|
|
16
|
+
return tags.find(t => t.identify?.(value) && !t.format);
|
|
17
17
|
}
|
|
18
18
|
function createNode(value, tagName, ctx) {
|
|
19
|
-
|
|
19
|
+
if (Node.isDocument(value))
|
|
20
|
+
value = value.contents;
|
|
20
21
|
if (Node.isNode(value))
|
|
21
22
|
return value;
|
|
22
23
|
if (Node.isPair(value)) {
|
|
23
|
-
const map =
|
|
24
|
+
const map = ctx.schema[Node.MAP].createNode?.(ctx.schema, null, ctx);
|
|
24
25
|
map.items.push(value);
|
|
25
26
|
return map;
|
|
26
27
|
}
|
|
27
28
|
if (value instanceof String ||
|
|
28
29
|
value instanceof Number ||
|
|
29
30
|
value instanceof Boolean ||
|
|
30
|
-
(typeof BigInt
|
|
31
|
+
(typeof BigInt !== 'undefined' && value instanceof BigInt) // not supported everywhere
|
|
31
32
|
) {
|
|
32
33
|
// https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
33
34
|
value = value.valueOf();
|
|
34
35
|
}
|
|
35
|
-
const { onAnchor, onTagObj, schema, sourceObjects } = ctx;
|
|
36
|
+
const { aliasDuplicateObjects, onAnchor, onTagObj, schema, sourceObjects } = ctx;
|
|
36
37
|
// Detect duplicate references to the same object & use Alias nodes for all
|
|
37
38
|
// after first. The `ref` wrapper allows for circular references to resolve.
|
|
38
39
|
let ref = undefined;
|
|
39
|
-
if (value && typeof value === 'object') {
|
|
40
|
+
if (aliasDuplicateObjects && value && typeof value === 'object') {
|
|
40
41
|
ref = sourceObjects.get(value);
|
|
41
42
|
if (ref) {
|
|
42
43
|
if (!ref.anchor)
|
|
@@ -48,12 +49,14 @@ function createNode(value, tagName, ctx) {
|
|
|
48
49
|
sourceObjects.set(value, ref);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
if (tagName
|
|
52
|
+
if (tagName?.startsWith('!!'))
|
|
52
53
|
tagName = defaultTagPrefix + tagName.slice(2);
|
|
53
54
|
let tagObj = findTagObject(value, tagName, schema.tags);
|
|
54
55
|
if (!tagObj) {
|
|
55
|
-
if (value && typeof value.toJSON === 'function')
|
|
56
|
+
if (value && typeof value.toJSON === 'function') {
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
56
58
|
value = value.toJSON();
|
|
59
|
+
}
|
|
57
60
|
if (!value || typeof value !== 'object') {
|
|
58
61
|
const node = new Scalar.Scalar(value);
|
|
59
62
|
if (ref)
|
|
@@ -71,7 +74,7 @@ function createNode(value, tagName, ctx) {
|
|
|
71
74
|
onTagObj(tagObj);
|
|
72
75
|
delete ctx.onTagObj;
|
|
73
76
|
}
|
|
74
|
-
const node =
|
|
77
|
+
const node = tagObj?.createNode
|
|
75
78
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
76
79
|
: new Scalar.Scalar(value);
|
|
77
80
|
if (tagName)
|
|
@@ -3,7 +3,7 @@ export declare class Directives {
|
|
|
3
3
|
static defaultYaml: Directives['yaml'];
|
|
4
4
|
static defaultTags: Directives['tags'];
|
|
5
5
|
yaml: {
|
|
6
|
-
version: '1.1' | '1.2';
|
|
6
|
+
version: '1.1' | '1.2' | 'next';
|
|
7
7
|
explicit?: boolean;
|
|
8
8
|
};
|
|
9
9
|
tags: Record<string, string>;
|
|
@@ -11,7 +11,9 @@ export declare class Directives {
|
|
|
11
11
|
* The directives-end/doc-start marker `---`. If `null`, a marker may still be
|
|
12
12
|
* included in the document's stringified representation.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
docStart: true | null;
|
|
15
|
+
/** The doc-end marker `...`. */
|
|
16
|
+
docEnd: boolean;
|
|
15
17
|
/**
|
|
16
18
|
* Used when parsing YAML 1.1, where:
|
|
17
19
|
* > If the document specifies no directives, it is parsed using the same
|
|
@@ -20,6 +22,7 @@ export declare class Directives {
|
|
|
20
22
|
*/
|
|
21
23
|
private atNextDocument?;
|
|
22
24
|
constructor(yaml?: Directives['yaml'], tags?: Directives['tags']);
|
|
25
|
+
clone(): Directives;
|
|
23
26
|
/**
|
|
24
27
|
* During parsing, get a Directives instance for the current document and
|
|
25
28
|
* update the stream state according to the current version's spec.
|
|
@@ -18,10 +18,17 @@ class Directives {
|
|
|
18
18
|
* The directives-end/doc-start marker `---`. If `null`, a marker may still be
|
|
19
19
|
* included in the document's stringified representation.
|
|
20
20
|
*/
|
|
21
|
-
this.
|
|
21
|
+
this.docStart = null;
|
|
22
|
+
/** The doc-end marker `...`. */
|
|
23
|
+
this.docEnd = false;
|
|
22
24
|
this.yaml = Object.assign({}, Directives.defaultYaml, yaml);
|
|
23
25
|
this.tags = Object.assign({}, Directives.defaultTags, tags);
|
|
24
26
|
}
|
|
27
|
+
clone() {
|
|
28
|
+
const copy = new Directives(this.yaml, this.tags);
|
|
29
|
+
copy.docStart = this.docStart;
|
|
30
|
+
return copy;
|
|
31
|
+
}
|
|
25
32
|
/**
|
|
26
33
|
* During parsing, get a Directives instance for the current document and
|
|
27
34
|
* update the stream state according to the current version's spec.
|
|
@@ -68,7 +75,7 @@ class Directives {
|
|
|
68
75
|
}
|
|
69
76
|
case '%YAML': {
|
|
70
77
|
this.yaml.explicit = true;
|
|
71
|
-
if (parts.length
|
|
78
|
+
if (parts.length !== 1) {
|
|
72
79
|
onError(0, '%YAML directive should contain exactly one part');
|
|
73
80
|
return false;
|
|
74
81
|
}
|
|
@@ -78,7 +85,8 @@ class Directives {
|
|
|
78
85
|
return true;
|
|
79
86
|
}
|
|
80
87
|
else {
|
|
81
|
-
|
|
88
|
+
const isValid = /^\d+\.\d+$/.test(version);
|
|
89
|
+
onError(6, `Unsupported YAML version ${version}`, isValid);
|
|
82
90
|
return false;
|
|
83
91
|
}
|
|
84
92
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LineCounter } from './parse/line-counter';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type ErrorCode = 'ALIAS_PROPS' | 'BAD_ALIAS' | 'BAD_DIRECTIVE' | 'BAD_DQ_ESCAPE' | 'BAD_INDENT' | 'BAD_PROP_ORDER' | 'BAD_SCALAR_START' | 'BLOCK_AS_IMPLICIT_KEY' | 'BLOCK_IN_FLOW' | 'DUPLICATE_KEY' | 'IMPOSSIBLE' | 'KEY_OVER_1024_CHARS' | 'MISSING_CHAR' | 'MULTILINE_IMPLICIT_KEY' | 'MULTIPLE_ANCHORS' | 'MULTIPLE_DOCS' | 'MULTIPLE_TAGS' | 'TAB_AS_INDENT' | 'TAG_RESOLVE_FAILED' | 'UNEXPECTED_TOKEN';
|
|
3
|
+
export type LinePos = {
|
|
4
4
|
line: number;
|
|
5
5
|
col: number;
|
|
6
6
|
};
|
|
@@ -49,7 +49,7 @@ const prettifyError = (src, lc) => (error) => {
|
|
|
49
49
|
let count = 1;
|
|
50
50
|
const end = error.linePos[1];
|
|
51
51
|
if (end && end.line === line && end.col > col) {
|
|
52
|
-
count = Math.min(end.col - col, 80 - ci);
|
|
52
|
+
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
53
53
|
}
|
|
54
54
|
const pointer = ' '.repeat(ci) + '^'.repeat(count);
|
|
55
55
|
error.message += `:\n\n${lineStr}\n${pointer}\n`;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export { Composer } from './compose/composer.js';
|
|
2
2
|
export { Document } from './doc/Document.js';
|
|
3
3
|
export { Schema } from './schema/Schema.js';
|
|
4
|
-
export { YAMLError, YAMLParseError, YAMLWarning } from './errors.js';
|
|
4
|
+
export { ErrorCode, YAMLError, YAMLParseError, YAMLWarning } from './errors.js';
|
|
5
5
|
export { Alias } from './nodes/Alias.js';
|
|
6
|
-
export { isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq, Node, ParsedNode } from './nodes/Node.js';
|
|
6
|
+
export { isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq, Node, ParsedNode, Range } from './nodes/Node.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';
|
|
10
10
|
export { YAMLSeq } from './nodes/YAMLSeq.js';
|
|
11
|
-
export { CreateNodeOptions,
|
|
11
|
+
export type { CreateNodeOptions, DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions, ToStringOptions } from './options.js';
|
|
12
12
|
export * as CST from './parse/cst.js';
|
|
13
13
|
export { Lexer } from './parse/lexer.js';
|
|
14
14
|
export { LineCounter } from './parse/line-counter.js';
|
|
@@ -16,4 +16,6 @@ export { Parser } from './parse/parser.js';
|
|
|
16
16
|
export { EmptyStream, parse, parseAllDocuments, parseDocument, stringify } from './public-api.js';
|
|
17
17
|
export type { TagId, Tags } from './schema/tags';
|
|
18
18
|
export type { CollectionTag, ScalarTag } from './schema/types';
|
|
19
|
-
export {
|
|
19
|
+
export type { YAMLOMap } from './schema/yaml-1.1/omap';
|
|
20
|
+
export type { YAMLSet } from './schema/yaml-1.1/set';
|
|
21
|
+
export { asyncVisitor, asyncVisitorFn, visit, visitAsync, visitor, visitorFn } from './visit.js';
|
|
@@ -10,7 +10,6 @@ var Pair = require('./nodes/Pair.js');
|
|
|
10
10
|
var Scalar = require('./nodes/Scalar.js');
|
|
11
11
|
var YAMLMap = require('./nodes/YAMLMap.js');
|
|
12
12
|
var YAMLSeq = require('./nodes/YAMLSeq.js');
|
|
13
|
-
var options = require('./options.js');
|
|
14
13
|
var cst = require('./parse/cst.js');
|
|
15
14
|
var lexer = require('./parse/lexer.js');
|
|
16
15
|
var lineCounter = require('./parse/line-counter.js');
|
|
@@ -39,7 +38,6 @@ exports.Pair = Pair.Pair;
|
|
|
39
38
|
exports.Scalar = Scalar.Scalar;
|
|
40
39
|
exports.YAMLMap = YAMLMap.YAMLMap;
|
|
41
40
|
exports.YAMLSeq = YAMLSeq.YAMLSeq;
|
|
42
|
-
exports.defaultOptions = options.defaultOptions;
|
|
43
41
|
exports.CST = cst;
|
|
44
42
|
exports.Lexer = lexer.Lexer;
|
|
45
43
|
exports.LineCounter = lineCounter.LineCounter;
|
|
@@ -49,3 +47,4 @@ exports.parseAllDocuments = publicApi.parseAllDocuments;
|
|
|
49
47
|
exports.parseDocument = publicApi.parseDocument;
|
|
50
48
|
exports.stringify = publicApi.stringify;
|
|
51
49
|
exports.visit = visit.visit;
|
|
50
|
+
exports.visitAsync = visit.visitAsync;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type LogLevelId = 'silent' | 'error' | 'warn' | 'debug';
|
|
2
2
|
export declare function debug(logLevel: LogLevelId, ...messages: any[]): void;
|
|
3
3
|
export declare function warn(logLevel: LogLevelId, warning: string | Error): void;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type { Document } from '../doc/Document';
|
|
1
|
+
import type { Document } from '../doc/Document.js';
|
|
2
|
+
import type { FlowScalar } from '../parse/cst.js';
|
|
2
3
|
import type { StringifyContext } from '../stringify/stringify.js';
|
|
3
4
|
import { NodeBase, Range } from './Node.js';
|
|
4
5
|
import type { Scalar } from './Scalar';
|
|
5
6
|
import type { ToJSContext } from './toJS.js';
|
|
6
|
-
import type { YAMLMap } from './YAMLMap';
|
|
7
|
-
import type { YAMLSeq } from './YAMLSeq';
|
|
7
|
+
import type { YAMLMap } from './YAMLMap.js';
|
|
8
|
+
import type { YAMLSeq } from './YAMLSeq.js';
|
|
8
9
|
export declare namespace Alias {
|
|
9
10
|
interface Parsed extends Alias {
|
|
10
11
|
range: Range;
|
|
12
|
+
srcToken?: FlowScalar & {
|
|
13
|
+
type: 'alias';
|
|
14
|
+
};
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
export declare class Alias extends NodeBase {
|
|
@@ -19,6 +23,6 @@ export declare class Alias extends NodeBase {
|
|
|
19
23
|
* instance of the `source` anchor before this node.
|
|
20
24
|
*/
|
|
21
25
|
resolve(doc: Document): Scalar | YAMLMap | YAMLSeq | undefined;
|
|
22
|
-
toJSON(_arg?: unknown, ctx?: ToJSContext):
|
|
26
|
+
toJSON(_arg?: unknown, ctx?: ToJSContext): {} | null;
|
|
23
27
|
toString(ctx?: StringifyContext, _onComment?: () => void, _onChompKeep?: () => void): string;
|
|
24
28
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Schema } from '../schema/Schema.js';
|
|
2
2
|
import { NodeBase, NODE_TYPE } from './Node.js';
|
|
3
|
-
export declare function collectionFromPath(schema: Schema, path: unknown[], value: unknown): import("./Node.js").Node
|
|
4
|
-
export declare const isEmptyPath: (path: Iterable<unknown> | null | undefined) =>
|
|
3
|
+
export declare function collectionFromPath(schema: Schema, path: unknown[], value: unknown): import("./Node.js").Node<unknown>;
|
|
4
|
+
export declare const isEmptyPath: (path: Iterable<unknown> | null | undefined) => path is null | undefined;
|
|
5
5
|
export declare abstract class Collection extends NodeBase {
|
|
6
6
|
static maxFlowStringSingleLineLength: number;
|
|
7
7
|
schema: Schema | undefined;
|
|
@@ -15,6 +15,12 @@ export declare abstract class Collection extends NodeBase {
|
|
|
15
15
|
*/
|
|
16
16
|
flow?: boolean;
|
|
17
17
|
constructor(type: symbol, schema?: Schema);
|
|
18
|
+
/**
|
|
19
|
+
* Create a copy of this collection.
|
|
20
|
+
*
|
|
21
|
+
* @param schema - If defined, overwrites the original's schema
|
|
22
|
+
*/
|
|
23
|
+
clone(schema?: Schema): Collection;
|
|
18
24
|
/** Adds a value to the collection. */
|
|
19
25
|
abstract add(value: unknown): void;
|
|
20
26
|
/**
|
|
@@ -47,21 +53,21 @@ export declare abstract class Collection extends NodeBase {
|
|
|
47
53
|
* Removes a value from the collection.
|
|
48
54
|
* @returns `true` if the item was found and removed.
|
|
49
55
|
*/
|
|
50
|
-
deleteIn(
|
|
56
|
+
deleteIn(path: Iterable<unknown>): boolean;
|
|
51
57
|
/**
|
|
52
58
|
* Returns item at `key`, or `undefined` if not found. By default unwraps
|
|
53
59
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
54
60
|
* `true` (collections are always returned intact).
|
|
55
61
|
*/
|
|
56
|
-
getIn(
|
|
62
|
+
getIn(path: Iterable<unknown>, keepScalar?: boolean): unknown;
|
|
57
63
|
hasAllNullValues(allowScalar?: boolean): boolean;
|
|
58
64
|
/**
|
|
59
65
|
* Checks if the collection includes a value with the key `key`.
|
|
60
66
|
*/
|
|
61
|
-
hasIn(
|
|
67
|
+
hasIn(path: Iterable<unknown>): boolean;
|
|
62
68
|
/**
|
|
63
69
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
64
70
|
* boolean to add/remove the item from the set.
|
|
65
71
|
*/
|
|
66
|
-
setIn(
|
|
72
|
+
setIn(path: Iterable<unknown>, value: unknown): void;
|
|
67
73
|
}
|