@xml-auditfile/auditfile 0.0.0-stage → 0.0.2-alpha.3

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 (83) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +183 -2
  3. package/package.json +62 -4
  4. package/src/auditfile.js +186 -0
  5. package/src/definitions/dialect.js +40 -0
  6. package/src/definitions/element-definition.js +27 -0
  7. package/src/definitions/localized-text.js +41 -0
  8. package/src/definitions/manifest.js +160 -0
  9. package/src/definitions/names.js +42 -0
  10. package/src/definitions/resources.js +29 -0
  11. package/src/definitions/view-definition.js +160 -0
  12. package/src/diagnostics/collector.js +139 -0
  13. package/src/diagnostics/diagnostic.js +53 -0
  14. package/src/diagnostics/report.js +56 -0
  15. package/src/generated/spec.js +74 -0
  16. package/src/index.js +20 -0
  17. package/src/internal/composite-key.js +2 -0
  18. package/src/internal/decimal.js +193 -0
  19. package/src/internal/encoding.js +118 -0
  20. package/src/internal/json.js +106 -0
  21. package/src/internal/sha256.js +147 -0
  22. package/src/internal/streams.js +232 -0
  23. package/src/internal/xml-reader.js +247 -0
  24. package/src/memory/memory-sink.js +68 -0
  25. package/src/reading/mapping-plan.js +91 -0
  26. package/src/reading/read-options.js +136 -0
  27. package/src/reading/read-session.js +446 -0
  28. package/src/reading/row-loader.js +362 -0
  29. package/src/reading/row.js +123 -0
  30. package/src/reading/source.js +146 -0
  31. package/src/reading/value-converter.js +136 -0
  32. package/src/schema/schema.js +256 -0
  33. package/src/sinks/sink.js +53 -0
  34. package/src/validation/reference-checker.js +146 -0
  35. package/src/validation/xaf-rules.js +167 -0
  36. package/src/versioning/version-resolver.js +119 -0
  37. package/src/versioning/version.js +217 -0
  38. package/src/views/view-result.js +20 -0
  39. package/src/views/view-runner.js +449 -0
  40. package/src/xsd/datatypes.js +141 -0
  41. package/src/xsd/regex.js +121 -0
  42. package/src/xsd/schema-set.js +555 -0
  43. package/src/xsd/validator.js +484 -0
  44. package/types/auditfile.d.ts +57 -0
  45. package/types/definitions/dialect.d.ts +27 -0
  46. package/types/definitions/element-definition.d.ts +16 -0
  47. package/types/definitions/localized-text.d.ts +25 -0
  48. package/types/definitions/manifest.d.ts +118 -0
  49. package/types/definitions/names.d.ts +25 -0
  50. package/types/definitions/resources.d.ts +9 -0
  51. package/types/definitions/view-definition.d.ts +85 -0
  52. package/types/diagnostics/collector.d.ts +38 -0
  53. package/types/diagnostics/diagnostic.d.ts +37 -0
  54. package/types/diagnostics/report.d.ts +32 -0
  55. package/types/generated/spec.d.ts +6 -0
  56. package/types/index.d.ts +18 -0
  57. package/types/internal/composite-key.d.ts +2 -0
  58. package/types/internal/decimal.d.ts +55 -0
  59. package/types/internal/encoding.d.ts +43 -0
  60. package/types/internal/json.d.ts +17 -0
  61. package/types/internal/sha256.d.ts +17 -0
  62. package/types/internal/streams.d.ts +35 -0
  63. package/types/internal/xml-reader.d.ts +50 -0
  64. package/types/memory/memory-sink.d.ts +29 -0
  65. package/types/reading/mapping-plan.d.ts +45 -0
  66. package/types/reading/read-options.d.ts +69 -0
  67. package/types/reading/read-session.d.ts +28 -0
  68. package/types/reading/row-loader.d.ts +18 -0
  69. package/types/reading/row.d.ts +53 -0
  70. package/types/reading/source.d.ts +73 -0
  71. package/types/reading/value-converter.d.ts +15 -0
  72. package/types/schema/schema.d.ts +116 -0
  73. package/types/sinks/sink.d.ts +59 -0
  74. package/types/validation/reference-checker.d.ts +11 -0
  75. package/types/validation/xaf-rules.d.ts +13 -0
  76. package/types/versioning/version-resolver.d.ts +25 -0
  77. package/types/versioning/version.d.ts +71 -0
  78. package/types/views/view-result.d.ts +13 -0
  79. package/types/views/view-runner.d.ts +1 -0
  80. package/types/xsd/datatypes.d.ts +40 -0
  81. package/types/xsd/regex.d.ts +6 -0
  82. package/types/xsd/schema-set.d.ts +20 -0
  83. package/types/xsd/validator.d.ts +48 -0
@@ -0,0 +1,118 @@
1
+ /** Logical type of a column; the values are the type names of auditfile-spec. */
2
+ export declare const ColumnType: Readonly<{
3
+ /** Text (`string`). */
4
+ String: "string";
5
+ /** Exact decimal number (`Decimal`). */
6
+ Decimal: "decimal";
7
+ /** Whole number (`number`, always a safe integer). */
8
+ Integer: "integer";
9
+ /** Date without time (`Date` at midnight UTC). */
10
+ Date: "date";
11
+ /** Date and time (`Date`; a value without time zone is taken as UTC). */
12
+ DateTime: "datetime";
13
+ /** Time of day (`string` "HH:MM:SS"). */
14
+ Time: "time";
15
+ /** True or false (`boolean`). */
16
+ Boolean: "boolean";
17
+ }>;
18
+ /** @param {string} type */
19
+ export declare function parseColumnType(type: string): string;
20
+ /** The structure of one audit file version, from manifest.json. */
21
+ export declare class AuditfileManifest {
22
+ #private;
23
+ /** Format version of manifest.json. */
24
+ formatVersion: any;
25
+ /** Audit file type, e.g. "xaf". */
26
+ standard: string;
27
+ /** Version, e.g. "3.2". */
28
+ version: string;
29
+ /** Official namespace. */
30
+ namespace: string;
31
+ /** Name of the root element. */
32
+ rootElement: string;
33
+ /** SHA-256 of the official XSD. */
34
+ xsdSha256: string;
35
+ /** Tables required by the XSD. */
36
+ requiredTables: readonly string[];
37
+ /** Tables optional in the XSD but expected in practice. */
38
+ expectedTables: readonly string[];
39
+ /** All tables in document order. */
40
+ tables: readonly ManifestTable[];
41
+ /**
42
+ * Finds a table by name, or returns null.
43
+ * @param {string} name
44
+ */
45
+ findTable(name: string): ManifestTable | null;
46
+ }
47
+ /** A table of the manifest. */
48
+ export declare class ManifestTable {
49
+ /** Position in the manifest. */
50
+ index: any;
51
+ /** Table name, e.g. "tr_line". */
52
+ name: string;
53
+ /** Element name, e.g. "trLine". */
54
+ xmlName: string;
55
+ /** Full XML path, e.g. "auditfile/company/transactions/journal/transaction/trLine". */
56
+ path: string;
57
+ /** Name of the parent table, or null for the root. */
58
+ parent: string | null;
59
+ /** Minimum occurrences relative to the XML parent element. */
60
+ minOccurs: any;
61
+ /** Maximum occurrences relative to the XML parent element; null means unbounded. */
62
+ maxOccurs: any;
63
+ /** Natural keys. */
64
+ keys: readonly ManifestKey[];
65
+ /** References to keys of other tables. */
66
+ references: readonly ManifestReference[];
67
+ /** Columns in XSD order. */
68
+ columns: readonly ManifestColumn[];
69
+ }
70
+ /** A column of a manifest table. */
71
+ export declare class ManifestColumn {
72
+ /** Position within the table. */
73
+ index: any;
74
+ /** Column name, e.g. "amnt". */
75
+ name: string;
76
+ /** Element or attribute name. */
77
+ xmlName: string;
78
+ /** Path relative to the table element: "amnt", "currency/curCode", "@attr" or ".". */
79
+ path: string;
80
+ /** "element" or "attribute". */
81
+ kind: string;
82
+ /** Logical type, one of {@link ColumnType}. */
83
+ type: string;
84
+ /** Name of the XSD type. */
85
+ xsdType: string;
86
+ /** Minimum occurrences relative to the XML parent element. */
87
+ minOccurs: any;
88
+ }
89
+ /** A natural key: the column values are unique within an import. */
90
+ export declare class ManifestKey {
91
+ /** Key name from the XSD. */
92
+ name: string;
93
+ /** Key columns. */
94
+ columns: readonly string[];
95
+ /**
96
+ * @param {string} name
97
+ * @param {string[]} columns
98
+ */
99
+ constructor(name: string, columns: string[]);
100
+ }
101
+ /** A reference from columns of one table to a key of another table. */
102
+ export declare class ManifestReference {
103
+ /** Reference name from the XSD. */
104
+ name: string;
105
+ /** Referencing columns. */
106
+ columns: readonly string[];
107
+ /** Referenced table. */
108
+ table: string;
109
+ /** Referenced key. */
110
+ key: string;
111
+ /**
112
+ * @param {string} name
113
+ * @param {string[]} columns
114
+ * @param {string} table
115
+ * @param {string} key
116
+ */
117
+ constructor(name: string, columns: string[], table: string, key: string);
118
+ }
@@ -0,0 +1,25 @@
1
+ /** What a dialect correction does. Unknown actions are refused when the definitions are loaded. */
2
+ export declare const DialectAction: Readonly<{
3
+ /** Read a file in `from` as the official namespace. */
4
+ ReplaceNamespace: "replaceNamespace";
5
+ /** A decimal comma becomes a point. */
6
+ DecimalComma: "decimalComma";
7
+ /** The time is removed from a date. */
8
+ DateFromDateTime: "dateFromDateTime";
9
+ }>;
10
+ /** How a view column aggregates its values. Unknown aggregates are refused when the definitions are loaded. */
11
+ export declare const ViewAggregate: Readonly<{
12
+ Sum: "sum";
13
+ Count: "count";
14
+ Min: "min";
15
+ Max: "max";
16
+ }>;
17
+ /** How a view column gets its value from an input row. Unknown operators are refused when the definitions are loaded. */
18
+ export declare const ViewOperator: Readonly<{
19
+ /** The value of the column. */
20
+ Column: "column";
21
+ /** The value when `by` is one of the codes, otherwise null. */
22
+ Only: "only";
23
+ /** The value, negated when `by` is one of the codes. */
24
+ Signed: "signed";
25
+ }>;
@@ -0,0 +1,9 @@
1
+ /** The files from auditfile-spec/generated/ that are embedded in this package (tools/embed-spec.mjs). */
2
+ /** @param {string} name */
3
+ export declare function exists(name: string): boolean;
4
+ /** @param {string} name */
5
+ export declare function readText(name: string): string;
6
+ /** @param {string} name */
7
+ export declare function readJson(name: string): any;
8
+ /** The bytes of an embedded file as published. */
9
+ export declare function readBytes(name: any): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,85 @@
1
+ import { LocalizedText } from './localized-text.js';
2
+ /**
3
+ * A view from views/<type>.json: a report over the rows of an import, such as a trial balance.
4
+ * Run it with {@link ViewDefinition#run} on any store that can hand out the rows of a table.
5
+ */
6
+ export declare class ViewDefinition {
7
+ /** View name, e.g. "trial_balance". */
8
+ name: string;
9
+ /** Display name. */
10
+ label: LocalizedText | null;
11
+ /** What the view shows. */
12
+ description: LocalizedText | null;
13
+ /** The table with one input row per row of the view (before grouping). */
14
+ source: string;
15
+ /** Tables joined to the source: an ancestor of the source, or a lookup on key columns. */
16
+ joins: readonly ViewJoin[];
17
+ /** Optional filters. */
18
+ parameters: readonly ViewParameter[];
19
+ /** Output columns. When any column aggregates, the other columns group. */
20
+ columns: readonly ViewColumn[];
21
+ /** Output column names to sort by, ascending. */
22
+ orderBy: readonly string[];
23
+ /** True when at least one column aggregates. */
24
+ get isAggregated(): boolean;
25
+ /**
26
+ * Runs the view. `rows` returns the rows of a table by name.
27
+ * `parameters` holds filter values by parameter name; null and undefined values are ignored.
28
+ * @param {import('../schema/schema.js').AuditfileSchema} schema
29
+ * @param {(table: string) => Iterable<import('../reading/row.js').AuditfileRow>} rows
30
+ * @param {Record<string, unknown> | Map<string, unknown> | null} [parameters]
31
+ * @param {'nl' | 'en'} [language]
32
+ * @returns {import('../views/view-result.js').ViewResult}
33
+ * @throws {TypeError} A parameter is unknown or its value cannot be converted.
34
+ */
35
+ run(schema: import('../schema/schema.js').AuditfileSchema, rows: (table: string) => Iterable<import('../reading/row.js').AuditfileRow>, parameters?: Record<string, unknown> | Map<string, unknown> | null, language?: 'nl' | 'en'): import('../views/view-result.js').ViewResult;
36
+ toString(): string;
37
+ }
38
+ /** A table joined to the source of a view. */
39
+ export declare class ViewJoin {
40
+ /** Table name. */
41
+ table: string;
42
+ /** Equality conditions; empty means {@link ViewJoin#table} is an ancestor of the source. */
43
+ on: readonly ViewJoinCondition[];
44
+ }
45
+ /** One equality condition of a join, as "table.column" references. */
46
+ export declare class ViewJoinCondition {
47
+ /** Column of the source or an earlier join. */
48
+ left: any;
49
+ /** Column of the joined table. */
50
+ right: any;
51
+ constructor(left: any, right: any);
52
+ }
53
+ /** An optional filter of a view. */
54
+ export declare class ViewParameter {
55
+ /** Parameter name, e.g. "period_from". */
56
+ name: string;
57
+ /** Display name. */
58
+ label: LocalizedText | null;
59
+ /** The filtered column, as "table.column". */
60
+ column: string;
61
+ /** "=", "<", "<=", ">" or ">=". */
62
+ operator: string;
63
+ }
64
+ /** An output column of a view. */
65
+ export declare class ViewColumn {
66
+ /** Column name. */
67
+ name: string;
68
+ /** Display name. */
69
+ label: LocalizedText | null;
70
+ aggregate: string | null;
71
+ /** The value per input row; null for a row count. */
72
+ value: ViewValue | null;
73
+ }
74
+ /** How a view column gets its value from an input row. */
75
+ export declare class ViewValue {
76
+ /** How the value is taken from `column`, one of {@link ViewOperator}. */
77
+ operator: any;
78
+ /** The value column, as "table.column". */
79
+ column: any;
80
+ /** The column holding the code, as "table.column". */
81
+ by: any;
82
+ /** Codes for "only" (in) or "signed" (negative). */
83
+ codes: readonly any[];
84
+ constructor(operator: any, column: any, by: any, codes: any);
85
+ }
@@ -0,0 +1,38 @@
1
+ import { Diagnostic } from './diagnostic.js';
2
+ /** Where a diagnostic applies. */
3
+ export declare class Location {
4
+ part: any;
5
+ line: any;
6
+ position: any;
7
+ path: any;
8
+ constructor(part?: null, line?: null, position?: null, path?: null);
9
+ static NONE: Location;
10
+ }
11
+ /**
12
+ * Collects diagnostics, formats messages from diagnostics.json and caps the list.
13
+ * The counts per severity cover every diagnostic, also the ones left out of a full list,
14
+ * and a full list makes room for an error by dropping an info or warning, so errors are never hidden behind them.
15
+ */
16
+ export declare class DiagnosticCollector {
17
+ #private;
18
+ /** Number of diagnostics per severity, including the ones left out. */
19
+ counts: {
20
+ info: number;
21
+ warning: number;
22
+ error: number;
23
+ fatal: number;
24
+ };
25
+ constructor(language: any, maximum: any);
26
+ /** @type {Diagnostic[]} The kept diagnostics, followed by XAF-X900 when some were left out. */
27
+ get items(): Diagnostic[];
28
+ get hasFatal(): boolean;
29
+ get hasErrors(): boolean;
30
+ /** True when diagnostics were left out of {@link DiagnosticCollector#items}. */
31
+ get isTruncated(): boolean;
32
+ /**
33
+ * @param {string} code
34
+ * @param {Location} location
35
+ * @param {Record<string, unknown>} [args]
36
+ */
37
+ add(code: string, location: Location, args?: Record<string, unknown>): void;
38
+ }
@@ -0,0 +1,37 @@
1
+ /** Severity of a diagnostic, from least to most severe. */
2
+ export declare const DiagnosticSeverity: Readonly<{
3
+ /** Information only. */
4
+ Info: "info";
5
+ /** Something to look at; the result is still usable. */
6
+ Warning: "warning";
7
+ /** The file does not meet the standard. */
8
+ Error: "error";
9
+ /** Reading stopped. */
10
+ Fatal: "fatal";
11
+ }>;
12
+ /**
13
+ * Orders severities: negative when `a` is less severe than `b`.
14
+ * @param {string} a
15
+ * @param {string} b
16
+ */
17
+ export declare function compareSeverity(a: string, b: string): number;
18
+ /** A finding about an audit file, with a stable code from auditfile-spec. */
19
+ export declare class Diagnostic {
20
+ /** Code, e.g. "XAF-R001". */
21
+ code: any;
22
+ /** "xml", "version", "structure", "xsd", "rules", "dialect" or "view". */
23
+ layer: any;
24
+ /** Severity, one of {@link DiagnosticSeverity}. */
25
+ severity: any;
26
+ /** Message in the requested language. */
27
+ message: any;
28
+ /** Source part (1-based), when known; otherwise null. */
29
+ part: any;
30
+ /** Line number, when known; otherwise null. */
31
+ line: any;
32
+ /** Position on the line, when known; otherwise null. */
33
+ position: any;
34
+ /** XML path, when known; otherwise null. */
35
+ path: any;
36
+ toString(): string;
37
+ }
@@ -0,0 +1,32 @@
1
+ /** Outcome of a scan, validation or read. */
2
+ export declare class AuditfileReport {
3
+ #private;
4
+ /** @type {import('../schema/schema.js').AuditfileSchema | null} The import schema, or null when the version could not be determined. */
5
+ schema: import('../schema/schema.js').AuditfileSchema | null;
6
+ /** @type {readonly import('../reading/source.js').PartInfo[]} Source parts with size and SHA-256 (empty when a part was not read completely). */
7
+ parts: readonly import('../reading/source.js').PartInfo[];
8
+ /**
9
+ * @type {readonly import('./diagnostic.js').Diagnostic[]} The diagnostics, in the order they were found, at most `maxDiagnostics`
10
+ * plus XAF-X900 when more were found. A full list makes room for errors by leaving out infos and warnings; fatal diagnostics are always included.
11
+ */
12
+ diagnostics: readonly import('./diagnostic.js').Diagnostic[];
13
+ /** True when diagnostics were left out of {@link AuditfileReport#diagnostics}; {@link AuditfileReport#count} still counts them. */
14
+ isTruncated: any;
15
+ /** @type {ReadonlyMap<string, number>} Rows per table. */
16
+ rowCounts: ReadonlyMap<string, number>;
17
+ /** True when rows were handed to the sink and completed. */
18
+ loaded: any;
19
+ /** Time taken, in milliseconds. */
20
+ duration: any;
21
+ /** True when a fatal diagnostic was found: reading stopped. */
22
+ get hasFatal(): boolean;
23
+ /** True when an error or fatal diagnostic was found, also when it is not in a truncated {@link AuditfileReport#diagnostics}. */
24
+ get hasErrors(): boolean;
25
+ /** True when there are no errors and no fatal diagnostics. */
26
+ get isValid(): boolean;
27
+ /**
28
+ * Number of diagnostics with the given severity, including the ones left out of a truncated {@link AuditfileReport#diagnostics}.
29
+ * @param {string} severity One of {@link DiagnosticSeverity}.
30
+ */
31
+ count(severity: string): any;
32
+ }
@@ -0,0 +1,6 @@
1
+ export declare const spec: {
2
+ repository: string;
3
+ tag: string;
4
+ commit: string;
5
+ };
6
+ export declare const files: Map<string, string>;
@@ -0,0 +1,18 @@
1
+ export { Auditfile, AuditfileReader } from './auditfile.js';
2
+ export { Dialect, DialectCorrection } from './definitions/dialect.js';
3
+ export { ElementDefinition } from './definitions/element-definition.js';
4
+ export { LocalizedText, TextLanguage } from './definitions/localized-text.js';
5
+ export { AuditfileManifest, ColumnType, ManifestColumn, ManifestKey, ManifestReference, ManifestTable } from './definitions/manifest.js';
6
+ export { DialectAction, ViewAggregate, ViewOperator } from './definitions/names.js';
7
+ export { ViewColumn, ViewDefinition, ViewJoin, ViewJoinCondition, ViewParameter, ViewValue } from './definitions/view-definition.js';
8
+ export { compareSeverity, Diagnostic, DiagnosticSeverity } from './diagnostics/diagnostic.js';
9
+ export { AuditfileReport } from './diagnostics/report.js';
10
+ export { Decimal } from './internal/decimal.js';
11
+ export { MemorySink } from './memory/memory-sink.js';
12
+ export { ReadMode, ReadProgress } from './reading/read-options.js';
13
+ export { AuditfileRow } from './reading/row.js';
14
+ export { AuditfileSource, PartInfo, SourcePart } from './reading/source.js';
15
+ export { AuditfileSchema, SchemaColumn, SchemaTable, VersionSource } from './schema/schema.js';
16
+ export { ImportContext, SinkCapabilities } from './sinks/sink.js';
17
+ export { AuditfileVersion } from './versioning/version.js';
18
+ export { ViewResult } from './views/view-result.js';
@@ -0,0 +1,2 @@
1
+ /** Joins the values of composite keys, view groups and joins: a character that cannot occur in XML text. */
2
+ export declare const SEPARATOR = "\u001F";
@@ -0,0 +1,55 @@
1
+ /**
2
+ * An exact decimal number: a BigInt coefficient and a scale (digits after the point).
3
+ * Amounts are never floating point, so totals and balances are exact.
4
+ * The scale is kept as written: `Decimal.parse('100.00').toString()` is `'100.00'`.
5
+ */
6
+ export declare class Decimal {
7
+ #private;
8
+ /**
9
+ * @param {bigint} coefficient
10
+ * @param {number} [scale]
11
+ */
12
+ constructor(coefficient: bigint, scale?: number);
13
+ /** Zero. */
14
+ static ZERO: Decimal;
15
+ /**
16
+ * Parses XSD notation: an optional sign, digits and an optional decimal point. No exponent, no grouping.
17
+ * Returns null when the text is not valid or outside the range of a .NET decimal.
18
+ * @param {string} text
19
+ * @returns {Decimal | null}
20
+ */
21
+ static parse(text: string): Decimal | null;
22
+ /**
23
+ * Converts a number, bigint, numeric string or Decimal.
24
+ * @param {Decimal | number | bigint | string} value
25
+ * @returns {Decimal}
26
+ */
27
+ static from(value: Decimal | number | bigint | string): Decimal;
28
+ /** The unscaled value. */
29
+ get coefficient(): bigint;
30
+ /** Digits after the decimal point. */
31
+ get scale(): number;
32
+ /** @param {Decimal} other */
33
+ add(other: Decimal): Decimal;
34
+ /** @param {Decimal} other */
35
+ subtract(other: Decimal): Decimal;
36
+ negate(): Decimal;
37
+ /**
38
+ * Compares by value: `1.0` equals `1.00`.
39
+ * @param {Decimal} other
40
+ * @returns {-1 | 0 | 1}
41
+ */
42
+ compareTo(other: Decimal): -1 | 0 | 1;
43
+ /** @param {unknown} other */
44
+ equals(other: unknown): boolean;
45
+ /** True when the value has no fractional part. */
46
+ get isInteger(): boolean;
47
+ /** The value with trailing fractional zeros removed: `1.50` becomes `1.5`. */
48
+ normalize(): Decimal;
49
+ /** Nearest JavaScript number; may lose precision. */
50
+ toNumber(): number;
51
+ /** Invariant notation with the scale as written, e.g. `-123.40`. */
52
+ toString(): string;
53
+ /** Serializes as a string so no precision is lost. */
54
+ toJSON(): string;
55
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The encoding of a document or part, from its byte order mark or XML declaration (UTF-8 when neither says otherwise),
3
+ * following the detection rules of XML 1.0 appendix F.
4
+ */
5
+ export declare class PartEncoding {
6
+ #private;
7
+ /** Name as declared, e.g. "utf-8", "utf-16le", "ISO-8859-1". */
8
+ name: any;
9
+ bomLength: any;
10
+ /** Bytes per code unit: 1 for UTF-8 and single-byte encodings, 2 for UTF-16. */
11
+ unitSize: any;
12
+ bigEndian: any;
13
+ /** Upper-case name for messages, e.g. "UTF-8". */
14
+ get label(): any;
15
+ /** True when both decode the same way; labels such as "latin1" and "ISO-8859-1" are the same encoding. */
16
+ sameAs(other: any): boolean;
17
+ /**
18
+ * @param {Uint8Array} bytes The first bytes.
19
+ * @returns {PartEncoding}
20
+ */
21
+ static detect(bytes: Uint8Array): PartEncoding;
22
+ /**
23
+ * Number of bytes of a leading byte order mark and XML declaration.
24
+ * @param {Uint8Array} bytes
25
+ * @param {number} length Bytes to look at.
26
+ */
27
+ skipDeclaration(bytes: Uint8Array, length: number): any;
28
+ }
29
+ /** The declared encoding is not supported (XAF-X004). */
30
+ export declare class XmlEncodingError extends Error {
31
+ encoding: any;
32
+ /** @type {number | null} The part, when one part differs from the first. */
33
+ part: number | null;
34
+ constructor(encoding: any, message?: string);
35
+ }
36
+ /**
37
+ * A continuation part in another encoding than the first part. The parts are decoded as one document,
38
+ * so it would be read as garbled text without any error; it is refused instead (XAF-X004).
39
+ */
40
+ export declare class PartEncodingError extends XmlEncodingError {
41
+ part: any;
42
+ constructor(part: any, encoding: any, first: any);
43
+ }
@@ -0,0 +1,17 @@
1
+ /** @param {unknown} value */
2
+ declare function isObject(value: unknown): boolean;
3
+ /**
4
+ * @param {string} text
5
+ * @param {string} name
6
+ */
7
+ export declare function parseObject(text: string, name: string): any;
8
+ export declare function string(json: any, key: any): string;
9
+ export declare function optionalString(json: any, key: any): string | null;
10
+ export declare function int(json: any, key: any): any;
11
+ export declare function optionalInt(json: any, key: any): any;
12
+ export declare function bool(json: any, key: any): boolean;
13
+ export declare function object(json: any, key: any): any;
14
+ export declare function array(json: any, key: any): any[];
15
+ export declare function objects(json: any, key: any): any[];
16
+ export declare function strings(json: any, key: any): string[];
17
+ export { isObject };
@@ -0,0 +1,17 @@
1
+ export declare class Sha256 {
2
+ #private;
3
+ /** @param {Uint8Array} data */
4
+ update(data: Uint8Array): this;
5
+ /** Finishes the hash and returns it as lowercase hex. */
6
+ digestHex(): string;
7
+ /** @param {Uint8Array} data */
8
+ static hex(data: Uint8Array): any;
9
+ /**
10
+ * The fastest available implementation: Node's when present, this one otherwise.
11
+ * @returns {{ update(data: Uint8Array): unknown, digestHex(): string }}
12
+ */
13
+ static create(): {
14
+ update(data: Uint8Array): unknown;
15
+ digestHex(): string;
16
+ };
17
+ }
@@ -0,0 +1,35 @@
1
+ import { PartInfo } from '../reading/source.js';
2
+ /** A part could not be opened or read; reported as XAF-X002, never thrown to the caller. */
3
+ export declare class SourceError extends Error {
4
+ part: any;
5
+ constructor(part: any, cause: any);
6
+ }
7
+ /**
8
+ * An async iterator over the chunks of any supported stream.
9
+ * With keepOpen the caller's stream is not destroyed when reading stops early.
10
+ * @returns {AsyncIterator<unknown>}
11
+ */
12
+ export declare function iterate(stream: any, keepOpen: any): AsyncIterator<unknown>;
13
+ /**
14
+ * Reads the parts of a source one after another as one document.
15
+ * For continuation parts a leading byte order mark and XML declaration are skipped; a part in another encoding
16
+ * than the first is refused (PartEncodingError), because it would be decoded with the encoding of the first part.
17
+ * Collects size, SHA-256 and line count per part when collectStatistics is set.
18
+ */
19
+ export declare class ConcatenatedStream {
20
+ #private;
21
+ collectStatistics: boolean;
22
+ /** @type {PartInfo[]} Statistics of the parts read completely so far. */
23
+ completed: PartInfo[];
24
+ /** Number (1-based) of the part the most recent chunk came from. */
25
+ part: number;
26
+ /** Bytes handed out so far, over all parts. */
27
+ position: number;
28
+ /**
29
+ * @param {readonly import('../reading/source.js').SourcePart[]} parts
30
+ * @param {boolean} collectStatistics
31
+ */
32
+ constructor(parts: readonly import('../reading/source.js').SourcePart[], collectStatistics: boolean);
33
+ /** @returns {AsyncGenerator<Uint8Array>} */
34
+ chunks(): AsyncGenerator<Uint8Array>;
35
+ }
@@ -0,0 +1,50 @@
1
+ import { XmlEncodingError } from './encoding.js';
2
+ /** Event kinds. */
3
+ export declare const START = 1;
4
+ export declare const END = 2;
5
+ export declare const TEXT = 3;
6
+ /** The document is not well-formed XML, or its bytes cannot be decoded. */
7
+ export declare class XmlSyntaxError extends Error {
8
+ line: any;
9
+ column: any;
10
+ part: any;
11
+ constructor(message: any, line: any, column: any, part: any);
12
+ }
13
+ export { XmlEncodingError };
14
+ /**
15
+ * Pull reader over a byte stream: start, text and end events with line, column, depth and source part.
16
+ * DTDs are refused, entities other than the five predefined ones are errors, and namespaces are resolved.
17
+ */
18
+ export declare class XmlReader {
19
+ #private;
20
+ /** @param {import('./streams.js').ConcatenatedStream} stream */
21
+ /**
22
+ * @param {import('./streams.js').ConcatenatedStream} stream
23
+ * @param {{ maxCharacters?: number }} [limits] maxCharacters: characters in the whole document; 0 is no limit.
24
+ */
25
+ constructor(stream: import('./streams.js').ConcatenatedStream, { maxCharacters }?: {
26
+ maxCharacters?: number;
27
+ });
28
+ /** Bytes before the slice in which the root element starts; precise to one slice (64 KB). */
29
+ rootOffset: null;
30
+ /** Bytes handed to the parser so far. */
31
+ get position(): number;
32
+ /** The source part being parsed. */
33
+ get part(): number;
34
+ /** Presents one namespace as another, e.g. an alias as the official namespace. */
35
+ mapNamespace(from: any, to: any): void;
36
+ /**
37
+ * The next event when one is already parsed; undefined when the caller must await {@link XmlReader#next}.
38
+ * Saves a promise per event, which is most of the cost of a large file.
39
+ */
40
+ poll(): any;
41
+ /**
42
+ * The next event, or null at the end of the document.
43
+ * @throws {XmlSyntaxError | XmlEncodingError}
44
+ */
45
+ next(): Promise<any>;
46
+ /** Puts an event back so the next call returns it again. */
47
+ pushBack(event: any): void;
48
+ /** Stops reading and closes the streams it opened. */
49
+ close(): Promise<void>;
50
+ }
@@ -0,0 +1,29 @@
1
+ /** Keeps all rows in memory, per table. Useful for tests, small files and the browser. */
2
+ export declare class MemorySink {
3
+ #private;
4
+ capabilities: 0;
5
+ /** @type {import('../schema/schema.js').AuditfileSchema | null} The import schema, after begin. */
6
+ schema: import('../schema/schema.js').AuditfileSchema | null;
7
+ /** @type {import('../diagnostics/report.js').AuditfileReport | null} The report, after completion or abort. */
8
+ report: import('../diagnostics/report.js').AuditfileReport | null;
9
+ /** True when the import was aborted; no rows are kept then. */
10
+ isAborted: boolean;
11
+ /**
12
+ * Rows of a table; empty when the table has no rows.
13
+ * @param {string} table
14
+ * @returns {readonly import('../reading/row.js').AuditfileRow[]}
15
+ */
16
+ rows(table: string): readonly import('../reading/row.js').AuditfileRow[];
17
+ /**
18
+ * Runs a view, e.g. `sink.run(sink.schema.version.findView('trial_balance'))`, over the rows in memory.
19
+ * @param {import('../definitions/view-definition.js').ViewDefinition} view
20
+ * @param {Record<string, unknown> | Map<string, unknown> | null} [parameters]
21
+ * @param {'nl' | 'en'} [language]
22
+ * @throws {Error} Nothing has been read yet.
23
+ */
24
+ run(view: import('../definitions/view-definition.js').ViewDefinition, parameters?: Record<string, unknown> | Map<string, unknown> | null, language?: 'nl' | 'en'): import("../index.js").ViewResult;
25
+ begin(context: any): void;
26
+ write(table: any, rows: any): void;
27
+ complete(report: any): void;
28
+ abort(report: any): void;
29
+ }