Updates
This commit is contained in:
+27
@@ -0,0 +1,27 @@
|
||||
import { AppData } from "../data/app-data";
|
||||
export type DataFileFormat = "ts" | "js" | "json" | "yaml";
|
||||
export type ResolvedDataFile = {
|
||||
path: string;
|
||||
basename: string;
|
||||
extension: (typeof AppData.SupportedDataFileExtensions)[number];
|
||||
format: DataFileFormat;
|
||||
};
|
||||
export type LoadedDataFile<T> = ResolvedDataFile & {
|
||||
data: T;
|
||||
};
|
||||
/**
|
||||
* Resolve a basename (no extension) to an existing file among supported formats.
|
||||
* Priority: .ts > .js > .json > .yaml > .yml
|
||||
* Errors if multiple matches exist.
|
||||
*/
|
||||
export declare function resolveDataFile(dir: string, baseName: string): ResolvedDataFile | null;
|
||||
export declare function supportedDataFileNames(baseName: string): string;
|
||||
export declare function isSchemaFileName(name: string): boolean;
|
||||
/**
|
||||
* Load a data file as a plain object.
|
||||
* - .ts / .js: require() and use default export (or module itself)
|
||||
* - .json: JSON.parse
|
||||
* - .yaml / .yml: Bun.YAML.parse
|
||||
*/
|
||||
export declare function loadDataFile<T>(resolved: ResolvedDataFile): T;
|
||||
export declare function resolveAndLoadDataFile<T>(dir: string, baseName: string): LoadedDataFile<T> | null;
|
||||
Reference in New Issue
Block a user