e1d9163cd7c534fd9398b5f89d2352796ff8ae7a6f62e9c912e7694cc76df3b5.json 5.4 KB

1
  1. {"ast":null,"code":"import { parseDef } from \"../parseDef.js\";\nconst isJsonSchema7AllOfType = type => {\n if (\"type\" in type && type.type === \"string\") return false;\n return \"allOf\" in type;\n};\nexport function parseIntersectionDef(def, refs) {\n const allOf = [parseDef(def.left._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"allOf\", \"0\"]\n }), parseDef(def.right._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"allOf\", \"1\"]\n })].filter(x => !!x);\n let unevaluatedProperties = refs.target === \"jsonSchema2019-09\" ? {\n unevaluatedProperties: false\n } : undefined;\n const mergedAllOf = [];\n // If either of the schemas is an allOf, merge them into a single allOf\n allOf.forEach(schema => {\n if (isJsonSchema7AllOfType(schema)) {\n mergedAllOf.push(...schema.allOf);\n if (schema.unevaluatedProperties === undefined) {\n // If one of the schemas has no unevaluatedProperties set,\n // the merged schema should also have no unevaluatedProperties set\n unevaluatedProperties = undefined;\n }\n } else {\n let nestedSchema = schema;\n if (\"additionalProperties\" in schema && schema.additionalProperties === false) {\n const {\n additionalProperties,\n ...rest\n } = schema;\n nestedSchema = rest;\n } else {\n // As soon as one of the schemas has additionalProperties set not to false, we allow unevaluatedProperties\n unevaluatedProperties = undefined;\n }\n mergedAllOf.push(nestedSchema);\n }\n });\n return mergedAllOf.length ? {\n allOf: mergedAllOf,\n ...unevaluatedProperties\n } : undefined;\n}","map":{"version":3,"names":["parseDef","isJsonSchema7AllOfType","type","parseIntersectionDef","def","refs","allOf","left","_def","currentPath","right","filter","x","unevaluatedProperties","target","undefined","mergedAllOf","forEach","schema","push","nestedSchema","additionalProperties","rest","length"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js"],"sourcesContent":["import { parseDef } from \"../parseDef.js\";\nconst isJsonSchema7AllOfType = (type) => {\n if (\"type\" in type && type.type === \"string\")\n return false;\n return \"allOf\" in type;\n};\nexport function parseIntersectionDef(def, refs) {\n const allOf = [\n parseDef(def.left._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"allOf\", \"0\"],\n }),\n parseDef(def.right._def, {\n ...refs,\n currentPath: [...refs.currentPath, \"allOf\", \"1\"],\n }),\n ].filter((x) => !!x);\n let unevaluatedProperties = refs.target === \"jsonSchema2019-09\"\n ? { unevaluatedProperties: false }\n : undefined;\n const mergedAllOf = [];\n // If either of the schemas is an allOf, merge them into a single allOf\n allOf.forEach((schema) => {\n if (isJsonSchema7AllOfType(schema)) {\n mergedAllOf.push(...schema.allOf);\n if (schema.unevaluatedProperties === undefined) {\n // If one of the schemas has no unevaluatedProperties set,\n // the merged schema should also have no unevaluatedProperties set\n unevaluatedProperties = undefined;\n }\n }\n else {\n let nestedSchema = schema;\n if (\"additionalProperties\" in schema &&\n schema.additionalProperties === false) {\n const { additionalProperties, ...rest } = schema;\n nestedSchema = rest;\n }\n else {\n // As soon as one of the schemas has additionalProperties set not to false, we allow unevaluatedProperties\n unevaluatedProperties = undefined;\n }\n mergedAllOf.push(nestedSchema);\n }\n });\n return mergedAllOf.length\n ? {\n allOf: mergedAllOf,\n ...unevaluatedProperties,\n }\n : undefined;\n}\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,MAAMC,sBAAsB,GAAIC,IAAI,IAAK;EACrC,IAAI,MAAM,IAAIA,IAAI,IAAIA,IAAI,CAACA,IAAI,KAAK,QAAQ,EACxC,OAAO,KAAK;EAChB,OAAO,OAAO,IAAIA,IAAI;AAC1B,CAAC;AACD,OAAO,SAASC,oBAAoBA,CAACC,GAAG,EAAEC,IAAI,EAAE;EAC5C,MAAMC,KAAK,GAAG,CACVN,QAAQ,CAACI,GAAG,CAACG,IAAI,CAACC,IAAI,EAAE;IACpB,GAAGH,IAAI;IACPI,WAAW,EAAE,CAAC,GAAGJ,IAAI,CAACI,WAAW,EAAE,OAAO,EAAE,GAAG;EACnD,CAAC,CAAC,E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