@getpeppr/sdk 0.1.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/README.md +463 -0
- package/dist/core/client.d.ts +523 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/client.js +1308 -0
- package/dist/core/client.js.map +1 -0
- package/dist/core/code-lists.d.ts +120 -0
- package/dist/core/code-lists.d.ts.map +1 -0
- package/dist/core/code-lists.js +247 -0
- package/dist/core/code-lists.js.map +1 -0
- package/dist/core/country-rules.d.ts +30 -0
- package/dist/core/country-rules.d.ts.map +1 -0
- package/dist/core/country-rules.js +128 -0
- package/dist/core/country-rules.js.map +1 -0
- package/dist/core/schematron.d.ts +59 -0
- package/dist/core/schematron.d.ts.map +1 -0
- package/dist/core/schematron.js +480 -0
- package/dist/core/schematron.js.map +1 -0
- package/dist/core/ubl-builder.d.ts +20 -0
- package/dist/core/ubl-builder.d.ts.map +1 -0
- package/dist/core/ubl-builder.js +530 -0
- package/dist/core/ubl-builder.js.map +1 -0
- package/dist/core/validator.d.ts +16 -0
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/core/validator.js +171 -0
- package/dist/core/validator.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/types/invoice.d.ts +635 -0
- package/dist/types/invoice.d.ts.map +1 -0
- package/dist/types/invoice.js +8 -0
- package/dist/types/invoice.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getpeppr SDK Client
|
|
3
|
+
*
|
|
4
|
+
* The main entry point. Designed to feel like Stripe's SDK:
|
|
5
|
+
*
|
|
6
|
+
* const peppol = new Peppol({ apiKey: "sk_live_..." });
|
|
7
|
+
* const result = await peppol.invoices.send({ from, to, lines });
|
|
8
|
+
*
|
|
9
|
+
* All requests go through the getpeppr API gateway (api.getpeppr.dev),
|
|
10
|
+
* which handles Peppol delivery, billing, and usage tracking.
|
|
11
|
+
* Use `baseUrl` to point to a custom instance or localhost.
|
|
12
|
+
*/
|
|
13
|
+
import type { PeppolConfig, InvoiceInput, CreditNoteInput, SendResult, ReceivedInvoice, ValidationResult, WebhookEvent, DocumentStatus, WaitForOptions, PaginatedResult, InvoiceSummary, ListInvoicesOptions, DirectoryEntry, PeppolId, DocumentFormat, ServerValidationResult, EventEntry, ListEventsOptions, BatchSendOptions, BatchSendResult, InvoiceOperationOptions, Contact, ContactInput, ListContactsOptions, BankAccount, BankAccountInput, ListBankAccountsOptions, ImportInvoiceOptions, TransportType, Transport } from "../types/invoice.js";
|
|
14
|
+
/**
|
|
15
|
+
* Backend adapter interface for the SDK's transport layer.
|
|
16
|
+
* The default implementation hits the getpeppr API gateway.
|
|
17
|
+
*/
|
|
18
|
+
export interface BackendAdapter {
|
|
19
|
+
/** Provider name (for logging) */
|
|
20
|
+
readonly name: string;
|
|
21
|
+
/** Send an invoice as structured JSON (gateway handles UBL generation) */
|
|
22
|
+
sendInvoice(input: InvoiceInput, options?: InvoiceOperationOptions): Promise<SendResult>;
|
|
23
|
+
/** Create a draft invoice without sending (POST /invoices, no send_after_import) */
|
|
24
|
+
createInvoice(input: InvoiceInput, options?: InvoiceOperationOptions): Promise<SendResult>;
|
|
25
|
+
/** Send an existing draft invoice by ID (POST /invoices/send/{id}, returns 204) */
|
|
26
|
+
sendInvoiceById(id: string): Promise<void>;
|
|
27
|
+
/** @deprecated Credit notes now route through sendInvoice with isCreditNote: true */
|
|
28
|
+
sendCreditNote(input: CreditNoteInput): Promise<SendResult>;
|
|
29
|
+
/** Validate an invoice server-side (free, no metering) */
|
|
30
|
+
validateDocument(input: InvoiceInput): Promise<{
|
|
31
|
+
valid: boolean;
|
|
32
|
+
errors: string[];
|
|
33
|
+
}>;
|
|
34
|
+
/** List received invoices */
|
|
35
|
+
listReceived(options?: {
|
|
36
|
+
limit?: number;
|
|
37
|
+
offset?: number;
|
|
38
|
+
}): Promise<ReceivedInvoice[]>;
|
|
39
|
+
/** List invoices with pagination and filtering */
|
|
40
|
+
listInvoices(options?: ListInvoicesOptions): Promise<PaginatedResult<InvoiceSummary>>;
|
|
41
|
+
/** Get document status by ID */
|
|
42
|
+
getStatus(documentId: string): Promise<SendResult>;
|
|
43
|
+
/** Look up a Peppol participant in the directory */
|
|
44
|
+
lookupDirectory(scheme: string, id: string): Promise<DirectoryEntry>;
|
|
45
|
+
/** Export an invoice in a specific format (e.g., PDF) — returns raw binary */
|
|
46
|
+
getInvoiceAs(id: string, format: DocumentFormat): Promise<ArrayBuffer>;
|
|
47
|
+
/** Validate an invoice server-side (XSD + Schematron) — builds UBL XML, sends to gateway */
|
|
48
|
+
validateDocumentServer(input: InvoiceInput): Promise<ServerValidationResult>;
|
|
49
|
+
/** List events with optional filtering and pagination */
|
|
50
|
+
listEvents(options?: ListEventsOptions): Promise<PaginatedResult<EventEntry>>;
|
|
51
|
+
/** Acknowledge a received invoice (POST /invoices/{id}/ack) */
|
|
52
|
+
acknowledgeInvoice(id: string): Promise<SendResult>;
|
|
53
|
+
/** List contacts with optional filtering and pagination */
|
|
54
|
+
listContacts(options?: ListContactsOptions): Promise<PaginatedResult<Contact>>;
|
|
55
|
+
/** Get a single contact by ID */
|
|
56
|
+
getContact(id: string): Promise<Contact>;
|
|
57
|
+
/** Create a new contact */
|
|
58
|
+
createContact(input: ContactInput): Promise<Contact>;
|
|
59
|
+
/** Update an existing contact */
|
|
60
|
+
updateContact(id: string, input: Partial<ContactInput>): Promise<Contact>;
|
|
61
|
+
/** Delete a contact */
|
|
62
|
+
deleteContact(id: string): Promise<void>;
|
|
63
|
+
/** List bank accounts with optional pagination */
|
|
64
|
+
listBankAccounts(options?: ListBankAccountsOptions): Promise<PaginatedResult<BankAccount>>;
|
|
65
|
+
/** Get a single bank account by ID */
|
|
66
|
+
getBankAccount(id: string): Promise<BankAccount>;
|
|
67
|
+
/** Create a new bank account */
|
|
68
|
+
createBankAccount(input: BankAccountInput): Promise<BankAccount>;
|
|
69
|
+
/** Update an existing bank account */
|
|
70
|
+
updateBankAccount(id: string, input: Partial<BankAccountInput>): Promise<BankAccount>;
|
|
71
|
+
/** Delete a bank account */
|
|
72
|
+
deleteBankAccount(id: string): Promise<void>;
|
|
73
|
+
/** Import an invoice from a file (XML, PDF, etc.) */
|
|
74
|
+
importInvoice(options: ImportInvoiceOptions): Promise<SendResult>;
|
|
75
|
+
/** List all available transport types (global, not account-scoped) */
|
|
76
|
+
listTransportTypes(): Promise<TransportType[]>;
|
|
77
|
+
/** List configured transports for this account */
|
|
78
|
+
listTransports(): Promise<Transport[]>;
|
|
79
|
+
}
|
|
80
|
+
/** Convert ArrayBuffer or Uint8Array to base64 string (works in all runtimes). */
|
|
81
|
+
export declare function arrayBufferToBase64(buffer: ArrayBuffer | Uint8Array): string;
|
|
82
|
+
/** Detect MIME type from a filename's extension. */
|
|
83
|
+
export declare function detectMimeType(filename: string): string;
|
|
84
|
+
export declare class PeppolError extends Error {
|
|
85
|
+
constructor(message: string);
|
|
86
|
+
}
|
|
87
|
+
export declare class PeppolValidationError extends PeppolError {
|
|
88
|
+
readonly validation: ValidationResult;
|
|
89
|
+
constructor(message: string, validation: ValidationResult);
|
|
90
|
+
}
|
|
91
|
+
export declare class PeppolApiError extends PeppolError {
|
|
92
|
+
readonly statusCode: number;
|
|
93
|
+
readonly responseBody: string;
|
|
94
|
+
/** Parsed Retry-After delay in milliseconds (present on 429 responses) */
|
|
95
|
+
readonly retryAfterMs?: number;
|
|
96
|
+
constructor(message: string, statusCode: number, responseBody: string, retryAfterMs?: number);
|
|
97
|
+
}
|
|
98
|
+
export declare class Peppol {
|
|
99
|
+
private adapter;
|
|
100
|
+
readonly invoices: InvoiceOperations;
|
|
101
|
+
readonly creditNotes: CreditNoteOperations;
|
|
102
|
+
readonly directory: DirectoryOperations;
|
|
103
|
+
readonly events: EventOperations;
|
|
104
|
+
readonly contacts: ContactOperations;
|
|
105
|
+
readonly bankAccounts: BankAccountOperations;
|
|
106
|
+
readonly transports: TransportOperations;
|
|
107
|
+
constructor(config: PeppolConfig);
|
|
108
|
+
/**
|
|
109
|
+
* Validate an invoice without sending it.
|
|
110
|
+
* Useful for pre-flight checks in your UI.
|
|
111
|
+
*/
|
|
112
|
+
validate(input: InvoiceInput): ValidationResult;
|
|
113
|
+
/**
|
|
114
|
+
* Generate UBL XML without sending.
|
|
115
|
+
* Useful for debugging or manual submission.
|
|
116
|
+
*/
|
|
117
|
+
toXml(input: InvoiceInput): string;
|
|
118
|
+
}
|
|
119
|
+
declare class InvoiceOperations {
|
|
120
|
+
private adapter;
|
|
121
|
+
constructor(adapter: BackendAdapter);
|
|
122
|
+
/**
|
|
123
|
+
* Create a draft invoice without sending it.
|
|
124
|
+
* Validates input client-side, then creates the invoice on B2BRouter.
|
|
125
|
+
* Use `sendById()` to send the draft when ready.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* const draft = await peppol.invoices.create({ number: "INV-001", to, lines });
|
|
130
|
+
* // Later, when ready:
|
|
131
|
+
* await peppol.invoices.sendById(draft.id);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
create(input: InvoiceInput, options?: InvoiceOperationOptions): Promise<SendResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Send an existing draft invoice by ID.
|
|
137
|
+
* The invoice must have been previously created with `create()`.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* await peppol.invoices.sendById("inv-1");
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
sendById(id: string): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Send an invoice via Peppol.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const result = await peppol.invoices.send({
|
|
151
|
+
* number: "INV-001",
|
|
152
|
+
* from: { name: "My Company", peppolId: "0208:BE0123456789", country: "BE" },
|
|
153
|
+
* to: { name: "Client Co", peppolId: "0208:BE9876543210", country: "BE" },
|
|
154
|
+
* lines: [
|
|
155
|
+
* { description: "Consulting", quantity: 10, unitPrice: 150, vatRate: 21 }
|
|
156
|
+
* ]
|
|
157
|
+
* });
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
send(input: InvoiceInput, options?: InvoiceOperationOptions): Promise<SendResult>;
|
|
161
|
+
/** List invoices with pagination, filtering, and proper metadata */
|
|
162
|
+
list(options?: ListInvoicesOptions): Promise<PaginatedResult<InvoiceSummary>>;
|
|
163
|
+
/**
|
|
164
|
+
* Async iterator over all invoices, automatically handling pagination.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* for await (const invoice of peppol.invoices.listAll({ type: "issued" })) {
|
|
169
|
+
* console.log(invoice.id, invoice.status);
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
listAll(options?: {
|
|
174
|
+
limit?: number;
|
|
175
|
+
type?: "issued" | "received";
|
|
176
|
+
includeLines?: boolean;
|
|
177
|
+
}): AsyncIterable<InvoiceSummary>;
|
|
178
|
+
/** List received invoices */
|
|
179
|
+
listReceived(options?: {
|
|
180
|
+
limit?: number;
|
|
181
|
+
offset?: number;
|
|
182
|
+
}): Promise<ReceivedInvoice[]>;
|
|
183
|
+
/** Get the status of a sent invoice */
|
|
184
|
+
getStatus(documentId: string): Promise<SendResult>;
|
|
185
|
+
/**
|
|
186
|
+
* Export an invoice in a specific format (e.g., PDF, UBL XML).
|
|
187
|
+
* Returns raw binary data as an ArrayBuffer.
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```ts
|
|
191
|
+
* const pdf = await peppol.invoices.getAs("inv-123", "pdf");
|
|
192
|
+
* fs.writeFileSync("invoice.pdf", Buffer.from(pdf));
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
getAs(id: string, format: DocumentFormat): Promise<ArrayBuffer>;
|
|
196
|
+
/**
|
|
197
|
+
* Validate an invoice server-side using XSD and Schematron rules.
|
|
198
|
+
* Builds UBL XML from the input and sends it to the server for validation.
|
|
199
|
+
* More thorough than client-side validation — catches XML-level issues.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```ts
|
|
203
|
+
* const result = await peppol.invoices.validateServer({
|
|
204
|
+
* number: "INV-001",
|
|
205
|
+
* to: { name: "Acme", peppolId: "0208:BE0123456789", country: "BE" },
|
|
206
|
+
* lines: [{ description: "Item", quantity: 1, unitPrice: 100, vatRate: 21 }]
|
|
207
|
+
* });
|
|
208
|
+
* console.log(result.valid, result.schematron.errors);
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
validateServer(input: InvoiceInput): Promise<ServerValidationResult>;
|
|
212
|
+
/**
|
|
213
|
+
* Import an invoice from a file (XML, PDF, JSON).
|
|
214
|
+
* The file is base64-encoded and sent to the gateway, which forwards it
|
|
215
|
+
* as multipart/form-data to B2BRouter's import endpoint.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```ts
|
|
219
|
+
* const xmlBytes = fs.readFileSync("invoice.xml");
|
|
220
|
+
* const result = await peppol.invoices.importFile({
|
|
221
|
+
* file: xmlBytes,
|
|
222
|
+
* filename: "invoice.xml",
|
|
223
|
+
* });
|
|
224
|
+
* console.log(result.id, result.status);
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
importFile(options: ImportInvoiceOptions): Promise<SendResult>;
|
|
228
|
+
/**
|
|
229
|
+
* Acknowledge a received invoice.
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* ```ts
|
|
233
|
+
* const result = await peppol.invoices.acknowledge("inv-123");
|
|
234
|
+
* console.log(result.status); // "accepted"
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
acknowledge(id: string): Promise<SendResult>;
|
|
238
|
+
/**
|
|
239
|
+
* Send multiple invoices in parallel with controlled concurrency.
|
|
240
|
+
* Each invoice is validated and sent individually — failures don't affect other invoices
|
|
241
|
+
* unless `stopOnError: true` is set.
|
|
242
|
+
*
|
|
243
|
+
* The SDK's built-in retry logic (including 429 Retry-After) provides automatic
|
|
244
|
+
* rate-limit handling at the request level.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* const result = await peppol.invoices.sendBatch([invoice1, invoice2, invoice3], {
|
|
249
|
+
* concurrency: 3,
|
|
250
|
+
* });
|
|
251
|
+
* console.log(`${result.succeeded.length} sent, ${result.failed.length} failed`);
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
sendBatch(inputs: InvoiceInput[], options?: BatchSendOptions): Promise<BatchSendResult>;
|
|
255
|
+
/**
|
|
256
|
+
* Poll until an invoice reaches a target status.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* ```ts
|
|
260
|
+
* const result = await peppol.invoices.waitFor(id, "accepted", { timeout: 60000 });
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
waitFor(documentId: string, targetStatus: DocumentStatus | DocumentStatus[], options?: WaitForOptions): Promise<SendResult>;
|
|
264
|
+
}
|
|
265
|
+
/** @deprecated Use peppol.invoices.send() with isCreditNote: true instead */
|
|
266
|
+
declare class CreditNoteOperations {
|
|
267
|
+
private adapter;
|
|
268
|
+
constructor(adapter: BackendAdapter);
|
|
269
|
+
/**
|
|
270
|
+
* Send a credit note via Peppol.
|
|
271
|
+
* @deprecated Use peppol.invoices.send({ ...input, isCreditNote: true }) instead.
|
|
272
|
+
*/
|
|
273
|
+
send(input: CreditNoteInput): Promise<SendResult>;
|
|
274
|
+
}
|
|
275
|
+
declare class DirectoryOperations {
|
|
276
|
+
private adapter;
|
|
277
|
+
constructor(adapter: BackendAdapter);
|
|
278
|
+
/**
|
|
279
|
+
* Look up a Peppol participant in the directory.
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```ts
|
|
283
|
+
* const entry = await peppol.directory.lookup("0208:BE0123456789");
|
|
284
|
+
* console.log(entry.name, entry.capabilities);
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
lookup(peppolId: PeppolId): Promise<DirectoryEntry>;
|
|
288
|
+
}
|
|
289
|
+
declare class EventOperations {
|
|
290
|
+
private adapter;
|
|
291
|
+
constructor(adapter: BackendAdapter);
|
|
292
|
+
/**
|
|
293
|
+
* List events with optional filtering and pagination.
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* const result = await peppol.events.list({ limit: 10 });
|
|
298
|
+
* console.log(result.data, result.meta);
|
|
299
|
+
*
|
|
300
|
+
* // Filter by invoice
|
|
301
|
+
* const invoiceEvents = await peppol.events.list({ invoiceId: "inv-123" });
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
list(options?: ListEventsOptions): Promise<PaginatedResult<EventEntry>>;
|
|
305
|
+
/**
|
|
306
|
+
* Async iterator over all events, automatically handling pagination.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* for await (const event of peppol.events.listAll({ invoiceId: "inv-123" })) {
|
|
311
|
+
* console.log(event.name, event.createdAt);
|
|
312
|
+
* }
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
listAll(options?: Omit<ListEventsOptions, "offset">): AsyncIterable<EventEntry>;
|
|
316
|
+
}
|
|
317
|
+
declare class ContactOperations {
|
|
318
|
+
private adapter;
|
|
319
|
+
constructor(adapter: BackendAdapter);
|
|
320
|
+
/**
|
|
321
|
+
* List contacts with optional filtering and pagination.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```ts
|
|
325
|
+
* const result = await peppol.contacts.list({ limit: 10, isClient: true });
|
|
326
|
+
* console.log(result.data, result.meta);
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
list(options?: ListContactsOptions): Promise<PaginatedResult<Contact>>;
|
|
330
|
+
/**
|
|
331
|
+
* Get a single contact by ID.
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* ```ts
|
|
335
|
+
* const contact = await peppol.contacts.get("123");
|
|
336
|
+
* console.log(contact.name, contact.peppolId);
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
get(id: string): Promise<Contact>;
|
|
340
|
+
/**
|
|
341
|
+
* Create a new contact.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* ```ts
|
|
345
|
+
* const contact = await peppol.contacts.create({
|
|
346
|
+
* name: "Acme Corp",
|
|
347
|
+
* peppolId: "0208:BE0123456789",
|
|
348
|
+
* country: "BE",
|
|
349
|
+
* isClient: true,
|
|
350
|
+
* });
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
create(input: ContactInput): Promise<Contact>;
|
|
354
|
+
/**
|
|
355
|
+
* Update an existing contact.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```ts
|
|
359
|
+
* const updated = await peppol.contacts.update("123", { email: "new@acme.com" });
|
|
360
|
+
* ```
|
|
361
|
+
*/
|
|
362
|
+
update(id: string, input: Partial<ContactInput>): Promise<Contact>;
|
|
363
|
+
/**
|
|
364
|
+
* Delete a contact.
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* await peppol.contacts.delete("123");
|
|
369
|
+
* ```
|
|
370
|
+
*/
|
|
371
|
+
delete(id: string): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* Async iterator over all contacts, automatically handling pagination.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* for await (const contact of peppol.contacts.listAll({ isClient: true })) {
|
|
378
|
+
* console.log(contact.name, contact.peppolId);
|
|
379
|
+
* }
|
|
380
|
+
* ```
|
|
381
|
+
*/
|
|
382
|
+
listAll(options?: Omit<ListContactsOptions, "limit" | "offset">): AsyncIterable<Contact>;
|
|
383
|
+
}
|
|
384
|
+
declare class BankAccountOperations {
|
|
385
|
+
private adapter;
|
|
386
|
+
constructor(adapter: BackendAdapter);
|
|
387
|
+
/**
|
|
388
|
+
* List bank accounts with optional pagination.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* const result = await peppol.bankAccounts.list({ limit: 10 });
|
|
393
|
+
* console.log(result.data, result.meta);
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
list(options?: ListBankAccountsOptions): Promise<PaginatedResult<BankAccount>>;
|
|
397
|
+
/**
|
|
398
|
+
* Get a single bank account by ID.
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* ```ts
|
|
402
|
+
* const account = await peppol.bankAccounts.get("123");
|
|
403
|
+
* console.log(account.name, account.iban);
|
|
404
|
+
* ```
|
|
405
|
+
*/
|
|
406
|
+
get(id: string): Promise<BankAccount>;
|
|
407
|
+
/**
|
|
408
|
+
* Create a new bank account.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* const account = await peppol.bankAccounts.create({
|
|
413
|
+
* name: "Main Account",
|
|
414
|
+
* iban: "BE68539007547034",
|
|
415
|
+
* bic: "BBRUBEBB",
|
|
416
|
+
* country: "BE",
|
|
417
|
+
* });
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
create(input: BankAccountInput): Promise<BankAccount>;
|
|
421
|
+
/**
|
|
422
|
+
* Update an existing bank account.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* ```ts
|
|
426
|
+
* const updated = await peppol.bankAccounts.update("123", { name: "Updated Name" });
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
update(id: string, input: Partial<BankAccountInput>): Promise<BankAccount>;
|
|
430
|
+
/**
|
|
431
|
+
* Delete a bank account.
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```ts
|
|
435
|
+
* await peppol.bankAccounts.delete("123");
|
|
436
|
+
* ```
|
|
437
|
+
*/
|
|
438
|
+
delete(id: string): Promise<void>;
|
|
439
|
+
/**
|
|
440
|
+
* Async iterator over all bank accounts, automatically handling pagination.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* for await (const account of peppol.bankAccounts.listAll()) {
|
|
445
|
+
* console.log(account.name, account.iban);
|
|
446
|
+
* }
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
listAll(options?: Omit<ListBankAccountsOptions, "limit" | "offset">): AsyncIterable<BankAccount>;
|
|
450
|
+
}
|
|
451
|
+
declare class TransportOperations {
|
|
452
|
+
private adapter;
|
|
453
|
+
constructor(adapter: BackendAdapter);
|
|
454
|
+
/**
|
|
455
|
+
* List all available transport types in the network.
|
|
456
|
+
* Returns global transport types (not account-scoped).
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* const types = await peppol.transports.listTypes();
|
|
461
|
+
* console.log(types); // [{ code: "peppol", name: "Peppol BIS 3.0" }, ...]
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
listTypes(): Promise<TransportType[]>;
|
|
465
|
+
/**
|
|
466
|
+
* List configured transports for this account.
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```ts
|
|
470
|
+
* const transports = await peppol.transports.list();
|
|
471
|
+
* console.log(transports); // [{ id: "t-1", transportTypeCode: "peppol", name: "..." }, ...]
|
|
472
|
+
* ```
|
|
473
|
+
*/
|
|
474
|
+
list(): Promise<Transport[]>;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Parse and verify a webhook payload from B2BRouter.
|
|
478
|
+
*
|
|
479
|
+
* B2BRouter signs webhooks with HMAC-SHA256. The signature header format is:
|
|
480
|
+
* `X-B2Brouter-Signature: t={timestamp},s={hmac_sha256_hex}`
|
|
481
|
+
*
|
|
482
|
+
* The signed payload is: `{timestamp}.{raw_json_body}`
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```ts
|
|
486
|
+
* app.post("/webhooks/peppol", (req, res) => {
|
|
487
|
+
* try {
|
|
488
|
+
* const event = Peppol.webhooks.parse(
|
|
489
|
+
* req.body, // raw body string
|
|
490
|
+
* req.headers["x-b2brouter-signature"], // signature header
|
|
491
|
+
* "whsec_your_webhook_secret", // your webhook secret
|
|
492
|
+
* );
|
|
493
|
+
* switch (event.type) {
|
|
494
|
+
* case "invoice.received":
|
|
495
|
+
* console.log("New invoice from:", event.data.senderId);
|
|
496
|
+
* break;
|
|
497
|
+
* }
|
|
498
|
+
* res.sendStatus(200);
|
|
499
|
+
* } catch (err) {
|
|
500
|
+
* res.status(400).send("Webhook verification failed");
|
|
501
|
+
* }
|
|
502
|
+
* });
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
export declare const webhooks: {
|
|
506
|
+
/**
|
|
507
|
+
* Parse a webhook payload without signature verification.
|
|
508
|
+
* Use `constructEvent()` for verified parsing in production.
|
|
509
|
+
*/
|
|
510
|
+
parse(payload: unknown): WebhookEvent;
|
|
511
|
+
/**
|
|
512
|
+
* Verify and parse a webhook payload using HMAC-SHA256 signature.
|
|
513
|
+
* Throws `PeppolError` if verification fails.
|
|
514
|
+
*
|
|
515
|
+
* @param rawBody — The raw request body string (NOT parsed JSON)
|
|
516
|
+
* @param signatureHeader — The `X-B2Brouter-Signature` header value
|
|
517
|
+
* @param secret — Your webhook secret from B2BRouter
|
|
518
|
+
* @param toleranceSeconds — Max age of the webhook in seconds (default: 300 = 5 min)
|
|
519
|
+
*/
|
|
520
|
+
constructEvent(rawBody: string, signatureHeader: string, secret: string, toleranceSeconds?: number): Promise<WebhookEvent>;
|
|
521
|
+
};
|
|
522
|
+
export {};
|
|
523
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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