@elaraai/east-node-io 0.0.1-beta.0 → 0.0.1-beta.2

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.
Files changed (114) hide show
  1. package/dist/compression/gzip.d.ts +108 -0
  2. package/dist/compression/gzip.d.ts.map +1 -0
  3. package/dist/compression/gzip.js +153 -0
  4. package/dist/compression/gzip.js.map +1 -0
  5. package/dist/compression/index.d.ts +308 -0
  6. package/dist/compression/index.d.ts.map +1 -0
  7. package/dist/compression/index.js +289 -0
  8. package/dist/compression/index.js.map +1 -0
  9. package/dist/compression/tar.d.ts +115 -0
  10. package/dist/compression/tar.d.ts.map +1 -0
  11. package/dist/compression/tar.js +254 -0
  12. package/dist/compression/tar.js.map +1 -0
  13. package/dist/compression/types.d.ts +124 -0
  14. package/dist/compression/types.d.ts.map +1 -0
  15. package/dist/compression/types.js +106 -0
  16. package/dist/compression/types.js.map +1 -0
  17. package/dist/compression/zip.d.ts +121 -0
  18. package/dist/compression/zip.d.ts.map +1 -0
  19. package/dist/compression/zip.js +200 -0
  20. package/dist/compression/zip.js.map +1 -0
  21. package/dist/connection/index.d.ts +78 -0
  22. package/dist/connection/index.d.ts.map +1 -0
  23. package/dist/connection/index.js +134 -0
  24. package/dist/connection/index.js.map +1 -0
  25. package/dist/format/csv.d.ts +210 -0
  26. package/dist/format/csv.d.ts.map +1 -0
  27. package/dist/format/csv.js +729 -0
  28. package/dist/format/csv.js.map +1 -0
  29. package/dist/format/index.d.ts +641 -0
  30. package/dist/format/index.d.ts.map +1 -0
  31. package/dist/format/index.js +463 -0
  32. package/dist/format/index.js.map +1 -0
  33. package/dist/format/types.d.ts +176 -0
  34. package/dist/format/types.d.ts.map +1 -0
  35. package/dist/format/types.js +122 -0
  36. package/dist/format/types.js.map +1 -0
  37. package/dist/format/xlsx.d.ts +178 -0
  38. package/dist/format/xlsx.d.ts.map +1 -0
  39. package/dist/format/xlsx.js +313 -0
  40. package/dist/format/xlsx.js.map +1 -0
  41. package/dist/format/xml.d.ts +302 -0
  42. package/dist/format/xml.d.ts.map +1 -0
  43. package/dist/format/xml.js +602 -0
  44. package/dist/format/xml.js.map +1 -0
  45. package/dist/index.d.ts +25 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +32 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/nosql/index.d.ts +503 -0
  50. package/dist/nosql/index.d.ts.map +1 -0
  51. package/dist/nosql/index.js +483 -0
  52. package/dist/nosql/index.js.map +1 -0
  53. package/dist/nosql/mongodb.d.ts +306 -0
  54. package/dist/nosql/mongodb.d.ts.map +1 -0
  55. package/dist/nosql/mongodb.js +552 -0
  56. package/dist/nosql/mongodb.js.map +1 -0
  57. package/dist/nosql/redis.d.ts +268 -0
  58. package/dist/nosql/redis.d.ts.map +1 -0
  59. package/dist/nosql/redis.js +371 -0
  60. package/dist/nosql/redis.js.map +1 -0
  61. package/dist/nosql/types.d.ts +70 -0
  62. package/dist/nosql/types.d.ts.map +1 -0
  63. package/dist/nosql/types.js +79 -0
  64. package/dist/nosql/types.js.map +1 -0
  65. package/dist/sql/index.d.ts +777 -0
  66. package/dist/sql/index.d.ts.map +1 -0
  67. package/dist/sql/index.js +515 -0
  68. package/dist/sql/index.js.map +1 -0
  69. package/dist/sql/mysql.d.ts +238 -0
  70. package/dist/sql/mysql.d.ts.map +1 -0
  71. package/dist/sql/mysql.js +396 -0
  72. package/dist/sql/mysql.js.map +1 -0
  73. package/dist/sql/postgres.d.ts +237 -0
  74. package/dist/sql/postgres.d.ts.map +1 -0
  75. package/dist/sql/postgres.js +381 -0
  76. package/dist/sql/postgres.js.map +1 -0
  77. package/dist/sql/sqlite.d.ts +217 -0
  78. package/dist/sql/sqlite.d.ts.map +1 -0
  79. package/dist/sql/sqlite.js +366 -0
  80. package/dist/sql/sqlite.js.map +1 -0
  81. package/dist/sql/types.d.ts +205 -0
  82. package/dist/sql/types.d.ts.map +1 -0
  83. package/dist/sql/types.js +175 -0
  84. package/dist/sql/types.js.map +1 -0
  85. package/dist/storage/index.d.ts +304 -0
  86. package/dist/storage/index.d.ts.map +1 -0
  87. package/dist/storage/index.js +234 -0
  88. package/dist/storage/index.js.map +1 -0
  89. package/dist/storage/s3.d.ts +373 -0
  90. package/dist/storage/s3.d.ts.map +1 -0
  91. package/dist/storage/s3.js +502 -0
  92. package/dist/storage/s3.js.map +1 -0
  93. package/dist/storage/types.d.ts +117 -0
  94. package/dist/storage/types.d.ts.map +1 -0
  95. package/dist/storage/types.js +94 -0
  96. package/dist/storage/types.js.map +1 -0
  97. package/dist/transfer/ftp.d.ts +333 -0
  98. package/dist/transfer/ftp.d.ts.map +1 -0
  99. package/dist/transfer/ftp.js +437 -0
  100. package/dist/transfer/ftp.js.map +1 -0
  101. package/dist/transfer/index.d.ts +456 -0
  102. package/dist/transfer/index.d.ts.map +1 -0
  103. package/dist/transfer/index.js +414 -0
  104. package/dist/transfer/index.js.map +1 -0
  105. package/dist/transfer/sftp.d.ts +333 -0
  106. package/dist/transfer/sftp.d.ts.map +1 -0
  107. package/dist/transfer/sftp.js +436 -0
  108. package/dist/transfer/sftp.js.map +1 -0
  109. package/dist/transfer/types.d.ts +108 -0
  110. package/dist/transfer/types.d.ts.map +1 -0
  111. package/dist/transfer/types.js +110 -0
  112. package/dist/transfer/types.js.map +1 -0
  113. package/dist/tsconfig.tsbuildinfo +1 -0
  114. package/package.json +8 -8
@@ -0,0 +1,302 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { BlobType, RecursiveType, StructType, StringType, DictType, ArrayType, VariantType, BooleanType, OptionType, type ValueTypeOf } from "@elaraai/east";
6
+ import type { PlatformFunction } from "@elaraai/east/internal";
7
+ /**
8
+ * XmlNode represents an XML element with its tag, attributes, and children.
9
+ *
10
+ * Children can be either TEXT nodes (string content) or ELEMENT nodes (nested XML elements).
11
+ * This recursive structure allows representing arbitrary XML trees.
12
+ */
13
+ export declare const XmlNode: RecursiveType<StructType<{
14
+ tag: StringType;
15
+ attributes: DictType<StringType, StringType>;
16
+ children: ArrayType<VariantType<{
17
+ TEXT: StringType;
18
+ ELEMENT: import("@elaraai/east").RecursiveTypeMarker;
19
+ }>>;
20
+ }>>;
21
+ export type XmlNodeValue = ValueTypeOf<typeof XmlNode>;
22
+ export declare const XmlParseConfig: StructType<{
23
+ preserveWhitespace: BooleanType;
24
+ decodeEntities: BooleanType;
25
+ }>;
26
+ export declare const XmlSerializeConfig: StructType<{
27
+ indent: OptionType<StringType>;
28
+ includeXmlDeclaration: BooleanType;
29
+ encodeEntities: BooleanType;
30
+ selfClosingTags: BooleanType;
31
+ }>;
32
+ /**
33
+ * Parses XML data from a binary blob into a recursive tree structure.
34
+ *
35
+ * Converts XML-formatted binary data into an {@link XmlNode} recursive structure,
36
+ * where each node contains a tag name, attributes dictionary, and children array.
37
+ * Children can be either TEXT nodes (string content) or ELEMENT nodes (nested elements).
38
+ *
39
+ * Supports XML declarations, namespaces (as attributes), CDATA sections,
40
+ * entity decoding, comments (ignored), processing instructions (ignored),
41
+ * and configurable whitespace handling.
42
+ *
43
+ * This is a platform function for the East language, enabling XML parsing
44
+ * in East programs running on Node.js.
45
+ *
46
+ * @param blob - The XML data as a binary blob (UTF-8 encoded)
47
+ * @param config - Parsing configuration including whitespace and entity handling options
48
+ * @returns An {@link XmlNode} representing the root element of the XML document
49
+ *
50
+ * @throws {EastError} When XML is malformed with specific error messages:
51
+ * - "Expected '<' at line N, column M" - Missing opening tag bracket
52
+ * - "Invalid tag name at line N, column M" - Tag name contains invalid characters
53
+ * - "Expected '=' after attribute name at line N, column M" - Missing equals in attribute
54
+ * - "Expected quote for attribute value at line N, column M" - Attribute value not quoted
55
+ * - "Unclosed attribute value at line N, column M" - Missing closing quote
56
+ * - "Expected '>' at line N, column M" - Missing closing bracket
57
+ * - "Mismatched closing tag: expected '</X>', found '</Y>' at line N, column M" - Tag mismatch
58
+ * - "Expected '>' in closing tag at line N, column M" - Malformed closing tag
59
+ * - "Unclosed comment at line N, column M" - Comment not properly closed
60
+ * - "Unclosed CDATA section at line N, column M" - CDATA not properly closed
61
+ * - "Empty XML document" - No root element found
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * const parseXML = East.function([BlobType], XmlNode, ($, xmlBlob) => {
66
+ * const config = $.const(East.value({
67
+ * preserveWhitespace: false,
68
+ * decodeEntities: true,
69
+ * }, XmlParseConfig));
70
+ *
71
+ * return xml_parse(xmlBlob, config);
72
+ * // Returns: { tag: "book", attributes: {"id": "123"}, children: [...] }
73
+ * });
74
+ * ```
75
+ *
76
+ * @remarks
77
+ * - Skips XML declarations (`<?xml version="1.0"?>`) and processing instructions
78
+ * - Ignores comments (`<!-- comment -->`) - they are not preserved
79
+ * - Handles CDATA sections (`<![CDATA[...]]>`) as text without entity decoding
80
+ * - Decodes predefined entities (`&lt;`, `&gt;`, `&amp;`, `&quot;`, `&apos;`)
81
+ * - Decodes numeric entities (decimal `&#65;` and hexadecimal `&#x41;`)
82
+ * - Namespaces are treated as regular attributes (e.g., `xmlns:foo="..."`)
83
+ * - Preserves namespace prefixes in tag names (e.g., `foo:element`)
84
+ * - Skips UTF-8 BOM (0xEF 0xBB 0xBF) if present at start
85
+ * - Tracks line and column numbers for precise error reporting
86
+ */
87
+ export declare const xml_parse: import("@elaraai/east").PlatformDefinition<[BlobType, StructType<{
88
+ preserveWhitespace: BooleanType;
89
+ decodeEntities: BooleanType;
90
+ }>], RecursiveType<StructType<{
91
+ tag: StringType;
92
+ attributes: DictType<StringType, StringType>;
93
+ children: ArrayType<VariantType<{
94
+ TEXT: StringType;
95
+ ELEMENT: import("@elaraai/east").RecursiveTypeMarker;
96
+ }>>;
97
+ }>>>;
98
+ /**
99
+ * Serializes a recursive XML tree structure into XML-formatted binary data.
100
+ *
101
+ * Converts an {@link XmlNode} recursive structure into XML-formatted binary data.
102
+ * Supports configurable indentation, XML declarations, entity encoding,
103
+ * and self-closing tag formatting.
104
+ *
105
+ * This is a platform function for the East language, enabling XML serialization
106
+ * in East programs running on Node.js.
107
+ *
108
+ * @param node - The {@link XmlNode} root element to serialize
109
+ * @param config - Serialization configuration including indentation and formatting options
110
+ * @returns A binary blob containing the XML-formatted data (UTF-8 encoded)
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const serializeXML = East.function([XmlNode], BlobType, ($, doc) => {
115
+ * const config = $.const(East.value({
116
+ * indent: variant('some', " "),
117
+ * includeXmlDeclaration: true,
118
+ * encodeEntities: true,
119
+ * selfClosingTags: true,
120
+ * }, XmlSerializeConfig));
121
+ *
122
+ * return xml_serialize(doc, config);
123
+ * // Returns blob that decodes to:
124
+ * // <?xml version="1.0" encoding="UTF-8"?>
125
+ * // <book id="123">
126
+ * // <title>East Guide</title>
127
+ * // </book>
128
+ * });
129
+ * ```
130
+ *
131
+ * @remarks
132
+ * - Automatically encodes special characters (`<`, `>`, `&`, `"`, `'`) when encodeEntities is true
133
+ * - Attributes are serialized in the order they appear in the dictionary (sorted)
134
+ * - Empty elements are serialized as self-closing tags (`<br/>`) when selfClosingTags is true
135
+ * - Mixed content (text and elements) avoids extra newlines for simple text-only content
136
+ * - Indentation is applied recursively to nested elements
137
+ * - XML declaration includes `version="1.0"` and `encoding="UTF-8"` when enabled
138
+ */
139
+ export declare const xml_serialize: import("@elaraai/east").PlatformDefinition<[RecursiveType<StructType<{
140
+ tag: StringType;
141
+ attributes: DictType<StringType, StringType>;
142
+ children: ArrayType<VariantType<{
143
+ TEXT: StringType;
144
+ ELEMENT: import("@elaraai/east").RecursiveTypeMarker;
145
+ }>>;
146
+ }>>, StructType<{
147
+ indent: OptionType<StringType>;
148
+ includeXmlDeclaration: BooleanType;
149
+ encodeEntities: BooleanType;
150
+ selfClosingTags: BooleanType;
151
+ }>], BlobType>;
152
+ /**
153
+ * Node.js implementation of XML platform functions.
154
+ *
155
+ * Pass this array to {@link East.compile} to enable XML operations.
156
+ */
157
+ declare const XmlImpl: PlatformFunction[];
158
+ /**
159
+ * Grouped XML platform functions.
160
+ *
161
+ * Provides XML parsing and serialization operations for East programs.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import { East, BlobType } from "@elaraai/east";
166
+ * import { XML, XmlParseConfig, XmlNode } from "@elaraai/east-node-std";
167
+ *
168
+ * const parseXML = East.function([BlobType], XmlNode, ($, xmlBlob) => {
169
+ * const config = $.const(East.value({
170
+ * preserveWhitespace: false,
171
+ * decodeEntities: true,
172
+ * }, XmlParseConfig));
173
+ *
174
+ * return XML.parse(xmlBlob, config);
175
+ * });
176
+ *
177
+ * const compiled = East.compile(parseXML.toIR(), XML.Implementation);
178
+ * const xmlData = new TextEncoder().encode("<book id='123'><title>East Guide</title></book>");
179
+ * compiled(xmlData); // Returns parsed XML tree
180
+ * ```
181
+ */
182
+ export declare const XML: {
183
+ /**
184
+ * Parses XML data from a binary blob into a recursive tree structure.
185
+ *
186
+ * Converts XML-formatted binary data into an XmlNode recursive structure.
187
+ * Supports XML declarations, namespaces, CDATA, entity decoding, and comments.
188
+ *
189
+ * @param blob - The XML data as a binary blob (UTF-8 encoded)
190
+ * @param config - Parsing configuration
191
+ * @returns An XmlNode representing the root element
192
+ * @throws {EastError} When XML is malformed
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * const parseXML = East.function([BlobType], XmlNode, ($, xmlBlob) => {
197
+ * const config = $.const(East.value({
198
+ * preserveWhitespace: false,
199
+ * decodeEntities: true,
200
+ * }, XmlParseConfig));
201
+ *
202
+ * return XML.parse(xmlBlob, config);
203
+ * });
204
+ *
205
+ * const compiled = East.compile(parseXML.toIR(), XML.Implementation);
206
+ * const xmlData = new TextEncoder().encode("<book><title>East</title></book>");
207
+ * compiled(xmlData); // Returns: { tag: "book", attributes: Map{}, children: [...] }
208
+ * ```
209
+ */
210
+ readonly parse: import("@elaraai/east").PlatformDefinition<[BlobType, StructType<{
211
+ preserveWhitespace: BooleanType;
212
+ decodeEntities: BooleanType;
213
+ }>], RecursiveType<StructType<{
214
+ tag: StringType;
215
+ attributes: DictType<StringType, StringType>;
216
+ children: ArrayType<VariantType<{
217
+ TEXT: StringType;
218
+ ELEMENT: import("@elaraai/east").RecursiveTypeMarker;
219
+ }>>;
220
+ }>>>;
221
+ /**
222
+ * Serializes a recursive XML tree structure into XML-formatted binary data.
223
+ *
224
+ * Converts an XmlNode recursive structure into XML-formatted binary data.
225
+ * Supports indentation, XML declarations, entity encoding, and self-closing tags.
226
+ *
227
+ * @param node - The XmlNode root element to serialize
228
+ * @param config - Serialization configuration
229
+ * @returns A binary blob containing the XML-formatted data
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * const serializeXML = East.function([XmlNode], BlobType, ($, doc) => {
234
+ * const config = $.const(East.value({
235
+ * indent: variant('some', " "),
236
+ * includeXmlDeclaration: true,
237
+ * encodeEntities: true,
238
+ * selfClosingTags: true,
239
+ * }, XmlSerializeConfig));
240
+ *
241
+ * return XML.serialize(doc, config);
242
+ * });
243
+ *
244
+ * const compiled = East.compile(serializeXML.toIR(), XML.Implementation);
245
+ * const xmlNode = { tag: "book", attributes: new Map(), children: [] };
246
+ * compiled(xmlNode); // Returns blob: "<?xml version=\"1.0\"?>\n<book/>"
247
+ * ```
248
+ */
249
+ readonly serialize: import("@elaraai/east").PlatformDefinition<[RecursiveType<StructType<{
250
+ tag: StringType;
251
+ attributes: DictType<StringType, StringType>;
252
+ children: ArrayType<VariantType<{
253
+ TEXT: StringType;
254
+ ELEMENT: import("@elaraai/east").RecursiveTypeMarker;
255
+ }>>;
256
+ }>>, StructType<{
257
+ indent: OptionType<StringType>;
258
+ includeXmlDeclaration: BooleanType;
259
+ encodeEntities: BooleanType;
260
+ selfClosingTags: BooleanType;
261
+ }>], BlobType>;
262
+ /**
263
+ * Node.js implementation of XML platform functions.
264
+ *
265
+ * Pass this to {@link East.compile} to enable XML operations.
266
+ */
267
+ readonly Implementation: PlatformFunction[];
268
+ /**
269
+ * Type definitions for XML operations.
270
+ */
271
+ readonly Types: {
272
+ /**
273
+ * XML parsing configuration type.
274
+ */
275
+ readonly ParseConfig: StructType<{
276
+ preserveWhitespace: BooleanType;
277
+ decodeEntities: BooleanType;
278
+ }>;
279
+ /**
280
+ * XML serialization configuration type.
281
+ */
282
+ readonly SerializeConfig: StructType<{
283
+ indent: OptionType<StringType>;
284
+ includeXmlDeclaration: BooleanType;
285
+ encodeEntities: BooleanType;
286
+ selfClosingTags: BooleanType;
287
+ }>;
288
+ /**
289
+ * XML node recursive type (element with tag, attributes, and children).
290
+ */
291
+ readonly Node: RecursiveType<StructType<{
292
+ tag: StringType;
293
+ attributes: DictType<StringType, StringType>;
294
+ children: ArrayType<VariantType<{
295
+ TEXT: StringType;
296
+ ELEMENT: import("@elaraai/east").RecursiveTypeMarker;
297
+ }>>;
298
+ }>>;
299
+ };
300
+ };
301
+ export { XmlImpl };
302
+ //# sourceMappingURL=xml.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xml.d.ts","sourceRoot":"","sources":["../../src/format/xml.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAW,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5K,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAK/D;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;;;;GASnB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,OAAO,CAAC,CAAC;AAIvD,eAAO,MAAM,cAAc;;;EAGzB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;EAK7B,CAAC;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;IAAkE,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;cAA0E,CAAC;AAErG;;;;GAIG;AACH,QAAA,MAAM,OAAO,EAAE,gBAAgB,EAwB9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,GAAG;IACZ;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;;;;;;;;;;;;IAGH;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;;;;;;;;;;;;;;IAGH;;;;OAIG;;IAGH;;OAEG;;QAEC;;WAEG;;;;;QAGH;;WAEG;;;;;;;QAGH;;WAEG;;;;;;;;;;CAGD,CAAC;AAGX,OAAO,EAAE,OAAO,EAAE,CAAC"}