import { logging } from '@angular-devkit/core'; import type { CategoryDescription } from '@o3r/core'; import * as ts from 'typescript'; import type { ConfigProperty } from '@o3r/components'; /** Information extracted from a configuration file */ export interface ConfigurationInformation { /** Name of the configuration */ name: string; /** Title of the configuration */ title?: string; /** Description of the configuration */ description?: string; /** Configuration tags */ tags?: string[]; /** Configuration categories' descriptions */ categories?: CategoryDescription[]; /** * Determine if the configuration is runtime * @note the current implementation set this value as `undefined` for all the components (only AppBuildConfiguration is set to `false` and AppRuntimeConfiguration is set to `true`) */ runtime?: boolean; /** Determine if the configuration is an application configuration */ isApplicationConfig?: boolean; /** List of properties of the configuration */ properties: ConfigProperty[]; } /** Information that represents a union type string literal that will be used for configuration */ export interface UnionTypeStringLiteral { /** The name of the union type */ name: string; /** The possible options extracted from the string literal values */ choices: string[]; } /** Wrapper for the configuration, to add nested configuration */ export interface ConfigurationInformationWrapper { configurationInformation?: ConfigurationInformation; unionTypeStringLiteral: UnionTypeStringLiteral[]; nestedConfiguration: ConfigurationInformation[]; } /** Configuration file extractor */ export declare class ComponentConfigExtractor { private readonly libraryName; private readonly strictMode; source: ts.SourceFile; private readonly logger; filePath: string; checker: ts.TypeChecker; libraries: string[]; /** List of all the configuration patterns that can be used inside a Page/Block or Component */ readonly COMPONENT_CONFIGURATION_INTERFACES: RegExp[]; /** List of all the configuration patterns */ readonly CONFIGURATION_INTERFACES: RegExp[]; /** String to display in case of unknown type */ readonly DEFAULT_UNKNOWN_TYPE = "unknown"; /** Parser of configuration doc */ private readonly configDocParser; /** * Configuration file extractor constructor * @param libraryName * @param strictMode * @param source Typescript SourceFile node of the file * @param logger Logger * @param filePath Path to the file to extract the configuration from * @param checker Typescript TypeChecker of the program * @param libraries */ constructor(libraryName: string, strictMode: boolean, source: ts.SourceFile, logger: logging.LoggerApi, filePath: string, checker: ts.TypeChecker, libraries?: string[]); /** * Handle error cases depending on the mode: throwing errors or logging warnings * @param message the warning message to be logged * @param errorMessage the error message to be thrown. If not provided, the warning one will be used */ private handleErrorCases; /** * Verifies if an UnionType has strings elements. * @param node Typescript node to be checked */ private hasStringElements; /** * Returns the name of the symbol * @param symbol */ private getSymbolName; /** * Get the type from a property * If the type refers to a NestedConfiguration type, then it will be replaced with element * and a reference to the object will be returned * @param node Typescript node to extract the data from * @param configurationWrapper the configuration wrapper containing nestedConfig and union type strings * @param source */ private getTypeFromNode; /** * Extract the property data from an interface property signature * @param propertyNode Node to extract the data from * @param configurationWrapper the configuration wrapper containing nestedConfig and union type strings * @param source */ private extractPropertySignatureData; /** * Extract the possible options in case of an enum node * @param node Node to extract the data from * @param source */ private extractOptionsForEnum; /** * Get the configuration properties from a given interface node * @param interfaceNode Node of a typescript interface * @param configurationWrapper * @param source */ private getPropertiesFromConfigurationInterface; /** * Extract the default value of a configuration interface * @param variableNode Typescript node of the default constant implementing the interface * @param configurationInformationWrapper Configuration object extracted from the interface */ private getDefaultValueFromConfigurationInterface; /** * Remove all quotation marks from the input string to prevent any ""my_string"" and "'my_string'" in the metadata file * @param inputString that needs to be format */ private removeQuotationMarks; /** * Check is name is typed as a known nested configuration * @param propertyName * @param nestedConfiguration List of nested configuration * @param libraries */ private isTypedNestedConfiguration; /** * This function checks if the interface name given as parameter is extended by the interface node * @param interfaceDeclaration * @param extendedInterfaceNames * @param source */ private isExtending; /** * Fill the nested configuration with default values * @param nestedConfigurationInformation */ private fillNestedConfigurationDefaultValues; /** * Collect nested configuration information * @param source */ private collectNestedConfiguration; /** * Extract the configuration of a typescript file */ extract(): ConfigurationInformationWrapper; } //# sourceMappingURL=component-config-extractor.d.ts.map