step-node-agent 3.25.4 → 3.26.0
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/AgentConf.yaml +13 -0
- package/api/controllers/controller.js +4 -0
- package/api/routes/routes.js +1 -0
- package/node_modules/aws4/aws4.js +1 -1
- package/node_modules/aws4/package.json +2 -2
- package/node_modules/body-parser/HISTORY.md +7 -0
- package/node_modules/body-parser/README.md +11 -0
- package/node_modules/body-parser/lib/types/urlencoded.js +30 -7
- package/node_modules/body-parser/package.json +2 -2
- package/node_modules/encodeurl/README.md +19 -38
- package/node_modules/encodeurl/index.js +1 -1
- package/node_modules/encodeurl/package.json +7 -7
- package/node_modules/express/History.md +27 -0
- package/node_modules/express/Readme.md +100 -6
- package/node_modules/express/lib/response.js +11 -10
- package/node_modules/express/package.json +11 -11
- package/node_modules/finalhandler/HISTORY.md +15 -0
- package/node_modules/finalhandler/README.md +2 -2
- package/node_modules/finalhandler/index.js +7 -2
- package/node_modules/finalhandler/package.json +8 -7
- package/node_modules/get-fqdn/LICENSE +21 -0
- package/node_modules/get-fqdn/README.md +83 -0
- package/node_modules/get-fqdn/index.js +17 -0
- package/node_modules/get-fqdn/package.json +73 -0
- package/node_modules/is-core-module/CHANGELOG.md +10 -0
- package/node_modules/is-core-module/core.json +2 -2
- package/node_modules/is-core-module/package.json +4 -4
- package/node_modules/is-core-module/test/index.js +17 -1
- package/node_modules/merge-descriptors/README.md +4 -3
- package/node_modules/merge-descriptors/index.js +3 -3
- package/node_modules/merge-descriptors/package.json +14 -7
- package/node_modules/path-to-regexp/index.js +57 -40
- package/node_modules/path-to-regexp/package.json +2 -2
- package/node_modules/qs/.editorconfig +3 -0
- package/node_modules/qs/.eslintrc +2 -2
- package/node_modules/qs/CHANGELOG.md +59 -5
- package/node_modules/qs/README.md +133 -49
- package/node_modules/qs/dist/qs.js +56 -2020
- package/node_modules/qs/lib/parse.js +46 -13
- package/node_modules/qs/lib/stringify.js +53 -28
- package/node_modules/qs/lib/utils.js +47 -34
- package/node_modules/qs/package.json +26 -12
- package/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/node_modules/qs/test/parse.js +347 -32
- package/node_modules/qs/test/stringify.js +436 -47
- package/node_modules/send/HISTORY.md +5 -0
- package/node_modules/send/index.js +1 -2
- package/node_modules/send/node_modules/encodeurl/LICENSE +22 -0
- package/node_modules/send/node_modules/encodeurl/README.md +128 -0
- package/node_modules/send/node_modules/encodeurl/index.js +60 -0
- package/node_modules/send/node_modules/encodeurl/package.json +40 -0
- package/node_modules/send/package.json +1 -1
- package/node_modules/serve-static/HISTORY.md +16 -0
- package/node_modules/serve-static/index.js +1 -2
- package/node_modules/serve-static/package.json +3 -3
- package/node_modules/yaml/LICENSE +13 -0
- package/node_modules/yaml/README.md +155 -0
- package/node_modules/yaml/bin.mjs +11 -0
- package/node_modules/yaml/browser/dist/compose/compose-collection.js +88 -0
- package/node_modules/yaml/browser/dist/compose/compose-doc.js +42 -0
- package/node_modules/yaml/browser/dist/compose/compose-node.js +92 -0
- package/node_modules/yaml/browser/dist/compose/compose-scalar.js +80 -0
- package/node_modules/yaml/browser/dist/compose/composer.js +217 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-map.js +113 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-scalar.js +198 -0
- package/node_modules/yaml/browser/dist/compose/resolve-block-seq.js +47 -0
- package/node_modules/yaml/browser/dist/compose/resolve-end.js +37 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-collection.js +203 -0
- package/node_modules/yaml/browser/dist/compose/resolve-flow-scalar.js +223 -0
- package/node_modules/yaml/browser/dist/compose/resolve-props.js +148 -0
- package/node_modules/yaml/browser/dist/compose/util-contains-newline.js +34 -0
- package/node_modules/yaml/browser/dist/compose/util-empty-scalar-position.js +27 -0
- package/node_modules/yaml/browser/dist/compose/util-flow-indent-check.js +15 -0
- package/node_modules/yaml/browser/dist/compose/util-map-includes.js +17 -0
- package/node_modules/yaml/browser/dist/doc/Document.js +334 -0
- package/node_modules/yaml/browser/dist/doc/anchors.js +72 -0
- package/node_modules/yaml/browser/dist/doc/applyReviver.js +55 -0
- package/node_modules/yaml/browser/dist/doc/createNode.js +89 -0
- package/node_modules/yaml/browser/dist/doc/directives.js +176 -0
- package/node_modules/yaml/browser/dist/errors.js +57 -0
- package/node_modules/yaml/browser/dist/index.js +17 -0
- package/node_modules/yaml/browser/dist/log.js +14 -0
- package/node_modules/yaml/browser/dist/nodes/Alias.js +101 -0
- package/node_modules/yaml/browser/dist/nodes/Collection.js +147 -0
- package/node_modules/yaml/browser/dist/nodes/Node.js +38 -0
- package/node_modules/yaml/browser/dist/nodes/Pair.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/Scalar.js +24 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLMap.js +144 -0
- package/node_modules/yaml/browser/dist/nodes/YAMLSeq.js +113 -0
- package/node_modules/yaml/browser/dist/nodes/addPairToJSMap.js +104 -0
- package/node_modules/yaml/browser/dist/nodes/identity.js +36 -0
- package/node_modules/yaml/browser/dist/nodes/toJS.js +37 -0
- package/node_modules/yaml/browser/dist/parse/cst-scalar.js +214 -0
- package/node_modules/yaml/browser/dist/parse/cst-stringify.js +61 -0
- package/node_modules/yaml/browser/dist/parse/cst-visit.js +97 -0
- package/node_modules/yaml/browser/dist/parse/cst.js +98 -0
- package/node_modules/yaml/browser/dist/parse/lexer.js +717 -0
- package/node_modules/yaml/browser/dist/parse/line-counter.js +39 -0
- package/node_modules/yaml/browser/dist/parse/parser.js +954 -0
- package/node_modules/yaml/browser/dist/public-api.js +99 -0
- package/node_modules/yaml/browser/dist/schema/Schema.js +38 -0
- package/node_modules/yaml/browser/dist/schema/common/map.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/null.js +15 -0
- package/node_modules/yaml/browser/dist/schema/common/seq.js +17 -0
- package/node_modules/yaml/browser/dist/schema/common/string.js +14 -0
- package/node_modules/yaml/browser/dist/schema/core/bool.js +19 -0
- package/node_modules/yaml/browser/dist/schema/core/float.js +43 -0
- package/node_modules/yaml/browser/dist/schema/core/int.js +38 -0
- package/node_modules/yaml/browser/dist/schema/core/schema.js +23 -0
- package/node_modules/yaml/browser/dist/schema/json/schema.js +62 -0
- package/node_modules/yaml/browser/dist/schema/tags.js +83 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/binary.js +66 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/bool.js +26 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/float.js +46 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/int.js +71 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/omap.js +74 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/pairs.js +78 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/schema.js +37 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/set.js +93 -0
- package/node_modules/yaml/browser/dist/schema/yaml-1.1/timestamp.js +101 -0
- package/node_modules/yaml/browser/dist/stringify/foldFlowLines.js +146 -0
- package/node_modules/yaml/browser/dist/stringify/stringify.js +124 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyCollection.js +143 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyComment.js +20 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyDocument.js +85 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyNumber.js +24 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyPair.js +150 -0
- package/node_modules/yaml/browser/dist/stringify/stringifyString.js +328 -0
- package/node_modules/yaml/browser/dist/util.js +11 -0
- package/node_modules/yaml/browser/dist/visit.js +233 -0
- package/node_modules/yaml/browser/index.js +5 -0
- package/node_modules/yaml/browser/package.json +3 -0
- package/node_modules/yaml/dist/cli.d.ts +8 -0
- package/node_modules/yaml/dist/cli.mjs +199 -0
- package/node_modules/yaml/dist/compose/compose-collection.d.ts +11 -0
- package/node_modules/yaml/dist/compose/compose-collection.js +90 -0
- package/node_modules/yaml/dist/compose/compose-doc.d.ts +7 -0
- package/node_modules/yaml/dist/compose/compose-doc.js +44 -0
- package/node_modules/yaml/dist/compose/compose-node.d.ts +28 -0
- package/node_modules/yaml/dist/compose/compose-node.js +95 -0
- package/node_modules/yaml/dist/compose/compose-scalar.d.ts +5 -0
- package/node_modules/yaml/dist/compose/compose-scalar.js +82 -0
- package/node_modules/yaml/dist/compose/composer.d.ts +62 -0
- package/node_modules/yaml/dist/compose/composer.js +221 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-map.js +115 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.d.ts +11 -0
- package/node_modules/yaml/dist/compose/resolve-block-scalar.js +200 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-block-seq.js +49 -0
- package/node_modules/yaml/dist/compose/resolve-end.d.ts +6 -0
- package/node_modules/yaml/dist/compose/resolve-end.js +39 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.d.ts +7 -0
- package/node_modules/yaml/dist/compose/resolve-flow-collection.js +205 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.d.ts +10 -0
- package/node_modules/yaml/dist/compose/resolve-flow-scalar.js +225 -0
- package/node_modules/yaml/dist/compose/resolve-props.d.ts +23 -0
- package/node_modules/yaml/dist/compose/resolve-props.js +150 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-contains-newline.js +36 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.d.ts +2 -0
- package/node_modules/yaml/dist/compose/util-empty-scalar-position.js +29 -0
- 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/compose/util-map-includes.d.ts +4 -0
- package/node_modules/yaml/dist/compose/util-map-includes.js +19 -0
- package/node_modules/yaml/dist/doc/Document.d.ts +141 -0
- package/node_modules/yaml/dist/doc/Document.js +336 -0
- package/node_modules/yaml/dist/doc/anchors.d.ts +24 -0
- package/node_modules/yaml/dist/doc/anchors.js +77 -0
- package/node_modules/yaml/dist/doc/applyReviver.d.ts +9 -0
- package/node_modules/yaml/dist/doc/applyReviver.js +57 -0
- package/node_modules/yaml/dist/doc/createNode.d.ts +17 -0
- package/node_modules/yaml/dist/doc/createNode.js +91 -0
- package/node_modules/yaml/dist/doc/directives.d.ts +49 -0
- package/node_modules/yaml/dist/doc/directives.js +178 -0
- package/node_modules/yaml/dist/errors.d.ts +21 -0
- package/node_modules/yaml/dist/errors.js +62 -0
- package/node_modules/yaml/dist/index.d.ts +22 -0
- package/node_modules/yaml/dist/index.js +50 -0
- package/node_modules/yaml/dist/log.d.ts +3 -0
- package/node_modules/yaml/dist/log.js +17 -0
- package/node_modules/yaml/dist/nodes/Alias.d.ts +28 -0
- package/node_modules/yaml/dist/nodes/Alias.js +103 -0
- package/node_modules/yaml/dist/nodes/Collection.d.ts +73 -0
- package/node_modules/yaml/dist/nodes/Collection.js +151 -0
- package/node_modules/yaml/dist/nodes/Node.d.ts +47 -0
- package/node_modules/yaml/dist/nodes/Node.js +40 -0
- package/node_modules/yaml/dist/nodes/Pair.d.ts +21 -0
- package/node_modules/yaml/dist/nodes/Pair.js +39 -0
- package/node_modules/yaml/dist/nodes/Scalar.d.ts +42 -0
- package/node_modules/yaml/dist/nodes/Scalar.js +27 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.d.ts +53 -0
- package/node_modules/yaml/dist/nodes/YAMLMap.js +147 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.d.ts +60 -0
- package/node_modules/yaml/dist/nodes/YAMLSeq.js +115 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.d.ts +4 -0
- package/node_modules/yaml/dist/nodes/addPairToJSMap.js +106 -0
- 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 +27 -0
- package/node_modules/yaml/dist/nodes/toJS.js +39 -0
- package/node_modules/yaml/dist/options.d.ts +338 -0
- package/node_modules/yaml/dist/parse/cst-scalar.d.ts +64 -0
- package/node_modules/yaml/dist/parse/cst-scalar.js +218 -0
- package/node_modules/yaml/dist/parse/cst-stringify.d.ts +8 -0
- package/node_modules/yaml/dist/parse/cst-stringify.js +63 -0
- package/node_modules/yaml/dist/parse/cst-visit.d.ts +39 -0
- package/node_modules/yaml/dist/parse/cst-visit.js +99 -0
- package/node_modules/yaml/dist/parse/cst.d.ts +108 -0
- package/node_modules/yaml/dist/parse/cst.js +112 -0
- package/node_modules/yaml/dist/parse/lexer.d.ts +87 -0
- package/node_modules/yaml/dist/parse/lexer.js +719 -0
- package/node_modules/yaml/dist/parse/line-counter.d.ts +22 -0
- package/node_modules/yaml/dist/parse/line-counter.js +41 -0
- package/node_modules/yaml/dist/parse/parser.d.ts +84 -0
- package/node_modules/yaml/dist/parse/parser.js +958 -0
- package/node_modules/yaml/dist/public-api.d.ts +43 -0
- package/node_modules/yaml/dist/public-api.js +104 -0
- package/node_modules/yaml/dist/schema/Schema.d.ts +18 -0
- package/node_modules/yaml/dist/schema/Schema.js +40 -0
- package/node_modules/yaml/dist/schema/common/map.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/map.js +19 -0
- package/node_modules/yaml/dist/schema/common/null.d.ts +4 -0
- package/node_modules/yaml/dist/schema/common/null.js +17 -0
- package/node_modules/yaml/dist/schema/common/seq.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/seq.js +19 -0
- package/node_modules/yaml/dist/schema/common/string.d.ts +2 -0
- package/node_modules/yaml/dist/schema/common/string.js +16 -0
- package/node_modules/yaml/dist/schema/core/bool.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/bool.js +21 -0
- package/node_modules/yaml/dist/schema/core/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/float.js +47 -0
- package/node_modules/yaml/dist/schema/core/int.d.ts +4 -0
- package/node_modules/yaml/dist/schema/core/int.js +42 -0
- package/node_modules/yaml/dist/schema/core/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/core/schema.js +25 -0
- package/node_modules/yaml/dist/schema/json/schema.d.ts +2 -0
- package/node_modules/yaml/dist/schema/json/schema.js +64 -0
- package/node_modules/yaml/dist/schema/json-schema.d.ts +69 -0
- package/node_modules/yaml/dist/schema/tags.d.ts +40 -0
- package/node_modules/yaml/dist/schema/tags.js +86 -0
- package/node_modules/yaml/dist/schema/types.d.ts +90 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.d.ts +2 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/binary.js +68 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.d.ts +7 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/bool.js +29 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.d.ts +4 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/float.js +50 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.d.ts +5 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/int.js +76 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/omap.js +77 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.d.ts +10 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/pairs.js +82 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.d.ts +1 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/schema.js +39 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.d.ts +28 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/set.js +96 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.d.ts +6 -0
- package/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js +105 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.d.ts +34 -0
- package/node_modules/yaml/dist/stringify/foldFlowLines.js +151 -0
- package/node_modules/yaml/dist/stringify/stringify.d.ts +21 -0
- package/node_modules/yaml/dist/stringify/stringify.js +127 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.d.ts +17 -0
- package/node_modules/yaml/dist/stringify/stringifyCollection.js +145 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.d.ts +10 -0
- package/node_modules/yaml/dist/stringify/stringifyComment.js +24 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.d.ts +4 -0
- package/node_modules/yaml/dist/stringify/stringifyDocument.js +87 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.d.ts +2 -0
- package/node_modules/yaml/dist/stringify/stringifyNumber.js +26 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.d.ts +3 -0
- package/node_modules/yaml/dist/stringify/stringifyPair.js +152 -0
- package/node_modules/yaml/dist/stringify/stringifyString.d.ts +9 -0
- package/node_modules/yaml/dist/stringify/stringifyString.js +330 -0
- package/node_modules/yaml/dist/test-events.d.ts +4 -0
- package/node_modules/yaml/dist/test-events.js +134 -0
- package/node_modules/yaml/dist/util.d.ts +12 -0
- package/node_modules/yaml/dist/util.js +28 -0
- package/node_modules/yaml/dist/visit.d.ts +102 -0
- package/node_modules/yaml/dist/visit.js +236 -0
- package/node_modules/yaml/package.json +96 -0
- package/node_modules/yaml/util.js +2 -0
- package/package.json +7 -3
- package/server.js +50 -23
- package/node_modules/path-to-regexp/History.md +0 -36
- /package/node_modules/{encodeurl → send/node_modules/encodeurl}/HISTORY.md +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var map = require('./common/map.js');
|
|
4
|
+
var _null = require('./common/null.js');
|
|
5
|
+
var seq = require('./common/seq.js');
|
|
6
|
+
var string = require('./common/string.js');
|
|
7
|
+
var bool = require('./core/bool.js');
|
|
8
|
+
var float = require('./core/float.js');
|
|
9
|
+
var int = require('./core/int.js');
|
|
10
|
+
var schema = require('./core/schema.js');
|
|
11
|
+
var schema$1 = require('./json/schema.js');
|
|
12
|
+
var binary = require('./yaml-1.1/binary.js');
|
|
13
|
+
var omap = require('./yaml-1.1/omap.js');
|
|
14
|
+
var pairs = require('./yaml-1.1/pairs.js');
|
|
15
|
+
var schema$2 = require('./yaml-1.1/schema.js');
|
|
16
|
+
var set = require('./yaml-1.1/set.js');
|
|
17
|
+
var timestamp = require('./yaml-1.1/timestamp.js');
|
|
18
|
+
|
|
19
|
+
const schemas = new Map([
|
|
20
|
+
['core', schema.schema],
|
|
21
|
+
['failsafe', [map.map, seq.seq, string.string]],
|
|
22
|
+
['json', schema$1.schema],
|
|
23
|
+
['yaml11', schema$2.schema],
|
|
24
|
+
['yaml-1.1', schema$2.schema]
|
|
25
|
+
]);
|
|
26
|
+
const tagsByName = {
|
|
27
|
+
binary: binary.binary,
|
|
28
|
+
bool: bool.boolTag,
|
|
29
|
+
float: float.float,
|
|
30
|
+
floatExp: float.floatExp,
|
|
31
|
+
floatNaN: float.floatNaN,
|
|
32
|
+
floatTime: timestamp.floatTime,
|
|
33
|
+
int: int.int,
|
|
34
|
+
intHex: int.intHex,
|
|
35
|
+
intOct: int.intOct,
|
|
36
|
+
intTime: timestamp.intTime,
|
|
37
|
+
map: map.map,
|
|
38
|
+
null: _null.nullTag,
|
|
39
|
+
omap: omap.omap,
|
|
40
|
+
pairs: pairs.pairs,
|
|
41
|
+
seq: seq.seq,
|
|
42
|
+
set: set.set,
|
|
43
|
+
timestamp: timestamp.timestamp
|
|
44
|
+
};
|
|
45
|
+
const coreKnownTags = {
|
|
46
|
+
'tag:yaml.org,2002:binary': binary.binary,
|
|
47
|
+
'tag:yaml.org,2002:omap': omap.omap,
|
|
48
|
+
'tag:yaml.org,2002:pairs': pairs.pairs,
|
|
49
|
+
'tag:yaml.org,2002:set': set.set,
|
|
50
|
+
'tag:yaml.org,2002:timestamp': timestamp.timestamp
|
|
51
|
+
};
|
|
52
|
+
function getTags(customTags, schemaName) {
|
|
53
|
+
let tags = schemas.get(schemaName);
|
|
54
|
+
if (!tags) {
|
|
55
|
+
if (Array.isArray(customTags))
|
|
56
|
+
tags = [];
|
|
57
|
+
else {
|
|
58
|
+
const keys = Array.from(schemas.keys())
|
|
59
|
+
.filter(key => key !== 'yaml11')
|
|
60
|
+
.map(key => JSON.stringify(key))
|
|
61
|
+
.join(', ');
|
|
62
|
+
throw new Error(`Unknown schema "${schemaName}"; use one of ${keys} or define customTags array`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (Array.isArray(customTags)) {
|
|
66
|
+
for (const tag of customTags)
|
|
67
|
+
tags = tags.concat(tag);
|
|
68
|
+
}
|
|
69
|
+
else if (typeof customTags === 'function') {
|
|
70
|
+
tags = customTags(tags.slice());
|
|
71
|
+
}
|
|
72
|
+
return tags.map(tag => {
|
|
73
|
+
if (typeof tag !== 'string')
|
|
74
|
+
return tag;
|
|
75
|
+
const tagObj = tagsByName[tag];
|
|
76
|
+
if (tagObj)
|
|
77
|
+
return tagObj;
|
|
78
|
+
const keys = Object.keys(tagsByName)
|
|
79
|
+
.map(key => JSON.stringify(key))
|
|
80
|
+
.join(', ');
|
|
81
|
+
throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
exports.coreKnownTags = coreKnownTags;
|
|
86
|
+
exports.getTags = getTags;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { CreateNodeContext } from '../doc/createNode.js';
|
|
2
|
+
import type { Node } from '../nodes/Node.js';
|
|
3
|
+
import type { Scalar } from '../nodes/Scalar.js';
|
|
4
|
+
import type { YAMLMap } from '../nodes/YAMLMap.js';
|
|
5
|
+
import type { YAMLSeq } from '../nodes/YAMLSeq.js';
|
|
6
|
+
import type { ParseOptions } from '../options.js';
|
|
7
|
+
import type { StringifyContext } from '../stringify/stringify.js';
|
|
8
|
+
import type { Schema } from './Schema.js';
|
|
9
|
+
interface TagBase {
|
|
10
|
+
/**
|
|
11
|
+
* An optional factory function, used e.g. by collections when wrapping JS objects as AST nodes.
|
|
12
|
+
*/
|
|
13
|
+
createNode?: (schema: Schema, value: unknown, ctx: CreateNodeContext) => Node;
|
|
14
|
+
/**
|
|
15
|
+
* If `true`, together with `test` allows for values to be stringified without
|
|
16
|
+
* an explicit tag. For most cases, it's unlikely that you'll actually want to
|
|
17
|
+
* use this, even if you first think you do.
|
|
18
|
+
*/
|
|
19
|
+
default?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* If a tag has multiple forms that should be parsed and/or stringified
|
|
22
|
+
* differently, use `format` to identify them.
|
|
23
|
+
*/
|
|
24
|
+
format?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Used by `YAML.createNode` to detect your data type, e.g. using `typeof` or
|
|
27
|
+
* `instanceof`.
|
|
28
|
+
*/
|
|
29
|
+
identify?: (value: unknown) => boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The identifier for your data type, with which its stringified form will be
|
|
32
|
+
* prefixed. Should either be a !-prefixed local `!tag`, or a fully qualified
|
|
33
|
+
* `tag:domain,date:foo`.
|
|
34
|
+
*/
|
|
35
|
+
tag: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ScalarTag extends TagBase {
|
|
38
|
+
collection?: never;
|
|
39
|
+
nodeClass?: never;
|
|
40
|
+
/**
|
|
41
|
+
* Turns a value into an AST node.
|
|
42
|
+
* If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
|
|
43
|
+
*/
|
|
44
|
+
resolve(value: string, onError: (message: string) => void, options: ParseOptions): unknown;
|
|
45
|
+
/**
|
|
46
|
+
* Optional function stringifying a Scalar node. If your data includes a
|
|
47
|
+
* suitable `.toString()` method, you can probably leave this undefined and
|
|
48
|
+
* use the default stringifier.
|
|
49
|
+
*
|
|
50
|
+
* @param item The node being stringified.
|
|
51
|
+
* @param ctx Contains the stringifying context variables.
|
|
52
|
+
* @param onComment Callback to signal that the stringifier includes the
|
|
53
|
+
* item's comment in its output.
|
|
54
|
+
* @param onChompKeep Callback to signal that the output uses a block scalar
|
|
55
|
+
* type with the `+` chomping indicator.
|
|
56
|
+
*/
|
|
57
|
+
stringify?: (item: Scalar, ctx: StringifyContext, onComment?: () => void, onChompKeep?: () => void) => string;
|
|
58
|
+
/**
|
|
59
|
+
* Together with `default` allows for values to be stringified without an
|
|
60
|
+
* explicit tag and detected using a regular expression. For most cases, it's
|
|
61
|
+
* unlikely that you'll actually want to use these, even if you first think
|
|
62
|
+
* you do.
|
|
63
|
+
*/
|
|
64
|
+
test?: RegExp;
|
|
65
|
+
}
|
|
66
|
+
export interface CollectionTag extends TagBase {
|
|
67
|
+
stringify?: never;
|
|
68
|
+
test?: never;
|
|
69
|
+
/** The source collection type supported by this tag. */
|
|
70
|
+
collection: 'map' | 'seq';
|
|
71
|
+
/**
|
|
72
|
+
* The `Node` child class that implements this tag.
|
|
73
|
+
* If set, used to select this tag when stringifying.
|
|
74
|
+
*
|
|
75
|
+
* If the class provides a static `from` method, then that
|
|
76
|
+
* will be used if the tag object doesn't have a `createNode` method.
|
|
77
|
+
*/
|
|
78
|
+
nodeClass?: {
|
|
79
|
+
new (schema?: Schema): Node;
|
|
80
|
+
from?: (schema: Schema, obj: unknown, ctx: CreateNodeContext) => Node;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Turns a value into an AST node.
|
|
84
|
+
* If returning a non-`Node` value, the output will be wrapped as a `Scalar`.
|
|
85
|
+
*
|
|
86
|
+
* Note: this is required if nodeClass is not provided.
|
|
87
|
+
*/
|
|
88
|
+
resolve?: (value: YAMLMap.Parsed | YAMLSeq.Parsed, onError: (message: string) => void, options: ParseOptions) => unknown;
|
|
89
|
+
}
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Scalar = require('../../nodes/Scalar.js');
|
|
4
|
+
var stringifyString = require('../../stringify/stringifyString.js');
|
|
5
|
+
|
|
6
|
+
const binary = {
|
|
7
|
+
identify: value => value instanceof Uint8Array, // Buffer inherits from Uint8Array
|
|
8
|
+
default: false,
|
|
9
|
+
tag: 'tag:yaml.org,2002:binary',
|
|
10
|
+
/**
|
|
11
|
+
* Returns a Buffer in node and an Uint8Array in browsers
|
|
12
|
+
*
|
|
13
|
+
* To use the resulting buffer as an image, you'll want to do something like:
|
|
14
|
+
*
|
|
15
|
+
* const blob = new Blob([buffer], { type: 'image/jpeg' })
|
|
16
|
+
* document.querySelector('#photo').src = URL.createObjectURL(blob)
|
|
17
|
+
*/
|
|
18
|
+
resolve(src, onError) {
|
|
19
|
+
if (typeof Buffer === 'function') {
|
|
20
|
+
return Buffer.from(src, 'base64');
|
|
21
|
+
}
|
|
22
|
+
else if (typeof atob === 'function') {
|
|
23
|
+
// On IE 11, atob() can't handle newlines
|
|
24
|
+
const str = atob(src.replace(/[\n\r]/g, ''));
|
|
25
|
+
const buffer = new Uint8Array(str.length);
|
|
26
|
+
for (let i = 0; i < str.length; ++i)
|
|
27
|
+
buffer[i] = str.charCodeAt(i);
|
|
28
|
+
return buffer;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
onError('This environment does not support reading binary tags; either Buffer or atob is required');
|
|
32
|
+
return src;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
stringify({ comment, type, value }, ctx, onComment, onChompKeep) {
|
|
36
|
+
const buf = value; // checked earlier by binary.identify()
|
|
37
|
+
let str;
|
|
38
|
+
if (typeof Buffer === 'function') {
|
|
39
|
+
str =
|
|
40
|
+
buf instanceof Buffer
|
|
41
|
+
? buf.toString('base64')
|
|
42
|
+
: Buffer.from(buf.buffer).toString('base64');
|
|
43
|
+
}
|
|
44
|
+
else if (typeof btoa === 'function') {
|
|
45
|
+
let s = '';
|
|
46
|
+
for (let i = 0; i < buf.length; ++i)
|
|
47
|
+
s += String.fromCharCode(buf[i]);
|
|
48
|
+
str = btoa(s);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required');
|
|
52
|
+
}
|
|
53
|
+
if (!type)
|
|
54
|
+
type = Scalar.Scalar.BLOCK_LITERAL;
|
|
55
|
+
if (type !== Scalar.Scalar.QUOTE_DOUBLE) {
|
|
56
|
+
const lineWidth = Math.max(ctx.options.lineWidth - ctx.indent.length, ctx.options.minContentWidth);
|
|
57
|
+
const n = Math.ceil(str.length / lineWidth);
|
|
58
|
+
const lines = new Array(n);
|
|
59
|
+
for (let i = 0, o = 0; i < n; ++i, o += lineWidth) {
|
|
60
|
+
lines[i] = str.substr(o, lineWidth);
|
|
61
|
+
}
|
|
62
|
+
str = lines.join(type === Scalar.Scalar.BLOCK_LITERAL ? '\n' : ' ');
|
|
63
|
+
}
|
|
64
|
+
return stringifyString.stringifyString({ comment, type, value: str }, ctx, onComment, onChompKeep);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.binary = binary;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Scalar = require('../../nodes/Scalar.js');
|
|
4
|
+
|
|
5
|
+
function boolStringify({ value, source }, ctx) {
|
|
6
|
+
const boolObj = value ? trueTag : falseTag;
|
|
7
|
+
if (source && boolObj.test.test(source))
|
|
8
|
+
return source;
|
|
9
|
+
return value ? ctx.options.trueStr : ctx.options.falseStr;
|
|
10
|
+
}
|
|
11
|
+
const trueTag = {
|
|
12
|
+
identify: value => value === true,
|
|
13
|
+
default: true,
|
|
14
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
15
|
+
test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
|
|
16
|
+
resolve: () => new Scalar.Scalar(true),
|
|
17
|
+
stringify: boolStringify
|
|
18
|
+
};
|
|
19
|
+
const falseTag = {
|
|
20
|
+
identify: value => value === false,
|
|
21
|
+
default: true,
|
|
22
|
+
tag: 'tag:yaml.org,2002:bool',
|
|
23
|
+
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
|
|
24
|
+
resolve: () => new Scalar.Scalar(false),
|
|
25
|
+
stringify: boolStringify
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.falseTag = falseTag;
|
|
29
|
+
exports.trueTag = trueTag;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Scalar = require('../../nodes/Scalar.js');
|
|
4
|
+
var stringifyNumber = require('../../stringify/stringifyNumber.js');
|
|
5
|
+
|
|
6
|
+
const floatNaN = {
|
|
7
|
+
identify: value => typeof value === 'number',
|
|
8
|
+
default: true,
|
|
9
|
+
tag: 'tag:yaml.org,2002:float',
|
|
10
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
11
|
+
resolve: (str) => str.slice(-3).toLowerCase() === 'nan'
|
|
12
|
+
? NaN
|
|
13
|
+
: str[0] === '-'
|
|
14
|
+
? Number.NEGATIVE_INFINITY
|
|
15
|
+
: Number.POSITIVE_INFINITY,
|
|
16
|
+
stringify: stringifyNumber.stringifyNumber
|
|
17
|
+
};
|
|
18
|
+
const floatExp = {
|
|
19
|
+
identify: value => typeof value === 'number',
|
|
20
|
+
default: true,
|
|
21
|
+
tag: 'tag:yaml.org,2002:float',
|
|
22
|
+
format: 'EXP',
|
|
23
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
|
|
24
|
+
resolve: (str) => parseFloat(str.replace(/_/g, '')),
|
|
25
|
+
stringify(node) {
|
|
26
|
+
const num = Number(node.value);
|
|
27
|
+
return isFinite(num) ? num.toExponential() : stringifyNumber.stringifyNumber(node);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const float = {
|
|
31
|
+
identify: value => typeof value === 'number',
|
|
32
|
+
default: true,
|
|
33
|
+
tag: 'tag:yaml.org,2002:float',
|
|
34
|
+
test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
|
|
35
|
+
resolve(str) {
|
|
36
|
+
const node = new Scalar.Scalar(parseFloat(str.replace(/_/g, '')));
|
|
37
|
+
const dot = str.indexOf('.');
|
|
38
|
+
if (dot !== -1) {
|
|
39
|
+
const f = str.substring(dot + 1).replace(/_/g, '');
|
|
40
|
+
if (f[f.length - 1] === '0')
|
|
41
|
+
node.minFractionDigits = f.length;
|
|
42
|
+
}
|
|
43
|
+
return node;
|
|
44
|
+
},
|
|
45
|
+
stringify: stringifyNumber.stringifyNumber
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.float = float;
|
|
49
|
+
exports.floatExp = floatExp;
|
|
50
|
+
exports.floatNaN = floatNaN;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var stringifyNumber = require('../../stringify/stringifyNumber.js');
|
|
4
|
+
|
|
5
|
+
const intIdentify = (value) => typeof value === 'bigint' || Number.isInteger(value);
|
|
6
|
+
function intResolve(str, offset, radix, { intAsBigInt }) {
|
|
7
|
+
const sign = str[0];
|
|
8
|
+
if (sign === '-' || sign === '+')
|
|
9
|
+
offset += 1;
|
|
10
|
+
str = str.substring(offset).replace(/_/g, '');
|
|
11
|
+
if (intAsBigInt) {
|
|
12
|
+
switch (radix) {
|
|
13
|
+
case 2:
|
|
14
|
+
str = `0b${str}`;
|
|
15
|
+
break;
|
|
16
|
+
case 8:
|
|
17
|
+
str = `0o${str}`;
|
|
18
|
+
break;
|
|
19
|
+
case 16:
|
|
20
|
+
str = `0x${str}`;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
const n = BigInt(str);
|
|
24
|
+
return sign === '-' ? BigInt(-1) * n : n;
|
|
25
|
+
}
|
|
26
|
+
const n = parseInt(str, radix);
|
|
27
|
+
return sign === '-' ? -1 * n : n;
|
|
28
|
+
}
|
|
29
|
+
function intStringify(node, radix, prefix) {
|
|
30
|
+
const { value } = node;
|
|
31
|
+
if (intIdentify(value)) {
|
|
32
|
+
const str = value.toString(radix);
|
|
33
|
+
return value < 0 ? '-' + prefix + str.substr(1) : prefix + str;
|
|
34
|
+
}
|
|
35
|
+
return stringifyNumber.stringifyNumber(node);
|
|
36
|
+
}
|
|
37
|
+
const intBin = {
|
|
38
|
+
identify: intIdentify,
|
|
39
|
+
default: true,
|
|
40
|
+
tag: 'tag:yaml.org,2002:int',
|
|
41
|
+
format: 'BIN',
|
|
42
|
+
test: /^[-+]?0b[0-1_]+$/,
|
|
43
|
+
resolve: (str, _onError, opt) => intResolve(str, 2, 2, opt),
|
|
44
|
+
stringify: node => intStringify(node, 2, '0b')
|
|
45
|
+
};
|
|
46
|
+
const intOct = {
|
|
47
|
+
identify: intIdentify,
|
|
48
|
+
default: true,
|
|
49
|
+
tag: 'tag:yaml.org,2002:int',
|
|
50
|
+
format: 'OCT',
|
|
51
|
+
test: /^[-+]?0[0-7_]+$/,
|
|
52
|
+
resolve: (str, _onError, opt) => intResolve(str, 1, 8, opt),
|
|
53
|
+
stringify: node => intStringify(node, 8, '0')
|
|
54
|
+
};
|
|
55
|
+
const int = {
|
|
56
|
+
identify: intIdentify,
|
|
57
|
+
default: true,
|
|
58
|
+
tag: 'tag:yaml.org,2002:int',
|
|
59
|
+
test: /^[-+]?[0-9][0-9_]*$/,
|
|
60
|
+
resolve: (str, _onError, opt) => intResolve(str, 0, 10, opt),
|
|
61
|
+
stringify: stringifyNumber.stringifyNumber
|
|
62
|
+
};
|
|
63
|
+
const intHex = {
|
|
64
|
+
identify: intIdentify,
|
|
65
|
+
default: true,
|
|
66
|
+
tag: 'tag:yaml.org,2002:int',
|
|
67
|
+
format: 'HEX',
|
|
68
|
+
test: /^[-+]?0x[0-9a-fA-F_]+$/,
|
|
69
|
+
resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
|
|
70
|
+
stringify: node => intStringify(node, 16, '0x')
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.int = int;
|
|
74
|
+
exports.intBin = intBin;
|
|
75
|
+
exports.intHex = intHex;
|
|
76
|
+
exports.intOct = intOct;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ToJSContext } from '../../nodes/toJS.js';
|
|
2
|
+
import { YAMLSeq } from '../../nodes/YAMLSeq.js';
|
|
3
|
+
import { CreateNodeContext } from '../../util.js';
|
|
4
|
+
import type { Schema } from '../Schema.js';
|
|
5
|
+
import { CollectionTag } from '../types.js';
|
|
6
|
+
export declare class YAMLOMap extends YAMLSeq {
|
|
7
|
+
static tag: string;
|
|
8
|
+
constructor();
|
|
9
|
+
add: (pair: import("../../index.js").Pair<any, any> | {
|
|
10
|
+
key: any;
|
|
11
|
+
value: any;
|
|
12
|
+
}, overwrite?: boolean) => void;
|
|
13
|
+
delete: (key: unknown) => boolean;
|
|
14
|
+
get: {
|
|
15
|
+
(key: unknown, keepScalar: true): import("../../index.js").Scalar<any> | undefined;
|
|
16
|
+
(key: unknown, keepScalar?: false): any;
|
|
17
|
+
(key: unknown, keepScalar?: boolean): any;
|
|
18
|
+
};
|
|
19
|
+
has: (key: unknown) => boolean;
|
|
20
|
+
set: (key: any, value: any) => void;
|
|
21
|
+
/**
|
|
22
|
+
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
23
|
+
* but TypeScript won't allow widening the signature of a child method.
|
|
24
|
+
*/
|
|
25
|
+
toJSON(_?: unknown, ctx?: ToJSContext): unknown[];
|
|
26
|
+
static from(schema: Schema, iterable: unknown, ctx: CreateNodeContext): YAMLOMap;
|
|
27
|
+
}
|
|
28
|
+
export declare const omap: CollectionTag;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var identity = require('../../nodes/identity.js');
|
|
4
|
+
var toJS = require('../../nodes/toJS.js');
|
|
5
|
+
var YAMLMap = require('../../nodes/YAMLMap.js');
|
|
6
|
+
var YAMLSeq = require('../../nodes/YAMLSeq.js');
|
|
7
|
+
var pairs = require('./pairs.js');
|
|
8
|
+
|
|
9
|
+
class YAMLOMap extends YAMLSeq.YAMLSeq {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
this.add = YAMLMap.YAMLMap.prototype.add.bind(this);
|
|
13
|
+
this.delete = YAMLMap.YAMLMap.prototype.delete.bind(this);
|
|
14
|
+
this.get = YAMLMap.YAMLMap.prototype.get.bind(this);
|
|
15
|
+
this.has = YAMLMap.YAMLMap.prototype.has.bind(this);
|
|
16
|
+
this.set = YAMLMap.YAMLMap.prototype.set.bind(this);
|
|
17
|
+
this.tag = YAMLOMap.tag;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
|
|
21
|
+
* but TypeScript won't allow widening the signature of a child method.
|
|
22
|
+
*/
|
|
23
|
+
toJSON(_, ctx) {
|
|
24
|
+
if (!ctx)
|
|
25
|
+
return super.toJSON(_);
|
|
26
|
+
const map = new Map();
|
|
27
|
+
if (ctx?.onCreate)
|
|
28
|
+
ctx.onCreate(map);
|
|
29
|
+
for (const pair of this.items) {
|
|
30
|
+
let key, value;
|
|
31
|
+
if (identity.isPair(pair)) {
|
|
32
|
+
key = toJS.toJS(pair.key, '', ctx);
|
|
33
|
+
value = toJS.toJS(pair.value, key, ctx);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
key = toJS.toJS(pair, '', ctx);
|
|
37
|
+
}
|
|
38
|
+
if (map.has(key))
|
|
39
|
+
throw new Error('Ordered maps must not include duplicate keys');
|
|
40
|
+
map.set(key, value);
|
|
41
|
+
}
|
|
42
|
+
return map;
|
|
43
|
+
}
|
|
44
|
+
static from(schema, iterable, ctx) {
|
|
45
|
+
const pairs$1 = pairs.createPairs(schema, iterable, ctx);
|
|
46
|
+
const omap = new this();
|
|
47
|
+
omap.items = pairs$1.items;
|
|
48
|
+
return omap;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
YAMLOMap.tag = 'tag:yaml.org,2002:omap';
|
|
52
|
+
const omap = {
|
|
53
|
+
collection: 'seq',
|
|
54
|
+
identify: value => value instanceof Map,
|
|
55
|
+
nodeClass: YAMLOMap,
|
|
56
|
+
default: false,
|
|
57
|
+
tag: 'tag:yaml.org,2002:omap',
|
|
58
|
+
resolve(seq, onError) {
|
|
59
|
+
const pairs$1 = pairs.resolvePairs(seq, onError);
|
|
60
|
+
const seenKeys = [];
|
|
61
|
+
for (const { key } of pairs$1.items) {
|
|
62
|
+
if (identity.isScalar(key)) {
|
|
63
|
+
if (seenKeys.includes(key.value)) {
|
|
64
|
+
onError(`Ordered maps must not include duplicate keys: ${key.value}`);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
seenKeys.push(key.value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Object.assign(new YAMLOMap(), pairs$1);
|
|
72
|
+
},
|
|
73
|
+
createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx)
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
exports.YAMLOMap = YAMLOMap;
|
|
77
|
+
exports.omap = omap;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CreateNodeContext } from '../../doc/createNode.js';
|
|
2
|
+
import type { ParsedNode } from '../../nodes/Node.js';
|
|
3
|
+
import { Pair } from '../../nodes/Pair.js';
|
|
4
|
+
import { YAMLMap } from '../../nodes/YAMLMap.js';
|
|
5
|
+
import { YAMLSeq } from '../../nodes/YAMLSeq.js';
|
|
6
|
+
import type { Schema } from '../../schema/Schema.js';
|
|
7
|
+
import type { CollectionTag } from '../types.js';
|
|
8
|
+
export declare function resolvePairs(seq: YAMLSeq.Parsed<ParsedNode | Pair<ParsedNode, ParsedNode | null>> | YAMLMap.Parsed, onError: (message: string) => void): YAMLSeq.Parsed<Pair<ParsedNode, ParsedNode | null>>;
|
|
9
|
+
export declare function createPairs(schema: Schema, iterable: unknown, ctx: CreateNodeContext): YAMLSeq<unknown>;
|
|
10
|
+
export declare const pairs: CollectionTag;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var identity = require('../../nodes/identity.js');
|
|
4
|
+
var Pair = require('../../nodes/Pair.js');
|
|
5
|
+
var Scalar = require('../../nodes/Scalar.js');
|
|
6
|
+
var YAMLSeq = require('../../nodes/YAMLSeq.js');
|
|
7
|
+
|
|
8
|
+
function resolvePairs(seq, onError) {
|
|
9
|
+
if (identity.isSeq(seq)) {
|
|
10
|
+
for (let i = 0; i < seq.items.length; ++i) {
|
|
11
|
+
let item = seq.items[i];
|
|
12
|
+
if (identity.isPair(item))
|
|
13
|
+
continue;
|
|
14
|
+
else if (identity.isMap(item)) {
|
|
15
|
+
if (item.items.length > 1)
|
|
16
|
+
onError('Each pair must have its own sequence indicator');
|
|
17
|
+
const pair = item.items[0] || new Pair.Pair(new Scalar.Scalar(null));
|
|
18
|
+
if (item.commentBefore)
|
|
19
|
+
pair.key.commentBefore = pair.key.commentBefore
|
|
20
|
+
? `${item.commentBefore}\n${pair.key.commentBefore}`
|
|
21
|
+
: item.commentBefore;
|
|
22
|
+
if (item.comment) {
|
|
23
|
+
const cn = pair.value ?? pair.key;
|
|
24
|
+
cn.comment = cn.comment
|
|
25
|
+
? `${item.comment}\n${cn.comment}`
|
|
26
|
+
: item.comment;
|
|
27
|
+
}
|
|
28
|
+
item = pair;
|
|
29
|
+
}
|
|
30
|
+
seq.items[i] = identity.isPair(item) ? item : new Pair.Pair(item);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
onError('Expected a sequence for this tag');
|
|
35
|
+
return seq;
|
|
36
|
+
}
|
|
37
|
+
function createPairs(schema, iterable, ctx) {
|
|
38
|
+
const { replacer } = ctx;
|
|
39
|
+
const pairs = new YAMLSeq.YAMLSeq(schema);
|
|
40
|
+
pairs.tag = 'tag:yaml.org,2002:pairs';
|
|
41
|
+
let i = 0;
|
|
42
|
+
if (iterable && Symbol.iterator in Object(iterable))
|
|
43
|
+
for (let it of iterable) {
|
|
44
|
+
if (typeof replacer === 'function')
|
|
45
|
+
it = replacer.call(iterable, String(i++), it);
|
|
46
|
+
let key, value;
|
|
47
|
+
if (Array.isArray(it)) {
|
|
48
|
+
if (it.length === 2) {
|
|
49
|
+
key = it[0];
|
|
50
|
+
value = it[1];
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
throw new TypeError(`Expected [key, value] tuple: ${it}`);
|
|
54
|
+
}
|
|
55
|
+
else if (it && it instanceof Object) {
|
|
56
|
+
const keys = Object.keys(it);
|
|
57
|
+
if (keys.length === 1) {
|
|
58
|
+
key = keys[0];
|
|
59
|
+
value = it[key];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new TypeError(`Expected tuple with one key, not ${keys.length} keys`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
key = it;
|
|
67
|
+
}
|
|
68
|
+
pairs.items.push(Pair.createPair(key, value, ctx));
|
|
69
|
+
}
|
|
70
|
+
return pairs;
|
|
71
|
+
}
|
|
72
|
+
const pairs = {
|
|
73
|
+
collection: 'seq',
|
|
74
|
+
default: false,
|
|
75
|
+
tag: 'tag:yaml.org,2002:pairs',
|
|
76
|
+
resolve: resolvePairs,
|
|
77
|
+
createNode: createPairs
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
exports.createPairs = createPairs;
|
|
81
|
+
exports.pairs = pairs;
|
|
82
|
+
exports.resolvePairs = resolvePairs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const schema: (import("../types.js").CollectionTag | import("../types.js").ScalarTag)[];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var map = require('../common/map.js');
|
|
4
|
+
var _null = require('../common/null.js');
|
|
5
|
+
var seq = require('../common/seq.js');
|
|
6
|
+
var string = require('../common/string.js');
|
|
7
|
+
var binary = require('./binary.js');
|
|
8
|
+
var bool = require('./bool.js');
|
|
9
|
+
var float = require('./float.js');
|
|
10
|
+
var int = require('./int.js');
|
|
11
|
+
var omap = require('./omap.js');
|
|
12
|
+
var pairs = require('./pairs.js');
|
|
13
|
+
var set = require('./set.js');
|
|
14
|
+
var timestamp = require('./timestamp.js');
|
|
15
|
+
|
|
16
|
+
const schema = [
|
|
17
|
+
map.map,
|
|
18
|
+
seq.seq,
|
|
19
|
+
string.string,
|
|
20
|
+
_null.nullTag,
|
|
21
|
+
bool.trueTag,
|
|
22
|
+
bool.falseTag,
|
|
23
|
+
int.intBin,
|
|
24
|
+
int.intOct,
|
|
25
|
+
int.int,
|
|
26
|
+
int.intHex,
|
|
27
|
+
float.floatNaN,
|
|
28
|
+
float.floatExp,
|
|
29
|
+
float.float,
|
|
30
|
+
binary.binary,
|
|
31
|
+
omap.omap,
|
|
32
|
+
pairs.pairs,
|
|
33
|
+
set.set,
|
|
34
|
+
timestamp.intTime,
|
|
35
|
+
timestamp.floatTime,
|
|
36
|
+
timestamp.timestamp
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
exports.schema = schema;
|