Kind: Constant
Source: packages/common/module-utils/constants.ts
Part of: Common
List of keys that are specific to ConfigurableModuleAsyncOptions and should be excluded when extracting user-defined extras.
ASYNC_OPTIONS_METADATA_KEYS defines the option property names reserved by ConfigurableModuleAsyncOptions. These keys are excluded when the module utilities extract user-defined “extras,” ensuring framework configuration fields such as factories and imports are not treated as custom module options.
Definition
ts[
'useFactory',
'useClass',
'useExisting',
'inject',
'imports',
'provideInjectionTokensFrom',
] as const
Value
ts[
'useFactory',
'useClass',
'useExisting',
'inject',
'imports',
'provideInjectionTokensFrom',
] as const
Diagram
mermaidgraph LR A[ConfigurableModuleAsyncOptions] --> B[Read option keys] B --> C{Key in ASYNC_OPTIONS_METADATA_KEYS?} C -->|Yes| D[Keep as framework async metadata] C -->|No| E[Extract as user-defined extras]
Usage
tsimport { ASYNC_OPTIONS_METADATA_KEYS } from './constants';
const asyncOptions = {
imports: [ConfigModule],
inject: [ConfigService],
useFactory: (configService: ConfigService) => ({
apiUrl: configService.get('API_URL'),
}),
isGlobal: true,
retryAttempts: 3,
};
const extras = Object.fromEntries(
Object.entries(asyncOptions).filter(
([key]) => !ASYNC_OPTIONS_METADATA_KEYS.includes(key),
),
);
// { isGlobal: true, retryAttempts: 3 }
console.log(extras);
AI Coding Instructions
- Treat this constant as the source of truth for async module option keys owned by the framework.
- Add new keys here when extending
ConfigurableModuleAsyncOptionswith metadata that must not become user-defined extras. - Do not include keys intended to be forwarded to the generated module’s custom options.
- Preserve the key names exactly as they appear in the async options interface and extraction logic.
- Update related option-extraction tests whenever this list changes.
Was this page helpful?