-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.d.ts
91 lines (80 loc) · 2.74 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import "chevrotain";
/**
* A {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#document|Document}.
*/
export type Document = Node[];
/**
* A {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#node|Node}.
*/
export interface Node {
/** The name of the Node */
name: string;
/** Collection of {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#argument|Arguments} */
values: Value[];
/** Collection of {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#property|Properties} */
properties: Record<string, Value>;
/** Nodes in the {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#children-block|Children block} */
children: Document;
/** Collection of {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#type-annotation|type annotations} */
tags: NodeTypeAnnotations;
}
/**
* A {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#value|Value}.
*/
export type Value = string | number | boolean | null;
/**
* The {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#type-annotation|Type annotations} associated with a {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#node|Node}.
*/
export interface NodeTypeAnnotations {
/** The type annotation of the Node */
name: string;
/** The type annotations of the {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#argument|Arguments} */
values: string[];
/** The type annotations of the {@link https://github.com/kdl-org/kdl/blob/main/SPEC.md#property|Properties} */
properties: Record<string, string>;
}
/**
* A {@link https://github.com/kdl-org/kdl/blob/main/QUERY-SPEC.md|Query string}.
*/
export type QueryString = string;
export interface ParseResult {
/** Parsing errors */
errors: chevrotain.IRecognitionException[];
/** KDL Document */
output?: Document;
}
/**
* Formatting options
*/
export interface FormattingOptions {
escapes?: Record<number, boolean>;
requireSemicolons?: boolean;
escapeNonAscii?: boolean;
escapeNonPrintableAscii?: boolean;
escapeCommon?: boolean;
escapeLinespace?: boolean;
newline?: string;
indent?: number;
indentChar?: string;
exponentChar?: string;
printEmptyChildren?: boolean;
printNullArgs?: boolean;
printNullProps?: boolean;
}
/**
* @param {string} text - Input KDL file (or fragment)
*/
export function parse(text: string): ParseResult;
/**
* @param {Document} doc - Input KDL document
*/
export function format(doc: Document, options?: FormattingOptions): string;
/**
* @param {Document} doc - Input KDL document
* @param {QueryString} queryString - Query for selecting and/or transforming results
*/
export function query(doc: Document, queryString: QueryString): any;
/**
* @param {Document} doc - KDL document
*/
export function validateDocument(doc: Document): boolean;