@xapi-js/core 1.2.0 → 1.3.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.
- package/dist/index.cjs +415 -185
- package/dist/index.d.cts +85 -26
- package/dist/index.d.ts +85 -26
- package/dist/index.js +412 -161
- package/package.json +1 -5
package/dist/index.d.cts
CHANGED
|
@@ -191,15 +191,15 @@ declare class XapiRoot {
|
|
|
191
191
|
*/
|
|
192
192
|
datasetSize(): number;
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
195
|
-
* @returns An
|
|
194
|
+
* Returns all parameters as an array.
|
|
195
|
+
* @returns An array of parameters.
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
getParameters(): Parameter[];
|
|
198
198
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @returns An
|
|
199
|
+
* Returns all datasets as an array.
|
|
200
|
+
* @returns An array of datasets.
|
|
201
201
|
*/
|
|
202
|
-
|
|
202
|
+
getDatasets(): Dataset[];
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* Represents a dataset within an X-API XML structure.
|
|
@@ -283,20 +283,20 @@ declare class Dataset {
|
|
|
283
283
|
*/
|
|
284
284
|
setColumn(rowIdx: number, columnId: string, value: XapiValueType): void;
|
|
285
285
|
/**
|
|
286
|
-
*
|
|
287
|
-
* @returns An
|
|
286
|
+
* Returns all constant column definitions as an array.
|
|
287
|
+
* @returns An array of constant columns.
|
|
288
288
|
*/
|
|
289
|
-
|
|
289
|
+
getConstColumns(): ConstColumn[];
|
|
290
290
|
/**
|
|
291
|
-
*
|
|
292
|
-
* @returns An
|
|
291
|
+
* Returns all column definitions as an array.
|
|
292
|
+
* @returns An array of columns.
|
|
293
293
|
*/
|
|
294
|
-
|
|
294
|
+
getColumns(): Column[];
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @returns An
|
|
296
|
+
* Returns all rows in the dataset as an array.
|
|
297
|
+
* @returns An array of rows.
|
|
298
298
|
*/
|
|
299
|
-
|
|
299
|
+
getRows(): Row[];
|
|
300
300
|
/**
|
|
301
301
|
* Returns the number of column definitions.
|
|
302
302
|
* @returns The count of columns.
|
|
@@ -322,14 +322,22 @@ declare class Dataset {
|
|
|
322
322
|
*/
|
|
323
323
|
declare function initXapi(options: XapiOptions): void;
|
|
324
324
|
/**
|
|
325
|
-
* Parses an XML string into an XapiRoot object using
|
|
325
|
+
* Parses an XML string into an XapiRoot object using custom parser.
|
|
326
326
|
* @param xml - The string containing the XML data.
|
|
327
|
-
* @returns
|
|
327
|
+
* @returns An XapiRoot object.
|
|
328
328
|
*/
|
|
329
329
|
declare function parse(xml: string): XapiRoot;
|
|
330
330
|
declare function write(root: XapiRoot): string;
|
|
331
331
|
//#endregion
|
|
332
332
|
//#region src/utils.d.ts
|
|
333
|
+
/**
|
|
334
|
+
* Represents an XML node in the parsed structure.
|
|
335
|
+
*/
|
|
336
|
+
type XmlNode = {
|
|
337
|
+
tagName: string;
|
|
338
|
+
attributes?: Record<string, string>;
|
|
339
|
+
children?: (XmlNode | string)[];
|
|
340
|
+
};
|
|
333
341
|
declare function arrayBufferToString(buffer: ArrayBuffer): string;
|
|
334
342
|
/**
|
|
335
343
|
* Creates an array of entities for parsing XML, including control characters.
|
|
@@ -339,14 +347,6 @@ declare function makeParseEntities(): {
|
|
|
339
347
|
entity: string;
|
|
340
348
|
value: string;
|
|
341
349
|
}[];
|
|
342
|
-
/**
|
|
343
|
-
* Creates an array of entities for writing XML, including control characters.
|
|
344
|
-
* @returns An array of objects, each with an `entity` (e.g., "") and its `value` (e.g., "\x01").
|
|
345
|
-
*/
|
|
346
|
-
declare function makeWriterEntities(): {
|
|
347
|
-
entity: string;
|
|
348
|
-
value: string;
|
|
349
|
-
}[];
|
|
350
350
|
/**
|
|
351
351
|
* Converts a Base64 string to a Uint8Array.
|
|
352
352
|
* @param base64String - The Base64 string to convert.
|
|
@@ -408,5 +408,64 @@ declare function convertToColumnType(value: XapiValueType, type: ColumnType): Xa
|
|
|
408
408
|
declare function convertToString(value: XapiValueType, type: ColumnType): string;
|
|
409
409
|
declare function _unescapeXml(str?: string): string | undefined;
|
|
410
410
|
declare function isXapiRoot(value: unknown): value is XapiRoot;
|
|
411
|
+
/**
|
|
412
|
+
* Escapes XML special characters in a string.
|
|
413
|
+
* @param str - The string to escape.
|
|
414
|
+
* @returns The escaped string.
|
|
415
|
+
*/
|
|
416
|
+
declare function escapeXml(str: string): string;
|
|
417
|
+
/**
|
|
418
|
+
* Encodes control characters as XML entities, excluding standard whitespace.
|
|
419
|
+
* Encodes 0x01-0x08, 0x0B-0x0C, 0x0E-0x1F but NOT 0x09 (tab), 0x0A (LF), 0x0D (CR), 0x20 (space).
|
|
420
|
+
* @param str - The string to encode.
|
|
421
|
+
* @returns The encoded string.
|
|
422
|
+
*/
|
|
423
|
+
declare function encodeControlChars(str: string): string;
|
|
424
|
+
/**
|
|
425
|
+
* A string builder for generating formatted XML.
|
|
426
|
+
*/
|
|
427
|
+
declare class XmlStringBuilder {
|
|
428
|
+
private lines;
|
|
429
|
+
private indentLevel;
|
|
430
|
+
private readonly indentString;
|
|
431
|
+
/**
|
|
432
|
+
* Writes the XML declaration.
|
|
433
|
+
* @param version - The XML version (default: "1.0").
|
|
434
|
+
* @param encoding - The encoding (default: "UTF-8").
|
|
435
|
+
*/
|
|
436
|
+
writeDeclaration(version?: string, encoding?: string): void;
|
|
437
|
+
/**
|
|
438
|
+
* Writes a start element tag.
|
|
439
|
+
* @param name - The element name.
|
|
440
|
+
* @param attributes - Optional attributes object.
|
|
441
|
+
* @param selfClosing - Whether to create a self-closing tag.
|
|
442
|
+
*/
|
|
443
|
+
writeStartElement(name: string, attributes?: Record<string, string>, selfClosing?: boolean): void;
|
|
444
|
+
/**
|
|
445
|
+
* Writes an end element tag.
|
|
446
|
+
* @param name - The element name.
|
|
447
|
+
*/
|
|
448
|
+
writeEndElement(name: string): void;
|
|
449
|
+
/**
|
|
450
|
+
* Writes an element with text content.
|
|
451
|
+
* @param name - The element name.
|
|
452
|
+
* @param attributes - Optional attributes object.
|
|
453
|
+
* @param text - The text content.
|
|
454
|
+
*/
|
|
455
|
+
writeElementWithText(name: string, attributes: Record<string, string> | undefined, text: string): void;
|
|
456
|
+
/**
|
|
457
|
+
* Returns the generated XML string.
|
|
458
|
+
* @returns The complete XML string with line breaks.
|
|
459
|
+
*/
|
|
460
|
+
toString(): string;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Parses XML string into an XML node structure.
|
|
464
|
+
* This is a lightweight parser optimized for X-API XML structure.
|
|
465
|
+
*
|
|
466
|
+
* @param xml - The XML string to parse.
|
|
467
|
+
* @returns An array of parsed XML nodes.
|
|
468
|
+
*/
|
|
469
|
+
declare function parseXml(xml: string): XmlNode[];
|
|
411
470
|
//#endregion
|
|
412
|
-
export { Col, Column, ColumnInfo, ColumnType, ColumnTypeError, ConstColumn, Dataset, InvalidXmlError, NexaVersion, Parameter, Row, RowType, Rows, StringWritableStream, XapiOptions, XapiParameters, XapiRoot, XapiValueType, XapiVersion, XplatformVersion, _unescapeXml, arrayBufferToString, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, initXapi, isXapiRoot, makeParseEntities,
|
|
471
|
+
export { Col, Column, ColumnInfo, ColumnType, ColumnTypeError, ConstColumn, Dataset, InvalidXmlError, NexaVersion, Parameter, Row, RowType, Rows, StringWritableStream, XapiOptions, XapiParameters, XapiRoot, XapiValueType, XapiVersion, XmlNode, XmlStringBuilder, XplatformVersion, _unescapeXml, arrayBufferToString, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, encodeControlChars, escapeXml, initXapi, isXapiRoot, makeParseEntities, parse, parseXml, rowType, stringToDate, stringToReadableStream, uint8ArrayToBase64, write };
|
package/dist/index.d.ts
CHANGED
|
@@ -191,15 +191,15 @@ declare class XapiRoot {
|
|
|
191
191
|
*/
|
|
192
192
|
datasetSize(): number;
|
|
193
193
|
/**
|
|
194
|
-
*
|
|
195
|
-
* @returns An
|
|
194
|
+
* Returns all parameters as an array.
|
|
195
|
+
* @returns An array of parameters.
|
|
196
196
|
*/
|
|
197
|
-
|
|
197
|
+
getParameters(): Parameter[];
|
|
198
198
|
/**
|
|
199
|
-
*
|
|
200
|
-
* @returns An
|
|
199
|
+
* Returns all datasets as an array.
|
|
200
|
+
* @returns An array of datasets.
|
|
201
201
|
*/
|
|
202
|
-
|
|
202
|
+
getDatasets(): Dataset[];
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
205
|
* Represents a dataset within an X-API XML structure.
|
|
@@ -283,20 +283,20 @@ declare class Dataset {
|
|
|
283
283
|
*/
|
|
284
284
|
setColumn(rowIdx: number, columnId: string, value: XapiValueType): void;
|
|
285
285
|
/**
|
|
286
|
-
*
|
|
287
|
-
* @returns An
|
|
286
|
+
* Returns all constant column definitions as an array.
|
|
287
|
+
* @returns An array of constant columns.
|
|
288
288
|
*/
|
|
289
|
-
|
|
289
|
+
getConstColumns(): ConstColumn[];
|
|
290
290
|
/**
|
|
291
|
-
*
|
|
292
|
-
* @returns An
|
|
291
|
+
* Returns all column definitions as an array.
|
|
292
|
+
* @returns An array of columns.
|
|
293
293
|
*/
|
|
294
|
-
|
|
294
|
+
getColumns(): Column[];
|
|
295
295
|
/**
|
|
296
|
-
*
|
|
297
|
-
* @returns An
|
|
296
|
+
* Returns all rows in the dataset as an array.
|
|
297
|
+
* @returns An array of rows.
|
|
298
298
|
*/
|
|
299
|
-
|
|
299
|
+
getRows(): Row[];
|
|
300
300
|
/**
|
|
301
301
|
* Returns the number of column definitions.
|
|
302
302
|
* @returns The count of columns.
|
|
@@ -322,14 +322,22 @@ declare class Dataset {
|
|
|
322
322
|
*/
|
|
323
323
|
declare function initXapi(options: XapiOptions): void;
|
|
324
324
|
/**
|
|
325
|
-
* Parses an XML string into an XapiRoot object using
|
|
325
|
+
* Parses an XML string into an XapiRoot object using custom parser.
|
|
326
326
|
* @param xml - The string containing the XML data.
|
|
327
|
-
* @returns
|
|
327
|
+
* @returns An XapiRoot object.
|
|
328
328
|
*/
|
|
329
329
|
declare function parse(xml: string): XapiRoot;
|
|
330
330
|
declare function write(root: XapiRoot): string;
|
|
331
331
|
//#endregion
|
|
332
332
|
//#region src/utils.d.ts
|
|
333
|
+
/**
|
|
334
|
+
* Represents an XML node in the parsed structure.
|
|
335
|
+
*/
|
|
336
|
+
type XmlNode = {
|
|
337
|
+
tagName: string;
|
|
338
|
+
attributes?: Record<string, string>;
|
|
339
|
+
children?: (XmlNode | string)[];
|
|
340
|
+
};
|
|
333
341
|
declare function arrayBufferToString(buffer: ArrayBuffer): string;
|
|
334
342
|
/**
|
|
335
343
|
* Creates an array of entities for parsing XML, including control characters.
|
|
@@ -339,14 +347,6 @@ declare function makeParseEntities(): {
|
|
|
339
347
|
entity: string;
|
|
340
348
|
value: string;
|
|
341
349
|
}[];
|
|
342
|
-
/**
|
|
343
|
-
* Creates an array of entities for writing XML, including control characters.
|
|
344
|
-
* @returns An array of objects, each with an `entity` (e.g., "") and its `value` (e.g., "\x01").
|
|
345
|
-
*/
|
|
346
|
-
declare function makeWriterEntities(): {
|
|
347
|
-
entity: string;
|
|
348
|
-
value: string;
|
|
349
|
-
}[];
|
|
350
350
|
/**
|
|
351
351
|
* Converts a Base64 string to a Uint8Array.
|
|
352
352
|
* @param base64String - The Base64 string to convert.
|
|
@@ -408,5 +408,64 @@ declare function convertToColumnType(value: XapiValueType, type: ColumnType): Xa
|
|
|
408
408
|
declare function convertToString(value: XapiValueType, type: ColumnType): string;
|
|
409
409
|
declare function _unescapeXml(str?: string): string | undefined;
|
|
410
410
|
declare function isXapiRoot(value: unknown): value is XapiRoot;
|
|
411
|
+
/**
|
|
412
|
+
* Escapes XML special characters in a string.
|
|
413
|
+
* @param str - The string to escape.
|
|
414
|
+
* @returns The escaped string.
|
|
415
|
+
*/
|
|
416
|
+
declare function escapeXml(str: string): string;
|
|
417
|
+
/**
|
|
418
|
+
* Encodes control characters as XML entities, excluding standard whitespace.
|
|
419
|
+
* Encodes 0x01-0x08, 0x0B-0x0C, 0x0E-0x1F but NOT 0x09 (tab), 0x0A (LF), 0x0D (CR), 0x20 (space).
|
|
420
|
+
* @param str - The string to encode.
|
|
421
|
+
* @returns The encoded string.
|
|
422
|
+
*/
|
|
423
|
+
declare function encodeControlChars(str: string): string;
|
|
424
|
+
/**
|
|
425
|
+
* A string builder for generating formatted XML.
|
|
426
|
+
*/
|
|
427
|
+
declare class XmlStringBuilder {
|
|
428
|
+
private lines;
|
|
429
|
+
private indentLevel;
|
|
430
|
+
private readonly indentString;
|
|
431
|
+
/**
|
|
432
|
+
* Writes the XML declaration.
|
|
433
|
+
* @param version - The XML version (default: "1.0").
|
|
434
|
+
* @param encoding - The encoding (default: "UTF-8").
|
|
435
|
+
*/
|
|
436
|
+
writeDeclaration(version?: string, encoding?: string): void;
|
|
437
|
+
/**
|
|
438
|
+
* Writes a start element tag.
|
|
439
|
+
* @param name - The element name.
|
|
440
|
+
* @param attributes - Optional attributes object.
|
|
441
|
+
* @param selfClosing - Whether to create a self-closing tag.
|
|
442
|
+
*/
|
|
443
|
+
writeStartElement(name: string, attributes?: Record<string, string>, selfClosing?: boolean): void;
|
|
444
|
+
/**
|
|
445
|
+
* Writes an end element tag.
|
|
446
|
+
* @param name - The element name.
|
|
447
|
+
*/
|
|
448
|
+
writeEndElement(name: string): void;
|
|
449
|
+
/**
|
|
450
|
+
* Writes an element with text content.
|
|
451
|
+
* @param name - The element name.
|
|
452
|
+
* @param attributes - Optional attributes object.
|
|
453
|
+
* @param text - The text content.
|
|
454
|
+
*/
|
|
455
|
+
writeElementWithText(name: string, attributes: Record<string, string> | undefined, text: string): void;
|
|
456
|
+
/**
|
|
457
|
+
* Returns the generated XML string.
|
|
458
|
+
* @returns The complete XML string with line breaks.
|
|
459
|
+
*/
|
|
460
|
+
toString(): string;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Parses XML string into an XML node structure.
|
|
464
|
+
* This is a lightweight parser optimized for X-API XML structure.
|
|
465
|
+
*
|
|
466
|
+
* @param xml - The XML string to parse.
|
|
467
|
+
* @returns An array of parsed XML nodes.
|
|
468
|
+
*/
|
|
469
|
+
declare function parseXml(xml: string): XmlNode[];
|
|
411
470
|
//#endregion
|
|
412
|
-
export { Col, Column, ColumnInfo, ColumnType, ColumnTypeError, ConstColumn, Dataset, InvalidXmlError, NexaVersion, Parameter, Row, RowType, Rows, StringWritableStream, XapiOptions, XapiParameters, XapiRoot, XapiValueType, XapiVersion, XplatformVersion, _unescapeXml, arrayBufferToString, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, initXapi, isXapiRoot, makeParseEntities,
|
|
471
|
+
export { Col, Column, ColumnInfo, ColumnType, ColumnTypeError, ConstColumn, Dataset, InvalidXmlError, NexaVersion, Parameter, Row, RowType, Rows, StringWritableStream, XapiOptions, XapiParameters, XapiRoot, XapiValueType, XapiVersion, XmlNode, XmlStringBuilder, XplatformVersion, _unescapeXml, arrayBufferToString, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, encodeControlChars, escapeXml, initXapi, isXapiRoot, makeParseEntities, parse, parseXml, rowType, stringToDate, stringToReadableStream, uint8ArrayToBase64, write };
|