/** * Mapper-boundary finality-synthesis guard. * * Commerce mappings preserve raw upstream artifacts and MUST NOT synthesize * payment finality (authorization, capture, settlement, refund, void, * chargeback) from non-payment artifacts or lifecycle states alone. * * This module provides the runtime guard that callers in commerce mappings * use to enforce that rule at the mapper boundary. It is deliberately * dependency-light and emits a stable string code via MapperBoundaryError * rather than registering a new wire-level error code. */ /** * Strictness mode for commerce mappers. * * - `strict` - reject any synthesis attempt; reject silent fallbacks * (currency='UNKNOWN', defaulted env). * - `interop` - emit a deprecation warning instead of rejecting; preserves * current consumer behavior. Default. * - `legacy` - preserve historical behavior with no warning. Reserved for * callers that have migration plans recorded elsewhere. */ export type StrictnessMode = 'strict' | 'interop' | 'legacy'; /** * Stable string identifier for the mapper-boundary finality-synthesis * violation. NOT a wire-level error code; consumers may switch on this * value to map to caller-specific error reporting. */ export declare const COMMERCE_FINALITY_SYNTHESIS_CODE: "commerce.finality_synthesis_blocked"; export type MapperBoundaryErrorCode = typeof COMMERCE_FINALITY_SYNTHESIS_CODE; export interface MapperBoundaryErrorInit { code: MapperBoundaryErrorCode; pointer?: string; upstreamArtifactHash?: string; reason?: string; } /** * Error thrown by mapper-boundary guards. Plain class, no schema dependency. * Carries a stable `code` and optional pointer + upstream-artifact-hash * fields to help callers correlate the failure. */ export declare class MapperBoundaryError extends Error { readonly code: MapperBoundaryErrorCode; readonly pointer?: string; readonly upstreamArtifactHash?: string; constructor(init: MapperBoundaryErrorInit); } export type CommerceFinalityEvent = 'authorization' | 'capture' | 'settlement' | 'refund' | 'void' | 'chargeback'; export interface FinalityGuardInput { /** * The candidate commerce `event` value (or `undefined` if unset). When * unset, the guard is a no-op. */ event?: string | undefined; /** * Whether the upstream artifact explicitly proves the claimed finality. * Mappers MUST set this from a definite read of upstream-supplied data, * NOT from inferred lifecycle state. */ hasExplicitUpstreamArtifact: boolean; /** * The currency code as read from upstream. Mappers MUST set this; callers * MUST NOT silently fall back to `'UNKNOWN'`. In strict mode, an empty, * `'UNKNOWN'`, or non-string value rejects. */ currency?: string; /** * The environment discriminant as read from upstream. Mappers MUST set * this when known; callers MUST NOT silently default. In strict mode, an * unset or non-`live`/`test` value rejects. */ env?: 'live' | 'test' | string | undefined; /** * Whether the env was explicitly asserted by upstream (vs defaulted). */ envExplicit?: boolean; } export interface FinalityGuardOptions { mode?: StrictnessMode; pointer?: string; upstreamArtifactHash?: string; /** * Optional warning sink for `interop` mode. Defaults to a no-op. */ warn?: (message: string) => void; } /** * Mapper-boundary finality-synthesis guard. * * Throws `MapperBoundaryError` when: * - `event` is one of the finality-bearing values AND * `hasExplicitUpstreamArtifact` is false (any mode). * - `currency` is missing, empty, or `'UNKNOWN'` and mode is `strict`. * - `env` is missing or `envExplicit` is false and mode is `strict`. * * In `interop` mode, the second and third conditions emit a warning via * the supplied `warn` sink instead of throwing. In `legacy` mode, only * the first condition throws; the second and third are silent. * * No-ops when `event` is unset (the common discovery / capability path). */ export declare function assertExplicitFinality(input: FinalityGuardInput, options?: FinalityGuardOptions): void; /** * Returns whether the given event is one of the finality-bearing commerce * events. Useful for callers that want to short-circuit before assembling * full guard input. */ export declare function isFinalityEvent(event: string | undefined): event is CommerceFinalityEvent; //# sourceMappingURL=finality.d.ts.map