feat: centralize application framework primitives
This commit is contained in:
@@ -330,6 +330,19 @@ export interface AppConfig {
|
||||
profiles?: Record<string, Partial<Omit<AppConfig, "profiles">>>;
|
||||
}
|
||||
|
||||
/** User-authored configuration; retained as an explicit name for API clarity. */
|
||||
export type AppConfigInput = AppConfig;
|
||||
|
||||
/** Configuration after profile/layer resolution. Required input fields stay required. */
|
||||
export type ResolvedAppConfig<T extends AppConfig = AppConfig> = Omit<
|
||||
AppConfig,
|
||||
"extends" | "profiles"
|
||||
> &
|
||||
Omit<T, "extends" | "profiles"> & {
|
||||
readonly extends?: undefined;
|
||||
readonly profiles?: undefined;
|
||||
};
|
||||
|
||||
const CONFIG_NAMES = ["wrnexus.config.ts", "wrnexus.config.js", "wrnexus.config.mjs"];
|
||||
|
||||
/**
|
||||
@@ -474,7 +487,7 @@ export async function loadRawConfig(appRoot: string): Promise<AppConfig> {
|
||||
}
|
||||
|
||||
/** Load `wrnexus.config.*`, applying the active profile's overrides. */
|
||||
export async function loadAppConfig(appRoot: string, profile?: string): Promise<AppConfig> {
|
||||
export async function loadAppConfig(appRoot: string, profile?: string): Promise<ResolvedAppConfig> {
|
||||
const active = profile ?? resolveProfile();
|
||||
// Configuration modules commonly read DATABASE_URL and other settings during
|
||||
// module evaluation. Load the profile cascade before importing the module so
|
||||
@@ -494,7 +507,7 @@ export async function loadAppConfig(appRoot: string, profile?: string): Promise<
|
||||
`Invalid wrnexus.config: ${errors.map((issue) => `${issue.path}: ${issue.message}`).join("; ")}`,
|
||||
);
|
||||
}
|
||||
return merged;
|
||||
return merged as ResolvedAppConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -573,7 +586,7 @@ export interface ConfigIssue {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function defineConfig(config: AppConfig): AppConfig {
|
||||
export function defineConfig<const T extends AppConfig>(config: T): T {
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
export type {
|
||||
AppConfig,
|
||||
AppConfigInput,
|
||||
ResolvedAppConfig,
|
||||
BuildConfig,
|
||||
ConfigIssue,
|
||||
DevToolbarConfig,
|
||||
|
||||
Reference in New Issue
Block a user