@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 1.88 kB
Source Map (JSON)
{"version":3,"file":"map.cjs","names":["def: ZodMapDef","refs: Refs","parseRecordDef","parseDef","parseAnyDef"],"sources":["../../../../src/utils/zod-to-json-schema/parsers/map.ts"],"sourcesContent":["import { ZodMapDef } from \"zod/v3\";\nimport { parseDef } from \"../parseDef.js\";\nimport { JsonSchema7Type } from \"../parseTypes.js\";\nimport { Refs } from \"../Refs.js\";\nimport { JsonSchema7RecordType, parseRecordDef } from \"./record.js\";\nimport { parseAnyDef } from \"./any.js\";\n\nexport type JsonSchema7MapType = {\n type: \"array\";\n maxItems: 125;\n items: {\n type: \"array\";\n items: [JsonSchema7Type, JsonSchema7Type];\n minItems: 2;\n maxItems: 2;\n };\n};\n\nexport function parseMapDef(\n def: ZodMapDef,\n refs: Refs\n): JsonSchema7MapType | JsonSchema7RecordType {\n if (refs.mapStrategy === \"record\") {\n return parseRecordDef(def, refs);\n }\n\n const keys =\n parseDef(def.keyType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"items\", \"items\", \"0\"],\n }) || parseAnyDef(refs);\n const values =\n parseDef(def.valueType._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"items\", \"items\", \"1\"],\n }) || parseAnyDef(refs);\n return {\n type: \"array\",\n maxItems: 125,\n items: {\n type: \"array\",\n items: [keys, values],\n minItems: 2,\n maxItems: 2,\n },\n };\n}\n"],"mappings":";;;;;AAkBA,SAAgB,YACdA,KACAC,MAC4C;AAC5C,KAAI,KAAK,gBAAgB,SACvB,QAAOC,8BAAe,KAAK,KAAK;CAGlC,MAAM,OACJC,0BAAS,IAAI,QAAQ,MAAM;EACzB,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;GAAS;EAAI;CAC1D,EAAC,IAAIC,wBAAY,KAAK;CACzB,MAAM,SACJD,0BAAS,IAAI,UAAU,MAAM;EAC3B,GAAG;EACH,aAAa;GAAC,GAAG,KAAK;GAAa;GAAS;GAAS;EAAI;CAC1D,EAAC,IAAIC,wBAAY,KAAK;AACzB,QAAO;EACL,MAAM;EACN,UAAU;EACV,OAAO;GACL,MAAM;GACN,OAAO,CAAC,MAAM,MAAO;GACrB,UAAU;GACV,UAAU;EACX;CACF;AACF"}