ksef-client-ts 0.9.1 → 0.10.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.
@@ -0,0 +1,316 @@
1
+ interface OperationResponse {
2
+ referenceNumber: string;
3
+ }
4
+ interface OperationStatusInfo {
5
+ code: number;
6
+ description: string;
7
+ details?: string[] | null;
8
+ }
9
+ interface TokenInfo {
10
+ token: string;
11
+ validUntil: string;
12
+ }
13
+ interface FormCode {
14
+ systemCode: string;
15
+ schemaVersion: string;
16
+ value: string;
17
+ }
18
+ interface EncryptionInfo {
19
+ encryptedSymmetricKey: string;
20
+ initializationVector: string;
21
+ /** Identifier of the public key used to encrypt the symmetric key — key-rotation selector (KSeF API v2.5.0). */
22
+ publicKeyId?: string;
23
+ }
24
+ interface FileMetadata {
25
+ hashSHA: string;
26
+ fileSize: number;
27
+ }
28
+ type ContextIdentifierType = 'Nip' | 'InternalId' | 'NipVatUe' | 'PeppolId';
29
+ interface ContextIdentifier {
30
+ type: ContextIdentifierType;
31
+ value: string;
32
+ }
33
+ /** Archive compression for batch upload / invoice export packages (KSeF API v2.6.0). Defaults to `Zip`. */
34
+ type CompressionType = 'Zip' | 'TarGz';
35
+ type SessionType = 'Online' | 'Batch';
36
+ type SessionStatus = 'Succeeded' | 'InProgress' | 'Failed' | 'Cancelled';
37
+ type SortOrder = 'Asc' | 'Desc';
38
+ type InvoicingMode = 'Online' | 'Offline';
39
+ type PermissionSubjectIdentifierType = 'Nip' | 'Pesel' | 'Fingerprint';
40
+
41
+ /**
42
+ * Invoice subject type — defines the taxpayer's role in the invoice.
43
+ * - `Subject1` — seller (invoices issued by us)
44
+ * - `Subject2` — buyer (invoices received by us)
45
+ * - `Subject3` — third party (e.g. intermediary)
46
+ * - `SubjectAuthorized` — authorized subject acting on behalf of seller/buyer
47
+ */
48
+ type InvoiceSubjectType = 'Subject1' | 'Subject2' | 'Subject3' | 'SubjectAuthorized';
49
+ type InvoiceQueryDateType = 'Issue' | 'Invoicing' | 'PermanentStorage';
50
+ type AmountType = 'Brutto' | 'Netto' | 'Vat';
51
+ type BuyerIdentifierType = 'Nip' | 'VatUe' | 'Other' | 'None';
52
+ type ThirdSubjectIdentifierType = 'Nip' | 'InternalId' | 'VatUe' | 'Other' | 'None';
53
+ type FormType = 'FA' | 'PEF' | 'FA_RR';
54
+ type InvoiceType = 'Vat' | 'Zal' | 'Kor' | 'Roz' | 'Upr' | 'KorZal' | 'KorRoz' | 'VatPef' | 'VatPefSp' | 'KorPef' | 'VatRr' | 'KorVatRr';
55
+ interface InvoiceQueryDateRange {
56
+ dateType: InvoiceQueryDateType;
57
+ from: string;
58
+ to?: string;
59
+ restrictToPermanentStorageHwmDate?: boolean;
60
+ }
61
+ interface InvoiceQueryAmount {
62
+ type: AmountType;
63
+ from?: number;
64
+ to?: number;
65
+ }
66
+ interface InvoiceQueryBuyerIdentifier {
67
+ type: BuyerIdentifierType;
68
+ value?: string;
69
+ }
70
+ interface InvoiceQueryFilters {
71
+ subjectType: InvoiceSubjectType;
72
+ dateRange: InvoiceQueryDateRange;
73
+ ksefNumber?: string;
74
+ invoiceNumber?: string;
75
+ amount?: InvoiceQueryAmount;
76
+ sellerNip?: string;
77
+ buyerIdentifier?: InvoiceQueryBuyerIdentifier;
78
+ currencyCodes?: string[];
79
+ invoicingMode?: InvoicingMode;
80
+ isSelfInvoicing?: boolean;
81
+ formType?: FormType;
82
+ invoiceTypes?: InvoiceType[];
83
+ hasAttachment?: boolean;
84
+ }
85
+ interface InvoiceMetadataSeller {
86
+ nip: string;
87
+ name?: string;
88
+ }
89
+ interface InvoiceMetadataBuyerIdentifier {
90
+ type: BuyerIdentifierType;
91
+ value?: string;
92
+ }
93
+ interface InvoiceMetadataBuyer {
94
+ identifier: InvoiceMetadataBuyerIdentifier;
95
+ name?: string;
96
+ }
97
+ interface InvoiceMetadataThirdSubjectIdentifier {
98
+ type: ThirdSubjectIdentifierType;
99
+ value?: string | null;
100
+ }
101
+ interface InvoiceMetadataThirdSubject {
102
+ identifier: InvoiceMetadataThirdSubjectIdentifier;
103
+ name?: string | null;
104
+ role: number;
105
+ }
106
+ interface InvoiceMetadataAuthorizedSubject {
107
+ nip: string;
108
+ name?: string;
109
+ role: number;
110
+ }
111
+ interface InvoiceMetadata {
112
+ ksefNumber: string;
113
+ invoiceNumber: string;
114
+ issueDate: string;
115
+ invoicingDate: string;
116
+ acquisitionDate: string;
117
+ permanentStorageDate: string;
118
+ seller: InvoiceMetadataSeller;
119
+ buyer: InvoiceMetadataBuyer;
120
+ netAmount: number;
121
+ grossAmount: number;
122
+ vatAmount: number;
123
+ currency: string;
124
+ invoicingMode: InvoicingMode;
125
+ invoiceType: InvoiceType;
126
+ formCode: FormCode;
127
+ isSelfInvoicing: boolean;
128
+ hasAttachment: boolean;
129
+ invoiceHash: string;
130
+ hashOfCorrectedInvoice?: string;
131
+ thirdSubjects?: InvoiceMetadataThirdSubject[];
132
+ authorizedSubject?: InvoiceMetadataAuthorizedSubject;
133
+ }
134
+ interface QueryInvoicesMetadataResponse {
135
+ hasMore: boolean;
136
+ isTruncated: boolean;
137
+ invoices: InvoiceMetadata[];
138
+ permanentStorageHwmDate?: string;
139
+ }
140
+ interface InvoiceResult {
141
+ xml: string;
142
+ /** SHA-256 base64 hash from the `x-ms-meta-hash` response header, if present. */
143
+ hash?: string;
144
+ }
145
+ interface InvoiceExportRequest {
146
+ encryption: EncryptionInfo;
147
+ filters: InvoiceQueryFilters;
148
+ onlyMetadata?: boolean;
149
+ /** Archive compression type for the export package (KSeF API v2.6.0). Omitted/`Zip` keeps the legacy behavior. */
150
+ compressionType?: CompressionType;
151
+ }
152
+ interface InvoiceExportPackagePart {
153
+ ordinalNumber: number;
154
+ partName: string;
155
+ method: string;
156
+ url: string;
157
+ partSize: number;
158
+ partHash: string;
159
+ encryptedPartSize: number;
160
+ encryptedPartHash: string;
161
+ expirationDate: string;
162
+ }
163
+ interface InvoiceExportPackage {
164
+ invoiceCount: number;
165
+ size: number;
166
+ parts: InvoiceExportPackagePart[];
167
+ isTruncated: boolean;
168
+ lastIssueDate?: string;
169
+ lastInvoicingDate?: string;
170
+ lastPermanentStorageDate?: string;
171
+ permanentStorageHwmDate?: string;
172
+ }
173
+ interface InvoiceExportStatusResponse {
174
+ status: OperationStatusInfo;
175
+ completedDate?: string;
176
+ packageExpirationDate?: string;
177
+ package?: InvoiceExportPackage;
178
+ }
179
+
180
+ interface OfflineInvoiceFilter {
181
+ status?: OfflineInvoiceStatus | OfflineInvoiceStatus[];
182
+ mode?: OfflineMode;
183
+ expiringBefore?: Date | string;
184
+ sellerNip?: string;
185
+ }
186
+ type OfflineInvoiceUpdates = Omit<Partial<OfflineInvoiceMetadata>, 'id'>;
187
+ interface OfflineInvoiceStorage {
188
+ save(invoice: OfflineInvoiceMetadata): Promise<void>;
189
+ get(id: string): Promise<OfflineInvoiceMetadata | null>;
190
+ list(filter?: OfflineInvoiceFilter): Promise<OfflineInvoiceMetadata[]>;
191
+ update(id: string, updates: OfflineInvoiceUpdates): Promise<void>;
192
+ delete(id: string): Promise<void>;
193
+ }
194
+ declare class InMemoryOfflineInvoiceStorage implements OfflineInvoiceStorage {
195
+ private readonly store;
196
+ save(invoice: OfflineInvoiceMetadata): Promise<void>;
197
+ get(id: string): Promise<OfflineInvoiceMetadata | null>;
198
+ list(filter?: OfflineInvoiceFilter): Promise<OfflineInvoiceMetadata[]>;
199
+ update(id: string, updates: OfflineInvoiceUpdates): Promise<void>;
200
+ delete(id: string): Promise<void>;
201
+ }
202
+
203
+ /** Offline invoice modes per KSeF docs (art. 106nda/106nh/106nf) */
204
+ type OfflineMode = 'offline24' | 'offline' | 'awaryjny' | 'awaria_calkowita';
205
+ /** Why this invoice was issued offline */
206
+ type OfflineReason = 'PLANNED' | 'SYSTEM_UNAVAILABLE' | 'EMERGENCY' | 'TOTAL_FAILURE';
207
+ /**
208
+ * Offline invoice lifecycle state machine:
209
+ * GENERATED → QUEUED → SUBMITTED → ACCEPTED | REJECTED
210
+ * Any non-terminal → EXPIRED
211
+ */
212
+ type OfflineInvoiceStatus = 'GENERATED' | 'QUEUED' | 'SUBMITTED' | 'ACCEPTED' | 'REJECTED' | 'CORRECTED' | 'EXPIRED';
213
+ interface OfflineInvoiceInputData {
214
+ invoiceNumber: string;
215
+ invoiceDate: string;
216
+ invoiceXml: string;
217
+ sellerNip: string;
218
+ sellerIdentifier: ContextIdentifier;
219
+ buyerIdentifier?: ContextIdentifier;
220
+ totalAmount?: number;
221
+ currency?: string;
222
+ }
223
+ interface OfflineCertificate {
224
+ privateKeyPem: string;
225
+ certificateSerial: string;
226
+ password?: string;
227
+ }
228
+ interface MaintenanceWindow {
229
+ id: string;
230
+ startTime: string;
231
+ endTime?: string;
232
+ active: boolean;
233
+ planned: boolean;
234
+ reason?: string;
235
+ }
236
+ interface OfflineInvoiceMetadata {
237
+ id: string;
238
+ mode: OfflineMode;
239
+ reason: OfflineReason;
240
+ status: OfflineInvoiceStatus;
241
+ invoiceNumber: string;
242
+ invoiceDate: string;
243
+ invoiceXml: string;
244
+ sellerNip: string;
245
+ sellerIdentifier: ContextIdentifier;
246
+ buyerIdentifier?: ContextIdentifier;
247
+ totalAmount?: number;
248
+ currency?: string;
249
+ kod1Url: string;
250
+ kod2Url?: string;
251
+ generatedAt: string;
252
+ submitBy: string;
253
+ submittedAt?: string;
254
+ acceptedAt?: string;
255
+ ksefReferenceNumber?: string;
256
+ error?: {
257
+ code: number;
258
+ message: string;
259
+ details?: string[];
260
+ };
261
+ maintenanceWindowId?: string;
262
+ correctedInvoiceId?: string;
263
+ correctedBy?: string;
264
+ }
265
+ interface OfflineInvoiceOptions {
266
+ mode?: OfflineMode;
267
+ certificate?: OfflineCertificate;
268
+ maintenanceWindow?: MaintenanceWindow;
269
+ customDeadline?: Date | string;
270
+ storage?: OfflineInvoiceStorage;
271
+ }
272
+ interface OfflineBatchResult {
273
+ total: number;
274
+ submitted: number;
275
+ accepted: number;
276
+ rejected: number;
277
+ failed: number;
278
+ expired: number;
279
+ results: OfflineSubmissionResult[];
280
+ }
281
+ interface OfflineSubmissionResult {
282
+ invoiceId: string;
283
+ invoiceNumber: string;
284
+ status: OfflineInvoiceStatus;
285
+ ksefReferenceNumber?: string;
286
+ error?: {
287
+ code: number;
288
+ message: string;
289
+ details?: string[];
290
+ };
291
+ }
292
+
293
+ type ContinuationPoints = Record<string, string | undefined>;
294
+ declare function updateContinuationPoint(points: ContinuationPoints, subjectType: string, pkg: Pick<InvoiceExportPackage, 'isTruncated' | 'lastPermanentStorageDate' | 'permanentStorageHwmDate'>): void;
295
+ declare function getEffectiveStartDate(points: ContinuationPoints, subjectType: string, windowFrom: string): string;
296
+ declare function deduplicateByKsefNumber<T extends {
297
+ ksefNumber: string;
298
+ }>(entries: T[]): T[];
299
+
300
+ interface HwmStore {
301
+ load(): Promise<ContinuationPoints>;
302
+ save(points: ContinuationPoints): Promise<void>;
303
+ }
304
+ declare class InMemoryHwmStore implements HwmStore {
305
+ private points;
306
+ load(): Promise<ContinuationPoints>;
307
+ save(points: ContinuationPoints): Promise<void>;
308
+ }
309
+ declare class FileHwmStore implements HwmStore {
310
+ private readonly filePath;
311
+ constructor(filePath: string);
312
+ load(): Promise<ContinuationPoints>;
313
+ save(points: ContinuationPoints): Promise<void>;
314
+ }
315
+
316
+ export { type OfflineInvoiceUpdates as $, type AmountType as A, type BuyerIdentifierType as B, type ContextIdentifier as C, InMemoryOfflineInvoiceStorage as D, type EncryptionInfo as E, type FormCode as F, type InvoiceExportPackage as G, type HwmStore as H, type InvoicingMode as I, type InvoiceExportPackagePart as J, type InvoiceMetadataAuthorizedSubject as K, type InvoiceMetadataBuyer as L, type MaintenanceWindow as M, type InvoiceMetadataBuyerIdentifier as N, type OperationStatusInfo as O, type PermissionSubjectIdentifierType as P, type QueryInvoicesMetadataResponse as Q, type InvoiceMetadataSeller as R, type SessionStatus as S, type TokenInfo as T, type InvoiceMetadataThirdSubject as U, type InvoiceMetadataThirdSubjectIdentifier as V, type InvoiceQueryAmount as W, type InvoiceQueryBuyerIdentifier as X, type InvoiceQueryDateRange as Y, type OfflineInvoiceFilter as Z, type OfflineInvoiceStatus as _, type CompressionType as a, type ThirdSubjectIdentifierType as a0, deduplicateByKsefNumber as a1, getEffectiveStartDate as a2, updateContinuationPoint as a3, FileHwmStore as a4, type FileMetadata as b, type InvoiceType as c, type SessionType as d, type InvoiceResult as e, type InvoiceQueryFilters as f, type SortOrder as g, type InvoiceExportRequest as h, type OperationResponse as i, type InvoiceExportStatusResponse as j, type InvoiceSubjectType as k, type InvoiceQueryDateType as l, type FormType as m, type OfflineInvoiceInputData as n, type OfflineInvoiceOptions as o, type OfflineInvoiceMetadata as p, type OfflineInvoiceStorage as q, type OfflineBatchResult as r, type OfflineCertificate as s, type OfflineSubmissionResult as t, type ContinuationPoints as u, type InvoiceMetadata as v, type OfflineMode as w, type OfflineReason as x, type ContextIdentifierType as y, InMemoryHwmStore as z };
@@ -0,0 +1,316 @@
1
+ interface OperationResponse {
2
+ referenceNumber: string;
3
+ }
4
+ interface OperationStatusInfo {
5
+ code: number;
6
+ description: string;
7
+ details?: string[] | null;
8
+ }
9
+ interface TokenInfo {
10
+ token: string;
11
+ validUntil: string;
12
+ }
13
+ interface FormCode {
14
+ systemCode: string;
15
+ schemaVersion: string;
16
+ value: string;
17
+ }
18
+ interface EncryptionInfo {
19
+ encryptedSymmetricKey: string;
20
+ initializationVector: string;
21
+ /** Identifier of the public key used to encrypt the symmetric key — key-rotation selector (KSeF API v2.5.0). */
22
+ publicKeyId?: string;
23
+ }
24
+ interface FileMetadata {
25
+ hashSHA: string;
26
+ fileSize: number;
27
+ }
28
+ type ContextIdentifierType = 'Nip' | 'InternalId' | 'NipVatUe' | 'PeppolId';
29
+ interface ContextIdentifier {
30
+ type: ContextIdentifierType;
31
+ value: string;
32
+ }
33
+ /** Archive compression for batch upload / invoice export packages (KSeF API v2.6.0). Defaults to `Zip`. */
34
+ type CompressionType = 'Zip' | 'TarGz';
35
+ type SessionType = 'Online' | 'Batch';
36
+ type SessionStatus = 'Succeeded' | 'InProgress' | 'Failed' | 'Cancelled';
37
+ type SortOrder = 'Asc' | 'Desc';
38
+ type InvoicingMode = 'Online' | 'Offline';
39
+ type PermissionSubjectIdentifierType = 'Nip' | 'Pesel' | 'Fingerprint';
40
+
41
+ /**
42
+ * Invoice subject type — defines the taxpayer's role in the invoice.
43
+ * - `Subject1` — seller (invoices issued by us)
44
+ * - `Subject2` — buyer (invoices received by us)
45
+ * - `Subject3` — third party (e.g. intermediary)
46
+ * - `SubjectAuthorized` — authorized subject acting on behalf of seller/buyer
47
+ */
48
+ type InvoiceSubjectType = 'Subject1' | 'Subject2' | 'Subject3' | 'SubjectAuthorized';
49
+ type InvoiceQueryDateType = 'Issue' | 'Invoicing' | 'PermanentStorage';
50
+ type AmountType = 'Brutto' | 'Netto' | 'Vat';
51
+ type BuyerIdentifierType = 'Nip' | 'VatUe' | 'Other' | 'None';
52
+ type ThirdSubjectIdentifierType = 'Nip' | 'InternalId' | 'VatUe' | 'Other' | 'None';
53
+ type FormType = 'FA' | 'PEF' | 'FA_RR';
54
+ type InvoiceType = 'Vat' | 'Zal' | 'Kor' | 'Roz' | 'Upr' | 'KorZal' | 'KorRoz' | 'VatPef' | 'VatPefSp' | 'KorPef' | 'VatRr' | 'KorVatRr';
55
+ interface InvoiceQueryDateRange {
56
+ dateType: InvoiceQueryDateType;
57
+ from: string;
58
+ to?: string;
59
+ restrictToPermanentStorageHwmDate?: boolean;
60
+ }
61
+ interface InvoiceQueryAmount {
62
+ type: AmountType;
63
+ from?: number;
64
+ to?: number;
65
+ }
66
+ interface InvoiceQueryBuyerIdentifier {
67
+ type: BuyerIdentifierType;
68
+ value?: string;
69
+ }
70
+ interface InvoiceQueryFilters {
71
+ subjectType: InvoiceSubjectType;
72
+ dateRange: InvoiceQueryDateRange;
73
+ ksefNumber?: string;
74
+ invoiceNumber?: string;
75
+ amount?: InvoiceQueryAmount;
76
+ sellerNip?: string;
77
+ buyerIdentifier?: InvoiceQueryBuyerIdentifier;
78
+ currencyCodes?: string[];
79
+ invoicingMode?: InvoicingMode;
80
+ isSelfInvoicing?: boolean;
81
+ formType?: FormType;
82
+ invoiceTypes?: InvoiceType[];
83
+ hasAttachment?: boolean;
84
+ }
85
+ interface InvoiceMetadataSeller {
86
+ nip: string;
87
+ name?: string;
88
+ }
89
+ interface InvoiceMetadataBuyerIdentifier {
90
+ type: BuyerIdentifierType;
91
+ value?: string;
92
+ }
93
+ interface InvoiceMetadataBuyer {
94
+ identifier: InvoiceMetadataBuyerIdentifier;
95
+ name?: string;
96
+ }
97
+ interface InvoiceMetadataThirdSubjectIdentifier {
98
+ type: ThirdSubjectIdentifierType;
99
+ value?: string | null;
100
+ }
101
+ interface InvoiceMetadataThirdSubject {
102
+ identifier: InvoiceMetadataThirdSubjectIdentifier;
103
+ name?: string | null;
104
+ role: number;
105
+ }
106
+ interface InvoiceMetadataAuthorizedSubject {
107
+ nip: string;
108
+ name?: string;
109
+ role: number;
110
+ }
111
+ interface InvoiceMetadata {
112
+ ksefNumber: string;
113
+ invoiceNumber: string;
114
+ issueDate: string;
115
+ invoicingDate: string;
116
+ acquisitionDate: string;
117
+ permanentStorageDate: string;
118
+ seller: InvoiceMetadataSeller;
119
+ buyer: InvoiceMetadataBuyer;
120
+ netAmount: number;
121
+ grossAmount: number;
122
+ vatAmount: number;
123
+ currency: string;
124
+ invoicingMode: InvoicingMode;
125
+ invoiceType: InvoiceType;
126
+ formCode: FormCode;
127
+ isSelfInvoicing: boolean;
128
+ hasAttachment: boolean;
129
+ invoiceHash: string;
130
+ hashOfCorrectedInvoice?: string;
131
+ thirdSubjects?: InvoiceMetadataThirdSubject[];
132
+ authorizedSubject?: InvoiceMetadataAuthorizedSubject;
133
+ }
134
+ interface QueryInvoicesMetadataResponse {
135
+ hasMore: boolean;
136
+ isTruncated: boolean;
137
+ invoices: InvoiceMetadata[];
138
+ permanentStorageHwmDate?: string;
139
+ }
140
+ interface InvoiceResult {
141
+ xml: string;
142
+ /** SHA-256 base64 hash from the `x-ms-meta-hash` response header, if present. */
143
+ hash?: string;
144
+ }
145
+ interface InvoiceExportRequest {
146
+ encryption: EncryptionInfo;
147
+ filters: InvoiceQueryFilters;
148
+ onlyMetadata?: boolean;
149
+ /** Archive compression type for the export package (KSeF API v2.6.0). Omitted/`Zip` keeps the legacy behavior. */
150
+ compressionType?: CompressionType;
151
+ }
152
+ interface InvoiceExportPackagePart {
153
+ ordinalNumber: number;
154
+ partName: string;
155
+ method: string;
156
+ url: string;
157
+ partSize: number;
158
+ partHash: string;
159
+ encryptedPartSize: number;
160
+ encryptedPartHash: string;
161
+ expirationDate: string;
162
+ }
163
+ interface InvoiceExportPackage {
164
+ invoiceCount: number;
165
+ size: number;
166
+ parts: InvoiceExportPackagePart[];
167
+ isTruncated: boolean;
168
+ lastIssueDate?: string;
169
+ lastInvoicingDate?: string;
170
+ lastPermanentStorageDate?: string;
171
+ permanentStorageHwmDate?: string;
172
+ }
173
+ interface InvoiceExportStatusResponse {
174
+ status: OperationStatusInfo;
175
+ completedDate?: string;
176
+ packageExpirationDate?: string;
177
+ package?: InvoiceExportPackage;
178
+ }
179
+
180
+ interface OfflineInvoiceFilter {
181
+ status?: OfflineInvoiceStatus | OfflineInvoiceStatus[];
182
+ mode?: OfflineMode;
183
+ expiringBefore?: Date | string;
184
+ sellerNip?: string;
185
+ }
186
+ type OfflineInvoiceUpdates = Omit<Partial<OfflineInvoiceMetadata>, 'id'>;
187
+ interface OfflineInvoiceStorage {
188
+ save(invoice: OfflineInvoiceMetadata): Promise<void>;
189
+ get(id: string): Promise<OfflineInvoiceMetadata | null>;
190
+ list(filter?: OfflineInvoiceFilter): Promise<OfflineInvoiceMetadata[]>;
191
+ update(id: string, updates: OfflineInvoiceUpdates): Promise<void>;
192
+ delete(id: string): Promise<void>;
193
+ }
194
+ declare class InMemoryOfflineInvoiceStorage implements OfflineInvoiceStorage {
195
+ private readonly store;
196
+ save(invoice: OfflineInvoiceMetadata): Promise<void>;
197
+ get(id: string): Promise<OfflineInvoiceMetadata | null>;
198
+ list(filter?: OfflineInvoiceFilter): Promise<OfflineInvoiceMetadata[]>;
199
+ update(id: string, updates: OfflineInvoiceUpdates): Promise<void>;
200
+ delete(id: string): Promise<void>;
201
+ }
202
+
203
+ /** Offline invoice modes per KSeF docs (art. 106nda/106nh/106nf) */
204
+ type OfflineMode = 'offline24' | 'offline' | 'awaryjny' | 'awaria_calkowita';
205
+ /** Why this invoice was issued offline */
206
+ type OfflineReason = 'PLANNED' | 'SYSTEM_UNAVAILABLE' | 'EMERGENCY' | 'TOTAL_FAILURE';
207
+ /**
208
+ * Offline invoice lifecycle state machine:
209
+ * GENERATED → QUEUED → SUBMITTED → ACCEPTED | REJECTED
210
+ * Any non-terminal → EXPIRED
211
+ */
212
+ type OfflineInvoiceStatus = 'GENERATED' | 'QUEUED' | 'SUBMITTED' | 'ACCEPTED' | 'REJECTED' | 'CORRECTED' | 'EXPIRED';
213
+ interface OfflineInvoiceInputData {
214
+ invoiceNumber: string;
215
+ invoiceDate: string;
216
+ invoiceXml: string;
217
+ sellerNip: string;
218
+ sellerIdentifier: ContextIdentifier;
219
+ buyerIdentifier?: ContextIdentifier;
220
+ totalAmount?: number;
221
+ currency?: string;
222
+ }
223
+ interface OfflineCertificate {
224
+ privateKeyPem: string;
225
+ certificateSerial: string;
226
+ password?: string;
227
+ }
228
+ interface MaintenanceWindow {
229
+ id: string;
230
+ startTime: string;
231
+ endTime?: string;
232
+ active: boolean;
233
+ planned: boolean;
234
+ reason?: string;
235
+ }
236
+ interface OfflineInvoiceMetadata {
237
+ id: string;
238
+ mode: OfflineMode;
239
+ reason: OfflineReason;
240
+ status: OfflineInvoiceStatus;
241
+ invoiceNumber: string;
242
+ invoiceDate: string;
243
+ invoiceXml: string;
244
+ sellerNip: string;
245
+ sellerIdentifier: ContextIdentifier;
246
+ buyerIdentifier?: ContextIdentifier;
247
+ totalAmount?: number;
248
+ currency?: string;
249
+ kod1Url: string;
250
+ kod2Url?: string;
251
+ generatedAt: string;
252
+ submitBy: string;
253
+ submittedAt?: string;
254
+ acceptedAt?: string;
255
+ ksefReferenceNumber?: string;
256
+ error?: {
257
+ code: number;
258
+ message: string;
259
+ details?: string[];
260
+ };
261
+ maintenanceWindowId?: string;
262
+ correctedInvoiceId?: string;
263
+ correctedBy?: string;
264
+ }
265
+ interface OfflineInvoiceOptions {
266
+ mode?: OfflineMode;
267
+ certificate?: OfflineCertificate;
268
+ maintenanceWindow?: MaintenanceWindow;
269
+ customDeadline?: Date | string;
270
+ storage?: OfflineInvoiceStorage;
271
+ }
272
+ interface OfflineBatchResult {
273
+ total: number;
274
+ submitted: number;
275
+ accepted: number;
276
+ rejected: number;
277
+ failed: number;
278
+ expired: number;
279
+ results: OfflineSubmissionResult[];
280
+ }
281
+ interface OfflineSubmissionResult {
282
+ invoiceId: string;
283
+ invoiceNumber: string;
284
+ status: OfflineInvoiceStatus;
285
+ ksefReferenceNumber?: string;
286
+ error?: {
287
+ code: number;
288
+ message: string;
289
+ details?: string[];
290
+ };
291
+ }
292
+
293
+ type ContinuationPoints = Record<string, string | undefined>;
294
+ declare function updateContinuationPoint(points: ContinuationPoints, subjectType: string, pkg: Pick<InvoiceExportPackage, 'isTruncated' | 'lastPermanentStorageDate' | 'permanentStorageHwmDate'>): void;
295
+ declare function getEffectiveStartDate(points: ContinuationPoints, subjectType: string, windowFrom: string): string;
296
+ declare function deduplicateByKsefNumber<T extends {
297
+ ksefNumber: string;
298
+ }>(entries: T[]): T[];
299
+
300
+ interface HwmStore {
301
+ load(): Promise<ContinuationPoints>;
302
+ save(points: ContinuationPoints): Promise<void>;
303
+ }
304
+ declare class InMemoryHwmStore implements HwmStore {
305
+ private points;
306
+ load(): Promise<ContinuationPoints>;
307
+ save(points: ContinuationPoints): Promise<void>;
308
+ }
309
+ declare class FileHwmStore implements HwmStore {
310
+ private readonly filePath;
311
+ constructor(filePath: string);
312
+ load(): Promise<ContinuationPoints>;
313
+ save(points: ContinuationPoints): Promise<void>;
314
+ }
315
+
316
+ export { type OfflineInvoiceUpdates as $, type AmountType as A, type BuyerIdentifierType as B, type ContextIdentifier as C, InMemoryOfflineInvoiceStorage as D, type EncryptionInfo as E, type FormCode as F, type InvoiceExportPackage as G, type HwmStore as H, type InvoicingMode as I, type InvoiceExportPackagePart as J, type InvoiceMetadataAuthorizedSubject as K, type InvoiceMetadataBuyer as L, type MaintenanceWindow as M, type InvoiceMetadataBuyerIdentifier as N, type OperationStatusInfo as O, type PermissionSubjectIdentifierType as P, type QueryInvoicesMetadataResponse as Q, type InvoiceMetadataSeller as R, type SessionStatus as S, type TokenInfo as T, type InvoiceMetadataThirdSubject as U, type InvoiceMetadataThirdSubjectIdentifier as V, type InvoiceQueryAmount as W, type InvoiceQueryBuyerIdentifier as X, type InvoiceQueryDateRange as Y, type OfflineInvoiceFilter as Z, type OfflineInvoiceStatus as _, type CompressionType as a, type ThirdSubjectIdentifierType as a0, deduplicateByKsefNumber as a1, getEffectiveStartDate as a2, updateContinuationPoint as a3, FileHwmStore as a4, type FileMetadata as b, type InvoiceType as c, type SessionType as d, type InvoiceResult as e, type InvoiceQueryFilters as f, type SortOrder as g, type InvoiceExportRequest as h, type OperationResponse as i, type InvoiceExportStatusResponse as j, type InvoiceSubjectType as k, type InvoiceQueryDateType as l, type FormType as m, type OfflineInvoiceInputData as n, type OfflineInvoiceOptions as o, type OfflineInvoiceMetadata as p, type OfflineInvoiceStorage as q, type OfflineBatchResult as r, type OfflineCertificate as s, type OfflineSubmissionResult as t, type ContinuationPoints as u, type InvoiceMetadata as v, type OfflineMode as w, type OfflineReason as x, type ContextIdentifierType as y, InMemoryHwmStore as z };