forked from SAP/xml-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.d.ts
79 lines (69 loc) · 2.18 KB
/
api.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
import { XMLAstNode, XMLAttribute, XMLElement } from "@xml-tools/ast";
import {
ValidationIssue,
AttributeValidator,
ElementValidator
} from "@xml-tools/validation";
import {
AttributeNameCompletion,
AttributeValueCompletion,
ElementContentCompletion,
ElementNameCompletion
} from "@xml-tools/content-assist";
// Represents the root element in an XML document
declare type SimpleSchema = XSSElement & {
// There may only be a single top level element in XML
cardinality: "single";
// The top level element in mandatory in XML
require: true;
};
declare type XSSElement = {
required: boolean;
cardinality: "many" | "single";
name: string;
namespace?: string;
attributesType?: "open" | "closed";
attributes: Record<string, XSSAttribute>;
elementsType?: "open" | "closed";
elements: Record<string, XSSElement>;
// TODO: textValue definition (for simple pure text only?)
};
declare type XSSAttribute = {
required: boolean;
key: string;
value?: XSSValue;
};
// TODO: could be expended to support more primitive types and also complex types such as `union type`
declare type XSSValue = RegExp | XSSValueEnum;
declare type XSSValueEnum = string[];
declare function getSchemaValidators(
schema: SimpleSchema
): {
attribute: AttributeValidator;
element: ElementValidator;
};
interface CompletionSuggestion {
text: string;
label?: string;
docs?: string;
commitCharacter?: string;
isNamespace?: boolean;
/**
* A measure of how certain we are about this suggestion's relevance.
* This value could be used to:
* - Filter out less relevant suggestions when there are too many possible suggestions.
* - Sort the suggestions by relevance.
*/
confidence?: number;
}
declare function getSchemaSuggestionsProviders(
schema: SimpleSchema
): {
// TBD in the future...
// schemaElementContentCompletion: ElementContentCompletion;
schemaElementNameCompletion: ElementNameCompletion<CompletionSuggestion>;
schemaAttributeNameCompletion: AttributeNameCompletion<CompletionSuggestion>;
schemaAttributeValueCompletion: AttributeValueCompletion<
CompletionSuggestion
>;
};