@effected/yaml 0.22.0 → 0.24.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/Yaml.js +23 -30
- package/YamlDiagnostic.js +1 -2
- package/YamlDocument.js +125 -51
- package/YamlEdit.js +1 -2
- package/YamlFormat.js +115 -57
- package/YamlLint.js +1 -2
- package/YamlLintRule.js +1 -2
- package/YamlNode.js +1 -2
- package/YamlToken.js +1 -2
- package/YamlVisitor.js +1 -2
- package/index.d.ts +158 -32
- package/internal/composer/anchors.js +1 -2
- package/internal/composer/block.js +1 -2
- package/internal/composer/comments.js +1 -2
- package/internal/composer/document.js +1 -2
- package/internal/composer/flow.js +1 -2
- package/internal/composer/scalars.js +1 -2
- package/internal/composer/state.js +1 -2
- package/internal/composer/tags.js +1 -2
- package/internal/cst-parser.js +1 -2
- package/internal/diagnostics.js +1 -2
- package/internal/diff.js +1 -2
- package/internal/fold.js +1 -2
- package/internal/lexer.js +1 -2
- package/internal/requote.js +1 -2
- package/internal/rules/catalog.js +1 -2
- package/internal/rules/colon-spacing.js +1 -2
- package/internal/rules/comments-spacing.js +1 -2
- package/internal/rules/document-end.js +1 -2
- package/internal/rules/document-start.js +1 -2
- package/internal/rules/empty-lines.js +1 -2
- package/internal/rules/eof-newline.js +1 -2
- package/internal/rules/hyphen-spacing.js +1 -2
- package/internal/rules/indentation.js +1 -2
- package/internal/rules/key-duplicates.js +1 -2
- package/internal/rules/line-length.js +1 -2
- package/internal/rules/parse-validity.js +1 -2
- package/internal/rules/quoted-strings.js +1 -2
- package/internal/rules/trailing-spaces.js +1 -2
- package/internal/rules/truthy.js +1 -2
- package/internal/rules/util.js +1 -2
- package/internal/stringifier.js +1 -2
- package/package.json +1 -1
package/YamlLintRule.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { YamlEdit } from "./YamlEdit.js";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/YamlLintRule.ts
|
|
5
5
|
/**
|
|
6
6
|
* Lint diagnostic severities. `"off"` is a config-level disable only and
|
|
7
7
|
* never reaches a diagnostic — a rule set to `"off"` is not run.
|
|
@@ -81,5 +81,4 @@ var StyleFloor = class extends Schema.TaggedClass()("StyleFloor", {
|
|
|
81
81
|
value: Schema.Number
|
|
82
82
|
}) {};
|
|
83
83
|
|
|
84
|
-
//#endregion
|
|
85
84
|
export { StyleFloor, StyleVote, YamlLintDiagnostic, YamlLintSeverity };
|
package/YamlNode.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option, Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/YamlNode.ts
|
|
4
4
|
/**
|
|
5
5
|
* YAML scalar presentation styles.
|
|
6
6
|
*
|
|
@@ -456,5 +456,4 @@ function nodeToValue(node, anchors, budget, counting = false) {
|
|
|
456
456
|
return null;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
//#endregion
|
|
460
459
|
export { AliasExpansionBudgetExceeded, CollectionStyle, QuoteCompat, QuoteStyle, ScalarChomp, ScalarStyle, YamlAlias, YamlMap, YamlNode, YamlPair, YamlScalar, YamlSeq, aliasExpansionLimit, nodeToJsValue };
|
package/YamlToken.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { lexAll } from "./internal/lexer.js";
|
|
2
2
|
import { Result, Schema, Stream } from "effect";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/YamlToken.ts
|
|
5
5
|
/**
|
|
6
6
|
* The 22 lexical token kinds produced by the YAML tokenizer.
|
|
7
7
|
*
|
|
@@ -139,5 +139,4 @@ var YamlTokens = class YamlTokens {
|
|
|
139
139
|
}
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
//#endregion
|
|
143
142
|
export { YamlToken, YamlTokenKind, YamlTokens };
|
package/YamlVisitor.js
CHANGED
|
@@ -3,7 +3,7 @@ import { composeAllDocuments } from "./internal/composer/document.js";
|
|
|
3
3
|
import { YamlDiagnostic } from "./YamlDiagnostic.js";
|
|
4
4
|
import { Data, Stream } from "effect";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/YamlVisitor.ts
|
|
7
7
|
/**
|
|
8
8
|
* Constructors and matchers for the `YamlVisitorEvent` union (e.g.
|
|
9
9
|
* `YamlVisitorEvent.Scalar({ path, depth, value, style })`,
|
|
@@ -225,5 +225,4 @@ function* walkPair(pair, parentPath, depth) {
|
|
|
225
225
|
if (pair.value !== null) yield* walkNode(pair.value, pairPath, depth + 1);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
//#endregion
|
|
229
228
|
export { YamlVisitor, YamlVisitorEvent };
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Data, Effect, Option, Result, Schema, Stream } from "effect";
|
|
2
|
-
//#region src/YamlDiagnostic.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Error codes emitted by the lexer stage.
|
|
5
4
|
*
|
|
@@ -121,8 +120,6 @@ export declare class YamlDiagnostic extends YamlDiagnostic_base {
|
|
|
121
120
|
readonly length: number;
|
|
122
121
|
}, text: string): YamlDiagnostic;
|
|
123
122
|
}
|
|
124
|
-
//#endregion
|
|
125
|
-
//#region src/Yaml.d.ts
|
|
126
123
|
declare const YamlParseOptions_base: Schema.Class<YamlParseOptions, Schema.Struct<{
|
|
127
124
|
readonly strict: Schema.optionalKey<Schema.Boolean>;
|
|
128
125
|
readonly maxAliasCount: Schema.optionalKey<Schema.Number>;
|
|
@@ -620,8 +617,6 @@ export declare class Yaml {
|
|
|
620
617
|
*/
|
|
621
618
|
static bind<T, E, RD = never, RE = never>(target: Schema.Codec<T, E, RD, RE>): YamlBoundCodec<T, RD, RE>;
|
|
622
619
|
}
|
|
623
|
-
//#endregion
|
|
624
|
-
//#region src/YamlEdit.d.ts
|
|
625
620
|
/**
|
|
626
621
|
* A single path segment: a `string` for mapping keys or a `number` for
|
|
627
622
|
* sequence indices.
|
|
@@ -678,8 +673,6 @@ export declare class YamlEdit extends YamlEdit_base {
|
|
|
678
673
|
*/
|
|
679
674
|
static applyAll(text: string, edits: ReadonlyArray<YamlEdit>): string;
|
|
680
675
|
}
|
|
681
|
-
//#endregion
|
|
682
|
-
//#region src/YamlNode.d.ts
|
|
683
676
|
/**
|
|
684
677
|
* YAML scalar presentation styles.
|
|
685
678
|
*
|
|
@@ -990,8 +983,6 @@ export declare class YamlSeq extends YamlSeq_base {
|
|
|
990
983
|
/** See `YamlScalar.toValue`. Pure and total. */
|
|
991
984
|
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
992
985
|
}
|
|
993
|
-
//#endregion
|
|
994
|
-
//#region src/YamlDocument.d.ts
|
|
995
986
|
declare const YamlDirective_base: Schema.Class<YamlDirective, Schema.Struct<{
|
|
996
987
|
readonly name: Schema.String;
|
|
997
988
|
readonly parameters: Schema.$Array<Schema.String>;
|
|
@@ -1045,11 +1036,39 @@ declare const YamlDocument_base: Schema.Class<YamlDocument, Schema.Struct<{
|
|
|
1045
1036
|
* @public
|
|
1046
1037
|
*/
|
|
1047
1038
|
export declare class YamlDocument extends YamlDocument_base {
|
|
1039
|
+
/**
|
|
1040
|
+
* Synchronous single-document parse, returning a `Result` instead of an
|
|
1041
|
+
* `Effect`. This is the primitive {@link YamlDocument.parse} is defined in
|
|
1042
|
+
* terms of — a synchronous host can call it without an Effect runtime.
|
|
1043
|
+
* Keeps the full AST, directives and recovered diagnostics; fails with the
|
|
1044
|
+
* aggregate {@link YamlParseError} when any fatal-code diagnostic is
|
|
1045
|
+
* present, and non-fatal diagnostics are data on the returned document.
|
|
1046
|
+
*
|
|
1047
|
+
* @example
|
|
1048
|
+
* ```ts
|
|
1049
|
+
* import { YamlDocument } from "@effected/yaml";
|
|
1050
|
+
* import { Result } from "effect";
|
|
1051
|
+
*
|
|
1052
|
+
* const result = YamlDocument.parseResult("name: Alice\n");
|
|
1053
|
+
* if (Result.isSuccess(result)) {
|
|
1054
|
+
* console.log(result.success.toValue()); // => { name: "Alice" }
|
|
1055
|
+
* }
|
|
1056
|
+
* ```
|
|
1057
|
+
*
|
|
1058
|
+
* @param text - The YAML source to parse.
|
|
1059
|
+
* @param options - Optional {@link YamlParseOptions}; defaults apply for
|
|
1060
|
+
* omitted fields.
|
|
1061
|
+
* @returns A `Result` succeeding with the {@link YamlDocument}, or failing
|
|
1062
|
+
* with {@link YamlParseError}.
|
|
1063
|
+
*/
|
|
1064
|
+
static parseResult(text: string, options?: YamlParseOptions): Result.Result<YamlDocument, YamlParseError>;
|
|
1048
1065
|
/**
|
|
1049
1066
|
* Parse a single YAML document, keeping the full AST, directives and
|
|
1050
1067
|
* recovered diagnostics. Fails with the aggregate {@link YamlParseError}
|
|
1051
1068
|
* when any fatal-code diagnostic is present; non-fatal diagnostics are
|
|
1052
|
-
* data on the returned document.
|
|
1069
|
+
* data on the returned document. Defined in terms of
|
|
1070
|
+
* {@link YamlDocument.parseResult} — synchronous callers can use that
|
|
1071
|
+
* variant directly.
|
|
1053
1072
|
*
|
|
1054
1073
|
* @param text - The YAML source to parse.
|
|
1055
1074
|
* @param options - Optional {@link YamlParseOptions}; defaults apply for
|
|
@@ -1058,10 +1077,37 @@ export declare class YamlDocument extends YamlDocument_base {
|
|
|
1058
1077
|
* with {@link YamlParseError}.
|
|
1059
1078
|
*/
|
|
1060
1079
|
static readonly parse: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<YamlDocument, YamlParseError, never>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Synchronous multi-document parse, returning a `Result` instead of an
|
|
1082
|
+
* `Effect` — the primitive {@link YamlDocument.parseAll} is defined in
|
|
1083
|
+
* terms of. Any fatal diagnostic in any document — or a stream-level
|
|
1084
|
+
* directive-placement error — fails the whole parse with one aggregate
|
|
1085
|
+
* {@link YamlParseError}.
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```ts
|
|
1089
|
+
* import { YamlDocument } from "@effected/yaml";
|
|
1090
|
+
* import { Result } from "effect";
|
|
1091
|
+
*
|
|
1092
|
+
* const result = YamlDocument.parseAllResult("a: 1\n---\nb: 2\n");
|
|
1093
|
+
* if (Result.isSuccess(result)) {
|
|
1094
|
+
* console.log(result.success.length); // => 2
|
|
1095
|
+
* }
|
|
1096
|
+
* ```
|
|
1097
|
+
*
|
|
1098
|
+
* @param text - The YAML stream to parse.
|
|
1099
|
+
* @param options - Optional {@link YamlParseOptions}; defaults apply for
|
|
1100
|
+
* omitted fields.
|
|
1101
|
+
* @returns A `Result` succeeding with one {@link YamlDocument} per
|
|
1102
|
+
* document, or failing with {@link YamlParseError}.
|
|
1103
|
+
*/
|
|
1104
|
+
static parseAllResult(text: string, options?: YamlParseOptions): Result.Result<ReadonlyArray<YamlDocument>, YamlParseError>;
|
|
1061
1105
|
/**
|
|
1062
1106
|
* Parse a multi-document YAML stream into one {@link YamlDocument} per
|
|
1063
1107
|
* document. Any fatal diagnostic in any document — or a stream-level
|
|
1064
|
-
* directive-placement error — fails the whole Effect.
|
|
1108
|
+
* directive-placement error — fails the whole Effect. Defined in terms of
|
|
1109
|
+
* {@link YamlDocument.parseAllResult} — synchronous callers can use that
|
|
1110
|
+
* variant directly.
|
|
1065
1111
|
*
|
|
1066
1112
|
* @param text - The YAML stream to parse.
|
|
1067
1113
|
* @param options - Optional {@link YamlParseOptions}; defaults apply for
|
|
@@ -1085,11 +1131,16 @@ export declare class YamlDocument extends YamlDocument_base {
|
|
|
1085
1131
|
static schema(options?: YamlParseOptions): Schema.Codec<YamlDocument, string>;
|
|
1086
1132
|
/**
|
|
1087
1133
|
* Stringify this document (contents, directives and framing) as YAML.
|
|
1088
|
-
* Fails with {@link YamlStringifyError} on
|
|
1089
|
-
*
|
|
1090
|
-
*
|
|
1091
|
-
*
|
|
1092
|
-
*
|
|
1134
|
+
* Fails with {@link YamlStringifyError} (`NestingDepthExceeded`) on a
|
|
1135
|
+
* synthetic AST nested deeper than the stringifier's recursion budget. A
|
|
1136
|
+
* cycle introduced into a synthetic AST fails the same way: the node path
|
|
1137
|
+
* keeps no ancestor set, so the cycle is caught by the depth cap rather
|
|
1138
|
+
* than reported as `CircularReference`. Either way the failure surfaces
|
|
1139
|
+
* through the typed error channel, never as an unhandled stack-overflow
|
|
1140
|
+
* defect.
|
|
1141
|
+
* Defined in terms of {@link YamlDocument.stringifyResult} behind a
|
|
1142
|
+
* `YamlDocument.stringify` span — synchronous callers can use that variant
|
|
1143
|
+
* directly.
|
|
1093
1144
|
*
|
|
1094
1145
|
* @remarks
|
|
1095
1146
|
* `YamlStringifyOptions.lineWidth` is not honored here: column-based
|
|
@@ -1108,6 +1159,39 @@ export declare class YamlDocument extends YamlDocument_base {
|
|
|
1108
1159
|
* {@link YamlStringifyError}.
|
|
1109
1160
|
*/
|
|
1110
1161
|
stringify(options?: YamlStringifyOptions): Effect.Effect<string, YamlStringifyError>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Synchronous stringify, returning a `Result` instead of an `Effect` — the
|
|
1164
|
+
* primitive {@link YamlDocument.stringify} is defined in terms of, so a
|
|
1165
|
+
* synchronous host can round-trip a document parsed with
|
|
1166
|
+
* {@link YamlDocument.parseResult} without an Effect runtime. Fails with
|
|
1167
|
+
* {@link YamlStringifyError} exactly where `stringify` does: a synthetic
|
|
1168
|
+
* AST nested deeper than the stringifier's recursion budget, or one
|
|
1169
|
+
* containing a cycle, both as `NestingDepthExceeded` (the node path keeps
|
|
1170
|
+
* no ancestor set, so a cycle is caught by the depth cap, not reported as
|
|
1171
|
+
* `CircularReference`).
|
|
1172
|
+
*
|
|
1173
|
+
* @remarks
|
|
1174
|
+
* `YamlStringifyOptions.lineWidth` is not honored here, for the reason
|
|
1175
|
+
* given on {@link YamlDocument.stringify}.
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```ts
|
|
1179
|
+
* import { YamlDocument } from "@effected/yaml";
|
|
1180
|
+
* import { Result } from "effect";
|
|
1181
|
+
*
|
|
1182
|
+
* const parsed = YamlDocument.parseResult("# keep\nname: Alice\n");
|
|
1183
|
+
* if (Result.isSuccess(parsed)) {
|
|
1184
|
+
* const text = parsed.success.stringifyResult();
|
|
1185
|
+
* if (Result.isSuccess(text)) console.log(text.success); // => "# keep\nname: Alice\n"
|
|
1186
|
+
* }
|
|
1187
|
+
* ```
|
|
1188
|
+
*
|
|
1189
|
+
* @param options - Optional {@link YamlStringifyOptions}; defaults apply for
|
|
1190
|
+
* omitted fields.
|
|
1191
|
+
* @returns A `Result` succeeding with the YAML text, or failing with
|
|
1192
|
+
* {@link YamlStringifyError}.
|
|
1193
|
+
*/
|
|
1194
|
+
stringifyResult(options?: YamlStringifyOptions): Result.Result<string, YamlStringifyError>;
|
|
1111
1195
|
/**
|
|
1112
1196
|
* Reconstruct the plain JavaScript value of this document's contents,
|
|
1113
1197
|
* resolving anchors and aliases. `null` for an empty document. Pure and
|
|
@@ -1115,8 +1199,6 @@ export declare class YamlDocument extends YamlDocument_base {
|
|
|
1115
1199
|
*/
|
|
1116
1200
|
toValue(): unknown;
|
|
1117
1201
|
}
|
|
1118
|
-
//#endregion
|
|
1119
|
-
//#region src/YamlFormat.d.ts
|
|
1120
1202
|
/**
|
|
1121
1203
|
* A range accepted at the `format`/`formatToString`/etc. call sites: either a
|
|
1122
1204
|
* {@link YamlRange} instance or a plain `{ offset, length }` literal (the two
|
|
@@ -1326,7 +1408,9 @@ export declare class YamlFormat {
|
|
|
1326
1408
|
*/
|
|
1327
1409
|
static formatToString(text: string, range?: YamlRangeLike, options?: YamlFormattingOptions): string;
|
|
1328
1410
|
/**
|
|
1329
|
-
* Compute the edits that insert, replace, or remove a value at `path
|
|
1411
|
+
* Compute the edits that insert, replace, or remove a value at `path`,
|
|
1412
|
+
* synchronously — the primitive {@link YamlFormat.modify} is defined in
|
|
1413
|
+
* terms of, so a synchronous host can call it without an Effect runtime.
|
|
1330
1414
|
* Passing `value === undefined` removes the target key/element; a missing
|
|
1331
1415
|
* insertion target appends after the last pair/element. Fails with
|
|
1332
1416
|
* {@link YamlModificationError} on a fatal parse error or a structural
|
|
@@ -1362,8 +1446,10 @@ export declare class YamlFormat {
|
|
|
1362
1446
|
*
|
|
1363
1447
|
* Two replacement values have no finite rendering and fail typed rather
|
|
1364
1448
|
* than hanging or overflowing the stack: one containing a circular
|
|
1365
|
-
* reference (`CircularReference`) and one
|
|
1366
|
-
* (`NestingDepthExceeded`).
|
|
1449
|
+
* reference (`CircularReference`) and one that would sit deeper than 256
|
|
1450
|
+
* levels in the output document (`NestingDepthExceeded`). The depth is
|
|
1451
|
+
* counted from the document root, so the same value can fit at `[]` and
|
|
1452
|
+
* fail a few keys down.
|
|
1367
1453
|
*
|
|
1368
1454
|
* **Single-document contract.** A `path` carries no document index, so on
|
|
1369
1455
|
* a multi-document stream there is no rule for which document it names —
|
|
@@ -1388,15 +1474,60 @@ export declare class YamlFormat {
|
|
|
1388
1474
|
* target instead.
|
|
1389
1475
|
* @param options - Optional {@link YamlStringifyOptions} for the
|
|
1390
1476
|
* re-stringify step.
|
|
1391
|
-
* @returns
|
|
1392
|
-
* `YamlEdit.applyAll`), or
|
|
1477
|
+
* @returns A `Result` succeeding with the edits to apply (via
|
|
1478
|
+
* `YamlEdit.applyAll`), or failing with {@link YamlModificationError}.
|
|
1393
1479
|
*
|
|
1394
1480
|
* @remarks
|
|
1395
1481
|
* `options` is a bare {@link YamlStringifyOptions} — it controls only the
|
|
1396
1482
|
* internal re-stringify step, not a range (there is no range to restrict
|
|
1397
1483
|
* for a path-targeted modification).
|
|
1398
1484
|
*/
|
|
1485
|
+
static modifyResult(text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions): Result.Result<ReadonlyArray<YamlEdit>, YamlModificationError>;
|
|
1486
|
+
/**
|
|
1487
|
+
* Compute the edits that insert, replace, or remove a value at `path`.
|
|
1488
|
+
* Defined in terms of {@link YamlFormat.modifyResult}, which carries the
|
|
1489
|
+
* full contract — value lowering, region-confined scalar replacement, the
|
|
1490
|
+
* single-document contract and the directive refusal — behind a
|
|
1491
|
+
* `YamlFormat.modify` span; synchronous callers can use that variant
|
|
1492
|
+
* directly.
|
|
1493
|
+
*
|
|
1494
|
+
* @param text - The YAML source to modify.
|
|
1495
|
+
* @param path - The location to insert, replace or remove.
|
|
1496
|
+
* @param value - The JavaScript value to write; `undefined` removes the
|
|
1497
|
+
* target instead.
|
|
1498
|
+
* @param options - Optional {@link YamlStringifyOptions} for the
|
|
1499
|
+
* re-stringify step.
|
|
1500
|
+
* @returns An `Effect` that succeeds with the edits to apply (via
|
|
1501
|
+
* `YamlEdit.applyAll`), or fails with {@link YamlModificationError}.
|
|
1502
|
+
*/
|
|
1399
1503
|
static readonly modify: (text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<readonly YamlEdit[], YamlModificationError, never>;
|
|
1504
|
+
/**
|
|
1505
|
+
* Synchronous {@link YamlFormat.modifyToString}: modify `text` and apply the
|
|
1506
|
+
* resulting edits in one step (`YamlEdit.applyAll ∘ modifyResult`),
|
|
1507
|
+
* returning a `Result`. Inherits the {@link YamlFormat.modifyResult} error
|
|
1508
|
+
* channel.
|
|
1509
|
+
*
|
|
1510
|
+
* @example
|
|
1511
|
+
* ```ts
|
|
1512
|
+
* import { YamlFormat } from "@effected/yaml";
|
|
1513
|
+
* import { Result } from "effect";
|
|
1514
|
+
*
|
|
1515
|
+
* const result = YamlFormat.modifyToStringResult("port: 3000 # dev\n", ["port"], 8080);
|
|
1516
|
+
* if (Result.isSuccess(result)) {
|
|
1517
|
+
* console.log(result.success); // => "port: 8080 # dev\n"
|
|
1518
|
+
* }
|
|
1519
|
+
* ```
|
|
1520
|
+
*
|
|
1521
|
+
* @param text - The YAML source to modify.
|
|
1522
|
+
* @param path - The location to insert, replace or remove.
|
|
1523
|
+
* @param value - The JavaScript value to write; `undefined` removes the
|
|
1524
|
+
* target instead.
|
|
1525
|
+
* @param options - Optional {@link YamlStringifyOptions} for the
|
|
1526
|
+
* re-stringify step.
|
|
1527
|
+
* @returns A `Result` succeeding with the modified text, or failing with
|
|
1528
|
+
* {@link YamlModificationError}.
|
|
1529
|
+
*/
|
|
1530
|
+
static modifyToStringResult(text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions): Result.Result<string, YamlModificationError>;
|
|
1400
1531
|
/**
|
|
1401
1532
|
* Modify `text` and apply the resulting edits in one step
|
|
1402
1533
|
* (`YamlEdit.applyAll ∘ modify`). Inherits the {@link YamlFormat.modify}
|
|
@@ -1412,11 +1543,13 @@ export declare class YamlFormat {
|
|
|
1412
1543
|
* re-stringify step.
|
|
1413
1544
|
* @returns An `Effect` that succeeds with the modified text, or fails with
|
|
1414
1545
|
* {@link YamlModificationError}.
|
|
1546
|
+
*
|
|
1547
|
+
* @remarks
|
|
1548
|
+
* Defined in terms of {@link YamlFormat.modifyToStringResult}; it opens its
|
|
1549
|
+
* own span, with no nested `YamlFormat.modify` child span.
|
|
1415
1550
|
*/
|
|
1416
1551
|
static readonly modifyToString: (text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<string, YamlModificationError, never>;
|
|
1417
1552
|
}
|
|
1418
|
-
//#endregion
|
|
1419
|
-
//#region src/YamlToken.d.ts
|
|
1420
1553
|
/**
|
|
1421
1554
|
* The 22 lexical token kinds produced by the YAML tokenizer.
|
|
1422
1555
|
*
|
|
@@ -1500,8 +1633,6 @@ export declare class YamlTokens {
|
|
|
1500
1633
|
*/
|
|
1501
1634
|
static stream(text: string): Stream.Stream<YamlToken>;
|
|
1502
1635
|
}
|
|
1503
|
-
//#endregion
|
|
1504
|
-
//#region src/YamlLintRule.d.ts
|
|
1505
1636
|
/**
|
|
1506
1637
|
* Lint diagnostic severities. `"off"` is a config-level disable only and
|
|
1507
1638
|
* never reaches a diagnostic — a rule set to `"off"` is not run.
|
|
@@ -1650,8 +1781,6 @@ interface YamlRule {
|
|
|
1650
1781
|
readonly check: (ctx: LintContext, options: unknown) => Iterable<YamlLintDiagnostic>;
|
|
1651
1782
|
readonly infer?: (ctx: LintContext) => Iterable<StyleObservation>;
|
|
1652
1783
|
}
|
|
1653
|
-
//#endregion
|
|
1654
|
-
//#region src/YamlLint.d.ts
|
|
1655
1784
|
/**
|
|
1656
1785
|
* One entry of the config `rules` map: a bare severity literal (the common
|
|
1657
1786
|
* case), `"off"` to disable, or a typed per-rule options object (the tuning
|
|
@@ -1938,8 +2067,6 @@ export declare class YamlLint {
|
|
|
1938
2067
|
*/
|
|
1939
2068
|
static inferLenient(text: string, rules: ReadonlyArray<YamlRule>, base?: YamlLintConfig): YamlLintInference;
|
|
1940
2069
|
}
|
|
1941
|
-
//#endregion
|
|
1942
|
-
//#region src/YamlVisitor.d.ts
|
|
1943
2070
|
/**
|
|
1944
2071
|
* The discriminated union of YAML AST visitor events. Every variant carries
|
|
1945
2072
|
* `path` (segments from the document root) and `depth` (zero-based nesting
|
|
@@ -2561,6 +2688,5 @@ export declare class YamlVisitor {
|
|
|
2561
2688
|
*/
|
|
2562
2689
|
static visit(text: string, options?: YamlParseOptions): Stream.Stream<YamlVisitorEvent>;
|
|
2563
2690
|
}
|
|
2564
|
-
//#endregion
|
|
2565
2691
|
export type { LintContext, LintLine, StyleObservation, YamlAliasEncoded, YamlBoundCodec, YamlLintInference, YamlMapEncoded, YamlPath, YamlRangeLike, YamlRule, YamlScalarEncoded, YamlSegment, YamlSeqEncoded };
|
|
2566
2692
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { YamlAlias } from "../../YamlNode.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/composer/anchors.ts
|
|
4
4
|
/**
|
|
5
5
|
* Check if a pending anchor is being applied to an alias node (invalid in YAML 1.2 §3.2.2).
|
|
6
6
|
* Aliases represent references to existing anchored nodes and cannot have their own anchors.
|
|
@@ -68,5 +68,4 @@ function scanName(text, start) {
|
|
|
68
68
|
return text.slice(start, end);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
//#endregion
|
|
72
71
|
export { checkAnchorOnAlias, getAliasName, getAnchorName, makeAlias, registerAnchor, scanName };
|
|
@@ -4,7 +4,7 @@ import { blankAboveIsKeepChompContent, columnAt, hasBlankLineAbove, isAfterIndic
|
|
|
4
4
|
import { enterNesting, exitNesting, hasMeta, hasNonWhitespaceBeforeOnLine, lineCol, lineIndentColumn, sameLine } from "./state.js";
|
|
5
5
|
import { blockMapStartsWithValueSep, classifyPlainNumeric, collectMultilineKey, collectMultilinePlainScalar, findFirstContent, findLastContent, findNextContentInList, findNextSignificantChild, findValueSepOffset, getScalarStyle, hasValueSepAfterInList, hasValueSepBetween, hasValueSepThroughPlainScalars, makeScalar, resolveScalar, shouldPreserveRaw } from "./scalars.js";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/internal/composer/block.ts
|
|
8
8
|
/**
|
|
9
9
|
* Compose a block map from its CST children, with an optional external first key.
|
|
10
10
|
*
|
|
@@ -1429,5 +1429,4 @@ function composeFlatBlockMap(children, startIdx, parentCst, state, externalFirst
|
|
|
1429
1429
|
return map;
|
|
1430
1430
|
}
|
|
1431
1431
|
|
|
1432
|
-
//#endregion
|
|
1433
1432
|
export { buildPairs, checkDuplicateKeys, checkMultilineImplicitKeys, checkTrailingContentOnSameLine, composeBlockMap, composeBlockSeq, composeFlatBlockMap, flattenBlockMapChildren, keyIdentity };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { YamlAlias, YamlMap, YamlScalar, YamlSeq } from "../../YamlNode.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/composer/comments.ts
|
|
4
4
|
/** True when there is no line break between `start` and `end` in `text`. */
|
|
5
5
|
function sameLineSpan(text, start, end) {
|
|
6
6
|
if (start < 0) return false;
|
|
@@ -220,5 +220,4 @@ function mergedCommentFields(existing, incoming) {
|
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
//#endregion
|
|
224
223
|
export { blankAboveIsKeepChompContent, blankLineAboveStart, columnAt, hasBlankLineAbove, hasBlankLineBelow, isAfterIndicatorOnly, isOwnLineAt, joinComments, rawCommentText, sameLineSpan, withCommentFields };
|
|
@@ -8,7 +8,7 @@ import { collectMultilinePlainScalar, findNextContentChild, getScalarStyle, hasB
|
|
|
8
8
|
import { composeBlockMap, composeBlockSeq, composeFlatBlockMap } from "./block.js";
|
|
9
9
|
import { composeFlowMap, composeFlowSeq } from "./flow.js";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// src/internal/composer/document.ts
|
|
12
12
|
/** The flow-composer dispatch wired into every state this module creates. */
|
|
13
13
|
const FLOW = {
|
|
14
14
|
composeFlowMap,
|
|
@@ -798,5 +798,4 @@ function stripOwnComment(node) {
|
|
|
798
798
|
});
|
|
799
799
|
}
|
|
800
800
|
|
|
801
|
-
//#endregion
|
|
802
801
|
export { EMPTY_DOCUMENT, composeAllDocuments, composeDocument, composeFirstDocument, composeFirstDocumentCounted, validateCrossDocumentDirectives };
|
|
@@ -5,7 +5,7 @@ import { enterNesting, exitNesting, hasMeta } from "./state.js";
|
|
|
5
5
|
import { collectMultilineKey, collectMultilinePlainScalar, getScalarStyle, hasValueSepThroughPlainScalars, makeScalar, resolveScalar } from "./scalars.js";
|
|
6
6
|
import { buildPairs, checkDuplicateKeys, checkMultilineImplicitKeys } from "./block.js";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// src/internal/composer/flow.ts
|
|
9
9
|
/**
|
|
10
10
|
* Validate that flow collection entries are separated by commas.
|
|
11
11
|
*
|
|
@@ -495,5 +495,4 @@ function composeFlowSeqInner(cst, state, meta, parentBlockColumn) {
|
|
|
495
495
|
return seq;
|
|
496
496
|
}
|
|
497
497
|
|
|
498
|
-
//#endregion
|
|
499
498
|
export { composeFlowMap, composeFlowSeq, flattenFlowChildren };
|
|
@@ -4,7 +4,7 @@ import { rawCommentText } from "./comments.js";
|
|
|
4
4
|
import { lineCol } from "./state.js";
|
|
5
5
|
import { resolveTagHandle } from "./tags.js";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/internal/composer/scalars.ts
|
|
8
8
|
const NULL_RE = /^(?:null|Null|NULL|~)$/;
|
|
9
9
|
const TRUE_RE = /^(?:true|True|TRUE)$/;
|
|
10
10
|
const FALSE_RE = /^(?:false|False|FALSE)$/;
|
|
@@ -930,5 +930,4 @@ function shouldPreserveRaw(rawValue, value) {
|
|
|
930
930
|
return false;
|
|
931
931
|
}
|
|
932
932
|
|
|
933
|
-
//#endregion
|
|
934
933
|
export { blockMapStartsWithValueSep, classifyPlainNumeric, collectMultilineKey, collectMultilinePlainScalar, findFirstContent, findLastContent, findNextContentChild, findNextContentInList, findNextSignificantChild, findValueSepOffset, foldFlowLines, getBlockChomp, getBlockIndent, getScalarStyle, getScalarValue, hasBlockMapAfterInList, hasValueSepAfter, hasValueSepAfterInList, hasValueSepBetween, hasValueSepThroughPlainScalars, indexOfChild, makeScalar, resolveScalar, shouldPreserveRaw };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/composer/state.ts
|
|
2
2
|
let lineStartsText;
|
|
3
3
|
let lineStartsCache = [];
|
|
4
4
|
function getLineStarts(text) {
|
|
@@ -134,5 +134,4 @@ function exitNesting(state) {
|
|
|
134
134
|
state.depth--;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
//#endregion
|
|
138
137
|
export { clearMeta, commentProps, createState, enterNesting, exitNesting, getLineStarts, hasMeta, hasNonWhitespaceBeforeOnLine, lineCol, lineIndentColumn, sameLine };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/composer/tags.ts
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a tag shorthand using the document's %TAG directives.
|
|
4
4
|
* For example, with `%TAG !! tag:example.com,2000:app/`, the tag `!!int`
|
|
@@ -84,5 +84,4 @@ function validateTagHandlesInDocument(docCst, state) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
//#endregion
|
|
88
87
|
export { parseDirective, resolveTagHandle, validateTagHandlesInDocument };
|
package/internal/cst-parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { lexAll } from "./lexer.js";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/internal/cst-parser.ts
|
|
4
4
|
/**
|
|
5
5
|
* Hardening: cap CST nesting so hostile inputs cannot overflow the stack
|
|
6
6
|
* while the tree is being BUILT. Set slightly above the composer's
|
|
@@ -721,5 +721,4 @@ function parseCSTAll(text) {
|
|
|
721
721
|
return parseDocuments(lexAll(text), text);
|
|
722
722
|
}
|
|
723
723
|
|
|
724
|
-
//#endregion
|
|
725
724
|
export { parseCSTAll };
|
package/internal/diagnostics.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/diagnostics.ts
|
|
2
2
|
/** Error codes emitted by the lexer stage. */
|
|
3
3
|
const YAML_LEX_ERROR_CODES = [
|
|
4
4
|
"UnexpectedCharacter",
|
|
@@ -93,5 +93,4 @@ function isFatalCode(code) {
|
|
|
93
93
|
return FATAL_CODES.has(code);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
//#endregion
|
|
97
96
|
export { FATAL_CODES, YAML_COMPOSE_ERROR_CODES, YAML_LEX_ERROR_CODES, YAML_MODIFY_ERROR_CODES, YAML_PARSE_ERROR_CODES, YAML_STRINGIFY_ERROR_CODES, isFatalCode };
|
package/internal/diff.js
CHANGED
package/internal/fold.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/fold.ts
|
|
2
2
|
/**
|
|
3
3
|
* Column-based line folding for a single logical scalar line (YAML 1.2 flow
|
|
4
4
|
* folding, §7.3 / §8.2.1). Breaks the content at "safe" single-space
|
|
@@ -246,5 +246,4 @@ function renderBlockFolded(s, indent, explicitChomp, explicitIndent) {
|
|
|
246
246
|
return `>${indentIndicator}${chomp}\n${outputLines.join("\n")}`;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
//#endregion
|
|
250
249
|
export { foldRenderedScalar, foldScalarLine, hasInteriorTrailingWhitespace, hasNewlineSpacesTab, isControlChar, renderBlockFolded, renderBlockLiteral, renderSingleQuotedMultiline };
|
package/internal/lexer.js
CHANGED
package/internal/requote.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isControlChar } from "./fold.js";
|
|
2
2
|
import { renderDoubleQuoted, renderSingleQuoted } from "./stringifier.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/internal/requote.ts
|
|
5
5
|
/**
|
|
6
6
|
* True when `value` can be carried by a single-quoted flow scalar on one
|
|
7
7
|
* line. Single-quoted style has exactly one escape (`''`), so any character
|
|
@@ -44,5 +44,4 @@ function requoteScalarText(text, scalar, quote, mode) {
|
|
|
44
44
|
return renderSingleQuoted(scalar.value);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
//#endregion
|
|
48
47
|
export { requoteScalarText };
|
|
@@ -13,7 +13,7 @@ import { quotedStrings, quotedStringsOptions } from "./quoted-strings.js";
|
|
|
13
13
|
import { trailingSpaces, trailingSpacesOptions } from "./trailing-spaces.js";
|
|
14
14
|
import { truthy, truthyOptions } from "./truthy.js";
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// src/internal/rules/catalog.ts
|
|
17
17
|
const catalog = [
|
|
18
18
|
[parseValidity, parseValidityOptions],
|
|
19
19
|
[lineLength, lineLengthOptions],
|
|
@@ -35,5 +35,4 @@ const builtinRules = catalog.map(([rule]) => rule);
|
|
|
35
35
|
/** Per-rule options schemas — the rule-aware half of config validation. */
|
|
36
36
|
const builtinOptionsSchemas = new Map(catalog.map(([rule, options]) => [rule.id, options]));
|
|
37
37
|
|
|
38
|
-
//#endregion
|
|
39
38
|
export { builtinOptionsSchemas, builtinRules };
|
|
@@ -3,7 +3,7 @@ import { YamlLintDiagnostic, YamlLintSeverity } from "../../YamlLintRule.js";
|
|
|
3
3
|
import { nonNegativeIntegerOption, positiveIntegerOption } from "./util.js";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/internal/rules/colon-spacing.ts
|
|
7
7
|
/**
|
|
8
8
|
* Options for `colon-spacing`: `maxSpacesBefore` (default 0) and
|
|
9
9
|
* `maxSpacesAfter` (default 1) around the `:` indicator. `maxSpacesBefore: 0`
|
|
@@ -73,5 +73,4 @@ const colonSpacing = {
|
|
|
73
73
|
}
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
//#endregion
|
|
77
76
|
export { colonSpacing, colonSpacingOptions };
|
|
@@ -3,7 +3,7 @@ import { StyleVote, YamlLintDiagnostic, YamlLintSeverity } from "../../YamlLintR
|
|
|
3
3
|
import { nonNegativeIntegerOption } from "./util.js";
|
|
4
4
|
import { Schema } from "effect";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/internal/rules/comments-spacing.ts
|
|
7
7
|
/**
|
|
8
8
|
* Options for `comments-spacing`: `minSpacesBefore` between content and a
|
|
9
9
|
* trailing `#` (default 1 — the kit's own emission spelling) and
|
|
@@ -103,5 +103,4 @@ const commentsSpacing = {
|
|
|
103
103
|
}
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
//#endregion
|
|
107
106
|
export { commentsSpacing, commentsSpacingOptions };
|
|
@@ -2,7 +2,7 @@ import { YamlEdit } from "../../YamlEdit.js";
|
|
|
2
2
|
import { StyleVote, YamlLintDiagnostic, YamlLintSeverity } from "../../YamlLintRule.js";
|
|
3
3
|
import { Schema } from "effect";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/internal/rules/document-end.ts
|
|
6
6
|
/** Options for `document-end`: require (`true`, default) or forbid the marker. */
|
|
7
7
|
const documentEndOptions = Schema.Struct({
|
|
8
8
|
severity: Schema.optionalKey(YamlLintSeverity),
|
|
@@ -91,5 +91,4 @@ const documentEnd = {
|
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
//#endregion
|
|
95
94
|
export { documentEnd, documentEndOptions };
|