@frihet/mcp-server 1.14.5 → 1.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +6 -28
  2. package/dist/__tests__/fiscal-tools.test.js +56 -0
  3. package/dist/__tests__/fiscal-tools.test.js.map +1 -1
  4. package/dist/__tests__/get-envelope-unwrap-regression.test.d.ts +27 -0
  5. package/dist/__tests__/get-envelope-unwrap-regression.test.d.ts.map +1 -0
  6. package/dist/__tests__/get-envelope-unwrap-regression.test.js +223 -0
  7. package/dist/__tests__/get-envelope-unwrap-regression.test.js.map +1 -0
  8. package/dist/__tests__/mutation-unwrap-and-schema-regression.test.d.ts +30 -0
  9. package/dist/__tests__/mutation-unwrap-and-schema-regression.test.d.ts.map +1 -0
  10. package/dist/__tests__/mutation-unwrap-and-schema-regression.test.js +164 -0
  11. package/dist/__tests__/mutation-unwrap-and-schema-regression.test.js.map +1 -0
  12. package/dist/__tests__/openai-grouped-compose.test.js +5 -0
  13. package/dist/__tests__/openai-grouped-compose.test.js.map +1 -1
  14. package/dist/__tests__/openai-profile.test.js +3 -0
  15. package/dist/__tests__/openai-profile.test.js.map +1 -1
  16. package/dist/__tests__/schema-envelope-guard.test.d.ts +18 -0
  17. package/dist/__tests__/schema-envelope-guard.test.d.ts.map +1 -0
  18. package/dist/__tests__/schema-envelope-guard.test.js +56 -0
  19. package/dist/__tests__/schema-envelope-guard.test.js.map +1 -0
  20. package/dist/client.d.ts +17 -7
  21. package/dist/client.d.ts.map +1 -1
  22. package/dist/client.js +112 -94
  23. package/dist/client.js.map +1 -1
  24. package/dist/openai-profile.d.ts +2 -2
  25. package/dist/openai-profile.d.ts.map +1 -1
  26. package/dist/openai-profile.js +15 -5
  27. package/dist/openai-profile.js.map +1 -1
  28. package/dist/redaction.d.ts +2 -1
  29. package/dist/redaction.d.ts.map +1 -1
  30. package/dist/redaction.js +5 -1
  31. package/dist/redaction.js.map +1 -1
  32. package/dist/resources/register-all.d.ts +3 -0
  33. package/dist/resources/register-all.d.ts.map +1 -1
  34. package/dist/resources/register-all.js +3 -0
  35. package/dist/resources/register-all.js.map +1 -1
  36. package/dist/tool-exposure.d.ts +6 -6
  37. package/dist/tool-exposure.js +7 -7
  38. package/dist/tools/clients.js +1 -1
  39. package/dist/tools/clients.js.map +1 -1
  40. package/dist/tools/deposits.js +1 -1
  41. package/dist/tools/deposits.js.map +1 -1
  42. package/dist/tools/expenses.js +1 -1
  43. package/dist/tools/expenses.js.map +1 -1
  44. package/dist/tools/fiscal.d.ts.map +1 -1
  45. package/dist/tools/fiscal.js +50 -3
  46. package/dist/tools/fiscal.js.map +1 -1
  47. package/dist/tools/invoices.js +4 -4
  48. package/dist/tools/invoices.js.map +1 -1
  49. package/dist/tools/products.js +1 -1
  50. package/dist/tools/products.js.map +1 -1
  51. package/dist/tools/quotes.js +1 -1
  52. package/dist/tools/quotes.js.map +1 -1
  53. package/dist/tools/register-all.d.ts +2 -2
  54. package/dist/tools/register-all.js +3 -3
  55. package/dist/tools/shared.d.ts +66 -11
  56. package/dist/tools/shared.d.ts.map +1 -1
  57. package/dist/tools/shared.js +84 -10
  58. package/dist/tools/shared.js.map +1 -1
  59. package/dist/tools/stay.js +2 -2
  60. package/dist/tools/stay.js.map +1 -1
  61. package/dist/tools/vendors.js +1 -1
  62. package/dist/tools/vendors.js.map +1 -1
  63. package/package.json +4 -3
  64. package/scripts/no-public-leak.sh +45 -0
package/dist/client.js CHANGED
@@ -116,14 +116,24 @@ export class FrihetClient {
116
116
  return new Promise((resolve) => setTimeout(resolve, ms));
117
117
  }
118
118
  /**
119
- * Wrapper for SINGLE-OBJECT endpoints whose backend wraps the item in a
120
- * `{ data, meta }` envelope (e.g. the shipped `/v1/fiscal/modelo/:code` CF).
119
+ * Wrapper for endpoints whose backend wraps the payload in a `{ data, meta }`
120
+ * envelope. This is the UNIFORM convention across the Frihet `/v1` REST API:
121
+ * - single-object GET reads (`getResource` → `{ data: <item>, meta }`),
122
+ * - create/update mutations (201 / PUT / PATCH → `{ data: <resource>, meta }`,
123
+ * publicApi.ts response block), AND
124
+ * - action POSTs (`/invoices/:id/paid`, `/send`, `/credit-note`, deposit
125
+ * apply/refund, etc. → `{ data: <actionResult>, meta }`, publicApi.ts
126
+ * `actionResponse = { data: actionResult, meta }`).
121
127
  *
122
- * The Cloudflare Function returns `res.json({ data: <item>, meta: {...} })`
123
- * for single-object reads, so the raw HTTP body is the envelope NOT the
124
- * item. Passing that envelope straight into a tool's `structuredContent`
125
- * surfaces `{ data, meta }` instead of the modelo summary, breaking the
126
- * tool's output schema. This unwraps to `body.data`.
128
+ * Passing that envelope straight into a tool's `structuredContent` surfaces
129
+ * `{ data, meta }` instead of the resource/action result, breaking the tool's
130
+ * output schema (id/clientName/items/success all read as `undefined`). This
131
+ * unwraps to `body.data`. Every create/update/action mutation routes through
132
+ * here for exactly this reason; single-object reads (`getInvoice`/…) have since
133
+ * #64. `deleteX` methods deliberately keep `request` (they return `void` — the
134
+ * tool discards the body and synthesizes `{ success, id }`, so there is nothing
135
+ * to unwrap). Only unwraps a non-array-object `data` (see guard below), so an
136
+ * array-`data` list envelope and any non-enveloped body pass through unchanged.
127
137
  *
128
138
  * Only unwraps when the body is an object carrying a `data` property that is
129
139
  * itself a (non-array) object — i.e. a genuine single-object envelope. It is
@@ -174,13 +184,13 @@ export class FrihetClient {
174
184
  });
175
185
  }
176
186
  async getInvoice(id) {
177
- return this.request("GET", `/invoices/${encodeURIComponent(id)}`);
187
+ return this.requestUnwrapped("GET", `/invoices/${encodeURIComponent(id)}`);
178
188
  }
179
189
  async createInvoice(data) {
180
- return this.request("POST", "/invoices", data);
190
+ return this.requestUnwrapped("POST", "/invoices", data);
181
191
  }
182
192
  async updateInvoice(id, data) {
183
- return this.request("PATCH", `/invoices/${encodeURIComponent(id)}`, data);
193
+ return this.requestUnwrapped("PATCH", `/invoices/${encodeURIComponent(id)}`, data);
184
194
  }
185
195
  async deleteInvoice(id) {
186
196
  return this.request("DELETE", `/invoices/${encodeURIComponent(id)}`);
@@ -212,13 +222,13 @@ export class FrihetClient {
212
222
  });
213
223
  }
214
224
  async getExpense(id) {
215
- return this.request("GET", `/expenses/${encodeURIComponent(id)}`);
225
+ return this.requestUnwrapped("GET", `/expenses/${encodeURIComponent(id)}`);
216
226
  }
217
227
  async createExpense(data) {
218
- return this.request("POST", "/expenses", data);
228
+ return this.requestUnwrapped("POST", "/expenses", data);
219
229
  }
220
230
  async updateExpense(id, data) {
221
- return this.request("PATCH", `/expenses/${encodeURIComponent(id)}`, data);
231
+ return this.requestUnwrapped("PATCH", `/expenses/${encodeURIComponent(id)}`, data);
222
232
  }
223
233
  async deleteExpense(id) {
224
234
  return this.request("DELETE", `/expenses/${encodeURIComponent(id)}`);
@@ -236,13 +246,13 @@ export class FrihetClient {
236
246
  });
237
247
  }
238
248
  async getClient(id) {
239
- return this.request("GET", `/clients/${encodeURIComponent(id)}`);
249
+ return this.requestUnwrapped("GET", `/clients/${encodeURIComponent(id)}`);
240
250
  }
241
251
  async createClient(data) {
242
- return this.request("POST", "/clients", data);
252
+ return this.requestUnwrapped("POST", "/clients", data);
243
253
  }
244
254
  async updateClient(id, data) {
245
- return this.request("PATCH", `/clients/${encodeURIComponent(id)}`, data);
255
+ return this.requestUnwrapped("PATCH", `/clients/${encodeURIComponent(id)}`, data);
246
256
  }
247
257
  async deleteClient(id) {
248
258
  return this.request("DELETE", `/clients/${encodeURIComponent(id)}`);
@@ -260,13 +270,13 @@ export class FrihetClient {
260
270
  });
261
271
  }
262
272
  async getProduct(id) {
263
- return this.request("GET", `/products/${encodeURIComponent(id)}`);
273
+ return this.requestUnwrapped("GET", `/products/${encodeURIComponent(id)}`);
264
274
  }
265
275
  async createProduct(data) {
266
- return this.request("POST", "/products", data);
276
+ return this.requestUnwrapped("POST", "/products", data);
267
277
  }
268
278
  async updateProduct(id, data) {
269
- return this.request("PATCH", `/products/${encodeURIComponent(id)}`, data);
279
+ return this.requestUnwrapped("PATCH", `/products/${encodeURIComponent(id)}`, data);
270
280
  }
271
281
  async deleteProduct(id) {
272
282
  return this.request("DELETE", `/products/${encodeURIComponent(id)}`);
@@ -287,13 +297,13 @@ export class FrihetClient {
287
297
  });
288
298
  }
289
299
  async getQuote(id) {
290
- return this.request("GET", `/quotes/${encodeURIComponent(id)}`);
300
+ return this.requestUnwrapped("GET", `/quotes/${encodeURIComponent(id)}`);
291
301
  }
292
302
  async createQuote(data) {
293
- return this.request("POST", "/quotes", data);
303
+ return this.requestUnwrapped("POST", "/quotes", data);
294
304
  }
295
305
  async updateQuote(id, data) {
296
- return this.request("PATCH", `/quotes/${encodeURIComponent(id)}`, data);
306
+ return this.requestUnwrapped("PATCH", `/quotes/${encodeURIComponent(id)}`, data);
297
307
  }
298
308
  async deleteQuote(id) {
299
309
  return this.request("DELETE", `/quotes/${encodeURIComponent(id)}`);
@@ -310,13 +320,13 @@ export class FrihetClient {
310
320
  });
311
321
  }
312
322
  async getVendor(id) {
313
- return this.request("GET", `/vendors/${encodeURIComponent(id)}`);
323
+ return this.requestUnwrapped("GET", `/vendors/${encodeURIComponent(id)}`);
314
324
  }
315
325
  async createVendor(data) {
316
- return this.request("POST", "/vendors", data);
326
+ return this.requestUnwrapped("POST", "/vendors", data);
317
327
  }
318
328
  async updateVendor(id, data) {
319
- return this.request("PATCH", `/vendors/${encodeURIComponent(id)}`, data);
329
+ return this.requestUnwrapped("PATCH", `/vendors/${encodeURIComponent(id)}`, data);
320
330
  }
321
331
  async deleteVendor(id) {
322
332
  return this.request("DELETE", `/vendors/${encodeURIComponent(id)}`);
@@ -324,27 +334,32 @@ export class FrihetClient {
324
334
  // ---------------------------------------------------------------- Invoice Actions
325
335
  // ----------------------------------------------------------------
326
336
  async sendInvoice(id, to) {
327
- return this.request("POST", `/invoices/${encodeURIComponent(id)}/send`, to ? { to } : undefined);
337
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(id)}/send`, to ? { to } : undefined);
328
338
  }
329
339
  async markInvoicePaid(id, paidDate) {
330
- return this.request("POST", `/invoices/${encodeURIComponent(id)}/paid`, paidDate ? { paidDate } : undefined);
340
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(id)}/paid`, paidDate ? { paidDate } : undefined);
331
341
  }
332
342
  async getInvoicePdf(id) {
333
- return this.request("GET", `/invoices/${encodeURIComponent(id)}/pdf`);
343
+ // get_invoice_pdf's outputSchema (pdfResultOutput) expects the flat
344
+ // { id, url?, contentType? } item, same as every other single-object read.
345
+ return this.requestUnwrapped("GET", `/invoices/${encodeURIComponent(id)}/pdf`);
334
346
  }
335
347
  async getInvoiceEInvoice(invoiceId) {
336
- return this.request("GET", `/invoices/${encodeURIComponent(invoiceId)}/xml`);
348
+ // get_invoice_einvoice's outputSchema expects the flat { xml, filename, format }
349
+ // item. requestUnwrapped is a no-op if the body isn't an object envelope
350
+ // (e.g. a bare XML string), so this is safe either way.
351
+ return this.requestUnwrapped("GET", `/invoices/${encodeURIComponent(invoiceId)}/xml`);
337
352
  }
338
353
  async createCreditNote(invoiceId, data) {
339
- return this.request("POST", `/invoices/${encodeURIComponent(invoiceId)}/credit-note`, data);
354
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(invoiceId)}/credit-note`, data);
340
355
  }
341
356
  async applyLateFee(invoiceId, data) {
342
- return this.request("POST", `/invoices/${encodeURIComponent(invoiceId)}/late-fee`, data ?? {});
357
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(invoiceId)}/late-fee`, data ?? {});
343
358
  }
344
359
  // ---------------------------------------------------------------- Quote Actions
345
360
  // ----------------------------------------------------------------
346
361
  async sendQuote(id, to) {
347
- return this.request("POST", `/quotes/${encodeURIComponent(id)}/send`, to ? { to } : undefined);
362
+ return this.requestUnwrapped("POST", `/quotes/${encodeURIComponent(id)}/send`, to ? { to } : undefined);
348
363
  }
349
364
  // ---------------------------------------------------------------- Webhooks
350
365
  // ----------------------------------------------------------------
@@ -355,13 +370,13 @@ export class FrihetClient {
355
370
  });
356
371
  }
357
372
  async getWebhook(id) {
358
- return this.request("GET", `/webhooks/${encodeURIComponent(id)}`);
373
+ return this.requestUnwrapped("GET", `/webhooks/${encodeURIComponent(id)}`);
359
374
  }
360
375
  async createWebhook(data) {
361
- return this.request("POST", "/webhooks", data);
376
+ return this.requestUnwrapped("POST", "/webhooks", data);
362
377
  }
363
378
  async updateWebhook(id, data) {
364
- return this.request("PATCH", `/webhooks/${encodeURIComponent(id)}`, data);
379
+ return this.requestUnwrapped("PATCH", `/webhooks/${encodeURIComponent(id)}`, data);
365
380
  }
366
381
  async deleteWebhook(id) {
367
382
  return this.request("DELETE", `/webhooks/${encodeURIComponent(id)}`);
@@ -375,7 +390,7 @@ export class FrihetClient {
375
390
  });
376
391
  }
377
392
  async createClientContact(clientId, data) {
378
- return this.request("POST", `/clients/${encodeURIComponent(clientId)}/contacts`, data);
393
+ return this.requestUnwrapped("POST", `/clients/${encodeURIComponent(clientId)}/contacts`, data);
379
394
  }
380
395
  async deleteClientContact(clientId, contactId) {
381
396
  return this.request("DELETE", `/clients/${encodeURIComponent(clientId)}/contacts/${encodeURIComponent(contactId)}`);
@@ -389,7 +404,7 @@ export class FrihetClient {
389
404
  });
390
405
  }
391
406
  async logClientActivity(clientId, data) {
392
- return this.request("POST", `/clients/${encodeURIComponent(clientId)}/activities`, data);
407
+ return this.requestUnwrapped("POST", `/clients/${encodeURIComponent(clientId)}/activities`, data);
393
408
  }
394
409
  // ---------------------------------------------------------------- CRM: Notes
395
410
  // ----------------------------------------------------------------
@@ -400,7 +415,7 @@ export class FrihetClient {
400
415
  });
401
416
  }
402
417
  async createClientNote(clientId, data) {
403
- return this.request("POST", `/clients/${encodeURIComponent(clientId)}/notes`, data);
418
+ return this.requestUnwrapped("POST", `/clients/${encodeURIComponent(clientId)}/notes`, data);
404
419
  }
405
420
  async deleteClientNote(clientId, noteId) {
406
421
  return this.request("DELETE", `/clients/${encodeURIComponent(clientId)}/notes/${encodeURIComponent(noteId)}`);
@@ -420,36 +435,39 @@ export class FrihetClient {
420
435
  });
421
436
  }
422
437
  async getDeposit(id) {
423
- return this.request("GET", `/deposits/${encodeURIComponent(id)}`);
438
+ return this.requestUnwrapped("GET", `/deposits/${encodeURIComponent(id)}`);
424
439
  }
425
440
  async createDeposit(data) {
426
- return this.request("POST", "/deposits", data);
441
+ return this.requestUnwrapped("POST", "/deposits", data);
427
442
  }
428
443
  async updateDeposit(id, data) {
429
- return this.request("PATCH", `/deposits/${encodeURIComponent(id)}`, data);
444
+ return this.requestUnwrapped("PATCH", `/deposits/${encodeURIComponent(id)}`, data);
430
445
  }
431
446
  async deleteDeposit(id) {
432
447
  return this.request("DELETE", `/deposits/${encodeURIComponent(id)}`);
433
448
  }
434
449
  async applyDeposit(id, data) {
435
- return this.request("POST", `/deposits/${encodeURIComponent(id)}/apply`, data ?? {});
450
+ return this.requestUnwrapped("POST", `/deposits/${encodeURIComponent(id)}/apply`, data ?? {});
436
451
  }
437
452
  async refundDeposit(id, data) {
438
- return this.request("POST", `/deposits/${encodeURIComponent(id)}/refund`, data ?? {});
453
+ return this.requestUnwrapped("POST", `/deposits/${encodeURIComponent(id)}/refund`, data ?? {});
439
454
  }
440
455
  // ---------------------------------------------------------------- E-Invoicing
441
456
  // ----------------------------------------------------------------
442
457
  async sendEInvoice(params) {
443
- return this.request("POST", "/einvoice/send", params);
458
+ return this.requestUnwrapped("POST", "/einvoice/send", params);
444
459
  }
445
460
  async getEInvoiceStatus(workflowRunId) {
446
- return this.request("GET", `/einvoice/status/${encodeURIComponent(workflowRunId)}`);
461
+ // get_einvoice_status's outputSchema (eInvoiceStatusOutput) expects the
462
+ // flat status object, same single-object envelope convention as the rest
463
+ // of the /v1 REST surface.
464
+ return this.requestUnwrapped("GET", `/einvoice/status/${encodeURIComponent(workflowRunId)}`);
447
465
  }
448
466
  async validateEInvoiceXml(params) {
449
- return this.request("POST", "/einvoice/validate", params);
467
+ return this.requestUnwrapped("POST", "/einvoice/validate", params);
450
468
  }
451
469
  async exportDatev(params) {
452
- return this.request("POST", "/einvoice/export-datev", params);
470
+ return this.requestUnwrapped("POST", "/einvoice/export-datev", params);
453
471
  }
454
472
  // ---------------------------------------------------------------- E-Invoice Day 4 (PR #414 + FACe PR #411 + TicketBAI PR #356)
455
473
  // ----------------------------------------------------------------
@@ -457,18 +475,18 @@ export class FrihetClient {
457
475
  // 404 responses propagate to tool handlers which fall back to stub responses.
458
476
  async exportEInvoice(params) {
459
477
  const { invoiceId, ...body } = params;
460
- return this.request("POST", `/invoices/${encodeURIComponent(invoiceId)}/einvoice/export`, body);
478
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(invoiceId)}/einvoice/export`, body);
461
479
  }
462
480
  async faceSubmit(params) {
463
481
  const { invoiceId, mode } = params;
464
- return this.request("POST", `/invoices/${encodeURIComponent(invoiceId)}/face/submit`, { mode });
482
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(invoiceId)}/face/submit`, { mode });
465
483
  }
466
484
  async faceStatus(params) {
467
485
  return this.request("GET", `/invoices/${encodeURIComponent(params.invoiceId)}/face/status`);
468
486
  }
469
487
  async ticketbaiSubmit(params) {
470
488
  const { invoiceId, sandbox } = params;
471
- return this.request("POST", `/invoices/${encodeURIComponent(invoiceId)}/ticketbai/submit`, { sandbox });
489
+ return this.requestUnwrapped("POST", `/invoices/${encodeURIComponent(invoiceId)}/ticketbai/submit`, { sandbox });
472
490
  }
473
491
  async ticketbaiStatus(params) {
474
492
  return this.request("GET", `/invoices/${encodeURIComponent(params.invoiceId)}/ticketbai/status`);
@@ -492,10 +510,10 @@ export class FrihetClient {
492
510
  });
493
511
  }
494
512
  async getReservation(id) {
495
- return this.request("GET", `/stay/reservations/${encodeURIComponent(id)}`);
513
+ return this.requestUnwrapped("GET", `/stay/reservations/${encodeURIComponent(id)}`);
496
514
  }
497
515
  async createReservation(data) {
498
- return this.request("POST", "/stay/reservations", data);
516
+ return this.requestUnwrapped("POST", "/stay/reservations", data);
499
517
  }
500
518
  async listProperties(params) {
501
519
  return this.requestPaginated("GET", "/stay/properties", undefined, {
@@ -508,7 +526,7 @@ export class FrihetClient {
508
526
  });
509
527
  }
510
528
  async syncChannel(channelId, direction) {
511
- return this.request("POST", `/stay/channels/${encodeURIComponent(channelId)}/sync`, { direction });
529
+ return this.requestUnwrapped("POST", `/stay/channels/${encodeURIComponent(channelId)}/sync`, { direction });
512
530
  }
513
531
  // ---------------------------------------------------------------- POS (Point of Sale)
514
532
  // ----------------------------------------------------------------
@@ -521,7 +539,7 @@ export class FrihetClient {
521
539
  });
522
540
  }
523
541
  async getSale(id) {
524
- return this.request("GET", `/pos/sales/${encodeURIComponent(id)}`);
542
+ return this.requestUnwrapped("GET", `/pos/sales/${encodeURIComponent(id)}`);
525
543
  }
526
544
  async listSales(params) {
527
545
  return this.requestPaginated("GET", "/pos/sales", undefined, {
@@ -535,7 +553,7 @@ export class FrihetClient {
535
553
  });
536
554
  }
537
555
  async refundSale(id, data) {
538
- return this.request("POST", `/pos/sales/${encodeURIComponent(id)}/refund`, data ?? {});
556
+ return this.requestUnwrapped("POST", `/pos/sales/${encodeURIComponent(id)}/refund`, data ?? {});
539
557
  }
540
558
  // ---------------------------------------------------------------- Kitchen (KDS)
541
559
  // ----------------------------------------------------------------
@@ -550,10 +568,10 @@ export class FrihetClient {
550
568
  });
551
569
  }
552
570
  async getKitchenTicket(id) {
553
- return this.request("GET", `/kitchen/tickets/${encodeURIComponent(id)}`);
571
+ return this.requestUnwrapped("GET", `/kitchen/tickets/${encodeURIComponent(id)}`);
554
572
  }
555
573
  async updateKitchenTicket(id, data) {
556
- return this.request("PATCH", `/kitchen/tickets/${encodeURIComponent(id)}`, data);
574
+ return this.requestUnwrapped("PATCH", `/kitchen/tickets/${encodeURIComponent(id)}`, data);
557
575
  }
558
576
  async listKitchenStations(params) {
559
577
  return this.requestPaginated("GET", "/kitchen/stations", undefined, {
@@ -596,7 +614,7 @@ export class FrihetClient {
596
614
  });
597
615
  }
598
616
  async getBankAccount(id) {
599
- return this.request("GET", `/banking/accounts/${encodeURIComponent(id)}`);
617
+ return this.requestUnwrapped("GET", `/banking/accounts/${encodeURIComponent(id)}`);
600
618
  }
601
619
  async listTransactions(params) {
602
620
  return this.requestPaginated("GET", "/banking/transactions", undefined, {
@@ -611,10 +629,10 @@ export class FrihetClient {
611
629
  });
612
630
  }
613
631
  async categorizeTransaction(id, data) {
614
- return this.request("PATCH", `/banking/transactions/${encodeURIComponent(id)}/categorize`, data);
632
+ return this.requestUnwrapped("PATCH", `/banking/transactions/${encodeURIComponent(id)}/categorize`, data);
615
633
  }
616
634
  async matchTransactionToDocument(transactionId, data) {
617
- return this.request("POST", `/banking/transactions/${encodeURIComponent(transactionId)}/match`, data);
635
+ return this.requestUnwrapped("POST", `/banking/transactions/${encodeURIComponent(transactionId)}/match`, data);
618
636
  }
619
637
  // ---------------------------------------------------------------- Fiscal
620
638
  // RESOLVED (was: "planned — 404 propagates until backend ships"). The
@@ -631,10 +649,10 @@ export class FrihetClient {
631
649
  });
632
650
  }
633
651
  async getVerifactuStatus(invoiceId) {
634
- return this.request("GET", `/fiscal/verifactu/${encodeURIComponent(invoiceId)}/status`);
652
+ return this.requestUnwrapped("GET", `/fiscal/verifactu/${encodeURIComponent(invoiceId)}/status`);
635
653
  }
636
654
  async resubmitVerifactu(invoiceId) {
637
- return this.request("POST", `/fiscal/verifactu/${encodeURIComponent(invoiceId)}/resubmit`, {});
655
+ return this.requestUnwrapped("POST", `/fiscal/verifactu/${encodeURIComponent(invoiceId)}/resubmit`, {});
638
656
  }
639
657
  async getTicketbaiStatus(invoiceId) {
640
658
  return this.request("GET", `/fiscal/ticketbai/${encodeURIComponent(invoiceId)}/status`);
@@ -654,19 +672,19 @@ export class FrihetClient {
654
672
  });
655
673
  }
656
674
  async getTimeEntry(id) {
657
- return this.request("GET", `/time/entries/${encodeURIComponent(id)}`);
675
+ return this.requestUnwrapped("GET", `/time/entries/${encodeURIComponent(id)}`);
658
676
  }
659
677
  async createTimeEntry(data) {
660
- return this.request("POST", "/time/entries", data);
678
+ return this.requestUnwrapped("POST", "/time/entries", data);
661
679
  }
662
680
  async updateTimeEntry(id, data) {
663
- return this.request("PATCH", `/time/entries/${encodeURIComponent(id)}`, data);
681
+ return this.requestUnwrapped("PATCH", `/time/entries/${encodeURIComponent(id)}`, data);
664
682
  }
665
683
  async deleteTimeEntry(id) {
666
684
  return this.request("DELETE", `/time/entries/${encodeURIComponent(id)}`);
667
685
  }
668
686
  async getTimeSummary(params) {
669
- return this.request("GET", "/time/summary", undefined, {
687
+ return this.requestUnwrapped("GET", "/time/summary", undefined, {
670
688
  from: params.from,
671
689
  to: params.to,
672
690
  userId: params?.userId,
@@ -684,25 +702,25 @@ export class FrihetClient {
684
702
  });
685
703
  }
686
704
  async getRecurringInvoice(id) {
687
- return this.request("GET", `/recurring/invoices/${encodeURIComponent(id)}`);
705
+ return this.requestUnwrapped("GET", `/recurring/invoices/${encodeURIComponent(id)}`);
688
706
  }
689
707
  async createRecurringInvoice(data) {
690
- return this.request("POST", "/recurring/invoices", data);
708
+ return this.requestUnwrapped("POST", "/recurring/invoices", data);
691
709
  }
692
710
  async updateRecurringInvoice(id, data) {
693
- return this.request("PATCH", `/recurring/invoices/${encodeURIComponent(id)}`, data);
711
+ return this.requestUnwrapped("PATCH", `/recurring/invoices/${encodeURIComponent(id)}`, data);
694
712
  }
695
713
  async pauseRecurringInvoice(id) {
696
- return this.request("POST", `/recurring/invoices/${encodeURIComponent(id)}/pause`, {});
714
+ return this.requestUnwrapped("POST", `/recurring/invoices/${encodeURIComponent(id)}/pause`, {});
697
715
  }
698
716
  async resumeRecurringInvoice(id) {
699
- return this.request("POST", `/recurring/invoices/${encodeURIComponent(id)}/resume`, {});
717
+ return this.requestUnwrapped("POST", `/recurring/invoices/${encodeURIComponent(id)}/resume`, {});
700
718
  }
701
719
  async deleteRecurringInvoice(id) {
702
720
  return this.request("DELETE", `/recurring/invoices/${encodeURIComponent(id)}`);
703
721
  }
704
722
  async runRecurringNow(templateId, options) {
705
- return this.request("POST", `/recurring/invoices/${encodeURIComponent(templateId)}/run`, {
723
+ return this.requestUnwrapped("POST", `/recurring/invoices/${encodeURIComponent(templateId)}/run`, {
706
724
  draftOnly: options?.draftOnly ?? true,
707
725
  });
708
726
  }
@@ -717,10 +735,10 @@ export class FrihetClient {
717
735
  });
718
736
  }
719
737
  async inviteTeamMember(data) {
720
- return this.request("POST", "/team/members/invite", data);
738
+ return this.requestUnwrapped("POST", "/team/members/invite", data);
721
739
  }
722
740
  async updateTeamMemberRole(memberId, role) {
723
- return this.request("PATCH", `/team/members/${encodeURIComponent(memberId)}/role`, { role });
741
+ return this.requestUnwrapped("PATCH", `/team/members/${encodeURIComponent(memberId)}/role`, { role });
724
742
  }
725
743
  async removeTeamMember(memberId) {
726
744
  return this.request("DELETE", `/team/members/${encodeURIComponent(memberId)}`);
@@ -731,7 +749,7 @@ export class FrihetClient {
731
749
  // #385 contextual messaging. REST shell proxies the callables + Firestore reads.
732
750
  // Tools surface 404 until backend ships.
733
751
  async sendGestoriaMessage(data) {
734
- return this.request("POST", "/gestoria/messages", data);
752
+ return this.requestUnwrapped("POST", "/gestoria/messages", data);
735
753
  }
736
754
  async listGestoriaMessages(params) {
737
755
  return this.request("GET", "/gestoria/messages", undefined, {
@@ -743,10 +761,10 @@ export class FrihetClient {
743
761
  });
744
762
  }
745
763
  async createGestoriaTemplate(data) {
746
- return this.request("POST", "/gestoria/templates", data);
764
+ return this.requestUnwrapped("POST", "/gestoria/templates", data);
747
765
  }
748
766
  async bulkSendGestoriaTemplate(data) {
749
- return this.request("POST", "/gestoria/templates/bulk-send", data);
767
+ return this.requestUnwrapped("POST", "/gestoria/templates/bulk-send", data);
750
768
  }
751
769
  async getGestoriaAgingConsolidated(params) {
752
770
  return this.request("GET", "/gestoria/aging/consolidated", undefined, {
@@ -756,10 +774,10 @@ export class FrihetClient {
756
774
  // ---------------------------------------------------------------- Audit GL
757
775
  // NOTE: /v1/gl/* endpoints proxy Firebase callables (PR #395). 404 until REST shell ships.
758
776
  async approveGLEntry(entryId, notes) {
759
- return this.request("POST", `/gl/entries/${encodeURIComponent(entryId)}/approve`, { notes });
777
+ return this.requestUnwrapped("POST", `/gl/entries/${encodeURIComponent(entryId)}/approve`, { notes });
760
778
  }
761
779
  async rejectGLEntry(entryId, reason) {
762
- return this.request("POST", `/gl/entries/${encodeURIComponent(entryId)}/reject`, { reason });
780
+ return this.requestUnwrapped("POST", `/gl/entries/${encodeURIComponent(entryId)}/reject`, { reason });
763
781
  }
764
782
  async getGLEntryAuditLog(entryId) {
765
783
  return this.request("GET", `/gl/entries/${encodeURIComponent(entryId)}/audit-log`);
@@ -767,10 +785,10 @@ export class FrihetClient {
767
785
  // ---------------------------------------------------------------- White-label Portal Domain
768
786
  // NOTE: /v1/portal/domain/* endpoints proxy Firebase callables (PR #397). 404 until REST shell ships.
769
787
  async addCustomPortalDomain(data) {
770
- return this.request("POST", "/portal/domain", data);
788
+ return this.requestUnwrapped("POST", "/portal/domain", data);
771
789
  }
772
790
  async verifyCustomPortalDomain(data) {
773
- return this.request("POST", `/portal/domain/${encodeURIComponent(data.domain)}/verify`, {});
791
+ return this.requestUnwrapped("POST", `/portal/domain/${encodeURIComponent(data.domain)}/verify`, {});
774
792
  }
775
793
  async removeCustomPortalDomain(data) {
776
794
  return this.request("DELETE", `/portal/domain/${encodeURIComponent(data.domain)}`);
@@ -778,7 +796,7 @@ export class FrihetClient {
778
796
  // ---------------------------------------------------------------- Self-onboard + VIES
779
797
  // NOTE: /v1/portal/onboard/* endpoints proxy Firebase callables (PR #398). 404 until REST shell ships.
780
798
  async generatePortalOnboardLink(data) {
781
- return this.request("POST", "/portal/onboard/link", data);
799
+ return this.requestUnwrapped("POST", "/portal/onboard/link", data);
782
800
  }
783
801
  async lookupTaxIdViaVIES(data) {
784
802
  return this.request("GET", "/tax/vies/lookup", undefined, {
@@ -795,7 +813,7 @@ export class FrihetClient {
795
813
  });
796
814
  }
797
815
  async calculateAiem(data) {
798
- return this.request("POST", "/igic/aiem/calculate", data);
816
+ return this.requestUnwrapped("POST", "/igic/aiem/calculate", data);
799
817
  }
800
818
  // ---------------------------------------------------------------- Impuesto Sociedades (IS)
801
819
  // NOTE: /v1/is/* endpoints (PR #392). 404 until REST shell ships.
@@ -815,7 +833,7 @@ export class FrihetClient {
815
833
  });
816
834
  }
817
835
  async createBankRule(data) {
818
- return this.request("POST", "/banking/rules", data);
836
+ return this.requestUnwrapped("POST", "/banking/rules", data);
819
837
  }
820
838
  // ---------------------------------------------------------------- HR (Leaves + Attendance + Anomalies)
821
839
  // NOTE: /v1/leaves, /v1/time-entries, /v1/anomalies — D4-A parallel deploy. 404 propagates until backend ships.
@@ -831,22 +849,22 @@ export class FrihetClient {
831
849
  });
832
850
  }
833
851
  async createLeaveRequest(data) {
834
- return this.request("POST", "/leaves", data);
852
+ return this.requestUnwrapped("POST", "/leaves", data);
835
853
  }
836
854
  async approveLeave(leaveId, data) {
837
- return this.request("POST", `/leaves/${encodeURIComponent(leaveId)}/approve`, data ?? {});
855
+ return this.requestUnwrapped("POST", `/leaves/${encodeURIComponent(leaveId)}/approve`, data ?? {});
838
856
  }
839
857
  async rejectLeave(leaveId, data) {
840
- return this.request("POST", `/leaves/${encodeURIComponent(leaveId)}/reject`, data);
858
+ return this.requestUnwrapped("POST", `/leaves/${encodeURIComponent(leaveId)}/reject`, data);
841
859
  }
842
860
  async cancelLeave(leaveId) {
843
- return this.request("POST", `/leaves/${encodeURIComponent(leaveId)}/cancel`, {});
861
+ return this.requestUnwrapped("POST", `/leaves/${encodeURIComponent(leaveId)}/cancel`, {});
844
862
  }
845
863
  async attendanceClockIn(data) {
846
- return this.request("POST", "/time-entries/clock-in", data);
864
+ return this.requestUnwrapped("POST", "/time-entries/clock-in", data);
847
865
  }
848
866
  async attendanceClockOut(entryId) {
849
- return this.request("PATCH", `/time-entries/${encodeURIComponent(entryId)}/clock-out`, {});
867
+ return this.requestUnwrapped("PATCH", `/time-entries/${encodeURIComponent(entryId)}/clock-out`, {});
850
868
  }
851
869
  async getOvertimeReport(params) {
852
870
  return this.request("GET", "/time-entries/overtime", undefined, {
@@ -867,7 +885,7 @@ export class FrihetClient {
867
885
  // ---------------------------------------------------------------- Webhook Trust-Area Extensions
868
886
  // NOTE: /v1/webhooks/:id/test — D4-A parallel deploy. 404 propagates until backend ships.
869
887
  async testWebhook(id, data) {
870
- return this.request("POST", `/webhooks/${encodeURIComponent(id)}/test`, data ?? {});
888
+ return this.requestUnwrapped("POST", `/webhooks/${encodeURIComponent(id)}/test`, data ?? {});
871
889
  }
872
890
  // ---------------------------------------------------------------- Payroll
873
891
  // NOTE: /v1/payroll/prep/* — D4-A parallel deploy. 404 propagates until backend ships.
@@ -888,7 +906,7 @@ export class FrihetClient {
888
906
  return this.request("GET", "/onboarding/status");
889
907
  }
890
908
  async setOnboardingPersona(data) {
891
- return this.request("PATCH", "/onboarding/persona", data);
909
+ return this.requestUnwrapped("PATCH", "/onboarding/persona", data);
892
910
  }
893
911
  // ---------------------------------------------------------------- Permissions
894
912
  // NOTE: /v1/permissions/* — D4-A parallel deploy. 404 propagates until backend ships.
@@ -907,10 +925,10 @@ export class FrihetClient {
907
925
  return this.request("GET", "/periods/current");
908
926
  }
909
927
  async closePeriod(data) {
910
- return this.request("POST", "/periods/close", data);
928
+ return this.requestUnwrapped("POST", "/periods/close", data);
911
929
  }
912
930
  async reopenPeriod(data) {
913
- return this.request("POST", `/periods/${encodeURIComponent(data.periodId)}/reopen`, { reason: data.reason });
931
+ return this.requestUnwrapped("POST", `/periods/${encodeURIComponent(data.periodId)}/reopen`, { reason: data.reason });
914
932
  }
915
933
  }
916
934
  //# sourceMappingURL=client.js.map