import type { AssetProvider, AssetTransformPlugin, BundleProvider, CacheResponse, DirectToCoreProxy, LwrService, ModuleProvider, RenderOptions, ResourceProvider, RouteHandlerViewResponse, RuntimeEnvironment, ServerContext, ServerTypes, ServiceCtor, Specifier, UriTransformPlugin, ViewParams, ViewProvider, ViewRequest, ViewResponse, ViewTransformPlugin } from './index.js'; export interface View { id: string; rootComponent?: string; contentTemplate?: string | Record; layoutTemplate?: string; bootstrap?: LwrAppBootstrapConfig; } export interface LwrBaseRoute extends View { properties?: Record; routeHandler?: ServiceConfig; cache?: CacheResponse; subRoutes?: string; } export interface LwrRoute extends LwrBaseRoute { path: string; method?: 'get' | 'post'; } export interface NormalizedLwrRoute extends LwrRoute { bootstrap: NormalizedLwrAppBootstrapConfig; routeHandler?: ServiceEntry; } export interface LwrErrorRoute extends LwrBaseRoute { status: 404 | 500; } export interface NormalizedLwrErrorRoute extends LwrErrorRoute { bootstrap: NormalizedLwrAppBootstrapConfig; routeHandler?: ServiceEntry; } export interface BootstrapService { name: string; ssr: boolean; version?: string; } export interface LwrAppBootstrapConfig { autoBoot?: boolean; syntheticShadow?: boolean; workers?: { [id: string]: string; }; services?: (string | BootstrapService)[]; configAsSrc?: boolean; ssr?: boolean; preloadData?: boolean; proxyForSSR?: boolean; includeCookiesForSSR?: boolean; mixedMode?: boolean; module?: string | undefined; preloadModules?: string[]; lwrVersion?: string; lwcVersion?: string; preloadResources?: PreloadResources; } export interface NormalizedLwrAppBootstrapConfig extends Required> { services: BootstrapService[]; module: string | undefined; } export interface LwrLockerConfig { enabled: boolean; trustedComponents?: string[]; } export interface RouteHandlersConfig { [id: string]: string | null; } export interface NormalizedRouteHandlersConfig { [id: string]: string | null; } export interface LocalizedViewRequest extends ViewRequest { locale?: string; basePath?: string; assetBasePath?: string; uiBasePath?: string; } export type RouteHandlerFunction = (viewRequest: LocalizedViewRequest, handlerContext: HandlerContext, routeHandlerOptions?: any) => Promise | RouteHandlerViewResponse; export interface ResourcePaths { rootDir: string; assets: AssetConfig[]; layoutsDir: string; contentDir: string; } export type RouteHandlerView = Pick; export interface RouteHandlerViewApi { hasViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): boolean; getViewResponse(view: RouteHandlerView, viewParams?: ViewParams, renderOptions?: RenderOptions): Promise; } export interface HandlerContext extends ResourcePaths { route: LwrRoute | LwrErrorRoute; viewApi: RouteHandlerViewApi; } export interface GlobalData { [key: string]: any; } export interface LwrGlobalConfig { apiVersion?: string; ignoreLwrConfigFile?: boolean; lwrConfigFile?: string; port?: number; serverMode?: string; minify?: boolean | null; basePath?: string; rootDir?: string; cacheDir?: string; contentDir?: string; layoutsDir?: string; globalDataDir?: string; globalData?: GlobalData; assets?: string | AssetConfig[]; assetProviders?: ServiceConfig[]; assetTransformers?: ServiceConfig[]; hooks?: ServiceConfig[]; environment?: EnvironmentConfig; lwc?: LwcConfig; bundleProviders?: ServiceConfig[]; moduleProviders?: ServiceConfig[]; resourceProviders?: ServiceConfig[]; viewProviders?: ServiceConfig[]; viewTransformers?: ServiceConfig[]; caseSensitiveRoutes?: boolean; routes?: LwrRoute[]; errorRoutes?: LwrErrorRoute[]; routeHandlers?: RouteHandlersConfig; bundleConfig?: BundleConfig; serverType?: ServerTypes; staticSiteGenerator?: StaticSiteGenerator; locker?: LwrLockerConfig; uriTransformers?: ServiceConfig[]; i18n?: I18NConfig; coreProxy?: DirectToCoreProxy | null; unsafeEnableViewLinkCaching?: boolean; _isSsrCompilerEnabled?: boolean; } type RequiredPick = { [P in K]-?: T[P]; }; export type OnStartConfig = RequiredPick; export interface BuildOptions { target?: string; input?: string; output?: string; routes?: string[]; modules?: string[]; locales?: string[]; clean?: boolean; mode?: string; } export interface NormalizedLwrGlobalConfig extends Required> { routes: NormalizedLwrRoute[]; errorRoutes: NormalizedLwrErrorRoute[]; routeHandlers: NormalizedRouteHandlersConfig; assets: AssetConfig[]; lwrVersion: string; amdLoader: string; esmLoader: string; hooks: ServiceEntry[]; bundleProviders: ServiceEntry[]; moduleProviders: ServiceEntry[]; viewProviders: ServiceEntry[]; viewTransformers: ServiceEntry[]; resourceProviders: ServiceEntry[]; assetProviders: ServiceEntry[]; assetTransformers: ServiceEntry[]; uriTransformers: ServiceEntry[]; lwc: NormalizedLwcConfig; i18n: I18NConfig; } export interface StaticSiteGenerator { outputDir?: string; skipCleanOutputDir?: boolean; skipBaseDocumentGeneration?: boolean; _additionalRoutePaths?: string[]; _additionalModules?: string[]; } export interface ServerBuild { buildDir: string; appConfig: NormalizedLwrGlobalConfig; runtimeEnvironment: RuntimeEnvironment; globalData: GlobalData; hooks: HooksPlugin[]; services: Services; routeHandlers: RouteHandlers; } export interface Services { moduleProviders: ResolvedServiceEntry[]; bundleProviders: ResolvedServiceEntry[]; viewProviders: ResolvedServiceEntry[]; viewTransformers: ResolvedServiceEntry[]; resourceProviders: ResolvedServiceEntry[]; assetProviders: ResolvedServiceEntry[]; assetTransformers: ResolvedServiceEntry[]; uriTransformers: ResolvedServiceEntry[]; } export interface RouteHandlers { [id: string]: RouteHandlerFunction; } interface AssetConfigCommon { urlPath?: string; alias?: string; } export interface AssetDirConfig extends AssetConfigCommon { dir: string; root?: boolean; } export interface AssetRootDirConfig extends AssetDirConfig { dir: string; root: true; } export interface AssetFileConfig extends AssetConfigCommon { file: string; } export type AssetConfig = AssetRootDirConfig | AssetDirConfig | AssetFileConfig; export interface LwcConfig { modules: ResolverModuleRecord[]; interchangeable?: string[]; interchangeableModules?: InterchangeableModuleRecord[]; } export type InterchangeableModuleMap = Map>; export interface NormalizedLwcConfig extends Omit { interchangeableModulesMap?: InterchangeableModuleMap; } export type ServiceEntry = [string, any?]; export type ServiceConfig = string | ServiceEntry; export type ResolvedServiceEntry = [ServiceCtor, any?]; export interface BundleConfig { exclude?: string[]; UNSAFE_lwrDefaultExclude?: string[]; external?: Record; alias?: Record; groups?: BundleGroups; } export interface ModuleRegistryConfig { bundleConfig: BundleConfig; } export interface BundleConfigOverrides extends BundleConfig { appendExcludes?: boolean; } export type BundleGroups = Record; export type Environment = string; export interface EnvironmentConfig { default?: Environment; supported?: Environment[]; } export interface AliasModuleRecord { name: string; path: string; } export interface DirModuleRecord { dir: string; } export interface NpmModuleRecord { npm: string; map?: { [key: string]: string; }; } export declare type ResolverModuleRecord = AliasModuleRecord | DirModuleRecord | NpmModuleRecord; export interface InterchangeableModuleRecord { context: string; modules: { [target: string]: string; }; } export interface Instrumentation { flush(): void; } export interface HooksPlugin { /** * Programmatically modify application and runtime configurations. * * @remarks * These hooks are invoked both at build time and runtime for Express and Koa(not MRT). * * During server build, config hooks are invoked prior to static site generation * and server bundling. * * For the `createServer`(ie. Express/Koa) runtime, these config hooks are invoked before all other hooks * during server context initialization * * For the `createHandler`(ie. MRT Serverless Express) runtime, these config hooks are NOT invoked. This runtime does * not support asynchronous execution during initialization. These hooks MUST be ran during * the server build. * */ initConfigs?: (lwrConfig: NormalizedLwrGlobalConfig, dataConfig: GlobalData, runtimeConfig: RuntimeEnvironment) => Promise | void; /** * Setup instrumentation utilities * * @remarks * - When running LWR server, these hooks are invoked after `initConfigs` hooks and before `onStart` hooks * - When running LWR handler, these hooks are invoked before config normalization and `onStart` hooks */ initInstrumentation?: () => Instrumentation; /** * Set a subset of LWR Configuration at runtime. Works in mrt * * @remarks * These hooks are invoked ONLY at runtime. * * For the `createServer` runtime, these hooks are invoked AFTER config hooks. * * For the `createHandler` runtime, these hooks are invoked during server context initialization. */ onStart?: (config: OnStartConfig) => void; /** * * Attach instantiated route handlers, providers, and transformers directly to the server context. * * @remarks * This is a temporary hook to enable a tactical solution for LWR@MRT local development * */ setupServerContext?: (context: ServerContext, startHooks: HooksPlugin[]) => Promise | void; } export interface Locale { id: string; fallback?: string; } export interface I18NConfig { defaultLocale: string; locales: Locale[]; uriPattern?: UriPattern; defaultRedirectParams?: Record; } export type UriPattern = undefined | 'path-prefix'; export interface PreloadResources { patterns: PreloadResourcePatterns[]; } export interface PreloadResourcePatterns { match: string | string[]; attributes?: Record; readonly dependent?: Dependent; } export interface Dependent { readonly value: string; readonly attributes?: Record; } export {}; //# sourceMappingURL=config.d.ts.map