import { AsyncAPIDocumentInterface } from '@asyncapi/parser'; import { MessageCodegenOptions } from './message-codegen-options'; /** * Processes AsyncAPI document and generates Typescript classes from it. * Generated output: * - message payloads will be transformed into Typescript types and bundled JSON schemas * - channels information will be used to generate MessagingSettings, that can be used to configure RabbitMQ connection. * @param inputDir - Path to input directory - AsyncAPI document root. * @param filePattern - Regular expression that matches suitable input files. * @param outputDir - Path to output directory - output root. */ export declare class Codegen { private readonly schemaRoot; private readonly filePattern; private readonly outputRoot; private readonly typesOutputRoot; private readonly schemasOutputRoot; private readonly messagingSettingsOutputRoot; constructor(options: MessageCodegenOptions); run(): Promise; /** * Recursively walks a schemas directory and generates TS + bundled JSON schema files. * @param dir - Directory to walk. */ walk(dir: string): Promise; /** * Builds a path for the generated TS file from an input JSON schema path, retains directory structure. * @param outputPath - output directory. * @param typeName - Name of the type. */ buildTsOutPath(outputPath: string, typeName: string): string; /** * Builds a path for the bundled JSON schema file from an input JSON schema path, retains directory structure. * @param outputPath - output directory. * @param typeName - Name of the type. */ buildSchemaOutPath(outputPath: string, typeName: string): string; /** * Generates TS interfaces and JSON schemas from AsyncAPI schema. * @param asyncApiFile - path to AsyncAPI document */ processAsyncAPIDocument(asyncApiFile: string): Promise; /** * Export all TS models from AsyncAPI document * @param asyncAPIDocument - AsyncAPI Document object * @param outputPath - output path for generated files */ exportTsModels(asyncAPIDocument: AsyncAPIDocumentInterface, outputPath: string): Promise; /** * Export all JSON Schemas from AsyncAPI document * @param asyncAPIDocument - AsyncAPI Document object * @param outputPath - output path for generated files */ exportSchemas(asyncAPIDocument: AsyncAPIDocumentInterface, outputPath: string): Promise; /** * Export all AsyncAPI document channels to Messaging Settings * @param asyncAPIDocument - AsyncAPI Document object * @param outputPath - output path for generated files */ exportSettings(asyncAPIDocument: AsyncAPIDocumentInterface, outputPath: string): Promise; /** * Generate Messaging Settings based on Channels data. * @param serviceId - service identifier * @param serviceTitle - service title * @param channelsData - AsyncAPI channels information * @param outputPath - output path for generated files */ generateMessagingSettings(serviceId: string, serviceTitle: string, channelsData: ChannelData[], outputPath: string): Promise; /** * Create new Messaging Settings file. * @param isMultiTenant - is file with multi tenant settings, or not * @param serviceId - service Identifier * @param serviceTitle - service Title * @param channelsData - AsyncAPI channels information * @param outputPath - output path for generated files */ createMessagingSettingFile(isMultiTenant: boolean, serviceId: string, serviceTitle: string, channelsData: ChannelData[], outputPath: string): Promise; /** * Create Messaging Settings property from Channel Data. * @param channelData - AsyncAPI channel information * @param settingsClassName - class name of messaging setting * @param isCommonService - flag to indicate if it's for `AX_COMMON_SERVICE_ID` */ createMessagingSettingProperty(channelData: ChannelData, settingsClassName: string, isCommonService: boolean): string; /** * Bundles a JSON schema into a self-contained file by including all external refs. * @param jsonSchema - Schema object. * @param outPath - Output JSON schema path. */ bundleSchema(jsonSchema: unknown, outPath: string): Promise; /** * Generates a barrel index.ts for all modules inside `outPath`. * In addition it generates a schemas enum for the included modules to make it easier to map them to bundled JSON schemas. * @param files - Files to roll up. * @param dirs - Directories to roll up. * @param outPath - Path where to write `index.ts`. */ barrelExportTs(files: string[], dirs: string[], outPath: string): Promise; /** * Generates a barrel index.ts for all Messaging Settings inside `outPath`. * @param files - Files to roll up. * @param dirs - Directories to roll up. * @param outPath - Path where to write `index.ts`. */ barrelExportSettings(files: string[], dirs: string[], outPath: string): Promise; /** * Generates a barrel index.ts for all JSON schemas inside `outPath`. * @param files - Files to roll up. * @param dirs - Directories to roll up. * @param outPath - Path where to write `index.ts`. */ barrelExportSchema(files: string[], dirs: string[], outPath: string): Promise; /** * Converts a generated TS path to a corresponding JSON schema path. * @param tsFile - Path to a generated TS file. */ tsPathToSchemaPath(tsFile: string): string; } /** * Metadata of channels for settings generation. */ interface ChannelData { /** Channel routing key */ routingKey: string; /** Channel queue */ queueName: string; /** Channel model */ payloadName: string; /** Accepted Action*/ acceptedAction: 'subscribe' | 'publish'; /** Channel multi tenancy */ isMultiTenant: boolean; /** Aggregate root type of the channel message */ aggregateType: string; /** * Aggregate root ID field of the channel message or "UNDEFINED_ID" if no ID * is known for this message or "MULTIPLE_IDS" if the message contains * multiple IDs. */ aggregateIdField: string; } export {};