-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader-utils.ts
More file actions
30 lines (27 loc) · 876 Bytes
/
loader-utils.ts
File metadata and controls
30 lines (27 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* Shared utilities for module and persona loaders
*/
import { pathToFileURL } from 'node:url';
import type { ValidationResult } from 'ums-lib';
/**
* Convert file path to file URL for dynamic import
* @param filePath - Absolute path to file
* @returns File URL string suitable for dynamic import
*/
export function filePathToUrl(filePath: string): string {
return pathToFileURL(filePath).href;
}
/**
* Format validation errors into a single error message
* @param validation - Validation result from ums-lib
* @param defaultPath - Default path to use if error has no path (e.g., 'module', 'persona')
* @returns Formatted error message string
*/
export function formatValidationErrors(
validation: ValidationResult,
defaultPath = 'module'
): string {
return validation.errors
.map(e => `${e.path ?? defaultPath}: ${e.message}`)
.join('; ');
}