Additional directives
This commit is contained in:
parent
542d28cb53
commit
3c6d7c18cd
7 changed files with 304 additions and 166 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue