@dxos/echo
    Preparing search index...

    Interface Annotation<T>

    Annotation is a typed property that can be assigned to a schema or an entity instance.

    interface Annotation<T> {
        "~@dxos/echo/Annotation": { _Type: T };
        get: (schema: Top) => Option<T>;
        getFromAst: (ast: AST) => Option<T>;
        key: string & Brand<"~@dxos/echo/AnnotationKey">;
        schema: Codec<T, unknown, never>;
        set: (value: T) => <S extends Top>(schema: S) => S;
    }

    Type Parameters

    • T
    Index

    Properties

    "~@dxos/echo/Annotation": { _Type: T }
    get: (schema: Top) => Option<T>

    Get the annotation value from an Effect schema.

    Only accepts Schema.Top — to read an annotation off a Type.Type entity, unwrap it first with Type.getSchema(entity). This keeps the annotation pipeline single-shaped and forces annotations to live on the source schema, not on the post-construction Type entity.

    O(1) annotation lookup, but decodes the value against schema on every call (not cached).

    getFromAst: (ast: AST) => Option<T>

    Get the annotation value from the AST.

    O(1) annotation lookup, but decodes the value against schema on every call (not cached).

    key: string & Brand<"~@dxos/echo/AnnotationKey">

    Unique fully-qualified identifier for the annotation.

    "org.dxos.annotation.color"
    
    schema: Codec<T, unknown, never>

    Schema of the annotation value.

    set: (value: T) => <S extends Top>(schema: S) => S

    Set the annotation on an Effect schema.

    Only accepts Schema.Top — annotations must be applied to the source schema BEFORE wrapping it with Type.makeObject / Type.makeRelation. In a pipe, place every Annotation.X.set(...) before the Type.make... step.

    O(value size) encode, once at schema-definition time.