import type { GeneratedDefinition, GeneratedValue } from './GeneratedValue.js'; import type { ContentSettings } from './ContentSettings.js'; import type { IdentifierBase } from './IdentifierBase.js'; /** * Constructor arguments for {@link Inserted}. * * @template V - The type of generated value * @template EnrichmentType - Optional enrichment data type */ type ConstructorArgs = { /** Content settings including identifier and export path */ settings: ContentSettings; /** The generated definition with its value */ definition: GeneratedDefinition; }; /** * Represents a successfully inserted generator artifact in the SKMTC DSL system. * * The `Inserted` class is returned when generators are inserted into the generation * context, providing access to the generated content, metadata, and configuration. * It acts as a bridge between the insertion process and the consuming code that * needs to reference or use the generated artifacts. * * This class provides type-safe access to generated values with proper handling * of both forced and lazy generation modes, ensuring the correct optionality * of the generated content based on the generation strategy used. * * ## Key Features * * - **Type Safety**: Generic parameters preserve exact types from generators * - **Metadata Access**: Provides access to identifiers, export paths, and settings * - **Value Extraction**: Type-safe value extraction with proper optionality * - **Enrichment Support**: Full support for custom enrichment data types * * @template V - The type of generated value (preserves generator output type) * @template EnrichmentType - Optional type for custom enrichment data * * @example Basic usage with forced generation * ```typescript * import { Inserted } from '@skmtc/core'; * * class MyGenerator extends ModelProjectionBase { * generate(): Definition { * // Insert a related model with forced generation * const userModel = this.insertModel( * new UserModelGenerator({ ... }), * 'User' * ); // Returns Inserted * * // Access the generated value (guaranteed to be present) * const userTypeName = userModel.toValue(); // UserModelValue (not undefined) * const exportPath = userModel.toExportPath(); // './src/models.ts' * const identifier = userModel.toName(); // 'User' * * return new Definition({ * identifier: createType(this.refName), * value: { * generatorKey: this.generatorKey, * content: `export interface Order { user: ${userTypeName}; }` * } * }); * } * } * ``` */ export declare class Inserted { /** Content settings including identifier and export path */ settings: ContentSettings; /** The generated definition with its value */ definition: GeneratedDefinition; /** * Creates a new Inserted instance. * * @param args - Insertion configuration * @param args.settings - Content settings with identifier and export path * @param args.definition - The generated definition containing the value */ constructor({ settings, definition }: ConstructorArgs); /** * Gets the name of the inserted artifact. * * This method returns the string name from the identifier, which is commonly * used when referencing the generated artifact in code or templates. * * @returns The name of the inserted artifact * * @example * ```typescript * const userModel = this.insertModel(generator, 'User'); * const name = userModel.toName(); // 'User' * * // Use in generated code * const code = `interface Order { user: ${name}; }`; * ``` */ toName(): string; /** * Gets the full identifier of the inserted artifact. * * This method returns the complete `IdentifierBase` object, which carries * the name and (language-neutrally) the type annotation. Useful when you * need access to the type annotation or export flag. * * @returns The complete `IdentifierBase` object * * @example * ```typescript * const model = this.insertModel(generator, 'User'); * const identifier = model.toIdentifier(); * * console.log(identifier.name); // 'User' * console.log(identifier.typeName); // optional type annotation * console.log(identifier.exported); // export flag * ``` */ toIdentifier(): IdentifierBase; /** * Gets the export path where the artifact was generated. * * This method returns the file path where the generated artifact is located, * which is useful for creating import statements or understanding the file * structure of generated code. * * @returns The export path of the generated artifact * * @example * ```typescript * const userModel = this.insertModel(generator, 'User'); * const exportPath = userModel.toExportPath(); // './src/models/User.ts' * * // Create import statement * const importStmt = `import { User } from '${exportPath}';`; * ``` */ toExportPath(): string; /** * Gets the generated value from the inserted artifact. * * This method returns the actual generated content with proper type safety * * @returns The generated value * * @example * ```typescript * const userModel = this.insertModel(generator, 'User'); * const value = userModel.toValue(); // UserModelValue * * // Use the generated value * const code = `type OrderUser = ${value};`; * ``` */ toValue(): V; } export {};