// SPDX-FileCopyrightText: 2026 Kerstin Humm // // SPDX-License-Identifier: AGPL-3.0-or-later import { AnnotatedJson, Annotation, AnnotationKind, fromJsonValue, isAnnotatedArray, isAnnotatedObject, isAnnotation, isJsonArray, isJsonObject, isPrimitive, isUrl, JsonValue, mergeAnnotatedJson, Rule, } from "./types.js"; export type { AnnotatedJson, Annotation, AnnotationKind, JsonValue }; export { isAnnotatedArray, isAnnotatedObject, isAnnotation, isJsonArray, isJsonObject, isPrimitive, isUrl, }; import timezone from "./rules/timezone.js"; import name from "./rules/name.js"; import to from "./rules/to.js"; import startTime from "./rules/startTime.js"; import endTime from "./rules/endTime.js"; import organizers from "./rules/organizers.js"; // import remaining from "./rules/remaining.js"; // Order in this matters! export const rules: Rule[] = [ timezone, name, to, startTime, endTime, organizers, // We skip this for now as it could be only accurate once we implemented all standardised attributes // remaining, ]; export function validate( apObject: Record, ): AnnotatedJson { let result: AnnotatedJson = fromJsonValue(apObject); for (const rule of rules) { const merge = mergeAnnotatedJson(result, rule.validate(apObject)); if (merge.ok) { result = merge.value; } else { console.error(merge.error); } } return result; }