@kreiseck/kasseneck-api 1.18.0 → 1.20.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 +22 -0
- package/README.md +90 -9
- package/dist/cjs/client/api.d.ts +19 -0
- package/dist/cjs/client/api.js +18 -0
- package/dist/cjs/client/aufrufe.d.ts +5 -3
- package/dist/cjs/client/aufrufe.js +20 -0
- package/dist/cjs/client/dep-export.d.ts +242 -0
- package/dist/cjs/client/dep-export.js +336 -0
- package/dist/cjs/client/index.d.ts +3 -2
- package/dist/cjs/client/index.js +22 -2
- package/dist/cjs/client/list-receipts.d.ts +45 -5
- package/dist/cjs/client/list-receipts.js +62 -3
- package/dist/cjs/client/receipts.js +2 -2
- package/dist/cjs/client/transport.d.ts +35 -0
- package/dist/cjs/client/transport.js +37 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +21 -2
- package/dist/cjs/models/receipt.d.ts +5 -3
- package/dist/cjs/stored/vokabular.d.ts +1 -1
- package/dist/cjs/stored/vokabular.js +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/client/api.d.ts +19 -0
- package/dist/esm/client/api.js +19 -1
- package/dist/esm/client/aufrufe.d.ts +5 -3
- package/dist/esm/client/aufrufe.js +20 -0
- package/dist/esm/client/dep-export.d.ts +242 -0
- package/dist/esm/client/dep-export.js +325 -0
- package/dist/esm/client/index.d.ts +3 -2
- package/dist/esm/client/index.js +3 -2
- package/dist/esm/client/list-receipts.d.ts +45 -5
- package/dist/esm/client/list-receipts.js +61 -3
- package/dist/esm/client/receipts.js +2 -2
- package/dist/esm/client/transport.d.ts +35 -0
- package/dist/esm/client/transport.js +36 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/models/receipt.d.ts +5 -3
- package/dist/esm/stored/vokabular.d.ts +1 -1
- package/dist/esm/stored/vokabular.js +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/fixtures/hobex-hps-codes.json +1 -1
- package/fixtures/invoice-api.schema.json +1 -1
- package/fixtures/invoice-texts.json +1 -1
- package/fixtures/pos-texts.json +1 -1
- package/fixtures/surface.json +12 -2
- package/fixtures/v3/antworten/belege.json +106 -8
- package/fixtures/v3/antworten/belegmail.json +1 -1
- package/fixtures/v3/antworten/berichte.json +1 -1
- package/fixtures/v3/antworten/kasse-belege.json +1 -1
- package/fixtures/v3/antworten/kasse.json +2 -2
- package/fixtures/v3/antworten/lager.json +1 -1
- package/fixtures/v3/antworten/rechnungen.json +1 -1
- package/fixtures/v3/antworten/storno.json +14 -2
- package/fixtures/v3/stored/belege.json +1 -1
- package/fixtures/v3/stored/kasse.json +2 -2
- package/fixtures/v3/stored/rechnungen.json +1 -1
- package/fixtures/v3/v3-vokabular.json +153 -10
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { KasseneckValidationError } from './errors.js';
|
|
2
|
+
import type { InternerDateiOderDatenTransport, InternerTransport } from './aufrufe.js';
|
|
3
|
+
import type { FetchLike } from './transport.js';
|
|
4
|
+
/**
|
|
5
|
+
* DEP-Export fuer die Kassennachschau (nur unter `/v3`): ein Export des
|
|
6
|
+
* Datenerfassungsprotokolls fuer einen vom Pruefungsorgan vorgegebenen
|
|
7
|
+
* Zeitraum (§ 19 Abs. 2 RKSV), Dateien zum Abholen und ein Pruefer-Link mit
|
|
8
|
+
* Code, ueber den das Pruefungsorgan die Dateien ohne Anmeldung laedt.
|
|
9
|
+
*
|
|
10
|
+
* **Anmeldung wie `listReceipts`:** API-Schluessel plus `cashregister-token`;
|
|
11
|
+
* die Kasse kommt aus dem Token, nie aus einem Parameter. Ein Export einer
|
|
12
|
+
* anderen Kasse ist `export_not_found`.
|
|
13
|
+
*
|
|
14
|
+
* **Ablauf:** `createDepExport` stellt den Export ein und antwortet sofort
|
|
15
|
+
* (`status: 'running'`; eine Wiederholung mit derselben `requestId` nennt den
|
|
16
|
+
* aktuellen Stand); er laeuft im Hintergrund. `waitForDepExport` fragt bis zum
|
|
17
|
+
* Ende, `getDepExportFile` holt eine Datei, `createDepHandoverLink` erzeugt den
|
|
18
|
+
* Link fuer das Pruefungsorgan.
|
|
19
|
+
*/
|
|
20
|
+
/** Zustand eines Exports: in Arbeit, fertig oder fehlgeschlagen. */
|
|
21
|
+
export declare const DEP_EXPORT_STATUSES: readonly ["running", "done", "failed"];
|
|
22
|
+
export type DepExportStatus = (typeof DEP_EXPORT_STATUSES)[number];
|
|
23
|
+
/** Die Dateien eines Exports: DEP-JSON, Protokoll (PDF), Positionen (CSV) und alles zusammen als ZIP. */
|
|
24
|
+
export declare const DEP_EXPORT_FILES: readonly ["dep", "protocol", "items", "zip"];
|
|
25
|
+
export type DepExportFileKind = (typeof DEP_EXPORT_FILES)[number];
|
|
26
|
+
/**
|
|
27
|
+
* Fehlercodes der fuenf Aufrufe (`code` des [KasseneckApiError]) wie im
|
|
28
|
+
* Vertrag des Backends (`errorCodes.depExport` in `fixtures/v3/v3-vokabular.json`,
|
|
29
|
+
* Katalog `dep_nachschau`), in dessen Reihenfolge; dazu kommen die gemeinsamen
|
|
30
|
+
* Codes von Anmeldung und Rand. Ein Code ausserhalb bleibt ueber
|
|
31
|
+
* `KasseneckApiError.code` lesbar.
|
|
32
|
+
*/
|
|
33
|
+
export declare const DEP_EXPORT_ERROR_CODES: readonly ["validation", "invalid_period", "idempotency_conflict", "export_running", "too_many_exports", "export_not_found", "export_not_ready", "export_failed", "invalid_file", "file_not_available", "too_many_links", "link_not_found", "server_error"];
|
|
34
|
+
/**
|
|
35
|
+
* Warum ein Export fehlgeschlagen ist (`DepExport.error`): die Werte des
|
|
36
|
+
* Katalogs `DEP_EXPORT_FEHLER` im Vertrag. `export_stalled` = nach 35 Minuten
|
|
37
|
+
* nicht fertig.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEP_EXPORT_FAILURES: readonly ["export_failed", "export_stalled"];
|
|
40
|
+
export type DepExportFailure = (typeof DEP_EXPORT_FAILURES)[number];
|
|
41
|
+
/**
|
|
42
|
+
* Codes, die die DEP-Aufrufe als `KasseneckApiError.code` werfen:
|
|
43
|
+
* [DEP_EXPORT_ERROR_CODES] und, aus [waitForDepExport], die Gruende eines
|
|
44
|
+
* fehlgeschlagenen Exports ([DEP_EXPORT_FAILURES], also auch `export_stalled`).
|
|
45
|
+
*/
|
|
46
|
+
export type DepExportErrorCode = (typeof DEP_EXPORT_ERROR_CODES)[number] | DepExportFailure;
|
|
47
|
+
/** Eingabe von [createDepExport]. Ohne `from`/`to` der ganze Bestand. */
|
|
48
|
+
export interface CreateDepExportOptions {
|
|
49
|
+
/** Erster Tag (inklusive), `YYYY-MM-DD`, nicht in der Zukunft. */
|
|
50
|
+
from?: string;
|
|
51
|
+
/** Letzter Tag (inklusive), `YYYY-MM-DD`, nicht vor `from`. */
|
|
52
|
+
to?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Wiederholungsschutz je Kasse: derselbe Wert mit demselben Zeitraum
|
|
55
|
+
* liefert denselben Export (mit seinem aktuellen Stand) statt eines zweiten;
|
|
56
|
+
* mit anderem Zeitraum `idempotency_conflict`. Hoechstens 64 Zeichen aus
|
|
57
|
+
* `A-Z a-z 0-9 _ -`. Bei unklarem Ausgang (Zeitlimit) mit **demselben** Wert
|
|
58
|
+
* und demselben Zeitraum wiederholen.
|
|
59
|
+
*/
|
|
60
|
+
requestId?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Antwort von [createDepExport]: Kennung und Zustand (bei einer wiederholten `requestId` auch `done`). */
|
|
63
|
+
export interface CreateDepExportResult {
|
|
64
|
+
exportId: string;
|
|
65
|
+
status: DepExportStatus;
|
|
66
|
+
from: string | null;
|
|
67
|
+
to: string | null;
|
|
68
|
+
}
|
|
69
|
+
/** Eine Luecke in der Belegnummerierung: Zaehler von bis (einschliesslich). */
|
|
70
|
+
export interface DepExportGap {
|
|
71
|
+
from: number;
|
|
72
|
+
to: number;
|
|
73
|
+
}
|
|
74
|
+
/** Erster Bruch der Signaturkette: am Zaehler `counter` erwartet, aber gefunden. */
|
|
75
|
+
export interface DepExportChainBreak {
|
|
76
|
+
counter: number | null;
|
|
77
|
+
expected: unknown;
|
|
78
|
+
found: unknown;
|
|
79
|
+
}
|
|
80
|
+
/** Befund der Pruefung des Exports (`DepExport.findings`). */
|
|
81
|
+
export interface DepExportFindings {
|
|
82
|
+
receiptCount: number | null;
|
|
83
|
+
counterFrom: number | null;
|
|
84
|
+
counterTo: number | null;
|
|
85
|
+
/** Fehlende Belegnummern als zusammenhaengende Bereiche. */
|
|
86
|
+
gaps: DepExportGap[];
|
|
87
|
+
/** Hoechstens ein Eintrag: der erste Bruch der Kette. */
|
|
88
|
+
chainBreaks: DepExportChainBreak[];
|
|
89
|
+
/** `receiptId` der Belege ohne Zaehler. */
|
|
90
|
+
withoutCounter: string[];
|
|
91
|
+
/** `receiptId` der Belege ohne Signatur. */
|
|
92
|
+
withoutSignature: string[];
|
|
93
|
+
}
|
|
94
|
+
/** Die Positionsdatei (CSV) eines Exports; `null` bei Exporten aus der Zeit davor. */
|
|
95
|
+
export interface DepExportItems {
|
|
96
|
+
rowCount: number;
|
|
97
|
+
sha256: string;
|
|
98
|
+
size: number;
|
|
99
|
+
}
|
|
100
|
+
/** Ein Pruefer-Link, wie ihn der Export auffuehrt (ohne Adresse und Code). */
|
|
101
|
+
export interface DepHandoverLinkInfo {
|
|
102
|
+
linkId: string;
|
|
103
|
+
createdAt: string | null;
|
|
104
|
+
expiresAt: string | null;
|
|
105
|
+
revokedAt: string | null;
|
|
106
|
+
firstAccessAt: string | null;
|
|
107
|
+
accessCount: number;
|
|
108
|
+
}
|
|
109
|
+
/** Ein Export mit Zustand, Kennzahlen, Befund und Links (`getDepExport`). Zeiten ISO 8601 (UTC). */
|
|
110
|
+
export interface DepExport {
|
|
111
|
+
exportId: string;
|
|
112
|
+
status: DepExportStatus;
|
|
113
|
+
from: string | null;
|
|
114
|
+
to: string | null;
|
|
115
|
+
createdAt: string | null;
|
|
116
|
+
finishedAt: string | null;
|
|
117
|
+
receiptCount: number | null;
|
|
118
|
+
counterFrom: number | null;
|
|
119
|
+
counterTo: number | null;
|
|
120
|
+
/** SHA-256 (hex) der DEP-JSON-Datei. */
|
|
121
|
+
sha256: string | null;
|
|
122
|
+
/** Groesse der DEP-JSON-Datei in Byte. */
|
|
123
|
+
size: number | null;
|
|
124
|
+
findings: DepExportFindings | null;
|
|
125
|
+
items: DepExportItems | null;
|
|
126
|
+
handoverLinks: DepHandoverLinkInfo[];
|
|
127
|
+
/** Nur bei `status: 'failed'`: `export_stalled` (haengend) oder `export_failed`. */
|
|
128
|
+
error?: DepExportFailure;
|
|
129
|
+
}
|
|
130
|
+
/** Eingabe von [waitForDepExport]. */
|
|
131
|
+
export interface WaitForDepExportOptions {
|
|
132
|
+
exportId: string;
|
|
133
|
+
/** Hoechstdauer in Millisekunden (Vorgabe 600.000 = 10 Minuten). */
|
|
134
|
+
timeoutMs?: number;
|
|
135
|
+
}
|
|
136
|
+
/** Eingabe von [getDepExportFile]. */
|
|
137
|
+
export interface GetDepExportFileOptions {
|
|
138
|
+
exportId: string;
|
|
139
|
+
file: DepExportFileKind;
|
|
140
|
+
/**
|
|
141
|
+
* Bekannte SHA-256-Pruefsumme (hex) der Datei, etwa `DepExport.sha256` fuer
|
|
142
|
+
* `dep` oder `DepExport.items.sha256` fuer `items`. Weicht die geladene Datei
|
|
143
|
+
* ab, wirft der Aufruf. Bei einem Lese-Link prueft der Aufruf ausserdem immer
|
|
144
|
+
* gegen die Pruefsumme, die der Server mit dem Link nennt.
|
|
145
|
+
*/
|
|
146
|
+
sha256?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Zeitlimit in Millisekunden (Vorgabe 600.000), je fuer den Aufruf selbst und
|
|
149
|
+
* fuer das Laden ueber einen Lese-Link. Der Aufruf liefert eine Datei bis
|
|
150
|
+
* 9 MiB direkt und braucht dafuer mehr als das allgemeine Zeitlimit des
|
|
151
|
+
* Transports (`timeoutMs`, Vorgabe 30 s); es gilt hier nicht.
|
|
152
|
+
*/
|
|
153
|
+
downloadTimeoutMs?: number;
|
|
154
|
+
}
|
|
155
|
+
/** Eine geladene, gepruefte Datei. */
|
|
156
|
+
export interface DepExportFile {
|
|
157
|
+
bytes: Uint8Array;
|
|
158
|
+
fileName: string;
|
|
159
|
+
contentType: string;
|
|
160
|
+
/** SHA-256 (hex) der Bytes, vom Paket berechnet. */
|
|
161
|
+
sha256: string;
|
|
162
|
+
}
|
|
163
|
+
/** Ein erzeugter Pruefer-Link (`createDepHandoverLink`). Adresse und Code nur jetzt, danach nie wieder. */
|
|
164
|
+
export interface DepHandoverLink {
|
|
165
|
+
linkId: string;
|
|
166
|
+
/** Adresse fuer das Pruefungsorgan (Token im Fragment). */
|
|
167
|
+
url: string;
|
|
168
|
+
/** 6-stelliger Code, getrennt von der Adresse zu uebergeben. */
|
|
169
|
+
code: string;
|
|
170
|
+
expiresAt: string;
|
|
171
|
+
}
|
|
172
|
+
/** Antwort von [revokeDepHandoverLink]. */
|
|
173
|
+
export interface RevokedDepHandoverLink {
|
|
174
|
+
linkId: string;
|
|
175
|
+
revokedAt: string | null;
|
|
176
|
+
}
|
|
177
|
+
/** Wartezeiten von [waitForDepExport]: 2 s, dann je x1,5, hoechstens 15 s. */
|
|
178
|
+
export declare const DEP_EXPORT_POLL_START_MS = 2000;
|
|
179
|
+
export declare const DEP_EXPORT_POLL_FACTOR = 1.5;
|
|
180
|
+
export declare const DEP_EXPORT_POLL_MAX_MS = 15000;
|
|
181
|
+
/** Vorgabe fuer `waitForDepExport.timeoutMs`. */
|
|
182
|
+
export declare const DEP_EXPORT_WAIT_TIMEOUT_MS = 600000;
|
|
183
|
+
/** Vorgabe fuer `getDepExportFile.downloadTimeoutMs`: der Aufruf selbst und das Laden ueber einen Lese-Link. */
|
|
184
|
+
export declare const DEP_EXPORT_DOWNLOAD_TIMEOUT_MS = 600000;
|
|
185
|
+
/**
|
|
186
|
+
* [waitForDepExport] gab auf, weil der Export nach `timeoutMs` weder fertig
|
|
187
|
+
* noch fehlgeschlagen war. Der Export laeuft serverseitig weiter: mit
|
|
188
|
+
* `getDepExport` (oder erneutem Warten) nachsehen, nicht neu anstossen.
|
|
189
|
+
*/
|
|
190
|
+
export declare class DepExportTimeoutError extends Error {
|
|
191
|
+
readonly name = "DepExportTimeoutError";
|
|
192
|
+
readonly exportId: string;
|
|
193
|
+
readonly timeoutMs: number;
|
|
194
|
+
/** Zustand bei der letzten Abfrage. */
|
|
195
|
+
readonly lastStatus: DepExportStatus;
|
|
196
|
+
constructor(exportId: string, timeoutMs: number, lastStatus: DepExportStatus);
|
|
197
|
+
}
|
|
198
|
+
/** Das Ergebnis stimmt nicht mit der Pruefsumme ueberein: die Datei ist nicht zu verwenden. */
|
|
199
|
+
export declare class DepExportChecksumError extends KasseneckValidationError {
|
|
200
|
+
readonly expected: string;
|
|
201
|
+
readonly actual: string;
|
|
202
|
+
constructor(exportId: string, file: DepExportFileKind, expected: string, actual: string);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Stellt einen DEP-Export ein (`createDepExport`) und antwortet sofort mit
|
|
206
|
+
* `status: 'running'`. Hoechstens ein laufender Export je Kasse
|
|
207
|
+
* (`export_running`, `details.exportId` nennt ihn). Mit `requestId` ist der
|
|
208
|
+
* Aufruf wiederholbar: dieselbe Kennung mit demselben Zeitraum liefert den
|
|
209
|
+
* bestehenden Export mit seinem aktuellen Stand (auch `done` oder `failed`),
|
|
210
|
+
* mit anderem Zeitraum `idempotency_conflict`.
|
|
211
|
+
*/
|
|
212
|
+
export declare function createDepExport(transport: InternerTransport, options?: CreateDepExportOptions): Promise<CreateDepExportResult>;
|
|
213
|
+
/** Zustand, Kennzahlen, Befund und Links eines Exports (`getDepExport`). */
|
|
214
|
+
export declare function getDepExport(transport: InternerTransport, options: {
|
|
215
|
+
exportId: string;
|
|
216
|
+
}): Promise<DepExport>;
|
|
217
|
+
/**
|
|
218
|
+
* Wartet, bis der Export fertig ist, und gibt ihn zurueck. Fragt mit
|
|
219
|
+
* [DEP_EXPORT_POLL_START_MS] Abstand, dann je x[DEP_EXPORT_POLL_FACTOR],
|
|
220
|
+
* hoechstens [DEP_EXPORT_POLL_MAX_MS]. Bei `failed` wirft er einen
|
|
221
|
+
* [KasseneckApiError] mit `code` `export_failed` oder `export_stalled`
|
|
222
|
+
* (haengender Export); nach `timeoutMs` einen [DepExportTimeoutError]. Ein
|
|
223
|
+
* Fehler beim Abfragen selbst bricht ab.
|
|
224
|
+
*/
|
|
225
|
+
export declare function waitForDepExport(transport: InternerTransport, options: WaitForDepExportOptions): Promise<DepExport>;
|
|
226
|
+
/**
|
|
227
|
+
* Holt eine Datei eines fertigen Exports (`getDepExportFile`). Der Server
|
|
228
|
+
* liefert sie bis 9 MiB selbst, darueber als signierten Lese-Link (15 Minuten);
|
|
229
|
+
* dem Link folgt dieser Aufruf und laedt die Bytes. In beiden Faellen ist das
|
|
230
|
+
* Ergebnis dasselbe. Geprueft wird die SHA-256-Summe: beim Lese-Link immer
|
|
231
|
+
* gegen die Summe des Servers, sonst und zusaetzlich gegen `options.sha256`,
|
|
232
|
+
* wenn sie bekannt ist. Eine Abweichung wirft [DepExportChecksumError].
|
|
233
|
+
*/
|
|
234
|
+
export declare function getDepExportFile(transport: InternerDateiOderDatenTransport, fetchFn: FetchLike, options: GetDepExportFileOptions): Promise<DepExportFile>;
|
|
235
|
+
/** Erzeugt einen Pruefer-Link zu einem fertigen Export (`createDepHandoverLink`). Gueltig 14 Tage. */
|
|
236
|
+
export declare function createDepHandoverLink(transport: InternerTransport, options: {
|
|
237
|
+
exportId: string;
|
|
238
|
+
}): Promise<DepHandoverLink>;
|
|
239
|
+
/** Widerruft einen Pruefer-Link der eigenen Kasse (`revokeDepHandoverLink`). */
|
|
240
|
+
export declare function revokeDepHandoverLink(transport: InternerTransport, options: {
|
|
241
|
+
linkId: string;
|
|
242
|
+
}): Promise<RevokedDepHandoverLink>;
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { KasseneckApiError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* DEP-Export fuer die Kassennachschau (nur unter `/v3`): ein Export des
|
|
4
|
+
* Datenerfassungsprotokolls fuer einen vom Pruefungsorgan vorgegebenen
|
|
5
|
+
* Zeitraum (§ 19 Abs. 2 RKSV), Dateien zum Abholen und ein Pruefer-Link mit
|
|
6
|
+
* Code, ueber den das Pruefungsorgan die Dateien ohne Anmeldung laedt.
|
|
7
|
+
*
|
|
8
|
+
* **Anmeldung wie `listReceipts`:** API-Schluessel plus `cashregister-token`;
|
|
9
|
+
* die Kasse kommt aus dem Token, nie aus einem Parameter. Ein Export einer
|
|
10
|
+
* anderen Kasse ist `export_not_found`.
|
|
11
|
+
*
|
|
12
|
+
* **Ablauf:** `createDepExport` stellt den Export ein und antwortet sofort
|
|
13
|
+
* (`status: 'running'`; eine Wiederholung mit derselben `requestId` nennt den
|
|
14
|
+
* aktuellen Stand); er laeuft im Hintergrund. `waitForDepExport` fragt bis zum
|
|
15
|
+
* Ende, `getDepExportFile` holt eine Datei, `createDepHandoverLink` erzeugt den
|
|
16
|
+
* Link fuer das Pruefungsorgan.
|
|
17
|
+
*/
|
|
18
|
+
/** Zustand eines Exports: in Arbeit, fertig oder fehlgeschlagen. */
|
|
19
|
+
export const DEP_EXPORT_STATUSES = Object.freeze(['running', 'done', 'failed']);
|
|
20
|
+
/** Die Dateien eines Exports: DEP-JSON, Protokoll (PDF), Positionen (CSV) und alles zusammen als ZIP. */
|
|
21
|
+
export const DEP_EXPORT_FILES = Object.freeze(['dep', 'protocol', 'items', 'zip']);
|
|
22
|
+
/**
|
|
23
|
+
* Fehlercodes der fuenf Aufrufe (`code` des [KasseneckApiError]) wie im
|
|
24
|
+
* Vertrag des Backends (`errorCodes.depExport` in `fixtures/v3/v3-vokabular.json`,
|
|
25
|
+
* Katalog `dep_nachschau`), in dessen Reihenfolge; dazu kommen die gemeinsamen
|
|
26
|
+
* Codes von Anmeldung und Rand. Ein Code ausserhalb bleibt ueber
|
|
27
|
+
* `KasseneckApiError.code` lesbar.
|
|
28
|
+
*/
|
|
29
|
+
export const DEP_EXPORT_ERROR_CODES = Object.freeze([
|
|
30
|
+
'validation', // ungueltige requestId (Details in den Feldfehlern)
|
|
31
|
+
'invalid_period', // from/to kein Datum JJJJ-MM-TT, from in der Zukunft oder to vor from
|
|
32
|
+
'idempotency_conflict', // dieselbe requestId gehoert zu einem Export mit anderem Zeitraum
|
|
33
|
+
'export_running', // fuer diese Kasse laeuft schon ein Export (`details.exportId` nennt ihn)
|
|
34
|
+
'too_many_exports', // Tagesgrenze der Exporte erreicht
|
|
35
|
+
'export_not_found', // unbekannt oder einer anderen Kasse
|
|
36
|
+
'export_not_ready', // Datei oder Link nur zu einem fertigen Export
|
|
37
|
+
'export_failed', // der Export ist fehlgeschlagen
|
|
38
|
+
'invalid_file', // keine der Dateien dep, protocol, items, zip
|
|
39
|
+
'file_not_available', // diese Datei gibt es zu diesem Export nicht (etwa Positionen bei einem alten Export)
|
|
40
|
+
'too_many_links', // Grenze der aktiven Links je Export oder der neuen Links je Tag erreicht
|
|
41
|
+
'link_not_found', // unbekannt oder einer anderen Kasse (ein schon widerrufener Link ist kein Fehler: der Widerruf ist wiederholbar)
|
|
42
|
+
'server_error',
|
|
43
|
+
]);
|
|
44
|
+
/**
|
|
45
|
+
* Warum ein Export fehlgeschlagen ist (`DepExport.error`): die Werte des
|
|
46
|
+
* Katalogs `DEP_EXPORT_FEHLER` im Vertrag. `export_stalled` = nach 35 Minuten
|
|
47
|
+
* nicht fertig.
|
|
48
|
+
*/
|
|
49
|
+
export const DEP_EXPORT_FAILURES = Object.freeze(['export_failed', 'export_stalled']);
|
|
50
|
+
/** Wartezeiten von [waitForDepExport]: 2 s, dann je x1,5, hoechstens 15 s. */
|
|
51
|
+
export const DEP_EXPORT_POLL_START_MS = 2_000;
|
|
52
|
+
export const DEP_EXPORT_POLL_FACTOR = 1.5;
|
|
53
|
+
export const DEP_EXPORT_POLL_MAX_MS = 15_000;
|
|
54
|
+
/** Vorgabe fuer `waitForDepExport.timeoutMs`. */
|
|
55
|
+
export const DEP_EXPORT_WAIT_TIMEOUT_MS = 600_000;
|
|
56
|
+
/** Vorgabe fuer `getDepExportFile.downloadTimeoutMs`: der Aufruf selbst und das Laden ueber einen Lese-Link. */
|
|
57
|
+
export const DEP_EXPORT_DOWNLOAD_TIMEOUT_MS = 600_000;
|
|
58
|
+
/**
|
|
59
|
+
* [waitForDepExport] gab auf, weil der Export nach `timeoutMs` weder fertig
|
|
60
|
+
* noch fehlgeschlagen war. Der Export laeuft serverseitig weiter: mit
|
|
61
|
+
* `getDepExport` (oder erneutem Warten) nachsehen, nicht neu anstossen.
|
|
62
|
+
*/
|
|
63
|
+
export class DepExportTimeoutError extends Error {
|
|
64
|
+
name = 'DepExportTimeoutError';
|
|
65
|
+
exportId;
|
|
66
|
+
timeoutMs;
|
|
67
|
+
/** Zustand bei der letzten Abfrage. */
|
|
68
|
+
lastStatus;
|
|
69
|
+
constructor(exportId, timeoutMs, lastStatus) {
|
|
70
|
+
super(`waitForDepExport: Export ${exportId} nach ${timeoutMs} ms nicht fertig (Zustand ${lastStatus})`);
|
|
71
|
+
this.exportId = exportId;
|
|
72
|
+
this.timeoutMs = timeoutMs;
|
|
73
|
+
this.lastStatus = lastStatus;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Das Ergebnis stimmt nicht mit der Pruefsumme ueberein: die Datei ist nicht zu verwenden. */
|
|
77
|
+
export class DepExportChecksumError extends KasseneckValidationError {
|
|
78
|
+
expected;
|
|
79
|
+
actual;
|
|
80
|
+
constructor(exportId, file, expected, actual) {
|
|
81
|
+
super('getDepExportFile', `Pruefsumme der Datei ${file} von ${exportId} stimmt nicht (erwartet ${expected}, berechnet ${actual})`, 'response');
|
|
82
|
+
this.expected = expected;
|
|
83
|
+
this.actual = actual;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// ---- Hilfen -------------------------------------------------------------------------------------
|
|
87
|
+
const TAG = /^\d{4}-\d{2}-\d{2}$/;
|
|
88
|
+
const ANFRAGE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
89
|
+
const SHA256 = /^[0-9a-f]{64}$/i;
|
|
90
|
+
const VORGABEN = {
|
|
91
|
+
dep: { fileName: (id) => `${id}.json`, contentType: 'application/json' },
|
|
92
|
+
protocol: { fileName: (id) => `${id}.pdf`, contentType: 'application/pdf' },
|
|
93
|
+
items: { fileName: (id) => `${id}_positionen.csv`, contentType: 'text/csv; charset=utf-8' },
|
|
94
|
+
zip: { fileName: (id) => `${id}.zip`, contentType: 'application/zip' },
|
|
95
|
+
};
|
|
96
|
+
function eingabefehler(name, grund) {
|
|
97
|
+
return new KasseneckValidationError(name, grund, 'request');
|
|
98
|
+
}
|
|
99
|
+
function antwortfehler(name, grund) {
|
|
100
|
+
return new KasseneckValidationError(name, grund, 'response');
|
|
101
|
+
}
|
|
102
|
+
const istObjekt = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
103
|
+
function pruefeKennung(name, feld, wert) {
|
|
104
|
+
if (typeof wert !== 'string' || wert.trim() === '')
|
|
105
|
+
throw eingabefehler(name, `${feld} fehlt oder ist leer`);
|
|
106
|
+
return wert;
|
|
107
|
+
}
|
|
108
|
+
/** Ist das ein echter Kalendertag `JJJJ-MM-TT`? (Rechnung ohne Zeitzone.) */
|
|
109
|
+
function istKalendertag(text) {
|
|
110
|
+
if (!TAG.test(text))
|
|
111
|
+
return false;
|
|
112
|
+
const [j, m, t] = text.split('-').map(Number);
|
|
113
|
+
const d = new Date(Date.UTC(j, m - 1, t));
|
|
114
|
+
return d.getUTCFullYear() === j && d.getUTCMonth() === m - 1 && d.getUTCDate() === t;
|
|
115
|
+
}
|
|
116
|
+
async function sha256Hex(bytes) {
|
|
117
|
+
const umgebung = globalThis;
|
|
118
|
+
const subtle = umgebung.crypto?.subtle;
|
|
119
|
+
if (!subtle)
|
|
120
|
+
throw new Error('getDepExportFile: kein globales crypto.subtle vorhanden — Node >= 20.18 verwenden');
|
|
121
|
+
const digest = new Uint8Array(await subtle.digest('SHA-256', bytes));
|
|
122
|
+
return Array.from(digest, (b) => b.toString(16).padStart(2, '0')).join('');
|
|
123
|
+
}
|
|
124
|
+
function exportAus(daten, name) {
|
|
125
|
+
if (!istObjekt(daten))
|
|
126
|
+
throw antwortfehler(name, 'Antwort enthaelt keine Daten (data fehlt)');
|
|
127
|
+
const status = daten['status'];
|
|
128
|
+
if (typeof daten['exportId'] !== 'string' || !DEP_EXPORT_STATUSES.includes(status)) {
|
|
129
|
+
throw antwortfehler(name, 'Antwort ohne exportId oder mit unbekanntem Zustand');
|
|
130
|
+
}
|
|
131
|
+
if (!Array.isArray(daten['handoverLinks']))
|
|
132
|
+
throw antwortfehler(name, 'Antwort ohne handoverLinks');
|
|
133
|
+
return daten;
|
|
134
|
+
}
|
|
135
|
+
// ---- Aufrufe ------------------------------------------------------------------------------------
|
|
136
|
+
/**
|
|
137
|
+
* Stellt einen DEP-Export ein (`createDepExport`) und antwortet sofort mit
|
|
138
|
+
* `status: 'running'`. Hoechstens ein laufender Export je Kasse
|
|
139
|
+
* (`export_running`, `details.exportId` nennt ihn). Mit `requestId` ist der
|
|
140
|
+
* Aufruf wiederholbar: dieselbe Kennung mit demselben Zeitraum liefert den
|
|
141
|
+
* bestehenden Export mit seinem aktuellen Stand (auch `done` oder `failed`),
|
|
142
|
+
* mit anderem Zeitraum `idempotency_conflict`.
|
|
143
|
+
*/
|
|
144
|
+
export async function createDepExport(transport, options = {}) {
|
|
145
|
+
const name = 'createDepExport';
|
|
146
|
+
const params = {};
|
|
147
|
+
for (const feld of ['from', 'to']) {
|
|
148
|
+
const wert = options[feld];
|
|
149
|
+
if (wert === undefined)
|
|
150
|
+
continue;
|
|
151
|
+
if (typeof wert !== 'string' || !istKalendertag(wert))
|
|
152
|
+
throw eingabefehler(name, `${feld} muss ein Datum JJJJ-MM-TT sein`);
|
|
153
|
+
params[feld] = wert;
|
|
154
|
+
}
|
|
155
|
+
if (options.from !== undefined && options.to !== undefined && options.to < options.from) {
|
|
156
|
+
throw eingabefehler(name, 'to liegt vor from');
|
|
157
|
+
}
|
|
158
|
+
if (options.requestId !== undefined) {
|
|
159
|
+
if (typeof options.requestId !== 'string' || !ANFRAGE_ID.test(options.requestId)) {
|
|
160
|
+
throw eingabefehler(name, 'requestId: hoechstens 64 Zeichen aus A-Z, a-z, 0-9, _ und -');
|
|
161
|
+
}
|
|
162
|
+
params['requestId'] = options.requestId;
|
|
163
|
+
}
|
|
164
|
+
const daten = await transport(name, params);
|
|
165
|
+
if (!istObjekt(daten) || typeof daten['exportId'] !== 'string' || !DEP_EXPORT_STATUSES.includes(daten['status'])) {
|
|
166
|
+
throw antwortfehler(name, 'Antwort ohne exportId oder mit unbekanntem Zustand');
|
|
167
|
+
}
|
|
168
|
+
return daten;
|
|
169
|
+
}
|
|
170
|
+
/** Zustand, Kennzahlen, Befund und Links eines Exports (`getDepExport`). */
|
|
171
|
+
export async function getDepExport(transport, options) {
|
|
172
|
+
const name = 'getDepExport';
|
|
173
|
+
const exportId = pruefeKennung(name, 'exportId', options?.exportId);
|
|
174
|
+
return exportAus(await transport(name, { exportId }), name);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Wartet, bis der Export fertig ist, und gibt ihn zurueck. Fragt mit
|
|
178
|
+
* [DEP_EXPORT_POLL_START_MS] Abstand, dann je x[DEP_EXPORT_POLL_FACTOR],
|
|
179
|
+
* hoechstens [DEP_EXPORT_POLL_MAX_MS]. Bei `failed` wirft er einen
|
|
180
|
+
* [KasseneckApiError] mit `code` `export_failed` oder `export_stalled`
|
|
181
|
+
* (haengender Export); nach `timeoutMs` einen [DepExportTimeoutError]. Ein
|
|
182
|
+
* Fehler beim Abfragen selbst bricht ab.
|
|
183
|
+
*/
|
|
184
|
+
export async function waitForDepExport(transport, options) {
|
|
185
|
+
const name = 'waitForDepExport';
|
|
186
|
+
const exportId = pruefeKennung(name, 'exportId', options?.exportId);
|
|
187
|
+
const timeoutMs = options.timeoutMs ?? DEP_EXPORT_WAIT_TIMEOUT_MS;
|
|
188
|
+
if (!(typeof timeoutMs === 'number' && Number.isFinite(timeoutMs) && timeoutMs > 0)) {
|
|
189
|
+
throw eingabefehler(name, 'timeoutMs muss eine positive Zahl sein');
|
|
190
|
+
}
|
|
191
|
+
const ende = Date.now() + timeoutMs;
|
|
192
|
+
let abstand = DEP_EXPORT_POLL_START_MS;
|
|
193
|
+
for (;;) {
|
|
194
|
+
const stand = await getDepExport(transport, { exportId });
|
|
195
|
+
if (stand.status === 'done')
|
|
196
|
+
return stand;
|
|
197
|
+
if (stand.status === 'failed') {
|
|
198
|
+
throw new KasseneckApiError('getDepExport', stand.error === 'export_stalled' ? 'Der Export haengt (Stillstand).' : 'Der Export ist fehlgeschlagen.', { exportId, error: stand.error ?? 'export_failed' }, stand.error ?? 'export_failed');
|
|
199
|
+
}
|
|
200
|
+
const rest = ende - Date.now();
|
|
201
|
+
if (rest <= 0)
|
|
202
|
+
throw new DepExportTimeoutError(exportId, timeoutMs, stand.status);
|
|
203
|
+
await new Promise((weiter) => setTimeout(weiter, Math.min(abstand, rest)));
|
|
204
|
+
abstand = Math.min(abstand * DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function linkAus(name, wert) {
|
|
208
|
+
if (!istObjekt(wert))
|
|
209
|
+
throw antwortfehler(name, 'Antwort ist weder eine Datei noch ein Lese-Link (data.download fehlt)');
|
|
210
|
+
const { url, expiresAt, size, sha256, fileName, contentType } = wert;
|
|
211
|
+
if (typeof url !== 'string' || typeof expiresAt !== 'string' || typeof fileName !== 'string' || typeof contentType !== 'string' ||
|
|
212
|
+
typeof sha256 !== 'string' || !SHA256.test(sha256) || typeof size !== 'number' || !Number.isSafeInteger(size) || size < 0) {
|
|
213
|
+
throw antwortfehler(name, 'Lese-Link unvollstaendig (url, expiresAt, size, sha256, fileName, contentType)');
|
|
214
|
+
}
|
|
215
|
+
let adresse;
|
|
216
|
+
try {
|
|
217
|
+
adresse = new URL(url);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
throw antwortfehler(name, 'Lese-Link ist keine Adresse');
|
|
221
|
+
}
|
|
222
|
+
const lokal = adresse.hostname === 'localhost' || adresse.hostname === '127.0.0.1' || adresse.hostname === '[::1]';
|
|
223
|
+
if (adresse.protocol !== 'https:' && !(adresse.protocol === 'http:' && lokal)) {
|
|
224
|
+
throw antwortfehler(name, 'Lese-Link ist keine https-Adresse');
|
|
225
|
+
}
|
|
226
|
+
return { url, expiresAt, size, sha256: sha256.toLowerCase(), fileName, contentType };
|
|
227
|
+
}
|
|
228
|
+
/** Laedt die Bytes hinter einem Lese-Link. Fehlertexte und Fehlerobjekte nennen die Adresse nie (sie traegt die Berechtigung). */
|
|
229
|
+
async function ladeLink(fetchFn, url, timeoutMs) {
|
|
230
|
+
const name = 'getDepExportFile';
|
|
231
|
+
const abbruch = new AbortController();
|
|
232
|
+
let abgelaufen = false;
|
|
233
|
+
const wecker = setTimeout(() => {
|
|
234
|
+
abgelaufen = true;
|
|
235
|
+
abbruch.abort();
|
|
236
|
+
}, timeoutMs);
|
|
237
|
+
try {
|
|
238
|
+
// Ein GET ohne Rumpf und ohne eigene Kopfzeilen; FetchLike verlangt formal einen Rumpf, den ein GET nicht tragen darf.
|
|
239
|
+
const antwort = await fetchFn(url, { method: 'GET', headers: {}, signal: abbruch.signal });
|
|
240
|
+
if (antwort.status !== 200) {
|
|
241
|
+
throw new KasseneckHttpError(name, antwort.status, antwort.headers.get('content-type') ?? undefined, 'server-error', 'rejected');
|
|
242
|
+
}
|
|
243
|
+
return new Uint8Array(await antwort.arrayBuffer());
|
|
244
|
+
}
|
|
245
|
+
catch (ursache) {
|
|
246
|
+
if (ursache instanceof KasseneckHttpError)
|
|
247
|
+
throw ursache;
|
|
248
|
+
throw new KasseneckNetworkError(name, abgelaufen, timeoutMs, {}, 'rejected');
|
|
249
|
+
}
|
|
250
|
+
finally {
|
|
251
|
+
clearTimeout(wecker);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Holt eine Datei eines fertigen Exports (`getDepExportFile`). Der Server
|
|
256
|
+
* liefert sie bis 9 MiB selbst, darueber als signierten Lese-Link (15 Minuten);
|
|
257
|
+
* dem Link folgt dieser Aufruf und laedt die Bytes. In beiden Faellen ist das
|
|
258
|
+
* Ergebnis dasselbe. Geprueft wird die SHA-256-Summe: beim Lese-Link immer
|
|
259
|
+
* gegen die Summe des Servers, sonst und zusaetzlich gegen `options.sha256`,
|
|
260
|
+
* wenn sie bekannt ist. Eine Abweichung wirft [DepExportChecksumError].
|
|
261
|
+
*/
|
|
262
|
+
export async function getDepExportFile(transport, fetchFn, options) {
|
|
263
|
+
const name = 'getDepExportFile';
|
|
264
|
+
const exportId = pruefeKennung(name, 'exportId', options?.exportId);
|
|
265
|
+
if (!DEP_EXPORT_FILES.includes(options.file)) {
|
|
266
|
+
throw eingabefehler(name, 'file muss dep, protocol, items oder zip sein');
|
|
267
|
+
}
|
|
268
|
+
if (options.sha256 !== undefined && !(typeof options.sha256 === 'string' && SHA256.test(options.sha256))) {
|
|
269
|
+
throw eingabefehler(name, 'sha256 muss 64 Hexzeichen haben');
|
|
270
|
+
}
|
|
271
|
+
const frist = options.downloadTimeoutMs ?? DEP_EXPORT_DOWNLOAD_TIMEOUT_MS;
|
|
272
|
+
if (!(typeof frist === 'number' && Number.isFinite(frist) && frist > 0)) {
|
|
273
|
+
throw eingabefehler(name, 'downloadTimeoutMs muss eine positive Zahl sein');
|
|
274
|
+
}
|
|
275
|
+
const bekannt = options.sha256?.toLowerCase();
|
|
276
|
+
const vorgabe = VORGABEN[options.file];
|
|
277
|
+
// Eine direkte Datei (bis 9 MiB) kommt im Aufruf selbst: dieselbe Frist wie das Laden ueber den Link, nicht die 30 s
|
|
278
|
+
// des Transports.
|
|
279
|
+
const ergebnis = await transport(name, { exportId, file: options.file }, { timeoutMs: frist });
|
|
280
|
+
let bytes;
|
|
281
|
+
let fileName;
|
|
282
|
+
let contentType;
|
|
283
|
+
let vomServer;
|
|
284
|
+
if ('file' in ergebnis) {
|
|
285
|
+
bytes = ergebnis.file.bytes;
|
|
286
|
+
fileName = ergebnis.file.fileName ?? vorgabe.fileName(exportId);
|
|
287
|
+
contentType = ergebnis.file.contentType ?? vorgabe.contentType;
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
const link = linkAus(name, istObjekt(ergebnis.data) ? ergebnis.data['download'] : undefined);
|
|
291
|
+
bytes = await ladeLink(fetchFn, link.url, frist);
|
|
292
|
+
if (bytes.length !== link.size) {
|
|
293
|
+
throw antwortfehler(name, `Die geladene Datei hat ${bytes.length} Byte, der Server nannte ${link.size}`);
|
|
294
|
+
}
|
|
295
|
+
fileName = link.fileName;
|
|
296
|
+
contentType = link.contentType;
|
|
297
|
+
vomServer = link.sha256;
|
|
298
|
+
}
|
|
299
|
+
const summe = await sha256Hex(bytes);
|
|
300
|
+
for (const erwartet of [vomServer, bekannt]) {
|
|
301
|
+
if (erwartet !== undefined && erwartet !== summe)
|
|
302
|
+
throw new DepExportChecksumError(exportId, options.file, erwartet, summe);
|
|
303
|
+
}
|
|
304
|
+
return { bytes, fileName, contentType, sha256: summe };
|
|
305
|
+
}
|
|
306
|
+
/** Erzeugt einen Pruefer-Link zu einem fertigen Export (`createDepHandoverLink`). Gueltig 14 Tage. */
|
|
307
|
+
export async function createDepHandoverLink(transport, options) {
|
|
308
|
+
const name = 'createDepHandoverLink';
|
|
309
|
+
const exportId = pruefeKennung(name, 'exportId', options?.exportId);
|
|
310
|
+
const daten = await transport(name, { exportId });
|
|
311
|
+
if (!istObjekt(daten) || typeof daten['linkId'] !== 'string' || typeof daten['url'] !== 'string' ||
|
|
312
|
+
typeof daten['code'] !== 'string' || typeof daten['expiresAt'] !== 'string') {
|
|
313
|
+
throw antwortfehler(name, 'Antwort ohne linkId, url, code oder expiresAt');
|
|
314
|
+
}
|
|
315
|
+
return { linkId: daten['linkId'], url: daten['url'], code: daten['code'], expiresAt: daten['expiresAt'] };
|
|
316
|
+
}
|
|
317
|
+
/** Widerruft einen Pruefer-Link der eigenen Kasse (`revokeDepHandoverLink`). */
|
|
318
|
+
export async function revokeDepHandoverLink(transport, options) {
|
|
319
|
+
const name = 'revokeDepHandoverLink';
|
|
320
|
+
const linkId = pruefeKennung(name, 'linkId', options?.linkId);
|
|
321
|
+
const daten = await transport(name, { linkId });
|
|
322
|
+
if (!istObjekt(daten) || typeof daten['linkId'] !== 'string')
|
|
323
|
+
throw antwortfehler(name, 'Antwort ohne linkId');
|
|
324
|
+
return { linkId: daten['linkId'], revokedAt: typeof daten['revokedAt'] === 'string' ? daten['revokedAt'] : null };
|
|
325
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, } from './auth.js';
|
|
2
|
-
export { DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, type KasseneckPdfOrDataTransport, type PdfOrData, createTransport, createBinaryTransport, createPdfOrDataTransport, } from './transport.js';
|
|
2
|
+
export { DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, type HttpResponseLike, type HttpRequestInit, type FetchLike, type TransportOptions, type TransportBodyFields, type TransportCallOptions, type KasseneckTransport, type KasseneckBinaryTransport, type KasseneckPdfOrDataTransport, type PdfOrData, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, type FileOrData, type FileOrDataCallOptions, type KasseneckFileOrDataTransport, } from './transport.js';
|
|
3
3
|
export { ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, } from './aufrufe.js';
|
|
4
4
|
export { KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, type ValidationScope, type KasseneckError, type HttpFailureReason, type CauseDigest, type ErrorOutcome, CLIENT_ERROR_CODES, type ClientErrorCode, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, } from './errors.js';
|
|
5
5
|
export { type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, type CancelReceiptResult, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, } from './receipts.js';
|
|
6
6
|
export { listMyCashregisters } from './cashregisters.js';
|
|
7
|
-
export { listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, type ListReceiptsErrorCode, type ListReceiptsView, type ListReceiptsOrder, type ListReceiptsOptions, type ListReceiptsWindow, type ListReceiptsGrossByRate, type ListReceiptsSummary, type ListReceiptsDaySummary, type ListReceiptsPage, type ListedReceipt, } from './list-receipts.js';
|
|
7
|
+
export { listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, type ListReceiptsErrorCode, type ListReceiptsView, type ListReceiptsOrder, type ListReceiptsOptions, type ListReceiptsWindow, type ListReceiptsGrossByRate, type ListReceiptsSummary, type ListReceiptsDaySummary, type ListReceiptsPage, type ListedReceipt, type ListedFullReceipt, type ListReceiptsHeader, } from './list-receipts.js';
|
|
8
|
+
export { createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, type DepExportStatus, type DepExportFileKind, type DepExportErrorCode, type DepExportFailure, type CreateDepExportOptions, type CreateDepExportResult, type DepExportGap, type DepExportChainBreak, type DepExportFindings, type DepExportItems, type DepHandoverLinkInfo, type DepExport, type WaitForDepExportOptions, type GetDepExportFileOptions, type DepExportFile, type DepHandoverLink, type RevokedDepHandoverLink, } from './dep-export.js';
|
|
8
9
|
export { downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, type CashregisterReportPeriod, type ReportV2, type ReportV2Metadata, type ReportV2Options } from './reports.js';
|
|
9
10
|
export { type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, } from './status.js';
|
|
10
11
|
export { type KasseneckApi, createKasseneckApi } from './api.js';
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { apiKeyAuth, registerUserAuth, } from './auth.js';
|
|
2
|
-
export { DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, createTransport, createBinaryTransport, createPdfOrDataTransport, } from './transport.js';
|
|
2
|
+
export { DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, } from './transport.js';
|
|
3
3
|
export { ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, } from './aufrufe.js';
|
|
4
4
|
export { KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, } from './errors.js';
|
|
5
5
|
export { sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, checkVoucherCombinationError, sendReceiptEmail, logReceiptOutputs, } from './receipts.js';
|
|
6
6
|
export { listMyCashregisters } from './cashregisters.js';
|
|
7
|
-
export { listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, } from './list-receipts.js';
|
|
7
|
+
export { listReceipts, listAllReceipts, fromListReceiptsSummaryPayload, listedReceiptWithCompany, LIST_RECEIPTS_VIEWS, LIST_RECEIPTS_ORDERS, LIST_RECEIPTS_LIMIT_MAX, LIST_RECEIPTS_DAYS_MAX, LIST_ALL_RECEIPTS_MAX_PAGES, LIST_RECEIPTS_ERROR_CODES, } from './list-receipts.js';
|
|
8
|
+
export { createDepExport, getDepExport, waitForDepExport, getDepExportFile, createDepHandoverLink, revokeDepHandoverLink, DepExportTimeoutError, DepExportChecksumError, DEP_EXPORT_STATUSES, DEP_EXPORT_FILES, DEP_EXPORT_ERROR_CODES, DEP_EXPORT_FAILURES, DEP_EXPORT_POLL_START_MS, DEP_EXPORT_POLL_FACTOR, DEP_EXPORT_POLL_MAX_MS, DEP_EXPORT_WAIT_TIMEOUT_MS, DEP_EXPORT_DOWNLOAD_TIMEOUT_MS, } from './dep-export.js';
|
|
8
9
|
export { downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2 } from './reports.js';
|
|
9
10
|
export { getCashboxStatus, getSignatureStatus, } from './status.js';
|
|
10
11
|
export { createKasseneckApi } from './api.js';
|