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
|
@@ -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],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isScalar, isPair } from '../../nodes/identity.js';
|
|
2
2
|
import { toJS } from '../../nodes/toJS.js';
|
|
3
|
-
import { isScalar, isPair } from '../../nodes/Node.js';
|
|
4
3
|
import { YAMLMap } from '../../nodes/YAMLMap.js';
|
|
4
|
+
import { YAMLSeq } from '../../nodes/YAMLSeq.js';
|
|
5
5
|
import { resolvePairs, createPairs } from './pairs.js';
|
|
6
6
|
|
|
7
7
|
class YAMLOMap extends YAMLSeq {
|
|
@@ -39,6 +39,12 @@ class YAMLOMap extends YAMLSeq {
|
|
|
39
39
|
}
|
|
40
40
|
return map;
|
|
41
41
|
}
|
|
42
|
+
static from(schema, iterable, ctx) {
|
|
43
|
+
const pairs = createPairs(schema, iterable, ctx);
|
|
44
|
+
const omap = new this();
|
|
45
|
+
omap.items = pairs.items;
|
|
46
|
+
return omap;
|
|
47
|
+
}
|
|
42
48
|
}
|
|
43
49
|
YAMLOMap.tag = 'tag:yaml.org,2002:omap';
|
|
44
50
|
const omap = {
|
|
@@ -62,12 +68,7 @@ const omap = {
|
|
|
62
68
|
}
|
|
63
69
|
return Object.assign(new YAMLOMap(), pairs);
|
|
64
70
|
},
|
|
65
|
-
createNode(schema, iterable, ctx)
|
|
66
|
-
const pairs = createPairs(schema, iterable, ctx);
|
|
67
|
-
const omap = new YAMLOMap();
|
|
68
|
-
omap.items = pairs.items;
|
|
69
|
-
return omap;
|
|
70
|
-
}
|
|
71
|
+
createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx)
|
|
71
72
|
};
|
|
72
73
|
|
|
73
74
|
export { YAMLOMap, omap };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSeq, isPair, isMap } from '../../nodes/
|
|
1
|
+
import { isSeq, isPair, isMap } from '../../nodes/identity.js';
|
|
2
2
|
import { Pair, createPair } from '../../nodes/Pair.js';
|
|
3
3
|
import { Scalar } from '../../nodes/Scalar.js';
|
|
4
4
|
import { YAMLSeq } from '../../nodes/YAMLSeq.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isMap, isPair, isScalar } from '../../nodes/
|
|
2
|
-
import {
|
|
1
|
+
import { isMap, isPair, isScalar } from '../../nodes/identity.js';
|
|
2
|
+
import { Pair, createPair } from '../../nodes/Pair.js';
|
|
3
3
|
import { YAMLMap, findPair } from '../../nodes/YAMLMap.js';
|
|
4
4
|
|
|
5
5
|
class YAMLSet extends YAMLMap {
|
|
@@ -57,6 +57,17 @@ class YAMLSet extends YAMLMap {
|
|
|
57
57
|
else
|
|
58
58
|
throw new Error('Set items must all have null values');
|
|
59
59
|
}
|
|
60
|
+
static from(schema, iterable, ctx) {
|
|
61
|
+
const { replacer } = ctx;
|
|
62
|
+
const set = new this(schema);
|
|
63
|
+
if (iterable && Symbol.iterator in Object(iterable))
|
|
64
|
+
for (let value of iterable) {
|
|
65
|
+
if (typeof replacer === 'function')
|
|
66
|
+
value = replacer.call(iterable, value, value);
|
|
67
|
+
set.items.push(createPair(value, null, ctx));
|
|
68
|
+
}
|
|
69
|
+
return set;
|
|
70
|
+
}
|
|
60
71
|
}
|
|
61
72
|
YAMLSet.tag = 'tag:yaml.org,2002:set';
|
|
62
73
|
const set = {
|
|
@@ -65,6 +76,7 @@ const set = {
|
|
|
65
76
|
nodeClass: YAMLSet,
|
|
66
77
|
default: false,
|
|
67
78
|
tag: 'tag:yaml.org,2002:set',
|
|
79
|
+
createNode: (schema, iterable, ctx) => YAMLSet.from(schema, iterable, ctx),
|
|
68
80
|
resolve(map, onError) {
|
|
69
81
|
if (isMap(map)) {
|
|
70
82
|
if (map.hasAllNullValues(true))
|
|
@@ -75,17 +87,6 @@ const set = {
|
|
|
75
87
|
else
|
|
76
88
|
onError('Expected a mapping for this tag');
|
|
77
89
|
return map;
|
|
78
|
-
},
|
|
79
|
-
createNode(schema, iterable, ctx) {
|
|
80
|
-
const { replacer } = ctx;
|
|
81
|
-
const set = new YAMLSet(schema);
|
|
82
|
-
if (iterable && Symbol.iterator in Object(iterable))
|
|
83
|
-
for (let value of iterable) {
|
|
84
|
-
if (typeof replacer === 'function')
|
|
85
|
-
value = replacer.call(iterable, value, value);
|
|
86
|
-
set.items.push(createPair(value, null, ctx));
|
|
87
|
-
}
|
|
88
|
-
return set;
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
92
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { anchorIsValid } from '../doc/anchors.js';
|
|
2
|
-
import { isPair, isAlias, isNode, isScalar, isCollection } from '../nodes/
|
|
2
|
+
import { isPair, isAlias, isNode, isScalar, isCollection } from '../nodes/identity.js';
|
|
3
3
|
import { stringifyComment } from './stringifyComment.js';
|
|
4
4
|
import { stringifyString } from './stringifyString.js';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Collection } from '../nodes/Collection.js';
|
|
2
|
-
import { isNode, isPair } from '../nodes/
|
|
2
|
+
import { isNode, isPair } from '../nodes/identity.js';
|
|
3
3
|
import { stringify } from './stringify.js';
|
|
4
4
|
import { lineComment, indentComment } from './stringifyComment.js';
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isCollection, isNode, isScalar, isSeq } from '../nodes/
|
|
1
|
+
import { isCollection, isNode, isScalar, isSeq } from '../nodes/identity.js';
|
|
2
2
|
import { Scalar } from '../nodes/Scalar.js';
|
|
3
3
|
import { stringify } from './stringify.js';
|
|
4
4
|
import { lineComment, indentComment } from './stringifyComment.js';
|
|
@@ -146,6 +146,15 @@ function quotedString(value, ctx) {
|
|
|
146
146
|
}
|
|
147
147
|
return qs(value, ctx);
|
|
148
148
|
}
|
|
149
|
+
// The negative lookbehind avoids a polynomial search,
|
|
150
|
+
// but isn't supported yet on Safari: https://caniuse.com/js-regexp-lookbehind
|
|
151
|
+
let blockEndNewlines;
|
|
152
|
+
try {
|
|
153
|
+
blockEndNewlines = new RegExp('(^|(?<!\n))\n+(?!\n|$)', 'g');
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
blockEndNewlines = /\n+(?!\n|$)/g;
|
|
157
|
+
}
|
|
149
158
|
function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
150
159
|
const { blockQuote, commentString, lineWidth } = ctx.options;
|
|
151
160
|
// 1. Block can't end in whitespace unless the last line is non-empty.
|
|
@@ -189,7 +198,7 @@ function blockString({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
|
189
198
|
value = value.slice(0, -end.length);
|
|
190
199
|
if (end[end.length - 1] === '\n')
|
|
191
200
|
end = end.slice(0, -1);
|
|
192
|
-
end = end.replace(
|
|
201
|
+
end = end.replace(blockEndNewlines, `$&${indent}`);
|
|
193
202
|
}
|
|
194
203
|
// determine indent indicator from whitespace at value start
|
|
195
204
|
let startWithSpace = false;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
export { createNode } from './doc/createNode.js';
|
|
1
2
|
export { debug, warn } from './log.js';
|
|
3
|
+
export { createPair } from './nodes/Pair.js';
|
|
2
4
|
export { findPair } from './nodes/YAMLMap.js';
|
|
3
5
|
export { toJS } from './nodes/toJS.js';
|
|
4
6
|
export { map as mapTag } from './schema/common/map.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isDocument, isNode, isPair, isCollection, isMap, isSeq, isScalar, isAlias } from './nodes/
|
|
1
|
+
import { isDocument, isNode, isPair, isCollection, isMap, isSeq, isScalar, isAlias } from './nodes/identity.js';
|
|
2
2
|
|
|
3
3
|
const BREAK = Symbol('break visit');
|
|
4
4
|
const SKIP = Symbol('skip children');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParsedNode } from '../nodes/Node.js';
|
|
1
|
+
import type { ParsedNode } from '../nodes/Node.js';
|
|
2
2
|
import type { BlockMap, BlockSequence, FlowCollection, SourceToken } from '../parse/cst.js';
|
|
3
3
|
import type { ComposeContext, ComposeNode } from './compose-node.js';
|
|
4
4
|
import type { ComposeErrorHandler } from './composer.js';
|
|
@@ -1,40 +1,52 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var identity = require('../nodes/identity.js');
|
|
4
4
|
var Scalar = require('../nodes/Scalar.js');
|
|
5
|
+
var YAMLMap = require('../nodes/YAMLMap.js');
|
|
6
|
+
var YAMLSeq = require('../nodes/YAMLSeq.js');
|
|
5
7
|
var resolveBlockMap = require('./resolve-block-map.js');
|
|
6
8
|
var resolveBlockSeq = require('./resolve-block-seq.js');
|
|
7
9
|
var resolveFlowCollection = require('./resolve-flow-collection.js');
|
|
8
10
|
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
case 'block-seq': {
|
|
17
|
-
coll = resolveBlockSeq.resolveBlockSeq(CN, ctx, token, onError);
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
case 'flow-collection': {
|
|
21
|
-
coll = resolveFlowCollection.resolveFlowCollection(CN, ctx, token, onError);
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
if (!tagToken)
|
|
26
|
-
return coll;
|
|
27
|
-
const tagName = ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
|
|
28
|
-
if (!tagName)
|
|
29
|
-
return coll;
|
|
30
|
-
// Cast needed due to: https://github.com/Microsoft/TypeScript/issues/3841
|
|
11
|
+
function resolveCollection(CN, ctx, token, onError, tagName, tag) {
|
|
12
|
+
const coll = token.type === 'block-map'
|
|
13
|
+
? resolveBlockMap.resolveBlockMap(CN, ctx, token, onError, tag)
|
|
14
|
+
: token.type === 'block-seq'
|
|
15
|
+
? resolveBlockSeq.resolveBlockSeq(CN, ctx, token, onError, tag)
|
|
16
|
+
: resolveFlowCollection.resolveFlowCollection(CN, ctx, token, onError, tag);
|
|
31
17
|
const Coll = coll.constructor;
|
|
18
|
+
// If we got a tagName matching the class, or the tag name is '!',
|
|
19
|
+
// then use the tagName from the node class used to create it.
|
|
32
20
|
if (tagName === '!' || tagName === Coll.tagName) {
|
|
33
21
|
coll.tag = Coll.tagName;
|
|
34
22
|
return coll;
|
|
35
23
|
}
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
if (tagName)
|
|
25
|
+
coll.tag = tagName;
|
|
26
|
+
return coll;
|
|
27
|
+
}
|
|
28
|
+
function composeCollection(CN, ctx, token, tagToken, onError) {
|
|
29
|
+
const tagName = !tagToken
|
|
30
|
+
? null
|
|
31
|
+
: ctx.directives.tagName(tagToken.source, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg));
|
|
32
|
+
const expType = token.type === 'block-map'
|
|
33
|
+
? 'map'
|
|
34
|
+
: token.type === 'block-seq'
|
|
35
|
+
? 'seq'
|
|
36
|
+
: token.start.source === '{'
|
|
37
|
+
? 'map'
|
|
38
|
+
: 'seq';
|
|
39
|
+
// shortcut: check if it's a generic YAMLMap or YAMLSeq
|
|
40
|
+
// before jumping into the custom tag logic.
|
|
41
|
+
if (!tagToken ||
|
|
42
|
+
!tagName ||
|
|
43
|
+
tagName === '!' ||
|
|
44
|
+
(tagName === YAMLMap.YAMLMap.tagName && expType === 'map') ||
|
|
45
|
+
(tagName === YAMLSeq.YAMLSeq.tagName && expType === 'seq') ||
|
|
46
|
+
!expType) {
|
|
47
|
+
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
48
|
+
}
|
|
49
|
+
let tag = ctx.schema.tags.find(t => t.tag === tagName && t.collection === expType);
|
|
38
50
|
if (!tag) {
|
|
39
51
|
const kt = ctx.schema.knownTags[tagName];
|
|
40
52
|
if (kt && kt.collection === expType) {
|
|
@@ -42,13 +54,18 @@ function composeCollection(CN, ctx, token, tagToken, onError) {
|
|
|
42
54
|
tag = kt;
|
|
43
55
|
}
|
|
44
56
|
else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
if (kt?.collection) {
|
|
58
|
+
onError(tagToken, 'BAD_COLLECTION_TYPE', `${kt.tag} used for ${expType} collection, but expects ${kt.collection}`, true);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
onError(tagToken, 'TAG_RESOLVE_FAILED', `Unresolved tag: ${tagName}`, true);
|
|
62
|
+
}
|
|
63
|
+
return resolveCollection(CN, ctx, token, onError, tagName);
|
|
48
64
|
}
|
|
49
65
|
}
|
|
50
|
-
const
|
|
51
|
-
const
|
|
66
|
+
const coll = resolveCollection(CN, ctx, token, onError, tagName, tag);
|
|
67
|
+
const res = tag.resolve?.(coll, msg => onError(tagToken, 'TAG_RESOLVE_FAILED', msg), ctx.options) ?? coll;
|
|
68
|
+
const node = identity.isNode(res)
|
|
52
69
|
? res
|
|
53
70
|
: new Scalar.Scalar(res);
|
|
54
71
|
node.range = coll.range;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Directives } from '../doc/directives.js';
|
|
2
2
|
import { Document } from '../doc/Document.js';
|
|
3
|
+
import type { ParsedNode } from '../nodes/Node.js';
|
|
3
4
|
import type { DocumentOptions, ParseOptions, SchemaOptions } from '../options.js';
|
|
4
5
|
import type * as CST from '../parse/cst.js';
|
|
5
6
|
import type { ComposeErrorHandler } from './composer.js';
|
|
6
|
-
export declare function composeDoc(options: ParseOptions & DocumentOptions & SchemaOptions, directives: Directives, { offset, start, value, end }: CST.Document, onError: ComposeErrorHandler): Document.Parsed<
|
|
7
|
+
export declare function composeDoc<Contents extends ParsedNode = ParsedNode, Strict extends boolean = true>(options: ParseOptions & DocumentOptions & SchemaOptions, directives: Directives, { offset, start, value, end }: CST.Document, onError: ComposeErrorHandler): Document.Parsed<Contents, Strict>;
|