import { Layer } from "effect"; import { SerializerRegistry, type SerializerRegistryShape } from "./serializer-service.js"; /** * Options for encoding data. */ export interface FormatOptions { readonly indent?: number; } /** * A FormatCodec defines a serialization format with: * - A human-readable name (e.g., "json", "yaml", "toml") * - Supported file extensions without dots (e.g., ["yaml", "yml"]) * - Synchronous encode/decode functions that throw on failure * * The compositor (makeSerializerLayer) wraps these in Effect.try * with proper error tagging. */ export interface FormatCodec { readonly name: string; readonly extensions: ReadonlyArray; readonly encode: (data: unknown, options?: FormatOptions) => string; readonly decode: (raw: string) => unknown; } /** * Creates a SerializerRegistry Layer from an array of FormatCodec instances. * * The compositor: * 1. Builds an extension → codec lookup map (O(1) dispatch) * 2. Wraps encode/decode in Effect.try with SerializationError * 3. Produces UnsupportedFormatError for unknown extensions * 4. Logs console.warn on duplicate extensions (last wins) * * @param codecs - Base codecs to register * @param pluginCodecs - Optional plugin codecs to append after base codecs (can override base codecs for the same extension) */ export declare const makeSerializerLayer: (codecs: ReadonlyArray, pluginCodecs?: ReadonlyArray) => Layer.Layer; /** * Wraps an existing SerializerRegistryShape with additional plugin codecs. * * Plugin codecs are checked first for matching extensions. If a plugin codec * matches the extension, it handles serialization/deserialization. Otherwise, * the request falls through to the base registry. * * This enables plugins to: * 1. Add support for new file extensions * 2. Override existing codecs (plugin codecs take precedence) * * @param baseRegistry - The original SerializerRegistryShape to wrap * @param pluginCodecs - Array of plugin codecs to layer on top * @returns A new SerializerRegistryShape with plugin codecs merged in */ export declare const mergeSerializerWithPluginCodecs: (baseRegistry: SerializerRegistryShape, pluginCodecs: ReadonlyArray) => SerializerRegistryShape; //# sourceMappingURL=format-codec.d.ts.map