/** * E-Invoicing tools for the Frihet MCP server. * * Wired to real CF endpoints at api.frihet.io/v1/invoices/:id/einvoice/*. * * The 5 per-invoice endpoints below are LIVE server-side (Frihet-ERP publicApi.ts): * einvoice/export, face/submit, face/status, ticketbai/submit, ticketbai/status. * On a successful fetch the tools return the real CF response unchanged. * * COMPLIANCE-CRITICAL 404-fallback contract: the stub is dispatched ONLY when the * CF returns a genuine 404 (jurisdiction without a deployed CF / endpoint not yet * shipped). Any other failure — 4xx auth/validation, 5xx signature/submission * error, network error — is RE-THROWN by isNotFoundError()=false and surfaced as a * tool error. A real FACe/TicketBAI signature or submission failure MUST NEVER be * masked as a successful (queued/accepted) stub. * * All 10 tools use the shared withToolLogging wrapper (Langfuse tracing applied * globally via patchServerWithTracing in register-all.ts). * * Trace names prefix: mcp.einvoice.* * Original 4 CF endpoints: https://api.frihet.io/v1/einvoice/{send,status,validate,export-datev} * Day 4 Wave 6 CF endpoints (PR #414 + FACe PR #411 + TicketBAI PR #356) — LIVE: * POST /v1/invoices/:id/einvoice/export — export XML in specific format (signed Facturae etc.) * POST /v1/invoices/:id/face/submit — Spain B2G FACe portal submission * GET /v1/invoices/:id/face/status — FACe submission status * POST /v1/invoices/:id/ticketbai/submit — Basque Country TicketBAI (Bizkaia/Gipuzkoa/Araba) * GET /v1/invoices/:id/ticketbai/status — TicketBAI submission status * POST /v1/invoices/:id/ksef/submit — Poland KSeF (stub — endpoint not yet exposed; returns unavailable) */ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod/v4"; import type { IFrihetClient } from "../client-interface.js"; /** * All supported e-invoice formats. * * | Format | Standard | Markets | Notes | * |-------------------------|-----------|--------------------------|---------------------------------------------------| * | xrechnung-cii | EN16931 | Germany (DE mandatory) | CII syntax, official DE B2G format | * | xrechnung-ubl | EN16931 | Germany (DE mandatory) | UBL 2.1 syntax, alternative DE B2G | * | facturx-en16931 | EN16931 | France, EU | PDF/A-3 embedded XML, Factur-X EN16931 profile | * | facturx-extended | EN16931+ | France, EU | Factur-X Extended — extra logistics/trade fields | * | facturx-basic | EN16931 | France, EU | Factur-X Basic — reduced field set | * | facturx-minimum | EN16931 | France, EU | Factur-X Minimum — summary invoices only | * | fatturapa | SDI | Italy (IT mandatory) | XML FatturaPA — sent via SDI interchange hub | * | ubl | UBL 2.1 | EU/global | Generic UBL — use when no country-specific needed | * | cii | UN/CEFACT | EU/global | Generic CII — Cross Industry Invoice XML | * | peppol-bis-3 | PEPPOL | EU/Nordic/AU/SG | PEPPOL BIS Billing 3.0 — B2B/B2G network | * | facturae | Facturae | Spain (ES B2G mandatory) | Facturae 3.2.x — AEAT/FACe submission | */ export declare const eInvoiceFormatSchema: z.ZodEnum<{ "xrechnung-cii": "xrechnung-cii"; "xrechnung-ubl": "xrechnung-ubl"; "facturx-en16931": "facturx-en16931"; "facturx-extended": "facturx-extended"; "facturx-basic": "facturx-basic"; "facturx-minimum": "facturx-minimum"; fatturapa: "fatturapa"; ubl: "ubl"; cii: "cii"; "peppol-bis-3": "peppol-bis-3"; facturae: "facturae"; }>; export type EInvoiceFormat = z.infer; export declare const sendEInvoiceOutput: z.ZodObject<{ workflowRunId: z.ZodString; status: z.ZodLiteral<"queued">; estimatedCompletionSec: z.ZodNumber; }, z.core.$loose>; export declare const eInvoiceStatusOutput: z.ZodObject<{ status: z.ZodEnum<{ queued: "queued"; running: "running"; succeeded: "succeeded"; failed: "failed"; cancelled: "cancelled"; }>; step: z.ZodString; error: z.ZodOptional; ackId: z.ZodOptional; pdfA3Url: z.ZodOptional; xmlUrl: z.ZodOptional; }, z.core.$loose>; export declare const validateEInvoiceOutput: z.ZodObject<{ valid: z.ZodBoolean; errors: z.ZodArray>; validator: z.ZodEnum<{ kosit: "kosit"; mustang: "mustang"; xsd: "xsd"; schematron: "schematron"; }>; durationMs: z.ZodNumber; }, z.core.$loose>; export declare const exportDatevOutput: z.ZodObject<{ fileUrl: z.ZodString; filename: z.ZodString; rowCount: z.ZodNumber; fiscalPeriod: z.ZodString; encoding: z.ZodLiteral<"cp1252">; }, z.core.$loose>; export declare const einvoiceExportOutput: z.ZodObject<{ xml: z.ZodString; contentType: z.ZodString; filename: z.ZodString; signed: z.ZodBoolean; format: z.ZodString; }, z.core.$loose>; export declare const faceSubmitOutput: z.ZodObject<{ status: z.ZodLiteral<"submitted">; numeroRegistro: z.ZodString; codigo: z.ZodString; descripcion: z.ZodString; idempotent: z.ZodOptional; }, z.core.$loose>; export declare const faceStatusOutput: z.ZodObject<{ numeroRegistro: z.ZodString; estadoTramitacion: z.ZodNullable; codigo: z.ZodNullable; descripcion: z.ZodNullable; motivo: z.ZodNullable; }, z.core.$loose>; export declare const ticketbaiSubmitOutput: z.ZodObject<{ accepted: z.ZodBoolean; csv: z.ZodString; tbaiIdentifier: z.ZodString; qrUrl: z.ZodString; idempotent: z.ZodOptional; }, z.core.$loose>; export declare const ticketbaiStatusOutput: z.ZodObject<{ accepted: z.ZodBoolean; csv: z.ZodString; tbaiIdentifier: z.ZodString; estado: z.ZodString; qrUrl: z.ZodNullable; submittedAt: z.ZodNullable; errors: z.ZodNullable>; }, z.core.$loose>; export declare const kSeFSubmitOutput: z.ZodObject<{ _notImplemented: z.ZodOptional; _note: z.ZodOptional; _plannedEndpoint: z.ZodOptional; invoiceId: z.ZodOptional; mode: z.ZodOptional; }, z.core.$loose>; export declare function registerEInvoiceTools(server: McpServer, _client: IFrihetClient): void; //# sourceMappingURL=einvoice.d.ts.map