xmljslib 0.0.0-stage → 1.0.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.
@@ -0,0 +1,153 @@
1
+ interface XMLParserConfig {
2
+ trimPrefixes?: boolean;
3
+ }
4
+ /**
5
+ * Converts an XML object type into its JSON representation.
6
+ *
7
+ * Attributes remain string properties prefixed with `$`.
8
+ * Element values are wrapped into `$value`.
9
+ * Nested elements and arrays are converted recursively.
10
+ */
11
+ type XMLJSON<T> = T extends readonly (infer U)[] ? XMLJSON<U>[] : T extends object ? {
12
+ [K in keyof T]: K extends `$${string}` ? string : XMLJSON<T[K]>;
13
+ } & {
14
+ $value: string | null;
15
+ } : {
16
+ $value: string | null;
17
+ };
18
+ declare class XMLParser<T extends object = Record<string, any>> {
19
+ private $tree;
20
+ private $config;
21
+ constructor(xml: string, config?: XMLParserConfig);
22
+ toJSON(): XMLJSON<T> | null;
23
+ static isXMLTag(xml: string): boolean;
24
+ private static parseTreeItem;
25
+ private static parseTreeJSON;
26
+ toObject(): T | null;
27
+ private static buildTagTree;
28
+ private static readOpenTag;
29
+ private static readCloseTag;
30
+ }
31
+
32
+ declare class WSDLTypeGenerator {
33
+ private typeRegistry;
34
+ private simpleTypeRegistry;
35
+ private simpleTypeDocumentationRegistry;
36
+ private portTypeRegistry;
37
+ private messageRegistry;
38
+ /**
39
+ * Связывает имя глобального XSD element с TypeScript-типом.
40
+ *
41
+ * Например:
42
+ * FetchBooking -> FetchBookingRequest
43
+ */
44
+ private globalElementRegistry;
45
+ private baseUrl;
46
+ private loadedUrls;
47
+ get complexTypeCount(): number;
48
+ get simpleTypeCount(): number;
49
+ generate(wsdlUrl: string, outputFilePath: string, config?: XMLParserConfig): Promise<void>;
50
+ private cleanPrefix;
51
+ private getChildNode;
52
+ private getAttribute;
53
+ /**
54
+ * Извлекает текст документации из XML-узла.
55
+ *
56
+ * Поддерживает:
57
+ * - wsdl:documentation
58
+ * - xs:annotation/xs:documentation
59
+ * - XMLLeaf / Proxy с текстовым значением
60
+ */
61
+ private extractDocumentation;
62
+ private formatDocumentation;
63
+ /**
64
+ * Извлекает wsdl:message и его wsdl:part.
65
+ */
66
+ private extractMessages;
67
+ /**
68
+ * Извлекает wsdl:portType и содержащиеся в них операции.
69
+ */
70
+ private extractOperations;
71
+ /**
72
+ * Разрешает WSDL message в TypeScript-тип.
73
+ *
74
+ * Если сообщение содержит один part:
75
+ * возвращает тип соответствующего element/type.
76
+ *
77
+ * Если несколько:
78
+ * возвращает имя сгенерированного интерфейса сообщения.
79
+ */
80
+ private resolveMessageType;
81
+ /**
82
+ * Разрешает wsdl:part в TypeScript-тип.
83
+ */
84
+ private resolveMessagePartType;
85
+ /**
86
+ * Имя интерфейса для WSDL message с несколькими part.
87
+ */
88
+ private getMessageInterfaceName;
89
+ /**
90
+ * Рекурсивно ищет XSD-схемы внутри WSDL.
91
+ */
92
+ private extractSchemas;
93
+ /**
94
+ * Разбирает XSD-схему.
95
+ */
96
+ private parseXSDSchema;
97
+ /**
98
+ * Регистрирует глобальный XSD element.
99
+ *
100
+ * Например:
101
+ *
102
+ * <xs:element name="FetchBooking" type="tns:FetchBookingRequest"/>
103
+ *
104
+ * Регистрирует:
105
+ *
106
+ * FetchBooking -> FetchBookingRequest
107
+ */
108
+ private parseGlobalElement;
109
+ /**
110
+ * Загружает внешнюю XSD-схему.
111
+ */
112
+ private loadExternalXSD;
113
+ /**
114
+ * Разбирает XSD simpleType.
115
+ */
116
+ private parseSimpleType;
117
+ /**
118
+ * Разбирает XSD complexType.
119
+ */
120
+ private parseComplexType;
121
+ /**
122
+ * Извлекает XSD-атрибуты.
123
+ */
124
+ private extractAttributes;
125
+ /**
126
+ * Преобразует XSD-типы в TypeScript-типы.
127
+ */
128
+ private mapXSDTypeToTS;
129
+ /**
130
+ * Генерирует интерфейсы для WSDL message с несколькими part.
131
+ */
132
+ private compileMessageInterfaces;
133
+ /**
134
+ * Генерирует TypeScript-код.
135
+ */
136
+ compileToTypeScript(): string;
137
+ }
138
+
139
+ interface XMLBuilderOptions {
140
+ declaration?: boolean;
141
+ }
142
+ type XMLPrimitive = string | number | boolean | null | undefined;
143
+ interface XMLBuilderNode {
144
+ [key: string]: XMLPrimitive | XMLBuilderNode | XMLBuilderNode[] | undefined;
145
+ }
146
+ type XMLBuilderData = Record<string, XMLBuilderNode | XMLPrimitive | XMLBuilderNode[]>;
147
+ declare class XMLBuilder<T extends object = Record<string, any>> {
148
+ private $input;
149
+ constructor(obj: T);
150
+ toXML(config?: XMLBuilderOptions): string;
151
+ }
152
+
153
+ export { WSDLTypeGenerator, XMLBuilder, type XMLBuilderData, type XMLBuilderNode, type XMLBuilderOptions, XMLParser, type XMLParserConfig, type XMLPrimitive };
@@ -0,0 +1,153 @@
1
+ interface XMLParserConfig {
2
+ trimPrefixes?: boolean;
3
+ }
4
+ /**
5
+ * Converts an XML object type into its JSON representation.
6
+ *
7
+ * Attributes remain string properties prefixed with `$`.
8
+ * Element values are wrapped into `$value`.
9
+ * Nested elements and arrays are converted recursively.
10
+ */
11
+ type XMLJSON<T> = T extends readonly (infer U)[] ? XMLJSON<U>[] : T extends object ? {
12
+ [K in keyof T]: K extends `$${string}` ? string : XMLJSON<T[K]>;
13
+ } & {
14
+ $value: string | null;
15
+ } : {
16
+ $value: string | null;
17
+ };
18
+ declare class XMLParser<T extends object = Record<string, any>> {
19
+ private $tree;
20
+ private $config;
21
+ constructor(xml: string, config?: XMLParserConfig);
22
+ toJSON(): XMLJSON<T> | null;
23
+ static isXMLTag(xml: string): boolean;
24
+ private static parseTreeItem;
25
+ private static parseTreeJSON;
26
+ toObject(): T | null;
27
+ private static buildTagTree;
28
+ private static readOpenTag;
29
+ private static readCloseTag;
30
+ }
31
+
32
+ declare class WSDLTypeGenerator {
33
+ private typeRegistry;
34
+ private simpleTypeRegistry;
35
+ private simpleTypeDocumentationRegistry;
36
+ private portTypeRegistry;
37
+ private messageRegistry;
38
+ /**
39
+ * Связывает имя глобального XSD element с TypeScript-типом.
40
+ *
41
+ * Например:
42
+ * FetchBooking -> FetchBookingRequest
43
+ */
44
+ private globalElementRegistry;
45
+ private baseUrl;
46
+ private loadedUrls;
47
+ get complexTypeCount(): number;
48
+ get simpleTypeCount(): number;
49
+ generate(wsdlUrl: string, outputFilePath: string, config?: XMLParserConfig): Promise<void>;
50
+ private cleanPrefix;
51
+ private getChildNode;
52
+ private getAttribute;
53
+ /**
54
+ * Извлекает текст документации из XML-узла.
55
+ *
56
+ * Поддерживает:
57
+ * - wsdl:documentation
58
+ * - xs:annotation/xs:documentation
59
+ * - XMLLeaf / Proxy с текстовым значением
60
+ */
61
+ private extractDocumentation;
62
+ private formatDocumentation;
63
+ /**
64
+ * Извлекает wsdl:message и его wsdl:part.
65
+ */
66
+ private extractMessages;
67
+ /**
68
+ * Извлекает wsdl:portType и содержащиеся в них операции.
69
+ */
70
+ private extractOperations;
71
+ /**
72
+ * Разрешает WSDL message в TypeScript-тип.
73
+ *
74
+ * Если сообщение содержит один part:
75
+ * возвращает тип соответствующего element/type.
76
+ *
77
+ * Если несколько:
78
+ * возвращает имя сгенерированного интерфейса сообщения.
79
+ */
80
+ private resolveMessageType;
81
+ /**
82
+ * Разрешает wsdl:part в TypeScript-тип.
83
+ */
84
+ private resolveMessagePartType;
85
+ /**
86
+ * Имя интерфейса для WSDL message с несколькими part.
87
+ */
88
+ private getMessageInterfaceName;
89
+ /**
90
+ * Рекурсивно ищет XSD-схемы внутри WSDL.
91
+ */
92
+ private extractSchemas;
93
+ /**
94
+ * Разбирает XSD-схему.
95
+ */
96
+ private parseXSDSchema;
97
+ /**
98
+ * Регистрирует глобальный XSD element.
99
+ *
100
+ * Например:
101
+ *
102
+ * <xs:element name="FetchBooking" type="tns:FetchBookingRequest"/>
103
+ *
104
+ * Регистрирует:
105
+ *
106
+ * FetchBooking -> FetchBookingRequest
107
+ */
108
+ private parseGlobalElement;
109
+ /**
110
+ * Загружает внешнюю XSD-схему.
111
+ */
112
+ private loadExternalXSD;
113
+ /**
114
+ * Разбирает XSD simpleType.
115
+ */
116
+ private parseSimpleType;
117
+ /**
118
+ * Разбирает XSD complexType.
119
+ */
120
+ private parseComplexType;
121
+ /**
122
+ * Извлекает XSD-атрибуты.
123
+ */
124
+ private extractAttributes;
125
+ /**
126
+ * Преобразует XSD-типы в TypeScript-типы.
127
+ */
128
+ private mapXSDTypeToTS;
129
+ /**
130
+ * Генерирует интерфейсы для WSDL message с несколькими part.
131
+ */
132
+ private compileMessageInterfaces;
133
+ /**
134
+ * Генерирует TypeScript-код.
135
+ */
136
+ compileToTypeScript(): string;
137
+ }
138
+
139
+ interface XMLBuilderOptions {
140
+ declaration?: boolean;
141
+ }
142
+ type XMLPrimitive = string | number | boolean | null | undefined;
143
+ interface XMLBuilderNode {
144
+ [key: string]: XMLPrimitive | XMLBuilderNode | XMLBuilderNode[] | undefined;
145
+ }
146
+ type XMLBuilderData = Record<string, XMLBuilderNode | XMLPrimitive | XMLBuilderNode[]>;
147
+ declare class XMLBuilder<T extends object = Record<string, any>> {
148
+ private $input;
149
+ constructor(obj: T);
150
+ toXML(config?: XMLBuilderOptions): string;
151
+ }
152
+
153
+ export { WSDLTypeGenerator, XMLBuilder, type XMLBuilderData, type XMLBuilderNode, type XMLBuilderOptions, XMLParser, type XMLParserConfig, type XMLPrimitive };