projen 0.71.67 → 0.71.69
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 +24 -6
- package/docs/api/API.md +2 -0
- package/lib/awscdk/auto-discover.js +5 -5
- package/lib/awscdk/awscdk-app-java.js +1 -1
- package/lib/awscdk/awscdk-app-py.js +1 -1
- package/lib/awscdk/awscdk-app-ts.js +1 -1
- package/lib/awscdk/awscdk-construct.js +2 -2
- package/lib/awscdk/awscdk-deps-java.js +1 -1
- package/lib/awscdk/awscdk-deps-js.js +1 -1
- package/lib/awscdk/awscdk-deps-py.js +1 -1
- package/lib/awscdk/awscdk-deps.js +1 -1
- package/lib/awscdk/cdk-config.js +1 -1
- package/lib/awscdk/cdk-tasks.js +1 -1
- package/lib/awscdk/integration-test.js +1 -1
- package/lib/awscdk/lambda-extension.js +1 -1
- package/lib/awscdk/lambda-function.js +2 -2
- package/lib/build/build-workflow.js +1 -1
- package/lib/cdk/auto-discover-base.js +2 -2
- package/lib/cdk/construct-lib.js +1 -1
- package/lib/cdk/integration-test-base.js +1 -1
- package/lib/cdk/jsii-docgen.js +1 -1
- package/lib/cdk/jsii-project.js +1 -1
- package/lib/cdk8s/auto-discover.js +2 -2
- package/lib/cdk8s/cdk8s-app-py.js +1 -1
- package/lib/cdk8s/cdk8s-app-ts.js +1 -1
- package/lib/cdk8s/cdk8s-construct.js +1 -1
- package/lib/cdk8s/cdk8s-deps-py.js +1 -1
- package/lib/cdk8s/cdk8s-deps.js +1 -1
- package/lib/cdk8s/integration-test.js +1 -1
- package/lib/cdktf/cdktf-construct.js +1 -1
- package/lib/circleci/circleci.js +1 -1
- package/lib/component.js +1 -1
- package/lib/dependencies.js +1 -1
- package/lib/dev-env.js +1 -1
- package/lib/docker-compose/docker-compose-service.js +1 -1
- package/lib/docker-compose/docker-compose.js +1 -1
- package/lib/file.js +1 -1
- package/lib/gitattributes.js +1 -1
- package/lib/github/actions-provider.js +1 -1
- package/lib/github/auto-approve.js +1 -1
- package/lib/github/auto-merge.js +1 -1
- package/lib/github/dependabot.js +1 -1
- package/lib/github/github-credentials.js +1 -1
- package/lib/github/github-project.js +1 -1
- package/lib/github/github.js +1 -1
- package/lib/github/mergify.js +1 -1
- package/lib/github/pr-template.js +1 -1
- package/lib/github/pull-request-lint.js +1 -1
- package/lib/github/stale.js +1 -1
- package/lib/github/task-workflow.js +1 -1
- package/lib/github/workflow-actions.js +1 -1
- package/lib/github/workflow-jobs.js +1 -1
- package/lib/github/workflows.js +1 -1
- package/lib/gitlab/configuration.js +1 -1
- package/lib/gitlab/gitlab-configuration.js +1 -1
- package/lib/gitlab/nested-configuration.js +1 -1
- package/lib/gitpod.js +1 -1
- package/lib/ignore-file.js +1 -1
- package/lib/ini.js +1 -1
- package/lib/java/java-project.js +1 -1
- package/lib/java/junit.js +1 -1
- package/lib/java/maven-compile.js +1 -1
- package/lib/java/maven-packaging.js +1 -1
- package/lib/java/maven-sample.js +1 -1
- package/lib/java/pom.js +1 -1
- package/lib/java/projenrc.js +1 -1
- package/lib/javascript/bundler.js +1 -1
- package/lib/javascript/eslint.js +1 -1
- package/lib/javascript/jest.js +4 -4
- package/lib/javascript/node-package.js +1 -1
- package/lib/javascript/node-project.js +1 -1
- package/lib/javascript/npm-config.js +1 -1
- package/lib/javascript/prettier.js +1 -1
- package/lib/javascript/projenrc.js +1 -1
- package/lib/javascript/typescript-config.js +2 -2
- package/lib/javascript/upgrade-dependencies.js +2 -2
- package/lib/json-patch.js +1 -1
- package/lib/json.js +1 -1
- package/lib/license.js +1 -1
- package/lib/logger.js +1 -1
- package/lib/makefile.js +1 -1
- package/lib/object-file.js +1 -1
- package/lib/project-build.js +1 -1
- package/lib/project.js +1 -1
- package/lib/projects.js +1 -1
- package/lib/projenrc-json.js +2 -2
- package/lib/projenrc.js +1 -1
- package/lib/python/pip.js +1 -1
- package/lib/python/poetry.js +2 -2
- package/lib/python/projenrc.js +1 -1
- package/lib/python/pytest-sample.js +1 -1
- package/lib/python/pytest.js +1 -1
- package/lib/python/python-project.js +1 -1
- package/lib/python/python-sample.js +1 -1
- package/lib/python/requirements-file.js +1 -1
- package/lib/python/setuppy.js +1 -1
- package/lib/python/setuptools.js +1 -1
- package/lib/python/venv.js +1 -1
- package/lib/readme.js +1 -1
- package/lib/release/publisher.js +1 -1
- package/lib/release/release-trigger.js +1 -1
- package/lib/release/release.js +1 -1
- package/lib/renovatebot.js +1 -1
- package/lib/run-task.js +1889 -0
- package/lib/sample-file.js +2 -2
- package/lib/semver.js +1 -1
- package/lib/source-code.js +1 -1
- package/lib/task-runtime.js +1 -1
- package/lib/task.js +1 -1
- package/lib/tasks.js +1 -1
- package/lib/testing.js +1 -1
- package/lib/textfile.js +1 -1
- package/lib/toml.js +1 -1
- package/lib/typescript/projenrc-ts.js +1 -1
- package/lib/typescript/projenrc.d.ts +8 -0
- package/lib/typescript/projenrc.js +14 -5
- package/lib/typescript/typescript-typedoc.js +1 -1
- package/lib/typescript/typescript.js +3 -3
- package/lib/version.js +1 -1
- package/lib/vscode/devcontainer.js +1 -1
- package/lib/vscode/extensions.js +1 -1
- package/lib/vscode/launch-config.js +1 -1
- package/lib/vscode/settings.js +1 -1
- package/lib/vscode/vscode.js +1 -1
- package/lib/web/next.js +3 -3
- package/lib/web/postcss.js +1 -1
- package/lib/web/react.js +4 -4
- package/lib/web/tailwind.js +1 -1
- package/lib/xmlfile.js +1 -1
- package/lib/yaml.js +1 -1
- 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 +8 -6
- package/package.json +3 -3
- package/node_modules/yaml/util.d.ts +0 -3
|
@@ -28,6 +28,7 @@ function composeDoc(options, directives, { offset, start, value, end }, onError)
|
|
|
28
28
|
!props.hasNewline)
|
|
29
29
|
onError(props.end, 'MISSING_CHAR', 'Block collection cannot start on same line with directives-end marker');
|
|
30
30
|
}
|
|
31
|
+
// @ts-expect-error If Contents is set, let's trust the user
|
|
31
32
|
doc.contents = value
|
|
32
33
|
? composeNode.composeNode(ctx, value, props, onError)
|
|
33
34
|
: composeNode.composeEmptyNode(ctx, props.end, start, null, props, onError);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
4
|
var Scalar = require('../nodes/Scalar.js');
|
|
5
5
|
var resolveBlockScalar = require('./resolve-block-scalar.js');
|
|
6
6
|
var resolveFlowScalar = require('./resolve-flow-scalar.js');
|
|
@@ -16,11 +16,11 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
16
16
|
? findScalarTagByName(ctx.schema, value, tagName, tagToken, onError)
|
|
17
17
|
: token.type === 'scalar'
|
|
18
18
|
? findScalarTagByTest(ctx, value, token, onError)
|
|
19
|
-
: ctx.schema[
|
|
19
|
+
: ctx.schema[identity.SCALAR];
|
|
20
20
|
let scalar;
|
|
21
21
|
try {
|
|
22
22
|
const res = tag.resolve(value, msg => onError(tagToken ?? token, 'TAG_RESOLVE_FAILED', msg), ctx.options);
|
|
23
|
-
scalar =
|
|
23
|
+
scalar = identity.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
24
24
|
}
|
|
25
25
|
catch (error) {
|
|
26
26
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -41,7 +41,7 @@ function composeScalar(ctx, token, tagToken, onError) {
|
|
|
41
41
|
}
|
|
42
42
|
function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
43
43
|
if (tagName === '!')
|
|
44
|
-
return schema[
|
|
44
|
+
return schema[identity.SCALAR]; // non-specific tag
|
|
45
45
|
const matchWithTest = [];
|
|
46
46
|
for (const tag of schema.tags) {
|
|
47
47
|
if (!tag.collection && tag.tag === tagName) {
|
|
@@ -62,13 +62,13 @@ function findScalarTagByName(schema, value, tagName, tagToken, onError) {
|
|
|
62
62
|
return kt;
|
|
63
63
|
}
|
|
64
64
|
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, tagName !== 'tag:yaml.org,2002:str');
|
|
65
|
-
return schema[
|
|
65
|
+
return schema[identity.SCALAR];
|
|
66
66
|
}
|
|
67
67
|
function findScalarTagByTest({ directives, schema }, value, token, onError) {
|
|
68
|
-
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[
|
|
68
|
+
const tag = schema.tags.find(tag => tag.default && tag.test?.test(value)) || schema[identity.SCALAR];
|
|
69
69
|
if (schema.compat) {
|
|
70
70
|
const compat = schema.compat.find(tag => tag.default && tag.test?.test(value)) ??
|
|
71
|
-
schema[
|
|
71
|
+
schema[identity.SCALAR];
|
|
72
72
|
if (tag.tag !== compat.tag) {
|
|
73
73
|
const ts = directives.tagString(tag.tag);
|
|
74
74
|
const cs = directives.tagString(compat.tag);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Directives } from '../doc/directives.js';
|
|
2
2
|
import { Document } from '../doc/Document.js';
|
|
3
3
|
import { ErrorCode, YAMLParseError, YAMLWarning } from '../errors.js';
|
|
4
|
-
import { Range } from '../nodes/Node.js';
|
|
4
|
+
import type { ParsedNode, Range } from '../nodes/Node.js';
|
|
5
5
|
import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js';
|
|
6
6
|
import type { Token } from '../parse/cst.js';
|
|
7
7
|
type ErrorSource = number | [number, number] | Range | {
|
|
@@ -20,7 +20,7 @@ export type ComposeErrorHandler = (source: ErrorSource, code: ErrorCode, message
|
|
|
20
20
|
* const docs = new Composer().compose(tokens)
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
export declare class Composer {
|
|
23
|
+
export declare class Composer<Contents extends ParsedNode = ParsedNode, Strict extends boolean = true> {
|
|
24
24
|
private directives;
|
|
25
25
|
private doc;
|
|
26
26
|
private options;
|
|
@@ -48,15 +48,15 @@ export declare class Composer {
|
|
|
48
48
|
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
|
|
49
49
|
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
50
50
|
*/
|
|
51
|
-
compose(tokens: Iterable<Token>, forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<
|
|
51
|
+
compose(tokens: Iterable<Token>, forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<Contents, Strict>, void, unknown>;
|
|
52
52
|
/** Advance the composer by one CST token. */
|
|
53
|
-
next(token: Token): Generator<Document.Parsed<
|
|
53
|
+
next(token: Token): Generator<Document.Parsed<Contents, Strict>, void, unknown>;
|
|
54
54
|
/**
|
|
55
55
|
* Call at end of input to yield any remaining document.
|
|
56
56
|
*
|
|
57
57
|
* @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
|
|
58
58
|
* @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
|
|
59
59
|
*/
|
|
60
|
-
end(forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<
|
|
60
|
+
end(forceDoc?: boolean, endOffset?: number): Generator<Document.Parsed<Contents, Strict>, void, unknown>;
|
|
61
61
|
}
|
|
62
62
|
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var directives = require('../doc/directives.js');
|
|
4
4
|
var Document = require('../doc/Document.js');
|
|
5
5
|
var errors = require('../errors.js');
|
|
6
|
-
var
|
|
6
|
+
var identity = require('../nodes/identity.js');
|
|
7
7
|
var composeDoc = require('./compose-doc.js');
|
|
8
8
|
var resolveEnd = require('./resolve-end.js');
|
|
9
9
|
|
|
@@ -83,9 +83,9 @@ class Composer {
|
|
|
83
83
|
else if (afterEmptyLine || doc.directives.docStart || !dc) {
|
|
84
84
|
doc.commentBefore = comment;
|
|
85
85
|
}
|
|
86
|
-
else if (
|
|
86
|
+
else if (identity.isCollection(dc) && !dc.flow && dc.items.length > 0) {
|
|
87
87
|
let it = dc.items[0];
|
|
88
|
-
if (
|
|
88
|
+
if (identity.isPair(it))
|
|
89
89
|
it = it.key;
|
|
90
90
|
const cb = it.commentBefore;
|
|
91
91
|
it.commentBefore = cb ? `${comment}\n${cb}` : comment;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ParsedNode } from '../nodes/Node.js';
|
|
2
2
|
import { YAMLMap } from '../nodes/YAMLMap.js';
|
|
3
3
|
import type { BlockMap } from '../parse/cst.js';
|
|
4
|
+
import { CollectionTag } from '../schema/types.js';
|
|
4
5
|
import type { ComposeContext, ComposeNode } from './compose-node.js';
|
|
5
6
|
import type { ComposeErrorHandler } from './composer.js';
|
|
6
|
-
export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler): YAMLMap.Parsed<ParsedNode, ParsedNode | null>;
|
|
7
|
+
export declare function resolveBlockMap({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bm: BlockMap, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLMap.Parsed<ParsedNode, ParsedNode | null>;
|
|
@@ -8,8 +8,9 @@ var utilFlowIndentCheck = require('./util-flow-indent-check.js');
|
|
|
8
8
|
var utilMapIncludes = require('./util-map-includes.js');
|
|
9
9
|
|
|
10
10
|
const startColMsg = 'All mapping items must start at the same column';
|
|
11
|
-
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError) {
|
|
12
|
-
const
|
|
11
|
+
function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) {
|
|
12
|
+
const NodeClass = tag?.nodeClass ?? YAMLMap.YAMLMap;
|
|
13
|
+
const map = new NodeClass(ctx.schema);
|
|
13
14
|
if (ctx.atRoot)
|
|
14
15
|
ctx.atRoot = false;
|
|
15
16
|
let offset = bm.offset;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
2
2
|
import type { BlockSequence } from '../parse/cst.js';
|
|
3
|
+
import { CollectionTag } from '../schema/types.js';
|
|
3
4
|
import type { ComposeContext, ComposeNode } from './compose-node.js';
|
|
4
5
|
import type { ComposeErrorHandler } from './composer.js';
|
|
5
|
-
export declare function resolveBlockSeq({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bs: BlockSequence, onError: ComposeErrorHandler): YAMLSeq.Parsed<import("../index.js").ParsedNode>;
|
|
6
|
+
export declare function resolveBlockSeq({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, bs: BlockSequence, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLSeq.Parsed<import("../index.js").ParsedNode>;
|
|
@@ -4,8 +4,9 @@ var YAMLSeq = require('../nodes/YAMLSeq.js');
|
|
|
4
4
|
var resolveProps = require('./resolve-props.js');
|
|
5
5
|
var utilFlowIndentCheck = require('./util-flow-indent-check.js');
|
|
6
6
|
|
|
7
|
-
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError) {
|
|
8
|
-
const
|
|
7
|
+
function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) {
|
|
8
|
+
const NodeClass = tag?.nodeClass ?? YAMLSeq.YAMLSeq;
|
|
9
|
+
const seq = new NodeClass(ctx.schema);
|
|
9
10
|
if (ctx.atRoot)
|
|
10
11
|
ctx.atRoot = false;
|
|
11
12
|
let offset = bs.offset;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { YAMLMap } from '../nodes/YAMLMap.js';
|
|
2
2
|
import { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
3
3
|
import type { FlowCollection } from '../parse/cst.js';
|
|
4
|
+
import { CollectionTag } from '../schema/types.js';
|
|
4
5
|
import type { ComposeContext, ComposeNode } from './compose-node.js';
|
|
5
6
|
import type { ComposeErrorHandler } from './composer.js';
|
|
6
|
-
export declare function resolveFlowCollection({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, fc: FlowCollection, onError: ComposeErrorHandler): YAMLMap.Parsed<import("../
|
|
7
|
+
export declare function resolveFlowCollection({ composeNode, composeEmptyNode }: ComposeNode, ctx: ComposeContext, fc: FlowCollection, onError: ComposeErrorHandler, tag?: CollectionTag): YAMLMap.Parsed<import("../index.js").ParsedNode, import("../index.js").ParsedNode | null> | YAMLSeq.Parsed<import("../index.js").ParsedNode>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
4
|
var Pair = require('../nodes/Pair.js');
|
|
5
5
|
var YAMLMap = require('../nodes/YAMLMap.js');
|
|
6
6
|
var YAMLSeq = require('../nodes/YAMLSeq.js');
|
|
@@ -11,12 +11,11 @@ var utilMapIncludes = require('./util-map-includes.js');
|
|
|
11
11
|
|
|
12
12
|
const blockMsg = 'Block collections are not allowed within flow collections';
|
|
13
13
|
const isBlock = (token) => token && (token.type === 'block-map' || token.type === 'block-seq');
|
|
14
|
-
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError) {
|
|
14
|
+
function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) {
|
|
15
15
|
const isMap = fc.start.source === '{';
|
|
16
16
|
const fcName = isMap ? 'flow map' : 'flow sequence';
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
: new YAMLSeq.YAMLSeq(ctx.schema);
|
|
17
|
+
const NodeClass = (tag?.nodeClass ?? (isMap ? YAMLMap.YAMLMap : YAMLSeq.YAMLSeq));
|
|
18
|
+
const coll = new NodeClass(ctx.schema);
|
|
20
19
|
coll.flow = true;
|
|
21
20
|
const atRoot = ctx.atRoot;
|
|
22
21
|
if (atRoot)
|
|
@@ -75,7 +74,7 @@ function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onErr
|
|
|
75
74
|
}
|
|
76
75
|
if (prevItemComment) {
|
|
77
76
|
let prev = coll.items[coll.items.length - 1];
|
|
78
|
-
if (
|
|
77
|
+
if (identity.isPair(prev))
|
|
79
78
|
prev = prev.value ?? prev.key;
|
|
80
79
|
if (prev.comment)
|
|
81
80
|
prev.comment += '\n' + prevItemComment;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParsedNode } from '../nodes/Node';
|
|
2
|
-
import { Pair } from '../nodes/Pair';
|
|
3
|
-
import { ComposeContext } from './compose-node';
|
|
1
|
+
import type { ParsedNode } from '../nodes/Node.js';
|
|
2
|
+
import type { Pair } from '../nodes/Pair.js';
|
|
3
|
+
import type { ComposeContext } from './compose-node.js';
|
|
4
4
|
export declare function mapIncludes(ctx: ComposeContext, items: Pair<ParsedNode>[], search: ParsedNode): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
4
|
|
|
5
5
|
function mapIncludes(ctx, items, search) {
|
|
6
6
|
const { uniqueKeys } = ctx.options;
|
|
@@ -9,8 +9,8 @@ function mapIncludes(ctx, items, search) {
|
|
|
9
9
|
const isEqual = typeof uniqueKeys === 'function'
|
|
10
10
|
? uniqueKeys
|
|
11
11
|
: (a, b) => a === b ||
|
|
12
|
-
(
|
|
13
|
-
|
|
12
|
+
(identity.isScalar(a) &&
|
|
13
|
+
identity.isScalar(b) &&
|
|
14
14
|
a.value === b.value &&
|
|
15
15
|
!(a.value === '<<' && ctx.schema.merge));
|
|
16
16
|
return items.some(pair => isEqual(pair.key, search));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { YAMLError, YAMLWarning } from '../errors.js';
|
|
2
2
|
import { Alias } from '../nodes/Alias.js';
|
|
3
|
-
import {
|
|
3
|
+
import { NODE_TYPE } from '../nodes/identity.js';
|
|
4
|
+
import type { Node, NodeType, ParsedNode, Range } from '../nodes/Node.js';
|
|
4
5
|
import { Pair } from '../nodes/Pair.js';
|
|
5
6
|
import type { Scalar } from '../nodes/Scalar.js';
|
|
6
7
|
import type { YAMLMap } from '../nodes/YAMLMap.js';
|
|
@@ -10,20 +11,21 @@ import { Schema } from '../schema/Schema.js';
|
|
|
10
11
|
import { Directives } from './directives.js';
|
|
11
12
|
export type Replacer = any[] | ((key: any, value: any) => unknown);
|
|
12
13
|
export declare namespace Document {
|
|
13
|
-
|
|
14
|
+
/** @ts-ignore The typing of directives fails in TS <= 4.2 */
|
|
15
|
+
interface Parsed<Contents extends ParsedNode = ParsedNode, Strict extends boolean = true> extends Document<Contents, Strict> {
|
|
14
16
|
directives: Directives;
|
|
15
17
|
range: Range;
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
|
-
export declare class Document<
|
|
20
|
+
export declare class Document<Contents extends Node = Node, Strict extends boolean = true> {
|
|
19
21
|
readonly [NODE_TYPE]: symbol;
|
|
20
22
|
/** A comment before this Document */
|
|
21
23
|
commentBefore: string | null;
|
|
22
24
|
/** A comment immediately after this Document */
|
|
23
25
|
comment: string | null;
|
|
24
26
|
/** The document contents. */
|
|
25
|
-
contents:
|
|
26
|
-
directives
|
|
27
|
+
contents: Strict extends true ? Contents | null : Contents;
|
|
28
|
+
directives: Strict extends true ? Directives | undefined : Directives;
|
|
27
29
|
/** Errors encountered during parsing. */
|
|
28
30
|
errors: YAMLError[];
|
|
29
31
|
options: Required<Omit<ParseOptions & DocumentOptions, '_directives' | 'lineCounter' | 'version'>>;
|
|
@@ -49,7 +51,7 @@ export declare class Document<T extends Node = Node> {
|
|
|
49
51
|
*
|
|
50
52
|
* Custom Node values that inherit from `Object` still refer to their original instances.
|
|
51
53
|
*/
|
|
52
|
-
clone(): Document<
|
|
54
|
+
clone(): Document<Contents, Strict>;
|
|
53
55
|
/** Adds a value to the document. */
|
|
54
56
|
add(value: any): void;
|
|
55
57
|
/** Adds a value to the document. */
|
|
@@ -63,7 +65,7 @@ export declare class Document<T extends Node = Node> {
|
|
|
63
65
|
* `name` will be used as a prefix for a new unique anchor.
|
|
64
66
|
* If `name` is undefined, the generated anchor will use 'a' as a prefix.
|
|
65
67
|
*/
|
|
66
|
-
createAlias(node: Scalar | YAMLMap | YAMLSeq, name?: string): Alias;
|
|
68
|
+
createAlias(node: Strict extends true ? Scalar | YAMLMap | YAMLSeq : Node, name?: string): Alias;
|
|
67
69
|
/**
|
|
68
70
|
* Convert any value into a `Node` using the current schema, recursively
|
|
69
71
|
* turning objects into collections.
|
|
@@ -90,13 +92,13 @@ export declare class Document<T extends Node = Node> {
|
|
|
90
92
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
91
93
|
* `true` (collections are always returned intact).
|
|
92
94
|
*/
|
|
93
|
-
get(key: unknown, keepScalar?: boolean): unknown;
|
|
95
|
+
get(key: unknown, keepScalar?: boolean): Strict extends true ? unknown : any;
|
|
94
96
|
/**
|
|
95
97
|
* Returns item at `path`, or `undefined` if not found. By default unwraps
|
|
96
98
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
97
99
|
* `true` (collections are always returned intact).
|
|
98
100
|
*/
|
|
99
|
-
getIn(path: Iterable<unknown> | null, keepScalar?: boolean): unknown;
|
|
101
|
+
getIn(path: Iterable<unknown> | null, keepScalar?: boolean): Strict extends true ? unknown : any;
|
|
100
102
|
/**
|
|
101
103
|
* Checks if the document includes a value with the key `key`.
|
|
102
104
|
*/
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var Alias = require('../nodes/Alias.js');
|
|
4
4
|
var Collection = require('../nodes/Collection.js');
|
|
5
|
-
var
|
|
5
|
+
var identity = require('../nodes/identity.js');
|
|
6
6
|
var Pair = require('../nodes/Pair.js');
|
|
7
7
|
var toJS = require('../nodes/toJS.js');
|
|
8
8
|
var Schema = require('../schema/Schema.js');
|
|
9
|
-
var stringify = require('../stringify/stringify.js');
|
|
10
9
|
var stringifyDocument = require('../stringify/stringifyDocument.js');
|
|
11
10
|
var anchors = require('./anchors.js');
|
|
12
11
|
var applyReviver = require('./applyReviver.js');
|
|
@@ -23,7 +22,7 @@ class Document {
|
|
|
23
22
|
this.errors = [];
|
|
24
23
|
/** Warnings encountered during parsing. */
|
|
25
24
|
this.warnings = [];
|
|
26
|
-
Object.defineProperty(this,
|
|
25
|
+
Object.defineProperty(this, identity.NODE_TYPE, { value: identity.DOC });
|
|
27
26
|
let _replacer = null;
|
|
28
27
|
if (typeof replacer === 'function' || Array.isArray(replacer)) {
|
|
29
28
|
_replacer = replacer;
|
|
@@ -51,11 +50,9 @@ class Document {
|
|
|
51
50
|
else
|
|
52
51
|
this.directives = new directives.Directives({ version });
|
|
53
52
|
this.setSchema(version, options);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.contents = this.createNode(value, _replacer, options);
|
|
58
|
-
}
|
|
53
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
54
|
+
this.contents =
|
|
55
|
+
value === undefined ? null : this.createNode(value, _replacer, options);
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
61
58
|
* Create a deep copy of this Document and its contents.
|
|
@@ -64,7 +61,7 @@ class Document {
|
|
|
64
61
|
*/
|
|
65
62
|
clone() {
|
|
66
63
|
const copy = Object.create(Document.prototype, {
|
|
67
|
-
[
|
|
64
|
+
[identity.NODE_TYPE]: { value: identity.DOC }
|
|
68
65
|
});
|
|
69
66
|
copy.commentBefore = this.commentBefore;
|
|
70
67
|
copy.comment = this.comment;
|
|
@@ -74,7 +71,8 @@ class Document {
|
|
|
74
71
|
if (this.directives)
|
|
75
72
|
copy.directives = this.directives.clone();
|
|
76
73
|
copy.schema = this.schema.clone();
|
|
77
|
-
|
|
74
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
75
|
+
copy.contents = identity.isNode(this.contents)
|
|
78
76
|
? this.contents.clone(copy.schema)
|
|
79
77
|
: this.contents;
|
|
80
78
|
if (this.range)
|
|
@@ -140,7 +138,7 @@ class Document {
|
|
|
140
138
|
sourceObjects
|
|
141
139
|
};
|
|
142
140
|
const node = createNode.createNode(value, tag, ctx);
|
|
143
|
-
if (flow &&
|
|
141
|
+
if (flow && identity.isCollection(node))
|
|
144
142
|
node.flow = true;
|
|
145
143
|
setAnchors();
|
|
146
144
|
return node;
|
|
@@ -169,6 +167,7 @@ class Document {
|
|
|
169
167
|
if (Collection.isEmptyPath(path)) {
|
|
170
168
|
if (this.contents == null)
|
|
171
169
|
return false;
|
|
170
|
+
// @ts-expect-error Presumed impossible if Strict extends false
|
|
172
171
|
this.contents = null;
|
|
173
172
|
return true;
|
|
174
173
|
}
|
|
@@ -182,7 +181,7 @@ class Document {
|
|
|
182
181
|
* `true` (collections are always returned intact).
|
|
183
182
|
*/
|
|
184
183
|
get(key, keepScalar) {
|
|
185
|
-
return
|
|
184
|
+
return identity.isCollection(this.contents)
|
|
186
185
|
? this.contents.get(key, keepScalar)
|
|
187
186
|
: undefined;
|
|
188
187
|
}
|
|
@@ -193,10 +192,10 @@ class Document {
|
|
|
193
192
|
*/
|
|
194
193
|
getIn(path, keepScalar) {
|
|
195
194
|
if (Collection.isEmptyPath(path))
|
|
196
|
-
return !keepScalar &&
|
|
195
|
+
return !keepScalar && identity.isScalar(this.contents)
|
|
197
196
|
? this.contents.value
|
|
198
197
|
: this.contents;
|
|
199
|
-
return
|
|
198
|
+
return identity.isCollection(this.contents)
|
|
200
199
|
? this.contents.getIn(path, keepScalar)
|
|
201
200
|
: undefined;
|
|
202
201
|
}
|
|
@@ -204,7 +203,7 @@ class Document {
|
|
|
204
203
|
* Checks if the document includes a value with the key `key`.
|
|
205
204
|
*/
|
|
206
205
|
has(key) {
|
|
207
|
-
return
|
|
206
|
+
return identity.isCollection(this.contents) ? this.contents.has(key) : false;
|
|
208
207
|
}
|
|
209
208
|
/**
|
|
210
209
|
* Checks if the document includes a value at `path`.
|
|
@@ -212,7 +211,7 @@ class Document {
|
|
|
212
211
|
hasIn(path) {
|
|
213
212
|
if (Collection.isEmptyPath(path))
|
|
214
213
|
return this.contents !== undefined;
|
|
215
|
-
return
|
|
214
|
+
return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
|
|
216
215
|
}
|
|
217
216
|
/**
|
|
218
217
|
* Sets a value in this document. For `!!set`, `value` needs to be a
|
|
@@ -220,6 +219,7 @@ class Document {
|
|
|
220
219
|
*/
|
|
221
220
|
set(key, value) {
|
|
222
221
|
if (this.contents == null) {
|
|
222
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
223
223
|
this.contents = Collection.collectionFromPath(this.schema, [key], value);
|
|
224
224
|
}
|
|
225
225
|
else if (assertCollection(this.contents)) {
|
|
@@ -231,9 +231,12 @@ class Document {
|
|
|
231
231
|
* boolean to add/remove the item from the set.
|
|
232
232
|
*/
|
|
233
233
|
setIn(path, value) {
|
|
234
|
-
if (Collection.isEmptyPath(path))
|
|
234
|
+
if (Collection.isEmptyPath(path)) {
|
|
235
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
235
236
|
this.contents = value;
|
|
237
|
+
}
|
|
236
238
|
else if (this.contents == null) {
|
|
239
|
+
// @ts-expect-error We can't really know that this matches Contents.
|
|
237
240
|
this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
|
|
238
241
|
}
|
|
239
242
|
else if (assertCollection(this.contents)) {
|
|
@@ -293,8 +296,7 @@ class Document {
|
|
|
293
296
|
keep: !json,
|
|
294
297
|
mapAsMap: mapAsMap === true,
|
|
295
298
|
mapKeyWarned: false,
|
|
296
|
-
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
297
|
-
stringify: stringify.stringify
|
|
299
|
+
maxAliasCount: typeof maxAliasCount === 'number' ? maxAliasCount : 100
|
|
298
300
|
};
|
|
299
301
|
const res = toJS.toJS(this.contents, jsonArg ?? '', ctx);
|
|
300
302
|
if (typeof onAnchor === 'function')
|
|
@@ -326,7 +328,7 @@ class Document {
|
|
|
326
328
|
}
|
|
327
329
|
}
|
|
328
330
|
function assertCollection(contents) {
|
|
329
|
-
if (
|
|
331
|
+
if (identity.isCollection(contents))
|
|
330
332
|
return true;
|
|
331
333
|
throw new Error('Expected a YAML collection as document contents');
|
|
332
334
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node } from '../nodes/Node.js';
|
|
1
|
+
import type { Node } from '../nodes/Node.js';
|
|
2
2
|
import type { Document } from './Document.js';
|
|
3
3
|
/**
|
|
4
4
|
* Verify that the input string is a valid anchor.
|
|
@@ -6,10 +6,10 @@ import type { Document } from './Document.js';
|
|
|
6
6
|
* Will throw on errors.
|
|
7
7
|
*/
|
|
8
8
|
export declare function anchorIsValid(anchor: string): true;
|
|
9
|
-
export declare function anchorNames(root: Document | Node): Set<string>;
|
|
9
|
+
export declare function anchorNames(root: Document<Node, boolean> | 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
|
-
export declare function createNodeAnchors(doc: Document, prefix: string): {
|
|
12
|
+
export declare function createNodeAnchors(doc: Document<Node, boolean>, prefix: string): {
|
|
13
13
|
onAnchor: (source: unknown) => string;
|
|
14
14
|
/**
|
|
15
15
|
* With circular references, the source node is only resolved after all
|
|
@@ -19,6 +19,6 @@ export declare function createNodeAnchors(doc: Document, prefix: string): {
|
|
|
19
19
|
setAnchors: () => void;
|
|
20
20
|
sourceObjects: Map<unknown, {
|
|
21
21
|
anchor: string | null;
|
|
22
|
-
node: Node
|
|
22
|
+
node: Node | null;
|
|
23
23
|
}>;
|
|
24
24
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
4
|
var visit = require('../visit.js');
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -57,7 +57,7 @@ function createNodeAnchors(doc, prefix) {
|
|
|
57
57
|
const ref = sourceObjects.get(source);
|
|
58
58
|
if (typeof ref === 'object' &&
|
|
59
59
|
ref.anchor &&
|
|
60
|
-
(
|
|
60
|
+
(identity.isScalar(ref.node) || identity.isCollection(ref.node))) {
|
|
61
61
|
ref.node.anchor = ref.anchor;
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Alias = require('../nodes/Alias.js');
|
|
4
|
-
var
|
|
4
|
+
var identity = require('../nodes/identity.js');
|
|
5
5
|
var Scalar = require('../nodes/Scalar.js');
|
|
6
6
|
|
|
7
7
|
const defaultTagPrefix = 'tag:yaml.org,2002:';
|
|
@@ -16,12 +16,12 @@ function findTagObject(value, tagName, tags) {
|
|
|
16
16
|
return tags.find(t => t.identify?.(value) && !t.format);
|
|
17
17
|
}
|
|
18
18
|
function createNode(value, tagName, ctx) {
|
|
19
|
-
if (
|
|
19
|
+
if (identity.isDocument(value))
|
|
20
20
|
value = value.contents;
|
|
21
|
-
if (
|
|
21
|
+
if (identity.isNode(value))
|
|
22
22
|
return value;
|
|
23
|
-
if (
|
|
24
|
-
const map = ctx.schema[
|
|
23
|
+
if (identity.isPair(value)) {
|
|
24
|
+
const map = ctx.schema[identity.MAP].createNode?.(ctx.schema, null, ctx);
|
|
25
25
|
map.items.push(value);
|
|
26
26
|
return map;
|
|
27
27
|
}
|
|
@@ -65,10 +65,10 @@ function createNode(value, tagName, ctx) {
|
|
|
65
65
|
}
|
|
66
66
|
tagObj =
|
|
67
67
|
value instanceof Map
|
|
68
|
-
? schema[
|
|
68
|
+
? schema[identity.MAP]
|
|
69
69
|
: Symbol.iterator in Object(value)
|
|
70
|
-
? schema[
|
|
71
|
-
: schema[
|
|
70
|
+
? schema[identity.SEQ]
|
|
71
|
+
: schema[identity.MAP];
|
|
72
72
|
}
|
|
73
73
|
if (onTagObj) {
|
|
74
74
|
onTagObj(tagObj);
|
|
@@ -76,9 +76,13 @@ function createNode(value, tagName, ctx) {
|
|
|
76
76
|
}
|
|
77
77
|
const node = tagObj?.createNode
|
|
78
78
|
? tagObj.createNode(ctx.schema, value, ctx)
|
|
79
|
-
:
|
|
79
|
+
: typeof tagObj?.nodeClass?.from === 'function'
|
|
80
|
+
? tagObj.nodeClass.from(ctx.schema, value, ctx)
|
|
81
|
+
: new Scalar.Scalar(value);
|
|
80
82
|
if (tagName)
|
|
81
83
|
node.tag = tagName;
|
|
84
|
+
else if (!tagObj.default)
|
|
85
|
+
node.tag = tagObj.tag;
|
|
82
86
|
if (ref)
|
|
83
87
|
ref.node = node;
|
|
84
88
|
return node;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
4
|
var visit = require('../visit.js');
|
|
5
5
|
|
|
6
6
|
const escapeChars = {
|
|
@@ -146,10 +146,10 @@ class Directives {
|
|
|
146
146
|
: [];
|
|
147
147
|
const tagEntries = Object.entries(this.tags);
|
|
148
148
|
let tagNames;
|
|
149
|
-
if (doc && tagEntries.length > 0 &&
|
|
149
|
+
if (doc && tagEntries.length > 0 && identity.isNode(doc.contents)) {
|
|
150
150
|
const tags = {};
|
|
151
151
|
visit.visit(doc.contents, (_key, node) => {
|
|
152
|
-
if (
|
|
152
|
+
if (identity.isNode(node) && node.tag)
|
|
153
153
|
tags[node.tag] = true;
|
|
154
154
|
});
|
|
155
155
|
tagNames = Object.keys(tags);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LineCounter } from './parse/line-counter';
|
|
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';
|
|
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' | 'BAD_COLLECTION_TYPE';
|
|
3
3
|
export type LinePos = {
|
|
4
4
|
line: number;
|
|
5
5
|
col: number;
|
|
@@ -3,7 +3,8 @@ export { Document } from './doc/Document.js';
|
|
|
3
3
|
export { Schema } from './schema/Schema.js';
|
|
4
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
|
|
6
|
+
export { isAlias, isCollection, isDocument, isMap, isNode, isPair, isScalar, isSeq } from './nodes/identity.js';
|
|
7
|
+
export { Node, ParsedNode, Range } from './nodes/Node.js';
|
|
7
8
|
export { Pair } from './nodes/Pair.js';
|
|
8
9
|
export { Scalar } from './nodes/Scalar.js';
|
|
9
10
|
export { YAMLMap } from './nodes/YAMLMap.js';
|
|
@@ -5,7 +5,7 @@ var Document = require('./doc/Document.js');
|
|
|
5
5
|
var Schema = require('./schema/Schema.js');
|
|
6
6
|
var errors = require('./errors.js');
|
|
7
7
|
var Alias = require('./nodes/Alias.js');
|
|
8
|
-
var
|
|
8
|
+
var identity = require('./nodes/identity.js');
|
|
9
9
|
var Pair = require('./nodes/Pair.js');
|
|
10
10
|
var Scalar = require('./nodes/Scalar.js');
|
|
11
11
|
var YAMLMap = require('./nodes/YAMLMap.js');
|
|
@@ -26,14 +26,14 @@ exports.YAMLError = errors.YAMLError;
|
|
|
26
26
|
exports.YAMLParseError = errors.YAMLParseError;
|
|
27
27
|
exports.YAMLWarning = errors.YAMLWarning;
|
|
28
28
|
exports.Alias = Alias.Alias;
|
|
29
|
-
exports.isAlias =
|
|
30
|
-
exports.isCollection =
|
|
31
|
-
exports.isDocument =
|
|
32
|
-
exports.isMap =
|
|
33
|
-
exports.isNode =
|
|
34
|
-
exports.isPair =
|
|
35
|
-
exports.isScalar =
|
|
36
|
-
exports.isSeq =
|
|
29
|
+
exports.isAlias = identity.isAlias;
|
|
30
|
+
exports.isCollection = identity.isCollection;
|
|
31
|
+
exports.isDocument = identity.isDocument;
|
|
32
|
+
exports.isMap = identity.isMap;
|
|
33
|
+
exports.isNode = identity.isNode;
|
|
34
|
+
exports.isPair = identity.isPair;
|
|
35
|
+
exports.isScalar = identity.isScalar;
|
|
36
|
+
exports.isSeq = identity.isSeq;
|
|
37
37
|
exports.Pair = Pair.Pair;
|
|
38
38
|
exports.Scalar = Scalar.Scalar;
|
|
39
39
|
exports.YAMLMap = YAMLMap.YAMLMap;
|