import { EggAppConfig, EggAppInfo, EggEnvType } from "./types.js"; import { PartialDeep } from "type-fest"; //#region src/lib/define.d.ts /** * Partial EggAppConfig */ export type PartialEggConfig = PartialDeep; /** * Configuration factory function return type */ export type EggConfigFactory = (appInfo: EggAppInfo) => PartialEggConfig; /** * Define configuration with type safety * @example * ```ts * import { defineConfig } from 'egg'; * * export default defineConfig({ * keys: 'my-keys', * middleware: [] * }); * ``` */ export declare function defineConfig(config: PartialEggConfig): PartialEggConfig; /** * Define configuration factory function with type safety * @example * ```ts * export default defineConfigFactory((appInfo): PartialEggConfig => ({ * keys: appInfo.name + '_keys', * middleware: [] * })); * ``` */ export declare function defineConfigFactory(configFactory: EggConfigFactory): EggConfigFactory; /** * Define plugin meta with type safety */ export interface EggPluginMeta { /** the plugin name, it can be used in `dep` */ name: string; /** whether enabled */ enable: boolean; /** the directory of the plugin package */ path: string; /** the dependent plugins, you can use the plugin name */ dependencies?: string[]; /** the optional dependent plugins. */ optionalDependencies?: string[]; /** specify the serverEnv that only enable the plugin in it, default to all envs */ env?: EggEnvType[]; } /** * Egg plugin options, user can't provide name, it will be generated by the plugin factory. */ export type EggPluginOptions = PartialDeep>; /** * Egg plugin factory type, the return value is a record of plugin name and plugin meta. */ export type EggPluginFactory = (options?: EggPluginOptions) => Record; /** * Define plugin factory with type safety * @example * ```ts * import { definePluginFactory } from 'egg'; * * export default definePluginFactory({ * name: 'my-plugin', * enable: true, * path: 'path/to/my-plugin', * dependencies: ['watcher'], * optionalDependencies: ['view'], * env: ['local', 'unittest'], * }); * ``` */ export declare function definePluginFactory(pluginMeta: EggPluginMeta): EggPluginFactory; //#endregion