@kreiseck/kasseneck-api 1.19.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +70 -1
  3. package/dist/cjs/client/api.d.ts +19 -0
  4. package/dist/cjs/client/api.js +18 -0
  5. package/dist/cjs/client/aufrufe.d.ts +5 -3
  6. package/dist/cjs/client/aufrufe.js +20 -0
  7. package/dist/cjs/client/dep-export.d.ts +242 -0
  8. package/dist/cjs/client/dep-export.js +336 -0
  9. package/dist/cjs/client/index.d.ts +2 -1
  10. package/dist/cjs/client/index.js +21 -2
  11. package/dist/cjs/client/transport.d.ts +35 -0
  12. package/dist/cjs/client/transport.js +37 -2
  13. package/dist/cjs/index.d.ts +1 -1
  14. package/dist/cjs/index.js +20 -2
  15. package/dist/cjs/stored/vokabular.d.ts +1 -1
  16. package/dist/cjs/stored/vokabular.js +1 -1
  17. package/dist/cjs/version.d.ts +1 -1
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/esm/client/api.d.ts +19 -0
  20. package/dist/esm/client/api.js +19 -1
  21. package/dist/esm/client/aufrufe.d.ts +5 -3
  22. package/dist/esm/client/aufrufe.js +20 -0
  23. package/dist/esm/client/dep-export.d.ts +242 -0
  24. package/dist/esm/client/dep-export.js +325 -0
  25. package/dist/esm/client/index.d.ts +2 -1
  26. package/dist/esm/client/index.js +2 -1
  27. package/dist/esm/client/transport.d.ts +35 -0
  28. package/dist/esm/client/transport.js +36 -2
  29. package/dist/esm/index.d.ts +1 -1
  30. package/dist/esm/index.js +1 -1
  31. package/dist/esm/stored/vokabular.d.ts +1 -1
  32. package/dist/esm/stored/vokabular.js +1 -1
  33. package/dist/esm/version.d.ts +1 -1
  34. package/dist/esm/version.js +1 -1
  35. package/fixtures/hobex-hps-codes.json +1 -1
  36. package/fixtures/invoice-api.schema.json +1 -1
  37. package/fixtures/invoice-texts.json +1 -1
  38. package/fixtures/pos-texts.json +1 -1
  39. package/fixtures/surface.json +12 -2
  40. package/fixtures/v3/antworten/belege.json +1 -1
  41. package/fixtures/v3/antworten/belegmail.json +1 -1
  42. package/fixtures/v3/antworten/berichte.json +1 -1
  43. package/fixtures/v3/antworten/kasse-belege.json +1 -1
  44. package/fixtures/v3/antworten/kasse.json +2 -2
  45. package/fixtures/v3/antworten/lager.json +1 -1
  46. package/fixtures/v3/antworten/rechnungen.json +1 -1
  47. package/fixtures/v3/antworten/storno.json +1 -1
  48. package/fixtures/v3/stored/belege.json +1 -1
  49. package/fixtures/v3/stored/kasse.json +2 -2
  50. package/fixtures/v3/stored/rechnungen.json +1 -1
  51. package/fixtures/v3/v3-vokabular.json +140 -8
  52. package/fixtures/v3/zahlbetrag-faelle.json +1 -1
  53. package/package.json +1 -1
@@ -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
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';
@@ -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
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';
@@ -217,3 +217,38 @@ export type KasseneckPdfOrDataTransport = (functionName: string, params?: Record
217
217
  * ist unlesbar mit denselben Gruenden wie dort.
218
218
  */
219
219
  export declare function createPdfOrDataTransport(options: TransportOptions): KasseneckPdfOrDataTransport;
220
+ /**
221
+ * Ergebnis eines Aufrufs, der eine beliebige Datei **oder** eine Nutzlast
222
+ * liefert: die Datei mit Namen und Inhaltstyp aus den Kopfzeilen der Antwort
223
+ * (`Content-Disposition: attachment`), oder die `data` einer Erfolgshuelle
224
+ * (etwa ein Lese-Link, wenn die Datei zu gross fuer die Antwort ist).
225
+ */
226
+ export type FileOrData = {
227
+ file: {
228
+ bytes: Uint8Array;
229
+ fileName: string | null;
230
+ contentType: string | undefined;
231
+ };
232
+ } | {
233
+ data: unknown;
234
+ };
235
+ /** Optionen je Aufruf des Datei-oder-Daten-Wegs ([createFileOrDataTransport]). */
236
+ export interface FileOrDataCallOptions {
237
+ /**
238
+ * Zeitlimit dieses Aufrufs in Millisekunden (Anmeldung, Anfrage und Lesen
239
+ * des Rumpfs); ohne Angabe `TransportOptions.timeoutMs` (Vorgabe 30 s). Eine
240
+ * Datei kommt im Rumpf und braucht dafuer laenger als eine Huelle.
241
+ */
242
+ timeoutMs?: number;
243
+ }
244
+ /** Ruft eine Backend-Funktion auf, die irgendeine Datei **oder** eine JSON-Nutzlast liefert. */
245
+ export type KasseneckFileOrDataTransport = (functionName: string, params?: Record<string, unknown>, options?: FileOrDataCallOptions) => Promise<FileOrData>;
246
+ /**
247
+ * Vierter Einstiegspunkt, fuer Aufrufe, deren Datei kein PDF ist (DEP-JSON,
248
+ * CSV, ZIP: `getDepExportFile`). Die Antwort wird nur als Bytes gelesen.
249
+ * Entschieden wird an der Kopfzeile `Content-Disposition: attachment` — eine
250
+ * Datei ist hier selbst JSON und liesse sich am Inhalt nicht von der
251
+ * Erfolgshuelle trennen. Ohne diese Kopfzeile gilt der Rumpf als Huelle
252
+ * (Erfolg: `{ data }`, Fehler: derselbe fachliche Fehler wie auf dem JSON-Weg).
253
+ */
254
+ export declare function createFileOrDataTransport(options: TransportOptions): KasseneckFileOrDataTransport;
@@ -104,6 +104,37 @@ export function createPdfOrDataTransport(options) {
104
104
  const kern = createCore(options);
105
105
  return (functionName, params) => kern(functionName, params, undefined, undefined, undefined, alsBytes, pdfOderDatenAuswerten);
106
106
  }
107
+ /**
108
+ * Vierter Einstiegspunkt, fuer Aufrufe, deren Datei kein PDF ist (DEP-JSON,
109
+ * CSV, ZIP: `getDepExportFile`). Die Antwort wird nur als Bytes gelesen.
110
+ * Entschieden wird an der Kopfzeile `Content-Disposition: attachment` — eine
111
+ * Datei ist hier selbst JSON und liesse sich am Inhalt nicht von der
112
+ * Erfolgshuelle trennen. Ohne diese Kopfzeile gilt der Rumpf als Huelle
113
+ * (Erfolg: `{ data }`, Fehler: derselbe fachliche Fehler wie auf dem JSON-Weg).
114
+ */
115
+ export function createFileOrDataTransport(options) {
116
+ const kern = createCore(options);
117
+ return (functionName, params, aufruf) => kern(functionName, params, undefined, undefined, undefined, alsRohAntwort, dateiOderDatenAuswerten, aufruf?.timeoutMs);
118
+ }
119
+ const alsRohAntwort = async (antwort, functionName) => ({
120
+ bytes: await alsBytes(antwort, functionName),
121
+ disposition: antwort.headers.get('content-disposition'),
122
+ });
123
+ /** Dateiname aus `Content-Disposition`; nur der letzte Pfadteil, ohne Steuerzeichen. `null`, wenn keiner da ist. */
124
+ function dateinameAusKopf(disposition) {
125
+ const treffer = /filename\s*=\s*"([^"]*)"|filename\s*=\s*([^;\s]+)/i.exec(disposition);
126
+ const roh = treffer ? (treffer[1] ?? treffer[2] ?? '') : '';
127
+ // eslint-disable-next-line no-control-regex
128
+ const name = (roh.split(/[\\/]/).pop() ?? '').replace(/[\u0000-\u001f\u007f]/g, '').trim();
129
+ return name === '' || name === '.' || name === '..' ? null : name;
130
+ }
131
+ function dateiOderDatenAuswerten(roh, functionName, statusCode, inhaltstyp, geheimnisse, unlesbar) {
132
+ if (roh.disposition !== null && /^\s*attachment\b/i.test(roh.disposition)) {
133
+ return { file: { bytes: roh.bytes, fileName: dateinameAusKopf(roh.disposition), contentType: inhaltstyp } };
134
+ }
135
+ const text = new TextDecoder('utf-8').decode(roh.bytes);
136
+ return { data: jsonAuswerten(text, functionName, statusCode, inhaltstyp, geheimnisse, unlesbar) };
137
+ }
107
138
  /**
108
139
  * Gemeinsamer Kern aller Einstiegspunkte: Anmeldung, Zeitlimit, Anfrage und
109
140
  * HTTP-Status. Was danach mit dem Rumpf geschieht, entscheiden `lesen` und
@@ -113,7 +144,7 @@ function createCore(options) {
113
144
  const oeffentlicheBasis = v3Basis('baseUrl', options.baseUrl) ?? DEFAULT_BASE_URL;
114
145
  const kassenBasis = v3Basis('posBaseUrl', options.posBaseUrl) ?? POS_BASE_URL;
115
146
  const kassenweg = isRegisterUserAuth(options.auth);
116
- const zeitlimitMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
147
+ const standardZeitlimitMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
117
148
  const holen = options.fetch ?? globalesFetch();
118
149
  const kennung = options.clientHeader ?? `kasseneck-api/${PACKAGE_VERSION}`;
119
150
  pruefeKennung(kennung);
@@ -126,7 +157,10 @@ function createCore(options) {
126
157
  * (Berichte, Zahlungen, FinanzOnline), geht an die oeffentliche Basis.
127
158
  */
128
159
  const basisFuer = (functionName) => isPosOnlyCall(functionName) || (kassenweg && isPosCall(functionName)) ? kassenBasis : oeffentlicheBasis;
129
- return async function aufrufen(functionName, params = {}, extraBodyFields, secretParams, callOptions, lesen, auswerten) {
160
+ return async function aufrufen(functionName, params = {}, extraBodyFields, secretParams, callOptions, lesen, auswerten,
161
+ // Zeitlimit nur dieses Aufrufs (Datei-oder-Daten-Weg); sonst das des Transports.
162
+ eigenesZeitlimitMs) {
163
+ const zeitlimitMs = eigenesZeitlimitMs ?? standardZeitlimitMs;
130
164
  // Die URL nennt die Backend-Funktion, die Fehler nennen den **Vorgang**:
131
165
  // `financeWebService` fuehrt ein Dutzend verschiedener Vorgaenge unter einem
132
166
  // Endpunkt, und ein Fehler, der nur "financeWebService" sagt, verschweigt
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, type ReceiptTypeKey, VatRate, type VatRateKey, KeckPaymentMethod, type KeckPaymentMethodKey, CreditCardProvider, type CreditCardProviderKey, VoucherType, type VoucherTypeKey, VoucherAction, type VoucherActionKey, StripeLinkMode, type StripeLinkModeKey, } from './enums/index.js';
2
2
  export { type ReceiptItem, type ReceiptItemPayload, type ReceiptItemPayloadRead, toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, type TipRecipient, isTipItem, isVoucherItem, isVoucherFloatItem, type Voucher, type VoucherArticle, type IssuedVoucher, type VoucherPayload, toVoucherPayload, fromVoucherPayload, voucherIsValid, type Receipt, type RegistrationInfo, type ReceiptPayload, type ReceiptPayloadRead, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, type CancellationOf, type CancellationItem, type Cancellation, type CancellationReason, type CancellationErrorCode, type CancellationStatus, type ReturnDisposition, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, type CancellationFieldError, type ReceiptPayment, type ReceiptPaymentPayload, type ReceiptPaymentInput, fromReceiptPaymentPayload, toReceiptPaymentPayload, type PaymentErrorCode, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, type PaymentFieldError, type ReceiptEmailErrorCode, type ReceiptEmailVia, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, type ReceiptEmailSendErrorCode, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, type ReceiptEmailFieldError, RECEIPT_OUTPUT_KINDS, type ReceiptOutputKind, RECEIPT_OUTPUT_LOG_KINDS, type ReceiptOutputLogKind, RECEIPT_OUTPUT_RESULTS, type ReceiptOutputResult, RECEIPT_OUTPUT_ENTRIES_MAX, type ReceiptOutput, type ReceiptOutputActor, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, type ReceiptOutputEntryErrorCode, RECEIPT_OUTPUT_ERROR_CODES, type ReceiptOutputErrorCode, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, type ReceiptOutputFieldError, type ReceiptErrorCode, type ReceiptFieldError, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, type TipRefundSource, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, type ReceiptCompany, type ReceiptCompanyPayload, fromReceiptCompanyPayload, receiptCompanyTaxInfo, type Cashregister, type CashregisterOnboarding, type CashregisterPayload, type CashregisterOnboardingPayload, type CashregisterAutoLogout, type CashregisterAutoLogoutPayload, fromCashregisterPayload, type ReceiptSummary, type ReceiptSummaryPayload, fromReceiptSummaryPayload, type ZeroKind, ZERO_KINDS, isZeroKind, type ReportMonth, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, type StripeUrlSession, type StripeUrlSessionPayload, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, type HobexReceipt, type HobexReceiptPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
- export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, 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, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, createPdfOrDataTransport, 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, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, 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, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
3
+ export { type AuthCredentials, type KasseneckAuth, type ApiKeyAuthOptions, type RegisterUserAuthOptions, apiKeyAuth, registerUserAuth, 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, ALL_CALLS, type ApiCall, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, type PublicCall, type PosCall, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, type FileOrData, type FileOrDataCallOptions, type KasseneckFileOrDataTransport, 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, type ReceiptCommonOptions, type SellReceiptOptions, type TipOptions, type TipRecipientShare, type CancelReceiptOptions, type CancelReceiptResult, type ReceiptWithCompany, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, type ListMyReceiptsOptions, type ReceiptList, type ReceiptListStats, listMyCashregisters, checkVoucherCombinationError, type SendReceiptEmailOptions, type SendReceiptEmailResult, sendReceiptEmail, type ReceiptOutputEntry, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type RejectedReceiptOutput, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, type CashregisterReportPeriod, getReportV2, type ReportV2, type ReportV2Metadata, type ReportV2Options, 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, 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, type ListedFullReceipt, type ListReceiptsHeader, type CashboxStatus, type SignatureStatus, getCashboxStatus, getSignatureStatus, type KasseneckApi, createKasseneckApi, } from './client/index.js';
4
4
  export { type ReceiptDueTip, type ReceiptDueTipRecipient, type ReceiptDueOptions, type ReceiptDueBuckets, type ReceiptDueBreakdown, type ReceiptDueErrorReason, receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, type VoucherDueInfo, type VoucherDueArticle, type VoucherDueType, type VoucherRedeemContext, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock, type ViennaWallClock } from './vienna-time.js';
6
6
  export { type PosBusinessSettings, type PosDeviceSettings, type PosSettings, type ArticleGroup, type PosArticle, POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, } from './pos/index.js';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { ReceiptType, VatRate, KeckPaymentMethod, CreditCardProvider, VoucherType, VoucherAction, StripeLinkMode, } from './enums/index.js';
2
2
  export { toReceiptItemPayload, fromReceiptItemPayload, receiptItemTotalCents, receiptItemIsValid, negateReceiptItem, isTipItem, isVoucherItem, isVoucherFloatItem, toVoucherPayload, fromVoucherPayload, voucherIsValid, toReceiptPayload, fromReceiptPayload, receiptSubSumCents, receiptSumCents, receiptValueVoucherSign, RETURN_DISPOSITIONS, CANCELLATION_REASONS, CANCELLATION_STATUSES, CANCELLATION_ERROR_CODES, CANCELLATION_RESERVATION_MS, isCancellationReason, isReturnDisposition, isCancellationErrorCode, cancellationErrorCode, isCancellationError, cancellationFieldErrors, fromReceiptPaymentPayload, toReceiptPaymentPayload, PAYMENT_ERROR_CODES, isPaymentErrorCode, paymentErrorCode, isPaymentError, paymentFieldErrors, RECEIPT_EMAIL_ERROR_CODES, RECEIPT_EMAIL_SEND_ERROR_CODES, RECEIPT_EMAIL_VIAS, isReceiptEmailErrorCode, receiptEmailErrorCode, isReceiptEmailError, receiptEmailFieldErrors, RECEIPT_OUTPUT_KINDS, RECEIPT_OUTPUT_LOG_KINDS, RECEIPT_OUTPUT_RESULTS, RECEIPT_OUTPUT_ENTRIES_MAX, RECEIPT_OUTPUT_ENTRY_ERROR_CODES, RECEIPT_OUTPUT_ERROR_CODES, isReceiptOutputErrorCode, receiptOutputErrorCode, isReceiptOutputError, receiptOutputFieldErrors, RECEIPT_ERROR_CODES, isReceiptErrorCode, receiptErrorCode, isReceiptError, receiptFieldErrors, remainingQuantities, TIP_REFUND_SOURCES, isTipRefundSource, openStaffTipCents, cancellationItemsForTip, cancellationCashRefundCents, asksTipRefundSource, asksRefundTip, fromReceiptCompanyPayload, receiptCompanyTaxInfo, fromCashregisterPayload, fromReceiptSummaryPayload, ZERO_KINDS, isZeroKind, reportMonthFromDate, previousReportMonth, nextReportMonth, reportMonthKey, reportMonthReadable, toStripeUrlSessionPayload, fromStripeUrlSessionPayload, toHobexReceiptPayload, fromHobexReceiptPayload, hobexReceiptToCardPaymentData, hobexReceiptNeedsSignature, } from './models/index.js';
3
- export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, createPdfOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, 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, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
3
+ export { apiKeyAuth, registerUserAuth, DEFAULT_BASE_URL, POS_BASE_URL, DEFAULT_TIMEOUT_MS, ALL_CALLS, PUBLIC_CALLS, POS_CALLS, UNKNOWN_OUTCOME_CALLS, createTransport, createBinaryTransport, createPdfOrDataTransport, createFileOrDataTransport, KasseneckApiError, KasseneckAuthError, KasseneckHttpError, KasseneckNetworkError, KasseneckValidationError, CLIENT_ERROR_CODES, isKasseneckApiError, isKasseneckAuthError, isKasseneckHttpError, isKasseneckNetworkError, isKasseneckValidationError, isOutcomeUnknown, sellReceipt, sellReceiptWithCompany, paymentsExpectedCents, cardRefundReference, receiptLayoutFromResult, cancelReceipt, zeroReceipt, getReceipt, getReceiptWithCompany, generateFullReceiptId, getFirstReceiptDate, listMyReceipts, listMyCashregisters, checkVoucherCombinationError, sendReceiptEmail, logReceiptOutputs, downloadDailyReport, downloadMonthlyReport, getCashregisterReport, getReportV2, 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, 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, getCashboxStatus, getSignatureStatus, createKasseneckApi, } from './client/index.js';
4
4
  export { receiptDueCents, receiptDueBreakdown, ReceiptDueError, RECEIPT_DUE_ERROR_REASONS, isReceiptDueError, voucherRedeemMaxCents, VOUCHER_ZERO_RATE_BUCKET_FROM, } from './receipt/due.js';
5
5
  export { parseServerTimeStamp, toViennaWallClock } from './vienna-time.js';
6
6
  export { POS_BUSINESS_DEFAULTS, POS_DEVICE_DEFAULTS, mergePosSettings, fromArticleGroupPayload, fromPosArticlePayload, listMyArticleGroups, listMyArticles, getPosSettings, setMyPosSettings, setMyRegisterDeviceSettings, distributeDiscount, cancelScopeOf, receiptsScopeOf, stockViewOf, voucherPermsOf, } from './pos/index.js';
@@ -1,5 +1,5 @@
1
1
  /** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
2
- export declare const VOKABULAR_QUELLE = "f9d375a30bfb51addc8405dd6f5c24928ebc628166ae5ebf2b0c43d9f19701dd";
2
+ export declare const VOKABULAR_QUELLE = "b06a8be2fe8c96e7e266a4e237c77588e9bef4e3272a9343ed2969ba722a87f4";
3
3
  /** Schema-Notation des Vertrags: Blatt 'aussen': 'innen', Objekt { __: 'innen', ... }, Liste [ { __: 'innen', ... } ]. */
4
4
  export type SchemaEintrag = string | SchemaObjekt | readonly [SchemaObjekt];
5
5
  export interface SchemaObjekt {
@@ -1,7 +1,7 @@
1
1
  // Erzeugt von scripts/stored-vokabular.mjs aus fixtures/v3/v3-vokabular.json.
2
2
  // Nicht von Hand aendern: test/stored.test.ts vergleicht mit dem Vertrag.
3
3
  /** Fingerabdruck des Vertrags-Exports, aus dem diese Datei stammt (`_quelle.sha256`). */
4
- export const VOKABULAR_QUELLE = "f9d375a30bfb51addc8405dd6f5c24928ebc628166ae5ebf2b0c43d9f19701dd";
4
+ export const VOKABULAR_QUELLE = "b06a8be2fe8c96e7e266a4e237c77588e9bef4e3272a9343ed2969ba722a87f4";
5
5
  /** Schema je Endpunkt (aussen -> innen) und Wertverweise auf die Kataloge. */
6
6
  export const SCHEMAS = {
7
7
  "getReceipt": {
@@ -4,4 +4,4 @@
4
4
  * Client-Version, Nachtrag §6). Ein Test haelt sie gleich mit `package.json`;
5
5
  * beim Anheben der Version beide Stellen aendern.
6
6
  */
7
- export declare const PACKAGE_VERSION = "1.19.0";
7
+ export declare const PACKAGE_VERSION = "1.20.0";
@@ -4,4 +4,4 @@
4
4
  * Client-Version, Nachtrag §6). Ein Test haelt sie gleich mit `package.json`;
5
5
  * beim Anheben der Version beide Stellen aendern.
6
6
  */
7
- export const PACKAGE_VERSION = '1.19.0';
7
+ export const PACKAGE_VERSION = '1.20.0';
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.20.0",
3
3
  "measuredOn": {
4
4
  "tid": "3600335",
5
5
  "hpsVersion": "1.10.0",
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "title": "Kasseneck Rechnungs-API",
4
4
  "version": 2,
5
- "package": "1.19.0",
5
+ "package": "1.20.0",
6
6
  "endpoints": {
7
7
  "createCustomer": {
8
8
  "request": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.20.0",
3
3
  "languages": [
4
4
  "de",
5
5
  "en"
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.20.0",
3
3
  "messages": {
4
4
  "network.no_connection": {
5
5
  "text": "Keine Verbindung zum Server. Bitte die Internetverbindung prüfen und erneut versuchen."
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.19.0",
2
+ "version": "1.20.0",
3
3
  "baseUrls": {
4
4
  "public": "https://api.kasseneck.at/v3",
5
5
  "pos": "https://kasse.kasseneck.at/api/v3"
@@ -12,6 +12,8 @@
12
12
  "createCreditNote",
13
13
  "createCustomer",
14
14
  "createCustomerCashregister",
15
+ "createDepExport",
16
+ "createDepHandoverLink",
15
17
  "createPartnerCustomer",
16
18
  "checkPartnerCustomerEmail",
17
19
  "createPartnerWebhook",
@@ -26,6 +28,8 @@
26
28
  "getCustomer",
27
29
  "getCustomerCredentials",
28
30
  "getCustomerSignatureStatus",
31
+ "getDepExport",
32
+ "getDepExportFile",
29
33
  "getFirstReceiptDate",
30
34
  "getInvoice",
31
35
  "getInvoicePdf",
@@ -49,6 +53,7 @@
49
53
  "recordInvoicePayment",
50
54
  "reportCustomerContract",
51
55
  "requestCustomerSignature",
56
+ "revokeDepHandoverLink",
52
57
  "searchCustomers",
53
58
  "sendPartnerCustomerFonLink",
54
59
  "sendPartnerWebhookTest",
@@ -258,7 +263,12 @@
258
263
  "getStocktakePdf",
259
264
  "orderSignatureCard",
260
265
  "getSignatureCardOrder",
261
- "listReceipts"
266
+ "listReceipts",
267
+ "createDepExport",
268
+ "getDepExport",
269
+ "getDepExportFile",
270
+ "createDepHandoverLink",
271
+ "revokeDepHandoverLink"
262
272
  ],
263
273
  "pos": [
264
274
  "pairRegisterDevice",
@@ -2,7 +2,7 @@
2
2
  "_hinweis": "Vertrags-Export /v3, erzeugt aus den echten Handlern (npm run vertrag:v3 in functions/ und functions-kasse/). Nicht von Hand pflegen.",
3
3
  "_quelle": {
4
4
  "sha256": "7781447b4d50979c70a5d117afb9ef7e93a0d93f01d19b25bbfd1ab233dfff69",
5
- "inputsSha256": "df1229235f9e3230ca2d6b32ad65c0dfb5ca5a476551e92d1bc92bb2fd5d11bf",
5
+ "inputsSha256": "3ee0bad6bd2e4b8c87412d7301d9862d0d79adf3494bde08ad8fc533c9a60b66",
6
6
  "backendPackage": "@kreiseck/kasseneck-api@0.36.0",
7
7
  "inputs": [
8
8
  "docs/api/fehlercodes.json",
@@ -2,7 +2,7 @@
2
2
  "_hinweis": "Vertrags-Export /v3, erzeugt aus den echten Handlern (npm run vertrag:v3 in functions/ und functions-kasse/). Nicht von Hand pflegen.",
3
3
  "_quelle": {
4
4
  "sha256": "265bcf3e14cdea33ec3c4df399eb487d40c0d7793ee23d2ee12bcf664bcad550",
5
- "inputsSha256": "df1229235f9e3230ca2d6b32ad65c0dfb5ca5a476551e92d1bc92bb2fd5d11bf",
5
+ "inputsSha256": "3ee0bad6bd2e4b8c87412d7301d9862d0d79adf3494bde08ad8fc533c9a60b66",
6
6
  "backendPackage": "@kreiseck/kasseneck-api@0.36.0",
7
7
  "inputs": [
8
8
  "docs/api/fehlercodes.json",