Files
NapCatQQ/.pnpm-store/v3/files/de/0d474a17394c8849a80a8d89cc52951f6dcdc9eba19d7d19daf60666cee544af368cf86eef3b6963d85d9b23f5bd461c908ec9212b1c244d27d2196b57594b
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

37 lines
1.4 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeDereferenceError = void 0;
exports.Pushref = Pushref;
exports.Deref = Deref;
const index_1 = require("../../type/error/index");
const index_2 = require("../../type/symbols/index");
const guard_1 = require("../guard/guard");
class TypeDereferenceError extends index_1.TypeBoxError {
constructor(schema) {
super(`Unable to dereference schema with $id '${schema.$ref}'`);
this.schema = schema;
}
}
exports.TypeDereferenceError = TypeDereferenceError;
function Resolve(schema, references) {
const target = references.find((target) => target.$id === schema.$ref);
if (target === undefined)
throw new TypeDereferenceError(schema);
return Deref(target, references);
}
/** `[Internal]` Pushes a schema onto references if the schema has an $id and does not exist on references */
function Pushref(schema, references) {
if (!(0, guard_1.IsString)(schema.$id) || references.some((target) => target.$id === schema.$id))
return references;
references.push(schema);
return references;
}
/** `[Internal]` Dereferences a schema from the references array or throws if not found */
function Deref(schema, references) {
// prettier-ignore
return (schema[index_2.Kind] === 'This' || schema[index_2.Kind] === 'Ref')
? Resolve(schema, references)
: schema;
}