@formfeed/engine 0.3.11 → 0.3.12
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/index.cjs +2414 -241
- package/index.js +2414 -241
- package/package.json +3 -2
- package/types/frame/text-edit.d.cts +8 -1
- package/types/frame/text-edit.d.ts +8 -1
- package/types/index.d.cts +3 -1
- package/types/index.d.ts +3 -1
- package/types/lib/assemble.d.cts +8 -0
- package/types/lib/assemble.d.ts +8 -0
- package/types/lib/einvoice/check.d.cts +181 -0
- package/types/lib/einvoice/check.d.ts +181 -0
- package/types/lib/einvoice/cii.d.cts +18 -0
- package/types/lib/einvoice/cii.d.ts +18 -0
- package/types/lib/einvoice/codes.generated.d.cts +14 -0
- package/types/lib/einvoice/codes.generated.d.ts +14 -0
- package/types/lib/einvoice/decimal.d.cts +29 -0
- package/types/lib/einvoice/decimal.d.ts +29 -0
- package/types/lib/einvoice/display.d.cts +43 -0
- package/types/lib/einvoice/display.d.ts +43 -0
- package/types/lib/einvoice/html-text.d.cts +17 -0
- package/types/lib/einvoice/html-text.d.ts +17 -0
- package/types/lib/einvoice/index.d.cts +45 -0
- package/types/lib/einvoice/index.d.ts +45 -0
- package/types/lib/einvoice/locate.d.cts +21 -0
- package/types/lib/einvoice/locate.d.ts +21 -0
- package/types/lib/einvoice/report.d.cts +59 -0
- package/types/lib/einvoice/report.d.ts +59 -0
- package/types/lib/einvoice/schema.d.cts +293 -0
- package/types/lib/einvoice/schema.d.ts +293 -0
- package/types/lib/einvoice/skeleton.d.cts +10 -0
- package/types/lib/einvoice/skeleton.d.ts +10 -0
- package/types/lib/generated/frames.d.cts +2 -2
- package/types/lib/generated/frames.d.ts +2 -2
- package/types/lib/preview.d.cts +6 -0
- package/types/lib/preview.d.ts +6 -0
- package/types/lib/source-edit.d.cts +5 -0
- package/types/lib/source-edit.d.ts +5 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Invoice } from './check.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* The display check (spec 17 §5.2). In a hybrid invoice the XML is the invoice, and a PDF that shows
|
|
4
|
+
* other details can count as a second one. Nothing makes a template print `_invoice`: one that adds
|
|
5
|
+
* up its own totals, or shows another field's number, renders without complaint. So the text of the
|
|
6
|
+
* finished PDF is searched for what the XML says: the invoice number and the totals.
|
|
7
|
+
*
|
|
8
|
+
* It finds a value that is missing, not a wrong one printed beside the right one. It is a net, not
|
|
9
|
+
* a proof, and it errs towards "shown": signs are ignored, because a credit note prints as negative
|
|
10
|
+
* what its XML states as positive, and a number counts in either notation, `1.234,56` or `1,234.56`.
|
|
11
|
+
*
|
|
12
|
+
* One function for the worker (the text the sidecar extracts), the editor (the preview's text) and
|
|
13
|
+
* the CLI, so all three agree on what "shown" means.
|
|
14
|
+
*/
|
|
15
|
+
export interface DisplayValue {
|
|
16
|
+
/** The business term of EN 16931, `BT-112`. */
|
|
17
|
+
term: string;
|
|
18
|
+
/** Where the value sits in `_invoice`. */
|
|
19
|
+
path: string;
|
|
20
|
+
/** The value as the XML states it. */
|
|
21
|
+
value: string;
|
|
22
|
+
shown: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface DisplayCheck {
|
|
25
|
+
/** The terms that were looked for, in the order they were checked. */
|
|
26
|
+
checked: string[];
|
|
27
|
+
/** Those of them the text does not show. */
|
|
28
|
+
missing: string[];
|
|
29
|
+
values: DisplayValue[];
|
|
30
|
+
}
|
|
31
|
+
/** What a term is called where a message names it. */
|
|
32
|
+
export declare const DISPLAY_TERMS: Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Every amount the text shows, in cents and without its sign. A run of digits and separators is
|
|
35
|
+
* read each way it can be read: `3.760` is three thousand seven hundred and sixty and also three
|
|
36
|
+
* point seven six, and `8 120,00` is both that number and `120,00` after an `8`. A line break never
|
|
37
|
+
* joins two numbers, so a page number above a total does not become part of it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function shownAmounts(text: string): Set<bigint>;
|
|
40
|
+
/** The text of a PDF (one string, or one per page) against the invoice its XML states. */
|
|
41
|
+
export declare function displayCheck(text: string | readonly string[], invoice: Invoice): DisplayCheck;
|
|
42
|
+
/** The values a check did not find, as one sentence for a problem or a warning; `null` when all are shown. */
|
|
43
|
+
export declare function displayMissingText(check: DisplayCheck): string | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Invoice } from './check.js';
|
|
2
|
+
/**
|
|
3
|
+
* The display check (spec 17 §5.2). In a hybrid invoice the XML is the invoice, and a PDF that shows
|
|
4
|
+
* other details can count as a second one. Nothing makes a template print `_invoice`: one that adds
|
|
5
|
+
* up its own totals, or shows another field's number, renders without complaint. So the text of the
|
|
6
|
+
* finished PDF is searched for what the XML says: the invoice number and the totals.
|
|
7
|
+
*
|
|
8
|
+
* It finds a value that is missing, not a wrong one printed beside the right one. It is a net, not
|
|
9
|
+
* a proof, and it errs towards "shown": signs are ignored, because a credit note prints as negative
|
|
10
|
+
* what its XML states as positive, and a number counts in either notation, `1.234,56` or `1,234.56`.
|
|
11
|
+
*
|
|
12
|
+
* One function for the worker (the text the sidecar extracts), the editor (the preview's text) and
|
|
13
|
+
* the CLI, so all three agree on what "shown" means.
|
|
14
|
+
*/
|
|
15
|
+
export interface DisplayValue {
|
|
16
|
+
/** The business term of EN 16931, `BT-112`. */
|
|
17
|
+
term: string;
|
|
18
|
+
/** Where the value sits in `_invoice`. */
|
|
19
|
+
path: string;
|
|
20
|
+
/** The value as the XML states it. */
|
|
21
|
+
value: string;
|
|
22
|
+
shown: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface DisplayCheck {
|
|
25
|
+
/** The terms that were looked for, in the order they were checked. */
|
|
26
|
+
checked: string[];
|
|
27
|
+
/** Those of them the text does not show. */
|
|
28
|
+
missing: string[];
|
|
29
|
+
values: DisplayValue[];
|
|
30
|
+
}
|
|
31
|
+
/** What a term is called where a message names it. */
|
|
32
|
+
export declare const DISPLAY_TERMS: Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Every amount the text shows, in cents and without its sign. A run of digits and separators is
|
|
35
|
+
* read each way it can be read: `3.760` is three thousand seven hundred and sixty and also three
|
|
36
|
+
* point seven six, and `8 120,00` is both that number and `120,00` after an `8`. A line break never
|
|
37
|
+
* joins two numbers, so a page number above a total does not become part of it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function shownAmounts(text: string): Set<bigint>;
|
|
40
|
+
/** The text of a PDF (one string, or one per page) against the invoice its XML states. */
|
|
41
|
+
export declare function displayCheck(text: string | readonly string[], invoice: Invoice): DisplayCheck;
|
|
42
|
+
/** The values a check did not find, as one sentence for a problem or a warning; `null` when all are shown. */
|
|
43
|
+
export declare function displayMissingText(check: DisplayCheck): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text of a rendered HTML document, for the display check before anything is rendered to PDF
|
|
3
|
+
* (spec 17 §5.2, §8): the editor holds the preview's document against the invoice, and the CLI the
|
|
4
|
+
* document it renders locally. The render itself checks the text of the finished PDF, which the
|
|
5
|
+
* sidecar extracts; this is the early warning, and it reads the markup, not the page.
|
|
6
|
+
*
|
|
7
|
+
* So it does not know what CSS hides or generates. What it must get right is where one number ends
|
|
8
|
+
* and the next begins: two table cells are two amounts, and an amount set in two `<span>`s is one.
|
|
9
|
+
* Elements that flow in a line join their text; every other element ends the line.
|
|
10
|
+
*
|
|
11
|
+
* No DOM is used: the engine runs in a Worker and in Node as well as in the browser.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The text a reader of `html` sees, as far as the markup says: comments, scripts and styles left
|
|
15
|
+
* out, references decoded, and a line break wherever an element that is not inline starts or ends.
|
|
16
|
+
*/
|
|
17
|
+
export declare function htmlText(html: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text of a rendered HTML document, for the display check before anything is rendered to PDF
|
|
3
|
+
* (spec 17 §5.2, §8): the editor holds the preview's document against the invoice, and the CLI the
|
|
4
|
+
* document it renders locally. The render itself checks the text of the finished PDF, which the
|
|
5
|
+
* sidecar extracts; this is the early warning, and it reads the markup, not the page.
|
|
6
|
+
*
|
|
7
|
+
* So it does not know what CSS hides or generates. What it must get right is where one number ends
|
|
8
|
+
* and the next begins: two table cells are two amounts, and an amount set in two `<span>`s is one.
|
|
9
|
+
* Elements that flow in a line join their text; every other element ends the line.
|
|
10
|
+
*
|
|
11
|
+
* No DOM is used: the engine runs in a Worker and in Node as well as in the browser.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The text a reader of `html` sees, as far as the markup says: comments, scripts and styles left
|
|
15
|
+
* out, references decoded, and a line break wherever an element that is not inline starts or ends.
|
|
16
|
+
*/
|
|
17
|
+
export declare function htmlText(html: string): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@formfeed/engine/einvoice` (spec 17): the `_invoice` block, the rules it is held to, the CII XML
|
|
3
|
+
* written from it and the display check. No template engine is imported here and nothing of Node,
|
|
4
|
+
* so the gateway Worker, the render-worker, the editor and the CLI all run the same code: what the
|
|
5
|
+
* API refuses, the editor has already said.
|
|
6
|
+
*/
|
|
7
|
+
import { type Invoice, type InvoiceProblem } from './check.cjs';
|
|
8
|
+
import type { EinvoiceFlavour, EinvoiceProfile } from './schema.cjs';
|
|
9
|
+
export { checkInvoice, type CheckOptions, type Identifier, type Invoice, type InvoiceAddress, type InvoiceAllowance, type InvoiceBreakdown, type InvoiceCheck, type InvoiceLine, type InvoiceParty, type InvoiceProblem, type InvoiceProblemCode, type InvoiceTax, } from './check.cjs';
|
|
10
|
+
export { CII_GUIDELINES, EINVOICE_XML_NAME, invoiceToCii } from './cii.cjs';
|
|
11
|
+
export { CODE_LIST_RELEASE } from './codes.generated.cjs';
|
|
12
|
+
export { DISPLAY_TERMS, displayCheck, displayMissingText, shownAmounts, type DisplayCheck, type DisplayValue, } from './display.cjs';
|
|
13
|
+
export { EINVOICE_FLAVOURS, EINVOICE_PROFILES, VAT_CATEGORIES, defaultEinvoiceOptions, einvoiceOptionsSchema, invoiceSchema, resolveEinvoiceOptions, type EinvoiceFlavour, type EinvoiceOptions, type EinvoiceOptionsInput, type EinvoiceProfile, type InvoiceInput, type ResolvedEinvoice, type VatCategory, } from './schema.cjs';
|
|
14
|
+
export { invoicePathSegments, locateJsonPath, type JsonLocation, } from './locate.cjs';
|
|
15
|
+
export { EINVOICE_FLAVOUR_NAMES, EINVOICE_MAX_MESSAGES, EINVOICE_PROFILE_NAMES, capMessages, einvoiceResult, invoiceLineOf, type EinvoiceDisplay, type EinvoiceMessage, type EinvoiceResult, type EinvoiceValidation, } from './report.cjs';
|
|
16
|
+
export { htmlText } from './html-text.cjs';
|
|
17
|
+
export { invoiceSkeleton } from './skeleton.cjs';
|
|
18
|
+
/** Where the invoice sits in the render data. */
|
|
19
|
+
export declare const INVOICE_DATA_KEY = "_invoice";
|
|
20
|
+
/**
|
|
21
|
+
* The release of the specification the XML is written for, under each of its two names: ZUGFeRD 2.5
|
|
22
|
+
* and Factur-X 1.09 are one document. The sidecar pins the same release (its validator is what a
|
|
23
|
+
* file is held to); `codes.generated.ts` carries that release's code lists.
|
|
24
|
+
*/
|
|
25
|
+
export declare const EINVOICE_SPEC_VERSIONS: Record<EinvoiceFlavour, string>;
|
|
26
|
+
/**
|
|
27
|
+
* An amount of a checked `Invoice` as the XML writes it and a reader expects it: `3760.40`. The
|
|
28
|
+
* invoice itself keeps the digits it was given (`3760.4`), which is one value all the same.
|
|
29
|
+
*/
|
|
30
|
+
export declare function invoiceAmountText(amount: string): string;
|
|
31
|
+
export type EinvoiceXml = {
|
|
32
|
+
ok: true;
|
|
33
|
+
xml: string;
|
|
34
|
+
invoice: Invoice;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
problems: InvoiceProblem[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The `_invoice` block of some render data as XML: checked, then written. A block that is absent is
|
|
41
|
+
* one finding, since a template that declares an e-invoice cannot render without one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function einvoiceXml(data: unknown, options: {
|
|
44
|
+
profile: EinvoiceProfile;
|
|
45
|
+
}): EinvoiceXml;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@formfeed/engine/einvoice` (spec 17): the `_invoice` block, the rules it is held to, the CII XML
|
|
3
|
+
* written from it and the display check. No template engine is imported here and nothing of Node,
|
|
4
|
+
* so the gateway Worker, the render-worker, the editor and the CLI all run the same code: what the
|
|
5
|
+
* API refuses, the editor has already said.
|
|
6
|
+
*/
|
|
7
|
+
import { type Invoice, type InvoiceProblem } from './check.js';
|
|
8
|
+
import type { EinvoiceFlavour, EinvoiceProfile } from './schema.js';
|
|
9
|
+
export { checkInvoice, type CheckOptions, type Identifier, type Invoice, type InvoiceAddress, type InvoiceAllowance, type InvoiceBreakdown, type InvoiceCheck, type InvoiceLine, type InvoiceParty, type InvoiceProblem, type InvoiceProblemCode, type InvoiceTax, } from './check.js';
|
|
10
|
+
export { CII_GUIDELINES, EINVOICE_XML_NAME, invoiceToCii } from './cii.js';
|
|
11
|
+
export { CODE_LIST_RELEASE } from './codes.generated.js';
|
|
12
|
+
export { DISPLAY_TERMS, displayCheck, displayMissingText, shownAmounts, type DisplayCheck, type DisplayValue, } from './display.js';
|
|
13
|
+
export { EINVOICE_FLAVOURS, EINVOICE_PROFILES, VAT_CATEGORIES, defaultEinvoiceOptions, einvoiceOptionsSchema, invoiceSchema, resolveEinvoiceOptions, type EinvoiceFlavour, type EinvoiceOptions, type EinvoiceOptionsInput, type EinvoiceProfile, type InvoiceInput, type ResolvedEinvoice, type VatCategory, } from './schema.js';
|
|
14
|
+
export { invoicePathSegments, locateJsonPath, type JsonLocation, } from './locate.js';
|
|
15
|
+
export { EINVOICE_FLAVOUR_NAMES, EINVOICE_MAX_MESSAGES, EINVOICE_PROFILE_NAMES, capMessages, einvoiceResult, invoiceLineOf, type EinvoiceDisplay, type EinvoiceMessage, type EinvoiceResult, type EinvoiceValidation, } from './report.js';
|
|
16
|
+
export { htmlText } from './html-text.js';
|
|
17
|
+
export { invoiceSkeleton } from './skeleton.js';
|
|
18
|
+
/** Where the invoice sits in the render data. */
|
|
19
|
+
export declare const INVOICE_DATA_KEY = "_invoice";
|
|
20
|
+
/**
|
|
21
|
+
* The release of the specification the XML is written for, under each of its two names: ZUGFeRD 2.5
|
|
22
|
+
* and Factur-X 1.09 are one document. The sidecar pins the same release (its validator is what a
|
|
23
|
+
* file is held to); `codes.generated.ts` carries that release's code lists.
|
|
24
|
+
*/
|
|
25
|
+
export declare const EINVOICE_SPEC_VERSIONS: Record<EinvoiceFlavour, string>;
|
|
26
|
+
/**
|
|
27
|
+
* An amount of a checked `Invoice` as the XML writes it and a reader expects it: `3760.40`. The
|
|
28
|
+
* invoice itself keeps the digits it was given (`3760.4`), which is one value all the same.
|
|
29
|
+
*/
|
|
30
|
+
export declare function invoiceAmountText(amount: string): string;
|
|
31
|
+
export type EinvoiceXml = {
|
|
32
|
+
ok: true;
|
|
33
|
+
xml: string;
|
|
34
|
+
invoice: Invoice;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
problems: InvoiceProblem[];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* The `_invoice` block of some render data as XML: checked, then written. A block that is absent is
|
|
41
|
+
* one finding, since a template that declares an e-invoice cannot render without one.
|
|
42
|
+
*/
|
|
43
|
+
export declare function einvoiceXml(data: unknown, options: {
|
|
44
|
+
profile: EinvoiceProfile;
|
|
45
|
+
}): EinvoiceXml;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Position } from '../types.cjs';
|
|
2
|
+
/**
|
|
3
|
+
* Where a finding sits in the JSON a data set is written as, so that the editor can mark the place
|
|
4
|
+
* and the CLI can print `data/default.json:38:5` instead of a path to count out by hand.
|
|
5
|
+
*
|
|
6
|
+
* `JSON.parse` keeps no positions, so the text is walked here. It only has to find its way through
|
|
7
|
+
* JSON that already parsed, not to judge it: anything unexpected ends the walk and the answer is
|
|
8
|
+
* what was reached until then.
|
|
9
|
+
*/
|
|
10
|
+
export interface JsonLocation extends Position {
|
|
11
|
+
/** How many segments of the path exist in the text; fewer than asked means the rest is missing. */
|
|
12
|
+
depth: number;
|
|
13
|
+
}
|
|
14
|
+
/** `lines[1].tax.rate` as the keys and indexes it names. */
|
|
15
|
+
export declare function invoicePathSegments(path: string): Array<string | number>;
|
|
16
|
+
/**
|
|
17
|
+
* The position of `path` in `text`: of the key (or the list item) the path ends on, or, when the
|
|
18
|
+
* text does not go that far, of the deepest part that is there. A field that is missing is thereby
|
|
19
|
+
* marked at the object it is missing from. `null` when the text has no value at all.
|
|
20
|
+
*/
|
|
21
|
+
export declare function locateJsonPath(text: string, path: ReadonlyArray<string | number>): JsonLocation | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Position } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Where a finding sits in the JSON a data set is written as, so that the editor can mark the place
|
|
4
|
+
* and the CLI can print `data/default.json:38:5` instead of a path to count out by hand.
|
|
5
|
+
*
|
|
6
|
+
* `JSON.parse` keeps no positions, so the text is walked here. It only has to find its way through
|
|
7
|
+
* JSON that already parsed, not to judge it: anything unexpected ends the walk and the answer is
|
|
8
|
+
* what was reached until then.
|
|
9
|
+
*/
|
|
10
|
+
export interface JsonLocation extends Position {
|
|
11
|
+
/** How many segments of the path exist in the text; fewer than asked means the rest is missing. */
|
|
12
|
+
depth: number;
|
|
13
|
+
}
|
|
14
|
+
/** `lines[1].tax.rate` as the keys and indexes it names. */
|
|
15
|
+
export declare function invoicePathSegments(path: string): Array<string | number>;
|
|
16
|
+
/**
|
|
17
|
+
* The position of `path` in `text`: of the key (or the list item) the path ends on, or, when the
|
|
18
|
+
* text does not go that far, of the deepest part that is there. A field that is missing is thereby
|
|
19
|
+
* marked at the object it is missing from. `null` when the text has no value at all.
|
|
20
|
+
*/
|
|
21
|
+
export declare function locateJsonPath(text: string, path: ReadonlyArray<string | number>): JsonLocation | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { DisplayCheck } from './display.cjs';
|
|
2
|
+
import type { EinvoiceFlavour, EinvoiceOptions, EinvoiceProfile } from './schema.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* What a render says about its e-invoice (spec 17 §4.1, §5): the validator's report and the display
|
|
5
|
+
* check. One shape for the render-worker that builds it, the database row that keeps it, the API
|
|
6
|
+
* that returns it, the render log and the CLI that show it.
|
|
7
|
+
*/
|
|
8
|
+
/** One finding of the validator: a rule of the XML (schematron, XSD) or of PDF/A (veraPDF). */
|
|
9
|
+
export interface EinvoiceMessage {
|
|
10
|
+
part: 'xml' | 'pdf';
|
|
11
|
+
severity: 'error' | 'warning';
|
|
12
|
+
/** `BR-CO-15`, `CII-SR-465`, or a clause of PDF/A such as `6.2.11.4.1-1`. */
|
|
13
|
+
rule: string | null;
|
|
14
|
+
message: string;
|
|
15
|
+
/** Where: an XPath into the XML, or the object of the PDF. */
|
|
16
|
+
location: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface EinvoiceValidation {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
/** The rule set the XML was held to, as the validator names it. */
|
|
21
|
+
schematron: string;
|
|
22
|
+
/** `PDF/A-3b` once the file was checked; `null` when validation ended at the XML. */
|
|
23
|
+
pdfa: string | null;
|
|
24
|
+
messages: EinvoiceMessage[];
|
|
25
|
+
/** More findings than the render keeps. */
|
|
26
|
+
truncated?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface EinvoiceDisplay {
|
|
29
|
+
/** The business terms looked for in the text of the PDF (`BT-1`, `BT-112`). */
|
|
30
|
+
checked: string[];
|
|
31
|
+
/** Those the text does not show. */
|
|
32
|
+
missing: string[];
|
|
33
|
+
}
|
|
34
|
+
/** `einvoice` of a render as the row keeps it; the API adds `xml_url`. */
|
|
35
|
+
export interface EinvoiceResult {
|
|
36
|
+
profile: EinvoiceProfile;
|
|
37
|
+
flavour: EinvoiceFlavour;
|
|
38
|
+
/** The release of the specification under the flavour's name: `1.09` or `2.5`. */
|
|
39
|
+
spec_version: string;
|
|
40
|
+
validation: EinvoiceValidation | null;
|
|
41
|
+
display: EinvoiceDisplay | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A render row travels in every list and webhook, so it keeps this many findings and says when there
|
|
45
|
+
* were more. Errors go first: a report cut short must not lose the reason it failed to warnings.
|
|
46
|
+
*/
|
|
47
|
+
export declare const EINVOICE_MAX_MESSAGES = 50;
|
|
48
|
+
export declare function capMessages(messages: readonly EinvoiceMessage[], max?: number): Pick<EinvoiceValidation, 'messages' | 'truncated'>;
|
|
49
|
+
/** The result of a render that got as far as `validation` and `display` say. */
|
|
50
|
+
export declare function einvoiceResult(options: Pick<EinvoiceOptions, 'profile' | 'flavour'>, specVersion: string, validation: EinvoiceValidation | null, display: DisplayCheck | null): EinvoiceResult;
|
|
51
|
+
/** The names a person reads: `Factur-X` and `EN 16931` for `factur-x` and `en16931`. */
|
|
52
|
+
export declare const EINVOICE_FLAVOUR_NAMES: Record<EinvoiceFlavour, string>;
|
|
53
|
+
export declare const EINVOICE_PROFILE_NAMES: Record<EinvoiceProfile, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Where in the invoice a finding of the XML sits, for a reader who knows `_invoice` and not CII:
|
|
56
|
+
* `line 2` for anything inside the second line item, `null` where the path names no line. The XPath
|
|
57
|
+
* itself stays beside it; this only spares the reader counting brackets.
|
|
58
|
+
*/
|
|
59
|
+
export declare function invoiceLineOf(location: string | null): number | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { DisplayCheck } from './display.js';
|
|
2
|
+
import type { EinvoiceFlavour, EinvoiceOptions, EinvoiceProfile } from './schema.js';
|
|
3
|
+
/**
|
|
4
|
+
* What a render says about its e-invoice (spec 17 §4.1, §5): the validator's report and the display
|
|
5
|
+
* check. One shape for the render-worker that builds it, the database row that keeps it, the API
|
|
6
|
+
* that returns it, the render log and the CLI that show it.
|
|
7
|
+
*/
|
|
8
|
+
/** One finding of the validator: a rule of the XML (schematron, XSD) or of PDF/A (veraPDF). */
|
|
9
|
+
export interface EinvoiceMessage {
|
|
10
|
+
part: 'xml' | 'pdf';
|
|
11
|
+
severity: 'error' | 'warning';
|
|
12
|
+
/** `BR-CO-15`, `CII-SR-465`, or a clause of PDF/A such as `6.2.11.4.1-1`. */
|
|
13
|
+
rule: string | null;
|
|
14
|
+
message: string;
|
|
15
|
+
/** Where: an XPath into the XML, or the object of the PDF. */
|
|
16
|
+
location: string | null;
|
|
17
|
+
}
|
|
18
|
+
export interface EinvoiceValidation {
|
|
19
|
+
valid: boolean;
|
|
20
|
+
/** The rule set the XML was held to, as the validator names it. */
|
|
21
|
+
schematron: string;
|
|
22
|
+
/** `PDF/A-3b` once the file was checked; `null` when validation ended at the XML. */
|
|
23
|
+
pdfa: string | null;
|
|
24
|
+
messages: EinvoiceMessage[];
|
|
25
|
+
/** More findings than the render keeps. */
|
|
26
|
+
truncated?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface EinvoiceDisplay {
|
|
29
|
+
/** The business terms looked for in the text of the PDF (`BT-1`, `BT-112`). */
|
|
30
|
+
checked: string[];
|
|
31
|
+
/** Those the text does not show. */
|
|
32
|
+
missing: string[];
|
|
33
|
+
}
|
|
34
|
+
/** `einvoice` of a render as the row keeps it; the API adds `xml_url`. */
|
|
35
|
+
export interface EinvoiceResult {
|
|
36
|
+
profile: EinvoiceProfile;
|
|
37
|
+
flavour: EinvoiceFlavour;
|
|
38
|
+
/** The release of the specification under the flavour's name: `1.09` or `2.5`. */
|
|
39
|
+
spec_version: string;
|
|
40
|
+
validation: EinvoiceValidation | null;
|
|
41
|
+
display: EinvoiceDisplay | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A render row travels in every list and webhook, so it keeps this many findings and says when there
|
|
45
|
+
* were more. Errors go first: a report cut short must not lose the reason it failed to warnings.
|
|
46
|
+
*/
|
|
47
|
+
export declare const EINVOICE_MAX_MESSAGES = 50;
|
|
48
|
+
export declare function capMessages(messages: readonly EinvoiceMessage[], max?: number): Pick<EinvoiceValidation, 'messages' | 'truncated'>;
|
|
49
|
+
/** The result of a render that got as far as `validation` and `display` say. */
|
|
50
|
+
export declare function einvoiceResult(options: Pick<EinvoiceOptions, 'profile' | 'flavour'>, specVersion: string, validation: EinvoiceValidation | null, display: DisplayCheck | null): EinvoiceResult;
|
|
51
|
+
/** The names a person reads: `Factur-X` and `EN 16931` for `factur-x` and `en16931`. */
|
|
52
|
+
export declare const EINVOICE_FLAVOUR_NAMES: Record<EinvoiceFlavour, string>;
|
|
53
|
+
export declare const EINVOICE_PROFILE_NAMES: Record<EinvoiceProfile, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Where in the invoice a finding of the XML sits, for a reader who knows `_invoice` and not CII:
|
|
56
|
+
* `line 2` for anything inside the second line item, `null` where the path names no line. The XPath
|
|
57
|
+
* itself stays beside it; this only spares the reader counting brackets.
|
|
58
|
+
*/
|
|
59
|
+
export declare function invoiceLineOf(location: string | null): number | null;
|