@xapi-js/core 1.0.0 → 1.1.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/README.md +217 -29
- package/dist/api-ISSD7HZ6.js +134436 -0
- package/dist/chunk-GI5RMYH6.js +37 -0
- package/dist/index.cjs +145 -127
- package/dist/index.d.cts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +133 -128
- package/dist/performance.test.js +2485 -0
- package/package.json +8 -3
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
7
|
+
}) : x)(function(x) {
|
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
10
|
+
});
|
|
11
|
+
var __esm = (fn, res) => function __init() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
__require,
|
|
33
|
+
__esm,
|
|
34
|
+
__commonJS,
|
|
35
|
+
__export,
|
|
36
|
+
__toCommonJS
|
|
37
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -22,10 +32,13 @@ var index_exports = {};
|
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
ColumnTypeError: () => ColumnTypeError,
|
|
24
34
|
Dataset: () => Dataset,
|
|
35
|
+
InvalidXmlError: () => InvalidXmlError,
|
|
25
36
|
NexaVersion: () => NexaVersion,
|
|
26
37
|
StringWritableStream: () => StringWritableStream,
|
|
27
38
|
XapiRoot: () => XapiRoot,
|
|
28
39
|
XplatformVersion: () => XplatformVersion,
|
|
40
|
+
_unescapeXml: () => _unescapeXml,
|
|
41
|
+
arrayBufferToString: () => arrayBufferToString,
|
|
29
42
|
base64ToUint8Array: () => base64ToUint8Array,
|
|
30
43
|
columnType: () => columnType,
|
|
31
44
|
convertToColumnType: () => convertToColumnType,
|
|
@@ -34,7 +47,7 @@ __export(index_exports, {
|
|
|
34
47
|
initXapi: () => initXapi,
|
|
35
48
|
makeParseEntities: () => makeParseEntities,
|
|
36
49
|
makeWriterEntities: () => makeWriterEntities,
|
|
37
|
-
parse: () =>
|
|
50
|
+
parse: () => parse2,
|
|
38
51
|
rowType: () => rowType,
|
|
39
52
|
stringToDate: () => stringToDate,
|
|
40
53
|
stringToReadableStream: () => stringToReadableStream,
|
|
@@ -46,6 +59,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
46
59
|
|
|
47
60
|
// src/handler.ts
|
|
48
61
|
var import_stax_xml = require("stax-xml");
|
|
62
|
+
var txml = __toESM(require("txml"), 1);
|
|
49
63
|
|
|
50
64
|
// src/types.ts
|
|
51
65
|
var rowType = ["insert", "update", "delete"];
|
|
@@ -64,21 +78,31 @@ var ColumnTypeError = class extends Error {
|
|
|
64
78
|
this.name = "ColumnTypeError";
|
|
65
79
|
}
|
|
66
80
|
};
|
|
81
|
+
var InvalidXmlError = class extends Error {
|
|
82
|
+
constructor(message) {
|
|
83
|
+
super(message);
|
|
84
|
+
this.name = "InvalidXmlError";
|
|
85
|
+
}
|
|
86
|
+
};
|
|
67
87
|
|
|
68
88
|
// src/utils.ts
|
|
89
|
+
function arrayBufferToString(buffer) {
|
|
90
|
+
const decoder = new TextDecoder();
|
|
91
|
+
return decoder.decode(buffer);
|
|
92
|
+
}
|
|
69
93
|
function makeParseEntities() {
|
|
70
|
-
const
|
|
94
|
+
const entities2 = [];
|
|
71
95
|
for (let i = 1; i <= 32; i++) {
|
|
72
|
-
|
|
96
|
+
entities2.push({ entity: `&#${i};`, value: String.fromCharCode(i) });
|
|
73
97
|
}
|
|
74
|
-
return
|
|
98
|
+
return entities2;
|
|
75
99
|
}
|
|
76
100
|
function makeWriterEntities() {
|
|
77
|
-
const
|
|
101
|
+
const entities2 = [];
|
|
78
102
|
for (let i = 1; i <= 32; i++) {
|
|
79
|
-
|
|
103
|
+
entities2.push({ entity: `&#${i};`, value: String.fromCharCode(i) });
|
|
80
104
|
}
|
|
81
|
-
return
|
|
105
|
+
return entities2;
|
|
82
106
|
}
|
|
83
107
|
function base64ToUint8Array(base64String) {
|
|
84
108
|
const binaryString = atob(base64String);
|
|
@@ -156,6 +180,7 @@ function dateToString(date, type) {
|
|
|
156
180
|
}
|
|
157
181
|
}
|
|
158
182
|
var StringWritableStream = class extends WritableStream {
|
|
183
|
+
result = "";
|
|
159
184
|
constructor() {
|
|
160
185
|
const decoder = new TextDecoder();
|
|
161
186
|
super({
|
|
@@ -166,7 +191,6 @@ var StringWritableStream = class extends WritableStream {
|
|
|
166
191
|
this.result += decoder.decode();
|
|
167
192
|
}
|
|
168
193
|
});
|
|
169
|
-
this.result = "";
|
|
170
194
|
}
|
|
171
195
|
/**
|
|
172
196
|
* Returns the collected string result.
|
|
@@ -227,23 +251,34 @@ function convertToString(value, type) {
|
|
|
227
251
|
return dateToString(value, type);
|
|
228
252
|
case "BLOB":
|
|
229
253
|
return uint8ArrayToBase64(value);
|
|
254
|
+
case "STRING":
|
|
255
|
+
return String(value);
|
|
230
256
|
default:
|
|
231
257
|
return String(value);
|
|
232
258
|
}
|
|
233
259
|
}
|
|
260
|
+
var entities = makeParseEntities();
|
|
261
|
+
function _unescapeXml(str) {
|
|
262
|
+
if (!str) return str;
|
|
263
|
+
const regex = new RegExp(entities.map((e) => e.entity).join("|"), "g");
|
|
264
|
+
return str.replace(regex, (match) => {
|
|
265
|
+
const entity = entities.find((e) => e.entity === match);
|
|
266
|
+
return entity ? entity.value : match;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
234
269
|
|
|
235
270
|
// src/xapi-data.ts
|
|
236
271
|
var XapiRoot = class {
|
|
272
|
+
/** An array of datasets within the X-API root. */
|
|
273
|
+
datasets = [];
|
|
274
|
+
/** Parameters associated with the X-API root. */
|
|
275
|
+
parameters = { params: [] };
|
|
237
276
|
/**
|
|
238
277
|
* Creates an instance of XapiRoot.
|
|
239
278
|
* @param datasets - Initial array of datasets.
|
|
240
279
|
* @param parameters - Initial parameters.
|
|
241
280
|
*/
|
|
242
281
|
constructor(datasets = [], parameters = { params: [] }) {
|
|
243
|
-
/** An array of datasets within the X-API root. */
|
|
244
|
-
this.datasets = [];
|
|
245
|
-
/** Parameters associated with the X-API root. */
|
|
246
|
-
this.parameters = { params: [] };
|
|
247
282
|
this.datasets = datasets;
|
|
248
283
|
this.parameters = parameters;
|
|
249
284
|
}
|
|
@@ -331,6 +366,13 @@ var XapiRoot = class {
|
|
|
331
366
|
}
|
|
332
367
|
};
|
|
333
368
|
var Dataset = class {
|
|
369
|
+
/** The ID of the dataset. */
|
|
370
|
+
id;
|
|
371
|
+
constColumns = [];
|
|
372
|
+
columns = [];
|
|
373
|
+
/** An array of rows in the dataset. */
|
|
374
|
+
rows = [];
|
|
375
|
+
_columnIndexMap = /* @__PURE__ */ new Map();
|
|
334
376
|
/**
|
|
335
377
|
* Creates an instance of Dataset.
|
|
336
378
|
* @param id - The ID of the dataset.
|
|
@@ -339,11 +381,6 @@ var Dataset = class {
|
|
|
339
381
|
* @param rows - Initial array of rows.
|
|
340
382
|
*/
|
|
341
383
|
constructor(id, constColumns = [], columns = [], rows = []) {
|
|
342
|
-
this.constColumns = [];
|
|
343
|
-
this.columns = [];
|
|
344
|
-
/** An array of rows in the dataset. */
|
|
345
|
-
this.rows = [];
|
|
346
|
-
this._columnIndexMap = /* @__PURE__ */ new Map();
|
|
347
384
|
this.id = id;
|
|
348
385
|
this.constColumns = constColumns;
|
|
349
386
|
this.columns = columns;
|
|
@@ -524,127 +561,105 @@ function initXapi(options) {
|
|
|
524
561
|
...options
|
|
525
562
|
};
|
|
526
563
|
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
if (typeof reader === "string") {
|
|
530
|
-
_stream = new ReadableStream({
|
|
531
|
-
start(controller) {
|
|
532
|
-
controller.enqueue(new TextEncoder().encode(reader));
|
|
533
|
-
controller.close();
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
} else {
|
|
537
|
-
_stream = reader;
|
|
538
|
-
}
|
|
539
|
-
const xmlParser = new import_stax_xml.StaxXmlParser(_stream, {
|
|
540
|
-
addEntities: makeParseEntities(),
|
|
541
|
-
encoding: "UTF-8"
|
|
542
|
-
});
|
|
564
|
+
function parse2(xml) {
|
|
565
|
+
const parsedXml = txml.parse(xml);
|
|
543
566
|
const xapiRoot = new XapiRoot();
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
type: startEvent.attributes["type"] || "STRING",
|
|
557
|
-
value: _options.parseToTypes ? convertToColumnType(paramValue, startEvent.attributes["type"] || "STRING") : paramValue
|
|
558
|
-
});
|
|
559
|
-
break;
|
|
560
|
-
case "Dataset":
|
|
561
|
-
xapiRoot.addDataset(await parseDataset(startEvent, xmlParser));
|
|
562
|
-
break;
|
|
567
|
+
const rootElement = parsedXml.find((node) => {
|
|
568
|
+
const rootNode = node;
|
|
569
|
+
return rootNode.tagName === "Root";
|
|
570
|
+
});
|
|
571
|
+
if (rootElement === void 0) return xapiRoot;
|
|
572
|
+
const parametersElement = rootElement.children?.find((node) => node.tagName === "Parameters");
|
|
573
|
+
parseParameters(parametersElement, xapiRoot);
|
|
574
|
+
const datasetsElements = rootElement.children?.filter((node) => node.tagName === "Dataset");
|
|
575
|
+
if (datasetsElements && datasetsElements?.length && datasetsElements.length > 0) {
|
|
576
|
+
for (const datasetsElement of datasetsElements) {
|
|
577
|
+
if (!datasetsElement.attributes || !datasetsElement.attributes.id) {
|
|
578
|
+
throw new InvalidXmlError("Dataset element must have an 'id' attribute");
|
|
563
579
|
}
|
|
580
|
+
const datasetId = datasetsElement.attributes?.id;
|
|
581
|
+
const dataset = new Dataset(datasetId);
|
|
582
|
+
xapiRoot.addDataset(dataset);
|
|
583
|
+
const columnInfoElement = datasetsElement.children?.find((node) => node.tagName === "ColumnInfo");
|
|
584
|
+
parseColumnInfo(columnInfoElement, dataset);
|
|
585
|
+
const rowsElement = datasetsElement.children?.find((node) => node.tagName === "Rows");
|
|
586
|
+
parseRows(rowsElement, dataset);
|
|
564
587
|
}
|
|
565
588
|
}
|
|
566
589
|
return xapiRoot;
|
|
567
590
|
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
591
|
+
function parseValue(value, type = "STRING") {
|
|
592
|
+
value = _unescapeXml(value);
|
|
593
|
+
return _options.parseToTypes ? convertToColumnType(value, type) : value;
|
|
594
|
+
}
|
|
595
|
+
function parseColumnInfo(columnInfoElement, dataset) {
|
|
596
|
+
if (!columnInfoElement) throw new InvalidXmlError("ColumnInfo element is missing in the dataset");
|
|
597
|
+
columnInfoElement.children?.forEach((colInfo) => {
|
|
598
|
+
if (colInfo.tagName === "ConstColumn") {
|
|
599
|
+
dataset.addConstColumn({
|
|
600
|
+
id: colInfo.attributes?.id,
|
|
601
|
+
size: parseInt(colInfo.attributes?.size || "0", 10),
|
|
602
|
+
type: colInfo.attributes?.type || "STRING",
|
|
603
|
+
value: parseValue(colInfo.attributes?.value, colInfo.attributes?.type)
|
|
604
|
+
});
|
|
605
|
+
} else if (colInfo.tagName === "Column") {
|
|
606
|
+
dataset.addColumn({
|
|
607
|
+
id: colInfo.attributes?.id,
|
|
608
|
+
size: parseInt(colInfo.attributes?.size || "0", 10),
|
|
609
|
+
type: colInfo.attributes?.type || "STRING"
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
function parseRows(rowsElement, dataset) {
|
|
615
|
+
rowsElement?.children?.forEach((r) => {
|
|
616
|
+
if (r.tagName === "Row") {
|
|
617
|
+
const rowIndex = dataset.newRow();
|
|
618
|
+
dataset.rows[rowIndex].type = r.attributes?.type || void 0;
|
|
619
|
+
r.children?.forEach((col) => {
|
|
620
|
+
if (col.tagName === "Col") {
|
|
621
|
+
const colId = col.attributes?.id;
|
|
622
|
+
const value = col.children?.[0];
|
|
623
|
+
const columnInfo = dataset.getColumnInfo(colId);
|
|
624
|
+
if (!columnInfo) throw new InvalidXmlError(`Column with id ${colId} not found in dataset ${dataset.id}`);
|
|
625
|
+
const castedValue = parseValue(value, columnInfo.type);
|
|
626
|
+
dataset.rows[rowIndex].cols.push({ id: colId, value: castedValue });
|
|
627
|
+
} else if (col.tagName === "OrgRow") {
|
|
628
|
+
dataset.rows[rowIndex].orgRow = [];
|
|
629
|
+
col.children?.forEach((orgCol) => {
|
|
630
|
+
if (orgCol.tagName === "Col") {
|
|
631
|
+
const colId = orgCol.attributes?.id;
|
|
632
|
+
const value = orgCol.children?.[0];
|
|
633
|
+
const columnInfo = dataset.getColumnInfo(colId);
|
|
634
|
+
const castedValue = parseValue(value, columnInfo.type);
|
|
635
|
+
if (dataset && dataset.rows && dataset.rows[rowIndex] && dataset.rows[rowIndex].orgRow) {
|
|
636
|
+
dataset.rows[rowIndex].orgRow.push({ id: colId, value: castedValue });
|
|
637
|
+
}
|
|
638
|
+
}
|
|
590
639
|
});
|
|
591
|
-
break;
|
|
592
|
-
case "Row":
|
|
593
|
-
currentRowIndex = dataset.newRow();
|
|
594
|
-
dataset.rows[currentRowIndex].type = startEvent.attributes["type"] || void 0;
|
|
595
|
-
break;
|
|
596
|
-
case "Col": {
|
|
597
|
-
await parseCol(xmlParser, startEvent, dataset, currentRowIndex, false);
|
|
598
|
-
break;
|
|
599
640
|
}
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
for await (const orgRowEvent of xmlParser) {
|
|
606
|
-
if (orgRowEvent.type === import_stax_xml.XmlEventType.END_ELEMENT && orgRowEvent.localName === "OrgRow") {
|
|
607
|
-
break;
|
|
608
|
-
}
|
|
609
|
-
if (orgRowEvent.type === import_stax_xml.XmlEventType.START_ELEMENT && orgRowEvent.localName === "Col") {
|
|
610
|
-
const orgColEvent = orgRowEvent;
|
|
611
|
-
await parseCol(xmlParser, orgColEvent, dataset, currentRowIndex, true);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
}
|
|
641
|
+
});
|
|
642
|
+
} else if (r.tagName === "Col") {
|
|
643
|
+
throw new InvalidXmlError("Row must be defined before Col");
|
|
644
|
+
} else if (r.tagName === "OrgRow") {
|
|
645
|
+
throw new InvalidXmlError("Row must be defined before OrgRow");
|
|
615
646
|
}
|
|
616
|
-
}
|
|
617
|
-
return dataset;
|
|
647
|
+
});
|
|
618
648
|
}
|
|
619
|
-
|
|
620
|
-
if (
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
value = colCharEvent.value;
|
|
632
|
-
} else if (colCharEvent.type === import_stax_xml.XmlEventType.CHARACTERS) {
|
|
633
|
-
value = colCharEvent.value;
|
|
634
|
-
}
|
|
635
|
-
let castedValue = value;
|
|
636
|
-
if (_options.parseToTypes) {
|
|
637
|
-
const columnInfo = dataset.getColumnInfo(colId);
|
|
638
|
-
if (!columnInfo || columnType.includes(columnInfo.type) === false) {
|
|
639
|
-
throw new Error(`Column type for ${colId} not found in dataset ${dataset.id}`);
|
|
649
|
+
function parseParameters(parametersElement, xapiRoot) {
|
|
650
|
+
if (!parametersElement) return;
|
|
651
|
+
parametersElement.children?.forEach((p) => {
|
|
652
|
+
if (p.tagName === "Parameter") {
|
|
653
|
+
const id = p.attributes?.id;
|
|
654
|
+
const type = p.attributes?.type || "STRING";
|
|
655
|
+
const value = p.children?.[0];
|
|
656
|
+
xapiRoot.addParameter({
|
|
657
|
+
id,
|
|
658
|
+
type,
|
|
659
|
+
value: parseValue(value, type)
|
|
660
|
+
});
|
|
640
661
|
}
|
|
641
|
-
|
|
642
|
-
}
|
|
643
|
-
if (!isOrgRow) {
|
|
644
|
-
dataset.rows[currentRowIndex].cols.push({ id: colId, value: castedValue });
|
|
645
|
-
} else {
|
|
646
|
-
dataset.rows[currentRowIndex].orgRow.push({ id: colId, value: castedValue });
|
|
647
|
-
}
|
|
662
|
+
});
|
|
648
663
|
}
|
|
649
664
|
async function writeString(root) {
|
|
650
665
|
const stringStream = new StringWritableStream();
|
|
@@ -765,10 +780,13 @@ async function writeColumn(writer, dataset, col) {
|
|
|
765
780
|
0 && (module.exports = {
|
|
766
781
|
ColumnTypeError,
|
|
767
782
|
Dataset,
|
|
783
|
+
InvalidXmlError,
|
|
768
784
|
NexaVersion,
|
|
769
785
|
StringWritableStream,
|
|
770
786
|
XapiRoot,
|
|
771
787
|
XplatformVersion,
|
|
788
|
+
_unescapeXml,
|
|
789
|
+
arrayBufferToString,
|
|
772
790
|
base64ToUint8Array,
|
|
773
791
|
columnType,
|
|
774
792
|
convertToColumnType,
|
package/dist/index.d.cts
CHANGED
|
@@ -127,6 +127,9 @@ interface XapiOptions {
|
|
|
127
127
|
declare class ColumnTypeError extends Error {
|
|
128
128
|
constructor(message: string);
|
|
129
129
|
}
|
|
130
|
+
declare class InvalidXmlError extends Error {
|
|
131
|
+
constructor(message: string);
|
|
132
|
+
}
|
|
130
133
|
|
|
131
134
|
/**
|
|
132
135
|
* Represents the root of an X-API XML structure, containing datasets and parameters.
|
|
@@ -312,17 +315,19 @@ declare class Dataset {
|
|
|
312
315
|
/**
|
|
313
316
|
* Initializes the X-API handler with the provided options.
|
|
314
317
|
* @param options - The options to initialize the X-API handler.
|
|
318
|
+
* @returns void
|
|
315
319
|
*/
|
|
316
320
|
declare function initXapi(options: XapiOptions): void;
|
|
317
321
|
/**
|
|
318
|
-
* Parses an XML
|
|
319
|
-
* @param
|
|
322
|
+
* Parses an XML string into an XapiRoot object using txml.
|
|
323
|
+
* @param xml - The string containing the XML data.
|
|
320
324
|
* @returns A Promise that resolves to an XapiRoot object.
|
|
321
325
|
*/
|
|
322
|
-
declare function parse(
|
|
326
|
+
declare function parse(xml: string): XapiRoot;
|
|
323
327
|
declare function writeString(root: XapiRoot): Promise<string>;
|
|
324
328
|
declare function write(stream: WritableStream<Uint8Array>, root: XapiRoot): Promise<void>;
|
|
325
329
|
|
|
330
|
+
declare function arrayBufferToString(buffer: ArrayBuffer): string;
|
|
326
331
|
/**
|
|
327
332
|
* Creates an array of entities for parsing XML, including control characters.
|
|
328
333
|
* @returns An array of objects, each with an `entity` (e.g., "") and its `value` (e.g., "\x01").
|
|
@@ -398,5 +403,6 @@ declare function convertToColumnType(value: XapiValueType, type: ColumnType): Xa
|
|
|
398
403
|
* @returns The string representation of the value.
|
|
399
404
|
*/
|
|
400
405
|
declare function convertToString(value: XapiValueType, type: ColumnType): string;
|
|
406
|
+
declare function _unescapeXml(str?: string): string | undefined;
|
|
401
407
|
|
|
402
|
-
export { type Col, type Column, type ColumnInfo, type ColumnType, ColumnTypeError, type ConstColumn, Dataset, NexaVersion, type Parameter, type Row, type RowType, type Rows, StringWritableStream, type XapiOptions, type XapiParameters, XapiRoot, type XapiValueType, type XapiVersion, XplatformVersion, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, initXapi, makeParseEntities, makeWriterEntities, parse, rowType, stringToDate, stringToReadableStream, uint8ArrayToBase64, write, writeString };
|
|
408
|
+
export { type Col, type Column, type ColumnInfo, type ColumnType, ColumnTypeError, type ConstColumn, Dataset, InvalidXmlError, NexaVersion, type Parameter, type Row, type RowType, type Rows, StringWritableStream, type XapiOptions, type XapiParameters, XapiRoot, type XapiValueType, type XapiVersion, XplatformVersion, _unescapeXml, arrayBufferToString, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, initXapi, makeParseEntities, makeWriterEntities, parse, rowType, stringToDate, stringToReadableStream, uint8ArrayToBase64, write, writeString };
|
package/dist/index.d.ts
CHANGED
|
@@ -127,6 +127,9 @@ interface XapiOptions {
|
|
|
127
127
|
declare class ColumnTypeError extends Error {
|
|
128
128
|
constructor(message: string);
|
|
129
129
|
}
|
|
130
|
+
declare class InvalidXmlError extends Error {
|
|
131
|
+
constructor(message: string);
|
|
132
|
+
}
|
|
130
133
|
|
|
131
134
|
/**
|
|
132
135
|
* Represents the root of an X-API XML structure, containing datasets and parameters.
|
|
@@ -312,17 +315,19 @@ declare class Dataset {
|
|
|
312
315
|
/**
|
|
313
316
|
* Initializes the X-API handler with the provided options.
|
|
314
317
|
* @param options - The options to initialize the X-API handler.
|
|
318
|
+
* @returns void
|
|
315
319
|
*/
|
|
316
320
|
declare function initXapi(options: XapiOptions): void;
|
|
317
321
|
/**
|
|
318
|
-
* Parses an XML
|
|
319
|
-
* @param
|
|
322
|
+
* Parses an XML string into an XapiRoot object using txml.
|
|
323
|
+
* @param xml - The string containing the XML data.
|
|
320
324
|
* @returns A Promise that resolves to an XapiRoot object.
|
|
321
325
|
*/
|
|
322
|
-
declare function parse(
|
|
326
|
+
declare function parse(xml: string): XapiRoot;
|
|
323
327
|
declare function writeString(root: XapiRoot): Promise<string>;
|
|
324
328
|
declare function write(stream: WritableStream<Uint8Array>, root: XapiRoot): Promise<void>;
|
|
325
329
|
|
|
330
|
+
declare function arrayBufferToString(buffer: ArrayBuffer): string;
|
|
326
331
|
/**
|
|
327
332
|
* Creates an array of entities for parsing XML, including control characters.
|
|
328
333
|
* @returns An array of objects, each with an `entity` (e.g., "") and its `value` (e.g., "\x01").
|
|
@@ -398,5 +403,6 @@ declare function convertToColumnType(value: XapiValueType, type: ColumnType): Xa
|
|
|
398
403
|
* @returns The string representation of the value.
|
|
399
404
|
*/
|
|
400
405
|
declare function convertToString(value: XapiValueType, type: ColumnType): string;
|
|
406
|
+
declare function _unescapeXml(str?: string): string | undefined;
|
|
401
407
|
|
|
402
|
-
export { type Col, type Column, type ColumnInfo, type ColumnType, ColumnTypeError, type ConstColumn, Dataset, NexaVersion, type Parameter, type Row, type RowType, type Rows, StringWritableStream, type XapiOptions, type XapiParameters, XapiRoot, type XapiValueType, type XapiVersion, XplatformVersion, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, initXapi, makeParseEntities, makeWriterEntities, parse, rowType, stringToDate, stringToReadableStream, uint8ArrayToBase64, write, writeString };
|
|
408
|
+
export { type Col, type Column, type ColumnInfo, type ColumnType, ColumnTypeError, type ConstColumn, Dataset, InvalidXmlError, NexaVersion, type Parameter, type Row, type RowType, type Rows, StringWritableStream, type XapiOptions, type XapiParameters, XapiRoot, type XapiValueType, type XapiVersion, XplatformVersion, _unescapeXml, arrayBufferToString, base64ToUint8Array, columnType, convertToColumnType, convertToString, dateToString, initXapi, makeParseEntities, makeWriterEntities, parse, rowType, stringToDate, stringToReadableStream, uint8ArrayToBase64, write, writeString };
|