import type { BatchOperation } from '../storage/interface.ts'; import type { SearchAttributeDefinition, SearchAttributeValue } from './types.ts'; export { searchAttribute, searchAttributeName } from './types.ts'; /** * Maximum size in bytes for an encoded attribute value. Values exceeding this * limit produce storage keys that may blow past backend size constraints. */ export declare const MAX_ENCODED_VALUE_BYTES = 1024; /** * Encode a search attribute value to a sortable string for index keys. * * @example * ```ts * import { encodeAttributeValue } from '@lostgradient/weft'; * * console.log(encodeAttributeValue('acme')); // 's:acme' * console.log(encodeAttributeValue(42)); // 'n:...' (sortable hex) * console.log(encodeAttributeValue(true)); // 'b:1' * console.log(encodeAttributeValue(new Date('2026-01-01'))); // 'd:2026-01-01T00:00:00.000Z' * ``` */ export declare function encodeAttributeValue(value: SearchAttributeValue): string; /** * Validate that an encoded attribute value does not exceed the storage key size limit. * Call this in the attribute-setting path, NOT in the general-purpose encoder — the encoder * is also used to reconstruct old keys for deletion, and throwing there would prevent * cleanup of pre-existing oversized values. */ export declare function validateEncodedValueSize(encoded: string, attributeName: string): void; /** * Decode an encoded attribute value back to its original type. * * @example * ```ts * import { encodeAttributeValue, decodeAttributeValue } from '@lostgradient/weft'; * * const encoded = encodeAttributeValue('acme'); * const decoded = decodeAttributeValue(encoded, 'string'); * console.log(decoded); // 'acme' * * const num = encodeAttributeValue(42); * console.log(decodeAttributeValue(num, 'number')); // 42 * ``` */ export declare function decodeAttributeValue(encoded: string, type: string): SearchAttributeValue; /** * Validate that a value's runtime type matches the declared schema type. * Throws a descriptive error on mismatch. */ export declare function validateAttributeType(attributeName: string, value: SearchAttributeValue, definition: SearchAttributeDefinition): void; /** * Compute the diff between old and new attributes, returning BatchOperations for index updates. * * @example * ```ts * import { buildIndexOperations } from '@lostgradient/weft'; * * const ops = buildIndexOperations( * 'wf-123', * { status: 'pending' }, * { status: 'completed', customerId: 'acme' }, * ); * // ops: delete old 'status' index key, put new 'status' key, put 'customerId' key * console.log(ops.length > 0); // true * ``` */ export declare function buildIndexOperations(workflowId: string, previous: Record, current: Record): BatchOperation[];