/** * Field-level guards for the durable application command mailbox (WFT-84). * * The generic checks — identities, durable JSON metadata, clock readings, * generated identifiers, derived instants, wait budgets — live in * `application-primitive-guards.ts` and are bound here to the mailbox's own * validation error class, so a mailbox caller always sees * `ApplicationCommandValidationError`. What remains here is what only the * mailbox validates: its backlog and listing ceilings, a claimant's rejection, * and a cancellation reason. * * Everything here is re-exported from `mailbox-validation.ts`, so * mailbox callers keep one import path. * * @module core/mailbox-guards */ import type { ApplicationCommandRejection } from './mailbox-contract.ts'; import type { ApplicationCommandFailure } from './mailbox-types.ts'; import { WeftError } from './weft-error.ts'; export { byteLengthOf, DEFAULT_WAIT_POLL_INTERVAL_MS, isWellFormedString, MAX_APPLICATION_IDENTITY_BYTES, MAX_DURABLE_METADATA_BYTES, MAX_TIMER_DELAY_MS, } from './application-primitive-guards.ts'; /** Maximum bytes in an idempotency key. */ export declare const MAX_APPLICATION_IDEMPOTENCY_KEY_BYTES = 256; /** Maximum bytes in a content-addressed payload reference. */ export { MAX_APPLICATION_PAYLOAD_REFERENCE_BYTES } from './application-primitive-payload.ts'; /** Maximum claims allowed for one command. */ export declare const MAX_APPLICATION_COMMAND_ATTEMPTS = 100; /** Maximum open commands a mailbox may be configured to hold. */ export declare const MAX_MAILBOX_BACKLOG = 1000000; /** Maximum receipts one `list()` call may return. */ export declare const MAX_MAILBOX_LIST_LIMIT = 1000; /** Maximum bytes in a caller-supplied failure message. */ export declare const MAX_FAILURE_MESSAGE_BYTES = 2048; /** Maximum bytes in a caller-supplied cancellation reason. */ export declare const MAX_CANCELLATION_REASON_BYTES = 2048; /** * Thrown when a caller hands the mailbox something it cannot admit: a missing * or oversized identity component, an unusable payload, or an out-of-range * policy value. * * This is a caller mistake, not an expected outcome — a full backlog and an * idempotency conflict are returned as discriminated results instead. * * @example * ```ts * import { ApplicationCommandValidationError } from '@lostgradient/weft'; * * const error = new ApplicationCommandValidationError('caller must be a non-empty string.'); * console.log(error.code); // 'ApplicationCommandValidationError' * ``` */ export declare class ApplicationCommandValidationError extends WeftError<'ApplicationCommandValidationError'> { constructor(message: string, options?: ErrorOptions); } export declare const requireIdentity: (value: unknown, field: string, maxBytes: number) => string, optionalIdentityOf: (value: unknown, field: string, maxBytes: number) => string | undefined, requirePositiveInteger: (value: unknown, field: string, maximum: number) => number, requireNonNegativeInteger: (value: unknown, field: string, maximum: number) => number, validateDurableJSONValue: (value: unknown, field: string) => import("./json.ts").JSONValue | undefined, requireGeneratedIdentifier: (value: string, field: string) => string, requireClockInstant: (now: number, source?: string) => number, requireDerivedInstant: (instant: number, field: string) => number, requireMaintenanceInstant: (now: number) => number, requireWaitBudget: (options: { readonly timeoutMs?: number | undefined; readonly pollIntervalMs?: number | undefined; }) => { readonly timeoutMs: number; readonly pollIntervalMs: number; }; /** * Validate a caller-supplied failure record before it becomes terminal evidence. * * @throws {ApplicationCommandValidationError} When `details` is not JSON-safe. */ export declare function validateFailure(failure: ApplicationCommandRejection): ApplicationCommandFailure; /** * Validate a caller-supplied cancellation reason before it becomes part of a * durable record. * * @throws {ApplicationCommandValidationError} When the reason is oversized or * not well-formed. */ export declare function validateCancellationReason(reason: string | undefined): string | undefined; /** * Clamp a caller-supplied listing limit into the bounded range. */ export declare function clampListLimit(limit: number | undefined): number;