@beliq/sdk 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -5
- package/dist/constants-BZuNzqbV.d.cts +85 -0
- package/dist/constants-BZuNzqbV.d.ts +85 -0
- package/dist/helpers.cjs +30 -1
- package/dist/helpers.d.cts +6 -2
- package/dist/helpers.d.ts +6 -2
- package/dist/helpers.js +26 -1
- package/dist/index.cjs +161 -18
- package/dist/index.d.cts +806 -30
- package/dist/index.d.ts +806 -30
- package/dist/index.js +154 -17
- package/package.json +12 -6
- package/dist/constants-bWOXCmJD.d.cts +0 -22
- package/dist/constants-bWOXCmJD.d.ts +0 -22
package/README.md
CHANGED
|
@@ -52,22 +52,82 @@ if (!result.valid) {
|
|
|
52
52
|
Create an API key in the beliq dashboard under API Keys, then pass it to the client:
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
|
-
new Beliq({ apiKey: '
|
|
56
|
-
new Beliq({ apiKey: '
|
|
57
|
-
new Beliq({ apiKey: '
|
|
55
|
+
new Beliq({ apiKey: 'blq_live_...' }); // sends X-API-Key (default)
|
|
56
|
+
new Beliq({ apiKey: 'blq_live_...', auth: 'bearer' }); // sends Authorization: Bearer
|
|
57
|
+
new Beliq({ apiKey: 'blq_live_...', baseUrl: 'https://staging.beliq.eu' });
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
Keys are prefixed `blq_live_` (production, draws your plan quota) or `blq_test_` (sandbox, separate free allowance, watermarked output). `client.livemode` reports the mode from the key prefix before any request; generate and convert results also carry the authoritative `meta.livemode` from the response.
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
const beliq = new Beliq({ apiKey: process.env.BELIQ_API_KEY! });
|
|
64
|
+
if (!beliq.livemode) console.warn('running against the sandbox');
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Timeouts and retries
|
|
68
|
+
|
|
69
|
+
The client retries transient failures for you, so you do not have to reimplement
|
|
70
|
+
backoff around it.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
new Beliq({
|
|
74
|
+
apiKey: 'blq_live_...',
|
|
75
|
+
timeoutMs: 90_000, // per-attempt deadline (default)
|
|
76
|
+
maxRetries: 3, // extra attempts after the first (default)
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Both defaults are exported as `DEFAULT_TIMEOUT_MS` and `DEFAULT_MAX_RETRIES`, so
|
|
81
|
+
you can derive from them instead of repeating the numbers.
|
|
82
|
+
|
|
83
|
+
Only `429`, `502` and `503` are retried, honouring the server's `Retry-After`
|
|
84
|
+
with jitter. beliq refunds the document's quota unit on a `503`, so a retry never
|
|
85
|
+
costs you a second document.
|
|
86
|
+
|
|
87
|
+
`504` and this client's own timeout are deliberately **not** retried: both mean
|
|
88
|
+
the work may still be running on beliq's side, so retrying risks producing a
|
|
89
|
+
second document rather than recovering the first.
|
|
90
|
+
|
|
91
|
+
The default deadline is generous because beliq runs the full Schematron rule set
|
|
92
|
+
over each document, and a generate or validate can legitimately take tens of
|
|
93
|
+
seconds. If you lower it, keep it above the latency you actually see: a deadline
|
|
94
|
+
shorter than the server's own turns completed work into an unknown outcome. Set
|
|
95
|
+
`timeoutMs: 0` to disable it, and `maxRetries: 0` to handle retrying yourself.
|
|
96
|
+
|
|
60
97
|
## API
|
|
61
98
|
|
|
62
99
|
| Method | Endpoint | Input | Returns |
|
|
63
100
|
|---|---|---|---|
|
|
64
101
|
| `me()` | GET /v1/me | none | `AccountInfo` (no quota cost) |
|
|
65
|
-
| `generate(input)` | POST /v1/generate | EN 16931 invoice object | `{ contentType, bytes, xml?, meta }` |
|
|
102
|
+
| `generate(input)` | POST /v1/generate | EN 16931 invoice object | `{ contentType, bytes, xml?, sha256?, validationResult?, meta }` |
|
|
66
103
|
| `validate(document, options?)` | POST /v1/validate | XML or PDF | `ValidationResult` |
|
|
67
104
|
| `parse(document, options?)` | POST /v1/parse | XML or PDF | `ParseResult` |
|
|
68
105
|
| `convert(document, options)` | POST /v1/convert | XML or PDF | `{ contentType, bytes, meta }` |
|
|
69
106
|
|
|
70
|
-
`document` accepts a `string`, `Uint8Array`, `Buffer`, `ArrayBuffer`, or typed array. The content type is sniffed from the bytes (PDF vs XML) unless you pass `options.contentType`. `generate` and `convert` return raw document bytes plus the response-header metadata (`schematronVersion`, `pdfKind`, `sourceFormat`/`targetFormat`, `lostElements`, `conversionTools`); for an XML output, `generate` also decodes `xml`.
|
|
107
|
+
`document` accepts a `string`, `Uint8Array`, `Buffer`, `ArrayBuffer`, or typed array. The content type is sniffed from the bytes (PDF vs XML) unless you pass `options.contentType`. `generate` and `convert` return raw document bytes plus the response-header metadata (`schematronVersion`, `pdfKind`, `sourceFormat`/`targetFormat`, `lostElements`, `conversionTools`, `livemode`); for an XML output, `generate` also decodes `xml`.
|
|
108
|
+
|
|
109
|
+
### Verify-it-yourself seal
|
|
110
|
+
|
|
111
|
+
Pass `seal: true` to `generate` to also get the document `sha256` and the full `validationResult`. Hashing the returned bytes reproduces the hash, so a recipient can check the document independently:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { createHash } from 'node:crypto';
|
|
115
|
+
|
|
116
|
+
const doc = await beliq.generate({ standard: 'xrechnung', invoice, seal: true });
|
|
117
|
+
const ok = createHash('sha256').update(doc.bytes).digest('hex') === doc.sha256;
|
|
118
|
+
console.log(doc.validationResult?.valid, doc.meta.rulesetSha256, ok);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Curated option lists
|
|
122
|
+
|
|
123
|
+
`LIVE_GENERATE_PRESETS` is the set of public generate targets beliq.eu itself offers, each mapping to the API `standard` (plus `profile`/`facturxProfile`) it needs. NLCIUS is a Peppol BIS profile and lives here rather than in `LIVE_GENERATE_STANDARDS`. Connectors build their dropdowns from these lists.
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
import { LIVE_GENERATE_PRESETS } from '@beliq/sdk';
|
|
127
|
+
|
|
128
|
+
const nlcius = LIVE_GENERATE_PRESETS.find((p) => p.id === 'nlcius');
|
|
129
|
+
await beliq.generate({ standard: nlcius!.standard, profile: nlcius!.profile, invoice });
|
|
130
|
+
```
|
|
71
131
|
|
|
72
132
|
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`:
|
|
73
133
|
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
declare const LIVE_GENERATE_STANDARDS: readonly ["xrechnung", "zugferd", "facturx", "peppol-bis"];
|
|
24
|
+
/** A named generate target: the API `standard` plus the `profile`/`facturxProfile`/`output` it needs. */
|
|
25
|
+
interface GeneratePreset {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
standard: (typeof LIVE_GENERATE_STANDARDS)[number];
|
|
29
|
+
output: 'xml' | 'pdf';
|
|
30
|
+
/** API `profile`; omitted lets the engine pick the standard's default. */
|
|
31
|
+
profile?: string;
|
|
32
|
+
/** API `facturxProfile`; Factur-X / ZUGFeRD only. */
|
|
33
|
+
facturxProfile?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Named generate targets surfaced to end users (connector dropdowns), mirroring
|
|
37
|
+
* the public set on beliq.eu's own generator. NLCIUS is a Peppol BIS profile,
|
|
38
|
+
* not a standalone standard, so it is reachable here rather than through
|
|
39
|
+
* LIVE_GENERATE_STANDARDS or the Factur-X-only LIVE_PROFILES.
|
|
40
|
+
*/
|
|
41
|
+
declare const LIVE_GENERATE_PRESETS: readonly GeneratePreset[];
|
|
42
|
+
/**
|
|
43
|
+
* The Factur-X granularity values offered publicly. Kept as the flat list the
|
|
44
|
+
* hybrid-PDF family shares; anything choosing a profile for a specific standard
|
|
45
|
+
* wants LIVE_PROFILES_BY_STANDARD instead, which is what the API enforces.
|
|
46
|
+
*/
|
|
47
|
+
declare const LIVE_PROFILES: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
|
|
48
|
+
/**
|
|
49
|
+
* Which profiles each standard accepts, publicly-offered values only.
|
|
50
|
+
*
|
|
51
|
+
* `profile` is not a free enum: the engine pins it per standard and answers a
|
|
52
|
+
* pair outside the table with `422 PROFILE_STANDARD_MISMATCH`
|
|
53
|
+
* (beliq-engine `app/routes/generate.py`, ALLOWED_PROFILES_FOR_STANDARD). A
|
|
54
|
+
* surface that offers one flat profile list therefore offers values that cannot
|
|
55
|
+
* succeed: none of the Factur-X granularity values is legal for `xrechnung` or
|
|
56
|
+
* `peppol-bis`, and `extended-ctc-fr` is the AFNOR XP Z12-012 France CTC overlay
|
|
57
|
+
* with no ZUGFeRD-branded counterpart.
|
|
58
|
+
*
|
|
59
|
+
* Narrower than the engine's own table in two places, both deliberate: the
|
|
60
|
+
* `minimum` and `basic` Factur-X profiles are engine-supported but withheld
|
|
61
|
+
* (FNFE-MPE source gating, mirroring beliq-types SUPPORTED_FACTURX_PROFILE_IDS),
|
|
62
|
+
* and the standards outside LIVE_GENERATE_STANDARDS are absent entirely.
|
|
63
|
+
*
|
|
64
|
+
* `scripts/check-profile-drift.mjs` compares this against the engine's table.
|
|
65
|
+
*/
|
|
66
|
+
declare const LIVE_PROFILES_BY_STANDARD: {
|
|
67
|
+
readonly xrechnung: readonly ["xrechnung"];
|
|
68
|
+
readonly 'peppol-bis': readonly ["peppol", "romania-ro-cius", "netherlands-nlcius"];
|
|
69
|
+
readonly zugferd: readonly ["basicwl", "en16931", "extended"];
|
|
70
|
+
readonly facturx: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
|
|
71
|
+
};
|
|
72
|
+
/** The profiles a caller may choose for `standard`; empty for an unknown standard. */
|
|
73
|
+
declare function profilesForStandard(standard: string): readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* Whether `profile` is legal for `standard`. An unknown standard passes: the API
|
|
76
|
+
* is the authority on values this list does not carry, and a client-side guess
|
|
77
|
+
* would refuse a request the server would have accepted.
|
|
78
|
+
*/
|
|
79
|
+
declare function isProfileAllowedForStandard(standard: string, profile: string): boolean;
|
|
80
|
+
declare const LIVE_VALIDATE_FORMATS: readonly ["auto", "cii", "ubl"];
|
|
81
|
+
declare const LIVE_PARSE_FORMATS: readonly ["auto", "cii", "ubl"];
|
|
82
|
+
declare const LIVE_CONVERT_SOURCE_FORMATS: readonly ["auto", "cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
|
|
83
|
+
declare const LIVE_CONVERT_TARGET_FORMATS: readonly ["cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
|
|
84
|
+
|
|
85
|
+
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 };
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
declare const LIVE_GENERATE_STANDARDS: readonly ["xrechnung", "zugferd", "facturx", "peppol-bis"];
|
|
24
|
+
/** A named generate target: the API `standard` plus the `profile`/`facturxProfile`/`output` it needs. */
|
|
25
|
+
interface GeneratePreset {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
standard: (typeof LIVE_GENERATE_STANDARDS)[number];
|
|
29
|
+
output: 'xml' | 'pdf';
|
|
30
|
+
/** API `profile`; omitted lets the engine pick the standard's default. */
|
|
31
|
+
profile?: string;
|
|
32
|
+
/** API `facturxProfile`; Factur-X / ZUGFeRD only. */
|
|
33
|
+
facturxProfile?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Named generate targets surfaced to end users (connector dropdowns), mirroring
|
|
37
|
+
* the public set on beliq.eu's own generator. NLCIUS is a Peppol BIS profile,
|
|
38
|
+
* not a standalone standard, so it is reachable here rather than through
|
|
39
|
+
* LIVE_GENERATE_STANDARDS or the Factur-X-only LIVE_PROFILES.
|
|
40
|
+
*/
|
|
41
|
+
declare const LIVE_GENERATE_PRESETS: readonly GeneratePreset[];
|
|
42
|
+
/**
|
|
43
|
+
* The Factur-X granularity values offered publicly. Kept as the flat list the
|
|
44
|
+
* hybrid-PDF family shares; anything choosing a profile for a specific standard
|
|
45
|
+
* wants LIVE_PROFILES_BY_STANDARD instead, which is what the API enforces.
|
|
46
|
+
*/
|
|
47
|
+
declare const LIVE_PROFILES: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
|
|
48
|
+
/**
|
|
49
|
+
* Which profiles each standard accepts, publicly-offered values only.
|
|
50
|
+
*
|
|
51
|
+
* `profile` is not a free enum: the engine pins it per standard and answers a
|
|
52
|
+
* pair outside the table with `422 PROFILE_STANDARD_MISMATCH`
|
|
53
|
+
* (beliq-engine `app/routes/generate.py`, ALLOWED_PROFILES_FOR_STANDARD). A
|
|
54
|
+
* surface that offers one flat profile list therefore offers values that cannot
|
|
55
|
+
* succeed: none of the Factur-X granularity values is legal for `xrechnung` or
|
|
56
|
+
* `peppol-bis`, and `extended-ctc-fr` is the AFNOR XP Z12-012 France CTC overlay
|
|
57
|
+
* with no ZUGFeRD-branded counterpart.
|
|
58
|
+
*
|
|
59
|
+
* Narrower than the engine's own table in two places, both deliberate: the
|
|
60
|
+
* `minimum` and `basic` Factur-X profiles are engine-supported but withheld
|
|
61
|
+
* (FNFE-MPE source gating, mirroring beliq-types SUPPORTED_FACTURX_PROFILE_IDS),
|
|
62
|
+
* and the standards outside LIVE_GENERATE_STANDARDS are absent entirely.
|
|
63
|
+
*
|
|
64
|
+
* `scripts/check-profile-drift.mjs` compares this against the engine's table.
|
|
65
|
+
*/
|
|
66
|
+
declare const LIVE_PROFILES_BY_STANDARD: {
|
|
67
|
+
readonly xrechnung: readonly ["xrechnung"];
|
|
68
|
+
readonly 'peppol-bis': readonly ["peppol", "romania-ro-cius", "netherlands-nlcius"];
|
|
69
|
+
readonly zugferd: readonly ["basicwl", "en16931", "extended"];
|
|
70
|
+
readonly facturx: readonly ["basicwl", "en16931", "extended", "extended-ctc-fr"];
|
|
71
|
+
};
|
|
72
|
+
/** The profiles a caller may choose for `standard`; empty for an unknown standard. */
|
|
73
|
+
declare function profilesForStandard(standard: string): readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* Whether `profile` is legal for `standard`. An unknown standard passes: the API
|
|
76
|
+
* is the authority on values this list does not carry, and a client-side guess
|
|
77
|
+
* would refuse a request the server would have accepted.
|
|
78
|
+
*/
|
|
79
|
+
declare function isProfileAllowedForStandard(standard: string, profile: string): boolean;
|
|
80
|
+
declare const LIVE_VALIDATE_FORMATS: readonly ["auto", "cii", "ubl"];
|
|
81
|
+
declare const LIVE_PARSE_FORMATS: readonly ["auto", "cii", "ubl"];
|
|
82
|
+
declare const LIVE_CONVERT_SOURCE_FORMATS: readonly ["auto", "cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
|
|
83
|
+
declare const LIVE_CONVERT_TARGET_FORMATS: readonly ["cii", "ubl", "zugferd", "facturx", "xrechnung", "peppol-bis"];
|
|
84
|
+
|
|
85
|
+
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 };
|
package/dist/helpers.cjs
CHANGED
|
@@ -23,15 +23,19 @@ __export(helpers_exports, {
|
|
|
23
23
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
24
24
|
LIVE_CONVERT_SOURCE_FORMATS: () => LIVE_CONVERT_SOURCE_FORMATS,
|
|
25
25
|
LIVE_CONVERT_TARGET_FORMATS: () => LIVE_CONVERT_TARGET_FORMATS,
|
|
26
|
+
LIVE_GENERATE_PRESETS: () => LIVE_GENERATE_PRESETS,
|
|
26
27
|
LIVE_GENERATE_STANDARDS: () => LIVE_GENERATE_STANDARDS,
|
|
27
28
|
LIVE_PARSE_FORMATS: () => LIVE_PARSE_FORMATS,
|
|
28
29
|
LIVE_PROFILES: () => LIVE_PROFILES,
|
|
30
|
+
LIVE_PROFILES_BY_STANDARD: () => LIVE_PROFILES_BY_STANDARD,
|
|
29
31
|
LIVE_VALIDATE_FORMATS: () => LIVE_VALIDATE_FORMATS,
|
|
30
32
|
buildRequest: () => buildRequest,
|
|
31
33
|
compactQuery: () => compactQuery,
|
|
32
34
|
decodeUtf8: () => decodeUtf8,
|
|
33
35
|
isPlainObject: () => isPlainObject,
|
|
36
|
+
isProfileAllowedForStandard: () => isProfileAllowedForStandard,
|
|
34
37
|
mergeDeep: () => mergeDeep,
|
|
38
|
+
profilesForStandard: () => profilesForStandard,
|
|
35
39
|
sniffContentType: () => sniffContentType,
|
|
36
40
|
toBytes: () => toBytes
|
|
37
41
|
});
|
|
@@ -111,7 +115,8 @@ function buildRequest(params) {
|
|
|
111
115
|
path: "/v1/generate",
|
|
112
116
|
jsonBody: merged,
|
|
113
117
|
contentType: "application/json",
|
|
114
|
-
|
|
118
|
+
// JSON mode returns the seal envelope; binary mode returns the raw document body.
|
|
119
|
+
...params.sealed ? { accept: "application/json", outputKind: "json" } : { outputKind: "binary" }
|
|
115
120
|
};
|
|
116
121
|
}
|
|
117
122
|
case "validate": {
|
|
@@ -161,7 +166,27 @@ function buildRequest(params) {
|
|
|
161
166
|
// src/constants.ts
|
|
162
167
|
var DEFAULT_BASE_URL = "https://api.beliq.eu";
|
|
163
168
|
var LIVE_GENERATE_STANDARDS = ["xrechnung", "zugferd", "facturx", "peppol-bis"];
|
|
169
|
+
var LIVE_GENERATE_PRESETS = [
|
|
170
|
+
{ id: "xrechnung", label: "XRechnung", standard: "xrechnung", output: "xml" },
|
|
171
|
+
{ id: "factur-x", label: "Factur-X", standard: "facturx", output: "pdf", facturxProfile: "en16931" },
|
|
172
|
+
{ id: "zugferd", label: "ZUGFeRD", standard: "zugferd", output: "pdf" },
|
|
173
|
+
{ id: "peppol-bis", label: "Peppol BIS 3.0", standard: "peppol-bis", output: "xml" },
|
|
174
|
+
{ id: "nlcius", label: "NLCIUS", standard: "peppol-bis", output: "xml", profile: "netherlands-nlcius" }
|
|
175
|
+
];
|
|
164
176
|
var LIVE_PROFILES = ["basicwl", "en16931", "extended", "extended-ctc-fr"];
|
|
177
|
+
var LIVE_PROFILES_BY_STANDARD = {
|
|
178
|
+
xrechnung: ["xrechnung"],
|
|
179
|
+
"peppol-bis": ["peppol", "romania-ro-cius", "netherlands-nlcius"],
|
|
180
|
+
zugferd: ["basicwl", "en16931", "extended"],
|
|
181
|
+
facturx: ["basicwl", "en16931", "extended", "extended-ctc-fr"]
|
|
182
|
+
};
|
|
183
|
+
function profilesForStandard(standard) {
|
|
184
|
+
return LIVE_PROFILES_BY_STANDARD[standard] ?? [];
|
|
185
|
+
}
|
|
186
|
+
function isProfileAllowedForStandard(standard, profile) {
|
|
187
|
+
const allowed = profilesForStandard(standard);
|
|
188
|
+
return allowed.length === 0 || allowed.includes(profile);
|
|
189
|
+
}
|
|
165
190
|
var LIVE_VALIDATE_FORMATS = ["auto", "cii", "ubl"];
|
|
166
191
|
var LIVE_PARSE_FORMATS = ["auto", "cii", "ubl"];
|
|
167
192
|
var LIVE_CONVERT_SOURCE_FORMATS = [
|
|
@@ -186,15 +211,19 @@ var LIVE_CONVERT_TARGET_FORMATS = [
|
|
|
186
211
|
DEFAULT_BASE_URL,
|
|
187
212
|
LIVE_CONVERT_SOURCE_FORMATS,
|
|
188
213
|
LIVE_CONVERT_TARGET_FORMATS,
|
|
214
|
+
LIVE_GENERATE_PRESETS,
|
|
189
215
|
LIVE_GENERATE_STANDARDS,
|
|
190
216
|
LIVE_PARSE_FORMATS,
|
|
191
217
|
LIVE_PROFILES,
|
|
218
|
+
LIVE_PROFILES_BY_STANDARD,
|
|
192
219
|
LIVE_VALIDATE_FORMATS,
|
|
193
220
|
buildRequest,
|
|
194
221
|
compactQuery,
|
|
195
222
|
decodeUtf8,
|
|
196
223
|
isPlainObject,
|
|
224
|
+
isProfileAllowedForStandard,
|
|
197
225
|
mergeDeep,
|
|
226
|
+
profilesForStandard,
|
|
198
227
|
sniffContentType,
|
|
199
228
|
toBytes
|
|
200
229
|
});
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlainObject } from './constants-
|
|
2
|
-
export { D as DEFAULT_BASE_URL, a as DocumentInput, L as LIVE_CONVERT_SOURCE_FORMATS, b as LIVE_CONVERT_TARGET_FORMATS, c as
|
|
1
|
+
import { P as PlainObject } from './constants-BZuNzqbV.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 './constants-BZuNzqbV.cjs';
|
|
3
3
|
|
|
4
4
|
type Operation = 'me' | 'generate' | 'validate' | 'parse' | 'convert';
|
|
5
5
|
/** 'json' => parse the `{ success, data }` envelope; 'binary' => return raw bytes. */
|
|
@@ -15,6 +15,8 @@ interface BuildParams {
|
|
|
15
15
|
verify?: boolean;
|
|
16
16
|
template?: string;
|
|
17
17
|
pdfTemplateId?: string;
|
|
18
|
+
/** Request the JSON-mode seal (Accept: application/json) instead of the binary body. */
|
|
19
|
+
sealed?: boolean;
|
|
18
20
|
rawBody?: Uint8Array;
|
|
19
21
|
rawContentType?: string;
|
|
20
22
|
validateFormat?: string;
|
|
@@ -37,6 +39,8 @@ interface BuiltRequest {
|
|
|
37
39
|
rawBody?: Uint8Array;
|
|
38
40
|
/** Request content type; absent for GET. */
|
|
39
41
|
contentType?: string;
|
|
42
|
+
/** Accept header; set when the caller wants a JSON envelope from an otherwise-binary op. */
|
|
43
|
+
accept?: string;
|
|
40
44
|
outputKind: OutputKind;
|
|
41
45
|
}
|
|
42
46
|
declare function buildRequest(params: BuildParams): BuiltRequest;
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PlainObject } from './constants-
|
|
2
|
-
export { D as DEFAULT_BASE_URL, a as DocumentInput, L as LIVE_CONVERT_SOURCE_FORMATS, b as LIVE_CONVERT_TARGET_FORMATS, c as
|
|
1
|
+
import { P as PlainObject } from './constants-BZuNzqbV.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 './constants-BZuNzqbV.js';
|
|
3
3
|
|
|
4
4
|
type Operation = 'me' | 'generate' | 'validate' | 'parse' | 'convert';
|
|
5
5
|
/** 'json' => parse the `{ success, data }` envelope; 'binary' => return raw bytes. */
|
|
@@ -15,6 +15,8 @@ interface BuildParams {
|
|
|
15
15
|
verify?: boolean;
|
|
16
16
|
template?: string;
|
|
17
17
|
pdfTemplateId?: string;
|
|
18
|
+
/** Request the JSON-mode seal (Accept: application/json) instead of the binary body. */
|
|
19
|
+
sealed?: boolean;
|
|
18
20
|
rawBody?: Uint8Array;
|
|
19
21
|
rawContentType?: string;
|
|
20
22
|
validateFormat?: string;
|
|
@@ -37,6 +39,8 @@ interface BuiltRequest {
|
|
|
37
39
|
rawBody?: Uint8Array;
|
|
38
40
|
/** Request content type; absent for GET. */
|
|
39
41
|
contentType?: string;
|
|
42
|
+
/** Accept header; set when the caller wants a JSON envelope from an otherwise-binary op. */
|
|
43
|
+
accept?: string;
|
|
40
44
|
outputKind: OutputKind;
|
|
41
45
|
}
|
|
42
46
|
declare function buildRequest(params: BuildParams): BuiltRequest;
|
package/dist/helpers.js
CHANGED
|
@@ -72,7 +72,8 @@ function buildRequest(params) {
|
|
|
72
72
|
path: "/v1/generate",
|
|
73
73
|
jsonBody: merged,
|
|
74
74
|
contentType: "application/json",
|
|
75
|
-
|
|
75
|
+
// JSON mode returns the seal envelope; binary mode returns the raw document body.
|
|
76
|
+
...params.sealed ? { accept: "application/json", outputKind: "json" } : { outputKind: "binary" }
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
79
|
case "validate": {
|
|
@@ -122,7 +123,27 @@ function buildRequest(params) {
|
|
|
122
123
|
// src/constants.ts
|
|
123
124
|
var DEFAULT_BASE_URL = "https://api.beliq.eu";
|
|
124
125
|
var LIVE_GENERATE_STANDARDS = ["xrechnung", "zugferd", "facturx", "peppol-bis"];
|
|
126
|
+
var LIVE_GENERATE_PRESETS = [
|
|
127
|
+
{ id: "xrechnung", label: "XRechnung", standard: "xrechnung", output: "xml" },
|
|
128
|
+
{ id: "factur-x", label: "Factur-X", standard: "facturx", output: "pdf", facturxProfile: "en16931" },
|
|
129
|
+
{ id: "zugferd", label: "ZUGFeRD", standard: "zugferd", output: "pdf" },
|
|
130
|
+
{ id: "peppol-bis", label: "Peppol BIS 3.0", standard: "peppol-bis", output: "xml" },
|
|
131
|
+
{ id: "nlcius", label: "NLCIUS", standard: "peppol-bis", output: "xml", profile: "netherlands-nlcius" }
|
|
132
|
+
];
|
|
125
133
|
var LIVE_PROFILES = ["basicwl", "en16931", "extended", "extended-ctc-fr"];
|
|
134
|
+
var LIVE_PROFILES_BY_STANDARD = {
|
|
135
|
+
xrechnung: ["xrechnung"],
|
|
136
|
+
"peppol-bis": ["peppol", "romania-ro-cius", "netherlands-nlcius"],
|
|
137
|
+
zugferd: ["basicwl", "en16931", "extended"],
|
|
138
|
+
facturx: ["basicwl", "en16931", "extended", "extended-ctc-fr"]
|
|
139
|
+
};
|
|
140
|
+
function profilesForStandard(standard) {
|
|
141
|
+
return LIVE_PROFILES_BY_STANDARD[standard] ?? [];
|
|
142
|
+
}
|
|
143
|
+
function isProfileAllowedForStandard(standard, profile) {
|
|
144
|
+
const allowed = profilesForStandard(standard);
|
|
145
|
+
return allowed.length === 0 || allowed.includes(profile);
|
|
146
|
+
}
|
|
126
147
|
var LIVE_VALIDATE_FORMATS = ["auto", "cii", "ubl"];
|
|
127
148
|
var LIVE_PARSE_FORMATS = ["auto", "cii", "ubl"];
|
|
128
149
|
var LIVE_CONVERT_SOURCE_FORMATS = [
|
|
@@ -146,15 +167,19 @@ export {
|
|
|
146
167
|
DEFAULT_BASE_URL,
|
|
147
168
|
LIVE_CONVERT_SOURCE_FORMATS,
|
|
148
169
|
LIVE_CONVERT_TARGET_FORMATS,
|
|
170
|
+
LIVE_GENERATE_PRESETS,
|
|
149
171
|
LIVE_GENERATE_STANDARDS,
|
|
150
172
|
LIVE_PARSE_FORMATS,
|
|
151
173
|
LIVE_PROFILES,
|
|
174
|
+
LIVE_PROFILES_BY_STANDARD,
|
|
152
175
|
LIVE_VALIDATE_FORMATS,
|
|
153
176
|
buildRequest,
|
|
154
177
|
compactQuery,
|
|
155
178
|
decodeUtf8,
|
|
156
179
|
isPlainObject,
|
|
180
|
+
isProfileAllowedForStandard,
|
|
157
181
|
mergeDeep,
|
|
182
|
+
profilesForStandard,
|
|
158
183
|
sniffContentType,
|
|
159
184
|
toBytes
|
|
160
185
|
};
|