A registry for storing and managing metadata associated with schemas. This class provides methods to get, extend, remove, and check metadata for a given schema.

Constructors

Methods

  • Extends or sets the metadata for a given schema.

    Type Parameters

    • TValue

      The value type of the schema.

    • TUpdate

      The update type of the schema (defaults to TValue).

    Parameters

    Returns void

  • Retrieves the metadata associated with a given schema.

    Type Parameters

    • TValue

      The value type of the schema.

    • TUpdate = TValue

      The update type of the schema (defaults to TValue).

    Parameters

    • schema: InteropZodType<TValue>

      The schema to retrieve metadata for.

    Returns undefined | SchemaMeta<TValue, TUpdate>

    The associated SchemaMeta, or undefined if not present.

  • Returns a mapping of channel instances for each property in the schema using the associated metadata in the registry.

    This is used to create the channels object that's passed to the Graph constructor.

    Type Parameters

    • T extends InteropZodObject

      The shape of the schema.

    Parameters

    • schema: T

      The schema to extract channels from.

    Returns InteropZodToStateDefinition<T, InteropZodObjectShape<T>>

    A mapping from property names to channel instances.

  • Returns a modified schema that introspectively looks at all keys of the provided object schema, and applies the augmentations based on meta provided with those keys in the registry and the selectors provided in the effects parameter.

    This assumes that the passed in schema is the "root" schema object for a graph where the keys of the schema are the channels of the graph. Because we need to represent the input of a graph in a couple of different ways, the effects parameter allows us to apply those augmentations based on pre determined conditions.

    Type Parameters

    • T extends InteropZodObject

    Parameters

    • schema: T

      The root schema object to extend.

    • effects: {
          asPartial?: boolean;
          withJsonSchemaExtrasAsDescription?: boolean;
          withReducerSchema?: boolean;
      }

      The effects that are being applied.

      • Optional asPartial?: boolean

        Applies the .partial() modifier to the schema.

      • Optional withJsonSchemaExtrasAsDescription?: boolean

        Applies the stringified jsonSchemaExtra as a description to the schema.

      • Optional withReducerSchema?: boolean

        Augments the shape by using the reducer's schema if it exists

    Returns InteropZodObject

    The extended schema.

  • Checks if metadata exists for a given schema.

    Parameters

    • schema: InteropZodType

      The schema to check.

    Returns boolean

    True if metadata exists, false otherwise.

  • Removes the metadata associated with a given schema.

    Parameters

    • schema: InteropZodType

      The schema to remove metadata for.

    Returns this

    The SchemaMetaRegistry instance (for chaining).