@langchain/core
Version:
Core LangChain.js abstractions and schemas
32 lines (31 loc) • 1.9 kB
text/typescript
import { InteropZodType } from "./types/zod.cjs";
import { JsonSchema7ArrayType } from "./zod-to-json-schema/parsers/array.cjs";
import { JsonSchema7NumberType } from "./zod-to-json-schema/parsers/number.cjs";
import { JsonSchema7StringType } from "./zod-to-json-schema/parsers/string.cjs";
import { JsonSchema7NullableType } from "./zod-to-json-schema/parsers/nullable.cjs";
import { JsonSchema7ObjectType } from "./zod-to-json-schema/parsers/object.cjs";
import { JsonSchema7Type } from "./zod-to-json-schema/parseTypes.cjs";
import { Validator, deepCompareStrict } from "@cfworker/json-schema";
//#region src/utils/json_schema.d.ts
/**
* Converts a Zod schema or JSON schema to a JSON schema.
* @param schema - The schema to convert.
* @returns The converted schema.
*/
declare function toJsonSchema(schema: InteropZodType | JsonSchema7Type): JsonSchema7Type;
/**
* Validates if a JSON schema validates only strings. May return false negatives in some edge cases
* (like recursive or unresolvable refs).
*
* @param schema - The schema to validate.
* @returns `true` if the schema validates only strings, `false` otherwise.
*/
declare function validatesOnlyStrings(schema: unknown): boolean;
// Re-export of the types used throughout langchain for json schema serialization.
// The plan is to eventually nix zod-to-json-schema altogether in place for
// zod v4 / a more standardized way of serializing validated inputs, so its re-exported
// here to remove the dependency on zod-to-json-schema in downstream packages until
// a determination is made.
//#endregion
export { type JsonSchema7Type as JSONSchema, type JsonSchema7ArrayType, type JsonSchema7NullableType, type JsonSchema7NumberType, type JsonSchema7ObjectType, type JsonSchema7StringType, type JsonSchema7Type, Validator, deepCompareStrict, toJsonSchema, validatesOnlyStrings };
//# sourceMappingURL=json_schema.d.cts.map