@beliq/sdk 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +14 -3
- package/dist/helpers.cjs +60 -2
- package/dist/helpers.d.cts +40 -3
- package/dist/helpers.d.ts +40 -3
- package/dist/helpers.js +50 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +6 -1781
- package/dist/index.d.ts +6 -1781
- package/dist/index.js +2 -2
- package/dist/types-BRDATaM6.d.cts +1936 -0
- package/dist/types-BRDATaM6.d.ts +1936 -0
- package/package.json +4 -4
- package/dist/constants-DFGl_MXW.d.cts +0 -94
- package/dist/constants-DFGl_MXW.d.ts +0 -94
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,54 @@
|
|
|
4
4
|
resolves 0.4.x and never reaches 0.5.0. Additive spec syncs ship as patches for
|
|
5
5
|
that reason, and a minor is reserved for a change that needs consumers to opt in.
|
|
6
6
|
|
|
7
|
+
## 0.5.2 - 2026-10-24
|
|
8
|
+
|
|
9
|
+
A patch: `@beliq/sdk/helpers` gains the wording for a verdict and a converted
|
|
10
|
+
PDF, and the vendored spec moves on two documents. No method changes.
|
|
11
|
+
|
|
12
|
+
- `verdictWord`, `checkDepth` and `DEPTH_NOT_STATED`, `franceBlockingRuleIds`,
|
|
13
|
+
`franceBlockLines` and `FRANCE_CTC_BLOCKING_FINDING_RULE_ID`, `pdfInputLine`
|
|
14
|
+
and `rulesetChannelLine` are the words beliq-cli and beliq-mcp printed from
|
|
15
|
+
two copies of their own. Each restates a field of `ValidationResult`.
|
|
16
|
+
`checkDepth` gives `verificationBadgeLabel` as it came, or
|
|
17
|
+
`check depth not stated` when the API sent no label, so it never names a
|
|
18
|
+
depth the API did not state.
|
|
19
|
+
- `CONVERT_PDF_LINE` says what a PDF that `convert()` returns for a `facturx`
|
|
20
|
+
or `zugferd` target is: the PDF as sent, with only its annotation flags
|
|
21
|
+
normalised for PDF/A and its container not checked, when its embedded XML
|
|
22
|
+
already is the target, and otherwise that PDF re-wrapped around the converted XML and passed by
|
|
23
|
+
veraPDF against PDF/A-3b. With a test key the PDF is watermarked after any
|
|
24
|
+
veraPDF check, so the line never says veraPDF checked the file returned.
|
|
25
|
+
- The vendored `openapi.json` is document `0.16.0` of the API, up from
|
|
26
|
+
`0.15.0`. Document `0.15.1` describes the PDF re-wrap in `convert()`'s
|
|
27
|
+
description. Document `0.16.0` gives each `previousChannel` row of
|
|
28
|
+
`GET /v1/rulesets` a `retained` list, in the generated `operations` type
|
|
29
|
+
only: the SDK has no method for that route.
|
|
30
|
+
|
|
31
|
+
## 0.5.1 - 2026-10-11
|
|
32
|
+
|
|
33
|
+
A patch: the types gain two fields and two error codes. No method changes.
|
|
34
|
+
|
|
35
|
+
- The vendored `openapi.json` is document `0.15.0` of the API, up from
|
|
36
|
+
`0.12.0`.
|
|
37
|
+
- `ValidationResult` gains `verificationBadgeLabel`, the English label of the
|
|
38
|
+
badge in `verificationBadge`. It is display text: print it as it is, and
|
|
39
|
+
compare `verificationBadge` in code. The API sets it only beside the badge,
|
|
40
|
+
so a result with no badge has no label. The `validationResult` of a sealed
|
|
41
|
+
`generate()` is the same type and carries it too.
|
|
42
|
+
- `ValidationResult` gains `pdfInput`, which the API sets when the document
|
|
43
|
+
sent to `validate()` was a PDF: the name of the embedded file the verdict is
|
|
44
|
+
about, how that file was found, how many candidates the PDF holds, and
|
|
45
|
+
`containerChecked: false`, because nothing checked the PDF around it.
|
|
46
|
+
- The error code union gains `CONVERSION_OUTPUT_INVALID` and `PDFA_VIOLATION`.
|
|
47
|
+
`convert()` answers 422 `CONVERSION_OUTPUT_INVALID` when the converted XML
|
|
48
|
+
fails validation: the document is not returned, and the verdict is in
|
|
49
|
+
`err.details.validationResult`. `generate()` answers 422 `PDFA_VIOLATION`
|
|
50
|
+
when veraPDF reports a violation of its PDF/A-3b profile in a ZUGFeRD or
|
|
51
|
+
Factur-X PDF it built: the PDF is not returned, and the failed rules are in
|
|
52
|
+
`err.details.failedRules`. A `switch` over the code that TypeScript checks
|
|
53
|
+
for exhaustiveness needs the two new cases.
|
|
54
|
+
|
|
7
55
|
## 0.5.0 - 2026-10-08
|
|
8
56
|
|
|
9
57
|
A minor, because code that reads a `parse()` result can stop compiling, and a
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @beliq/sdk
|
|
2
2
|
|
|
3
|
-
Official Node/TypeScript SDK for the [beliq](https://beliq.eu)
|
|
3
|
+
Official Node/TypeScript SDK for the [beliq](https://beliq.eu) API: validate, generate, convert and parse EU e-invoices (XRechnung, ZUGFeRD, Factur-X, Peppol BIS) from Node.js. A validation result names the rule pack that judged the document, its version and, in `verificationBadgeLabel` when the API states one, how deep the check went. [How verification works](https://docs.beliq.eu/compliance/how-verification-works/) explains each depth.
|
|
4
4
|
|
|
5
|
-
beliq produces and checks the
|
|
5
|
+
beliq produces and checks the document. Transmission (Peppol, plateforme agréée, KSeF, SDI), archiving, and tax-authority reporting stay with your access point.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -60,7 +60,7 @@ const generated = await beliq.generate({
|
|
|
60
60
|
});
|
|
61
61
|
console.log(generated.xml, generated.meta.schematronVersion);
|
|
62
62
|
|
|
63
|
-
// Validate
|
|
63
|
+
// Validate a document. The result names the rules that ran and, when the API states one, the check depth.
|
|
64
64
|
const result = await beliq.validate(generated.xml!, { format: 'auto' });
|
|
65
65
|
if (!result.valid) {
|
|
66
66
|
for (const issue of result.errors) console.log(issue.ruleId, issue.message);
|
|
@@ -154,6 +154,17 @@ const nlcius = LIVE_GENERATE_PRESETS.find((p) => p.id === 'nlcius');
|
|
|
154
154
|
await beliq.generate({ standard: nlcius!.standard, profile: nlcius!.profile, invoice });
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
+
### Verdict and convert wording
|
|
158
|
+
|
|
159
|
+
`@beliq/sdk/helpers` holds the words the beliq tools print for a verdict, so each tool says the same thing. `verdictWord` gives `VALID`, `INVALID`, or `NOT VALIDATED` when no ruleset ran. `checkDepth` gives `verificationBadgeLabel` as the API sent it, or `check depth not stated` when it sent none. `franceBlockLines` gives the API's explanation when `franceCtcBlockingRuleIds` is present. `pdfInputLine` and `rulesetChannelLine` restate `pdfInput` and the ruleset channel. `CONVERT_PDF_LINE` says what a PDF that `convert` returns is.
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
import { checkDepth, franceBlockLines, verdictWord } from '@beliq/sdk/helpers';
|
|
163
|
+
|
|
164
|
+
const result = await beliq.validate(xml);
|
|
165
|
+
console.log(...franceBlockLines(result), `${verdictWord(result)} (${checkDepth(result)})`);
|
|
166
|
+
```
|
|
167
|
+
|
|
157
168
|
Every option enum is typed from the OpenAPI spec, so wrong values fail at compile time. Errors throw `BeliqApiError` with a typed `.code`, HTTP `.status`, and any `.details`:
|
|
158
169
|
|
|
159
170
|
```ts
|
package/dist/helpers.cjs
CHANGED
|
@@ -20,7 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/helpers.ts
|
|
21
21
|
var helpers_exports = {};
|
|
22
22
|
__export(helpers_exports, {
|
|
23
|
+
CONVERT_PDF_LINE: () => CONVERT_PDF_LINE,
|
|
23
24
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
25
|
+
DEPTH_NOT_STATED: () => DEPTH_NOT_STATED,
|
|
26
|
+
FRANCE_CTC_BLOCKING_FINDING_RULE_ID: () => FRANCE_CTC_BLOCKING_FINDING_RULE_ID,
|
|
24
27
|
LIVE_CONVERT_SOURCE_FORMATS: () => LIVE_CONVERT_SOURCE_FORMATS,
|
|
25
28
|
LIVE_CONVERT_TARGET_FORMATS: () => LIVE_CONVERT_TARGET_FORMATS,
|
|
26
29
|
LIVE_GENERATE_PRESETS: () => LIVE_GENERATE_PRESETS,
|
|
@@ -30,14 +33,20 @@ __export(helpers_exports, {
|
|
|
30
33
|
LIVE_PROFILES_BY_STANDARD: () => LIVE_PROFILES_BY_STANDARD,
|
|
31
34
|
LIVE_VALIDATE_FORMATS: () => LIVE_VALIDATE_FORMATS,
|
|
32
35
|
buildRequest: () => buildRequest,
|
|
36
|
+
checkDepth: () => checkDepth,
|
|
33
37
|
compactQuery: () => compactQuery,
|
|
34
38
|
decodeUtf8: () => decodeUtf8,
|
|
39
|
+
franceBlockLines: () => franceBlockLines,
|
|
40
|
+
franceBlockingRuleIds: () => franceBlockingRuleIds,
|
|
35
41
|
isPlainObject: () => isPlainObject,
|
|
36
42
|
isProfileAllowedForStandard: () => isProfileAllowedForStandard,
|
|
37
43
|
mergeDeep: () => mergeDeep,
|
|
44
|
+
pdfInputLine: () => pdfInputLine,
|
|
38
45
|
profilesForStandard: () => profilesForStandard,
|
|
46
|
+
rulesetChannelLine: () => rulesetChannelLine,
|
|
39
47
|
sniffContentType: () => sniffContentType,
|
|
40
|
-
toBytes: () => toBytes
|
|
48
|
+
toBytes: () => toBytes,
|
|
49
|
+
verdictWord: () => verdictWord
|
|
41
50
|
});
|
|
42
51
|
module.exports = __toCommonJS(helpers_exports);
|
|
43
52
|
|
|
@@ -219,9 +228,52 @@ var LIVE_CONVERT_TARGET_FORMATS = [
|
|
|
219
228
|
"xrechnung",
|
|
220
229
|
"peppol-bis"
|
|
221
230
|
];
|
|
231
|
+
|
|
232
|
+
// src/verdict.ts
|
|
233
|
+
var DEPTH_NOT_STATED = "check depth not stated";
|
|
234
|
+
var FRANCE_CTC_BLOCKING_FINDING_RULE_ID = "FRANCE_CTC_FINDINGS_BLOCK_TRANSMISSION";
|
|
235
|
+
var CONVERT_PDF_LINE = "The PDF is the one sent, with only its annotation flags normalised for PDF/A, when its embedded XML already is the target: that XML was checked and the PDF container was not. Otherwise it is that PDF re-wrapped around the converted XML, returned only after veraPDF passed it against PDF/A-3b. With a test key the PDF is watermarked last, after any veraPDF check. Detail: https://docs.beliq.eu/api-reference/convert/#a-pdf-sent-for-a-zugferd-or-factur-x-target";
|
|
236
|
+
function verdictWord(result) {
|
|
237
|
+
if (result.verified === false) return "NOT VALIDATED";
|
|
238
|
+
return result.valid ? "VALID" : "INVALID";
|
|
239
|
+
}
|
|
240
|
+
function checkDepth(result) {
|
|
241
|
+
return result.verificationBadgeLabel ?? DEPTH_NOT_STATED;
|
|
242
|
+
}
|
|
243
|
+
function franceBlockingRuleIds(result) {
|
|
244
|
+
return result.franceCtcBlockingRuleIds ?? [];
|
|
245
|
+
}
|
|
246
|
+
function franceBlockLines(result) {
|
|
247
|
+
const ids = franceBlockingRuleIds(result);
|
|
248
|
+
if (ids.length === 0) return [];
|
|
249
|
+
const entry = (result.warnings ?? []).find((w) => w.ruleId === FRANCE_CTC_BLOCKING_FINDING_RULE_ID);
|
|
250
|
+
const idLine = `France CTC blocking rule ids: ${ids.join(", ")}`;
|
|
251
|
+
if (!entry) return [idLine];
|
|
252
|
+
const named = new Set(entry.message.split(/[^A-Za-z0-9_-]+/));
|
|
253
|
+
return ids.every((id) => named.has(id)) ? [entry.message] : [entry.message, idLine];
|
|
254
|
+
}
|
|
255
|
+
function printable(name) {
|
|
256
|
+
return name.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}"]/gu, "?");
|
|
257
|
+
}
|
|
258
|
+
function pdfInputLine(result) {
|
|
259
|
+
const pdf = result.pdfInput;
|
|
260
|
+
if (!pdf) return void 0;
|
|
261
|
+
const name = pdf.attachmentName ? ` "${printable(pdf.attachmentName)}"` : "";
|
|
262
|
+
const others = pdf.attachmentCandidates > 1 ? ` ${pdf.attachmentCandidates} embedded files could be taken for the invoice, and nothing compared them.` : "";
|
|
263
|
+
return `PDF input: the verdict is about the embedded XML${name} (found by ${pdf.attachmentFoundBy}). The PDF itself was not checked.${others}`;
|
|
264
|
+
}
|
|
265
|
+
function rulesetChannelLine(result) {
|
|
266
|
+
if (!result.rulesetChannel) return void 0;
|
|
267
|
+
const fellBack = result.rulesetFellBack ? ", which had nothing to reach, so the latest ruleset ran" : "";
|
|
268
|
+
const sunset = result.rulesetSunsetsOn ? `; the retained ruleset is served until ${result.rulesetSunsetsOn}` : "";
|
|
269
|
+
return `Ruleset channel: ${result.rulesetChannel}${fellBack}${sunset}`;
|
|
270
|
+
}
|
|
222
271
|
// Annotate the CommonJS export names for ESM import in node:
|
|
223
272
|
0 && (module.exports = {
|
|
273
|
+
CONVERT_PDF_LINE,
|
|
224
274
|
DEFAULT_BASE_URL,
|
|
275
|
+
DEPTH_NOT_STATED,
|
|
276
|
+
FRANCE_CTC_BLOCKING_FINDING_RULE_ID,
|
|
225
277
|
LIVE_CONVERT_SOURCE_FORMATS,
|
|
226
278
|
LIVE_CONVERT_TARGET_FORMATS,
|
|
227
279
|
LIVE_GENERATE_PRESETS,
|
|
@@ -231,12 +283,18 @@ var LIVE_CONVERT_TARGET_FORMATS = [
|
|
|
231
283
|
LIVE_PROFILES_BY_STANDARD,
|
|
232
284
|
LIVE_VALIDATE_FORMATS,
|
|
233
285
|
buildRequest,
|
|
286
|
+
checkDepth,
|
|
234
287
|
compactQuery,
|
|
235
288
|
decodeUtf8,
|
|
289
|
+
franceBlockLines,
|
|
290
|
+
franceBlockingRuleIds,
|
|
236
291
|
isPlainObject,
|
|
237
292
|
isProfileAllowedForStandard,
|
|
238
293
|
mergeDeep,
|
|
294
|
+
pdfInputLine,
|
|
239
295
|
profilesForStandard,
|
|
296
|
+
rulesetChannelLine,
|
|
240
297
|
sniffContentType,
|
|
241
|
-
toBytes
|
|
298
|
+
toBytes,
|
|
299
|
+
verdictWord
|
|
242
300
|
});
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlainObject } from './
|
|
2
|
-
export { D as DEFAULT_BASE_URL, a as DocumentInput, G as GeneratePreset, L as LIVE_CONVERT_SOURCE_FORMATS, b as LIVE_CONVERT_TARGET_FORMATS, c as LIVE_GENERATE_PRESETS, d as LIVE_GENERATE_STANDARDS, e as LIVE_PARSE_FORMATS, f as LIVE_PROFILES, g as LIVE_PROFILES_BY_STANDARD, h as LIVE_VALIDATE_FORMATS, i as compactQuery, j as decodeUtf8, k as isPlainObject, l as isProfileAllowedForStandard, m as mergeDeep, p as profilesForStandard, s as sniffContentType, t as toBytes } from './
|
|
1
|
+
import { P as PlainObject, V as ValidationResult } from './types-BRDATaM6.cjs';
|
|
2
|
+
export { D as DEFAULT_BASE_URL, a as DocumentInput, G as GeneratePreset, L as LIVE_CONVERT_SOURCE_FORMATS, b as LIVE_CONVERT_TARGET_FORMATS, c as LIVE_GENERATE_PRESETS, d as LIVE_GENERATE_STANDARDS, e as LIVE_PARSE_FORMATS, f as LIVE_PROFILES, g as LIVE_PROFILES_BY_STANDARD, h as LIVE_VALIDATE_FORMATS, i as compactQuery, j as decodeUtf8, k as isPlainObject, l as isProfileAllowedForStandard, m as mergeDeep, p as profilesForStandard, s as sniffContentType, t as toBytes } from './types-BRDATaM6.cjs';
|
|
3
3
|
|
|
4
4
|
type Operation = 'me' | 'generate' | 'validate' | 'parse' | 'convert';
|
|
5
5
|
/** 'json' => parse the `{ success, data }` envelope; 'binary' => return raw bytes. */
|
|
@@ -45,4 +45,41 @@ interface BuiltRequest {
|
|
|
45
45
|
}
|
|
46
46
|
declare function buildRequest(params: BuildParams): BuiltRequest;
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Printed where the API sent no badge label for a verdict. It names no depth,
|
|
50
|
+
* so it claims none.
|
|
51
|
+
*/
|
|
52
|
+
declare const DEPTH_NOT_STATED = "check depth not stated";
|
|
53
|
+
/**
|
|
54
|
+
* The `ruleId` of the API's own `info` entry in `warnings` that explains
|
|
55
|
+
* `franceCtcBlockingRuleIds` (https://docs.beliq.eu/api-reference/validate/).
|
|
56
|
+
*/
|
|
57
|
+
declare const FRANCE_CTC_BLOCKING_FINDING_RULE_ID = "FRANCE_CTC_FINDINGS_BLOCK_TRANSMISSION";
|
|
58
|
+
/**
|
|
59
|
+
* What a PDF that `convert()` returns for a `facturx` or `zugferd` target is, in the words of
|
|
60
|
+
* https://docs.beliq.eu/api-reference/convert/. No documented field says which of the two paths
|
|
61
|
+
* ran, so the line names both. The test-key half is why it never says "veraPDF checked this
|
|
62
|
+
* file": the watermark comes after the check, and the watermarked file does not pass it.
|
|
63
|
+
*/
|
|
64
|
+
declare const CONVERT_PDF_LINE: string;
|
|
65
|
+
/**
|
|
66
|
+
* The verdict in the API's own words. `verified: false` means no ruleset ran
|
|
67
|
+
* (generate with verify off), so neither word applies.
|
|
68
|
+
*/
|
|
69
|
+
declare function verdictWord(result: Pick<ValidationResult, 'valid' | 'verified'>): string;
|
|
70
|
+
/** The badge label the API sent, as it came, or the mark for none. */
|
|
71
|
+
declare function checkDepth(result: Pick<ValidationResult, 'verificationBadgeLabel'>): string;
|
|
72
|
+
/** The France CTC rule ids the API reports as ending a transmission; empty when it sent none. */
|
|
73
|
+
declare function franceBlockingRuleIds(result: Pick<ValidationResult, 'franceCtcBlockingRuleIds'>): string[];
|
|
74
|
+
/**
|
|
75
|
+
* The lines that explain a France CTC block: the API's own message for it when
|
|
76
|
+
* the result carries one, and the rule ids unless that message already names
|
|
77
|
+
* every one of them.
|
|
78
|
+
*/
|
|
79
|
+
declare function franceBlockLines(result: Pick<ValidationResult, 'franceCtcBlockingRuleIds' | 'warnings'>): string[];
|
|
80
|
+
/** What the API says about a PDF input: which embedded file was read, and that the PDF was not checked. */
|
|
81
|
+
declare function pdfInputLine(result: Pick<ValidationResult, 'pdfInput'>): string | undefined;
|
|
82
|
+
/** Which ruleset channel the API says served the request, when the result names one. */
|
|
83
|
+
declare function rulesetChannelLine(result: Pick<ValidationResult, 'rulesetChannel' | 'rulesetFellBack' | 'rulesetSunsetsOn'>): string | undefined;
|
|
84
|
+
|
|
85
|
+
export { type BuildParams, type BuiltRequest, CONVERT_PDF_LINE, DEPTH_NOT_STATED, FRANCE_CTC_BLOCKING_FINDING_RULE_ID, type Operation, type OutputKind, PlainObject, type QueryValue, buildRequest, checkDepth, franceBlockLines, franceBlockingRuleIds, pdfInputLine, rulesetChannelLine, verdictWord };
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlainObject } from './
|
|
2
|
-
export { D as DEFAULT_BASE_URL, a as DocumentInput, G as GeneratePreset, L as LIVE_CONVERT_SOURCE_FORMATS, b as LIVE_CONVERT_TARGET_FORMATS, c as LIVE_GENERATE_PRESETS, d as LIVE_GENERATE_STANDARDS, e as LIVE_PARSE_FORMATS, f as LIVE_PROFILES, g as LIVE_PROFILES_BY_STANDARD, h as LIVE_VALIDATE_FORMATS, i as compactQuery, j as decodeUtf8, k as isPlainObject, l as isProfileAllowedForStandard, m as mergeDeep, p as profilesForStandard, s as sniffContentType, t as toBytes } from './
|
|
1
|
+
import { P as PlainObject, V as ValidationResult } from './types-BRDATaM6.js';
|
|
2
|
+
export { D as DEFAULT_BASE_URL, a as DocumentInput, G as GeneratePreset, L as LIVE_CONVERT_SOURCE_FORMATS, b as LIVE_CONVERT_TARGET_FORMATS, c as LIVE_GENERATE_PRESETS, d as LIVE_GENERATE_STANDARDS, e as LIVE_PARSE_FORMATS, f as LIVE_PROFILES, g as LIVE_PROFILES_BY_STANDARD, h as LIVE_VALIDATE_FORMATS, i as compactQuery, j as decodeUtf8, k as isPlainObject, l as isProfileAllowedForStandard, m as mergeDeep, p as profilesForStandard, s as sniffContentType, t as toBytes } from './types-BRDATaM6.js';
|
|
3
3
|
|
|
4
4
|
type Operation = 'me' | 'generate' | 'validate' | 'parse' | 'convert';
|
|
5
5
|
/** 'json' => parse the `{ success, data }` envelope; 'binary' => return raw bytes. */
|
|
@@ -45,4 +45,41 @@ interface BuiltRequest {
|
|
|
45
45
|
}
|
|
46
46
|
declare function buildRequest(params: BuildParams): BuiltRequest;
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Printed where the API sent no badge label for a verdict. It names no depth,
|
|
50
|
+
* so it claims none.
|
|
51
|
+
*/
|
|
52
|
+
declare const DEPTH_NOT_STATED = "check depth not stated";
|
|
53
|
+
/**
|
|
54
|
+
* The `ruleId` of the API's own `info` entry in `warnings` that explains
|
|
55
|
+
* `franceCtcBlockingRuleIds` (https://docs.beliq.eu/api-reference/validate/).
|
|
56
|
+
*/
|
|
57
|
+
declare const FRANCE_CTC_BLOCKING_FINDING_RULE_ID = "FRANCE_CTC_FINDINGS_BLOCK_TRANSMISSION";
|
|
58
|
+
/**
|
|
59
|
+
* What a PDF that `convert()` returns for a `facturx` or `zugferd` target is, in the words of
|
|
60
|
+
* https://docs.beliq.eu/api-reference/convert/. No documented field says which of the two paths
|
|
61
|
+
* ran, so the line names both. The test-key half is why it never says "veraPDF checked this
|
|
62
|
+
* file": the watermark comes after the check, and the watermarked file does not pass it.
|
|
63
|
+
*/
|
|
64
|
+
declare const CONVERT_PDF_LINE: string;
|
|
65
|
+
/**
|
|
66
|
+
* The verdict in the API's own words. `verified: false` means no ruleset ran
|
|
67
|
+
* (generate with verify off), so neither word applies.
|
|
68
|
+
*/
|
|
69
|
+
declare function verdictWord(result: Pick<ValidationResult, 'valid' | 'verified'>): string;
|
|
70
|
+
/** The badge label the API sent, as it came, or the mark for none. */
|
|
71
|
+
declare function checkDepth(result: Pick<ValidationResult, 'verificationBadgeLabel'>): string;
|
|
72
|
+
/** The France CTC rule ids the API reports as ending a transmission; empty when it sent none. */
|
|
73
|
+
declare function franceBlockingRuleIds(result: Pick<ValidationResult, 'franceCtcBlockingRuleIds'>): string[];
|
|
74
|
+
/**
|
|
75
|
+
* The lines that explain a France CTC block: the API's own message for it when
|
|
76
|
+
* the result carries one, and the rule ids unless that message already names
|
|
77
|
+
* every one of them.
|
|
78
|
+
*/
|
|
79
|
+
declare function franceBlockLines(result: Pick<ValidationResult, 'franceCtcBlockingRuleIds' | 'warnings'>): string[];
|
|
80
|
+
/** What the API says about a PDF input: which embedded file was read, and that the PDF was not checked. */
|
|
81
|
+
declare function pdfInputLine(result: Pick<ValidationResult, 'pdfInput'>): string | undefined;
|
|
82
|
+
/** Which ruleset channel the API says served the request, when the result names one. */
|
|
83
|
+
declare function rulesetChannelLine(result: Pick<ValidationResult, 'rulesetChannel' | 'rulesetFellBack' | 'rulesetSunsetsOn'>): string | undefined;
|
|
84
|
+
|
|
85
|
+
export { type BuildParams, type BuiltRequest, CONVERT_PDF_LINE, DEPTH_NOT_STATED, FRANCE_CTC_BLOCKING_FINDING_RULE_ID, type Operation, type OutputKind, PlainObject, type QueryValue, buildRequest, checkDepth, franceBlockLines, franceBlockingRuleIds, pdfInputLine, rulesetChannelLine, verdictWord };
|
package/dist/helpers.js
CHANGED
|
@@ -176,8 +176,51 @@ var LIVE_CONVERT_TARGET_FORMATS = [
|
|
|
176
176
|
"xrechnung",
|
|
177
177
|
"peppol-bis"
|
|
178
178
|
];
|
|
179
|
+
|
|
180
|
+
// src/verdict.ts
|
|
181
|
+
var DEPTH_NOT_STATED = "check depth not stated";
|
|
182
|
+
var FRANCE_CTC_BLOCKING_FINDING_RULE_ID = "FRANCE_CTC_FINDINGS_BLOCK_TRANSMISSION";
|
|
183
|
+
var CONVERT_PDF_LINE = "The PDF is the one sent, with only its annotation flags normalised for PDF/A, when its embedded XML already is the target: that XML was checked and the PDF container was not. Otherwise it is that PDF re-wrapped around the converted XML, returned only after veraPDF passed it against PDF/A-3b. With a test key the PDF is watermarked last, after any veraPDF check. Detail: https://docs.beliq.eu/api-reference/convert/#a-pdf-sent-for-a-zugferd-or-factur-x-target";
|
|
184
|
+
function verdictWord(result) {
|
|
185
|
+
if (result.verified === false) return "NOT VALIDATED";
|
|
186
|
+
return result.valid ? "VALID" : "INVALID";
|
|
187
|
+
}
|
|
188
|
+
function checkDepth(result) {
|
|
189
|
+
return result.verificationBadgeLabel ?? DEPTH_NOT_STATED;
|
|
190
|
+
}
|
|
191
|
+
function franceBlockingRuleIds(result) {
|
|
192
|
+
return result.franceCtcBlockingRuleIds ?? [];
|
|
193
|
+
}
|
|
194
|
+
function franceBlockLines(result) {
|
|
195
|
+
const ids = franceBlockingRuleIds(result);
|
|
196
|
+
if (ids.length === 0) return [];
|
|
197
|
+
const entry = (result.warnings ?? []).find((w) => w.ruleId === FRANCE_CTC_BLOCKING_FINDING_RULE_ID);
|
|
198
|
+
const idLine = `France CTC blocking rule ids: ${ids.join(", ")}`;
|
|
199
|
+
if (!entry) return [idLine];
|
|
200
|
+
const named = new Set(entry.message.split(/[^A-Za-z0-9_-]+/));
|
|
201
|
+
return ids.every((id) => named.has(id)) ? [entry.message] : [entry.message, idLine];
|
|
202
|
+
}
|
|
203
|
+
function printable(name) {
|
|
204
|
+
return name.replace(/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}"]/gu, "?");
|
|
205
|
+
}
|
|
206
|
+
function pdfInputLine(result) {
|
|
207
|
+
const pdf = result.pdfInput;
|
|
208
|
+
if (!pdf) return void 0;
|
|
209
|
+
const name = pdf.attachmentName ? ` "${printable(pdf.attachmentName)}"` : "";
|
|
210
|
+
const others = pdf.attachmentCandidates > 1 ? ` ${pdf.attachmentCandidates} embedded files could be taken for the invoice, and nothing compared them.` : "";
|
|
211
|
+
return `PDF input: the verdict is about the embedded XML${name} (found by ${pdf.attachmentFoundBy}). The PDF itself was not checked.${others}`;
|
|
212
|
+
}
|
|
213
|
+
function rulesetChannelLine(result) {
|
|
214
|
+
if (!result.rulesetChannel) return void 0;
|
|
215
|
+
const fellBack = result.rulesetFellBack ? ", which had nothing to reach, so the latest ruleset ran" : "";
|
|
216
|
+
const sunset = result.rulesetSunsetsOn ? `; the retained ruleset is served until ${result.rulesetSunsetsOn}` : "";
|
|
217
|
+
return `Ruleset channel: ${result.rulesetChannel}${fellBack}${sunset}`;
|
|
218
|
+
}
|
|
179
219
|
export {
|
|
220
|
+
CONVERT_PDF_LINE,
|
|
180
221
|
DEFAULT_BASE_URL,
|
|
222
|
+
DEPTH_NOT_STATED,
|
|
223
|
+
FRANCE_CTC_BLOCKING_FINDING_RULE_ID,
|
|
181
224
|
LIVE_CONVERT_SOURCE_FORMATS,
|
|
182
225
|
LIVE_CONVERT_TARGET_FORMATS,
|
|
183
226
|
LIVE_GENERATE_PRESETS,
|
|
@@ -187,12 +230,18 @@ export {
|
|
|
187
230
|
LIVE_PROFILES_BY_STANDARD,
|
|
188
231
|
LIVE_VALIDATE_FORMATS,
|
|
189
232
|
buildRequest,
|
|
233
|
+
checkDepth,
|
|
190
234
|
compactQuery,
|
|
191
235
|
decodeUtf8,
|
|
236
|
+
franceBlockLines,
|
|
237
|
+
franceBlockingRuleIds,
|
|
192
238
|
isPlainObject,
|
|
193
239
|
isProfileAllowedForStandard,
|
|
194
240
|
mergeDeep,
|
|
241
|
+
pdfInputLine,
|
|
195
242
|
profilesForStandard,
|
|
243
|
+
rulesetChannelLine,
|
|
196
244
|
sniffContentType,
|
|
197
|
-
toBytes
|
|
245
|
+
toBytes,
|
|
246
|
+
verdictWord
|
|
198
247
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -425,7 +425,7 @@ var Beliq = class {
|
|
|
425
425
|
async me() {
|
|
426
426
|
return this.#json({ operation: "me" });
|
|
427
427
|
}
|
|
428
|
-
/** Generate
|
|
428
|
+
/** Generate an e-invoice from an EN 16931 object. */
|
|
429
429
|
async generate(input) {
|
|
430
430
|
const res = await send(
|
|
431
431
|
this.#config,
|
|
@@ -460,7 +460,7 @@ var Beliq = class {
|
|
|
460
460
|
meta
|
|
461
461
|
};
|
|
462
462
|
}
|
|
463
|
-
/** Validate a document
|
|
463
|
+
/** Validate a document. The result names the rules that ran and, in `verificationBadgeLabel` when the API states one, the check depth. */
|
|
464
464
|
async validate(document, options = {}) {
|
|
465
465
|
return this.#json({
|
|
466
466
|
operation: "validate",
|