Files
bun-mariadb/dist/utils/resolve-and-load-data-file.d.ts
T
2026-07-30 07:19:07 +01:00

28 lines
1.1 KiB
TypeScript

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;