@dxos/echo
    Preparing search index...

    Variable makeObjectConst

    makeObject: <Self>(
        dxn: DXN.DXN,
        options?: { id?: Key.EntityId },
    ) => MakeObject<Self> = ...

    Factory function to create an ECHO object type.

    Returns a Type.Type entity — a live, in-memory TypeSchema instance, NOT a Schema.Schema. Use Type.InstanceType<typeof Foo> for the instance type and Type.getSchema(Foo) to obtain the underlying Effect Schema.

    The entity's id defaults to EntityId.deterministic(typename, version) so constructing a type never reaches crypto.getRandomValues() — required for Cloudflare workerd, which forbids RNG calls in global (module-evaluation) scope. Pass { id } to override (e.g. with EntityId.random() from a request handler).

    Giving the type a nominal class name keeps its inferred type portable for declaration emit: structural expansion (which can pull in unnameable union members from referenced schemas) is replaced by a reference to the class.

    The second call takes either a schema, or struct fields (wrapped in Schema.Struct) with an optional function that pipes annotations onto the struct.

    Type declaration

    export class Person extends Type.makeObject<Person>(DXN.make('com.example.type.myType', '0.1.0'))(Schema.Struct({
    name: Schema.String,
    })) {}

    export class Tag extends Type.makeObject<Tag>(DXN.make('com.example.type.tag', '0.1.0'))(
    { label: Schema.String },
    Annotation.LabelAnnotation.set(['label']),
    ) {}

    O(schema size) once at definition time; builds the type entity eagerly, so call it at module scope, not per use.