Additional directives

This commit is contained in:
Endeavorance 2025-02-12 18:56:45 -05:00
parent 542d28cb53
commit 3c6d7c18cd
7 changed files with 304 additions and 166 deletions

View file

@ -8,6 +8,14 @@ import {
export class ResourceFileError extends Error { }
export class NullResourceError extends Error { }
/**
* Load and process all documents in a yaml file at the given path
* @param filePath - The path to the yaml file
* @returns An array of validated resources
*
* @throws ResourceFileError
* @throws NullResourceError
*/
export async function loadResourceFile(
filePath: string,
): Promise<AnyResource[]> {
@ -37,8 +45,8 @@ export async function loadResourceFile(
const parsed = AnyResourceSchema.parse(raw);
const type = parsed.$define;
const schemaToUse = ResourceMap[type];
collection.push(schemaToUse.parse(parsed));
const validated = schemaToUse.parse(parsed);
collection.push(validated);
}
return collection;