Files
SnowLuma/.pnpm-store/v11/files/d6/c99a25ee1e51651ffb6bf0aa5032fe53a6e84dc288f95b905dcec41ae96c5488715bd13af7b3bd08eed55b1dc8cca0a821f2f8cb63650205e36558ef9eb1f2
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

57 lines
2.1 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseIntersectionDef = void 0;
const parseDef_js_1 = require("../parseDef.js");
const isJsonSchema7AllOfType = (type) => {
if ("type" in type && type.type === "string")
return false;
return "allOf" in type;
};
function parseIntersectionDef(def, refs) {
const allOf = [
(0, parseDef_js_1.parseDef)(def.left._def, {
...refs,
currentPath: [...refs.currentPath, "allOf", "0"],
}),
(0, parseDef_js_1.parseDef)(def.right._def, {
...refs,
currentPath: [...refs.currentPath, "allOf", "1"],
}),
].filter((x) => !!x);
let unevaluatedProperties = refs.target === "jsonSchema2019-09"
? { unevaluatedProperties: false }
: undefined;
const mergedAllOf = [];
// If either of the schemas is an allOf, merge them into a single allOf
allOf.forEach((schema) => {
if (isJsonSchema7AllOfType(schema)) {
mergedAllOf.push(...schema.allOf);
if (schema.unevaluatedProperties === undefined) {
// If one of the schemas has no unevaluatedProperties set,
// the merged schema should also have no unevaluatedProperties set
unevaluatedProperties = undefined;
}
}
else {
let nestedSchema = schema;
if ("additionalProperties" in schema &&
schema.additionalProperties === false) {
const { additionalProperties, ...rest } = schema;
nestedSchema = rest;
}
else {
// As soon as one of the schemas has additionalProperties set not to false, we allow unevaluatedProperties
unevaluatedProperties = undefined;
}
mergedAllOf.push(nestedSchema);
}
});
return mergedAllOf.length
? {
allOf: mergedAllOf,
...unevaluatedProperties,
}
: undefined;
}
exports.parseIntersectionDef = parseIntersectionDef;