@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beliq/sdk",
3
- "version": "0.5.0",
4
- "description": "Official beliq SDK: generate, validate, parse, and convert EU-compliant e-invoices (XRechnung, ZUGFeRD, Factur-X, Peppol BIS) against authority-pinned, drift-checked rules.",
3
+ "version": "0.5.2",
4
+ "description": "Official beliq SDK: validate, generate, convert and parse EU e-invoices (XRechnung, ZUGFeRD, Factur-X, Peppol BIS) with the beliq API from Node.js.",
5
5
  "keywords": [
6
6
  "beliq",
7
7
  "e-invoice",
@@ -69,8 +69,8 @@
69
69
  "clean": "rm -rf dist",
70
70
  "build": "npm run clean && tsup",
71
71
  "typecheck": "tsc --noEmit",
72
- "lint": "eslint src test scripts",
73
- "lint:fix": "eslint src test scripts --fix",
72
+ "lint": "eslint . --max-warnings 0",
73
+ "lint:fix": "eslint . --fix",
74
74
  "scrub:check": "bash scripts/scrub-check.sh",
75
75
  "sync:spec": "node scripts/sync-spec.mjs",
76
76
  "gen:types": "node scripts/gen-types.mjs",
@@ -1,94 +0,0 @@
1
- type PlainObject = Record<string, unknown>;
2
- declare function isPlainObject(value: unknown): value is PlainObject;
3
- /** Deep-merge `source` into `target` (source wins). Arrays and scalars overwrite. */
4
- declare function mergeDeep(target: PlainObject, source: PlainObject): PlainObject;
5
- /** Drop undefined/empty entries so optional query params are omitted, not sent blank. */
6
- declare function compactQuery(query: PlainObject): PlainObject;
7
- /** Document bytes a caller may pass to validate/parse/convert. */
8
- type DocumentInput = string | Uint8Array | ArrayBuffer | ArrayBufferView;
9
- declare function toBytes(input: DocumentInput): Uint8Array;
10
- declare function decodeUtf8(bytes: Uint8Array): string;
11
- /** Sniff `application/pdf` vs `application/xml` from the leading bytes. */
12
- declare function sniffContentType(bytes: Uint8Array): string;
13
-
14
- declare const DEFAULT_BASE_URL = "https://api.beliq.eu";
15
- /**
16
- * Per-attempt deadline. Sits above the API's own worst case so the server is
17
- * always the one to answer: a client that gives up first abandons work that is
18
- * still running, and cannot tell whether the document was produced.
19
- */
20
- declare const DEFAULT_TIMEOUT_MS = 90000;
21
- /** Extra attempts after the first, for 429 / 502 / 503 only. */
22
- declare const DEFAULT_MAX_RETRIES = 3;
23
- /**
24
- * Every `standard` POST /v1/generate accepts, in the order its enum lists them.
25
- * The four national formats are Schema-checked: their authority publishes a
26
- * schema and no machine-readable business rules, so beliq checks structure and
27
- * says so. GET /v1/rulesets carries each one's badge.
28
- */
29
- declare const LIVE_GENERATE_STANDARDS: readonly ["xrechnung", "zugferd", "facturx", "peppol-bis", "fatturapa", "facturae", "eslog", "ksef"];
30
- /** A named generate target: the API `standard` plus the `profile`/`facturxProfile`/`output` it needs. */
31
- interface GeneratePreset {
32
- id: string;
33
- label: string;
34
- standard: (typeof LIVE_GENERATE_STANDARDS)[number];
35
- output: 'xml' | 'pdf';
36
- /** API `profile`; omitted lets the engine pick the standard's default. */
37
- profile?: string;
38
- /** API `facturxProfile`; Factur-X / ZUGFeRD only. */
39
- facturxProfile?: string;
40
- }
41
- /**
42
- * Named generate targets surfaced to end users (connector dropdowns), mirroring
43
- * the public set on beliq.eu's own generator. NLCIUS is a Peppol BIS profile,
44
- * not a standalone standard, so it is reachable here rather than through
45
- * LIVE_GENERATE_STANDARDS or the Factur-X-only LIVE_PROFILES.
46
- */
47
- declare const LIVE_GENERATE_PRESETS: readonly GeneratePreset[];
48
- /**
49
- * The Factur-X granularity values offered publicly. Kept as the flat list the
50
- * hybrid-PDF family shares; anything choosing a profile for a specific standard
51
- * wants LIVE_PROFILES_BY_STANDARD instead, which is what the API enforces.
52
- */
53
- declare const LIVE_PROFILES: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
54
- /**
55
- * Which profiles each standard accepts, publicly-offered values only.
56
- *
57
- * `profile` is not a free enum: the engine pins it per standard and answers a
58
- * pair outside the table with `422 PROFILE_STANDARD_MISMATCH`
59
- * (the engine's ALLOWED_PROFILES_FOR_STANDARD table). A
60
- * surface that offers one flat profile list therefore offers values that cannot
61
- * succeed: none of the Factur-X granularity values is legal for `xrechnung` or
62
- * `peppol-bis`, and `extended-ctc-fr` is the AFNOR XP Z12-012 France CTC overlay
63
- * with no ZUGFeRD-branded counterpart.
64
- *
65
- * It carries every standard the API accepts. It stays narrower than the
66
- * engine's table in one place: the `minimum` and `basic` Factur-X profiles are
67
- * engine-supported but not offered here (FNFE-MPE source gating).
68
- *
69
- * `scripts/check-profile-drift.mjs` compares this against the engine's table.
70
- */
71
- declare const LIVE_PROFILES_BY_STANDARD: {
72
- readonly xrechnung: readonly ["xrechnung"];
73
- readonly 'peppol-bis': readonly ["peppol", "romania-ro-cius", "netherlands-nlcius"];
74
- readonly zugferd: readonly ["basicwl", "en16931", "extended"];
75
- readonly facturx: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
76
- readonly fatturapa: readonly ["ordinaria"];
77
- readonly facturae: readonly ["ordinaria"];
78
- readonly eslog: readonly ["eracun"];
79
- readonly ksef: readonly ["fa3"];
80
- };
81
- /** The profiles a caller may choose for `standard`; empty for an unknown standard. */
82
- declare function profilesForStandard(standard: string): readonly string[];
83
- /**
84
- * Whether `profile` is legal for `standard`. An unknown standard passes: the API
85
- * is the authority on values this list does not carry, and a client-side guess
86
- * would refuse a request the server would have accepted.
87
- */
88
- declare function isProfileAllowedForStandard(standard: string, profile: string): boolean;
89
- declare const LIVE_VALIDATE_FORMATS: readonly ["auto", "cii", "ubl"];
90
- declare const LIVE_PARSE_FORMATS: readonly ["auto", "cii", "ubl"];
91
- declare const LIVE_CONVERT_SOURCE_FORMATS: readonly ["auto", "cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
92
- declare const LIVE_CONVERT_TARGET_FORMATS: readonly ["cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
93
-
94
- export { DEFAULT_BASE_URL as D, type GeneratePreset as G, LIVE_CONVERT_SOURCE_FORMATS as L, type PlainObject as P, type DocumentInput as a, LIVE_CONVERT_TARGET_FORMATS as b, LIVE_GENERATE_PRESETS as c, LIVE_GENERATE_STANDARDS as d, LIVE_PARSE_FORMATS as e, LIVE_PROFILES as f, LIVE_PROFILES_BY_STANDARD as g, LIVE_VALIDATE_FORMATS as h, compactQuery as i, decodeUtf8 as j, isPlainObject as k, isProfileAllowedForStandard as l, mergeDeep as m, DEFAULT_MAX_RETRIES as n, DEFAULT_TIMEOUT_MS as o, profilesForStandard as p, sniffContentType as s, toBytes as t };
@@ -1,94 +0,0 @@
1
- type PlainObject = Record<string, unknown>;
2
- declare function isPlainObject(value: unknown): value is PlainObject;
3
- /** Deep-merge `source` into `target` (source wins). Arrays and scalars overwrite. */
4
- declare function mergeDeep(target: PlainObject, source: PlainObject): PlainObject;
5
- /** Drop undefined/empty entries so optional query params are omitted, not sent blank. */
6
- declare function compactQuery(query: PlainObject): PlainObject;
7
- /** Document bytes a caller may pass to validate/parse/convert. */
8
- type DocumentInput = string | Uint8Array | ArrayBuffer | ArrayBufferView;
9
- declare function toBytes(input: DocumentInput): Uint8Array;
10
- declare function decodeUtf8(bytes: Uint8Array): string;
11
- /** Sniff `application/pdf` vs `application/xml` from the leading bytes. */
12
- declare function sniffContentType(bytes: Uint8Array): string;
13
-
14
- declare const DEFAULT_BASE_URL = "https://api.beliq.eu";
15
- /**
16
- * Per-attempt deadline. Sits above the API's own worst case so the server is
17
- * always the one to answer: a client that gives up first abandons work that is
18
- * still running, and cannot tell whether the document was produced.
19
- */
20
- declare const DEFAULT_TIMEOUT_MS = 90000;
21
- /** Extra attempts after the first, for 429 / 502 / 503 only. */
22
- declare const DEFAULT_MAX_RETRIES = 3;
23
- /**
24
- * Every `standard` POST /v1/generate accepts, in the order its enum lists them.
25
- * The four national formats are Schema-checked: their authority publishes a
26
- * schema and no machine-readable business rules, so beliq checks structure and
27
- * says so. GET /v1/rulesets carries each one's badge.
28
- */
29
- declare const LIVE_GENERATE_STANDARDS: readonly ["xrechnung", "zugferd", "facturx", "peppol-bis", "fatturapa", "facturae", "eslog", "ksef"];
30
- /** A named generate target: the API `standard` plus the `profile`/`facturxProfile`/`output` it needs. */
31
- interface GeneratePreset {
32
- id: string;
33
- label: string;
34
- standard: (typeof LIVE_GENERATE_STANDARDS)[number];
35
- output: 'xml' | 'pdf';
36
- /** API `profile`; omitted lets the engine pick the standard's default. */
37
- profile?: string;
38
- /** API `facturxProfile`; Factur-X / ZUGFeRD only. */
39
- facturxProfile?: string;
40
- }
41
- /**
42
- * Named generate targets surfaced to end users (connector dropdowns), mirroring
43
- * the public set on beliq.eu's own generator. NLCIUS is a Peppol BIS profile,
44
- * not a standalone standard, so it is reachable here rather than through
45
- * LIVE_GENERATE_STANDARDS or the Factur-X-only LIVE_PROFILES.
46
- */
47
- declare const LIVE_GENERATE_PRESETS: readonly GeneratePreset[];
48
- /**
49
- * The Factur-X granularity values offered publicly. Kept as the flat list the
50
- * hybrid-PDF family shares; anything choosing a profile for a specific standard
51
- * wants LIVE_PROFILES_BY_STANDARD instead, which is what the API enforces.
52
- */
53
- declare const LIVE_PROFILES: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
54
- /**
55
- * Which profiles each standard accepts, publicly-offered values only.
56
- *
57
- * `profile` is not a free enum: the engine pins it per standard and answers a
58
- * pair outside the table with `422 PROFILE_STANDARD_MISMATCH`
59
- * (the engine's ALLOWED_PROFILES_FOR_STANDARD table). A
60
- * surface that offers one flat profile list therefore offers values that cannot
61
- * succeed: none of the Factur-X granularity values is legal for `xrechnung` or
62
- * `peppol-bis`, and `extended-ctc-fr` is the AFNOR XP Z12-012 France CTC overlay
63
- * with no ZUGFeRD-branded counterpart.
64
- *
65
- * It carries every standard the API accepts. It stays narrower than the
66
- * engine's table in one place: the `minimum` and `basic` Factur-X profiles are
67
- * engine-supported but not offered here (FNFE-MPE source gating).
68
- *
69
- * `scripts/check-profile-drift.mjs` compares this against the engine's table.
70
- */
71
- declare const LIVE_PROFILES_BY_STANDARD: {
72
- readonly xrechnung: readonly ["xrechnung"];
73
- readonly 'peppol-bis': readonly ["peppol", "romania-ro-cius", "netherlands-nlcius"];
74
- readonly zugferd: readonly ["basicwl", "en16931", "extended"];
75
- readonly facturx: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
76
- readonly fatturapa: readonly ["ordinaria"];
77
- readonly facturae: readonly ["ordinaria"];
78
- readonly eslog: readonly ["eracun"];
79
- readonly ksef: readonly ["fa3"];
80
- };
81
- /** The profiles a caller may choose for `standard`; empty for an unknown standard. */
82
- declare function profilesForStandard(standard: string): readonly string[];
83
- /**
84
- * Whether `profile` is legal for `standard`. An unknown standard passes: the API
85
- * is the authority on values this list does not carry, and a client-side guess
86
- * would refuse a request the server would have accepted.
87
- */
88
- declare function isProfileAllowedForStandard(standard: string, profile: string): boolean;
89
- declare const LIVE_VALIDATE_FORMATS: readonly ["auto", "cii", "ubl"];
90
- declare const LIVE_PARSE_FORMATS: readonly ["auto", "cii", "ubl"];
91
- declare const LIVE_CONVERT_SOURCE_FORMATS: readonly ["auto", "cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
92
- declare const LIVE_CONVERT_TARGET_FORMATS: readonly ["cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
93
-
94
- export { DEFAULT_BASE_URL as D, type GeneratePreset as G, LIVE_CONVERT_SOURCE_FORMATS as L, type PlainObject as P, type DocumentInput as a, LIVE_CONVERT_TARGET_FORMATS as b, LIVE_GENERATE_PRESETS as c, LIVE_GENERATE_STANDARDS as d, LIVE_PARSE_FORMATS as e, LIVE_PROFILES as f, LIVE_PROFILES_BY_STANDARD as g, LIVE_VALIDATE_FORMATS as h, compactQuery as i, decodeUtf8 as j, isPlainObject as k, isProfileAllowedForStandard as l, mergeDeep as m, DEFAULT_MAX_RETRIES as n, DEFAULT_TIMEOUT_MS as o, profilesForStandard as p, sniffContentType as s, toBytes as t };