import type { LinkResolver } from 'alinea/core/db/LinkResolver';
import { Expr } from './Expr.js';
import { type HasField, internalField } from './Internal.js';
import type { Shape } from './Shape.js';
import type { View } from './View.js';
export interface FieldOptions<StoredValue> {
    /** A description of the field */
    label: string;
    /** Hide this field in the dashboard */
    hidden?: boolean;
    /** Mark this field as read-only */
    readOnly?: boolean;
    /** The initial value of the field */
    initialValue?: StoredValue;
    /** The value of this field is shared across all languages */
    shared?: boolean;
    /** Providing a value for this field is required */
    required?: boolean;
    /** Validate the given value */
    validate?(value: StoredValue): boolean | string | undefined;
}
export type WithoutLabel<Options extends FieldOptions<any>> = Omit<Options, 'label'>;
export interface FieldMeta<StoredValue, QueryValue, Mutator, Options> {
    options: Options & FieldOptions<StoredValue>;
    view: View<{
        field: Field<StoredValue, QueryValue, Mutator, Options>;
    }>;
    postProcess?: (value: StoredValue, loader: LinkResolver) => Promise<void>;
}
export interface FieldData<StoredValue, QueryValue, Mutator, Options> extends FieldMeta<StoredValue, QueryValue, Mutator, Options> {
    shape: Shape<StoredValue, Mutator>;
    referencedViews: Array<string>;
}
export interface FieldInternal extends FieldData<any, any, any, any> {
    ref: symbol;
}
declare const brand: unique symbol;
export declare class Field<StoredValue = any, QueryValue = any, Mutator = any, Options = any> extends Expr<QueryValue> implements HasField {
    [brand]: [StoredValue, QueryValue, Mutator, Options];
    [internalField]: FieldInternal;
    constructor(data: FieldData<StoredValue, QueryValue, Mutator, Options>);
}
export declare namespace Field {
    function ref(field: HasField): symbol;
    function shape(field: HasField): Shape;
    function label(field: HasField): string;
    function initialValue(field: HasField): unknown;
    function view<StoredValue, QueryValue, Mutator, Options extends FieldOptions<StoredValue>>(field: Field<StoredValue, QueryValue, Mutator, Options>): View<{
        field: Field<StoredValue, QueryValue, Mutator, Options>;
    }>;
    function referencedViews(field: Field): Array<string>;
    function options<StoredValue, QueryValue, Options extends FieldOptions<StoredValue>>(field: Field<StoredValue, QueryValue, any, Options>): Options;
    function isField(value: any): value is Field;
}
export {};
