import { MetaType, MetaEntry } from '../types'; /** * Create a metadata builder for decorating stores with custom metadata. * * Meta allows libraries and users to attach arbitrary typed metadata to: * - Store level: `myMeta()` or `myMeta(value)` - applies to the entire store * - Field level: `myMeta.for("fieldName")` or `myMeta.for("fieldName", value)` - applies to specific field * * ## Overloads * * ### 1. `meta()` - Boolean flag meta * Creates a meta type where calling `myMeta()` returns `MetaEntry` * ```ts * const persist = meta(); * persist() // MetaEntry with value: true * persist.for("field") // MetaEntry with value: true for field * ``` * * ### 2. `meta()` - Typed value meta (requires value argument) * Creates a meta type where calling `myMeta(value)` returns `MetaEntry` * ```ts * const priority = meta(); * priority(1) // MetaEntry with value: 1 * priority.for("field", 5) // MetaEntry with value: 5 for field * ``` * * ### 3. `meta(builder)` - Custom builder meta * Creates a meta type with custom value transformation * ```ts * const config = meta((name: string, value: number) => ({ name, value })); * config("timeout", 5000) // MetaEntry with value: { name: "timeout", value: 5000 } * ``` * * @example Boolean flag meta (single) * ```ts * const persist = meta(); * * const userStore = store({ * state: { name: "" }, * meta: persist(), // single meta * }); * * ctx.meta(persist).store; // true * ``` * * @example Multiple metas with meta.of() * ```ts * const persist = meta(); * const priority = meta(); * * const criticalStore = store({ * state: { data: null }, * meta: meta.of(persist(), priority(1)), // type-safe array * }); * * ctx.meta(priority).store; // 1 * ``` * * @example Field-level meta * ```ts * const validate = meta(); * * const formStore = store({ * state: { email: "", age: 0 }, * meta: meta.of( * validate.for("email", "email-format"), * validate.for("age", "positive-number"), * ), * }); * * formStore.meta(validate).fields.email; // "email-format" * formStore.meta(validate).fields.age; // "positive-number" * ``` * * @param builder - Optional function to transform arguments into meta value. * If omitted with no type param, meta value is `true`. * If omitted with type param, first argument is returned as value. * @returns A MetaType that creates MetaEntry objects */ export declare function meta(): MetaType<[], true>; export declare function meta(): MetaType<[value: TValue], TValue>; export declare function meta(builder: (...args: TArgs) => TValue): MetaType; export declare namespace meta { /** * Create a type-safe array of meta entries for stores with multiple metas. * * Use this when attaching multiple meta entries to a store. For single meta, * pass it directly without `meta.of()`. * * @example Single meta (no wrapper needed) * ```ts * const userStore = store({ * state: { name: "" }, * meta: persist(), * }); * ``` * * @example Multiple metas (use meta.of) * ```ts * const userStore = store({ * state: { name: "", password: "" }, * meta: meta.of( * persist(), * notPersisted.for("password"), * ), * }); * ``` * * @param metas - Meta entries to combine * @returns Object with `metas` array for store options */ function of[]>(...metas: TMetas): { metas: TMetas; }; } //# sourceMappingURL=meta.d.ts.map