@effected/yaml 0.1.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/LICENSE +21 -0
- package/README.md +111 -0
- package/Yaml.js +414 -0
- package/YamlDiagnostic.js +126 -0
- package/YamlDocument.js +181 -0
- package/YamlEdit.js +45 -0
- package/YamlFormat.js +309 -0
- package/YamlNode.js +396 -0
- package/YamlVisitor.js +172 -0
- package/index.d.ts +1331 -0
- package/index.js +9 -0
- package/internal/composer/anchors.js +97 -0
- package/internal/composer/block.js +1155 -0
- package/internal/composer/document.js +677 -0
- package/internal/composer/flow.js +400 -0
- package/internal/composer/scalars.js +885 -0
- package/internal/composer/state.js +117 -0
- package/internal/composer/tags.js +88 -0
- package/internal/cst-parser.js +716 -0
- package/internal/diagnostics.js +80 -0
- package/internal/diff.js +56 -0
- package/internal/fold.js +153 -0
- package/internal/lexer.js +959 -0
- package/internal/stringifier.js +797 -0
- package/package.json +47 -0
- package/tsdoc-metadata.json +11 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1331 @@
|
|
|
1
|
+
import { Data, Effect, Option, Schema, Stream } from "effect";
|
|
2
|
+
//#region src/YamlDiagnostic.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Error codes emitted by the lexer stage.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
declare const YamlLexErrorCode: Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>;
|
|
9
|
+
/**
|
|
10
|
+
* The union of all lexer-stage error code string literals.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
type YamlLexErrorCode = typeof YamlLexErrorCode.Type;
|
|
15
|
+
/**
|
|
16
|
+
* Error codes emitted by the CST-parser stage.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
declare const YamlParseErrorCode: Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>;
|
|
21
|
+
/**
|
|
22
|
+
* The union of all parser-stage error code string literals.
|
|
23
|
+
*
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
type YamlParseErrorCode = typeof YamlParseErrorCode.Type;
|
|
27
|
+
/**
|
|
28
|
+
* Error codes emitted by the composer stage.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
declare const YamlComposerErrorCode: Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>;
|
|
33
|
+
/**
|
|
34
|
+
* The union of all composer-stage error code string literals.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
type YamlComposerErrorCode = typeof YamlComposerErrorCode.Type;
|
|
39
|
+
/**
|
|
40
|
+
* Error codes emitted by the stringifier (the circular-reference guard).
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
declare const YamlStringifyErrorCode: Schema.Literals<readonly ["CircularReference"]>;
|
|
45
|
+
/**
|
|
46
|
+
* The union of all stringifier-stage error code string literals.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
type YamlStringifyErrorCode = typeof YamlStringifyErrorCode.Type;
|
|
51
|
+
/**
|
|
52
|
+
* Error codes emitted by `YamlFormat.modify`'s path navigation against an
|
|
53
|
+
* already-composed AST — not raised by the parser/composer/stringifier.
|
|
54
|
+
*
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
declare const YamlModifyErrorCode: Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable"]>;
|
|
58
|
+
/**
|
|
59
|
+
* The union of all modify-stage error code string literals.
|
|
60
|
+
*
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
type YamlModifyErrorCode = typeof YamlModifyErrorCode.Type;
|
|
64
|
+
/**
|
|
65
|
+
* Union of all YAML error codes across all pipeline stages. Stage
|
|
66
|
+
* discrimination lives here (in the code), not in separate error classes.
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
declare const YamlErrorCode: Schema.Union<readonly [Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>, Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>, Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>, Schema.Literals<readonly ["CircularReference"]>, Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable"]>]>;
|
|
71
|
+
/**
|
|
72
|
+
* The union of all YAML error code string literals.
|
|
73
|
+
*
|
|
74
|
+
* @public
|
|
75
|
+
*/
|
|
76
|
+
type YamlErrorCode = typeof YamlErrorCode.Type;
|
|
77
|
+
declare const YamlDiagnostic_base: Schema.Class<YamlDiagnostic, Schema.Struct<{
|
|
78
|
+
readonly code: Schema.Union<readonly [Schema.Literals<readonly ["UnexpectedCharacter", "UnterminatedString", "InvalidEscapeSequence", "InvalidUnicode", "UnterminatedBlockScalar", "UnterminatedFlowCollection", "InvalidDirective", "InvalidTagHandle", "InvalidAnchorName", "UnexpectedByteOrderMark"]>, Schema.Literals<readonly ["InvalidIndentation", "DuplicateKey", "UnexpectedToken", "MissingValue", "MissingKey", "TabIndentation", "InvalidBlockStructure", "MalformedFlowCollection", "NestingDepthExceeded"]>, Schema.Literals<readonly ["UndefinedAlias", "DuplicateAnchor", "CircularAlias", "UnresolvedTag", "InvalidTagValue", "AliasCountExceeded", "InvalidDirective"]>, Schema.Literals<readonly ["CircularReference"]>, Schema.Literals<readonly ["EmptyDocument", "PathNotFound", "InvalidIndex", "NotNavigable"]>]>;
|
|
79
|
+
readonly message: Schema.String;
|
|
80
|
+
readonly offset: Schema.Number;
|
|
81
|
+
readonly length: Schema.Number;
|
|
82
|
+
readonly line: Schema.Number;
|
|
83
|
+
readonly character: Schema.Number;
|
|
84
|
+
}>, {}>;
|
|
85
|
+
/**
|
|
86
|
+
* One structured diagnostic: its {@link (YamlErrorCode:type)}, a
|
|
87
|
+
* human-readable `message`, and its exact position (`offset`/`length`, plus
|
|
88
|
+
* zero-based `line`/`character`). Used for both errors and warnings-as-data;
|
|
89
|
+
* fatality is a property of the code — see {@link YamlDiagnostic.isFatal}.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* The five-field positional core (`code`/`offset`/`length`/`line`/`character`)
|
|
93
|
+
* is structurally identical to `@effected/jsonc`'s parse-error detail shape;
|
|
94
|
+
* `message` is this package's additive extra.
|
|
95
|
+
*
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
declare class YamlDiagnostic extends YamlDiagnostic_base {
|
|
99
|
+
/**
|
|
100
|
+
* The single fatal-code predicate: whether diagnostics with this code
|
|
101
|
+
* abort a parse (vs. being recoverable warnings-as-data). Declared once,
|
|
102
|
+
* as a property of the code — replacing the v3 source's three
|
|
103
|
+
* subtly-differing inline fatal lists.
|
|
104
|
+
*/
|
|
105
|
+
static isFatal(code: YamlErrorCode): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Materialize a raw engine diagnostic record into a `YamlDiagnostic`,
|
|
108
|
+
* deriving `line`/`character` from `offset` against the source `text`.
|
|
109
|
+
* Advanced — the parse/stringify entry points call this for you.
|
|
110
|
+
*/
|
|
111
|
+
static fromRaw(raw: {
|
|
112
|
+
readonly code: YamlErrorCode;
|
|
113
|
+
readonly message: string;
|
|
114
|
+
readonly offset: number;
|
|
115
|
+
readonly length: number;
|
|
116
|
+
}, text: string): YamlDiagnostic;
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/Yaml.d.ts
|
|
120
|
+
declare const YamlParseOptions_base: Schema.Class<YamlParseOptions, Schema.Struct<{
|
|
121
|
+
readonly strict: Schema.optionalKey<Schema.Boolean>;
|
|
122
|
+
readonly maxAliasCount: Schema.optionalKey<Schema.Number>;
|
|
123
|
+
readonly uniqueKeys: Schema.optionalKey<Schema.Boolean>;
|
|
124
|
+
}>, {}>;
|
|
125
|
+
/**
|
|
126
|
+
* Options controlling parse behavior. All fields are omissible; absent fields
|
|
127
|
+
* resolve to `strict` `true`, `maxAliasCount` `100` (the alias-based
|
|
128
|
+
* denial-of-service guard) and `uniqueKeys` `true` (duplicate mapping keys
|
|
129
|
+
* are errors).
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
declare class YamlParseOptions extends YamlParseOptions_base {}
|
|
134
|
+
declare const YamlStringifyOptions_base: Schema.Class<YamlStringifyOptions, Schema.Struct<{
|
|
135
|
+
readonly indent: Schema.optionalKey<Schema.Number>;
|
|
136
|
+
readonly lineWidth: Schema.optionalKey<Schema.Number>;
|
|
137
|
+
readonly defaultScalarStyle: Schema.optionalKey<Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>>;
|
|
138
|
+
readonly defaultCollectionStyle: Schema.optionalKey<Schema.Literals<readonly ["block", "flow"]>>;
|
|
139
|
+
readonly sortKeys: Schema.optionalKey<Schema.Boolean>;
|
|
140
|
+
readonly finalNewline: Schema.optionalKey<Schema.Boolean>;
|
|
141
|
+
readonly forceDefaultStyles: Schema.optionalKey<Schema.Boolean>;
|
|
142
|
+
}>, {}>;
|
|
143
|
+
/**
|
|
144
|
+
* Options controlling stringify behavior. All fields are omissible; absent
|
|
145
|
+
* fields resolve to `indent` `2`, `lineWidth` `80`, `defaultScalarStyle`
|
|
146
|
+
* `"plain"`, `defaultCollectionStyle` `"block"`, `sortKeys` `false`,
|
|
147
|
+
* `finalNewline` `true` and `forceDefaultStyles` `false`.
|
|
148
|
+
*
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
declare class YamlStringifyOptions extends YamlStringifyOptions_base {}
|
|
152
|
+
declare const YamlParseError_base: Schema.Class<YamlParseError, Schema.TaggedStruct<"YamlParseError", {
|
|
153
|
+
readonly diagnostics: Schema.$Array<typeof YamlDiagnostic>;
|
|
154
|
+
readonly input: Schema.String;
|
|
155
|
+
}>, import("effect/Cause").YieldableError>;
|
|
156
|
+
/**
|
|
157
|
+
* Error-recovery parse failure: aggregates every fatal {@link YamlDiagnostic}
|
|
158
|
+
* encountered, so a single failure reports the whole batch. Raised by
|
|
159
|
+
* {@link Yaml.parse}, {@link Yaml.parseAll}, `YamlDocument.parse`/`parseAll`
|
|
160
|
+
* and the decode direction of the schema factories.
|
|
161
|
+
*
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
declare class YamlParseError extends YamlParseError_base {
|
|
165
|
+
get message(): string;
|
|
166
|
+
}
|
|
167
|
+
declare const YamlStringifyError_base: Schema.Class<YamlStringifyError, Schema.TaggedStruct<"YamlStringifyError", {
|
|
168
|
+
readonly diagnostics: Schema.$Array<typeof YamlDiagnostic>;
|
|
169
|
+
readonly value: Schema.Unknown;
|
|
170
|
+
}>, import("effect/Cause").YieldableError>;
|
|
171
|
+
/**
|
|
172
|
+
* Stringification failure (the circular-reference guard), carrying structured
|
|
173
|
+
* {@link YamlDiagnostic} entries and the offending value. Raised by
|
|
174
|
+
* {@link Yaml.stringify}, `YamlDocument#stringify` and the encode direction of
|
|
175
|
+
* the schema factories.
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
declare class YamlStringifyError extends YamlStringifyError_base {
|
|
180
|
+
get message(): string;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Static entry points for YAML parsing, stringification, comment stripping,
|
|
184
|
+
* semantic equality and the schema factories. Not instantiable.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* `parse`/`parseAll`/`stringify` and the schema factories carry real typed
|
|
188
|
+
* error channels — including the hardening guards (an alias-expansion budget
|
|
189
|
+
* on decode, a nesting-depth cap on encode) that keep malformed or
|
|
190
|
+
* adversarial input on the typed channel instead of surfacing as an unhandled
|
|
191
|
+
* defect. `stripComments`/`equals`/`equalsValue` are pure total functions.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* import { Yaml } from "@effected/yaml";
|
|
196
|
+
* import { Effect } from "effect";
|
|
197
|
+
*
|
|
198
|
+
* const program = Effect.gen(function* () {
|
|
199
|
+
* const value = yield* Yaml.parse("name: Alice\nage: 30");
|
|
200
|
+
* return value; // { name: "Alice", age: 30 }
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
declare class Yaml {
|
|
207
|
+
private constructor();
|
|
208
|
+
/**
|
|
209
|
+
* Parse a single YAML document into a plain JavaScript value, resolving
|
|
210
|
+
* anchors and aliases. Error-recovery parsing: collects every fatal
|
|
211
|
+
* diagnostic and fails once with the aggregate {@link YamlParseError}.
|
|
212
|
+
* Returns `unknown`, never `any`.
|
|
213
|
+
*
|
|
214
|
+
* A "billion laughs" alias-expansion blow-up (an alias chain whose
|
|
215
|
+
* resolved size grows exponentially relative to `maxAliasCount`) also
|
|
216
|
+
* fails through {@link YamlParseError} with an `AliasCountExceeded`
|
|
217
|
+
* diagnostic, never as an unhandled defect.
|
|
218
|
+
*/
|
|
219
|
+
static readonly parse: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<unknown, YamlParseError, never>;
|
|
220
|
+
/**
|
|
221
|
+
* Parse a multi-document YAML stream into an array of plain JavaScript
|
|
222
|
+
* values (one per document, in order). Any fatal diagnostic in any
|
|
223
|
+
* document — or a stream-level directive-placement error — fails the
|
|
224
|
+
* whole Effect with the aggregate {@link YamlParseError}.
|
|
225
|
+
*
|
|
226
|
+
* A "billion laughs" alias-expansion blow-up in any document also fails
|
|
227
|
+
* through {@link YamlParseError} with an `AliasCountExceeded` diagnostic,
|
|
228
|
+
* never as an unhandled defect.
|
|
229
|
+
*/
|
|
230
|
+
static readonly parseAll: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<readonly unknown[], YamlParseError, never>;
|
|
231
|
+
/**
|
|
232
|
+
* Stringify a plain JavaScript value as YAML. Fails with
|
|
233
|
+
* {@link YamlStringifyError} on circular references (`CircularReference`)
|
|
234
|
+
* or on a value nested deeper than the stringifier's recursion budget
|
|
235
|
+
* (`NestingDepthExceeded`) — both surface through the typed error channel
|
|
236
|
+
* rather than as an unhandled stack-overflow defect.
|
|
237
|
+
*/
|
|
238
|
+
static readonly stringify: (value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<string, YamlStringifyError, never>;
|
|
239
|
+
/**
|
|
240
|
+
* Strip comments from YAML text. Without `replaceCh`, comment characters
|
|
241
|
+
* are removed (line breaks are kept, so line numbers stay stable); with a
|
|
242
|
+
* `replaceCh` (e.g. `" "`), each comment character is replaced instead,
|
|
243
|
+
* keeping all offsets stable. Quote-aware: `#` inside quoted scalars is
|
|
244
|
+
* content, not a comment. Pure and total.
|
|
245
|
+
*/
|
|
246
|
+
static stripComments(text: string, replaceCh?: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* Compare two YAML strings for semantic equality: comments, whitespace,
|
|
249
|
+
* formatting and mapping key order are ignored; sequence order is
|
|
250
|
+
* significant. Malformed input is never equal to anything — parse errors
|
|
251
|
+
* (or duplicate keys) on either side yield `false` rather than comparing
|
|
252
|
+
* recovery-parser artifacts. Pure and total.
|
|
253
|
+
*/
|
|
254
|
+
static equals(a: string, b: string): boolean;
|
|
255
|
+
/**
|
|
256
|
+
* Compare a YAML string against an existing JavaScript value with the
|
|
257
|
+
* same semantics as {@link Yaml.equals}: malformed `text` yields `false`.
|
|
258
|
+
* Pure and total.
|
|
259
|
+
*/
|
|
260
|
+
static equalsValue(text: string, value: unknown): boolean;
|
|
261
|
+
/**
|
|
262
|
+
* A `Schema<unknown, string>` decoding a single YAML document with the
|
|
263
|
+
* given `options` (defaults when omitted) and encoding values back to
|
|
264
|
+
* YAML text with default stringify options.
|
|
265
|
+
*
|
|
266
|
+
* Schema-producing: each call returns a fresh schema whose derivation
|
|
267
|
+
* caches are not shared across calls. Bind the result to a `const` on hot
|
|
268
|
+
* paths; for the default-options case use {@link Yaml.YamlFromString}.
|
|
269
|
+
*/
|
|
270
|
+
static fromString(options?: YamlParseOptions): Schema.Codec<unknown, string>;
|
|
271
|
+
/**
|
|
272
|
+
* The zero-config `Schema<unknown, string>` — `Yaml.fromString()` with
|
|
273
|
+
* default options, pre-bound so the common case needs no memoization
|
|
274
|
+
* discipline.
|
|
275
|
+
*/
|
|
276
|
+
static readonly YamlFromString: Schema.Codec<unknown, string>;
|
|
277
|
+
/**
|
|
278
|
+
* A `Schema<ReadonlyArray<unknown>, string>` decoding a multi-document
|
|
279
|
+
* YAML stream into one value per document, and encoding an array of
|
|
280
|
+
* values back into a `---`-separated stream.
|
|
281
|
+
*
|
|
282
|
+
* Schema-producing: bind the result to a `const` on hot paths (see
|
|
283
|
+
* {@link Yaml.fromString}).
|
|
284
|
+
*/
|
|
285
|
+
static allFromString(options?: YamlParseOptions): Schema.Codec<ReadonlyArray<unknown>, string>;
|
|
286
|
+
/**
|
|
287
|
+
* Compose {@link Yaml.fromString} with a target schema, yielding a
|
|
288
|
+
* `Schema<A, string>` that decodes YAML straight into a validated domain
|
|
289
|
+
* value — the single best consumer-facing feature of the library. The
|
|
290
|
+
* target's decoding/encoding service requirements flow through.
|
|
291
|
+
*
|
|
292
|
+
* Schema-producing: bind the result to a `const` on hot paths (see
|
|
293
|
+
* {@link Yaml.fromString}).
|
|
294
|
+
*/
|
|
295
|
+
static schema<T, E, RD = never, RE = never>(target: Schema.Codec<T, E, RD, RE>, options?: YamlParseOptions): Schema.Codec<T, string, RD, RE>;
|
|
296
|
+
}
|
|
297
|
+
//#endregion
|
|
298
|
+
//#region src/YamlEdit.d.ts
|
|
299
|
+
/**
|
|
300
|
+
* A single path segment: a `string` for mapping keys or a `number` for
|
|
301
|
+
* sequence indices.
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
*/
|
|
305
|
+
type YamlSegment = string | number;
|
|
306
|
+
/**
|
|
307
|
+
* An ordered sequence of {@link (YamlSegment:type)} values describing a
|
|
308
|
+
* location within a YAML document tree.
|
|
309
|
+
*
|
|
310
|
+
* @public
|
|
311
|
+
*/
|
|
312
|
+
type YamlPath = ReadonlyArray<YamlSegment>;
|
|
313
|
+
declare const YamlRange_base: Schema.Class<YamlRange, Schema.Struct<{
|
|
314
|
+
readonly offset: Schema.Number;
|
|
315
|
+
readonly length: Schema.Number;
|
|
316
|
+
}>, {}>;
|
|
317
|
+
/**
|
|
318
|
+
* A range within a YAML document, expressed as a zero-based character
|
|
319
|
+
* `offset` and a `length` in UTF-16 code units. Pass to `YamlFormat.format`
|
|
320
|
+
* to restrict formatting to a region.
|
|
321
|
+
*
|
|
322
|
+
* @public
|
|
323
|
+
*/
|
|
324
|
+
declare class YamlRange extends YamlRange_base {}
|
|
325
|
+
declare const YamlEdit_base: Schema.Class<YamlEdit, Schema.Struct<{
|
|
326
|
+
readonly offset: Schema.Number;
|
|
327
|
+
readonly length: Schema.Number;
|
|
328
|
+
readonly content: Schema.String;
|
|
329
|
+
}>, {}>;
|
|
330
|
+
/**
|
|
331
|
+
* A non-mutating text edit: replace the span `[offset, offset + length)` with
|
|
332
|
+
* `content`. Set `length` to `0` to insert, `content` to `""` to delete.
|
|
333
|
+
*
|
|
334
|
+
* @remarks
|
|
335
|
+
* Structurally identical to `@effected/jsonc`'s edit shape (same field names,
|
|
336
|
+
* types and semantics) per the jsonc/yaml parity convention, so consumer code
|
|
337
|
+
* can be written once over "a document codec's Edit/Range/Path".
|
|
338
|
+
*
|
|
339
|
+
* @public
|
|
340
|
+
*/
|
|
341
|
+
declare class YamlEdit extends YamlEdit_base {
|
|
342
|
+
/**
|
|
343
|
+
* Apply `edits` to `text`, producing a new string. Edits are applied in
|
|
344
|
+
* reverse-offset order so earlier offsets stay valid; the input `edits`
|
|
345
|
+
* array is not mutated. Pure and total.
|
|
346
|
+
*/
|
|
347
|
+
static applyAll(text: string, edits: ReadonlyArray<YamlEdit>): string;
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/YamlNode.d.ts
|
|
351
|
+
/**
|
|
352
|
+
* YAML scalar presentation styles.
|
|
353
|
+
*
|
|
354
|
+
* @public
|
|
355
|
+
*/
|
|
356
|
+
declare const ScalarStyle: Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>;
|
|
357
|
+
/**
|
|
358
|
+
* The union of all scalar style string literals.
|
|
359
|
+
*
|
|
360
|
+
* @public
|
|
361
|
+
*/
|
|
362
|
+
type ScalarStyle = typeof ScalarStyle.Type;
|
|
363
|
+
/**
|
|
364
|
+
* YAML collection presentation styles.
|
|
365
|
+
*
|
|
366
|
+
* @public
|
|
367
|
+
*/
|
|
368
|
+
declare const CollectionStyle: Schema.Literals<readonly ["block", "flow"]>;
|
|
369
|
+
/**
|
|
370
|
+
* The union of all collection style string literals.
|
|
371
|
+
*
|
|
372
|
+
* @public
|
|
373
|
+
*/
|
|
374
|
+
type CollectionStyle = typeof CollectionStyle.Type;
|
|
375
|
+
/**
|
|
376
|
+
* Block-scalar chomping indicators (`-` strip, default clip, `+` keep).
|
|
377
|
+
* Referenced by the {@link YamlScalar} `chomp` field schema.
|
|
378
|
+
*
|
|
379
|
+
* @public
|
|
380
|
+
*/
|
|
381
|
+
declare const ScalarChomp: Schema.Literals<readonly ["strip", "clip", "keep"]>;
|
|
382
|
+
/**
|
|
383
|
+
* The union of all block-scalar chomping indicator string literals.
|
|
384
|
+
*
|
|
385
|
+
* @public
|
|
386
|
+
*/
|
|
387
|
+
type ScalarChomp = typeof ScalarChomp.Type;
|
|
388
|
+
declare const YamlScalar_base: Schema.Class<YamlScalar, Schema.TaggedStruct<"YamlScalar", {
|
|
389
|
+
readonly value: Schema.Unknown;
|
|
390
|
+
readonly tag: Schema.optionalKey<Schema.String>;
|
|
391
|
+
readonly style: Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>;
|
|
392
|
+
readonly anchor: Schema.optionalKey<Schema.String>;
|
|
393
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
394
|
+
readonly chomp: Schema.optionalKey<Schema.Literals<readonly ["strip", "clip", "keep"]>>;
|
|
395
|
+
readonly raw: Schema.optionalKey<Schema.String>;
|
|
396
|
+
readonly sourceMultiline: Schema.optionalKey<Schema.Boolean>;
|
|
397
|
+
readonly offset: Schema.Number;
|
|
398
|
+
readonly length: Schema.Number;
|
|
399
|
+
}>, {}>;
|
|
400
|
+
/**
|
|
401
|
+
* A YAML scalar AST node, representing a leaf value such as a string,
|
|
402
|
+
* number, boolean, or null.
|
|
403
|
+
*
|
|
404
|
+
* - `value` — the resolved JavaScript value (null, boolean, number, bigint or
|
|
405
|
+
* string).
|
|
406
|
+
* - `style` — the scalar presentation style in the source document.
|
|
407
|
+
* - `tag` — optional explicit YAML tag (e.g. `!!str`, `!!int`).
|
|
408
|
+
* - `anchor` — optional anchor name for aliasing.
|
|
409
|
+
* - `comment` — optional trailing or leading comment text.
|
|
410
|
+
* - `chomp` — block-scalar chomping indicator, when the scalar is a block
|
|
411
|
+
* scalar.
|
|
412
|
+
* - `raw` — the raw source text, preserved when it differs from the resolved
|
|
413
|
+
* value in a way stringification needs to know about.
|
|
414
|
+
* - `sourceMultiline` — `true` when the source span covers two or more lines;
|
|
415
|
+
* absent on synthetic nodes.
|
|
416
|
+
* - `offset` / `length` — the node's span in the source.
|
|
417
|
+
*
|
|
418
|
+
* @public
|
|
419
|
+
*/
|
|
420
|
+
declare class YamlScalar extends YamlScalar_base {
|
|
421
|
+
/**
|
|
422
|
+
* Navigate to a descendant by path (string segments for mapping keys,
|
|
423
|
+
* numbers for sequence indices). `Option.none()` when any segment cannot
|
|
424
|
+
* be resolved. Pure.
|
|
425
|
+
*/
|
|
426
|
+
find(path: YamlPath): Option.Option<YamlNode>;
|
|
427
|
+
/**
|
|
428
|
+
* Find the deepest node whose span contains `offset` (half-open interval),
|
|
429
|
+
* or `Option.none()` when the offset falls outside this subtree. Pure.
|
|
430
|
+
*/
|
|
431
|
+
findAtOffset(offset: number): Option.Option<YamlNode>;
|
|
432
|
+
/**
|
|
433
|
+
* Return the path from this node to the given descendant node (matched by
|
|
434
|
+
* reference identity), or `Option.none()` when it is not in this subtree.
|
|
435
|
+
* The inverse of {@link YamlScalar.find}. Pure.
|
|
436
|
+
*/
|
|
437
|
+
pathOf(node: YamlNode): Option.Option<YamlPath>;
|
|
438
|
+
/**
|
|
439
|
+
* Reconstruct the plain JavaScript value of this subtree. Aliases resolve
|
|
440
|
+
* through `anchors` (anchors encountered during the walk register
|
|
441
|
+
* incrementally, so an alias sees the most recent definition at its point
|
|
442
|
+
* of use); unresolvable aliases yield `null`. Pure and total.
|
|
443
|
+
*/
|
|
444
|
+
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
445
|
+
}
|
|
446
|
+
declare const YamlAlias_base: Schema.Class<YamlAlias, Schema.TaggedStruct<"YamlAlias", {
|
|
447
|
+
readonly name: Schema.String;
|
|
448
|
+
readonly offset: Schema.Number;
|
|
449
|
+
readonly length: Schema.Number;
|
|
450
|
+
}>, {}>;
|
|
451
|
+
/**
|
|
452
|
+
* A YAML alias AST node, referencing a previously defined anchor by name
|
|
453
|
+
* (without the leading `*`).
|
|
454
|
+
*
|
|
455
|
+
* @public
|
|
456
|
+
*/
|
|
457
|
+
declare class YamlAlias extends YamlAlias_base {
|
|
458
|
+
/** See `YamlScalar.find`. Pure. */
|
|
459
|
+
find(path: YamlPath): Option.Option<YamlNode>;
|
|
460
|
+
/** See `YamlScalar.findAtOffset`. Pure. */
|
|
461
|
+
findAtOffset(offset: number): Option.Option<YamlNode>;
|
|
462
|
+
/** See `YamlScalar.pathOf`. Pure. */
|
|
463
|
+
pathOf(node: YamlNode): Option.Option<YamlPath>;
|
|
464
|
+
/** See `YamlScalar.toValue`. Pure and total. */
|
|
465
|
+
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* A discriminated-union schema covering all four YAML AST value node types:
|
|
469
|
+
* {@link YamlScalar}, {@link YamlMap}, {@link YamlSeq} and {@link YamlAlias}.
|
|
470
|
+
* Defined lazily via `Schema.suspend` to break the recursive reference chain
|
|
471
|
+
* `YamlNode → YamlMap → YamlPair → YamlNode`.
|
|
472
|
+
*
|
|
473
|
+
* @remarks
|
|
474
|
+
* Construct member nodes via their `.make(...)` static (e.g.
|
|
475
|
+
* `YamlScalar.make(...)`), never `new YamlScalar(...)` — the internal
|
|
476
|
+
* composer's hot-path `new` construction is the one recorded exception, kept
|
|
477
|
+
* internal to the engine for its allocation-sensitive walk.
|
|
478
|
+
*
|
|
479
|
+
* @public
|
|
480
|
+
*/
|
|
481
|
+
declare const YamlNode: Schema.Schema<YamlScalar | YamlMap | YamlSeq | YamlAlias>;
|
|
482
|
+
/**
|
|
483
|
+
* The union of all YAML AST value node types.
|
|
484
|
+
*
|
|
485
|
+
* @public
|
|
486
|
+
*/
|
|
487
|
+
type YamlNode = YamlScalar | YamlMap | YamlSeq | YamlAlias;
|
|
488
|
+
declare const YamlPair_base: Schema.Class<YamlPair, Schema.TaggedStruct<"YamlPair", {
|
|
489
|
+
readonly key: Schema.suspend<Schema.Schema<YamlNode>>;
|
|
490
|
+
readonly value: Schema.NullOr<Schema.suspend<Schema.Schema<YamlNode>>>;
|
|
491
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
492
|
+
}>, {}>;
|
|
493
|
+
/**
|
|
494
|
+
* A YAML key-value pair AST node, representing one entry within a mapping.
|
|
495
|
+
* `value` is `null` when absent (e.g. `key:` with no value).
|
|
496
|
+
*
|
|
497
|
+
* @public
|
|
498
|
+
*/
|
|
499
|
+
declare class YamlPair extends YamlPair_base {}
|
|
500
|
+
declare const YamlMap_base: Schema.Class<YamlMap, Schema.TaggedStruct<"YamlMap", {
|
|
501
|
+
readonly items: Schema.$Array<Schema.suspend<Schema.Schema<YamlPair>>>;
|
|
502
|
+
readonly tag: Schema.optionalKey<Schema.String>;
|
|
503
|
+
readonly anchor: Schema.optionalKey<Schema.String>;
|
|
504
|
+
readonly style: Schema.Literals<readonly ["block", "flow"]>;
|
|
505
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
506
|
+
readonly sourceMultiline: Schema.optionalKey<Schema.Boolean>;
|
|
507
|
+
readonly offset: Schema.Number;
|
|
508
|
+
readonly length: Schema.Number;
|
|
509
|
+
}>, {}>;
|
|
510
|
+
/**
|
|
511
|
+
* A YAML mapping AST node, representing a collection of {@link YamlPair}
|
|
512
|
+
* entries.
|
|
513
|
+
*
|
|
514
|
+
* - `style` — the presentation style: `"block"` or `"flow"`.
|
|
515
|
+
* - `sourceMultiline` — `true` when the source span covers two or more lines;
|
|
516
|
+
* used by the canonical stringifier. Absent on synthetic nodes.
|
|
517
|
+
*
|
|
518
|
+
* @public
|
|
519
|
+
*/
|
|
520
|
+
declare class YamlMap extends YamlMap_base {
|
|
521
|
+
/** See `YamlScalar.find`. Pure. */
|
|
522
|
+
find(path: YamlPath): Option.Option<YamlNode>;
|
|
523
|
+
/** See `YamlScalar.findAtOffset`. Pure. */
|
|
524
|
+
findAtOffset(offset: number): Option.Option<YamlNode>;
|
|
525
|
+
/** See `YamlScalar.pathOf`. Pure. */
|
|
526
|
+
pathOf(node: YamlNode): Option.Option<YamlPath>;
|
|
527
|
+
/** See `YamlScalar.toValue`. Pure and total. */
|
|
528
|
+
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
529
|
+
}
|
|
530
|
+
declare const YamlSeq_base: Schema.Class<YamlSeq, Schema.TaggedStruct<"YamlSeq", {
|
|
531
|
+
readonly items: Schema.$Array<Schema.suspend<Schema.Schema<YamlNode>>>;
|
|
532
|
+
readonly tag: Schema.optionalKey<Schema.String>;
|
|
533
|
+
readonly anchor: Schema.optionalKey<Schema.String>;
|
|
534
|
+
readonly style: Schema.Literals<readonly ["block", "flow"]>;
|
|
535
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
536
|
+
readonly sourceMultiline: Schema.optionalKey<Schema.Boolean>;
|
|
537
|
+
readonly offset: Schema.Number;
|
|
538
|
+
readonly length: Schema.Number;
|
|
539
|
+
}>, {}>;
|
|
540
|
+
/**
|
|
541
|
+
* A YAML sequence AST node, representing an ordered list of
|
|
542
|
+
* {@link (YamlNode:type)} values.
|
|
543
|
+
*
|
|
544
|
+
* @public
|
|
545
|
+
*/
|
|
546
|
+
declare class YamlSeq extends YamlSeq_base {
|
|
547
|
+
/** See `YamlScalar.find`. Pure. */
|
|
548
|
+
find(path: YamlPath): Option.Option<YamlNode>;
|
|
549
|
+
/** See `YamlScalar.findAtOffset`. Pure. */
|
|
550
|
+
findAtOffset(offset: number): Option.Option<YamlNode>;
|
|
551
|
+
/** See `YamlScalar.pathOf`. Pure. */
|
|
552
|
+
pathOf(node: YamlNode): Option.Option<YamlPath>;
|
|
553
|
+
/** See `YamlScalar.toValue`. Pure and total. */
|
|
554
|
+
toValue(anchors?: Map<string, YamlNode>): unknown;
|
|
555
|
+
}
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region src/YamlDocument.d.ts
|
|
558
|
+
declare const YamlDirective_base: Schema.Class<YamlDirective, Schema.Struct<{
|
|
559
|
+
readonly name: Schema.String;
|
|
560
|
+
readonly parameters: Schema.$Array<Schema.String>;
|
|
561
|
+
}>, {}>;
|
|
562
|
+
/**
|
|
563
|
+
* A YAML directive appearing before a document (e.g. `%YAML 1.2` or
|
|
564
|
+
* `%TAG ! tag:example.com,2000:`). `"YAML"` and `"TAG"` are the YAML 1.2
|
|
565
|
+
* spec-defined directives; any other name is a reserved directive preserved
|
|
566
|
+
* for round-trip fidelity.
|
|
567
|
+
*
|
|
568
|
+
* @public
|
|
569
|
+
*/
|
|
570
|
+
declare class YamlDirective extends YamlDirective_base {}
|
|
571
|
+
declare const YamlDocument_base: Schema.Class<YamlDocument, Schema.Struct<{
|
|
572
|
+
readonly contents: Schema.NullOr<Schema.suspend<Schema.Schema<YamlNode>>>;
|
|
573
|
+
readonly errors: Schema.$Array<typeof YamlDiagnostic>;
|
|
574
|
+
readonly warnings: Schema.$Array<typeof YamlDiagnostic>;
|
|
575
|
+
readonly directives: Schema.$Array<typeof YamlDirective>;
|
|
576
|
+
readonly comment: Schema.optionalKey<Schema.String>;
|
|
577
|
+
readonly hasDocumentStart: Schema.optionalKey<Schema.Boolean>;
|
|
578
|
+
readonly hasDocumentEnd: Schema.optionalKey<Schema.Boolean>;
|
|
579
|
+
readonly hasDocumentStartTab: Schema.optionalKey<Schema.Boolean>;
|
|
580
|
+
}>, {}>;
|
|
581
|
+
/**
|
|
582
|
+
* A parsed YAML document: the root {@link (YamlNode:type)} (or `null` when
|
|
583
|
+
* empty), recovered `errors` and `warnings` as {@link YamlDiagnostic} data,
|
|
584
|
+
* the {@link YamlDirective} list, an optional document-level comment, and the
|
|
585
|
+
* `---`/`...` framing flags (absent flags read as `false`).
|
|
586
|
+
*
|
|
587
|
+
* Construct via `YamlDocument.parse` / `parseAll`; `YamlDocument.make` is for
|
|
588
|
+
* synthetic documents.
|
|
589
|
+
*
|
|
590
|
+
* @public
|
|
591
|
+
*/
|
|
592
|
+
declare class YamlDocument extends YamlDocument_base {
|
|
593
|
+
/**
|
|
594
|
+
* Parse a single YAML document, keeping the full AST, directives and
|
|
595
|
+
* recovered diagnostics. Fails with the aggregate {@link YamlParseError}
|
|
596
|
+
* when any fatal-code diagnostic is present; non-fatal diagnostics are
|
|
597
|
+
* data on the returned document.
|
|
598
|
+
*/
|
|
599
|
+
static readonly parse: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<YamlDocument, YamlParseError, never>;
|
|
600
|
+
/**
|
|
601
|
+
* Parse a multi-document YAML stream into one {@link YamlDocument} per
|
|
602
|
+
* document. Any fatal diagnostic in any document — or a stream-level
|
|
603
|
+
* directive-placement error — fails the whole Effect.
|
|
604
|
+
*/
|
|
605
|
+
static readonly parseAll: (text: string, options?: YamlParseOptions | undefined) => Effect.Effect<readonly YamlDocument[], YamlParseError, never>;
|
|
606
|
+
/**
|
|
607
|
+
* A `Schema<YamlDocument, string>` decoding YAML text into a full
|
|
608
|
+
* document (AST, directives, diagnostics) and encoding a document back to
|
|
609
|
+
* YAML text.
|
|
610
|
+
*
|
|
611
|
+
* Schema-producing: each call returns a fresh schema whose derivation
|
|
612
|
+
* caches are not shared across calls; bind the result to a `const` on hot
|
|
613
|
+
* paths.
|
|
614
|
+
*/
|
|
615
|
+
static schema(options?: YamlParseOptions): Schema.Codec<YamlDocument, string>;
|
|
616
|
+
/**
|
|
617
|
+
* Stringify this document (contents, directives and framing) as YAML.
|
|
618
|
+
* Fails with {@link YamlStringifyError} on circular references introduced
|
|
619
|
+
* into a synthetic AST (`CircularReference`) or on a synthetic AST nested
|
|
620
|
+
* deeper than the stringifier's recursion budget (`NestingDepthExceeded`)
|
|
621
|
+
* — both surface through the typed error channel rather than as an
|
|
622
|
+
* unhandled stack-overflow defect.
|
|
623
|
+
*/
|
|
624
|
+
stringify(options?: YamlStringifyOptions): Effect.Effect<string, YamlStringifyError>;
|
|
625
|
+
/**
|
|
626
|
+
* Reconstruct the plain JavaScript value of this document's contents,
|
|
627
|
+
* resolving anchors and aliases. `null` for an empty document. Pure and
|
|
628
|
+
* total.
|
|
629
|
+
*/
|
|
630
|
+
toValue(): unknown;
|
|
631
|
+
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/YamlFormat.d.ts
|
|
634
|
+
/**
|
|
635
|
+
* A range accepted at the `format`/`formatToString`/etc. call sites: either a
|
|
636
|
+
* {@link YamlRange} instance or a plain `{ offset, length }` literal (the two
|
|
637
|
+
* are structurally interchangeable — only `offset`/`length` are read).
|
|
638
|
+
*
|
|
639
|
+
* @public
|
|
640
|
+
*/
|
|
641
|
+
type YamlRangeLike = YamlRange | {
|
|
642
|
+
readonly offset: number;
|
|
643
|
+
readonly length: number;
|
|
644
|
+
};
|
|
645
|
+
declare const YamlFormattingOptions_base: Schema.Class<YamlFormattingOptions, Schema.Struct<{
|
|
646
|
+
readonly indent: Schema.optionalKey<Schema.Number>;
|
|
647
|
+
readonly lineWidth: Schema.optionalKey<Schema.Number>;
|
|
648
|
+
readonly defaultScalarStyle: Schema.optionalKey<Schema.Literals<readonly ["plain", "single-quoted", "double-quoted", "block-literal", "block-folded"]>>;
|
|
649
|
+
readonly defaultCollectionStyle: Schema.optionalKey<Schema.Literals<readonly ["block", "flow"]>>;
|
|
650
|
+
readonly sortKeys: Schema.optionalKey<Schema.Boolean>;
|
|
651
|
+
readonly finalNewline: Schema.optionalKey<Schema.Boolean>;
|
|
652
|
+
readonly forceDefaultStyles: Schema.optionalKey<Schema.Boolean>;
|
|
653
|
+
readonly preserveComments: Schema.optionalKey<Schema.Boolean>;
|
|
654
|
+
readonly range: Schema.optionalKey<typeof YamlRange>;
|
|
655
|
+
}>, {}>;
|
|
656
|
+
/**
|
|
657
|
+
* Options controlling formatting behavior: every {@link YamlStringifyOptions}
|
|
658
|
+
* field (derived, not hand-duplicated) plus `preserveComments` (default
|
|
659
|
+
* `true`) and `range` (restrict edits to a region; see the module-level
|
|
660
|
+
* remarks on the `range` parameter vs. this field).
|
|
661
|
+
*
|
|
662
|
+
* @public
|
|
663
|
+
*/
|
|
664
|
+
declare class YamlFormattingOptions extends YamlFormattingOptions_base {}
|
|
665
|
+
declare const YamlModificationError_base: Schema.Class<YamlModificationError, Schema.TaggedStruct<"YamlModificationError", {
|
|
666
|
+
readonly path: Schema.$Array<Schema.Union<readonly [Schema.String, Schema.Number]>>;
|
|
667
|
+
readonly diagnostics: Schema.$Array<typeof YamlDiagnostic>;
|
|
668
|
+
}>, import("effect/Cause").YieldableError>;
|
|
669
|
+
/**
|
|
670
|
+
* Raised when `YamlFormat.modify` cannot navigate the requested path against
|
|
671
|
+
* the composed AST (a structural mismatch) or the source fails to parse.
|
|
672
|
+
* Carries structured {@link YamlDiagnostic} entries — never a collapsed
|
|
673
|
+
* `reason` string (the structure-preserving-errors house rule).
|
|
674
|
+
*
|
|
675
|
+
* @public
|
|
676
|
+
*/
|
|
677
|
+
declare class YamlModificationError extends YamlModificationError_base {
|
|
678
|
+
get message(): string;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Formatting and modification statics. Not instantiable.
|
|
682
|
+
*
|
|
683
|
+
* @remarks
|
|
684
|
+
* `format`/`formatToString` are pure and total (edit computation never fails
|
|
685
|
+
* — malformed input yields no edits rather than corrupting the document).
|
|
686
|
+
* `modify`/`modifyToString` carry a real error channel: navigation failures
|
|
687
|
+
* against the composed AST raise {@link YamlModificationError}, which — per
|
|
688
|
+
* the structure-preserving-errors house rule — carries
|
|
689
|
+
* `diagnostics: ReadonlyArray<YamlDiagnostic>`, never a collapsed `reason`
|
|
690
|
+
* string.
|
|
691
|
+
*
|
|
692
|
+
* @public
|
|
693
|
+
*/
|
|
694
|
+
declare class YamlFormat {
|
|
695
|
+
private constructor();
|
|
696
|
+
/**
|
|
697
|
+
* Compute formatting edits for a YAML document. Non-mutating — apply the
|
|
698
|
+
* result with `YamlEdit.applyAll` (or use {@link YamlFormat.formatToString}).
|
|
699
|
+
* Pure and total: malformed input (a fatal parse error) yields `[]` rather
|
|
700
|
+
* than corrupting the document.
|
|
701
|
+
*
|
|
702
|
+
* @remarks
|
|
703
|
+
* The positional `range` argument takes precedence over
|
|
704
|
+
* `options?.range` when both are given; either accepts a plain
|
|
705
|
+
* `{ offset, length }` object as well as a {@link YamlRange} instance, so
|
|
706
|
+
* callers do not need `YamlRange.make(...)` for the common case.
|
|
707
|
+
*/
|
|
708
|
+
static format(text: string, range?: YamlRangeLike, options?: YamlFormattingOptions): ReadonlyArray<YamlEdit>;
|
|
709
|
+
/**
|
|
710
|
+
* Format `text` and apply the resulting edits in one step
|
|
711
|
+
* (`YamlEdit.applyAll ∘ format`). Pure and total.
|
|
712
|
+
*/
|
|
713
|
+
static formatToString(text: string, range?: YamlRangeLike, options?: YamlFormattingOptions): string;
|
|
714
|
+
/**
|
|
715
|
+
* Compute the edits that insert, replace, or remove a value at `path`.
|
|
716
|
+
* Passing `value === undefined` removes the target key/element; a missing
|
|
717
|
+
* insertion target appends after the last pair/element. Only
|
|
718
|
+
* scalar-compatible values are supported (matching v3 — arbitrary object
|
|
719
|
+
* graphs are not recursively lowered into AST nodes). Fails with
|
|
720
|
+
* {@link YamlModificationError} on a fatal parse error or a structural
|
|
721
|
+
* navigation mismatch.
|
|
722
|
+
*
|
|
723
|
+
* @remarks
|
|
724
|
+
* `options` is a bare {@link YamlStringifyOptions} — it controls only the
|
|
725
|
+
* internal re-stringify step, not a range (there is no range to restrict
|
|
726
|
+
* for a path-targeted modification).
|
|
727
|
+
*/
|
|
728
|
+
static readonly modify: (text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<readonly YamlEdit[], YamlModificationError, never>;
|
|
729
|
+
/**
|
|
730
|
+
* Modify `text` and apply the resulting edits in one step
|
|
731
|
+
* (`YamlEdit.applyAll ∘ modify`).
|
|
732
|
+
*/
|
|
733
|
+
static readonly modifyToString: (text: string, path: YamlPath, value: unknown, options?: YamlStringifyOptions | undefined) => Effect.Effect<string, YamlModificationError, never>;
|
|
734
|
+
}
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/YamlVisitor.d.ts
|
|
737
|
+
/**
|
|
738
|
+
* The discriminated union of YAML AST visitor events. Every variant carries
|
|
739
|
+
* `path` (segments from the document root) and `depth` (zero-based nesting
|
|
740
|
+
* level); collection/scalar begin events also carry `style` and the optional
|
|
741
|
+
* `tag`/`anchor`. `Error` carries a materialized {@link YamlDiagnostic} for
|
|
742
|
+
* every diagnostic recorded while composing the document — fatal or not.
|
|
743
|
+
*
|
|
744
|
+
* @public
|
|
745
|
+
*/
|
|
746
|
+
type YamlVisitorEvent = Data.TaggedEnum<{
|
|
747
|
+
DocumentStart: {
|
|
748
|
+
readonly path: YamlPath;
|
|
749
|
+
readonly depth: number;
|
|
750
|
+
readonly directives: ReadonlyArray<{
|
|
751
|
+
readonly name: string;
|
|
752
|
+
readonly parameters: ReadonlyArray<string>;
|
|
753
|
+
}>;
|
|
754
|
+
};
|
|
755
|
+
DocumentEnd: {
|
|
756
|
+
readonly path: YamlPath;
|
|
757
|
+
readonly depth: number;
|
|
758
|
+
};
|
|
759
|
+
MapStart: {
|
|
760
|
+
readonly path: YamlPath;
|
|
761
|
+
readonly depth: number;
|
|
762
|
+
readonly style: CollectionStyle;
|
|
763
|
+
readonly tag?: string;
|
|
764
|
+
readonly anchor?: string;
|
|
765
|
+
};
|
|
766
|
+
MapEnd: {
|
|
767
|
+
readonly path: YamlPath;
|
|
768
|
+
readonly depth: number;
|
|
769
|
+
};
|
|
770
|
+
SeqStart: {
|
|
771
|
+
readonly path: YamlPath;
|
|
772
|
+
readonly depth: number;
|
|
773
|
+
readonly style: CollectionStyle;
|
|
774
|
+
readonly tag?: string;
|
|
775
|
+
readonly anchor?: string;
|
|
776
|
+
};
|
|
777
|
+
SeqEnd: {
|
|
778
|
+
readonly path: YamlPath;
|
|
779
|
+
readonly depth: number;
|
|
780
|
+
};
|
|
781
|
+
Pair: {
|
|
782
|
+
readonly path: YamlPath;
|
|
783
|
+
readonly depth: number;
|
|
784
|
+
readonly key: unknown;
|
|
785
|
+
readonly value: unknown;
|
|
786
|
+
};
|
|
787
|
+
Scalar: {
|
|
788
|
+
readonly path: YamlPath;
|
|
789
|
+
readonly depth: number;
|
|
790
|
+
readonly value: unknown;
|
|
791
|
+
readonly style: ScalarStyle;
|
|
792
|
+
readonly tag?: string;
|
|
793
|
+
readonly anchor?: string;
|
|
794
|
+
};
|
|
795
|
+
Alias: {
|
|
796
|
+
readonly path: YamlPath;
|
|
797
|
+
readonly depth: number;
|
|
798
|
+
readonly name: string;
|
|
799
|
+
};
|
|
800
|
+
Comment: {
|
|
801
|
+
readonly path: YamlPath;
|
|
802
|
+
readonly depth: number;
|
|
803
|
+
readonly text: string;
|
|
804
|
+
};
|
|
805
|
+
Directive: {
|
|
806
|
+
readonly path: YamlPath;
|
|
807
|
+
readonly depth: number;
|
|
808
|
+
readonly name: string;
|
|
809
|
+
readonly parameters: string;
|
|
810
|
+
};
|
|
811
|
+
Error: {
|
|
812
|
+
readonly path: YamlPath;
|
|
813
|
+
readonly depth: number;
|
|
814
|
+
readonly diagnostic: YamlDiagnostic;
|
|
815
|
+
};
|
|
816
|
+
}>;
|
|
817
|
+
/**
|
|
818
|
+
* Constructors and matchers for the `YamlVisitorEvent` union (e.g.
|
|
819
|
+
* `YamlVisitorEvent.Scalar({ path, depth, value, style })`,
|
|
820
|
+
* `YamlVisitorEvent.$is("MapStart")`).
|
|
821
|
+
*
|
|
822
|
+
* @public
|
|
823
|
+
*/
|
|
824
|
+
declare const YamlVisitorEvent: {
|
|
825
|
+
readonly $is: <Tag extends "Alias" | "Comment" | "Directive" | "DocumentEnd" | "DocumentStart" | "Error" | "MapEnd" | "MapStart" | "Pair" | "Scalar" | "SeqEnd" | "SeqStart">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
826
|
+
readonly _tag: "Alias";
|
|
827
|
+
readonly path: YamlPath;
|
|
828
|
+
readonly depth: number;
|
|
829
|
+
readonly name: string;
|
|
830
|
+
}, {
|
|
831
|
+
readonly _tag: Tag;
|
|
832
|
+
}> | Extract<{
|
|
833
|
+
readonly _tag: "Comment";
|
|
834
|
+
readonly path: YamlPath;
|
|
835
|
+
readonly depth: number;
|
|
836
|
+
readonly text: string;
|
|
837
|
+
}, {
|
|
838
|
+
readonly _tag: Tag;
|
|
839
|
+
}> | Extract<{
|
|
840
|
+
readonly _tag: "Directive";
|
|
841
|
+
readonly path: YamlPath;
|
|
842
|
+
readonly depth: number;
|
|
843
|
+
readonly name: string;
|
|
844
|
+
readonly parameters: string;
|
|
845
|
+
}, {
|
|
846
|
+
readonly _tag: Tag;
|
|
847
|
+
}> | Extract<{
|
|
848
|
+
readonly _tag: "DocumentEnd";
|
|
849
|
+
readonly path: YamlPath;
|
|
850
|
+
readonly depth: number;
|
|
851
|
+
}, {
|
|
852
|
+
readonly _tag: Tag;
|
|
853
|
+
}> | Extract<{
|
|
854
|
+
readonly _tag: "DocumentStart";
|
|
855
|
+
readonly path: YamlPath;
|
|
856
|
+
readonly depth: number;
|
|
857
|
+
readonly directives: ReadonlyArray<{
|
|
858
|
+
readonly name: string;
|
|
859
|
+
readonly parameters: ReadonlyArray<string>;
|
|
860
|
+
}>;
|
|
861
|
+
}, {
|
|
862
|
+
readonly _tag: Tag;
|
|
863
|
+
}> | Extract<{
|
|
864
|
+
readonly _tag: "Error";
|
|
865
|
+
readonly path: YamlPath;
|
|
866
|
+
readonly depth: number;
|
|
867
|
+
readonly diagnostic: YamlDiagnostic;
|
|
868
|
+
}, {
|
|
869
|
+
readonly _tag: Tag;
|
|
870
|
+
}> | Extract<{
|
|
871
|
+
readonly _tag: "MapEnd";
|
|
872
|
+
readonly path: YamlPath;
|
|
873
|
+
readonly depth: number;
|
|
874
|
+
}, {
|
|
875
|
+
readonly _tag: Tag;
|
|
876
|
+
}> | Extract<{
|
|
877
|
+
readonly _tag: "MapStart";
|
|
878
|
+
readonly path: YamlPath;
|
|
879
|
+
readonly depth: number;
|
|
880
|
+
readonly style: CollectionStyle;
|
|
881
|
+
readonly tag?: string | undefined;
|
|
882
|
+
readonly anchor?: string | undefined;
|
|
883
|
+
}, {
|
|
884
|
+
readonly _tag: Tag;
|
|
885
|
+
}> | Extract<{
|
|
886
|
+
readonly _tag: "Pair";
|
|
887
|
+
readonly path: YamlPath;
|
|
888
|
+
readonly depth: number;
|
|
889
|
+
readonly key: unknown;
|
|
890
|
+
readonly value: unknown;
|
|
891
|
+
}, {
|
|
892
|
+
readonly _tag: Tag;
|
|
893
|
+
}> | Extract<{
|
|
894
|
+
readonly _tag: "Scalar";
|
|
895
|
+
readonly path: YamlPath;
|
|
896
|
+
readonly depth: number;
|
|
897
|
+
readonly value: unknown;
|
|
898
|
+
readonly style: ScalarStyle;
|
|
899
|
+
readonly tag?: string | undefined;
|
|
900
|
+
readonly anchor?: string | undefined;
|
|
901
|
+
}, {
|
|
902
|
+
readonly _tag: Tag;
|
|
903
|
+
}> | Extract<{
|
|
904
|
+
readonly _tag: "SeqEnd";
|
|
905
|
+
readonly path: YamlPath;
|
|
906
|
+
readonly depth: number;
|
|
907
|
+
}, {
|
|
908
|
+
readonly _tag: Tag;
|
|
909
|
+
}> | Extract<{
|
|
910
|
+
readonly _tag: "SeqStart";
|
|
911
|
+
readonly path: YamlPath;
|
|
912
|
+
readonly depth: number;
|
|
913
|
+
readonly style: CollectionStyle;
|
|
914
|
+
readonly tag?: string | undefined;
|
|
915
|
+
readonly anchor?: string | undefined;
|
|
916
|
+
}, {
|
|
917
|
+
readonly _tag: Tag;
|
|
918
|
+
}>;
|
|
919
|
+
readonly $match: {
|
|
920
|
+
<Cases extends {
|
|
921
|
+
readonly Alias: (args: {
|
|
922
|
+
readonly _tag: "Alias";
|
|
923
|
+
readonly path: YamlPath;
|
|
924
|
+
readonly depth: number;
|
|
925
|
+
readonly name: string;
|
|
926
|
+
}) => any;
|
|
927
|
+
readonly Comment: (args: {
|
|
928
|
+
readonly _tag: "Comment";
|
|
929
|
+
readonly path: YamlPath;
|
|
930
|
+
readonly depth: number;
|
|
931
|
+
readonly text: string;
|
|
932
|
+
}) => any;
|
|
933
|
+
readonly Directive: (args: {
|
|
934
|
+
readonly _tag: "Directive";
|
|
935
|
+
readonly path: YamlPath;
|
|
936
|
+
readonly depth: number;
|
|
937
|
+
readonly name: string;
|
|
938
|
+
readonly parameters: string;
|
|
939
|
+
}) => any;
|
|
940
|
+
readonly DocumentEnd: (args: {
|
|
941
|
+
readonly _tag: "DocumentEnd";
|
|
942
|
+
readonly path: YamlPath;
|
|
943
|
+
readonly depth: number;
|
|
944
|
+
}) => any;
|
|
945
|
+
readonly DocumentStart: (args: {
|
|
946
|
+
readonly _tag: "DocumentStart";
|
|
947
|
+
readonly path: YamlPath;
|
|
948
|
+
readonly depth: number;
|
|
949
|
+
readonly directives: ReadonlyArray<{
|
|
950
|
+
readonly name: string;
|
|
951
|
+
readonly parameters: ReadonlyArray<string>;
|
|
952
|
+
}>;
|
|
953
|
+
}) => any;
|
|
954
|
+
readonly Error: (args: {
|
|
955
|
+
readonly _tag: "Error";
|
|
956
|
+
readonly path: YamlPath;
|
|
957
|
+
readonly depth: number;
|
|
958
|
+
readonly diagnostic: YamlDiagnostic;
|
|
959
|
+
}) => any;
|
|
960
|
+
readonly MapEnd: (args: {
|
|
961
|
+
readonly _tag: "MapEnd";
|
|
962
|
+
readonly path: YamlPath;
|
|
963
|
+
readonly depth: number;
|
|
964
|
+
}) => any;
|
|
965
|
+
readonly MapStart: (args: {
|
|
966
|
+
readonly _tag: "MapStart";
|
|
967
|
+
readonly path: YamlPath;
|
|
968
|
+
readonly depth: number;
|
|
969
|
+
readonly style: CollectionStyle;
|
|
970
|
+
readonly tag?: string | undefined;
|
|
971
|
+
readonly anchor?: string | undefined;
|
|
972
|
+
}) => any;
|
|
973
|
+
readonly Pair: (args: {
|
|
974
|
+
readonly _tag: "Pair";
|
|
975
|
+
readonly path: YamlPath;
|
|
976
|
+
readonly depth: number;
|
|
977
|
+
readonly key: unknown;
|
|
978
|
+
readonly value: unknown;
|
|
979
|
+
}) => any;
|
|
980
|
+
readonly Scalar: (args: {
|
|
981
|
+
readonly _tag: "Scalar";
|
|
982
|
+
readonly path: YamlPath;
|
|
983
|
+
readonly depth: number;
|
|
984
|
+
readonly value: unknown;
|
|
985
|
+
readonly style: ScalarStyle;
|
|
986
|
+
readonly tag?: string | undefined;
|
|
987
|
+
readonly anchor?: string | undefined;
|
|
988
|
+
}) => any;
|
|
989
|
+
readonly SeqEnd: (args: {
|
|
990
|
+
readonly _tag: "SeqEnd";
|
|
991
|
+
readonly path: YamlPath;
|
|
992
|
+
readonly depth: number;
|
|
993
|
+
}) => any;
|
|
994
|
+
readonly SeqStart: (args: {
|
|
995
|
+
readonly _tag: "SeqStart";
|
|
996
|
+
readonly path: YamlPath;
|
|
997
|
+
readonly depth: number;
|
|
998
|
+
readonly style: CollectionStyle;
|
|
999
|
+
readonly tag?: string | undefined;
|
|
1000
|
+
readonly anchor?: string | undefined;
|
|
1001
|
+
}) => any;
|
|
1002
|
+
}>(cases: Cases): (value: {
|
|
1003
|
+
readonly _tag: "Alias";
|
|
1004
|
+
readonly path: YamlPath;
|
|
1005
|
+
readonly depth: number;
|
|
1006
|
+
readonly name: string;
|
|
1007
|
+
} | {
|
|
1008
|
+
readonly _tag: "Comment";
|
|
1009
|
+
readonly path: YamlPath;
|
|
1010
|
+
readonly depth: number;
|
|
1011
|
+
readonly text: string;
|
|
1012
|
+
} | {
|
|
1013
|
+
readonly _tag: "Directive";
|
|
1014
|
+
readonly path: YamlPath;
|
|
1015
|
+
readonly depth: number;
|
|
1016
|
+
readonly name: string;
|
|
1017
|
+
readonly parameters: string;
|
|
1018
|
+
} | {
|
|
1019
|
+
readonly _tag: "DocumentEnd";
|
|
1020
|
+
readonly path: YamlPath;
|
|
1021
|
+
readonly depth: number;
|
|
1022
|
+
} | {
|
|
1023
|
+
readonly _tag: "DocumentStart";
|
|
1024
|
+
readonly path: YamlPath;
|
|
1025
|
+
readonly depth: number;
|
|
1026
|
+
readonly directives: ReadonlyArray<{
|
|
1027
|
+
readonly name: string;
|
|
1028
|
+
readonly parameters: ReadonlyArray<string>;
|
|
1029
|
+
}>;
|
|
1030
|
+
} | {
|
|
1031
|
+
readonly _tag: "Error";
|
|
1032
|
+
readonly path: YamlPath;
|
|
1033
|
+
readonly depth: number;
|
|
1034
|
+
readonly diagnostic: YamlDiagnostic;
|
|
1035
|
+
} | {
|
|
1036
|
+
readonly _tag: "MapEnd";
|
|
1037
|
+
readonly path: YamlPath;
|
|
1038
|
+
readonly depth: number;
|
|
1039
|
+
} | {
|
|
1040
|
+
readonly _tag: "MapStart";
|
|
1041
|
+
readonly path: YamlPath;
|
|
1042
|
+
readonly depth: number;
|
|
1043
|
+
readonly style: CollectionStyle;
|
|
1044
|
+
readonly tag?: string | undefined;
|
|
1045
|
+
readonly anchor?: string | undefined;
|
|
1046
|
+
} | {
|
|
1047
|
+
readonly _tag: "Pair";
|
|
1048
|
+
readonly path: YamlPath;
|
|
1049
|
+
readonly depth: number;
|
|
1050
|
+
readonly key: unknown;
|
|
1051
|
+
readonly value: unknown;
|
|
1052
|
+
} | {
|
|
1053
|
+
readonly _tag: "Scalar";
|
|
1054
|
+
readonly path: YamlPath;
|
|
1055
|
+
readonly depth: number;
|
|
1056
|
+
readonly value: unknown;
|
|
1057
|
+
readonly style: ScalarStyle;
|
|
1058
|
+
readonly tag?: string | undefined;
|
|
1059
|
+
readonly anchor?: string | undefined;
|
|
1060
|
+
} | {
|
|
1061
|
+
readonly _tag: "SeqEnd";
|
|
1062
|
+
readonly path: YamlPath;
|
|
1063
|
+
readonly depth: number;
|
|
1064
|
+
} | {
|
|
1065
|
+
readonly _tag: "SeqStart";
|
|
1066
|
+
readonly path: YamlPath;
|
|
1067
|
+
readonly depth: number;
|
|
1068
|
+
readonly style: CollectionStyle;
|
|
1069
|
+
readonly tag?: string | undefined;
|
|
1070
|
+
readonly anchor?: string | undefined;
|
|
1071
|
+
}) => import("effect/Unify").Unify<ReturnType<Cases["Alias" | "Comment" | "Directive" | "DocumentEnd" | "DocumentStart" | "Error" | "MapEnd" | "MapStart" | "Pair" | "Scalar" | "SeqEnd" | "SeqStart"]>>;
|
|
1072
|
+
<Cases extends {
|
|
1073
|
+
readonly Alias: (args: {
|
|
1074
|
+
readonly _tag: "Alias";
|
|
1075
|
+
readonly path: YamlPath;
|
|
1076
|
+
readonly depth: number;
|
|
1077
|
+
readonly name: string;
|
|
1078
|
+
}) => any;
|
|
1079
|
+
readonly Comment: (args: {
|
|
1080
|
+
readonly _tag: "Comment";
|
|
1081
|
+
readonly path: YamlPath;
|
|
1082
|
+
readonly depth: number;
|
|
1083
|
+
readonly text: string;
|
|
1084
|
+
}) => any;
|
|
1085
|
+
readonly Directive: (args: {
|
|
1086
|
+
readonly _tag: "Directive";
|
|
1087
|
+
readonly path: YamlPath;
|
|
1088
|
+
readonly depth: number;
|
|
1089
|
+
readonly name: string;
|
|
1090
|
+
readonly parameters: string;
|
|
1091
|
+
}) => any;
|
|
1092
|
+
readonly DocumentEnd: (args: {
|
|
1093
|
+
readonly _tag: "DocumentEnd";
|
|
1094
|
+
readonly path: YamlPath;
|
|
1095
|
+
readonly depth: number;
|
|
1096
|
+
}) => any;
|
|
1097
|
+
readonly DocumentStart: (args: {
|
|
1098
|
+
readonly _tag: "DocumentStart";
|
|
1099
|
+
readonly path: YamlPath;
|
|
1100
|
+
readonly depth: number;
|
|
1101
|
+
readonly directives: ReadonlyArray<{
|
|
1102
|
+
readonly name: string;
|
|
1103
|
+
readonly parameters: ReadonlyArray<string>;
|
|
1104
|
+
}>;
|
|
1105
|
+
}) => any;
|
|
1106
|
+
readonly Error: (args: {
|
|
1107
|
+
readonly _tag: "Error";
|
|
1108
|
+
readonly path: YamlPath;
|
|
1109
|
+
readonly depth: number;
|
|
1110
|
+
readonly diagnostic: YamlDiagnostic;
|
|
1111
|
+
}) => any;
|
|
1112
|
+
readonly MapEnd: (args: {
|
|
1113
|
+
readonly _tag: "MapEnd";
|
|
1114
|
+
readonly path: YamlPath;
|
|
1115
|
+
readonly depth: number;
|
|
1116
|
+
}) => any;
|
|
1117
|
+
readonly MapStart: (args: {
|
|
1118
|
+
readonly _tag: "MapStart";
|
|
1119
|
+
readonly path: YamlPath;
|
|
1120
|
+
readonly depth: number;
|
|
1121
|
+
readonly style: CollectionStyle;
|
|
1122
|
+
readonly tag?: string | undefined;
|
|
1123
|
+
readonly anchor?: string | undefined;
|
|
1124
|
+
}) => any;
|
|
1125
|
+
readonly Pair: (args: {
|
|
1126
|
+
readonly _tag: "Pair";
|
|
1127
|
+
readonly path: YamlPath;
|
|
1128
|
+
readonly depth: number;
|
|
1129
|
+
readonly key: unknown;
|
|
1130
|
+
readonly value: unknown;
|
|
1131
|
+
}) => any;
|
|
1132
|
+
readonly Scalar: (args: {
|
|
1133
|
+
readonly _tag: "Scalar";
|
|
1134
|
+
readonly path: YamlPath;
|
|
1135
|
+
readonly depth: number;
|
|
1136
|
+
readonly value: unknown;
|
|
1137
|
+
readonly style: ScalarStyle;
|
|
1138
|
+
readonly tag?: string | undefined;
|
|
1139
|
+
readonly anchor?: string | undefined;
|
|
1140
|
+
}) => any;
|
|
1141
|
+
readonly SeqEnd: (args: {
|
|
1142
|
+
readonly _tag: "SeqEnd";
|
|
1143
|
+
readonly path: YamlPath;
|
|
1144
|
+
readonly depth: number;
|
|
1145
|
+
}) => any;
|
|
1146
|
+
readonly SeqStart: (args: {
|
|
1147
|
+
readonly _tag: "SeqStart";
|
|
1148
|
+
readonly path: YamlPath;
|
|
1149
|
+
readonly depth: number;
|
|
1150
|
+
readonly style: CollectionStyle;
|
|
1151
|
+
readonly tag?: string | undefined;
|
|
1152
|
+
readonly anchor?: string | undefined;
|
|
1153
|
+
}) => any;
|
|
1154
|
+
}>(value: {
|
|
1155
|
+
readonly _tag: "Alias";
|
|
1156
|
+
readonly path: YamlPath;
|
|
1157
|
+
readonly depth: number;
|
|
1158
|
+
readonly name: string;
|
|
1159
|
+
} | {
|
|
1160
|
+
readonly _tag: "Comment";
|
|
1161
|
+
readonly path: YamlPath;
|
|
1162
|
+
readonly depth: number;
|
|
1163
|
+
readonly text: string;
|
|
1164
|
+
} | {
|
|
1165
|
+
readonly _tag: "Directive";
|
|
1166
|
+
readonly path: YamlPath;
|
|
1167
|
+
readonly depth: number;
|
|
1168
|
+
readonly name: string;
|
|
1169
|
+
readonly parameters: string;
|
|
1170
|
+
} | {
|
|
1171
|
+
readonly _tag: "DocumentEnd";
|
|
1172
|
+
readonly path: YamlPath;
|
|
1173
|
+
readonly depth: number;
|
|
1174
|
+
} | {
|
|
1175
|
+
readonly _tag: "DocumentStart";
|
|
1176
|
+
readonly path: YamlPath;
|
|
1177
|
+
readonly depth: number;
|
|
1178
|
+
readonly directives: ReadonlyArray<{
|
|
1179
|
+
readonly name: string;
|
|
1180
|
+
readonly parameters: ReadonlyArray<string>;
|
|
1181
|
+
}>;
|
|
1182
|
+
} | {
|
|
1183
|
+
readonly _tag: "Error";
|
|
1184
|
+
readonly path: YamlPath;
|
|
1185
|
+
readonly depth: number;
|
|
1186
|
+
readonly diagnostic: YamlDiagnostic;
|
|
1187
|
+
} | {
|
|
1188
|
+
readonly _tag: "MapEnd";
|
|
1189
|
+
readonly path: YamlPath;
|
|
1190
|
+
readonly depth: number;
|
|
1191
|
+
} | {
|
|
1192
|
+
readonly _tag: "MapStart";
|
|
1193
|
+
readonly path: YamlPath;
|
|
1194
|
+
readonly depth: number;
|
|
1195
|
+
readonly style: CollectionStyle;
|
|
1196
|
+
readonly tag?: string | undefined;
|
|
1197
|
+
readonly anchor?: string | undefined;
|
|
1198
|
+
} | {
|
|
1199
|
+
readonly _tag: "Pair";
|
|
1200
|
+
readonly path: YamlPath;
|
|
1201
|
+
readonly depth: number;
|
|
1202
|
+
readonly key: unknown;
|
|
1203
|
+
readonly value: unknown;
|
|
1204
|
+
} | {
|
|
1205
|
+
readonly _tag: "Scalar";
|
|
1206
|
+
readonly path: YamlPath;
|
|
1207
|
+
readonly depth: number;
|
|
1208
|
+
readonly value: unknown;
|
|
1209
|
+
readonly style: ScalarStyle;
|
|
1210
|
+
readonly tag?: string | undefined;
|
|
1211
|
+
readonly anchor?: string | undefined;
|
|
1212
|
+
} | {
|
|
1213
|
+
readonly _tag: "SeqEnd";
|
|
1214
|
+
readonly path: YamlPath;
|
|
1215
|
+
readonly depth: number;
|
|
1216
|
+
} | {
|
|
1217
|
+
readonly _tag: "SeqStart";
|
|
1218
|
+
readonly path: YamlPath;
|
|
1219
|
+
readonly depth: number;
|
|
1220
|
+
readonly style: CollectionStyle;
|
|
1221
|
+
readonly tag?: string | undefined;
|
|
1222
|
+
readonly anchor?: string | undefined;
|
|
1223
|
+
}, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Alias" | "Comment" | "Directive" | "DocumentEnd" | "DocumentStart" | "Error" | "MapEnd" | "MapStart" | "Pair" | "Scalar" | "SeqEnd" | "SeqStart"]>>;
|
|
1224
|
+
};
|
|
1225
|
+
readonly Alias: Data.TaggedEnum.ConstructorFrom<{
|
|
1226
|
+
readonly _tag: "Alias";
|
|
1227
|
+
readonly path: YamlPath;
|
|
1228
|
+
readonly depth: number;
|
|
1229
|
+
readonly name: string;
|
|
1230
|
+
}, "_tag">;
|
|
1231
|
+
readonly Comment: Data.TaggedEnum.ConstructorFrom<{
|
|
1232
|
+
readonly _tag: "Comment";
|
|
1233
|
+
readonly path: YamlPath;
|
|
1234
|
+
readonly depth: number;
|
|
1235
|
+
readonly text: string;
|
|
1236
|
+
}, "_tag">;
|
|
1237
|
+
readonly Directive: Data.TaggedEnum.ConstructorFrom<{
|
|
1238
|
+
readonly _tag: "Directive";
|
|
1239
|
+
readonly path: YamlPath;
|
|
1240
|
+
readonly depth: number;
|
|
1241
|
+
readonly name: string;
|
|
1242
|
+
readonly parameters: string;
|
|
1243
|
+
}, "_tag">;
|
|
1244
|
+
readonly DocumentEnd: Data.TaggedEnum.ConstructorFrom<{
|
|
1245
|
+
readonly _tag: "DocumentEnd";
|
|
1246
|
+
readonly path: YamlPath;
|
|
1247
|
+
readonly depth: number;
|
|
1248
|
+
}, "_tag">;
|
|
1249
|
+
readonly DocumentStart: Data.TaggedEnum.ConstructorFrom<{
|
|
1250
|
+
readonly _tag: "DocumentStart";
|
|
1251
|
+
readonly path: YamlPath;
|
|
1252
|
+
readonly depth: number;
|
|
1253
|
+
readonly directives: ReadonlyArray<{
|
|
1254
|
+
readonly name: string;
|
|
1255
|
+
readonly parameters: ReadonlyArray<string>;
|
|
1256
|
+
}>;
|
|
1257
|
+
}, "_tag">;
|
|
1258
|
+
readonly Error: Data.TaggedEnum.ConstructorFrom<{
|
|
1259
|
+
readonly _tag: "Error";
|
|
1260
|
+
readonly path: YamlPath;
|
|
1261
|
+
readonly depth: number;
|
|
1262
|
+
readonly diagnostic: YamlDiagnostic;
|
|
1263
|
+
}, "_tag">;
|
|
1264
|
+
readonly MapEnd: Data.TaggedEnum.ConstructorFrom<{
|
|
1265
|
+
readonly _tag: "MapEnd";
|
|
1266
|
+
readonly path: YamlPath;
|
|
1267
|
+
readonly depth: number;
|
|
1268
|
+
}, "_tag">;
|
|
1269
|
+
readonly MapStart: Data.TaggedEnum.ConstructorFrom<{
|
|
1270
|
+
readonly _tag: "MapStart";
|
|
1271
|
+
readonly path: YamlPath;
|
|
1272
|
+
readonly depth: number;
|
|
1273
|
+
readonly style: CollectionStyle;
|
|
1274
|
+
readonly tag?: string | undefined;
|
|
1275
|
+
readonly anchor?: string | undefined;
|
|
1276
|
+
}, "_tag">;
|
|
1277
|
+
readonly Pair: Data.TaggedEnum.ConstructorFrom<{
|
|
1278
|
+
readonly _tag: "Pair";
|
|
1279
|
+
readonly path: YamlPath;
|
|
1280
|
+
readonly depth: number;
|
|
1281
|
+
readonly key: unknown;
|
|
1282
|
+
readonly value: unknown;
|
|
1283
|
+
}, "_tag">;
|
|
1284
|
+
readonly Scalar: Data.TaggedEnum.ConstructorFrom<{
|
|
1285
|
+
readonly _tag: "Scalar";
|
|
1286
|
+
readonly path: YamlPath;
|
|
1287
|
+
readonly depth: number;
|
|
1288
|
+
readonly value: unknown;
|
|
1289
|
+
readonly style: ScalarStyle;
|
|
1290
|
+
readonly tag?: string | undefined;
|
|
1291
|
+
readonly anchor?: string | undefined;
|
|
1292
|
+
}, "_tag">;
|
|
1293
|
+
readonly SeqEnd: Data.TaggedEnum.ConstructorFrom<{
|
|
1294
|
+
readonly _tag: "SeqEnd";
|
|
1295
|
+
readonly path: YamlPath;
|
|
1296
|
+
readonly depth: number;
|
|
1297
|
+
}, "_tag">;
|
|
1298
|
+
readonly SeqStart: Data.TaggedEnum.ConstructorFrom<{
|
|
1299
|
+
readonly _tag: "SeqStart";
|
|
1300
|
+
readonly path: YamlPath;
|
|
1301
|
+
readonly depth: number;
|
|
1302
|
+
readonly style: CollectionStyle;
|
|
1303
|
+
readonly tag?: string | undefined;
|
|
1304
|
+
readonly anchor?: string | undefined;
|
|
1305
|
+
}, "_tag">;
|
|
1306
|
+
};
|
|
1307
|
+
/**
|
|
1308
|
+
* SAX-style YAML AST visitor statics. Not instantiable.
|
|
1309
|
+
*
|
|
1310
|
+
* @public
|
|
1311
|
+
*/
|
|
1312
|
+
declare class YamlVisitor {
|
|
1313
|
+
private constructor();
|
|
1314
|
+
/**
|
|
1315
|
+
* Create a lazy `Stream` of `YamlVisitorEvent` from YAML text, in document
|
|
1316
|
+
* order. Multi-document streams (separated by `---`) produce a separate
|
|
1317
|
+
* `DocumentStart`/`DocumentEnd` pair per document. Events are produced on
|
|
1318
|
+
* demand, so combining with `Stream.take` allows efficient partial scans
|
|
1319
|
+
* of large documents without materializing the whole event sequence.
|
|
1320
|
+
*
|
|
1321
|
+
* @remarks
|
|
1322
|
+
* Infallible at the type level: diagnostics recorded while composing
|
|
1323
|
+
* (fatal or not, including an exceeded `maxAliasCount`, recorded as
|
|
1324
|
+
* `AliasCountExceeded`) surface as `Error` events inside the stream rather
|
|
1325
|
+
* than failing it.
|
|
1326
|
+
*/
|
|
1327
|
+
static visit(text: string, options?: YamlParseOptions): Stream.Stream<YamlVisitorEvent>;
|
|
1328
|
+
}
|
|
1329
|
+
//#endregion
|
|
1330
|
+
export { CollectionStyle, ScalarChomp, ScalarStyle, Yaml, YamlAlias, YamlComposerErrorCode, YamlDiagnostic, YamlDirective, YamlDocument, YamlEdit, YamlErrorCode, YamlFormat, YamlFormattingOptions, YamlLexErrorCode, YamlMap, YamlModificationError, YamlModifyErrorCode, YamlNode, YamlPair, YamlParseError, YamlParseErrorCode, YamlParseOptions, type YamlPath, YamlRange, type YamlRangeLike, YamlScalar, type YamlSegment, YamlSeq, YamlStringifyError, YamlStringifyErrorCode, YamlStringifyOptions, YamlVisitor, YamlVisitorEvent };
|
|
1331
|
+
//# sourceMappingURL=index.d.ts.map
|