@langchain/langgraph
Version:
41 lines (40 loc) • 1.51 kB
JavaScript
const require_meta = require("./meta.cjs");
let _langchain_core_utils_types = require("@langchain/core/utils/types");
let zod_v4_core = require("zod/v4/core");
//#region src/graph/zod/zod-registry.ts
/**
* A Zod v4-compatible meta registry that extends the base registry.
*
* This registry allows you to associate and retrieve metadata for Zod schemas,
* leveraging the base registry for storage. It is compatible with Zod v4 and
* interoperates with the base registry to ensure consistent metadata management
* across different Zod versions.
*
* @template Meta - The type of metadata associated with each schema.
* @template Schema - The Zod schema type.
*/
var LanggraphZodMetaRegistry = class extends zod_v4_core.$ZodRegistry {
/**
* Creates a new LanggraphZodMetaRegistry instance.
*
* @param parent - The base SchemaMetaRegistry to use for metadata storage.
*/
constructor(parent) {
super();
this.parent = parent;
this._map = this.parent._map;
}
add(schema, ..._meta) {
const firstMeta = _meta[0];
if (firstMeta && !firstMeta?.default) {
const defaultValueGetter = (0, _langchain_core_utils_types.getInteropZodDefaultGetter)(schema);
if (defaultValueGetter != null) firstMeta.default = defaultValueGetter;
}
return super.add(schema, ..._meta);
}
};
const registry = new LanggraphZodMetaRegistry(require_meta.schemaMetaRegistry);
//#endregion
exports.LanggraphZodMetaRegistry = LanggraphZodMetaRegistry;
exports.registry = registry;
//# sourceMappingURL=zod-registry.cjs.map