@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.
- package/CHANGELOG.md +14 -0
- package/README.md +70 -1
- 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 +2 -1
- package/dist/cjs/client/index.js +21 -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 +20 -2
- 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 +2 -1
- package/dist/esm/client/index.js +2 -1
- 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/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 +1 -1
- 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 +1 -1
- 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 +140 -8
- package/fixtures/v3/zahlbetrag-faelle.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ Was vor 0.7.0 geschah, steht in der Commit-Historie (`git log`); ab hier wird
|
|
|
4
4
|
es hier geführt. Ein Eintrag nennt die Änderung **und ihren Grund** —
|
|
5
5
|
nur der Grund überlebt den nächsten Umbau.
|
|
6
6
|
|
|
7
|
+
## 1.20.0 - 2026-10-30
|
|
8
|
+
|
|
9
|
+
DEP export for the cash register inspection (*Kassennachschau*): `createDepExport`, `getDepExport`, `waitForDepExport`, `getDepExportFile`, `createDepHandoverLink` and `revokeDepHandoverLink` for the five new public endpoints (`/v3` only). Additive.
|
|
10
|
+
|
|
11
|
+
- **`createDepExport({ from?, to?, requestId? })`** (root and `createKasseneckApi`, `apiKeyAuth` with `cashregister-token` like `listReceipts`) queues an export of the data capture log (§ 19 para. 2 RKSV) and answers at once with `{ exportId, status, from, to }`. `from`/`to` are real calendar days `YYYY-MM-DD`, `to` not before `from`; `requestId` at most 64 characters of `A-Z a-z 0-9 _ -`; all checked before sending (`KasseneckValidationError`, `scope: 'request'`). Classified `repeatable` (not in `UNKNOWN_OUTCOME_CALLS`, outcome `rejected` after a lost answer): with `requestId` the call is idempotent, without it a repeat only starts a second export (limit 20 a day, no booking); resend with the **same** `requestId` and period to get the first, with its current `status` (also `done` or `failed`). The same `requestId` with another period is rejected with `idempotency_conflict`; `export_running` names the running export in `details.exportId`. Reason: an export runs minutes in the background and the hosting redirect cuts requests after 60 s, so creating and fetching are separate calls.
|
|
12
|
+
- **`getDepExport({ exportId })`** returns `DepExport`: `status` `running|done|failed`, `from`/`to`, `createdAt`/`finishedAt` (ISO 8601 UTC), `receiptCount`, `counterFrom`/`counterTo`, `sha256`/`size` of the DEP file, `findings` (`DepExportFindings`: `gaps [{ from, to }]`, `chainBreaks` with at most the first break, `withoutCounter` and `withoutSignature` as receipt ids), `items` (`rowCount`, `sha256`, `size`; `null` for exports from before item lines), `handoverLinks` (`DepHandoverLinkInfo`, never address or code) and, when failed, `error` `export_failed|export_stalled`. A body without `exportId`, with an unknown `status` or without `handoverLinks` throws `KasseneckValidationError` (`scope: 'response'`).
|
|
13
|
+
- **`waitForDepExport({ exportId, timeoutMs = 600000 })`** polls `getDepExport`: the first query at once, then after 2 s, every wait 1.5 times longer, at most 15 s (`DEP_EXPORT_POLL_*`); the last wait is shortened to the deadline, so the last query lies on it. `done` returns the export, `failed` throws `KasseneckApiError` with `code` `export_failed` or `export_stalled` (`details.exportId`; both in the type `DepExportErrorCode`), the deadline throws the new `DepExportTimeoutError` (`exportId`, `timeoutMs`, `lastStatus`; no `KasseneckApiError`, because the export keeps running and must be looked up, not queued again). A failing query (also a network error) ends the wait with its own error; the export keeps running, follow it with `getDepExport` (README). Reason: callers should not each write the same loop with their own back-off.
|
|
14
|
+
- **`getDepExportFile({ exportId, file, sha256?, downloadTimeoutMs? })`**, `file` `dep|protocol|items|zip` (`DEP_EXPORT_FILES`), returns `{ bytes, fileName, contentType, sha256 }`. The server answers up to 9 MiB with the file itself and above with JSON `{ download: { url, expiresAt, size, sha256, fileName, contentType } }`; the package follows the link (`GET`, no sign-in headers, https only, `http` only for localhost) and checks size and SHA-256 against the server's values. `downloadTimeoutMs` (default 600000 = 10 minutes, checked before sending) limits the call itself and the download over the link, each; the client's general `timeoutMs` (30 s) does not apply to this call. Reason: the server reads and checks a direct file of up to 9 MiB before it answers, which can take longer than 30 s. With `sha256` (for example `DepExport.sha256` or `items.sha256`) it checks a direct file as well; the sum is a client-side check and not sent. A mismatch throws `DepExportChecksumError` (a `KasseneckValidationError` with `scope: 'response'`, `expected`, `actual`). Errors while loading the link (`KasseneckHttpError`, `KasseneckNetworkError`) and the messages never contain the signed address. Reason: a download link carries the permission, and a file that does not match its checksum must not be handed on.
|
|
15
|
+
- **New transport entry `createFileOrDataTransport`** (root and `./client`, types `FileOrData`, `FileOrDataCallOptions`, `KasseneckFileOrDataTransport`): takes an optional per-call `{ timeoutMs }` (otherwise the transport's), reads the answer as bytes and decides on `Content-Disposition: attachment` between `{ file: { bytes, fileName, contentType } }` and the `data` of a success envelope (an error envelope gives the usual `KasseneckApiError`). The existing `createPdfOrDataTransport` decides on `%PDF` and cannot tell DEP JSON, CSV or ZIP from an envelope. The file name from the header is reduced to its last path part and stripped of control characters.
|
|
16
|
+
- **`createDepHandoverLink({ exportId })`** returns `{ linkId, url, code, expiresAt }` (valid 14 days; `url` and the 6-digit `code`, a string with leading zeros, only in this answer), **`revokeDepHandoverLink({ linkId })`** returns `{ linkId, revokedAt }`. Both are `repeatable` like `createDepExport`: a repeated `createDepHandoverLink` makes a second link (the first stays in `getDepExport().handoverLinks` and can be revoked; the price is at most `too_many_links`), `revokeDepHandoverLink` is idempotent. `getDepExport` and `getDepExportFile` are reads.
|
|
17
|
+
- **`DEP_EXPORT_ERROR_CODES`** equal to `errorCodes.depExport` of the contract (order included, every code in `errorCodes.all`; pinned by a test): `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` (unknown or of another cash register; revoking twice is no error), `server_error` (plus the codes of sign-in and edge). **`DEP_EXPORT_FAILURES`** (`export_failed`, `export_stalled`) equal to the values of the contract catalogue `DEP_EXPORT_FEHLER`. Type `DepExportErrorCode` covers both lists.
|
|
18
|
+
- `PUBLIC_CALLS` is now 113 and `ALL_CALLS`, `CALLS_WITHOUT_EFFECT` know the five calls (two reads, three `repeatable`; `UNKNOWN_OUTCOME_CALLS` unchanged). Contract `v3` re-fetched from the backend (the five endpoints in `endpoints.public`, `v3Routed` and the effect lists; their schemas are empty; `errorCodes.depExport` and `catalogs.DEP_EXPORT_FEHLER`).
|
|
19
|
+
|
|
7
20
|
## 1.19.0 - 2026-10-30
|
|
8
21
|
|
|
9
22
|
The full view of `listReceipts` delivers what `getReceipt` delivers (backend 30.10.2026, spec `list-receipts-voll`). Additive for reading.
|
|
@@ -12,6 +25,7 @@ The full view of `listReceipts` delivers what `getReceipt` delivers (backend 30.
|
|
|
12
25
|
- **Receipts of the full view: `ListedFullReceipt`** (`Receipt` plus `testSignature`); `registrationInfo` on zero receipts. No server `layout` in the list: it is the main cost driver of a page (about 2.7 times the size) and only needed for the receipt someone opens or prints, so it stays with `getReceiptWithCompany`. New helper `listedReceiptWithCompany(page, receipt)` returns the `ReceiptWithCompany` of `getReceiptWithCompany` without `outputs` and with `layout: null`; `receiptLayoutFromResult` builds the layout from it. Reason: one way to print and show a receipt, single or from the list.
|
|
13
26
|
- **Provider data follow the caller, not the channel.** The backend now returns `payments[].providerPaymentId`/`providerData` (and `cardPaymentId`/`cardPaymentData` on old card receipts) to the business itself on both channels, in `getReceipt`, `createReceipt`, `cancelReceipt`, `getReportV2` and `listReceipts`; a partner access never. No API change here (the fields were already optional); `cardRefundReference` and the card-refund check now name that rule in their messages. Reason: the restriction to the register channel stopped nobody holding the API key and pushed integrations into the register channel.
|
|
14
27
|
- Contract re-fetched from the backend: provider data now in the `/v3` cases of `belege.json` and `storno.json`, schema of `listReceipts` with the new fields; other files change only `_quelle`.
|
|
28
|
+
|
|
15
29
|
## 1.18.0 - 2026-10-30
|
|
16
30
|
|
|
17
31
|
Recording handwritten receipts (Nacherfassung). After a register outage or a sale outside the premises the business
|
package/README.md
CHANGED
|
@@ -553,7 +553,8 @@ The facade from `createKasseneckApi` offers `sellReceipt` and
|
|
|
553
553
|
`sendReceiptEmail`, the report downloads, the FinanzOnline status queries
|
|
554
554
|
(`getCashboxStatus`, `getSignatureStatus`), `getReportV2({ start, end })` for
|
|
555
555
|
the raw receipts and company data of a period, `listReceipts` and
|
|
556
|
-
`listAllReceipts` for receipt lists page by page (see below),
|
|
556
|
+
`listAllReceipts` for receipt lists page by page (see below), the DEP export
|
|
557
|
+
for the cash register inspection (see below), and the Stripe
|
|
557
558
|
and Hobex cloud payments.
|
|
558
559
|
|
|
559
560
|
The models are English throughout: the company has `taxNumber` and `vatId`, a
|
|
@@ -673,6 +674,74 @@ for await (const receipt of api.listAllReceipts({ from: '2026-10-01', to: '2026-
|
|
|
673
674
|
cash register or query, or changed window, `order` or `view`),
|
|
674
675
|
`server_error`, plus the codes of sign-in and edge.
|
|
675
676
|
|
|
677
|
+
### DEP export for the cash register inspection (*Kassennachschau*)
|
|
678
|
+
|
|
679
|
+
For a period named by the inspector (§ 19 para. 2 RKSV) the register hands out
|
|
680
|
+
its data capture log (*DEP*), a protocol, the item lines and everything as a ZIP,
|
|
681
|
+
and a handover link with a code the inspector opens without signing in. Same
|
|
682
|
+
sign-in as `listReceipts` (API key plus `cashregister-token`, the cash register
|
|
683
|
+
comes from the token), only on `/v3`.
|
|
684
|
+
|
|
685
|
+
```ts
|
|
686
|
+
const started = await api.createDepExport({ from: '2026-10-01', to: '2026-10-29', requestId: 'inspection-2026-10-30' });
|
|
687
|
+
const dep = await api.waitForDepExport({ exportId: started.exportId }); // polls 2 s, x1.5, at most 15 s
|
|
688
|
+
console.log(dep.receiptCount, dep.findings?.gaps, dep.findings?.chainBreaks);
|
|
689
|
+
|
|
690
|
+
// DEP JSON, checked against the checksum the export names.
|
|
691
|
+
const file = await api.getDepExportFile({ exportId: dep.exportId, file: 'dep', sha256: dep.sha256! });
|
|
692
|
+
// file.bytes, file.fileName, file.contentType, file.sha256
|
|
693
|
+
|
|
694
|
+
const link = await api.createDepHandoverLink({ exportId: dep.exportId }); // { linkId, url, code, expiresAt }
|
|
695
|
+
await api.revokeDepHandoverLink({ linkId: link.linkId });
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
- **`createDepExport({ from?, to?, requestId? })`** queues the export and
|
|
699
|
+
answers at once with `{ exportId, status: 'running', from, to }`; it runs in
|
|
700
|
+
the background, at most one per cash register at a time (`export_running`,
|
|
701
|
+
`details.exportId` names the running one). `from`/`to` are `YYYY-MM-DD`, both
|
|
702
|
+
inclusive; without them the whole stock is exported. With a `requestId` (at
|
|
703
|
+
most 64 characters of `A-Z a-z 0-9 _ -`) the call is repeatable: the same
|
|
704
|
+
value with the same period returns that export with its current `status`
|
|
705
|
+
(also `done` or `failed`); the same value with another period is rejected
|
|
706
|
+
with `idempotency_conflict`. After a lost answer resend with the **same**
|
|
707
|
+
`requestId` and period (without it you only get a second export).
|
|
708
|
+
- **`getDepExport({ exportId })`** returns `DepExport`: `status`
|
|
709
|
+
(`running|done|failed`), counts, `sha256`/`size` of the DEP file, `findings`
|
|
710
|
+
(`gaps` as ranges of missing receipt numbers, `chainBreaks`, receipts
|
|
711
|
+
`withoutCounter` and `withoutSignature`), `items` (the CSV of item lines),
|
|
712
|
+
`handoverLinks` and, when failed, `error` (`export_failed|export_stalled`).
|
|
713
|
+
- **`waitForDepExport({ exportId, timeoutMs = 600000 })`** polls `getDepExport`
|
|
714
|
+
(first at once, then after 2 s, each wait 1.5 times longer, at most 15 s) and
|
|
715
|
+
returns the finished export. A failed export throws `KasseneckApiError` whose
|
|
716
|
+
`code` is the export's `error` (`export_failed` or `export_stalled`); after
|
|
717
|
+
`timeoutMs` it throws `DepExportTimeoutError` (the export keeps running on
|
|
718
|
+
the server: look it up with `getDepExport`, do not queue a new one). A
|
|
719
|
+
network error while waiting also ends `waitForDepExport` with that error; the
|
|
720
|
+
export keeps running on the server as well, follow it with `getDepExport`.
|
|
721
|
+
- **`getDepExportFile({ exportId, file, sha256?, downloadTimeoutMs? })`** with
|
|
722
|
+
`file` `dep`, `protocol` (PDF), `items` (CSV) or `zip`. Up to 9 MiB the server
|
|
723
|
+
sends the file itself, above it a signed download link (15 minutes); the
|
|
724
|
+
package follows the link, so the result is the same: `{ bytes, fileName, contentType, sha256 }`.
|
|
725
|
+
A file is recognised by `Content-Disposition: attachment`, never by its
|
|
726
|
+
content type (the DEP itself is JSON). `downloadTimeoutMs` (default 600000)
|
|
727
|
+
limits the call itself and the download over a link, each; the general
|
|
728
|
+
`timeoutMs` of the client (30 s) does not apply here, because a direct file
|
|
729
|
+
of up to 9 MiB comes in the answer of the call.
|
|
730
|
+
The SHA-256 is always checked against the sum the server names with a link;
|
|
731
|
+
pass `sha256` (for example `dep.sha256`, `dep.items.sha256`) to check a direct
|
|
732
|
+
file as well. A mismatch throws `DepExportChecksumError`
|
|
733
|
+
(`KasseneckValidationError`, `scope: 'response'`); do not use the bytes.
|
|
734
|
+
- **`createDepHandoverLink` / `revokeDepHandoverLink`:** the link is valid for
|
|
735
|
+
14 days, `url` and the 6-digit `code` (a string, keep leading zeros) come only
|
|
736
|
+
in this answer and are handed over separately.
|
|
737
|
+
- **Errors** (`KasseneckApiError.code`, `DEP_EXPORT_ERROR_CODES`, the list
|
|
738
|
+
`errorCodes.depExport` of the contract): `validation`, `invalid_period`,
|
|
739
|
+
`idempotency_conflict`, `export_running`, `too_many_exports`,
|
|
740
|
+
`export_not_found`, `export_not_ready`, `export_failed`, `invalid_file`,
|
|
741
|
+
`file_not_available`, `too_many_links`, `link_not_found`, `server_error`, plus
|
|
742
|
+
the codes of sign-in and edge; `waitForDepExport` also throws `export_stalled`
|
|
743
|
+
(type `DepExportErrorCode`). Revoking a link twice is no error.
|
|
744
|
+
|
|
676
745
|
## Cancellation (Storno)
|
|
677
746
|
|
|
678
747
|
A cancellation (*Storno*) refers to the original receipt, in full or in part:
|
package/dist/cjs/client/api.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { type HobexPayOptions, type HobexRefundOptions } from '../payments/hobex
|
|
|
4
4
|
import { type TransportOptions } from './transport.js';
|
|
5
5
|
import { type CashregisterReportPeriod, type ReportV2, type ReportV2Options } from './reports.js';
|
|
6
6
|
import { type CashboxStatus, type SignatureStatus } from './status.js';
|
|
7
|
+
import { type CreateDepExportOptions, type CreateDepExportResult, type DepExport, type DepExportFile, type DepHandoverLink, type GetDepExportFileOptions, type RevokedDepHandoverLink, type WaitForDepExportOptions } from './dep-export.js';
|
|
7
8
|
import { type ListedReceipt, type ListReceiptsOptions, type ListReceiptsPage, type ListReceiptsView } from './list-receipts.js';
|
|
8
9
|
import { type SendReceiptEmailOptions, type SendReceiptEmailResult, type LogReceiptOutputsOptions, type LogReceiptOutputsResult, type ListMyReceiptsOptions, type ReceiptList, type ReceiptWithCompany, type SellReceiptOptions, type CancelReceiptOptions, type CancelReceiptResult } from './receipts.js';
|
|
9
10
|
/**
|
|
@@ -61,6 +62,24 @@ export interface KasseneckApi {
|
|
|
61
62
|
listReceipts<V extends ListReceiptsView = 'summary'>(options: ListReceiptsOptions<V>): Promise<ListReceiptsPage<V>>;
|
|
62
63
|
/** Alle Belege eines Tages oder Zeitraums, Seite fuer Seite geholt (hoechstens 100 Seiten). */
|
|
63
64
|
listAllReceipts<V extends ListReceiptsView = 'summary'>(options: ListReceiptsOptions<V>): AsyncGenerator<ListedReceipt<V>, void, undefined>;
|
|
65
|
+
/** DEP-Export fuer die Kassennachschau einstellen (`createDepExport`, nur /v3); antwortet sofort, der Export laeuft im Hintergrund. */
|
|
66
|
+
createDepExport(options?: CreateDepExportOptions): Promise<CreateDepExportResult>;
|
|
67
|
+
/** Zustand, Kennzahlen, Befund und Pruefer-Links eines Exports (`getDepExport`). */
|
|
68
|
+
getDepExport(options: {
|
|
69
|
+
exportId: string;
|
|
70
|
+
}): Promise<DepExport>;
|
|
71
|
+
/** Wartet, bis der Export fertig ist (Abfrage 2 s, x1,5, hoechstens 15 s; Vorgabe 10 Minuten). */
|
|
72
|
+
waitForDepExport(options: WaitForDepExportOptions): Promise<DepExport>;
|
|
73
|
+
/** Eine Datei des Exports (dep, protocol, items, zip) laden und gegen die SHA-256-Summe pruefen. */
|
|
74
|
+
getDepExportFile(options: GetDepExportFileOptions): Promise<DepExportFile>;
|
|
75
|
+
/** Pruefer-Link (Adresse und 6-stelliger Code, 14 Tage) zu einem fertigen Export. */
|
|
76
|
+
createDepHandoverLink(options: {
|
|
77
|
+
exportId: string;
|
|
78
|
+
}): Promise<DepHandoverLink>;
|
|
79
|
+
/** Pruefer-Link der eigenen Kasse widerrufen. */
|
|
80
|
+
revokeDepHandoverLink(options: {
|
|
81
|
+
linkId: string;
|
|
82
|
+
}): Promise<RevokedDepHandoverLink>;
|
|
64
83
|
/** Kassenbericht als PDF (v2): abgeschlossener Monat, Tag oder Zeitraum (Endpunkt `getCashregisterReport`). */
|
|
65
84
|
getCashregisterReport(options: CashregisterReportPeriod): Promise<Uint8Array>;
|
|
66
85
|
/** @deprecated Since 1.10.0: use getCashregisterReport. Tagesbericht als PDF (Kalendertag nach Wiener Zeit). */
|
package/dist/cjs/client/api.js
CHANGED
|
@@ -6,6 +6,7 @@ const hobex_js_1 = require("../payments/hobex.js");
|
|
|
6
6
|
const transport_js_1 = require("./transport.js");
|
|
7
7
|
const reports_js_1 = require("./reports.js");
|
|
8
8
|
const status_js_1 = require("./status.js");
|
|
9
|
+
const dep_export_js_1 = require("./dep-export.js");
|
|
9
10
|
const list_receipts_js_1 = require("./list-receipts.js");
|
|
10
11
|
const receipts_js_1 = require("./receipts.js");
|
|
11
12
|
const cashregisters_js_1 = require("./cashregisters.js");
|
|
@@ -15,6 +16,17 @@ function createKasseneckApi(options) {
|
|
|
15
16
|
// Zweiter Einstiegspunkt fuer die PDF-Downloads; dieselben Optionen,
|
|
16
17
|
// dieselbe Anmeldung — nur die Antwort wird als Bytes gelesen.
|
|
17
18
|
const rufenBinaer = (0, transport_js_1.createBinaryTransport)(options);
|
|
19
|
+
// Fuer Dateien beliebiger Art (DEP-Export): Datei oder Lese-Link.
|
|
20
|
+
const rufenDatei = (0, transport_js_1.createFileOrDataTransport)(options);
|
|
21
|
+
// Das globale fetch erst beim Folgen eines Lese-Links holen: ohne Link braucht es niemand.
|
|
22
|
+
const holen = (url, init) => {
|
|
23
|
+
if (options.fetch)
|
|
24
|
+
return options.fetch(url, init);
|
|
25
|
+
const umgebung = globalThis;
|
|
26
|
+
if (typeof umgebung.fetch !== 'function')
|
|
27
|
+
throw new Error('getDepExportFile: kein globales fetch vorhanden');
|
|
28
|
+
return umgebung.fetch(url, init);
|
|
29
|
+
};
|
|
18
30
|
return {
|
|
19
31
|
sellReceipt: (o) => (0, receipts_js_1.sellReceipt)(rufen, o),
|
|
20
32
|
sellReceiptWithCompany: (o) => (0, receipts_js_1.sellReceiptWithCompany)(rufen, o),
|
|
@@ -31,6 +43,12 @@ function createKasseneckApi(options) {
|
|
|
31
43
|
getReportV2: (o) => (0, reports_js_1.getReportV2)(rufen, o),
|
|
32
44
|
listReceipts: (o) => (0, list_receipts_js_1.listReceipts)(rufen, o),
|
|
33
45
|
listAllReceipts: (o) => (0, list_receipts_js_1.listAllReceipts)(rufen, o),
|
|
46
|
+
createDepExport: (o) => (0, dep_export_js_1.createDepExport)(rufen, o),
|
|
47
|
+
getDepExport: (o) => (0, dep_export_js_1.getDepExport)(rufen, o),
|
|
48
|
+
waitForDepExport: (o) => (0, dep_export_js_1.waitForDepExport)(rufen, o),
|
|
49
|
+
getDepExportFile: (o) => (0, dep_export_js_1.getDepExportFile)(rufenDatei, holen, o),
|
|
50
|
+
createDepHandoverLink: (o) => (0, dep_export_js_1.createDepHandoverLink)(rufen, o),
|
|
51
|
+
revokeDepHandoverLink: (o) => (0, dep_export_js_1.revokeDepHandoverLink)(rufen, o),
|
|
34
52
|
getCashregisterReport: (options) => (0, reports_js_1.getCashregisterReport)(rufenBinaer, options),
|
|
35
53
|
downloadDailyReport: (date) => (0, reports_js_1.downloadDailyReport)(rufenBinaer, date),
|
|
36
54
|
downloadMonthlyReport: (reportMonth) => (0, reports_js_1.downloadMonthlyReport)(rufenBinaer, reportMonth),
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* weiterhin jeden `string`: wer einen Aufruf braucht, den dieses Paket nicht
|
|
13
13
|
* umhuellt, muss ihn weiterhin absetzen koennen.
|
|
14
14
|
*/
|
|
15
|
-
import type { PdfOrData, TransportBodyFields, TransportCallOptions } from './transport.js';
|
|
16
|
-
export declare const ALL_CALLS: readonly ["activateCashregister", "cancelInvoice", "cancelReceipt", "createCreditNote", "createCustomer", "createCustomerCashregister", "createPartnerCustomer", "checkPartnerCustomerEmail", "createPartnerWebhook", "createPaymentLinkStripe", "createPrintJob", "createReceipt", "deletePartnerWebhook", "downloadDailyReport", "downloadReport", "endRegisterSession", "financeWebService", "generateFullReceiptId", "getCashregisterReport", "getCustomer", "getCustomerCredentials", "getCustomerSignatureStatus", "getFirstReceiptDate", "getInvoice", "getInvoicePdf", "getInvoiceSetupStatus", "getInvoiceXml", "getKasseSettings", "getPartnerCustomer", "getPartnerInfo", "getPrintJob", "getReceipt", "getReportV2", "hobexPayApi", "hobexRefundApi", "issueInvoice", "listCustomerCashregisters", "listInvoices", "listBrands", "listMyArticleGroups", "listMyArticles", "listMyCashregisters", "listMyPrinters", "listMyReceipts", "listMyStock", "listMyStockLocations", "listMyTipRecipients", "listPartnerCustomers", "listPartnerWebhookDeliveries", "listPartnerWebhooks", "listReceipts", "listRegisterUsersForDevice", "listRegisterSessionsForDevice", "pairRegisterDevice", "recordInvoicePayment", "registerPinLogin", "registerUserLogin", "renewRegisterSession", "reportCustomerContract", "requestCustomerSignature", "searchCustomers", "sendPartnerCustomerFonLink", "sendPartnerWebhookTest", "sendReceiptEmail", "setMyCashregisterStockLocation", "setMyKasseLogo", "setMyKasseSettings", "setMyRegisterDeviceSettings", "stripeCaptureIntent", "unpairRegisterDevice", "rotatePartnerWebhookSecret", "updateCustomer", "updatePartnerWebhook", "getArticle", "listArticles", "lookupArticleByCode", "listLocations", "getStock", "listStock", "listStockMovements", "createWebhook", "updateWebhook", "deleteWebhook", "listWebhooks", "sendWebhookTest", "rotateWebhookSecret", "listWebhookDeliveries", "createArticle", "updateArticle", "deactivateArticle", "receiveGoods", "transferStock", "recordStockLoss", "changeStockCondition", "reverseStockMovement", "createReservation", "extendReservation", "releaseReservation", "getReservation", "listReservations", "createVariantGroup", "updateVariantGroup", "getVariantGroup", "listVariantGroups", "addVariant", "createStocktake", "listStocktakes", "getStocktake", "listStocktakeItems", "recordStocktakeCount", "voidStocktakeCount", "listStocktakeCounts", "reviewStocktake", "recountStocktake", "closeStocktake", "cancelStocktake", "getStocktakePdf", "orderSignatureCard", "getSignatureCardOrder", "listMyStocktakes", "listMyStocktakeItems", "listMyStocktakeCounts", "recordMyStocktakeCount", "voidMyStocktakeCount", "checkVoucher", "reprintVoucherLabel", "getMyDrawerState", "openMyShift", "recordMyCashMovement", "logMyDrawerOpenings", "getMyShiftReport", "closeMyShift", "logReceiptOutputs"];
|
|
15
|
+
import type { FileOrData, FileOrDataCallOptions, PdfOrData, TransportBodyFields, TransportCallOptions } from './transport.js';
|
|
16
|
+
export declare const ALL_CALLS: readonly ["activateCashregister", "cancelInvoice", "cancelReceipt", "createCreditNote", "createCustomer", "createCustomerCashregister", "createDepExport", "createDepHandoverLink", "createPartnerCustomer", "checkPartnerCustomerEmail", "createPartnerWebhook", "createPaymentLinkStripe", "createPrintJob", "createReceipt", "deletePartnerWebhook", "downloadDailyReport", "downloadReport", "endRegisterSession", "financeWebService", "generateFullReceiptId", "getCashregisterReport", "getCustomer", "getCustomerCredentials", "getCustomerSignatureStatus", "getDepExport", "getDepExportFile", "getFirstReceiptDate", "getInvoice", "getInvoicePdf", "getInvoiceSetupStatus", "getInvoiceXml", "getKasseSettings", "getPartnerCustomer", "getPartnerInfo", "getPrintJob", "getReceipt", "getReportV2", "hobexPayApi", "hobexRefundApi", "issueInvoice", "listCustomerCashregisters", "listInvoices", "listBrands", "listMyArticleGroups", "listMyArticles", "listMyCashregisters", "listMyPrinters", "listMyReceipts", "listMyStock", "listMyStockLocations", "listMyTipRecipients", "listPartnerCustomers", "listPartnerWebhookDeliveries", "listPartnerWebhooks", "listReceipts", "listRegisterUsersForDevice", "listRegisterSessionsForDevice", "pairRegisterDevice", "recordInvoicePayment", "registerPinLogin", "registerUserLogin", "renewRegisterSession", "reportCustomerContract", "requestCustomerSignature", "revokeDepHandoverLink", "searchCustomers", "sendPartnerCustomerFonLink", "sendPartnerWebhookTest", "sendReceiptEmail", "setMyCashregisterStockLocation", "setMyKasseLogo", "setMyKasseSettings", "setMyRegisterDeviceSettings", "stripeCaptureIntent", "unpairRegisterDevice", "rotatePartnerWebhookSecret", "updateCustomer", "updatePartnerWebhook", "getArticle", "listArticles", "lookupArticleByCode", "listLocations", "getStock", "listStock", "listStockMovements", "createWebhook", "updateWebhook", "deleteWebhook", "listWebhooks", "sendWebhookTest", "rotateWebhookSecret", "listWebhookDeliveries", "createArticle", "updateArticle", "deactivateArticle", "receiveGoods", "transferStock", "recordStockLoss", "changeStockCondition", "reverseStockMovement", "createReservation", "extendReservation", "releaseReservation", "getReservation", "listReservations", "createVariantGroup", "updateVariantGroup", "getVariantGroup", "listVariantGroups", "addVariant", "createStocktake", "listStocktakes", "getStocktake", "listStocktakeItems", "recordStocktakeCount", "voidStocktakeCount", "listStocktakeCounts", "reviewStocktake", "recountStocktake", "closeStocktake", "cancelStocktake", "getStocktakePdf", "orderSignatureCard", "getSignatureCardOrder", "listMyStocktakes", "listMyStocktakeItems", "listMyStocktakeCounts", "recordMyStocktakeCount", "voidMyStocktakeCount", "checkVoucher", "reprintVoucherLabel", "getMyDrawerState", "openMyShift", "recordMyCashMovement", "logMyDrawerOpenings", "getMyShiftReport", "closeMyShift", "logReceiptOutputs"];
|
|
17
17
|
export type ApiCall = typeof ALL_CALLS[number];
|
|
18
18
|
/**
|
|
19
19
|
* Die oeffentlichen Endpunkte unter `/v3` (`https://api.kasseneck.at/v3/<name>`),
|
|
@@ -21,7 +21,7 @@ export type ApiCall = typeof ALL_CALLS[number];
|
|
|
21
21
|
* (`fixtures/v3/v3-vokabular.json`, `endpoints.public`, umbenannt nach
|
|
22
22
|
* `names`). Ein Test haelt beide Listen deckungsgleich.
|
|
23
23
|
*/
|
|
24
|
-
export declare const PUBLIC_CALLS: readonly ["createReceipt", "getReceipt", "cancelReceipt", "sendReceiptEmail", "generateFullReceiptId", "downloadReceipt", "getFirstReceiptDate", "getReportV2", "downloadReport", "downloadDailyReport", "getCashregisterReport", "createPaymentLinkStripe", "stripeCaptureIntent", "hobexPayApi", "hobexRefundApi", "hobexGetStatus", "financeWebService", "listMyTipRecipients", "getPartnerInfo", "createPartnerCustomer", "checkPartnerCustomerEmail", "listPartnerCustomers", "getPartnerCustomer", "sendPartnerCustomerFonLink", "createPartnerWebhook", "updatePartnerWebhook", "deletePartnerWebhook", "listPartnerWebhooks", "sendPartnerWebhookTest", "rotatePartnerWebhookSecret", "listPartnerWebhookDeliveries", "requestCustomerSignature", "getCustomerSignatureStatus", "createCustomerCashregister", "activateCashregister", "listCustomerCashregisters", "getCustomerCredentials", "reportCustomerContract", "getPartnerBilling", "getPartnerBillingMonth", "createCustomer", "getCustomer", "updateCustomer", "searchCustomers", "issueInvoice", "cancelInvoice", "createCreditNote", "getInvoice", "listInvoices", "getInvoicePdf", "getInvoiceXml", "getInvoiceSetupStatus", "listBrands", "recordInvoicePayment", "createInvoiceItem", "updateInvoiceItem", "withdrawInvoiceItem", "getInvoiceItem", "listInvoiceItems", "setCustomerMandate", "revokeCustomerMandate", "getArticle", "listArticles", "lookupArticleByCode", "listLocations", "getStock", "listStock", "listStockMovements", "createWebhook", "updateWebhook", "deleteWebhook", "listWebhooks", "sendWebhookTest", "rotateWebhookSecret", "listWebhookDeliveries", "createArticle", "updateArticle", "deactivateArticle", "receiveGoods", "transferStock", "recordStockLoss", "changeStockCondition", "reverseStockMovement", "createReservation", "extendReservation", "releaseReservation", "getReservation", "listReservations", "createVariantGroup", "updateVariantGroup", "getVariantGroup", "listVariantGroups", "addVariant", "createStocktake", "listStocktakes", "getStocktake", "listStocktakeItems", "recordStocktakeCount", "voidStocktakeCount", "listStocktakeCounts", "reviewStocktake", "recountStocktake", "closeStocktake", "cancelStocktake", "getStocktakePdf", "orderSignatureCard", "getSignatureCardOrder", "listReceipts"];
|
|
24
|
+
export declare const PUBLIC_CALLS: readonly ["createReceipt", "getReceipt", "cancelReceipt", "sendReceiptEmail", "generateFullReceiptId", "downloadReceipt", "getFirstReceiptDate", "getReportV2", "downloadReport", "downloadDailyReport", "getCashregisterReport", "createPaymentLinkStripe", "stripeCaptureIntent", "hobexPayApi", "hobexRefundApi", "hobexGetStatus", "financeWebService", "listMyTipRecipients", "getPartnerInfo", "createPartnerCustomer", "checkPartnerCustomerEmail", "listPartnerCustomers", "getPartnerCustomer", "sendPartnerCustomerFonLink", "createPartnerWebhook", "updatePartnerWebhook", "deletePartnerWebhook", "listPartnerWebhooks", "sendPartnerWebhookTest", "rotatePartnerWebhookSecret", "listPartnerWebhookDeliveries", "requestCustomerSignature", "getCustomerSignatureStatus", "createCustomerCashregister", "activateCashregister", "listCustomerCashregisters", "getCustomerCredentials", "reportCustomerContract", "getPartnerBilling", "getPartnerBillingMonth", "createCustomer", "getCustomer", "updateCustomer", "searchCustomers", "issueInvoice", "cancelInvoice", "createCreditNote", "getInvoice", "listInvoices", "getInvoicePdf", "getInvoiceXml", "getInvoiceSetupStatus", "listBrands", "recordInvoicePayment", "createInvoiceItem", "updateInvoiceItem", "withdrawInvoiceItem", "getInvoiceItem", "listInvoiceItems", "setCustomerMandate", "revokeCustomerMandate", "getArticle", "listArticles", "lookupArticleByCode", "listLocations", "getStock", "listStock", "listStockMovements", "createWebhook", "updateWebhook", "deleteWebhook", "listWebhooks", "sendWebhookTest", "rotateWebhookSecret", "listWebhookDeliveries", "createArticle", "updateArticle", "deactivateArticle", "receiveGoods", "transferStock", "recordStockLoss", "changeStockCondition", "reverseStockMovement", "createReservation", "extendReservation", "releaseReservation", "getReservation", "listReservations", "createVariantGroup", "updateVariantGroup", "getVariantGroup", "listVariantGroups", "addVariant", "createStocktake", "listStocktakes", "getStocktake", "listStocktakeItems", "recordStocktakeCount", "voidStocktakeCount", "listStocktakeCounts", "reviewStocktake", "recountStocktake", "closeStocktake", "cancelStocktake", "getStocktakePdf", "orderSignatureCard", "getSignatureCardOrder", "listReceipts", "createDepExport", "getDepExport", "getDepExportFile", "createDepHandoverLink", "revokeDepHandoverLink"];
|
|
25
25
|
/**
|
|
26
26
|
* Die Endpunkte des Kassenwegs (`https://kasse.kasseneck.at/api/v3/<name>`,
|
|
27
27
|
* Web-Kasse: gleicher Ursprung `/api/v3`), in der Reihenfolge von
|
|
@@ -99,3 +99,5 @@ export type InternerTransport = <T = unknown>(functionName: ApiCall, params?: Re
|
|
|
99
99
|
export type InternerBinaerTransport = (functionName: ApiCall, params?: Record<string, unknown>) => Promise<Uint8Array>;
|
|
100
100
|
/** Wie `createPdfOrDataTransport` (transport.ts), nur mit bekanntem Aufrufnamen. */
|
|
101
101
|
export type InternerPdfOderDatenTransport = (functionName: ApiCall, params?: Record<string, unknown>) => Promise<PdfOrData>;
|
|
102
|
+
/** Wie `createFileOrDataTransport` (transport.ts), nur mit bekanntem Aufrufnamen. */
|
|
103
|
+
export type InternerDateiOderDatenTransport = (functionName: ApiCall, params?: Record<string, unknown>, options?: FileOrDataCallOptions) => Promise<FileOrData>;
|
|
@@ -11,6 +11,8 @@ exports.ALL_CALLS = [
|
|
|
11
11
|
'createCreditNote',
|
|
12
12
|
'createCustomer',
|
|
13
13
|
'createCustomerCashregister',
|
|
14
|
+
'createDepExport',
|
|
15
|
+
'createDepHandoverLink',
|
|
14
16
|
'createPartnerCustomer',
|
|
15
17
|
'checkPartnerCustomerEmail',
|
|
16
18
|
'createPartnerWebhook',
|
|
@@ -27,6 +29,8 @@ exports.ALL_CALLS = [
|
|
|
27
29
|
'getCustomer',
|
|
28
30
|
'getCustomerCredentials',
|
|
29
31
|
'getCustomerSignatureStatus',
|
|
32
|
+
'getDepExport',
|
|
33
|
+
'getDepExportFile',
|
|
30
34
|
'getFirstReceiptDate',
|
|
31
35
|
'getInvoice',
|
|
32
36
|
'getInvoicePdf',
|
|
@@ -65,6 +69,7 @@ exports.ALL_CALLS = [
|
|
|
65
69
|
'renewRegisterSession',
|
|
66
70
|
'reportCustomerContract',
|
|
67
71
|
'requestCustomerSignature',
|
|
72
|
+
'revokeDepHandoverLink',
|
|
68
73
|
'searchCustomers',
|
|
69
74
|
'sendPartnerCustomerFonLink',
|
|
70
75
|
'sendPartnerWebhookTest',
|
|
@@ -271,6 +276,12 @@ exports.PUBLIC_CALLS = [
|
|
|
271
276
|
'getSignatureCardOrder',
|
|
272
277
|
// Belege einer Kasse auflisten, nur unter /v3 (Nachfolger von getReportV2 fuer Listen).
|
|
273
278
|
'listReceipts',
|
|
279
|
+
// DEP-Export fuer die Kassennachschau (Kassen-Token), nur unter /v3.
|
|
280
|
+
'createDepExport',
|
|
281
|
+
'getDepExport',
|
|
282
|
+
'getDepExportFile',
|
|
283
|
+
'createDepHandoverLink',
|
|
284
|
+
'revokeDepHandoverLink',
|
|
274
285
|
];
|
|
275
286
|
/**
|
|
276
287
|
* Die Endpunkte des Kassenwegs (`https://kasse.kasseneck.at/api/v3/<name>`,
|
|
@@ -455,6 +466,15 @@ exports.CALLS_WITHOUT_EFFECT = Object.freeze({
|
|
|
455
466
|
getCustomer: 'read',
|
|
456
467
|
getCustomerCredentials: 'read',
|
|
457
468
|
getCustomerSignatureStatus: 'read',
|
|
469
|
+
// DEP-Export: ein verlorener Ausgang ist harmlos wiederholbar. createDepExport ist mit requestId idempotent, ohne nur
|
|
470
|
+
// doppelt (Grenze 20 je Tag, keine Buchung). createDepHandoverLink erzeugt bei Wiederholung einen zweiten Link (der
|
|
471
|
+
// alte steht in getDepExport().handoverLinks und ist widerrufbar; Preis hoechstens too_many_links). revokeDepHandoverLink
|
|
472
|
+
// ist idempotent.
|
|
473
|
+
createDepExport: 'repeatable',
|
|
474
|
+
createDepHandoverLink: 'repeatable',
|
|
475
|
+
revokeDepHandoverLink: 'repeatable',
|
|
476
|
+
getDepExport: 'read',
|
|
477
|
+
getDepExportFile: 'read',
|
|
458
478
|
getFirstReceiptDate: 'read',
|
|
459
479
|
getInvoice: 'read',
|
|
460
480
|
getInvoiceItem: 'read',
|
|
@@ -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>;
|