/** * @module Cache */ import { type StandardSchemaV1 } from "@standard-schema/spec"; import { type ICacheAdapter } from "../../../../cache/contracts/_module.js"; import { type PluginFn } from "../../../../middleware/contracts/_module.js"; /** * Settings for the {@link withCacheSchema} plugin. * * IMPORT_PATH: `"@daiso-tech/core/cache/plugins"` * @group Plugins */ export type WithCacheSchemaSettings = { /** * A standard-schema-compliant schema used to validate cache values. * Compatible with libraries such as Zod, ArkType, Valibot, and others * that implement the `StandardSchemaV1` specification. */ schema: StandardSchemaV1; /** * Whether to validate values returned by `get` and `getAndRemove` * on retrieval, in addition to validating values on write. * When `true`, malformed data in the cache is caught at read time * rather than silently returned. * * @default true */ shouldValidateOutput?: boolean; }; /** * Creates a plugin that validates cache values against a standard schema. * * On `add`, `put`, and `update` operations the input value is validated * against the provided schema before being stored. Optionally, `get` and * `getAndRemove` outputs can also be validated on retrieval to ensure data * integrity. * * @param settings - Configuration for the schema validation. * @param settings.schema - A standard-schema compliant schema to validate * values against. * @param settings.shouldValidateOutput - Whether to validate values returned * by `get` and `getAndRemove`. * @default true * @returns A middleware plugin that wraps an `ICacheAdapter`. * * IMPORT_PATH: `"@daiso-tech/core/cache/plugins"` * @group Plugins */ export declare function withCacheSchema(settings: WithCacheSchemaSettings): PluginFn;