1 | export as namespace jsyaml;
|
2 |
|
3 | export function load(str: string, opts?: LoadOptions): unknown;
|
4 |
|
5 | export class Type {
|
6 | constructor(tag: string, opts?: TypeConstructorOptions);
|
7 | kind: "sequence" | "scalar" | "mapping" | null;
|
8 | resolve(data: any): boolean;
|
9 | construct(data: any, type?: string): any;
|
10 | instanceOf: object | null;
|
11 | predicate: ((data: object) => boolean) | null;
|
12 | represent: ((data: object) => any) | { [x: string]: (data: object) => any } | null;
|
13 | representName: ((data: object) => any) | null;
|
14 | defaultStyle: string | null;
|
15 | multi: boolean;
|
16 | styleAliases: { [x: string]: any };
|
17 | }
|
18 |
|
19 | export class Schema {
|
20 | constructor(definition: SchemaDefinition | Type[] | Type);
|
21 | extend(types: SchemaDefinition | Type[] | Type): Schema;
|
22 | }
|
23 |
|
24 | export function loadAll(str: string, iterator?: null, opts?: LoadOptions): unknown[];
|
25 | export function loadAll(str: string, iterator: (doc: unknown) => void, opts?: LoadOptions): void;
|
26 |
|
27 | export function dump(obj: any, opts?: DumpOptions): string;
|
28 |
|
29 | export interface LoadOptions {
|
30 | /** string to be used as a file path in error/warning messages. */
|
31 | filename?: string | undefined;
|
32 | /** function to call on warning messages. */
|
33 | onWarning?(this: null, e: YAMLException): void;
|
34 | /** specifies a schema to use. */
|
35 | schema?: Schema | undefined;
|
36 | /** compatibility with JSON.parse behaviour. */
|
37 | json?: boolean | undefined;
|
38 | /** listener for parse events */
|
39 | listener?(this: State, eventType: EventType, state: State): void;
|
40 | }
|
41 |
|
42 | export type EventType = "open" | "close";
|
43 |
|
44 | export interface State {
|
45 | input: string;
|
46 | filename: string | null;
|
47 | schema: Schema;
|
48 | onWarning: (this: null, e: YAMLException) => void;
|
49 | json: boolean;
|
50 | length: number;
|
51 | position: number;
|
52 | line: number;
|
53 | lineStart: number;
|
54 | lineIndent: number;
|
55 | version: null | number;
|
56 | checkLineBreaks: boolean;
|
57 | kind: string;
|
58 | result: any;
|
59 | implicitTypes: Type[];
|
60 | }
|
61 |
|
62 | export interface DumpOptions {
|
63 |
|
64 | indent?: number | undefined;
|
65 |
|
66 | noArrayIndent?: boolean | undefined;
|
67 |
|
68 | skipInvalid?: boolean | undefined;
|
69 |
|
70 | flowLevel?: number | undefined;
|
71 |
|
72 | styles?: { [x: string]: any } | undefined;
|
73 |
|
74 | schema?: Schema | undefined;
|
75 |
|
76 | sortKeys?: boolean | ((a: any, b: any) => number) | undefined;
|
77 | /** set max line width. (default: 80) */
|
78 | lineWidth?: number | undefined;
|
79 | /** if true, don't convert duplicate objects into references (default: false) */
|
80 | noRefs?: boolean | undefined;
|
81 | /** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */
|
82 | noCompatMode?: boolean | undefined;
|
83 | /**
|
84 | * if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
|
85 | * Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false).
|
86 | */
|
87 | condenseFlow?: boolean | undefined;
|
88 | /** strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters. (default: `'`) */
|
89 | quotingType?: "'" | "\"" | undefined;
|
90 | /** if true, all non-key strings will be quoted even if they normally don't need to. (default: false) */
|
91 | forceQuotes?: boolean | undefined;
|
92 | /** callback `function (key, value)` called recursively on each key/value in source object (see `replacer` docs for `JSON.stringify`). */
|
93 | replacer?: ((key: string, value: any) => any) | undefined;
|
94 | }
|
95 |
|
96 | export interface TypeConstructorOptions {
|
97 | kind?: "sequence" | "scalar" | "mapping" | undefined;
|
98 | resolve?: ((data: any) => boolean) | undefined;
|
99 | construct?: ((data: any, type?: string) => any) | undefined;
|
100 | instanceOf?: object | undefined;
|
101 | predicate?: ((data: object) => boolean) | undefined;
|
102 | represent?: ((data: object) => any) | { [x: string]: (data: object) => any } | undefined;
|
103 | representName?: ((data: object) => any) | undefined;
|
104 | defaultStyle?: string | undefined;
|
105 | multi?: boolean | undefined;
|
106 | styleAliases?: { [x: string]: any } | undefined;
|
107 | }
|
108 |
|
109 | export interface SchemaDefinition {
|
110 | implicit?: Type[] | undefined;
|
111 | explicit?: Type[] | undefined;
|
112 | }
|
113 |
|
114 | /** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
115 | export let FAILSAFE_SCHEMA: Schema;
|
116 | /** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
117 | export let JSON_SCHEMA: Schema;
|
118 | /** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */
|
119 | export let CORE_SCHEMA: Schema;
|
120 | /** all supported YAML types */
|
121 | export let DEFAULT_SCHEMA: Schema;
|
122 |
|
123 | export interface Mark {
|
124 | buffer: string;
|
125 | column: number;
|
126 | line: number;
|
127 | name: string;
|
128 | position: number;
|
129 | snippet: string;
|
130 | }
|
131 |
|
132 | export class YAMLException extends Error {
|
133 | constructor(reason?: string, mark?: Mark);
|
134 |
|
135 | toString(compact?: boolean): string;
|
136 |
|
137 | name: string;
|
138 |
|
139 | reason: string;
|
140 |
|
141 | message: string;
|
142 |
|
143 | mark: Mark;
|
144 | }
|
145 |
|
\ | No newline at end of file |