@beliq/sdk 0.5.2 → 0.6.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/CHANGELOG.md +34 -0
- package/README.md +1 -1
- package/dist/helpers.cjs +9 -1
- package/dist/helpers.d.cts +5 -3
- package/dist/helpers.d.ts +5 -3
- package/dist/helpers.js +9 -1
- package/dist/index.cjs +20 -11
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +20 -11
- package/dist/{types-BRDATaM6.d.cts → types-Bc3c79Ss.d.cts} +123 -73
- package/dist/{types-BRDATaM6.d.ts → types-Bc3c79Ss.d.ts} +123 -73
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,40 @@
|
|
|
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.6.0 - 2026-11-03
|
|
8
|
+
|
|
9
|
+
A minor, because code can stop compiling in two places, and a `^0.5.0` range
|
|
10
|
+
does not reach a minor.
|
|
11
|
+
|
|
12
|
+
- `ConvertMeta.lostElements` holds the entries of `x-lost-elements` as the API
|
|
13
|
+
sends them. Each is a `LostElement` with `path`, `value`, `reason`, `severity`
|
|
14
|
+
and `acceptableLoss`, as
|
|
15
|
+
https://docs.beliq.eu/api-reference/convert/#lostelement-schema describes.
|
|
16
|
+
Past the API's 6 KB header cap the list holds one `LostElementsTruncated`
|
|
17
|
+
entry, `{ truncated: true, reason? }`, instead, and `lostElementsCount` stays
|
|
18
|
+
the exact count. The field was typed `string[]` and held `"[object Object]"`
|
|
19
|
+
for every entry, so code that reads an entry as a string stops compiling.
|
|
20
|
+
Both types are exported.
|
|
21
|
+
- The vendored `openapi.json` is document `0.23.0` of the API, up from
|
|
22
|
+
`0.16.0`. In the generated types, `generate()`'s `invoice.spain` (Facturae)
|
|
23
|
+
takes only the value the engine builds for each field: `modality` `I`,
|
|
24
|
+
`invoiceIssuerType` `EM`, `invoiceDocumentType` `FC`, `invoiceClass` `OO`
|
|
25
|
+
and `taxTypeCode` `01`. `invoice.poland` (KSeF) takes only `"2"` for
|
|
26
|
+
`adnotacje.P_18`, `adnotacje.P_23`, `jst` and `gv`. Code that passes another
|
|
27
|
+
value stops compiling. The API refuses those values.
|
|
28
|
+
- The error code union gains `DATABASE_UNAVAILABLE`, a 503 on every route,
|
|
29
|
+
which the client retries like any 503. A `switch` over the code that
|
|
30
|
+
TypeScript checks for exhaustiveness needs the new case.
|
|
31
|
+
- `ValidateFormat` and `ParseFormat` take `poland_ksef_fa2`.
|
|
32
|
+
- `LIVE_VALIDATE_FORMATS` gains `fatturapa`, `facturae`, `eslog` and
|
|
33
|
+
`poland_ksef_fa3`, the four national formats `GET /v1/rulesets` lists, each
|
|
34
|
+
Schema-checked. A tool that builds a validate option list from it offers the
|
|
35
|
+
four. `LIVE_PARSE_FORMATS` stays `auto`, `cii` and `ubl`, because
|
|
36
|
+
`POST /v1/parse` reads CII and UBL only.
|
|
37
|
+
- `advanced` on `validate()`, `parse()` and `convert()` is merged into the
|
|
38
|
+
query. The API answers 400 `VALIDATION_ERROR` to a query key the operation
|
|
39
|
+
does not declare, and `err.details.fields` names it.
|
|
40
|
+
|
|
7
41
|
## 0.5.2 - 2026-10-24
|
|
8
42
|
|
|
9
43
|
A patch: `@beliq/sdk/helpers` gains the wording for a verdict and a converted
|
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@ shorter than the server's own turns completed work into an unknown outcome. Set
|
|
|
129
129
|
| `parse(document, options?)` | POST /v1/parse | XML or PDF | `ParseResult` |
|
|
130
130
|
| `convert(document, options)` | POST /v1/convert | XML or PDF | `{ contentType, bytes, meta }` |
|
|
131
131
|
|
|
132
|
-
`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`.
|
|
132
|
+
`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`. Each entry of `lostElements` is a `LostElement` as https://docs.beliq.eu/api-reference/convert/#lostelement-schema describes it, except past the API's 6 KB header cap, where the list holds one `{ truncated: true, reason }` entry instead and `lostElementsCount` stays the exact count.
|
|
133
133
|
|
|
134
134
|
### Verify-it-yourself seal
|
|
135
135
|
|
package/dist/helpers.cjs
CHANGED
|
@@ -209,7 +209,15 @@ function isProfileAllowedForStandard(standard, profile) {
|
|
|
209
209
|
const allowed = profilesForStandard(standard);
|
|
210
210
|
return allowed.length === 0 || allowed.includes(profile);
|
|
211
211
|
}
|
|
212
|
-
var LIVE_VALIDATE_FORMATS = [
|
|
212
|
+
var LIVE_VALIDATE_FORMATS = [
|
|
213
|
+
"auto",
|
|
214
|
+
"cii",
|
|
215
|
+
"ubl",
|
|
216
|
+
"fatturapa",
|
|
217
|
+
"facturae",
|
|
218
|
+
"eslog",
|
|
219
|
+
"poland_ksef_fa3"
|
|
220
|
+
];
|
|
213
221
|
var LIVE_PARSE_FORMATS = ["auto", "cii", "ubl"];
|
|
214
222
|
var LIVE_CONVERT_SOURCE_FORMATS = [
|
|
215
223
|
"auto",
|
package/dist/helpers.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { P as PlainObject
|
|
2
|
-
|
|
1
|
+
import { P as PlainObject } from './types-Bc3c79Ss.cjs';
|
|
2
|
+
import { ValidationResult } from './index.cjs';
|
|
3
|
+
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-Bc3c79Ss.cjs';
|
|
3
4
|
|
|
4
5
|
type Operation = 'me' | 'generate' | 'validate' | 'parse' | 'convert';
|
|
5
6
|
/** 'json' => parse the `{ success, data }` envelope; 'binary' => return raw bytes. */
|
|
@@ -82,4 +83,5 @@ declare function pdfInputLine(result: Pick<ValidationResult, 'pdfInput'>): strin
|
|
|
82
83
|
/** Which ruleset channel the API says served the request, when the result names one. */
|
|
83
84
|
declare function rulesetChannelLine(result: Pick<ValidationResult, 'rulesetChannel' | 'rulesetFellBack' | 'rulesetSunsetsOn'>): string | undefined;
|
|
84
85
|
|
|
85
|
-
export {
|
|
86
|
+
export { CONVERT_PDF_LINE, DEPTH_NOT_STATED, FRANCE_CTC_BLOCKING_FINDING_RULE_ID, PlainObject, buildRequest, checkDepth, franceBlockLines, franceBlockingRuleIds, pdfInputLine, rulesetChannelLine, verdictWord };
|
|
87
|
+
export type { BuildParams, BuiltRequest, Operation, OutputKind, QueryValue };
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { P as PlainObject
|
|
2
|
-
|
|
1
|
+
import { P as PlainObject } from './types-Bc3c79Ss.js';
|
|
2
|
+
import { ValidationResult } from './index.js';
|
|
3
|
+
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-Bc3c79Ss.js';
|
|
3
4
|
|
|
4
5
|
type Operation = 'me' | 'generate' | 'validate' | 'parse' | 'convert';
|
|
5
6
|
/** 'json' => parse the `{ success, data }` envelope; 'binary' => return raw bytes. */
|
|
@@ -82,4 +83,5 @@ declare function pdfInputLine(result: Pick<ValidationResult, 'pdfInput'>): strin
|
|
|
82
83
|
/** Which ruleset channel the API says served the request, when the result names one. */
|
|
83
84
|
declare function rulesetChannelLine(result: Pick<ValidationResult, 'rulesetChannel' | 'rulesetFellBack' | 'rulesetSunsetsOn'>): string | undefined;
|
|
84
85
|
|
|
85
|
-
export {
|
|
86
|
+
export { CONVERT_PDF_LINE, DEPTH_NOT_STATED, FRANCE_CTC_BLOCKING_FINDING_RULE_ID, PlainObject, buildRequest, checkDepth, franceBlockLines, franceBlockingRuleIds, pdfInputLine, rulesetChannelLine, verdictWord };
|
|
87
|
+
export type { BuildParams, BuiltRequest, Operation, OutputKind, QueryValue };
|
package/dist/helpers.js
CHANGED
|
@@ -157,7 +157,15 @@ function isProfileAllowedForStandard(standard, profile) {
|
|
|
157
157
|
const allowed = profilesForStandard(standard);
|
|
158
158
|
return allowed.length === 0 || allowed.includes(profile);
|
|
159
159
|
}
|
|
160
|
-
var LIVE_VALIDATE_FORMATS = [
|
|
160
|
+
var LIVE_VALIDATE_FORMATS = [
|
|
161
|
+
"auto",
|
|
162
|
+
"cii",
|
|
163
|
+
"ubl",
|
|
164
|
+
"fatturapa",
|
|
165
|
+
"facturae",
|
|
166
|
+
"eslog",
|
|
167
|
+
"poland_ksef_fa3"
|
|
168
|
+
];
|
|
161
169
|
var LIVE_PARSE_FORMATS = ["auto", "cii", "ubl"];
|
|
162
170
|
var LIVE_CONVERT_SOURCE_FORMATS = [
|
|
163
171
|
"auto",
|
package/dist/index.cjs
CHANGED
|
@@ -246,7 +246,15 @@ function isProfileAllowedForStandard(standard, profile) {
|
|
|
246
246
|
const allowed = profilesForStandard(standard);
|
|
247
247
|
return allowed.length === 0 || allowed.includes(profile);
|
|
248
248
|
}
|
|
249
|
-
var LIVE_VALIDATE_FORMATS = [
|
|
249
|
+
var LIVE_VALIDATE_FORMATS = [
|
|
250
|
+
"auto",
|
|
251
|
+
"cii",
|
|
252
|
+
"ubl",
|
|
253
|
+
"fatturapa",
|
|
254
|
+
"facturae",
|
|
255
|
+
"eslog",
|
|
256
|
+
"poland_ksef_fa3"
|
|
257
|
+
];
|
|
250
258
|
var LIVE_PARSE_FORMATS = ["auto", "cii", "ubl"];
|
|
251
259
|
var LIVE_CONVERT_SOURCE_FORMATS = [
|
|
252
260
|
"auto",
|
|
@@ -366,6 +374,16 @@ function parseRulesetArtifacts(headers) {
|
|
|
366
374
|
return void 0;
|
|
367
375
|
}
|
|
368
376
|
}
|
|
377
|
+
function parseLostElements(headers) {
|
|
378
|
+
const raw = headers.get("x-lost-elements");
|
|
379
|
+
if (!raw) return void 0;
|
|
380
|
+
try {
|
|
381
|
+
const parsed = JSON.parse(raw);
|
|
382
|
+
return Array.isArray(parsed) ? parsed : void 0;
|
|
383
|
+
} catch {
|
|
384
|
+
return void 0;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
369
387
|
function generateMeta(headers) {
|
|
370
388
|
return {
|
|
371
389
|
schematronVersion: headers.get("x-schematron-version") ?? void 0,
|
|
@@ -377,22 +395,13 @@ function generateMeta(headers) {
|
|
|
377
395
|
};
|
|
378
396
|
}
|
|
379
397
|
function convertMeta(headers) {
|
|
380
|
-
let lostElements;
|
|
381
|
-
const lostRaw = headers.get("x-lost-elements");
|
|
382
|
-
if (lostRaw) {
|
|
383
|
-
try {
|
|
384
|
-
const parsed = JSON.parse(lostRaw);
|
|
385
|
-
if (Array.isArray(parsed)) lostElements = parsed.map(String);
|
|
386
|
-
} catch {
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
398
|
const countRaw = headers.get("x-lost-elements-count");
|
|
390
399
|
return {
|
|
391
400
|
sourceFormat: headers.get("x-source-format") ?? void 0,
|
|
392
401
|
targetFormat: headers.get("x-target-format") ?? void 0,
|
|
393
402
|
profileDetected: headers.get("x-profile-detected") ?? void 0,
|
|
394
403
|
lostElementsCount: countRaw != null ? Number(countRaw) : void 0,
|
|
395
|
-
lostElements,
|
|
404
|
+
lostElements: parseLostElements(headers),
|
|
396
405
|
conversionTools: headers.get("x-conversion-tools") ?? void 0,
|
|
397
406
|
livemode: livemodeHeader(headers)
|
|
398
407
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { A as AccountInfo, S as Standard, I as Invoice, n as GenerateProfile, F as FacturxProfile,
|
|
2
|
-
|
|
1
|
+
import { A as AccountInfo, S as Standard, I as Invoice, n as GenerateProfile, F as FacturxProfile, V as ValidationResult, R as RulesetArtifact, a as DocumentInput, o as ValidateFormat, q as ParseFormat, r as ParseResult, C as ConvertTargetFormat, u as ConvertSourceFormat, v as ApiErrorCode } from './types-Bc3c79Ss.cjs';
|
|
2
|
+
import { PlainObject } from './helpers.cjs';
|
|
3
|
+
export { w as ApiError, D as DEFAULT_BASE_URL, x as DEFAULT_MAX_RETRIES, y as DEFAULT_TIMEOUT_MS, z as GenerateBody, G as GeneratePreset, B as GenerateResponse, 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, E as ParseWarning, H as ParseWarningCode, J as Severity, K as ValidationFormat, M as ValidationIssue, l as isProfileAllowedForStandard, p as profilesForStandard } from './types-Bc3c79Ss.cjs';
|
|
3
4
|
|
|
4
5
|
interface BeliqOptions {
|
|
5
6
|
/** API key from the beliq dashboard (API Keys). */
|
|
@@ -51,7 +52,11 @@ interface GenerateInput {
|
|
|
51
52
|
interface DocumentOptions {
|
|
52
53
|
/** Override the sniffed request content type (application/xml | application/pdf). */
|
|
53
54
|
contentType?: string;
|
|
54
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Raw JSON deep-merged into the query; its values win over the named options.
|
|
57
|
+
* The API answers 400 `VALIDATION_ERROR` to a query key the operation does not
|
|
58
|
+
* declare, and `details.fields` names it.
|
|
59
|
+
*/
|
|
55
60
|
advanced?: PlainObject;
|
|
56
61
|
}
|
|
57
62
|
interface ValidateOptions extends DocumentOptions {
|
|
@@ -91,13 +96,29 @@ interface GenerateResult {
|
|
|
91
96
|
validationResult?: ValidationResult;
|
|
92
97
|
meta: GenerateMeta;
|
|
93
98
|
}
|
|
99
|
+
/** One loss a conversion recorded: https://docs.beliq.eu/api-reference/convert/#lostelement-schema */
|
|
100
|
+
interface LostElement {
|
|
101
|
+
path: string;
|
|
102
|
+
value: string | null;
|
|
103
|
+
reason: string;
|
|
104
|
+
severity: 'info' | 'warning';
|
|
105
|
+
acceptableLoss: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The one entry `lostElements` holds in place of the list when the list would pass
|
|
109
|
+
* the API's 6 KB header cap. `lostElementsCount` stays the exact count.
|
|
110
|
+
*/
|
|
111
|
+
interface LostElementsTruncated {
|
|
112
|
+
truncated: true;
|
|
113
|
+
reason?: string;
|
|
114
|
+
}
|
|
94
115
|
/** Header metadata returned alongside a converted document. */
|
|
95
116
|
interface ConvertMeta {
|
|
96
117
|
sourceFormat?: string;
|
|
97
118
|
targetFormat?: string;
|
|
98
119
|
profileDetected?: string;
|
|
99
120
|
lostElementsCount?: number;
|
|
100
|
-
lostElements?:
|
|
121
|
+
lostElements?: Array<LostElement | LostElementsTruncated>;
|
|
101
122
|
conversionTools?: string;
|
|
102
123
|
/** True for a live key, false for a blq_test_ sandbox key. */
|
|
103
124
|
livemode?: boolean;
|
|
@@ -145,4 +166,5 @@ declare class BeliqApiError extends Error {
|
|
|
145
166
|
});
|
|
146
167
|
}
|
|
147
168
|
|
|
148
|
-
export { AccountInfo, ApiErrorCode, Beliq, BeliqApiError,
|
|
169
|
+
export { AccountInfo, ApiErrorCode, Beliq, BeliqApiError, ConvertSourceFormat, ConvertTargetFormat, DocumentInput, FacturxProfile, GenerateProfile, Invoice, ParseFormat, ParseResult, RulesetArtifact, Standard, ValidateFormat, ValidationResult };
|
|
170
|
+
export type { BeliqOptions, ConvertMeta, ConvertOptions, ConvertResult, DocumentOptions, GenerateInput, GenerateMeta, GenerateResult, LostElement, LostElementsTruncated, ParseOptions, ValidateOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { A as AccountInfo, S as Standard, I as Invoice, n as GenerateProfile, F as FacturxProfile,
|
|
2
|
-
|
|
1
|
+
import { A as AccountInfo, S as Standard, I as Invoice, n as GenerateProfile, F as FacturxProfile, V as ValidationResult, R as RulesetArtifact, a as DocumentInput, o as ValidateFormat, q as ParseFormat, r as ParseResult, C as ConvertTargetFormat, u as ConvertSourceFormat, v as ApiErrorCode } from './types-Bc3c79Ss.js';
|
|
2
|
+
import { PlainObject } from './helpers.js';
|
|
3
|
+
export { w as ApiError, D as DEFAULT_BASE_URL, x as DEFAULT_MAX_RETRIES, y as DEFAULT_TIMEOUT_MS, z as GenerateBody, G as GeneratePreset, B as GenerateResponse, 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, E as ParseWarning, H as ParseWarningCode, J as Severity, K as ValidationFormat, M as ValidationIssue, l as isProfileAllowedForStandard, p as profilesForStandard } from './types-Bc3c79Ss.js';
|
|
3
4
|
|
|
4
5
|
interface BeliqOptions {
|
|
5
6
|
/** API key from the beliq dashboard (API Keys). */
|
|
@@ -51,7 +52,11 @@ interface GenerateInput {
|
|
|
51
52
|
interface DocumentOptions {
|
|
52
53
|
/** Override the sniffed request content type (application/xml | application/pdf). */
|
|
53
54
|
contentType?: string;
|
|
54
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Raw JSON deep-merged into the query; its values win over the named options.
|
|
57
|
+
* The API answers 400 `VALIDATION_ERROR` to a query key the operation does not
|
|
58
|
+
* declare, and `details.fields` names it.
|
|
59
|
+
*/
|
|
55
60
|
advanced?: PlainObject;
|
|
56
61
|
}
|
|
57
62
|
interface ValidateOptions extends DocumentOptions {
|
|
@@ -91,13 +96,29 @@ interface GenerateResult {
|
|
|
91
96
|
validationResult?: ValidationResult;
|
|
92
97
|
meta: GenerateMeta;
|
|
93
98
|
}
|
|
99
|
+
/** One loss a conversion recorded: https://docs.beliq.eu/api-reference/convert/#lostelement-schema */
|
|
100
|
+
interface LostElement {
|
|
101
|
+
path: string;
|
|
102
|
+
value: string | null;
|
|
103
|
+
reason: string;
|
|
104
|
+
severity: 'info' | 'warning';
|
|
105
|
+
acceptableLoss: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The one entry `lostElements` holds in place of the list when the list would pass
|
|
109
|
+
* the API's 6 KB header cap. `lostElementsCount` stays the exact count.
|
|
110
|
+
*/
|
|
111
|
+
interface LostElementsTruncated {
|
|
112
|
+
truncated: true;
|
|
113
|
+
reason?: string;
|
|
114
|
+
}
|
|
94
115
|
/** Header metadata returned alongside a converted document. */
|
|
95
116
|
interface ConvertMeta {
|
|
96
117
|
sourceFormat?: string;
|
|
97
118
|
targetFormat?: string;
|
|
98
119
|
profileDetected?: string;
|
|
99
120
|
lostElementsCount?: number;
|
|
100
|
-
lostElements?:
|
|
121
|
+
lostElements?: Array<LostElement | LostElementsTruncated>;
|
|
101
122
|
conversionTools?: string;
|
|
102
123
|
/** True for a live key, false for a blq_test_ sandbox key. */
|
|
103
124
|
livemode?: boolean;
|
|
@@ -145,4 +166,5 @@ declare class BeliqApiError extends Error {
|
|
|
145
166
|
});
|
|
146
167
|
}
|
|
147
168
|
|
|
148
|
-
export { AccountInfo, ApiErrorCode, Beliq, BeliqApiError,
|
|
169
|
+
export { AccountInfo, ApiErrorCode, Beliq, BeliqApiError, ConvertSourceFormat, ConvertTargetFormat, DocumentInput, FacturxProfile, GenerateProfile, Invoice, ParseFormat, ParseResult, RulesetArtifact, Standard, ValidateFormat, ValidationResult };
|
|
170
|
+
export type { BeliqOptions, ConvertMeta, ConvertOptions, ConvertResult, DocumentOptions, GenerateInput, GenerateMeta, GenerateResult, LostElement, LostElementsTruncated, ParseOptions, ValidateOptions };
|
package/dist/index.js
CHANGED
|
@@ -206,7 +206,15 @@ function isProfileAllowedForStandard(standard, profile) {
|
|
|
206
206
|
const allowed = profilesForStandard(standard);
|
|
207
207
|
return allowed.length === 0 || allowed.includes(profile);
|
|
208
208
|
}
|
|
209
|
-
var LIVE_VALIDATE_FORMATS = [
|
|
209
|
+
var LIVE_VALIDATE_FORMATS = [
|
|
210
|
+
"auto",
|
|
211
|
+
"cii",
|
|
212
|
+
"ubl",
|
|
213
|
+
"fatturapa",
|
|
214
|
+
"facturae",
|
|
215
|
+
"eslog",
|
|
216
|
+
"poland_ksef_fa3"
|
|
217
|
+
];
|
|
210
218
|
var LIVE_PARSE_FORMATS = ["auto", "cii", "ubl"];
|
|
211
219
|
var LIVE_CONVERT_SOURCE_FORMATS = [
|
|
212
220
|
"auto",
|
|
@@ -326,6 +334,16 @@ function parseRulesetArtifacts(headers) {
|
|
|
326
334
|
return void 0;
|
|
327
335
|
}
|
|
328
336
|
}
|
|
337
|
+
function parseLostElements(headers) {
|
|
338
|
+
const raw = headers.get("x-lost-elements");
|
|
339
|
+
if (!raw) return void 0;
|
|
340
|
+
try {
|
|
341
|
+
const parsed = JSON.parse(raw);
|
|
342
|
+
return Array.isArray(parsed) ? parsed : void 0;
|
|
343
|
+
} catch {
|
|
344
|
+
return void 0;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
329
347
|
function generateMeta(headers) {
|
|
330
348
|
return {
|
|
331
349
|
schematronVersion: headers.get("x-schematron-version") ?? void 0,
|
|
@@ -337,22 +355,13 @@ function generateMeta(headers) {
|
|
|
337
355
|
};
|
|
338
356
|
}
|
|
339
357
|
function convertMeta(headers) {
|
|
340
|
-
let lostElements;
|
|
341
|
-
const lostRaw = headers.get("x-lost-elements");
|
|
342
|
-
if (lostRaw) {
|
|
343
|
-
try {
|
|
344
|
-
const parsed = JSON.parse(lostRaw);
|
|
345
|
-
if (Array.isArray(parsed)) lostElements = parsed.map(String);
|
|
346
|
-
} catch {
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
358
|
const countRaw = headers.get("x-lost-elements-count");
|
|
350
359
|
return {
|
|
351
360
|
sourceFormat: headers.get("x-source-format") ?? void 0,
|
|
352
361
|
targetFormat: headers.get("x-target-format") ?? void 0,
|
|
353
362
|
profileDetected: headers.get("x-profile-detected") ?? void 0,
|
|
354
363
|
lostElementsCount: countRaw != null ? Number(countRaw) : void 0,
|
|
355
|
-
lostElements,
|
|
364
|
+
lostElements: parseLostElements(headers),
|
|
356
365
|
conversionTools: headers.get("x-conversion-tools") ?? void 0,
|
|
357
366
|
livemode: livemodeHeader(headers)
|
|
358
367
|
};
|