/** * @peac/mappings-acp * * Agentic Commerce Protocol (ACP) integration for PEAC. * Maps ACP checkout events to PEAC receipts and carries evidence via HTTP headers. */ import { type PaymentEvidence } from '@peac/schema'; import { type StrictnessMode } from '@peac/adapter-core'; export * from './budget'; export type { HeaderMap, AcpMessageLike, AcpExtractResult, AcpExtractAsyncResult } from './carrier'; export { ACP_CARRIER_LIMITS, attachCarrierToACPHeaders, attachCarrierToACPMessage, extractCarrierFromACPHeaders, extractCarrierFromACPHeadersAsync, AcpCarrierAdapter, } from './carrier'; /** * ACP Checkout Success Event. * * Carrier-shape input for an ACP checkout-success observation. The amount is * a base-10 integer string in the smallest currency unit (e.g. "9999" for * $99.99) to preserve precision above Number.MAX_SAFE_INTEGER. The * environment is asserted by upstream and never silently defaulted. */ export interface ACPCheckoutSuccess { checkout_id: string; resource_uri: string; /** * Amount in smallest currency unit as a base-10 integer string. * Validated against the shared AmountMinorStringSchema and must be * non-negative. Decimals, empty strings, and numeric values are rejected. */ amount_minor: string; currency: string; payment_rail: string; payment_reference: string; /** Environment as asserted by upstream. Required: no silent default. */ env: 'live' | 'test'; customer_id?: string; metadata?: Record; } /** * Optional knobs for fromACPCheckoutSuccess. Mode controls the * mapper-boundary finality-synthesis guard (default `interop`). */ export interface ACPCheckoutSuccessOptions { mode?: StrictnessMode; warn?: (message: string) => void; } /** * Stable error codes emitted by ACP mapper validation. Callers MAY switch * on `code` to discriminate without parsing message text. Distinct from * `@peac/adapter-core` MapperBoundaryError codes (which carry the finality- * synthesis code only); kept local to avoid widening the adapter-core enum * for ACP-specific validation concerns. */ export type ACPMapperBoundaryErrorCode = 'acp.checkout_invalid_event' | 'acp.checkout_missing_checkout_id' | 'acp.checkout_invalid_resource_uri' | 'acp.checkout_legacy_total_amount' | 'acp.checkout_invalid_amount_minor' | 'acp.checkout_unsafe_amount_minor' | 'acp.checkout_invalid_currency' | 'acp.checkout_missing_payment_rail' | 'acp.checkout_missing_payment_reference' | 'acp.checkout_missing_env' | 'acp.checkout_invalid_env'; export interface ACPMapperBoundaryErrorInit { code: ACPMapperBoundaryErrorCode; field: string; message: string; } /** * Structured validation error thrown by ACP mapper input checks. Carries a * stable `code` and `field` so callers can discriminate programmatically. */ export declare class ACPMapperBoundaryError extends Error { readonly code: ACPMapperBoundaryErrorCode; readonly field: string; constructor(init: ACPMapperBoundaryErrorInit); } /** * PEAC Receipt Input (for issue()) */ export interface PEACReceiptInput { subject_uri: string; amt: number; cur: string; payment: PaymentEvidence; } /** * Convert ACP checkout success event to PEAC receipt input. * * Observational mapping only. fromACPCheckoutSuccess does NOT synthesize * commerce finality: a checkout-success observation alone does not prove * authorization, capture, settlement, refund, void, or chargeback. The * mapper records checkout/payment evidence only; no `commerce_event`, * `settlement_state`, `capture_state`, or `authorization_state` is emitted. * Callers that have an explicit payment-bearing artifact should route * through fromACPDelegatedPaymentObservation or fromACPPaymentObservation * instead. * * Validation errors are thrown as ACPMapperBoundaryError with stable * `code` and `field` so callers can discriminate programmatically. * * @param event - ACP checkout success event * @param options - Optional strictness mode + warn sink * @returns PEAC receipt input ready for issue() */ export declare function fromACPCheckoutSuccess(event: ACPCheckoutSuccess, options?: ACPCheckoutSuccessOptions): PEACReceiptInput; /** * Attach PEAC receipt to ACP response * * @param response - ACP response object * @param receiptJWS - PEAC receipt JWS * @returns ACP response with PEAC receipt attached */ export declare function attachReceiptToACPResponse>(response: T, receiptJWS: string): T & { peac_receipt: string; }; /** * Extract PEAC receipt from ACP response * * @param response - ACP response object * @returns PEAC receipt JWS or null if not present */ export declare function extractReceiptFromACPResponse(response: Record): string | null; export type { ACPSessionState, ACPSessionEvent, ObservedPaymentState, ACPPaymentArtifact, ACPCapabilityNegotiation, ACPIntervention, SessionReceiptInput, } from './session.js'; export { fromACPSessionLifecycleEvent, fromACPPaymentObservation, fromACPCapabilitySnapshot, fromACPInterventionRequired, } from './session.js'; export type { DelegatedPaymentState, ACPDelegatedPaymentObservation, ACPDelegatedPaymentOptions, } from './session.js'; export { fromACPDelegatedPaymentObservation } from './session.js'; //# sourceMappingURL=index.d.ts.map