UNPKG

@autorest/modelerfour

Version:
70 lines 2.47 kB
import { Languages } from "@autorest/codemodel"; import { Session } from "@autorest/extension-base"; import { Styler } from "@azure-tools/codegen"; export declare function getNameOptions(typeName: string, components: Array<string>): string[]; interface SetNameOptions { /** * Remove consecutive duplicate words in the name. * @example "FooBarBarSomething" -> "FooBarSomething" */ removeDuplicates?: boolean; /** * Error message if a name is empty. */ nameEmptyErrorMessage?: string; } export interface Nameable { language: Languages; } export declare class NamingService { private session; constructor(session: Session<unknown>); setName(thing: Nameable, styler: Styler, defaultValue: string, overrides: Record<string, string>, options?: SetNameOptions): void; setNameAllowEmpty(thing: Nameable, styler: Styler, defaultValue: string, overrides: Record<string, string>, options?: SetNameOptions): void; } export declare function isUnassigned(value: string): boolean; export interface ScopeNamerOptions { deduplicateNames?: boolean; overrides?: Record<string, string>; } /** * Class that will style and resolve unique names for entities in the same scope. */ export declare class ScopeNamer { private session; private options; private names; constructor(session: Session<unknown>, options: ScopeNamerOptions); /** * Add a nameable entity to be styled and named. * @param entity Nameable entity. * @param styler Styler to use to render name. * @param defaultName Default name in case entity doesn't have any specified. */ add(entity: Nameable, styler: Styler, defaultName?: string): void; /** * Returns true if the name is already used in this scope. * @param name Name to check * @returns Boolean */ isUsed(name: string): boolean; /** * Trigger the renaming process. * Will go over all the entity and find best possible names. */ process(): void; /** * 1st pass of the name resolving where it tries to simplify names with duplicate consecutive words. */ private processSimplifyNames; /** * 2nd pass of the name resolving where it will deduplicate names used twice. */ private deduplicateNames; /** * Tries to find a new compatible name for the given schema. */ private deduplicateSchemaName; } export {}; //# sourceMappingURL=naming-utils.d.ts.map